feat(search): expose drawer_id in mempalace_search results#1219
feat(search): expose drawer_id in mempalace_search results#1219pepo72 wants to merge 2 commits intoMemPalace:developfrom
Conversation
Closes MemPalace#1026. Without drawer_id, callers must drop into SQLite to find a drawer's ID before calling delete_drawer/get_drawer/update_drawer. Chroma already returns ids on every query — just thread it through search_memories into each result entry.
|
Independent confirmation — landed the same change in our fork at We extended it to two adjacent payloads with the same "consumer wants to follow up by ID" problem: One tip from cherry-picking ours: a couple existing test mocks omit ids = _first_or_empty(drawer_results, "ids")
if not ids and drawer_results.get("documents"):
ids = [None] * len(_first_or_empty(drawer_results, "documents"))Production chromadb always returns ids — purely a test-fixture compatibility shim, but might be worth including here to avoid mock churn during review. Closes #1026 either way. Update 2026-04-27: going with the follow-up path — your PR can land narrow, and I'll file the diary + recovery slices as a small separate PR after. No need to expand scope here. |
Production chromadb always returns ids, but some existing test mocks omit them in mock_col.query.return_value. zip() truncates to the shortest input, collapsing those fixtures to zero hits once ids is threaded into the loop. Pad with None entries when ids is empty but documents are present.
|
Thanks for the review and the heads-up on the test mocks — added the defensive pad in 490e5b1. Happy to land narrow as suggested; looking forward to your follow-up PR for the diary and recovery slices. |
Closes #1026.
Problem
mempalace_searchreturnstext,wing,room,source_file,similarityetc. but notdrawer_id. Any caller that wants to follow up withmempalace_delete_drawer,mempalace_get_drawer, ormempalace_update_drawer(all of which requiredrawer_id) has to drop into SQLite and reverse-lookup by content/metadata. This breaks the MCP abstraction and turns simple cleanup workflows into bespoke scripts.Fix
Chroma's
query()already returnsidson every result. Thread it throughsearch_memories(searcher.py) into each result entry asdrawer_id. Three lines.Diff
Test
Smoke-tested against a real palace (~1100 drawers) on
develop-equivalent v3.3.3:Scope
Intentionally minimal — no rename, no schema, no behavior change beyond adding the field. Re-rank / hydration / closet-boost paths preserve the new key (they only
pop_sort_key/_source_file_full/_chunk_index).