Context
Split from #12331 (unit-test store isolation). #12331 ships the daemon-spec os.tmpdir() isolation + the purgeTestCollections reclaimer (parts 1 + 3). This ticket is the deferred part 2: by-construction ephemeral isolation of the unit-test ChromaDB namespace.
The Problem
Under UNIT_TEST_MODE, the memory-core config names test collections test-memory-* / test-session-* (config.template.mjs:119-120), but they still land in the same default_tenant/default_database as production. afterAll cleanup handles the happy path; interrupted/Ctrl-C/CI-cancel runs and bare-npx bypasses leak orphans into the prod namespace (the 1,281 backlog #12331's purge clears). The purge is a reclaimer, not prevention — orphans re-accumulate between runs.
The Fix
Route the unit-test Chroma client to an isolated tenant/database (chroma multi-tenancy) under UNIT_TEST_MODE, so test collections never enter default_tenant/default_database and the whole test namespace is droppable wholesale. Prod path stays default_tenant/default_database (unchanged). This is the chroma analogue of the graph store's already-correct :memory: isolation (config.template.mjs:112).
The Architectural Reality
ai/services/memory-core/managers/ChromaManager.mjs:82 — new ChromaClient({host, port, ssl: false}); add tenant/database under UNIT_TEST_MODE. The test db must be ensured-to-exist on connect (chroma 3.x admin/create-database API) — confirm the exact mechanism (tenant vs database vs throwaway persist-dir) against chromadb 3.3.1 at implementation.
ai/scripts/maintenance/purgeTestCollections.mjs (from #12331) — once isolation lands, the purge can drop the whole test tenant/db instead of enumerating test-* names.
- Sensitive surface: this mutates the prod chroma connect path (UNIT_TEST_MODE-guarded). Deserves its own focused PR + careful prod-regression verification (the reason it was split from #12331).
Acceptance Criteria
Related
Origin Session ID: da9a6007-1250-4363-8c15-dff69eccb3be
Retrieval Hint: "chroma unit-test ephemeral tenant database isolation UNIT_TEST_MODE default_tenant"
Context
Split from #12331 (unit-test store isolation). #12331 ships the daemon-spec
os.tmpdir()isolation + thepurgeTestCollectionsreclaimer (parts 1 + 3). This ticket is the deferred part 2: by-construction ephemeral isolation of the unit-test ChromaDB namespace.The Problem
Under
UNIT_TEST_MODE, the memory-core config names test collectionstest-memory-*/test-session-*(config.template.mjs:119-120), but they still land in the samedefault_tenant/default_databaseas production.afterAllcleanup handles the happy path; interrupted/Ctrl-C/CI-cancel runs and bare-npxbypasses leak orphans into the prod namespace (the 1,281 backlog #12331's purge clears). The purge is a reclaimer, not prevention — orphans re-accumulate between runs.The Fix
Route the unit-test Chroma client to an isolated tenant/database (chroma multi-tenancy) under
UNIT_TEST_MODE, so test collections never enterdefault_tenant/default_databaseand the whole test namespace is droppable wholesale. Prod path staysdefault_tenant/default_database(unchanged). This is the chroma analogue of the graph store's already-correct:memory:isolation (config.template.mjs:112).The Architectural Reality
ai/services/memory-core/managers/ChromaManager.mjs:82—new ChromaClient({host, port, ssl: false}); addtenant/databaseunderUNIT_TEST_MODE. The test db must be ensured-to-exist on connect (chroma 3.x admin/create-database API) — confirm the exact mechanism (tenant vs database vs throwaway persist-dir) against chromadb 3.3.1 at implementation.ai/scripts/maintenance/purgeTestCollections.mjs(from #12331) — once isolation lands, the purge can drop the whole test tenant/db instead of enumeratingtest-*names.Acceptance Criteria
UNIT_TEST_MODE, test collections resolve to a tenant/database distinct fromdefault_tenant/default_database(statically verifiable); no test run — including crashed/npx-bypassed — can create collections in the prod namespace.default_tenant/default_database); prod-wipe guards (DestructiveOperationGuard, FATALUNIT_TEST_MODEguard) intact.purgeTestCollectionscan drop the whole test namespace (in addition to the name-pattern path).Related
Origin Session ID: da9a6007-1250-4363-8c15-dff69eccb3be Retrieval Hint: "chroma unit-test ephemeral tenant database isolation UNIT_TEST_MODE default_tenant"