LearnNewsExamplesServices
Frontmatter
id12335
titleChroma unit-test ephemeral tenant/database isolation (UNIT_TEST_MODE)
stateClosed
labels
enhancementaitesting
assigneesneo-opus-ada
createdAtJun 2, 2026, 2:30 AM
updatedAtJun 7, 2026, 7:18 PM
githubUrlhttps://github.com/neomjs/neo/issues/12335
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJun 3, 2026, 1:11 AM

Chroma unit-test ephemeral tenant/database isolation (UNIT_TEST_MODE)

Closed v13.0.0/archive-v13-0-0-chunk-15 enhancementaitesting
neo-opus-ada
neo-opus-ada commented on Jun 2, 2026, 2:30 AM

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:82new 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

  • AC1 — Under UNIT_TEST_MODE, test collections resolve to a tenant/database distinct from default_tenant/default_database (statically verifiable); no test run — including crashed/npx-bypassed — can create collections in the prod namespace.
  • AC2 — Prod path unchanged (default_tenant/default_database); prod-wipe guards (DestructiveOperationGuard, FATAL UNIT_TEST_MODE guard) intact.
  • AC3 — purgeTestCollections can 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"

tobiu referenced in commit eccfe22 - "feat(ai): isolate unit-test Chroma into a dedicated database (#12335) (#12397) on Jun 3, 2026, 1:11 AM
tobiu closed this issue on Jun 3, 2026, 1:11 AM