You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeScript returns stored merge rewrites with their keys in alphabetical order, so entity merges and graph.diff output differ from Python #525
Merge records read back from the store list each rewrite's keys in a different order in TypeScript than in Python, so the CLI entity merges, the MCP entity_merges tool, and the entities_merged / entities_unmerged lists of graph.diff print different JSON for the same graph. Results and keys are a wire format both SDKs share.
Reproduce
Embedded Kuzu, current main, one database for both CLIs:
It does not matter which SDK wrote the merge; a fresh insert result is in model order in both, so only reads diverge.
The evidence records inside a rewrite (kept for a relation a merge dropped as a self-loop) come back the same way: TypeScript prints chunk_id, confidence, end_offset, quote, source_id, source_version, start_offset, Python the Evidence field order.
Expected
The same key order in both SDKs, the model's field order.
Root cause
typescript/src/resolution.ts, decodeMerge, rebuilds rewrites with { ...rw, dropped: ..., evidence: rw.evidence ?? [] }. That spreads the stored JSON, whose keys are sorted, instead of building a MergeRewrite in its field order.
Proposed fix
Build each rewrite, and each evidence record in it, explicitly in field order in decodeMerge, and add the key order of a merges read to the conformance pair.
Confirmed from the code path: both SDKs store each rewrite with sorted keys, but on read Python coerces the stored dicts back into MergeRewrite (model field order) while TypeScript decodeMerge spreads the stored object (...rw), keeping the alphabetical key order. So entity merges, the MCP entity_merges tool, and the entities_merged / entities_unmerged lists of graph.diff print different JSON for the same merge, and the nested evidence records diverge the same way.
Scope: TypeScript only, since Python already emits the model field order. Build each rewrite, and each evidence record inside it, explicitly in field order in decodeMerge, and add a merges read to the conformance pair so the key order is checked from now on.
Priority P3, effort S: no wrong values or data loss, but merge reads are a wire format both SDKs share.
Approved by @arrry-hydraDB. @saurav-shakya or an assignee of this issue can now open a PR that links it with Closes #525 (max 10 open PRs at a time). Anyone else can comment /take on this issue to be assigned.
Activity
arrry-hydraDB commentedon Nov 26, 2026
/approved
Confirmed from the code path: both SDKs store each rewrite with sorted keys, but on read Python coerces the stored dicts back into
MergeRewrite(model field order) while TypeScriptdecodeMergespreads the stored object (...rw), keeping the alphabetical key order. Soentity merges, the MCPentity_mergestool, and theentities_merged/entities_unmergedlists ofgraph.diffprint different JSON for the same merge, and the nested evidence records diverge the same way.Scope: TypeScript only, since Python already emits the model field order. Build each rewrite, and each evidence record inside it, explicitly in field order in
decodeMerge, and add a merges read to the conformance pair so the key order is checked from now on.Priority P3, effort S: no wrong values or data loss, but merge reads are a wire format both SDKs share.
github-actions commentedon Nov 26, 2026
Approved by @arrry-hydraDB. @saurav-shakya or an assignee of this issue can now open a PR that links it with
Closes #525(max 10 open PRs at a time). Anyone else can comment/takeon this issue to be assigned.