Skip to content

fix(chroma): read list_drawers and tunnels from sqlite, skip HNSW - #2314

Merged
igorls merged 2 commits into
developfrom
fix/chroma-sqlite-metadata-reads
Aug 20, 2026
Merged

fix(chroma): read list_drawers and tunnels from sqlite, skip HNSW#2314
igorls merged 2 commits into
developfrom
fix/chroma-sqlite-metadata-reads

Conversation

@igorls

@igorls igorls commented Aug 20, 2026

Copy link
Copy Markdown
Member

Yes — chroma can take the same shortcut sqlite_exact did: read loci from chroma.sqlite3, do not page col.get() / HNSW.

Measured on igorls-blade-15 (i7-8750H, chroma 1.7 GB, 165k drawers, develop 3.7.1):

Call Before
list_drawers no filter, limit=20 36.6 s
find_tunnels 29.7 s then Internal tool error
graph_stats 1.2 s (already had sqlite GROUP BY)
warm search 111–373 ms (HNSW is fine once loaded)

Changes

  • chroma.sqlite_list_id_metadata — ids + metadata + chroma:document from embedding_metadata, no vector index
  • chroma.sqlite_room_wing_hall_counts — shared grouped read for graph_stats and build_graph
  • build_graph() uses that path when MCP does not inject a collection (tests that pass col= keep paging)
  • find_tunnels / traverse no longer open the collection first

list_drawers and tunnels become sqlite scans; search still uses HNSW (that's the right tool).

Tests: TestReadTools graph_stats / find_tunnels / list_drawers sqlite tripwires + test_palace_graph.py.

On the i7-8750H chroma palace, list_drawers(limit=20) took 36s and
find_tunnels died at 30s because both paged col.get() and cold-loaded
the vector index. chroma.sqlite3 already has embedding_metadata.

- sqlite_list_id_metadata: ids + metadata + chroma:document without HNSW
- sqlite_room_wing_hall_counts shared with graph_stats
- build_graph uses that grouped read when no collection is injected
- find_tunnels/traverse no longer open the collection first

MCP tests assert the client paging path is not used.
@igorls
igorls requested a review from milla-jovovich as a code owner August 20, 2026 02:24
Copilot AI lite review requested due to automatic review settings August 20, 2026 02:24
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…o sql

Follow-up on the same palace. The metadata scan joined every
embedding_metadata row, and chroma:document lives in that table — so
list_drawers pulled the palace's entire verbatim text into memory to
render 20 previews, then filtered wing/room in Python after scanning
the whole collection.

Measured on the 1.7 GB / 165k-drawer chroma palace,
list_drawers(wing=..., limit=20):

  before  2.31 s, 1148 MB peak RSS
  after   0.01 s,   86 MB peak RSS

Unfiltered goes 1.61 s / 1162 MB -> 1.57 s / 894 MB.

- exclude chroma:document from the scan; hydrate the displayed page via
  sqlite_documents_for_ids (two indexed steps — embedding_id is only
  indexed under UNIQUE(segment_id, embedding_id), so a single join on it
  scans embedding_metadata: 5.7 s for one page)
- push the wing/room equality into SQL as a join per key
- decode cells through _metadata_cell_value with column probing, so
  bool_value is not silently dropped on newer chroma schemas
- grouped counts carry MAX(date), restoring find_tunnels' "recent",
  which the sqlite path had blanked (both backends)
- resolve the graph's sqlite reader from the configured backend instead
  of sniffing the palace dir, so a two-backend directory still raises
  BackendMismatchError instead of being silently picked
- find_tunnels/traverse fall back to the collection when sqlite cannot
  serve, so a missing palace reports "Chroma database missing" again
  rather than [] and "Room not found"

Tests: sql tripwires for the scan (no documents, filter pushed down,
id-scoped preview read), recent-from-sqlite, missing-palace diagnostics,
and backend-gating for the graph reader.
@igorls
igorls merged commit 570891e into develop Aug 20, 2026
9 checks passed
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.

2 participants