Repository navigation
Description
Pass 2 fuzzy dedup merges identical-label nodes across unrelated source files
Summary
dedup.py:deduplicate_entities() Pass 1 was fixed in #895 to only merge nodes within the same source_file. Pass 2 (MinHash+Jaro-Winkler, dedup.py L195-254) still freely merges across files. When two distinct nodes have identical normalized labels in different files, they hit Pass 2 with JW score = 100 and silently pass through every guard (_is_variant_pair, _short_label_blocked) because those guards only block similar-but-not-equal cases.
Result: the fix for #895 leaks straight through Pass 2 for the most common collision pattern — identical method names across modules.
Reproducer (real corpus: 605 files, ~880k words, mixed Rust/TS/Svelte)
After /graphify --update with the merged extraction, build_merge reported:
[graphify] Deduplicated 792 node(s) (253 exact, 475 fuzzy).
Of the 475 fuzzy merges, ~231 are cross-source_file. Spot-checking 200 of them, ~150 are false positives (different functions with the same name in different files). Concrete examples:
Old node (source_file) |
New node (source_file) |
Issue |
|---|---|---|
state.borrow_from_vault() (src/rumi_protocol_backend/src/state.rs) |
main.borrow_from_vault() (src/rumi_protocol_backend/src/main.rs) |
Same canister, state-layer method merged with main-layer endpoint wrapper |
analytics/storage/mod.from_bytes() (src/rumi_analytics/src/storage/mod.rs) |
3pool/storage.from_bytes() (src/rumi_3pool/src/storage.rs) |
Different canisters, different Storable::from_bytes impls |
threePoolService.getSwapEventCount() |
ammService.getSwapEventCount() |
Different frontend services calling different canisters |
icusd_ledger.did.d.ts:Transaction |
rumi_amm/lib.rs:Transaction |
Same name, completely different types (Candid TS binding vs Rust struct) |
GuardPrincipal::new() (guard.rs) |
ICP::new() (numeric.rs) |
Different types, same trait method name |
InterpolationMethod::default() |
Mode::default() |
Different types, same trait method name |
Verified directly: querying src_main_repay_and_close_vault after dedup shows 4 outgoing edges — 2 to internal vault.rs functions (correct) and 2 to frontend TypeScript services (false). The Rust public endpoint was merged with the TS ProtocolManager.repayAndCloseVault wrapper that calls it, fusing two distinct nodes into one.
Root cause
dedup.py L210-253 (Pass 2):
for node in candidates:
norm_label = _norm(...)
neighbors = lsh.query(minhashes[node_id])
for neighbor_id in neighbors:
...
neighbor_norm = _norm(...)
score = JaroWinkler.normalized_similarity(norm_label, neighbor_norm) * 100
if _is_variant_pair(norm_label, neighbor_norm):
continue
if _short_label_blocked(norm_label, neighbor_norm, score):
continue
# ↑ both guards only fire on similar-but-unequal labels
if score >= _MERGE_THRESHOLD:
...
uf.union(winner["id"], node_id)
uf.union(winner["id"], neighbor_id)JaroWinkler.normalized_similarity(x, x) = 1.0 → score = 100, which is ≥ _MERGE_THRESHOLD (92). _is_variant_pair returns False if a == b. _short_label_blocked only handles insertion/deletion differences. So identical normalized labels in different files always merge regardless of length, entropy, or context.
Pass 1's source_file partition (the #895 fix) is the natural pattern but it doesn't extend to Pass 2.
Proposed fix
Mirror Pass 1's source_file partition for the identical-label sub-case of Pass 2. Concrete:
if score >= _MERGE_THRESHOLD:
# If the labels are byte-identical after normalization, treat the same
# way Pass 1 does: only merge within the same source_file. Cross-file
# identical-label matches almost always indicate same-named-but-different
# symbols (trait impls, wrapper methods, common type names).
if norm_label == neighbor_norm:
sf_a = node.get("source_file") or ""
sf_b = neighbor.get("source_file") or ""
if sf_a != sf_b:
continue
# otherwise proceed with normal Pass 2 merge
...This preserves Pass 2's value for genuinely similar-but-distinct labels (e.g. parseUserInput vs parse_user_input) while closing the identical-label leak that bypasses #895's fix.
Alternative / additive: a denylist of common trait-impl method names (.from_bytes(), .to_bytes(), .new(), .default(), .from(), .fmt(), .clone(), .into(), .eq(), .hash(), .drop(), .cmp(), .next(), .iter(), …). Refuse Pass 2 merges when the normalized label is on this list and source_files differ. Could ship as data alongside (a).
Environment
- graphify version: 0.8.17
- Python: 3.13
- Install:
uv tool install graphifyy - Corpus: ~6700 nodes, mostly Rust + SvelteKit, mixed
.rs/.ts/.svelte/.md - Triggered via
/graphify --updateafter committing 4 backend Rust files + 9 doc files
Related
- dedup.py Pass 1 exact normalization merges short generic labels across unrelated files, inflating god_nodes #895 — Pass 1 cross-file exact merge (fixed; this issue is the Pass 2 leak)
- Fuzzy dedup falsely merges similar-but-distinct entities (chip models, codenames with shared prefixes) #878 — Pass 2 fuzzy on chip-name variants (fixed for similar-but-unequal labels)
- #896 (search-found-related, didn't verify)
Happy to send a PR with the identical-label source_file partition if there's appetite.
Activity
fix: memory-dir gitignore leak, Pass 2 dedup cross-file identical mer…
safishamsi commentedon May 27, 2026
Fixed in v8 (commit 9f73400). Added a source_file partition for the identical-label sub-case in Pass 2: when
norm_label == neighbor_normand the two nodes have differentsource_filevalues, the merge is skipped. This closes the leak from #895's Pass 1 fix — identical names across different files (trait impls like.new(),.default(), wrapper methods, etc.) are no longer fused. Similar-but-not-equal labels across files still merge normally via the existing JW threshold path. Thanks for the detailed analysis and the concrete corpus evidence — very useful report.feat: BYOND DreamMaker support, --mode deep flag, changelog fixes (#884…
fix(dedup): stop fuzzy merges from crossing app/language boundaries
fix(dedup): pick pass-2 winner from the verified pair only (#1247)
fix: memory-dir gitignore leak, Pass 2 dedup cross-file identical mer…
feat: BYOND DreamMaker support, --mode deep flag, changelog fixes (Gr…
fix(dedup): pick pass-2 winner from the verified pair only (Graphify-…