Repository navigation
feat: signed, verifiable memory export/import bundle - #48
Merged
Merged
Conversation
`export` writes a signed bundle of a context's memories, optionally narrowed by --type/--basis/--status. Each record keeps its author's own proof verbatim; the exporter signs the bundle as a whole, so a record added, dropped or edited fails it. `import` checks both, all or nothing, before connecting, and writes each memory attributed to its original author: signed by the importer for where it now is, carrying the original in `importedFrom`, which a reader checks for the same content. Format documented in docs/memory-bundle.md. Closes #36 Signed-off-by: Glenn Gore <glenn.g@affinidi.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.
Closes #36.
What it does
vta-agent-memory export [--out FILE] [--type …] [--basis …] [--status …]writes a signed JSON bundle of the context's memories. Each record is included exactly as stored, with its author's own proof. The exporter's Data Integrity proof (eddsa-jcs-2022) covers the whole bundle: the record list, the source context and the filter. Records that are refused or unattributed are left out and listed with the reason. The file is written with mode0600.vta-agent-memory import FILE|- [--replace] [--dry-run] [filters]checks the bundle's proof and every record's own proof (author,contextId=sourceContext, and the key) before connecting. It is all or nothing: a bundle with one bad record imports nothing. Without--replace, a memory that already exists under the same key is left alone (create-onlyexpectedVersion: 0). With--replace, the import becomes a new version and the old one goes to history.docs/memory-bundle.mddocuments the format and the checks, so a non-VTA reader can verify a bundle.Keeping the original author
A record's signature names the context it was written in, so an imported record can't keep that signature as its own: the relocation check from #31 would rightly refuse it. Re-signing as the importer would lose who wrote it. Instead, the importer signs a record for its new location and carries the original verbatim in
importedFrom.authorship::verifythen checks:key, and no nested import;supersedesandimportedFrom) is the same in both.If all three hold, the memory is attributed to the original author, with
importedByandimportedFromshown alongside (authorJSON block, and the note "imported from contexthome"). Re-importing flattens to the first original. Any later save or status change dropsimportedFrom, so the editor becomes the author and the imported version stays in history.Tests (
tests/bundle.rs, 7)updatedAt, basis, confidence, evidence, status, reason andreviewAfter, each attributed to its original author (agent or operator).--replace, and keeps history with it.filter, and lists unattributed records it left out.Also checked:
cargo clippy --all-targetsis clean, every existing test passes, and the eval's hard checks all pass. Nothing that affects ranking changed.Notes
importedFromcontext and timestamps say where it came from and when.importwrites memories one at a time once the bundle has been checked, so a VTA failure partway through can leave a partial import. Re-running without--replacepicks up the rest.Version 0.6.1 → 0.7.0.