Repository navigation
Description
dedup.py Pass 1 exact normalization merges short generic labels across unrelated files, inflating god_nodes
Summary
dedup.py:deduplicate_entities() Pass 1 ("exact normalization") groups nodes by _norm(label) — a key that lowercases the label and collapses non-alphanumeric runs to spaces. For short, generic labels (main(), description, methodology, init(), issue, …) this key is identical across many unrelated source files, so the pass unions every occurrence into a single survivor node and rewires every incoming edge onto it.
The fuzzy-pass guard (_short_label_blocked, _is_variant_pair) only runs on Pass 2 (MinHash/JW). Pass 1 is unconditional — there is no short-label or generic-label gate before the union.
Result: artificial god nodes whose degree comes entirely from cross-source collisions, not real centrality. This is distinct from #438 (AST _make_id stem collision) and #543 (cross-file INFERRED calls resolution via global name map) — those operate at the extraction layer; this one fires at the dedup layer, after the AST extractor has correctly produced distinct IDs.
Root cause
graphify/dedup.py ~L165-L180:
# ── pass 1: exact normalization ───────────────────────────────────────────
norm_to_nodes: dict[str, list[dict]] = defaultdict(list)
for node in unique_nodes:
key = _norm(node.get("label", node.get("id", "")))
if key:
norm_to_nodes[key].append(node)
uf = _UF()
for key, group in norm_to_nodes.items():
if len(group) > 1:
winner = _pick_winner(group)
for node in group:
uf.union(winner["id"], node["id"])_norm (L17): re.sub(r"[^a-z0-9]+", " ", label.lower()).strip() — "main()", "main", "MAIN" all collapse to "main".
The Pass 2 guards (_short_label_blocked, _is_variant_pair) explicitly handle this risk for fuzzy matches but never see Pass 1.
Reproducer
Real corpus: a knowledge-archive repo with skills/, scripts/, third-party plugin trees. graphify v0.8.5.
After full /graphify --update:
| Survivor node ID | Survivor label | Surviving degree | Distinct source_file values feeding edges |
|---|---|---|---|
skills_scout_main |
main() |
99 | 15+ (scripts/scan_tool_inventory.py, scripts/archive_tool.py, scripts/build_embeddings.py, docs/archive-agent-poc/scripts/archive_agent_poc.py, Understand-Anything/.../extract-domain-context.py, …) |
raw_nemotron3_..._description |
description |
98 | 17 paper JSON files |
raw_agentic_..._methodology |
methodology |
40 | 8 paper JSON files |
Verification — exactly one node survives Pass 1 for each _norm key:
>>> from graphify.dedup import _norm
>>> _norm("main()")
'main'
>>> _norm("description")
'description'
>>> _norm("methodology")
'methodology'
>>> _norm("init()")
'init'In the surviving graph, [n for n in nodes if n["label"] == "main()"] returns a single node carrying every incoming calls edge from 15+ unrelated callers — those callers' own main() functions had distinct AST-generated IDs (scripts_archive_tool_main, scripts_scan_tool_inventory_main, …) that Pass 1 collapsed.
Merge log line confirms the scale:
[graphify] Deduplicated 3559 node(s) (3287 exact, 272 fuzzy).
3287 of the 3559 merges came from Pass 1.
Why this hits paper-corpus users especially hard
When the input includes structured paper JSONs (Nemotron, Externalization in LLM Agents, …), semantic subagents commonly emit field-name nodes (description, methodology, core_problem, abstract, summary). Each individual paper produces a distinct ID, but every label normalizes to the same key, so Pass 1 collapses all of them into one god node per field name.
The downstream effects:
god_nodes()output is dominated by these artifacts, not by real abstractions- Community detection treats the survivor as a hub, distorting community boundaries
surprising_connectionsproduces spurious bridges via the collision nodeSuggested Questionsare framed around AMBIGUOUS edges that exist only because of the collision
Proposed fix (any of these, in increasing complexity)
(a) Short / generic label guard for Pass 1. Skip the union if the _norm key is ≤ N characters (e.g. 12, same threshold as _short_label_blocked) and the group nodes belong to different source_file values. Mirror the existing Pass 2 guard.
(b) Source-file disjointedness check. Inside Pass 1, only union nodes whose source_file paths share a common directory ancestor, or when entropy of _norm exceeds a threshold (very generic single-word labels fail). The current _entropy helper is only used for Pass 2 candidate selection — it could gate Pass 1 too.
(c) Generic-label denylist. Hard-list the recurring offenders for code (main, init, run, update, setup, teardown) and paper schemas (description, methodology, abstract, summary, introduction, conclusion, limitations, related_work). Refuse Pass 1 merges when the key is on this list and the source_files differ.
(d) Opt-out flag. --no-exact-dedup or dedup_short_labels=False parameter on deduplicate_entities. Less elegant but immediately useful for users running incremental updates on heterogeneous corpora.
(a) is the smallest change with the broadest impact. (c) is more aggressive but matches the failure modes users actually see.
Environment
- graphify version: 0.8.5
- Python: 3.13
- Install:
uv tool install graphifyy - Corpus: ~3000–5000 nodes, mixed code + wiki + papers, run via
/graphify --update
Related
- Node ID collisions when multiple files share the same stem (e.g. Program.cs) #438 — AST
_make_idstem collision (different layer, complementary fix) - Cross-file INFERRED
callsresolution lacks import evidence + ambiguous-candidate handling — short common names blow up god_nodes ranking #543 — cross-file INFERREDcallsglobal name map (different layer) - Fuzzy dedup falsely merges similar-but-distinct entities (chip models, codenames with shared prefixes) #878 — fuzzy dedup over-merge (Pass 2, different symptom)
Happy to send a PR for (a) — Pass 1 short-label guard mirroring _short_label_blocked's threshold — if there's appetite for the patch.
Activity
safishamsi commentedon May 16, 2026
Fixed in v0.8.7.
Pass 1 now partitions same-label groups by
source_filebefore unioning. Nodes with generic labels (handle,init,run) from different files are no longer merged — they fall through to Pass 2 fuzzy matching where the entropy/similarity gates prevent god-node creation. Within the same file, same-label merging still works as before.Also fixed the
exact_mergescounter which previously over-counted by including cross-file non-merges.fix #898 #895 #899: C++ header extraction, dedup cross-file merge, in…
fix review findings from #898 #895 #899 corrections
fix Graphify-Labs#898 Graphify-Labs#895 Graphify-Labs#899: C++ header…
fix review findings from Graphify-Labs#898 Graphify-Labs#895 Graphify…
fix Graphify-Labs#898 Graphify-Labs#895 Graphify-Labs#899: C++ header…
fix review findings from Graphify-Labs#898 Graphify-Labs#895 Graphify…