fix(frameworks): a framework resolves only references written in its own languages
Problem
ReferenceResolver.resolveOneInner's Strategy 1 ran every detected framework's resolve() on every reference, whatever its language. Each FrameworkResolver declares languages, but only extraction read it (getApplicableFrameworks in parse-worker.ts / tree-sitter.ts). gateFrameworkLanguage only rejects a target across a code boundary, and passes every calls result, so a JS framework's naming rule could still resolve a Go reference to a Go node.
In etcd (Express is detected there by the file-content scan; there's no package.json), 7 Go references carried {"framework":"express","resolvedBy":"framework"}. One example: func (s *mockServer) Logger() *zap.Logger linked its result type to the method itself, through Express's logger middleware rule.
Several resolvers had already grown their own if (ref.language …) return null for this (React #2211, Vue, SwiftUI/UIKit/Vapor, Spring after #1825, Go since #2408). Express, NestJS, Angular Router, Django/Flask/FastAPI, Rails, Laravel, Play, Drupal, ASP.NET, Rust and CICS had none, and Svelte had one only for $store subscriptions.
Fix
- New
getResolvingFrameworks(detected, language)inframeworks/index.ts. Strategy 1 now loops only over the frameworks that read the reference's language:resolveLanguagesif set, elselanguages, and frameworks declaring neither stay universal (Vue, Nuxt, Astro). The per-language list is memoized on the resolver and cleared ininitialize(). - New optional
FrameworkResolver.resolveLanguages, for a resolver whoseresolve()reads languages it extracts nothing from. Wideninglanguagesinstead would runextract()on those files, and an applicable framework withextract()also takes a file off the kernel's deferred-decode path. Two resolvers need it:- svelte:
['svelte', 'typescript', 'javascript']. SvelteKit route modules (+page.server.js,hooks.server.ts) import$lib/…/$app/…, and Svelte 5 runes live in.svelte.ts/.svelte.js. Without this, svelte-realworld loses 12$libimport edges from.jsroute modules. - aspnet:
['csharp', 'razor']. A Razor page's@model IndexModelnames the PageModel in the code-behind beside it. Its folder namespace (…Pages.Basket) is never@using-imported, so only ASP.NET's beside-the-page pick finds it. Without this, eShopOnWeb loses 4 correct@modeledges, and 34 more get re-resolved by plain name matching.
- svelte:
claimsReference()deliberately stays universal (there's a comment at the pre-filter). Narrowing it too dropped 858 correct protobuf C++ calls written with a leading::(::_pbi::PrivateAccess::GenerateParseTable). The name pre-filter reads no leading::, and those calls get past it only because the Swift ↔ Objective-C bridge (detected because protobuf ships 3.swiftfiles) claims any name with a:in it. A C++-only repo already drops them (rocksdb: 822 refs). I've filed that as a follow-up; once the pre-filter reads a leading::, claims can be narrowed the same way.- Removed the stale "
languagesgates only extraction" comments inreact.ts/swift.ts.
Cross-language resolvers audited
Each one lists the language its references are written in, so none is affected:
| resolver | resolve languages | evidence (framework edges, unchanged) |
|---|---|---|
Drupal routing.yml → PHP controller | php, yaml | admin-toolbar: 16 from yaml, 31 from php |
| React Native bridge (JS → native) | JS/TS/TSX/JSX (+objc for extraction) | rn-geolocation 4, async-storage 16 |
| Swift ↔ Objective-C bridge | swift, objc | async-storage 11, expo-wechat 1, protobuf 16 |
| Expo modules (native side resolves nothing; JS side) | swift,kotlin / TS, TSX, JS, JSX | expo-wechat 1 |
| Fabric view (resolves nothing; a synthesizer bridges) | — | — |
SvelteKit $lib / runes | svelte + TS/JS via resolveLanguages | svelte-realworld 12 from .js |
ASP.NET Razor @model | csharp + razor via resolveLanguages | eShopOnWeb 38 from .cshtml |
Open PRs that add bridge resolvers already declare their source languages: #878 (Tauri: the JS family + svelte + rust) and #714 (Salesforce). #2331's Lua→Rust bridge isn't a FrameworkResolver.
Validation
A/B on 28 repos at main 5ace306b (#2403 landed after; it touches sync's failed-ref tails only, so a fresh index is unaffected). The two arms used the same dist and the same kernel, differing only in the changed resolver files. Each repo was fully indexed per arm, and resolved edges were diffed by site (source, line, col, refName, refKind), with synthesized edges and unresolved statuses diffed too.
| repo | languages | framework edges | changed sites |
|---|---|---|---|
| etcd | Go (+Express detected) | 1418 | 4 dropped, 2 retargeted, 1 metadata |
| harbor | Go, TS, Python | 1732 | 6 dropped |
| traefik | Go, TSX | 690 | 2 metadata |
| bitwarden | TS, Rust | 535 | 1 dropped |
| prometheus, gin-vue-admin, chushi | Go + TS/Vue/JSX | 2974 / 90 / 39 | 0 |
| protobuf | C++, Go, Java, C#, PHP, ObjC, Swift… | 16 | 0 |
| admin-toolbar (Drupal), laravel-realworld | PHP, YAML, JS | 47 / 12 | 0 |
| rn-geolocation, async-storage, expo-obytes, expo-wechat | RN / Expo | 4 / 31 / 3 / 2 | 0 |
| eshop, clean-arch | C#, Razor / C#, TS, JSX | 55 / 13 | 0 |
| fastapi-template, svelte-realworld, nuxt-movies, stalux | Python+TSX, Svelte, Vue, Astro | 12 / 43 / 8 / 78 | 0 |
| proshop, bookbrainz-site, outline | Express/Koa + JSX/TSX | 20 / 26 / 277 | 0 |
| play-samples, spring-petclinic, vispana | Scala/Java/routes, Java, Java+JS | 116 / 10 / 1 | 0 |
| vapor-clean, carddemo | Swift, COBOL/CICS | 39 / 24 | 0 |
No edge was added and no synthesized edge changed anywhere. Every changed site came from Express's naming rules applied to another language's code:
- etcd, dropped (all wrong):
func (s *mockServer) Logger() *zap.Loggerandfunc (s *EtcdServer) Logger() *zap.Logger: the result type linked to the method itself.isLearnerReady(lg *zap.Logger, …): the parameter type linked to theEtcdServer.Loggermethod.a.options.AuthStore.Authenticate(…)insideapplierV3backend.Authenticate: linked to the calling method itself.- All four are now unresolved. zap is external, and the auth store's receiver type isn't inferred.
- etcd, retargeted:
srv.(AuthServer).Authenticate(ctx, in)atrpc_grpc.pb.go:1813,1820went from the client'sAuthClient.AuthenticatetoUnimplementedAuthServer.Authenticate. That's what name matching gives every other handler in the file (srv.(KVServer).Range→UnimplementedKVServer.Range). The exact target, the asserted interface's method, is a pre-existing Go gap, filed separately. - etcd / traefik, metadata only:
Validate(…)andsanitizeDomains(…)keep their same-file target, now by exact name (0.7) instead of Express (0.8). - harbor, dropped (all wrong):
self.jaeger.validate()andself.otel.validate()were linked toInternalTLS.validate; the receivers are aJaegerExporterand anOtelExporter.- Four
conf['trace'].validate()-style calls were linked to the callingvalidatefunction itself.
- bitwarden, dropped (wrong):
biometric_lock_system.inner.authenticate(…)inside the napiauthenticatewas linked to that function itself.
Tests
__tests__/framework-resolve-language.test.ts:getResolvingFrameworksunit cases.- The etcd shape (Express beside Go): fails on main, passes here.
- Two controls that pin the exemptions, both passing on main: a SvelteKit
+page.server.tsimport * as api from '$lib/api', and two RazorIndexpages that each bind@model IndexModelto their own code-behind. Droppingtypescriptfrom Svelte's orrazorfrom ASP.NET'sresolveLanguagesfails exactly the matching control.
tsc --noEmitis clean.- The 77 framework/bridge-related test files pass. Five timed out at 5 s while 28 repos were indexing next to them, and all five passed serially.
- Full suite on this Windows box, run in parallel under load: 6381 passed and 44 failed. All 44 were in the load-sensitive sync, git, WAL, MCP and oversize files: 41 timeouts, an EBUSY, a 2.1 s vs 2.0 s timing bound, and one oversize-file assertion.
- Rerun serially with long timeouts, those 22 files pass (976 of 978, 1 skipped). The one exception is function-ref's #1820 "module global" case, which hits its own 60 s limit on main 5ace306b too.
🤖 Generated with Claude Code