fix(mcp): purge stale closets on drawer update and delete - #2355
Open
AmirF194 wants to merge 1 commit into
Open
Conversation
Member
|
Thanks for working on this fix! The logic for invalidating stale closets on drawer update/delete looks great and directly addresses #2325. Could you please rebase your branch against the latest |
Closets are mined once from a source file's content and only rebuilt by re-mining that file. tool_update_drawer and tool_delete_drawer never touched them, so a corrected or deleted drawer left a closet quoting the old text indefinitely, and search boosts ranking by source_file, so a stale closet could outrank the corrected drawer. Purge the matching source's closets through _purge_source_closets, the helper delete_by_source already uses for this reason. update_drawer purges only when content changes; a wing/room move alone leaves the quoted text correct. Fixes MemPalace#2325
AmirF194
force-pushed
the
fix/2325-drawer-mutation-closet-purge
branch
from
August 24, 2026 23:15
79e9658 to
f92095e
Compare
Author
|
Rebased onto the latest develop, force-pushed. CI is running now; will follow up if anything comes back red. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closets (the AAAK search-index layer) are mined once from a source file's raw content and only ever rebuilt by re-mining that file. Neither
tool_update_drawernortool_delete_drawertouches them, so a drawer corrected or deleted in place leaves its closet quoting the old text indefinitely.search_memoriesboosts ranking bysource_fileand previews the closet document verbatim, so a stale closet can outrank the corrected drawer, worst case a retracted instruction stays the top search result.Both tools now purge the matching source's closets through
_purge_source_closets, the helperdelete_by_sourcealready uses for this exact reason (#1722), rather than rebuild them: closets are LLM-derived from file content, and neither tool has the source file or the budget to regenerate them inline.delete_drawerpurges unconditionally;update_drawerpurges only whencontentchanges, since a wing/room move alone leaves the quoted text correct.This implements the issue's first, cheapest direction: invalidate on mutation. Rebuilding stale closets from the stored drawers (the issue's second direction) is a separate, larger change and is not attempted here.
How to test
develop(KeyError: 'closets_deleted') and pass on this branch.python -m pytest tests/ -von Python 3.9 and 3.13 in clean containers: 373 passed, 3 pre-existing failures unrelated to this change (root-ownedchmod 0o000tests no-op under a root test runner; the same 3 fail on unmodifieddevelop).Checklist
python -m pytest tests/ -v)ruff check .)Fixes #2325