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
build_from_json collapses same-file, same-label nodes at different locations (even with dedup=False) — regression vs 0.8.31 #4019
build_from_json (and therefore build_merge(..., dedup=False)) collapses nodes that share the same source_file and the same label but sit at different source_locations. In 0.8.31 they are all kept; in 0.9.74 only one survives. This is not the cross-file merge from #3094 — the nodes are in the same file and the control below (same label, different file) is preserved.
Typical victims: a JSON key that appears at several nesting levels (name at L2 and L5 of one plugin.json), and a heading repeated in two sections of one Markdown document. They are distinct nodes with distinct ids and locations, but they get merged even though dedup=False was requested.
On an existing, hand-curated graph (6,412 nodes / 9,308 edges), re-loading its own graph.json through build_from_json gives 6,119 nodes / 8,562 edges on 0.9.74 (0.8.31: unchanged). 286 nodes and 746 edges disappear; 284 of those 286 have a surviving node with the same source_file + label (210 code, 49 document, 11 rationale). None of them come from deleted files.
Consequence: build_merge(new_chunks, graph_path=..., dedup=False) with an empty chunk raises the #479 guard (build_merge would drop 217 node(s) from sources that were neither re-extracted nor pruned) and refuses to write. The guard does its job, but it means an existing graph can no longer be merged incrementally on 0.9.74 without losing nodes, even with dedup=False.
What I did not verify
I suspect the (source_file, label) key used by the ghost-duplicate merge pass in build_from_json (#1145 / #2068) but I have not confirmed that this is the code path. I also did not check intermediate versions between 0.8.31 and 0.9.74, so I can't say which release introduced it.
Expected
Nodes at different source_locations with different ids should survive dedup=False, or the collapse should be limited to the AST-vs-LLM twin case it was designed for (and be opt-out).
Environment: Windows 11, Python 3.14, graphifyy 0.8.31 vs 0.9.74 (fresh venv).
Confirming this reproduces on current v8 (0.9.75): the repro from the issue gives 5 -> 3, losing pkg_name and doc_s2_notes. The other_name control (same label, different file) is kept, as reported.
It looks like the same-file, same-label collapse comes from the ghost-dedup in build_from_json (#1145 and its follow-ups): non-AST nodes are keyed on (source_file, label), and a later node on the same key is treated as a duplicate of the first. That is what removes the two name nodes at L2 and L5 and the two Notas headings.
The tension is that this key is what catches the LLM/AST ghost twins. A fix that keeps same-file nodes with different source_location would also let some real ghosts through, unless the location is part of the key or the collapse is limited to nodes with no location.
Is the collapse meant to apply to same-label nodes at different locations in one file? If you tell me which direction you want (keep them when locations differ, or leave the collapse and make it opt-out for dedup=False), I'm happy to build it with tests.
Activity
github-actions commentedon Oct 3, 2026
Thanks for opening this issue, @cabgab-dev. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
deepanshupal commentedon Oct 4, 2026
Confirming this reproduces on current
v8(0.9.75): the repro from the issue gives5 -> 3, losingpkg_nameanddoc_s2_notes. Theother_namecontrol (same label, different file) is kept, as reported.It looks like the same-file, same-label collapse comes from the ghost-dedup in
build_from_json(#1145 and its follow-ups): non-AST nodes are keyed on(source_file, label), and a later node on the same key is treated as a duplicate of the first. That is what removes the twonamenodes atL2andL5and the twoNotasheadings.The tension is that this key is what catches the LLM/AST ghost twins. A fix that keeps same-file nodes with different
source_locationwould also let some real ghosts through, unless the location is part of the key or the collapse is limited to nodes with no location.Is the collapse meant to apply to same-label nodes at different locations in one file? If you tell me which direction you want (keep them when locations differ, or leave the collapse and make it opt-out for
dedup=False), I'm happy to build it with tests.fix(build): honor disabled same-file semantic deduplication