fix: keep graph_add_memory entries past the 200-entry pruning cap - #38
Open
Hardik-369 wants to merge 1 commit into
Open
fix: keep graph_add_memory entries past the 200-entry pruning cap#38Hardik-369 wants to merge 1 commit into
Hardik-369 wants to merge 1 commit into
Conversation
graph_add_memory wrote entries with a type key and no created_epoch, but _prune_context_entries reads kind and sorts by created_epoch. Missing created_epoch reads as 0, so once the store hits 200 entries the new entry sorts dead last and is silently evicted before it is written. Write the entry in the same normalized shape as graph_register_edit (kind, created_at, created_epoch) so pruning judges it correctly and the next load has nothing to heal. Fixes kunal12203#37.
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Thanks for the detailed analysis and fix — the bug report in #37 is excellent and your fix is correct. However, I can't merge this PR as-is because it adds the full I'll port your fix into the next release (the 4-line change to normalize Closing this, but the fix ships in the next version. Thanks! |
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.
Fixes #37
What changed
graph_add_memorybuilt its entry with a"type"key and nocreated_epoch, but_prune_context_entries— which runs on everysave — reads
"kind"and sorts bycreated_epoch. Thetype→kindnormalization only ran on load, never before save, so the entrywas judged in its raw form.
Missing
created_epochreads as0, which sorts a brand-new entrydead last in the newest-first ranking. Once the store holds 200
entries the prune loop hits its cap before reaching it, so the entry is
silently dropped while the tool still returns
{"ok": true, ...}.The entry is now written in the same normalized shape as
graph_register_edit(which shipskind,created_atandcreated_epochon every write):No other write path is affected —
_upsert_context_memoryandgraph_register_editalready write these keys, so this alignsgraph_add_memorywith the rest of the codebase.Why this PR adds the file
The core lives in the private
Claude-CLI-Compact-corerepo and shipsvia the
graperootPyPI wheel, so this PR carries the current shippedsource (
graperoot3.10.8 wheel,mcp_graph_server.py) with the fixapplied for porting into the private repo. The diff against the
shipped file is the
graph_add_memorychange above only.Testing performed
entry shape (
type/date, nocreated_epoch) is evicted by_prune_context_entrieson save.pruning (oldest entry evicted instead) and loads back normalized
with
kind,created_epochand a generatedid.graph_add_memorytool viabuild_server()against a store pre-filled to 200 entries — returns{"ok": true, "total": 200}and the entry is persisted.