Skip to content

Fix save_graph dropping per-node graph_id for unified graphs#19

Merged
monneyboi merged 2 commits intomainfrom
fix/save-graph-preserves-graph-id
Mar 7, 2026
Merged

Fix save_graph dropping per-node graph_id for unified graphs#19
monneyboi merged 2 commits intomainfrom
fix/save-graph-preserves-graph-id

Conversation

@claude
Copy link

@claude claude bot commented Mar 7, 2026

Summary

  • save_graph now includes graph_id in per-node JSON when it differs from the top-level graph id, preserving source provenance for unified/matched graphs
  • load_graph reads per-node graph_id when present, falling back to the top-level id for backwards compatibility with single-article graph files
  • Added round-trip tests for both single-article and unified graph serialization

Closes #15

Test plan

  • New test_save_load_roundtrip_single_graph — verifies graph_id is omitted from JSON for single-article graphs and inferred correctly on load
  • New test_save_load_roundtrip_unified_graph — verifies per-node graph_id is serialized only when it differs, and preserved through save/load round-trip
  • Existing tests pass

🤖 Generated with Claude Code

save_graph now includes graph_id in per-node serialization when it
differs from the top-level graph id. load_graph reads it back when
present, falling back to the top-level id for backwards compatibility.

Closes #15

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@monneyboi monneyboi closed this Mar 7, 2026
@monneyboi monneyboi reopened this Mar 7, 2026
Copy link
Contributor

@monneyboi monneyboi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always serialize graph_id per node — don't conditionally omit it when it matches the top-level id. And on load, read it from the node directly without falling back to the top-level id.

The conditional omit/fallback adds backward-compatibility complexity we don't need. Every node should explicitly carry its graph_id in the JSON.

The tests should be updated accordingly — assert graph_id is always present in the serialized JSON.

- save_graph: always include graph_id on every node in JSON
- load_graph: read graph_id directly from node, no fallback to top-level id
- Tests updated to assert graph_id is always present

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Author

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Code now always serializes and reads graph_id per node with no conditional logic — clean and correct. Tests match the new behavior. No bugs, logic errors, or security issues found.

@monneyboi monneyboi merged commit 387d28c into main Mar 7, 2026
2 checks passed
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.

save_graph loses per-node graph_id for unified graphs

1 participant