Repository navigation
fix(memory): forget the older versions a forgotten memory superseded - #7269
Merged
Merged
Conversation
Forgetting a fact deleted only the current row; the versions it had replaced kept their full text on disk. forget() now walks the superseded_by chain and deletes each older version too, recording it as forgotten (word stems only when sensitive), in the same transaction. Closes #7266
Resolves the conflict with #7212 in MemoryStore.forget: the superseded-chain walk keeps main's sensitive argument, and if any version in the chain is sensitive every version is kept as stems only, so an unflagged old version can't leave a sensitive fact's words in forgotten. Adds tests for that, for a supersede cycle, and for forget_with_copies taking a copy's older versions with it.
Contributor
Author
|
Verdict: Approve Forgetting a memory now erases every older version it replaced, not just the current one. Before this, the earlier wording stayed on disk even after the user said "forget". The fix is correct and stays within one transaction, so a failure part-way leaves nothing half-erased. A replacement loop between two memories can't make it hang. Forgetting an old version leaves the newer one in place. The tests cover each of these cases, plus the sensitive-version and copy paths. No blocking issues. Both callers (the chat agent's 🔍 Technical details
|
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.
When the user forgot a fact that had replaced an older version, only the current version was erased. The older versions stayed on disk with their full text. Recall and the Memory page hid them, but they were still stored, which broke the promise that "forget" erases the fact. Now forget erases every older version too, and records each one as forgotten so it isn't learned again from old chats. A sensitive version is recorded as word stems only.
Closes #7266
Test plan
python -m pytest tests/unit/test_memory_forget_superseded.pypasses (2 of its 4 tests fail onmain)python util/lint.py --allpassespytest tests/unit -k "memory or forget": 2572 passed; 25 collection errors are modules this runner lacks,responses/matplotlib)~/.gaia/memory.dband confirm neither version is inknowledge🔍 Technical details
MemoryStore.forgetgathers the target plus every row that reaches it throughsuperseded_by, using a recursive CTE.UNIONrather thanUNION ALL, so a cycle (consolidation can link two rows either way) terminates. Each row is checked against the privileged-category rule, removed fromknowledge_ftsandknowledge, and written toforgotten(stems if sensitive), all in one transaction._faiss_remove(old_id)), and the index is rebuilt from active rows only.forget. The two changes are complementary.