Repository navigation
Description
Problem
Semantic (LLM subagent) extraction can emit [calls] [INFERRED] edges whose source and target are in different languages, by mapping a call-site identifier in one language to a same-named definition in another language that happened to be in the same subagent chunk.
The result: a single low-importance symbol (a const cancel = ... local in a JS test file) becomes a graph hub with inbound calls from 17+ communities of Go code, polluting community detection, god-node ranking, and queries.
Concrete repro
In a mixed Go + TypeScript repo (≈ 700+ files, semantic extraction via Claude Code subagents, graphifyy 0.8.10):
The node:
id: clusterdetail_clusterjobsstorage_test_cancel
label: cancel
file: ui/src/pages/ClusterDetail/clusterJobsStorage.test.ts L52
Its definition is a local const inside a Vitest it() block:
const cancel = runSupportBundleSimulation(clusterId, { ... });Not exported. Not a function definition. Not reachable from anything outside that it() block.
The spurious inbound edges: 28 INFERRED calls edges, 100% from .go source files, e.g.
{
"source": "re_sim_main_runregister",
"target": "clusterdetail_clusterjobsstorage_test_cancel",
"relation": "calls",
"confidence": "INFERRED",
"confidence_score": 0.8,
"source_file": "api/cmd/re-sim/main.go",
"source_location": "L300",
"weight": 1.0
}The Go sites are all ctx, cancel := context.WithCancel(ctx); defer cancel() — the standard Go context-cancel pattern. They invoke the local closure returned by context.WithCancel, which has nothing to do with the JS variable.
These edges span 17 communities (worker tests, otel tests, healthz handlers, sim runners, HTTP handlers, …), making cancel look like a top god node.
Why I think this happens (not 100% certain on the internals)
This is not the AST cross-file resolver — that's per-language. Hard evidence:
- All 28 spurious edges have
confidence: INFERRED(AST emits EXTRACTED) - Source ext: 100%
.go, target ext:.ts(no Go AST extractor would produce a TS target)
So the edges came from a semantic subagent. The most plausible mechanism: the subagent's chunk contained both api/cmd/re-sim/main.go and ui/src/pages/ClusterDetail/clusterJobsStorage.test.ts. When the model saw cancel called in main.go, it scanned its visible window for a cancel definition, found the JS const cancel, and serialized the full long-form ID as the edge target. The skill prompt tells the model how to build IDs but doesn't tell it what to do when the only available definition is in a different language.
Related issues
Distinct from but related to:
- Cross-file inference creates false edges via common .NET method names #437 (open) — .NET BCL name collisions in AST cross-file resolver
- Cross-file INFERRED
callsresolution lacks import evidence + ambiguous-candidate handling — short common names blow up god_nodes ranking #543, Phantom god nodes from member-call name collisions in cross-file resolver #598, dedup.py Pass 1 exact normalization merges short generic labels across unrelated files, inflating god_nodes #895 (closed) — AST/dedup collisions on short generic labels - Surprising Connections still shows cross-language false positives (INFERRED edges between unrelated source files) #726 (open) — surprising-connections filter for cross-language false positives
- #908 (merged) / fix(extract): filter language built-in globals from call edges (#726) #916 — name-blocklist filtering for ambiguous cross-corpus names
The blocklist approach those PRs use would also help here (cancel is a strong candidate to add), but it doesn't solve the general case: any common identifier in a chunk window will produce the same failure. cancel is the most visible offender because of Go's context.WithCancel idiom, but Close, Start, Stop, Run, Get, Set, New, Error are all at risk.
Suggested fix (cheapest → most invasive)
-
Post-extraction validator (recommended for first cut). Drop semantic
callsedges whose source and target source-file extensions belong to different language families (.go↔.ts/.tsx/.js/.jsx,.py↔.go, etc.). Cross-languagecallsis essentially never legitimate; FFI/binding cases would still be detectable asreferencesor via explicit hints. Near-zero false positives, ~3 lines of code. -
Reject semantic edges to non-definition targets. A
const x = expr()inside a test block is a binding, not a callable definition. The extractor could flag nodes that don't represent functions/classes/methods and refuse to use them ascallstargets in semantic edges. This requires the extractor to know whether a node is "callable" — but it already distinguishesfile_typeand could add akinddiscriminator. -
Prompt hardening (best long-term). Add an explicit anti-rule to the subagent prompt:
Do not emit a
callsedge whose target lives in a file written in a different language from the source. The Go idiomctx, cancel := context.WithCancel(ctx); defer cancel()invokes the local closure returned bycontext.WithCancel, not any same-named symbol in another file or language.With an example. The current prompt's ID-format guidance is precise about how to name an ID, but silent on whether to draw the edge at all in this case.
(1) gives the biggest immediate quality win and is composable with (2) and (3).
Environment
- graphifyy 0.8.10
- Extraction backend: Claude Code subagents (no
GEMINI_API_KEYset) - Corpus: ~700 files, mixed Go (
api/) + TypeScript (ui/) - Graph: ~10k nodes, semantic chunk size 20–25 files
Activity
gnesher commentedon May 23, 2026
Second confirmed instance in the same repo, even more severe than
cancel:The node:
Defaultatui/src/foundation/filters/cluster-filters.stories.tsx:16— a Storybook story:Inbound edges: 39 total. 1 legit (
contains, EXTRACTED). 38 spurious INFERREDcalls— 100% from.gosource files, across 33 communities.Sample Go callers:
None of these can reach a Storybook story export. They're all Go stdlib
Defaultreferences (slog.Default,http.DefaultTransport,time.UTC-style defaults, etc.).Why this matters for prioritization:
Defaultis in the top-tier of "common across all languages" identifiers — Storybook conventions (export const Default), Go stdlib (slog.Default,http.DefaultTransport,tls.DefaultCipherSuites...), Python (default=), .NET (default(T)), TS enums (enum X { Default }). Any mixed-language repo with both aDefault-exported TS symbol and Go stdlib usage will exhibit this. In our 10k-node graph it produced one of the loudest god-node false positives.This supports the language-boundary post-extraction validator as fix #1 — it would have caught both
cancelandDefaultwith one ~3-line check, and the false-positive rate for a.go→.tsxcallsedge is essentially zero in practice (no FFI bridge between Go and TS storybook code is plausible).gnesher commentedon May 23, 2026
Third instance — and this one shows the bug isn't only cross-language, which has implications for the fix.
The node:
getEnvatapi/internal/config/config.go:332—func getEnv(key, fallback string) string. Note the lowercase name: Go's visibility rule makes this function callable only from withinapi/internal/config.Inbound
callsedges:.gosource filesapi/internal/config/✓ legitimate (within-package callers)api/internal/worker,api/internal/service/clusters,api/internal/auth,api/cmd/e2e-fixture, …) ✗ impossible — Go won't compile cross-package access to an unexported identifierThe 46 outside callers are real call sites in other packages that happen to invoke
os.Getenv(...)or a similarly named local helper. The semantic subagent collapsed all of them onto the onlygetEnvnode it could see in its chunk window.Why this matters for the proposed fixes:
Fix #1 (cross-language
.go↔.tsxvalidator) would catchcancel,Default,int(). It would not catch this — source and target are both.go. Yet the edges are just as impossible.This pushes Fix #2 ("reject semantic
callsedges to non-callable / non-reachable targets") higher up the priority list. For Go specifically, that means honoring the lowercase-is-unexported rule when validating semantic edges — an edge whose target identifier starts with a lowercase letter and whose source is in a different package directory is provably wrong. Similar visibility rules exist in other languages (Javaprivate, TSprivate/non-export, Python_-prefixed conventions, Rustpub).A minimum-effort version of Fix #2 that just covers Go visibility would already eliminate this class. Together with Fix #1, both
cancel/Default/int()(cross-language) andgetEnv(same-language, cross-package) would be caught.Fix case-sensitive call resolution and cross-language phantom calls (#…
safishamsi commentedon May 23, 2026
Fixed in 4dce16f: two-layer defense - (1) skill.md prompt now explicitly forbids cross-language calls edges; (2) build_from_json drops any INFERRED calls edge where source and target nodes live in different language families.
Fix case-sensitive call resolution and cross-language phantom calls (G…