Skip to content

refactor: route all chromadb access through ChromaBackend (v4 prep)#852

Merged
igorls merged 1 commit intodevelopfrom
release/v4-prep
Apr 14, 2026
Merged

refactor: route all chromadb access through ChromaBackend (v4 prep)#852
igorls merged 1 commit intodevelopfrom
release/v4-prep

Conversation

@igorls
Copy link
Copy Markdown
Member

@igorls igorls commented Apr 14, 2026

Summary

Prerequisite for RFC 001 (storage backend plugin spec, #743) and PalaceStore. Removes every direct import chromadb outside the ChromaDB backend itself so core modules depend only on the backend abstraction layer.

With this in, RFC 001 can be enforced and third-party backends — starting with PalaceStore — can ship as plugins without touching core modules.

What changed

  • backends/base.py — added update() to the BaseCollection contract.
  • backends/chroma.py — per-instance client cache, plus new methods: make_client, backend_version, get_or_create_collection, delete_collection, create_collection, update.
  • mcp_server.py, dedup.py, repair.py, cli.py, migrate.py — all chromadb access routed through ChromaBackend.
  • tests/test_cli.py, test_dedup.py, test_repair.py — patch ChromaBackend instead of chromadb.

Only remaining import chromadb lives in mempalace/backends/chroma.py (as intended).

v4 roadmap (for context)

  1. This PR — de-hardcode chromadb (prerequisite).
  2. ⏭ Land RFC 001 (docs: RFC 001 — storage backend plugin specification #743) — formalize the plugin contract.
  3. ⏭ Land PalaceStore (POC: bespoke PalaceStore storage layer (drop-in ChromaDB replacement) #643) as an opt-in plugin; ChromaDB stays default. Field-test it in real palaces.
  4. v4.0 — flip default to PalaceStore, extract ChromaDB to pip install mempalace-chromadb, ship an explicit migrate --to palace_store (no auto-migration — safer for users' data).

Test plan

  • uv run pytest tests/ --ignore=tests/benchmarks — 864/864 pass
  • uv run ruff check . clean
  • uvx --from 'ruff>=0.4.0,<0.5' ruff format --check . clean (CI-pinned ruff)
  • Grep confirms: only backends/chroma.py imports chromadb
  • CI green on all platforms

Prerequisite for RFC 001 (plugin spec, #743). Removes every direct
`import chromadb` outside the ChromaDB backend itself so the core
modules depend only on the backend abstraction layer.

Extends ChromaBackend with make_client, get_or_create_collection,
delete_collection, create_collection, and backend_version. Adds
update() to the BaseCollection contract. Non-backend callers
(mcp_server, dedup, repair, migrate, cli) now go through the
abstraction; tests patch ChromaBackend instead of chromadb.

With this landed, the RFC 001 spec can be enforced and PalaceStore
(#643) can ship as a plugin without touching core modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant