feat: lossless, idempotent export/import round-trip with JSON-LD @id/@type - #13
Open
marcdhansen wants to merge 2 commits into
Open
feat: lossless, idempotent export/import round-trip with JSON-LD @id/@type#13marcdhansen wants to merge 2 commits into
marcdhansen wants to merge 2 commits into
Conversation
- add MemoryGraph::add_node_with_id (explicit id, idempotent skip, next_id bump) - import honors id/@id and created_at on nodes and edges, carries access_count/last_accessed/decay_score through, dedupes edges on (source, target, type) - export emits JSON-LD @id/@type alongside legacy keys Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Motivation
Export/import round trips should preserve node identity and history instead of assigning new IDs and duplicating edges. This is needed for deterministic checkpoints and idempotent rebuilds from append-only JSONL.
Changes
MemoryGraph::add_node_with_idfor explicit, idempotent node insertion.@idand@typefields while retaining the legacy fields.(source, target, type)edges.The adjacent stronger change, replacing the legacy export fields with JSON-LD fields, is intentionally rejected because it would break existing consumers. This patch emits both formats and accepts either.
Verification
cargo fmt --all -- --check: passed after applying rustfmt.cargo clippy --workspace --all-targets -- -D warnings: passed.cargo test -p agentic-memory --test phase4_integration test_cli_export_import -- --exact --nocapture: passed.cargo test --workspace: reached the unrelated timing assertiontest_large_graph_similarity_speedat 2.104s versus its 2s threshold; the test passed in isolation at 1.956s. The full run stopped at that assertion.No breaking changes are intended. Existing
idandevent_typefields remain present and supported.