Repository navigation
Description
Version: graphifyy 0.9.44
Environment: macOS arm64, Python 3.12/3.14 (Go codebase, tree-sitter-go)
Related: #993 (case-insensitive resolution, fixed in 4dce16f — this is a different layer: the fix made lookup case-sensitive, but the extractor still emits casefolded node ids), #2774 (Rust: same symptom — private fns absorbing edges via bare-name identity — different trigger), #438 (id collision across files; this one is within a single file, which _disambiguate_colliding_node_ids explicitly skips via its len(source_keys) < 2 guard)
Summary
Node ids are casefolded (ids.py:normalize_id), so a Go file that declares both an
exported Run and an unexported run produces the same id for both. The
extractor's add_node dedups on id alone and silently drops the second
declaration (extractors/go.py, first-wins). Two failure modes follow:
- The unexported sibling vanishes from the graph. Its declaration produces
no node, and the edges of its body are attributed to the exported sibling's
node. - Its call sites resolve to another package. The call
run(1)insideRun
finds no localrunnode, so the (case-sensitive, post-Case-insensitive call resolution generates phantomcallsedges in Ruby (Punditauthorize→Authorizemarker class) #993) resolver's only
candidate is a same-named unexported function in a different package — an
INFERREDcallsedge that Go's visibility rules make impossible
(unexported identifiers are package-private;mainpackages cannot be
imported at all).
The Run() { return run(...) } exported-wrapper / unexported-worker pattern is
idiomatic Go (it is how test seams are injected), so real codebases hit this.
Minimal repro
// go.mod: module example.com/repro
// pkga/a.go
package pkga
func Run() error {
return run(1)
}
func run(n int) error {
return nil
}
// pkgb/b.go
package pkgb
func run(s string) error {
return nil
}$ graphify (extract over both files)
nodes:
pkga_a_run Run() pkga/a.go:L3 <- run() L7 is MISSING
pkgb_b_run run() pkgb/b.go:L3
edges:
pkga_a_run -calls-> pkgb_b_run [INFERRED 0.8] <- impossible
Expected: two nodes for a.go (Run L3, run L7) and one
Run -calls-> run edge inside the file.
Control: rename Run to Start (no case collision) and the output is correct —
both nodes appear and Start -calls-> run binds within the file. The trigger is
the id collision, not the resolver.
Impact on a real corpus
On a private Go codebase, one file declares two such exported/unexported pairs:
- 2 of that file's 10 functions are missing from the graph
- a phantom
callsedge crosses from the exported wrapper into an unrelated
mainpackage (which cannot be imported at all), and surfaced in
GRAPH_REPORT.md's "Surprising Connections" as if it were an architectural
insight - 5 body edges of the dropped functions (
callsandreferencesemitted while
walking their bodies) are misattributed to the exported siblings
A quick audit rule — "calls edge crossing a package boundary whose target name
starts lowercase" — is guaranteed-false by the language and found exactly this
one instance in that corpus, so the failure is systematic but low-noise.
Where it sits
ids.pycasefolds by design (AST / LLM / builder id parity — Chinese/Unicode identifiers cause silent node deduplication — only 8 of 202 functions captured #811, Node ID collision when multiple files share the same filename (e.g. ASP.NET Razor Pages) #550,
AST and semantic extractors generate mismatched node IDs for the same file, splitting it into two disconnected nodes #1033, Unable to install with uv tool install graphifyy #1104), so "stop lowercasing" is not an option.- Case-insensitive call resolution generates phantom
callsedges in Ruby (Punditauthorize→Authorizemarker class) #993's fix is in the resolution index and works; the missing node is
produced one layer earlier, at extraction. _disambiguate_colliding_node_idsonly handles collisions across files
(len(source_keys) < 2skips same-file groups), and its remap key
(old_id, source_key)cannot distinguish two symbols in the same file.
I have a patch ready (extractor-level: detect case-only collisions per file,
keep the plain id on the exported member — the one cross-package edges and docs
actually reference, so incremental rebuilds don't re-point stored edges — and
salt the unexported sibling), with tests that fail on unpatched v8, plus
full-suite (4520 passed) and real-corpus A/B verification. PR follows.
Activity
imagineers-tyler commentedon Aug 16, 2026
This reproduces outside Go, and the trigger is wider than casefolding — which matters for
where the fix goes.
normalize_idruns several lossy normalization stages, yielding at least five collision axes.Four are visible in ordinary ASCII identifiers — casefolding, punctuation replacement,
repeated-underscore collapse, and edge stripping — and NFKC adds a Unicode
compatibility-collapse axis:
Case (your
Run/run) is one axis. The others collide just as silently, and some collisionscome from stages combining rather than from any single one —
#closeis#close→_close(punctuation) →close(edge strip).NFKC-induced collisions — each pair is already equal immediately after the first NFKC step,
before casefolding or punctuation handling:
One file, two sibling declarations — graphifyy 0.9.44
Same shape as your repro: the second declaration produces no node.
class R { _onBegin(a){} onBegin(b){} }._onBegin()_class W { #close(a){} close(b){} }.#close()declare class Q { $set(a); set(b); }.$set()function parseURL(a){}+function parseUrl(b){}parseURL()def _run(a)+def run(b)_run()_def a_(p)+def a(q)a_()_def alpha(p)+def beta(q)alpha(),beta()make_idon each pair:Which member survives is declaration order (first-wins), not visibility: in my synthetic
cases the private one survived, in happy-dom's real files the public one does.
The
#close/closecase is worth calling out separately:#closeis a private classmethod, a distinct language-level member that can coexist with
closeby design — not anaming convention the extractor could reasonably fold.
Confirmed on real files, with controls
Run through
extract()on 0.9.44, one file at a time:websocket/WebSocket.js#close/closecloseonly —#closelostxml-serializer/XMLSerializer.js#serializeToString/serializeToStringnodes/html-form-element/HTMLFormElement.js#submit/submitdocument.d.ts$set/set$setonly —setlostlib/runner/index.js_onBegin/onBegin_onBeginonly —onBeginlostThe playwright one has the same control you used. Renaming only the private half:
The public method reappears and the node count goes up by exactly one, so the trigger is the
id collision, not one of the "methods not extracted" gaps (#2419 / #2110 / #2524).
That pair is declared in two different classes in that file and still collides, which is
worth unpacking because it shows a second ingredient. Both owners are class expressions:
JS
class_typesisfrozenset({"class_declaration"}), and the TS set adds onlyabstract_class_declaration/interface_declaration/enum_declaration/type_alias_declaration— no class-expression type in either. So neither expression mints anowner node (the extraction produces no
TeleReporterReceiver/TerminalReporternode atall), and their methods fall back to file-level ids rather than class-qualified ones:
The observed id for the surviving node is exactly that file-level form, and its label is
_onBegin()rather than._onBegin(), i.e. it was registered as a file-level function, not amethod. So the normalization collision and the lost ownership qualifier compound: without an
owner to qualify against, two methods from unrelated classes land on one id.
Your second failure mode reproduces too (Python)
The collision is required — delete
runand the phantom goes away.run's shadow set ({x})lands on the surviving
_runentry, so_run's ownhelperparameter stops shadowing and theargument resolves by name to the imported
helper. Same mechanism as your misattributed bodyedges, reached through the shadow-set path instead of the resolver.
Why this changes the fix's scope
Your read of the mechanism matches what I see, including that
_disambiguate_colliding_node_idsskips this case — on 0.9.44 the guard is stillso a within-file collision (one
source_key) never reaches the salting path.The part I'd add: a fix scoped to Go, or scoped to case-folding, leaves the other axes live
across the shared extractor stack wherever each language's identifier grammar admits those
forms, since
ids.pyis shared by all extractors.On where it could go — one caveat worth stating up front, since it constrains the obvious
answers.
ids.py's 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), so changing
normalize_iditself has a wide blastradius. That might argue for a collision-aware declaration-registration layer near the
seen_idscheck, keyed by the raw declared name. But that layer would have to return theresolved id and propagate it, because today the caller owns the id and keeps using its own
copy after
add_nodereturns nothing — e.g.engine.pyaround the function-def site:add_edge,callable_def_nids,local_bound_names,function_bodiesand the per-languagetables all key off the caller's
func_nid. Salting insideadd_nodealone would move the nodeand leave every one of those pointing at the old id, so that is not a small change — I'm
raising it as a constraint on the design rather than proposing it as the fix.
Related, on the "wider than one language" point: #1522 (closed) reached the same conclusion
about
normalize_idfrom the path axis, calling it lossy and unsuitable for generatingunique keys. This issue is the symbol-name axis of the same argument.
Environment: graphifyy 0.9.44, macOS arm64, Python 3.14.7. Synthetic repros are single-file
except the Python phantom-edge one (two files); the confirmed rows are real files from
node_modules, extracted individually.
I also have an approximate candidate scanner and raw package lists available, but I have kept
the claims above to the five sites confirmed through
extract().fix(go): keep both halves of a case-only symbol collision (#2779)
test(go): cover method-level and all-exported case-only collisions (#…
chore: bump to 0.9.45
safishamsi commentedon Aug 16, 2026
Fixed in v0.9.45 (on PyPI now) via #2780, thanks @catpotd. Closing.
chore: bump to 0.9.46
fix(csharp): emit member nodes for properties only, not fields
feat(kernel): Go native walker
Fix Python leading-underscore method/function id collision
fix(go,rust): keep same-file declarations whose names differ only by …
fix(serve): a name spelled exactly wins a lookup tie that is only case