Chroma Vector DB Backfill Fix
Fixes the Chroma backfill system to correctly sync all SQLite observations into the vector database on worker startup.
Bug Fixes
-
Backfill all projects on startup —
backfillAllProjects()now runs on worker startup, iterating all projects in SQLite and syncing missing observations to Chroma. PreviouslyensureBackfilled()existed but was never called, leaving Chroma with incomplete data after cache clears. -
Fixed critical collection routing bug — Backfill now uses the shared
cm__claude-memcollection (matching how DatabaseManager and SearchManager operate) instead of creating per-project orphan collections that no search path reads from. -
Hardened collection name sanitization — Project names with special characters (e.g., "YC Stuff") are sanitized for Chroma's naming constraints, including stripping trailing non-alphanumeric characters.
-
Eliminated shared mutable state —
ensureBackfilled()andgetExistingChromaIds()now accept project as a parameter instead of mutating instance state, keeping a single Chroma connection while avoiding fragile property mutation across iterations. -
Chroma readiness guard — Backfill waits for Chroma server readiness before running, preventing spurious error logs when Chroma fails to start.
Changed Files
src/services/sync/ChromaSync.ts— Core backfill logic, sanitization, parameter passingsrc/services/worker-service.ts— Startup backfill trigger + readiness guardsrc/utils/logger.ts— AddedCHROMA_SYNClog component