feat(cli): add --supersedes to --store and surface write-time warnings - #42
Merged
Merged
Conversation
The correction rule ("store a corrected version with supersedes, don't
rewrite the store") was only reachable through MCP store_memory. Agents
wired to the CLI had no way to execute it, so corrections piled up as new
rows next to the stale ones they were meant to replace.
--supersedes takes comma-separated rowids and fails the whole write if any
target is not live (deleted, already superseded, or nonexistent). A partial
supersede is worse than none: the write lands, the stale version stays
recallable, and the correction looks applied.
Also surfaces three guards the CLI was dropping into the log stream only —
metaDowngrade, supersedeShrink and quotaRejected. The shrink guard in
particular exists to tell the caller what the new version stopped carrying;
silently discarding that defeats its purpose.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Why
docs/configuring-your-agent.mdtells agents: "When you find an outdated memory, store a corrected version withsupersedes: [\"<old id>\"]. Replace specific entries; never wholesale-rewrite the store."That instruction was only reachable through MCP
store_memory. An agent wired to the CLI had no way to execute it — so corrections piled up as new rows sitting next to the stale ones they were meant to replace, and the stale ones stayed live and recallable.A rule whose action has no interface in the daily path is a rule that never fires.
What
--supersedes 123,456on--store. Fails the whole write if any target is not live (deleted, already superseded, or nonexistent):A partial supersede is worse than none — the write lands, the stale version stays recallable, and the correction looks applied. So the CLI pre-checks with
getMemoriesByIdsand refuses before writing rather than lettingstoreMemorypoint at whatever still exists.Three guards the CLI was dropping.
storeMemoryreportsmetaDowngrade,supersedeShrinkandquotaRejectedthroughopts.out, but the CLI never passed anout— so they only reached the log stream. The shrink guard in particular exists to tell the caller what the new version stopped carrying; discarding that silently defeats its purpose. Now:Tests
New
cli-supersedes.test.mjs, 12 assertions on a temp DB — happy path, chain pointer, both refusal paths, already-superseded target, and that refused calls (including a partly-dead target list) write nothing and leave live targets untouched.supersede-shrinkandmeta-gatesuites still pass.🤖 Generated with Claude Code