fix(import): keep the replaced content when an import overwrites a memory - #556
Merged
Merged
Conversation
…mory An import with merge strategy overwrite cleared the observations and tags of every existing memory the bundle named, and kept nothing. It now records the replaced version (title, observations, tags) in the memory's `metadata.replaced_history`, the same way `remember` with `replace` does, with the same bounds: the newest 20 versions and at most 64 KB, a single oversized version keeping the observations, then the tags, that fit. A bundle still cannot put its own history onto an existing memory. Refs #530
…ry out An `import` overwrite whose content equals what the memory already holds (title, observations in order, tags) now records no history entry. Re-running a backup restore with overwrite used to add an identical version each time, so after 20 restores the memory's genuine earlier versions were gone from `replaced_history`. A change to only the title, only the tags or only the order of observations still records a version. The tool description exported for OpenAI-format clients no longer says overwrite deletes the previous content. Refs #530
…tory bounds - An import file that names one memory more than once is refused before anything is written. Otherwise the second entry's overwrite filed the first (possibly huge) entry into the memory's history, and the size limit then pushed every earlier version out. - `npm run audit:memory` now reports a memory whose replaced_history is not a list, holds more than 50 versions, or is larger than 256 KiB, the most any writer stores (a trusted restore of a fresh memory; `remember` replace and an import overwrite keep 20 and 64 KiB). - The audit exits 2 when a file is not a database or cannot be queried, instead of printing a clean verdict; only a missing table or column is still skipped as an older schema. - The audit prints the byte count the bound is judged by. - The import documentation says overwrite adds the replaced version (nothing when the content is identical), and that `truncated` also covers tags. Refs #530
…history # Conflicts: # CHANGELOG.md # dist/mcp/THIRD_PARTY_NOTICES.txt # dist/mcp/server.js.map # dist/transports/mcp/handlers.js.map
…name The duplicate-name refusal compared UTF-16 strings, but SQLite stores a lone surrogate as U+FFFD, so two such names in one import file were the same memory and slipped past it. The refusal now compares the spelling the database keeps. The audit script's header states all of its exit codes. Refs #530
The duplicate-name check now takes the name through a UTF-8 round trip, which turns a lone surrogate into U+FFFD exactly as SQLite does, instead of a hand-written pattern. The tests also cover lone low halves, runs of high halves, and two emoji that share their second half. Refs #530
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.
Refs #530.
What was wrong
importwith merge strategyoverwritecleared the observations, tags and title of every existing memory the bundle named, and kept nothing. There was no way to get the old content back.What changed
metadata.replaced_history, the same wayrememberwithreplace: truedoes. MCPimport,POST /v1/importandmemesh import --merge overwriteall do this.truncated.rememberreplace now trims tags of an oversized version too.docs/api/API_REFERENCE.mdsay what overwrite now does.Tests
tests/core/import-overwrite-history.test.ts(new) and the updated cases intests/core/export-import.test.tsfail without the fix and pass with it.npm run verifyis green.