Skip to content

feat: lossless, idempotent export/import round-trip with JSON-LD @id/@type - #13

Open
marcdhansen wants to merge 2 commits into
agentralabs:mainfrom
marcdhansen:lossless-export-import
Open

feat: lossless, idempotent export/import round-trip with JSON-LD @id/@type#13
marcdhansen wants to merge 2 commits into
agentralabs:mainfrom
marcdhansen:lossless-export-import

Conversation

@marcdhansen

@marcdhansen marcdhansen commented Jul 18, 2026

Copy link
Copy Markdown

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

  • Add MemoryGraph::add_node_with_id for explicit, idempotent node insertion.
  • Export JSON-LD @id and @type fields while retaining the legacy fields.
  • Import either legacy or JSON-LD identity/type fields.
  • Preserve node access metadata and edge creation timestamps.
  • Skip duplicate nodes and identical (source, target, type) edges.
  • Report duplicate skips in import output.

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 assertion test_large_graph_similarity_speed at 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 id and event_type fields remain present and supported.

OpenLoop Agent (wild-forging-map) and others added 2 commits July 18, 2026 06:52
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant