Repository navigation
Description
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_nodepattern 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) … } // L1113JS 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:
- The second declaration vanishes — no node for it anywhere in the graph.
- Its body edges are misattributed to the surviving sibling.
local_bound_namesis overwritten for the shared id.- A fabricated
indirect_callfollows 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
abhay-codes07 commentedon Aug 17, 2026
Confirmed on a second platform (Windows, Python 3.12, v0.9.44), one file per case, counting only symbol nodes:
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.jsonpoint 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:
_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;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.
imagineers-tyler commentedon Aug 18, 2026
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
v8and released in v0.9.45 — themaintainer's closing comment on #2779 says so directly. It shows as
CLOSEDwithmergedAt: nullbecause of the cherry-pick, which is easy to read as "still open"; I misreadthat same signal on my own PRs earlier.
The installed 0.9.45 carries the logic you describe, in
graphify/extractors/go.py, reasoningincluded:
and Go
func Run()+func run()yields two nodes on 0.9.45 where 0.9.44 yielded one. So theshape is settled, not in flux.
On
_xas the analogue of Go's unexported — I went looking, and it does not holdI 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:
And they are referenced through objects, not just
this. Countingx._y(call sites andexcluding
this.:obj._x()totalthis.with shapes like
locator._expect()(×31),testInfo._runWithTimeout(),suite._addTest(),SchemaType._isRef()(×13),schema._getSchema().These counts demonstrate ordinary use through non-
thisreceivers, so underscore-prefixedmembers are not merely private implementation details. At least one representative group is
directly cross-file:
SchemaType._isRefis defined inlib/schemaType.js:1659and called fromlib/schema/{number,objectId,date,decimal128,array,string}.js. The raw totals themselves arereceiver-call counts, not a count of verified cross-file edges —
testInfo._runWithTimeout, forinstance, 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
_xis explicitly importable (theunderscore only affects wildcard imports). I do not think
_x/xcan inherit Go's policy onthis 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/xis the one axis where the Go argument transfers by guaranteeA private class element is language-enforced; in this repro
#p()is a private method: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
_xcase it is a guarantee rather than a survey, so salting the
#member cannot invalidate alegitimate 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 ispublic 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:
Neither mints an owner node, so both methods fall back to a file-level id. On 0.9.45:
The plain id
index_onbegingoes to whichever member is declared first, and the node countrises 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:
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.
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 itfinds no name (
engine.py:2957-2966) — these two methods would regain distinctclass-qualified ids and this particular collision would disappear. Worth deciding whether the
id policy is written against today's
class_typesor 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.
fix(csharp): emit member nodes for properties only, not fields
imagineers-tyler commentedon Aug 30, 2026
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
.jsfile under sixnode_modulestrees on one machine, deduplicated bySHA-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 physicalline 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 cachereuse between files.
Detector. For every node id, collect the source lines of the
containsandmethodedgespointing 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_nodecall sites, so it does not by itselfestablish that a second node was attempted and discarded. That is the mechanism this issue is
about —
add_node(extractors/engine.py:2995) returns early onif nid in seen_idsat: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 definitionsite by line number — recursively, not only at top level: declarations, class members with
get/set/staticdistinguished, andexports.X/module.exports.Xassignments — thenmatch 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
get/setpairThe 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.jsstartTime, L511/L514 and L544/L547), an accessor pair sharingits id with a private method (
undici/lib/web/websocket/websocket.js:get/set onmessageand#onMessageat L526, in two corpus copies), two getters and one setter(
three/src/materials/nodes/NodeMaterial.jstype), and a getter whose leading underscore isstripped into the pair (
jsdom/.../HTMLProgressElement-impl.js:_valueL18,valueL47/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".
get/setaccessor pair_$#staticmethod vs instance methodexports.X = fn(CommonJS)exports.X = wrapper(fn)(the #3035 path, added in 0.9.50)The
_x/xrow deserves separate mention: 206 files. That is the ordinary JS private-helperconvention, and
normalize_id'sre.sub(r"_+", "_", …)followed by.strip("_")maps bothspellings 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 exportedGlobconstructor has no node.Both mint
…_glob_glob. Twocontainsedges (L62, L117) point at one node, and that node isglob()@ L62. No node labelledGlob()exists in the file. (Globis a constructor functionhere, not a
classdeclaration — 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).Survivors:
._add()@ L470 and._test()@ L641. So the publicIgnore.test()is gone,displaced by a private helper, and internally
RuleManager.add()is gone too. Method ids areowner-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.Two
containsedges (L1174, L1190), survivorbasicURLParse()@ L1174. The call at L1214goes through the exported wrapper, but the graph records it as a
callsedge onto the privateL1174 implementation;
parseURLWithValidationErrorsis bound the same way from L1224. Identicalon 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.normalize_id('_wrap') == normalize_id('wrap') == 'wrap', so both mint…_manipulation_wrap.containsedges at…_manipulation_wrap_wrap()@ L240_wrap()@ L240_wrap()@ L240This is not a regression —
exports.wraphad no node in 0.9.49 either, because no branchlooked 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 featureworks; 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 — theelif kind == "exports"arm atextractors/engine.py:2180— calls_make_id(stem, member_name)at:2192, passes the result toadd_node_fnat:2193and emitscontainsat:2194, exactly as the three older sites do, so it lands in the same id space and issubject 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_idscannot repair any of this:extractors/resolution.py:684skips 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-fileloser was already suppressed by
seen_idsbefore 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_nodewithout disambiguation has this failure mode.Where this measurement is soft
two ownership edges at distinct lines on one id. It does not read
add_nodecall sites, so itcannot 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.
colliding declarations on the same physical line collapse into one set entry, a colliding path
that emits no
contains/methodedge is invisible, and a collision against an id minted by adifferent node kind is invisible.
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.
node_modulestrees from a single machine, heavy on buildtooling 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.
srctree 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 exportshapes, 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 zerofor the detector used here.
published ≠ authored. Much of the corpus is TypeScript or Babel output. Transpilation bothcreates collisions (
exports.Xwrappers) and destroys them (renaming).selection and the 400 KB cap were applied when building the file list, not recorded in the
results.
node changes an answer from
graphify query.Reproduction
Expected:
hementhu commentedon Oct 15, 2026
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_textboth 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(): onrequests/sessions.pyitself,session()is absent from the graphclass Foo/class FOOclass Pair/class _PairI 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.
fix(python): salt module-level class ids that collide with a function…
fix(go,rust): keep same-file declarations whose names differ only by …
fix(python): extract explicit type aliases as type nodes
fix(python): extract explicit type aliases as type nodes
fix(python): extract explicit type aliases as type nodes
fix(extract): link docstrings of colliding names to salted ids
fix(ids): keep module-level _x and x as distinct declarations (#2810)
fix(php): keep _x() and x() methods of one class as distinct nodes
chore(cache): combine the schema-44 comment for the 0.9.107 batch
fix(lua): keep `M._name`/`M.name` function twins apart in node ids