Repository navigation
Description
Discovered while addressing a Greptile PR #2028 review finding (constructor-call attribution through a renaming barrel export).
Context: PR #2028 fixed a bug in the TypeScript engine where attachConstructorTargets used the call site's (possibly barrel-aliased) name instead of the barrel-resolved true declared name when building the qualified constructor-method lookup key. That fix only touches src/domain/graph/builder/call-resolver.ts.
While verifying whether the Rust engine (crates/codegraph-core/src/domain/graph/builder/stages/build_edges.rs) needed an equivalent mirrored fix, I found the underlying mechanism is architecturally different — and the Rust side appears to be missing barrel-hop resolution for call edges entirely, not just for the new constructor-attribution feature:
- TypeScript's
resolveCallTargetshas an explicit fallback: when the direct(name, importedFrom)lookup misses andlookup.isBarrel(importedFrom)is true, it callslookup.resolveBarrel(importedFrom, targetName)to find the name/file actually declared in the barrel's re-export chain, then re-queries with that resolved name/file. - Rust's
resolve_call_targets_core(build_edges.rs, spans roughly lines 1019–1337) has no equivalent step anywhere in its tiers. Its "1. Import-aware resolution" tier does a single directctx.nodes_by_name_and_file.get(&(target_name, imp_file))lookup with no barrel fallback if that misses.ctx.nodes_by_name_and_fileitself (built inEdgeContext::new) is keyed purely by each node's own declared(name, file)— no barrel-alias entries are pre-seeded either. - Rust does have substantial barrel-handling code (
barrel_resolutionmodule,resolve_barrel_export,emit_barrel_through_edges, etc.), but on inspection this is used for import-edge emission (the file-level import graph), a different edge kind from the calls edgesresolve_call_targets_coreproduces.
Suspected impact: a call site that constructs (or calls a method on) a class imported through a barrel that renames the export (export { Foo as Bar } from './foo'; ... new Bar()) may not resolve to any calls edge at all in the native/Rust engine, whereas the WASM/TypeScript engine resolves it correctly via the resolveBarrel fallback. This would be a pre-existing engine-parity gap, not something introduced by PR #2028 — that PR's own constructor-attribution addition just uses the same imported_original_names primitive the rest of Rust's call resolution already relies on, so it doesn't add a new divergence beyond whatever already exists here.
Not yet verified: I have not confirmed with an end-to-end repro (only via static code reading) that this actually produces a missing/divergent edge for a real barrel-renamed construction call under the native engine — that would be the first step of investigating this. If confirmed, the fix would add a genuine barrel-hop tier to resolve_call_targets_core, mirroring the TS isBarrel/resolveBarrel fallback, which is a non-trivial, separate change from the narrow constructor-attribution fix in PR #2028.
Activity
fix: use the barrel-resolved true name for constructor attribution (#…
carlos-alm commentedon Aug 7, 2026
Investigated with concrete repros as part of a `/fixer` pass — the suspected gap does not actually exist. Closing as not reproducible / already correctly handled.
What I tested: three scenarios against both engines (WASM and a locally rebuilt native addon), each with a barrel that renames the export (`export { Foo as Bar } from './foo.js'`) and a call site that constructs through the renamed binding:
All three resolved correctly in both engines — identical `calls` edges, same target file, same constructor-method attribution.
Why the static-reading suspicion didn't hold up: the issue's diagnosis of `resolve_call_targets_core` itself (no `isBarrel`/`resolveBarrel` fallback tier) is accurate, but the conclusion doesn't follow — that resolution already happens upstream, before Rust ever sees the call. `ImportedName` (the struct the NAPI boundary passes into Rust) is populated by `buildImportedNamesForNative` in `src/domain/graph/builder/stages/build-edges.ts`, which calls the exact same `traceBarrelTarget`/`resolveBarrelExportCached`/`isBarrelFile` helpers the WASM path's `resolveCallTargets` uses (unified under `traceBarrelTarget`, #2071, specifically to prevent this kind of divergence). By the time `resolve_call_targets_core`'s import-aware tier runs, `imported_from`/`target_name` are already the fully barrel-dereferenced file and declared name — confirmed directly by temporarily instrumenting `resolve_call_targets_core` and tracing the two-hop repro: `call.name="Bar" target_name="Foo" imported_from="foo.ts"`, i.e. already resolved through both hops before the Rust function's first lookup.
So Rust doesn't need its own barrel-hop tier because the TypeScript orchestration layer that prepares its input already did the hop — a different architecture from the WASM path's inline fallback, but not a parity gap. No code change made.