Skip to content

JS/TS/Python: distinct same-file symbols still collapse after ID normalization in v0.9.45 #2810

Open

Description

@imagineers-tyler

Version: graphifyy 0.9.45 · macOS arm64 · Python 3.14.7
Follow-up to: #2779 / #2780 (Go, fixed) — same invariant, different extractors
Related but distinct: #2774 (Rust, bare-name trigger), #438 / #952 (cross-file id collision; this is within a single file, which _disambiguate_colliding_node_ids skips via its len(source_keys) < 2 guard)

Summary

#2780 correctly fixes the Go case it scoped itself to, and says so explicitly:

Scope: Go extractor only. The same first-wins add_node pattern exists in the other extractors

This issue tracks that remaining scope. The same post-normalization same-file collision is
still live in the JS, TS and Python paths on v0.9.45: two distinct sibling declarations
normalize to one node id, add_node drops the second on if nid in seen_ids: return, and the
lost declaration's body edges are re-attributed to the survivor.

ids.py is byte-identical between v0.9.44 and v0.9.45, so nothing about the shared
normalization changed — which is expected given the PR's stated scope, and is why the other
languages are unaffected by the fix.

v0.9.44 → v0.9.45

One file, two sibling declarations. "one node" means the second declaration produced no node
at all.

language source v0.9.44 v0.9.45
Go func Run() + func run() one node two nodes — FIXED by #2780
JS class R { _onBegin(a){} onBegin(b){} } one node one node
JS class W { #close(a){} close(b){} } one node one node
TS declare class Q { $set(a); set(b); } one node one node
JS function parseURL(a){} + function parseUrl(b){} one node one node
Python def _run(a) + def run(b) one node one node
Python def a_(p) + def a(q) one node one node
control def alpha(p) + def beta(q) two nodes two nodes

The parseURL / parseUrl row is the direct one: that is the same case-folding axis as
#2779
, and outside Go it still collapses on v0.9.45.

The others are separate axes of the same recipe — normalize_id casefolds, maps [^\w]+ to
_, collapses repeated _, and strips leading/trailing _, so _x/x, $x/x, #x/x
and x_/x all land together too. (There is an NFKC axis as well; I worked through each stage
in detail in
a comment on #2779
rather than repeat it here.)

Confirmed on real files — v0.9.45

Each run through extract(), one file at a time, from node_modules:

file pair result
happy-dom websocket/WebSocket.js #close / close close only — #close lost
happy-dom xml-serializer/XMLSerializer.js #serializeToString / serializeToString public only — private lost
happy-dom nodes/html-form-element/HTMLFormElement.js #submit / submit public only — private lost
mongoose document.d.ts $set / set $set only — set lost
playwright lib/runner/index.js _onBegin / onBegin _onBegin only — onBegin lost

Which member survives is declaration order (first-wins), not visibility — the private half
survives in some files and the public half in others.

Two of these are worth separating out:

#close is a private class method, a distinct language-level member that can coexist with
close by design. That is not a naming convention an extractor could reasonably fold.

The playwright row has a second ingredient and should not be read as a pure normalization
collision. Its two methods live in different classes, but both owners are class expressions:

var TeleReporterReceiver = class { … _onBegin() … }    // L104
var TerminalReporter     = class { … onBegin(suite) … } // L1113

JS class_types is frozenset({"class_declaration"}) (the TS set adds only
abstract_class_declaration / interface_declaration / enum_declaration /
type_alias_declaration), so neither expression mints an owner node, and their methods fall
back to file-level ids instead of class-qualified ones. Normalization collision and lost
ownership qualifier compound there. The rename control still isolates the collision as the
trigger:

original                      nodes=408   _onBegin=1  onBegin=0
rename _onBegin -> _zzBegin   nodes=409   _zzBegin=1  onBegin=1

The public method reappears and the node count rises by exactly one, so this is not one of the
"methods not extracted" gaps (#2419 / #2110 / #2524).

Impact

Four consequences of the same collision mechanism reproduce outside Go:

  1. The second declaration vanishes — no node for it anywhere in the graph.
  2. Its body edges are misattributed to the surviving sibling.
  3. local_bound_names is overwritten for the shared id.
  4. A fabricated indirect_call follows from (3). Minimal Python repro:
# vendor.py
def helper(a):
    return a

# b.py
from vendor import helper

class B:
    def _run(self, helper, p):
        return p.submit(helper)

    def run(self, x, p):
        return p.submit(x)
_run alone            nodes=['._run()', 'helper()']   indirect_call: none
_run + run            nodes=['._run()', 'helper()']   indirect_call: ._run() -> helper()

The collision is required — delete run and the phantom goes away. run's shadow set ({x})
lands on the surviving _run entry, so _run's own helper parameter stops shadowing and the
argument resolves by name to the imported helper.

Constraints on a fix

Not proposing a patch — raising what any fix has to satisfy, since the two obvious shapes both
have a catch.

Changing normalize_id has a wide blast radius. Its module docstring sets out that the
recipe is shared by three producers (AST extractor, LLM subagents, graph builder) and that
divergence between them is a recurring bug class (#811, #550, #1033, #1104).

Salting inside add_node is not sufficient on its own. add_node returns None and the
caller owns the id, continuing to use its own copy afterwards — e.g. engine.py at the
function-def site:

func_nid = _make_id(parent_class_nid, func_name)
add_node(func_nid, f".{func_name}()", line)
add_edge(parent_class_nid, func_nid, "method", line)
...
callable_def_nids.add(func_nid)
local_bound_names[func_nid] = _python_local_bound_names(node, source)

add_edge, callable_def_nids, local_bound_names, function_bodies and the per-language
tables all key off the caller's func_nid. A collision-aware registration layer near the
seen_ids check would have to return the resolved id and propagate it through all of them;
moving the node alone would leave every consumer pointing at the old id.

Doing this per-language, as #2780 did for Go, is a reasonable increment — but the JS, TS and
Python paths are the ones still open, and #2774 has the Rust flavor.

Repro

from graphify.extract import extract
from pathlib import Path
# src/a.js:  export class W { #close(a){ return a; } close(b){ return this.#close(b); } }
r = extract([Path('src/a.js')], cache_root=Path('.c'), parallel=False)
print([n['label'] for n in r['nodes']])   # ['a.js', 'W', '.#close()']  — no `close`

Happy to hand over the per-package candidate lists or the scanner I used to find these sites;
the claims above are limited to the five confirmed through extract().

Activity

  1. abhay-codes07 commented on Aug 17, 2026

    @abhay-codes07
    Contributor

    Confirmed on a second platform (Windows, Python 3.12, v0.9.44), one file per case, counting only symbol nodes:

    _run + run          symbols=1  labels=['_run()']       id=py_..._run
    a_ + a              symbols=1  labels=['a_()']         id=py_..._a
    parseURL + parseUrl symbols=1  labels=['parseURL()']   id=js_..._parseurl
    class R{_onBegin,onBegin}  symbols=2  ['R', '._onBegin()']
    class W{#close,close}      symbols=2  ['W', '.#close()']
    alpha + beta (control)     symbols=2  ['alpha()', 'beta()']
    

    Matches your table exactly, including that the class rows lose the second member rather than producing no class. So it is not macOS- or 3.14-specific.

    One thing worth surfacing for whoever takes this, because it is the part that makes it more than a mechanical port of #2780:

    #2780 does not just salt the loser — it decides which member keeps the plain id, and it decides it from Go's visibility rules. Its reasoning is that only exported symbols are reachable across packages, so cross-package edges and edges already cached in graph.json point at the exported one; keeping that id stable means adding or removing an unexported sibling during an incremental update never re-points anything. It then salts both members when there is no unique exported one (Run/RUN) so the outcome never depends on declaration order.

    That argument does not transfer as-is. Python and JS have no exported/unexported distinction, and the collisions here sit on two different normalisation axes:

    • leading underscore (_run/run, _onBegin/onBegin, #close/close) — there is a privacy convention, so the non-underscored member is the natural analogue of Go's exported half and could keep the plain id;
    • case only (parseURL/parseUrl) and trailing underscore (a_/a) — no convention picks a winner, so by fix(go): keep both halves of a case-only symbol collision (#2779) #2780's own order-independence rule both members would have to be salted.

    So the port needs a stated id-stability policy per axis, not just a collision check, and getting it wrong re-points cross-file edges and breaks warm incremental rebuilds silently.

    I have the reproduction and I am happy to do the JS/TS/Python work, but I did not want to invent that policy in parallel with #2780 still under review — if its approach shifts during review, a fix built on the current shape would have to be redone, and node identity is not somewhere to guess. Happy to pick it up once #2780 lands, or sooner if you would rather settle the policy here first.

  2. imagineers-tyler commented on Aug 18, 2026

    @imagineers-tyler
    ContributorAuthor

    Thanks for the second-platform run — Windows/3.12/0.9.44 matching row for row rules out my
    environment, which I could not do alone.

    #2780 has already landed

    Your blocker may be gone: #2780 was cherry-picked onto v8 and released in v0.9.45 — the
    maintainer's closing comment on #2779 says so directly. It shows as CLOSED with
    mergedAt: null because of the cherry-pick, which is easy to read as "still open"; I misread
    that same signal on my own PRs earlier.

    The installed 0.9.45 carries the logic you describe, in graphify/extractors/go.py, reasoning
    included:

    The EXPORTED member keeps the plain id. Only exported symbols are reachable […] When the
    collision has no unique exported member (Run/RUN), every member is salted

    and Go func Run() + func run() yields two nodes on 0.9.45 where 0.9.44 yielded one. So the
    shape is settled, not in flux.

    On _x as the analogue of Go's unexported — I went looking, and it does not hold

    I tried to support the "non-underscored member keeps the plain id" half of your split and ended
    up with evidence against it. Two things, in the corpora already in this issue:

    Underscore-prefixed symbols do get exported. playwright exports four:

    export const _android
    export const _baseTest      (×2)
    export const _electron
    export const _utilityTest
    

    And they are referenced through objects, not just this. Counting x._y( call sites and
    excluding this.:

    package obj._x() total excluding this.
    mongoose 272 90
    playwright 748 150
    eslint 15 0

    with shapes like locator._expect() (×31), testInfo._runWithTimeout(), suite._addTest(),
    SchemaType._isRef() (×13), schema._getSchema().

    These counts demonstrate ordinary use through non-this receivers, so underscore-prefixed
    members are not merely private implementation details. At least one representative group is
    directly cross-file: SchemaType._isRef is defined in lib/schemaType.js:1659 and called from
    lib/schema/{number,objectId,date,decimal128,array,string}.js. The raw totals themselves are
    receiver-call counts, not a count of verified cross-file edges — testInfo._runWithTimeout, for
    instance, is defined and called inside the same bundled worker/workerProcessEntry.js.

    So a leading underscore is a convention, not an access restriction — in JS/TS it does not
    prevent export or cross-module reference, and in Python _x is explicitly importable (the
    underscore only affects wildcard imports). I do not think _x/x can inherit Go's policy on
    this basis; it stays an open question for whoever writes the policy, and I would not assume
    either member is the safe one to keep stable.

    Correcting my own process here: my first pass at this search reported zero hits everywhere,
    which was a broken harness rather than a result — the recursive form of my grep silently
    matched nothing. The numbers above are from the corrected run, checked against a known-positive
    file first.

    #x/x is the one axis where the Go argument transfers by guarantee

    A private class element is language-enforced; in this repro #p() is a private method:

    class W { #p(){ return 1; } pub(){ return this.#p(); } }
    new W().pub()   // 1
    w.#p()          // SyntaxError: Private field '#p' must be declared in an enclosing class

    No legitimate source-level reference outside the declaring class's lexical scope can target it —
    the grammar forbids it. That is the same property Go's unexported gives you, and unlike the _x
    case it is a guarantee rather than a survey, so salting the # member cannot invalidate a
    legitimate cross-class reference. (An existing graph edge pointing at the private member's plain
    id is a product of this bug, not a reference worth preserving.)

    Case-only and trailing-underscore stay where you put them, with one hedge: no naming
    convention
    alone picks a winner, and absent a unique exported member or another stable
    reference signal, #2780's order-independence rule points toward salting both. Export/import
    information might still supply a stable winner in some of those pairs — class_ in Python is
    public API, and one half of a case-only JS pair may be the exported one.

    One shape that breaks the per-class framing

    Worth knowing before the policy is written, because it is where "the class's N member keeps
    the plain id" has no class to key on.

    The playwright row in my table is two methods in two different classes. Both owners are class
    expressions:

    var TeleReporterReceiver = class { … _onBegin() … }     // L104
    var TerminalReporter     = class { … onBegin(suite) … } // L1113

    Neither mints an owner node, so both methods fall back to a file-level id. On 0.9.45:

    original                      nodes=408   _onBegin id=index_onbegin   onBegin absent
    rename _onBegin -> _zzBegin   nodes=409   onBegin  id=index_onbegin   _zzBegin separate
    

    The plain id index_onbegin goes to whichever member is declared first, and the node count
    rises by exactly one when the collision is removed — so the collision is the trigger, not one of
    the "methods not extracted" gaps (#2419 / #2110 / #2524).

    Two consequences:

    1. Under today's lost-owner representation, the raw method name is the only signal still
      preserved at that point — the declarator binding, the source scope and the import graph are
      all still available in the tree, but the current id construction does not include them in the
      id input.
    2. The collision set is not fixed. If the extractor were taught to mint owner nodes for class
      expressions — using the enclosing declarator's binding name, not merely by adding the
      anonymous class node type to class_types, since the class handler returns early when it
      finds no name (engine.py:2957-2966) — these two methods would regain distinct
      class-qualified ids and this particular collision would disappear. Worth deciding whether the
      id policy is written against today's class_types or a corrected one.

    On who does it

    Please do take it — you have the reproduction, the second platform, and you have thought further
    about id stability than I had. I am happy to run A/B measurements against whatever shape you
    land on, or to check candidate policies against the five real files in the issue body. I would
    rather not fork the effort.

  3. imagineers-tyler commented on Aug 30, 2026

    @imagineers-tyler
    ContributorAuthor

    Corpus measurement on 0.9.52: in 5.5% of installed JS files, two source positions collide on one node id

    This issue has so far been argued from synthetic fixtures. Below is a measurement over installed
    npm packages, to put a number on how often it comes up. Everything is on graphifyy 0.9.52,
    CPython 3.14.7. The Where this measurement is soft section at the end states what the numbers
    do and do not establish, and it is load-bearing.

    Method

    Corpus. Every .js file under six node_modules trees on one machine, deduplicated by
    SHA-256, smaller than 400 KB: 14,340 unique files. All 14,340 were extracted without error
    (the sweep reports parsed=14340), so nothing is silently missing from the denominator.

    342 files are flagged by a minification heuristic — .min. in the basename, or mean physical
    line length > 200 bytes. The heuristic is not a proof of minification, but it is deliberately
    crude in the safe direction: it removes files whose single-letter identifiers manufacture
    collisions that say nothing about authored code. Those 342 are excluded from every number below.
    Denominator: 13,998 files. For the record, including them raises the totals to 1,079 files and
    8,430 events: only 56 of the 342 flagged files produce any event at all, and those 56 account for
    3,913 of 8,430 events (46%). That concentration is why they are excluded.

    Extraction. One extract([file], parallel=False, cache_root=<tmpdir>) per file, no cache
    reuse between files.

    Detector. For every node id, collect the source lines of the contains and method edges
    pointing at it. Two distinct lines on one id is a collision event: two source positions were
    minted into the same id, and the graph holds one node for both. Events per file are
    sum(len(distinct_lines) - 1).

    The detector stops there. It does not observe add_node call sites, so it does not by itself
    establish that a second node was attempted and discarded. That is the mechanism this issue is
    about — add_node (extractors/engine.py:2995) returns early on if nid in seen_ids at :2997,
    so where both positions do reach it, the later one is dropped silently — but for the aggregate it
    is an inference, not an observation. The four hand-verified packages below are where that step is
    actually checked.

    Attribution. Re-parse each affected file with tree_sitter_javascript, index every definition
    site by line number — recursively, not only at top level: declarations, class members with
    get / set / static distinguished, and exports.X / module.exports.X assignments — then
    match the colliding edge lines back to their syntax. 4,341 of 4,517 events (96%) matched at least
    two definition sites; 176 did not and are excluded from the axis table.

    Result

    files collision events
    non-minified corpus 13,998 —
    at least one event 1,023 (7.31%) 4,517
    excluding groups containing a get/set pair 769 (5.49%) 2,554

    The second row exists because a getter and a setter for one property arguably should share a
    node. If you agree they should, that row is the headline. It is a slight over-exclusion: of the
    1,963 events it removes, 1,952 come from groups that are exactly one getter plus one setter, and
    11 come from 5 groups holding more than that — two accessor pairs
    (playwright/lib/runner/index.js startTime, L511/L514 and L544/L547), an accessor pair sharing
    its id with a private method (undici/lib/web/websocket/websocket.js: get/set onmessage and
    #onMessage at L526, in two corpus copies), two getters and one setter
    (three/src/materials/nodes/NodeMaterial.js type), and a getter whose leading underscore is
    stripped into the pair (jsdom/.../HTMLProgressElement-impl.js: _value L18, value L47/L53).
    Excluding only clean pairs, rather than whole groups, gives 2,565 events.

    Which collisions

    Tags are assigned per collision group, not per colliding declaration, and are non-exclusive —
    one group can be both "differs only by case" and "static vs instance", and all of the group's
    events are counted under every tag that applies. The column therefore sums to more than 4,517 and
    should be read as "how many events occur in groups with this property", not "how many declarations
    this axis destroyed".

    collision axis events files
    identical spelling, distinct declarations 3,358 435
    get/set accessor pair 1,963 289
    names differ only by case 504 404
    names differ only by leading/trailing _ $ # 420 206
    static method vs instance method 70 34
    exports.X = fn (CommonJS) 66 16
    names differ by other punctuation / NFKC 59 26
    exports.X = wrapper(fn) (the #3035 path, added in 0.9.50) 1 1

    The _x / x row deserves separate mention: 206 files. That is the ordinary JS private-helper
    convention, and normalize_id's re.sub(r"_+", "_", …) followed by .strip("_") maps both
    spellings onto one id.

    Four named packages

    Every line number, label and count below is copied from a fresh 0.9.52 extraction.

    1. [email protected] — glob.js (27 nodes, 73 edges). The exported Glob constructor has no node.

    function glob (pattern, options, cb) {   // L62
    glob.Glob = Glob                         // L115
    function Glob (pattern, options, cb) {   // L117

    Both mint …_glob_glob. Two contains edges (L62, L117) point at one node, and that node is
    glob() @ L62. No node labelled Glob() exists in the file. (Glob is a constructor function
    here, not a class declaration — the collision does not depend on which.)

    2. [email protected] — index.js (41 nodes, 75 edges). Two methods dropped, one of them public.

    The file declares three classes: IgnoreRule (L377), RuleManager (L464), Ignore (L603).

    class RuleManager {
      _add (pattern) {                                        // L470  → id rulemanager_add
      add (pattern) {                                         // L492  → id rulemanager_add
    class Ignore {
      _test (originalPath, cache, checkUnignored, slices) {   // L641  → id ignore_test
      test (path) {                                           // L741  → id ignore_test

    Survivors: ._add() @ L470 and ._test() @ L641. So the public Ignore.test() is gone,
    displaced by a private helper, and internally RuleManager.add() is gone too. Method ids are
    owner-qualified, so the rest of the public surface is unaffected — Ignore.add() @ L624,
    .ignores() @ L728, .filter() and .createFilter() all keep their own nodes.

    3. [email protected] — lib/url-state-machine.js (42 nodes, 93 edges). Export wrapper swallowed, caller mis-bound.

    function basicURLParse(input, options = {}, validationErrors = null) {   // L1174
    module.exports.basicURLParse = function (input, options = {}) {          // L1190
      return basicURLParse(input, options);
    };
    module.exports.parseURL = function (input, options = {}) {               // L1212
      return module.exports.basicURLParse(input, { … });                     // L1214
    };

    Two contains edges (L1174, L1190), survivor basicURLParse() @ L1174. The call at L1214
    goes through the exported wrapper, but the graph records it as a calls edge onto the private
    L1174 implementation; parseURLWithValidationErrors is bound the same way from L1224. Identical
    on 0.9.49, so this path predates 0.9.50.

    4. [email protected] — dist/commonjs/api/manipulation.js (29 nodes, 59 edges). The #3035 path lands on an occupied id.

    function _wrap(insert) {                                          // L240
    exports.wrap = _wrap((el, elInsertLocation, wrapperDom) => {      // L318

    normalize_id('_wrap') == normalize_id('wrap') == 'wrap', so both mint …_manipulation_wrap.

    nodes contains edges at …_manipulation_wrap node
    0.9.49 26 L240 _wrap() @ L240
    0.9.50 29 L240, L318 _wrap() @ L240
    0.9.52 29 L240, L318 _wrap() @ L240

    This is not a regression — exports.wrap had no node in 0.9.49 either, because no branch
    looked for it. What 0.9.50 changed is that the new branch now recognizes L318 and emits an
    ownership edge for it, while the node it tries to create is discarded. The file went from
    silently missing the export to claiming the private _wrap() helper is what lives at L318.
    wrapInner() @ L375, which has no same-file name conflict, does get its own node — so the feature
    works; it just cannot survive a collision.

    The 0.9.50 branch mints ids the same way as the older ones

    The exports.X = wrapper(fn) branch added for #3035 — the elif kind == "exports" arm at
    extractors/engine.py:2180 — calls _make_id(stem, member_name) at :2192, passes the result to
    add_node_fn at :2193 and emits contains at :2194, exactly as the three older sites do, so it lands in the same id space and is
    subject to the same first-wins drop. #3035 is closed as "Fixed in v0.9.50" and the feature does
    work — but on cheerio, one of its intended targets, the node it creates is discarded.

    _disambiguate_colliding_node_ids cannot repair any of this: extractors/resolution.py:684
    skips a group unless it has at least two nodes from at least two source keys
    (if len(group) < 2 or len(source_keys) < 2: continue), and the same-file
    loser was already suppressed by seen_ids before that pass runs.

    Worth naming as a pattern: #2779 (Go, fixed by PR #2780) and #3077 (Ruby, _ruby_sanitize_method_name)
    each solved this collision family inside one language's extractor, and 0.9.50 added a new
    id-minting branch without inheriting either fix. Any branch that mints a normalized id and hands
    it to add_node without disambiguation has this failure mode.

    Where this measurement is soft

    • "Collision event" is an inference, not a proven dropped declaration. The detector observes
      two ownership edges at distinct lines on one id. It does not read add_node call sites, so it
      cannot prove every event corresponds to a node that should have existed separately. Getter/setter
      pairs are the clearest case where reasonable people may say one node is correct — hence the
      second headline row. I have verified the four named packages by hand; the aggregate is not
      hand-verified.
    • It is therefore not a mathematical lower bound, though it does miss real collisions: two
      colliding declarations on the same physical line collapse into one set entry, a colliding path
      that emits no contains/method edge is invisible, and a collision against an id minted by a
      different node kind is invisible.
    • Axis counts are group-level tags. Where a group carries two tags, its events are counted
      under both; the table does not attribute an individual declaration to an individual axis.
      Attribution also matches only the final normalized id component against normalized definition
      names — it does not re-derive the full owning scope.
    • One corpus, and a biased one. Six node_modules trees from a single machine, heavy on build
      tooling and web libraries. These are locally installed package files; I did not verify each
      against the npm registry. It is almost all third-party code, but not entirely: one of my own
      published packages is installed as a dependency, and it accounted for 12 of the 4,517 recorded
      events. That file has since been deleted from disk, so it is present in the recorded results but
      is no longer re-extractable.
    • No project's own src tree was run through this detector. A separate scan did cover them —
      2,664 unique files across 30 project trees, excluding node_modules — but it looked only for CommonJS export
      shapes, which is not this measurement. For the record it found 55 files with exports.X = fn,
      none with exports.X = wrapper(fn), and no candidate collisions. That is not evidence of a zero
      for the detector used here.
    • published ≠ authored. Much of the corpus is TypeScript or Babel output. Transpilation both
      creates collisions (exports.X wrappers) and destroys them (renaming).
    • The corpus construction is not recoverable from the published artifacts — the six-tree
      selection and the 400 KB cap were applied when building the file list, not recorded in the
      results.
    • No downstream impact measured. These numbers describe the graph, not how often a collapsed
      node changes an answer from graphify query.

    Reproduction

    python -m venv /tmp/g52 && /tmp/g52/bin/pip install -q 'graphifyy==0.9.52'
    mkdir -p /tmp/g52fix && cd /tmp/g52fix && npm i --silent [email protected] [email protected] [email protected] [email protected]
    /tmp/g52/bin/python - <<'PY'
    from pathlib import Path
    from collections import defaultdict
    import tempfile
    from graphify.extract import extract
    
    for rel in ("glob/glob.js", "ignore/index.js",
                "cheerio/dist/commonjs/api/manipulation.js",
                "whatwg-url/lib/url-state-machine.js"):
        f = next(Path("/tmp/g52fix/node_modules").glob(rel), None)   # npm layout; under pnpm the
        if f is None:                                                # real path is
            print("missing:", rel); continue                         # node_modules/.pnpm/<pkg>@<ver>/node_modules/<rel>
        with tempfile.TemporaryDirectory() as cache:
            r = extract([f], cache_root=Path(cache), parallel=False)
        nodes = {n["id"]: n for n in r["nodes"]}
        lines = defaultdict(set)
        for e in r["edges"]:
            if e["relation"] in ("contains", "method"):
                lines[e["target"]].add(e.get("source_location") or e.get("line"))
        print(f"== {rel}: {len(r['nodes'])} nodes, {len(r['edges'])} edges")
        for nid, ls in lines.items():
            if len(ls) > 1:
                n = nodes.get(nid)
                print(f"   {nid.split('_')[-1]:16} edges {sorted(ls)}  surviving node: "
                      f"{n and n.get('label')} @ {n and (n.get('source_location') or n.get('line'))}")
    PY

    Expected:

    == glob/glob.js: 27 nodes, 73 edges
       glob             edges ['L117', 'L62']  surviving node: glob() @ L62
    == ignore/index.js: 41 nodes, 75 edges
       add              edges ['L470', 'L492']  surviving node: ._add() @ L470
       test             edges ['L641', 'L741']  surviving node: ._test() @ L641
    == cheerio/dist/commonjs/api/manipulation.js: 29 nodes, 59 edges
       wrap             edges ['L240', 'L318']  surviving node: _wrap() @ L240
    == whatwg-url/lib/url-state-machine.js: 42 nodes, 93 edges
       basicurlparse    edges ['L1174', 'L1190']  surviving node: basicURLParse() @ L1174
    
  4. hementhu commented on Oct 15, 2026

    @hementhu
    Contributor

    I'd like to take the Python part of this.

    On v8 (0.9.91) the #3302 pre-scan already separates function/function and method/method collisions (parseURL/parseUrl, visit_TEXT/visit_text both survive). Module-level class names aren't in that pre-scan, though, so a class that shares an id with a function or another class still loses one declaration, and which one survives depends on declaration order:

    • class Session / def session(): on requests/sessions.py itself, session() is absent from the graph
    • class Foo / class FOO
    • class Pair / class _Pair

    I have a narrow fix that extends that pre-scan to module-level classes, with regression tests, and will open a PR shortly. @abdulsamie10, #3322 covers this area too. If you're still planning the narrowed version you mentioned, tell me and I'll step back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions