LearnNewsExamplesServices
Frontmatter
id10867
titleMock Memory Core Chroma collections in Playwright unit tests
stateClosed
labels
bugaitesting
assigneesneo-gemini-3-1-pro
createdAtMay 7, 2026, 3:23 AM
updatedAtMay 7, 2026, 3:55 AM
githubUrlhttps://github.com/neomjs/neo/issues/10867
authorneo-gemini-3-1-pro
commentsCount0
parentIssue10845
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMay 7, 2026, 3:55 AM

Mock Memory Core Chroma collections in Playwright unit tests

Closedbugaitesting
neo-gemini-3-1-pro
neo-gemini-3-1-pro commented on May 7, 2026, 3:23 AM

Context

Following the recent P0 Memory Core wipe incident, forensic analysis revealed that the wipe was triggered by Playwright unit tests executing destructive cleanup operations on canonical production collections.

The Problem

While several test files correctly isolate their SQLite paths via aiConfig.storagePaths.graph, they fail to override the Chroma collection names (aiConfig.collections.memory and aiConfig.collections.session). Consequently, when cleanupChromaManager() is invoked during test teardown, it reads the default canonical names and deletes the production databases.

The Architectural Reality

The offending test files include:

  • test/playwright/unit/ai/mcp/server/memory-core/services/GraphService.spec.mjs
  • test/playwright/unit/ai/mcp/server/memory-core/services/FileSystemIngestor.spec.mjs
  • test/playwright/unit/ai/mcp/server/memory-core/services/PermissionService.spec.mjs
  • test/playwright/unit/ai/mcp/server/memory-core/services/DatabaseService.backupPath.spec.mjs
  • test/playwright/unit/ai/mcp/server/memory-core/services/WakeSubscriptionService.spec.mjs
  • test/playwright/unit/ai/mcp/server/memory-core/services/CoalescingEngineService.spec.mjs

By contrast, SessionService.spec.mjs properly isolates these collections in its beforeAll block.

The Fix

  1. Update the beforeAll blocks in the 6 offending test files to assign process-isolated names to aiConfig.collections.memory and aiConfig.collections.session.
  2. Add a hardcoded safety check in test/playwright/unit/ai/mcp/server/memory-core/util.mjs to throw an error if cleanupChromaManager() is called against neo-agent-memory or neo-agent-sessions.

Acceptance Criteria

  • GraphService.spec.mjs properly mocks Chroma collection names.
  • FileSystemIngestor.spec.mjs properly mocks Chroma collection names.
  • PermissionService.spec.mjs properly mocks Chroma collection names.
  • DatabaseService.backupPath.spec.mjs properly mocks Chroma collection names.
  • WakeSubscriptionService.spec.mjs properly mocks Chroma collection names.
  • CoalescingEngineService.spec.mjs properly mocks Chroma collection names.
  • util.mjs cleanupChromaManager() includes a hardcoded failsafe against canonical collection names.

Out of Scope

  • The universal destructive-operation guard for AI data stores, which is covered by #10845.

Related

Origin Session ID: e32b637d-4a13-4bfa-8518-974a31772835

tobiu closed this issue on May 7, 2026, 3:55 AM
tobiu referenced in commit aa506e0 - "test(memory-core): mock Chroma collections to prevent data wipes (#10867) (#10868) on May 7, 2026, 3:55 AM