fix(extract): use full path instead of stem for within-file node IDs#329
Open
BTCB wants to merge 1 commit intosafishamsi:v4from
Open
fix(extract): use full path instead of stem for within-file node IDs#329BTCB wants to merge 1 commit intosafishamsi:v4from
BTCB wants to merge 1 commit intosafishamsi:v4from
Conversation
Node IDs were generated as `<path.stem>_<ident>`, causing collisions whenever two files in the corpus shared a basename (lib.rs across Rust crates, __init__.py across Python packages, index.ts in TS monorepos) AND contained symbols with the same name. Merged nodes inherited edges from multiple files, producing fake high-betweenness bridges and duplicate entries in the God Nodes ranking. Fix: replace `stem = path.stem` with `stem = _make_id(str(path))` at all 10 declaration sites in extract.py. The resulting IDs have a path-unique prefix (same as the file-level `file_nid`), so within-file _make_id(stem, ident) calls never collide across files. Cross-file references are unaffected: import handlers don't use stem, label-based call resolution uses labels not IDs, and pre_link_python's stem_to_entities lookups remain consistent because key+value change uniformly. Verified on a 23-crate Rust workspace: 59 collision casualties -> 0, biggest weakly-connected component grew from 367 to 939 nodes, god node ranking stopped showing duplicate labels (test_config() had appeared at both rank 1 and rank 6 due to non-deterministic merge order). Full test suite: 426 passed, 0 regressions. (7 failures in test_security.py are pre-existing and environment-specific — they reproduce identically on unpatched HEAD.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node IDs were generated as
<path.stem>_<ident>, causing collisions whenever two files in the corpus shared a basename (lib.rs across Rust crates, init.py across Python packages, index.ts in TS monorepos) AND contained symbols with the same name. Merged nodes inherited edges from multiple files, producing fake high-betweenness bridges and duplicate entries in the God Nodes ranking.Fix: replace
stem = path.stemwithstem = _make_id(str(path))at all 10 declaration sites in extract.py. The resulting IDs have a path-unique prefix (same as the file-levelfile_nid), so within-file _make_id(stem, ident) calls never collide across files.Cross-file references are unaffected: import handlers don't use stem, label-based call resolution uses labels not IDs, and pre_link_python's stem_to_entities lookups remain consistent because key+value change uniformly.
Verified on a 23-crate Rust workspace: 59 collision casualties -> 0, biggest weakly-connected component grew from 367 to 939 nodes, god node ranking stopped showing duplicate labels (test_config() had appeared at both rank 1 and rank 6 due to non-deterministic merge order).
Full test suite: 426 passed, 0 regressions. (7 failures in test_security.py are pre-existing and environment-specific — they reproduce identically on unpatched HEAD.)