Skip to content

fix(export): stabilize graph JSON collection order - #2582

Closed
hjotha wants to merge 1 commit into
Graphify-Labs:v8from
hjotha:agent/stabilize-graph-json-array-order
Closed

hjotha wants to merge 1 commit into
Graphify-Labs:v8from
hjotha:agent/stabilize-graph-json-array-order

Conversation

@hjotha

@hjotha hjotha commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • sort exported nodes and links with a canonical JSON comparison key
  • sort hyperedges in both the NetworkX graph metadata and the top-level compatibility field
  • add a regression proving reversed collection insertion order produces byte-identical graph.json

Root cause

networkx.node_link_data() preserves graph insertion order. Equivalent graphs assembled in a different node, edge, or hyperedge order therefore produced noisy graph.json rewrites after small incremental changes.

This complements #1010, which stabilized edge-conflict resolution and clustering but did not canonicalize the serializer's collection order. The scope here is intentionally limited to collection ordering; mapping-key ordering is unchanged.

Impact

The graph topology and attributes are unchanged. The first export may reorder existing collections once; later equivalent rebuilds remain byte-stable.

Validation

  • focused export suite: 53 passed
  • Python 3.12 full suite: 4141 passed, 3 skipped
  • Python 3.10 full suite: 4141 passed, 3 skipped
  • all five tools.skillgen CI validators passed
  • Ruff passed on both changed files
  • git diff --check passed
  • repeated structural Graphify rebuild reported no topology changes on the second pass
  • graphify --help and graphify install smoke tests passed in a clean HOME

safishamsi added a commit that referenced this pull request Aug 11, 2026
Batch of correctness/determinism fixes (#2610/#2599, #2612, #2618, #2614,
#2582, #2467, #2544, #2493, #2568-followup, #2605, #2608, #2598).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Fixed in v0.9.40 (graphifyy==0.9.40 on PyPI). graph.json node/edge/hyperedge collection order is now sorted deterministically, so identical inputs produce byte-stable output across runs. Thanks @hjotha (PR #2582).

@safishamsi safishamsi closed this Aug 11, 2026
safishamsi pushed a commit that referenced this pull request Aug 19, 2026
…ound-trip (#2582)

node_link_data always appends the node key (id) last, so id sat mid-dict on a
cold build but last after a read-rebuild — churning graph.json key order with
no content change and defeating byte-stable caching. to_json now canonicalizes
each node/link dict (id / source,target,relation first, remaining keys sorted)
before serialization, so a load -> rebuild -> write round-trip is byte-identical.
Pure key permutation; values are untouched.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
safishamsi added a commit that referenced this pull request Aug 19, 2026
… fix (#2582)

Covers the ensure_ascii write path the field-order stabilization implicitly
relies on: a reordered node dict carrying escaped-unicode values must serialize
byte-identically across a read-rebuild.
safishamsi added a commit that referenced this pull request Aug 19, 2026
Ships this cycle: the graph-correctness/UX batch — JS/TS factory-object methods
(#2745), stable graph.json field order (#2582), query names its graph (#2789),
ThinkingBlock-safe claude backend (#2697), manifest churn guard (#2838), C# primary
ctor refs (#2829), AST INFERRED rubric confidence_score (#2813), legacy numeric
confidence normalization; plus the small-fix batch — chunk-bisect on timeout (#2866),
symlink cache identity (#2832), sidecar cache root (#2787), driveless Windows path
guard (#2795), actionable partial-parse warning (#2788), and non-ASCII Obsidian tags
(#2862).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants