Repository navigation
Description
Summary
The AST extractor resolves a member call whose method name matches a function declared in the same file to that local function, instead of to a method on the receiver's type. The result is a false calls self-loop edge on the local function.
Reproduced on graphify 0.9.74, graphify update . (AST-only path), TypeScript sources.
Repro
Case A — DOM method
// packages/portal/src/components/ui.tsx
export function confirm(message: string): boolean {
return window.confirm(message);
}window.confirm is a Window method. The graph records confirm() in ui.tsx as calling itself (calls edge, source == target).
Case B — class field receiver
// packages/web/src/ChatClient.ts
close(): void {
// ...
const socket = this.socket;
if (socket) {
this.detach(socket);
socket.close(); // WebSocket.close()
}
}socket.close() is WebSocket.prototype.close. The graph records ChatClient.close() as calling itself.
Diagnosis
The resolution appears to ignore the receiver expression and match on the member name alone:
window.confirm(message)→ matches localconfirm(wrong)socket.close()→ matches own methodclose(wrong)this.emitStatus(...),this.clearTimers(...),this.detach(...)→ resolve correctly (the receiver isthis, and those names don't collide)
So the failure is specifically receiver-scoped name collision on a non-this receiver. this.method() and module-level calls resolve correctly; expr.method() where expr is not this does not consult expr's type.
Impact
Small in edge count but visible in every health report, because these surface as self_loop_edges in:
graphify diagnose multigraph
In the repro repo, 2 of 387 calls edges are misresolved this way. They are indistinguishable from genuine recursion, so a reader has to open the source to classify each self-loop. That is the real cost: the diagnostic cannot be trusted as a regression signal without manual triage.
Suggested fix
When resolving receiver.method(...):
- If
receiveristhis/self, resolve against the enclosing class/struct — current behaviour is already correct here. - Otherwise, resolve against the inferred type of
receiver. For known globals (window,document,console,globalThis,process) consult the ambient/global type rather than local scope. - Only fall back to a same-file name match when the receiver type is unknown and no matching symbol is reachable on the receiver — and in that fallback, prefer emitting no edge over a self-loop.
Also worth considering: the Window.confirm / WebSocket.close cases would both be fixed by seeding ambient lib types (lib.dom.d.ts) as known symbol sources.
Related
graphify diagnose multigraph reports self_loop_edges without distinguishing genuine recursion from misresolution. Tagging the provenance (e.g. relation_source: lexical | inferred) would let consumers filter, and would have made this triagable without reading source.
Activity
github-actions commentedon Oct 5, 2026
Thanks for opening this issue, @LukeStanbery89. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
docs: #108 phase 4 — refresh graphify baseline + classify all 11 self…