Repository navigation
Description
Summary
A TypeScript named import from an external package can resolve to an unrelated exported project function that is never imported when the dependency is missing from package metadata. The resulting imports and calls edges are marked exact-match with provenance: null.
Verified on unmodified upstream source, not introduced by the fork customization. This issue tracks the demonstrated variant locally before conditional upstream submission on Tuesday, November 10.
Minimal reproduction
No package.json, tsconfig aliases, ambient declarations or dependency installation:
// main.ts
import { useForm } from 'react-hook-form';
export function entry() { return useForm(); }// decoy.ts — nothing imports this module
export function useForm() { return 42; }Index a fresh directory containing those files.
Expected: the external binding stays outside the project/unresolved; no edge targets decoy.ts.
Actual:
| Source | Kind | Target | Metadata |
|---|---|---|---|
| main.ts:1 | imports | decoy.ts:useForm | exact-match; null provenance |
| entry, main.ts:2 | calls | decoy.ts:useForm | exact-match; null provenance |
Removing decoy.ts removes the false edges. Merely declaring react-hook-form in a minimal package.json dependency entry also removes them without installing the dependency.
Independent upstream verification
Checked 2026-11-08 on Linux/WSL, Node 22.22.2, kernel 0/WASM:
| Subject | Pinned commit | Result |
|---|---|---|
| Official upstream v1.6.2 tag | 6560052a6f856855d3f71eee838fd66ccfa4285d |
Same 3 semantic failures, 4 controls pass |
| Official upstream main | f72c9d2efb14454ff4f9fd7b8460abd82f19a287 |
Same 3 semantic failures, 4 controls pass |
| Deployed em.40 fork | 5e0664891af0e87e6fd18bbfa16cab39237570f5 |
Same 3 semantic failures, 4 controls pass |
The two official upstream checkouts were cloned directly from colbymchenry/codegraph, installed using fresh locked dependencies with npm ci --ignore-scripts --no-audit --no-fund, then built with each checkout's official npm run build. No fork source, node_modules, runtime or grammar files were reused. Both upstream source trees remained pristine after build and testing.
All 21 fresh indexes completed successfully. The seven case/edge records match exactly across all three subjects.
Controls and failure condition
- External import with no decoy: no false edge.
- External import with matching local export: false import and call.
- Aliased import with a decoy matching the original export name only: no false edge.
- Aliased import with a decoy matching the local alias: false import and call.
- Inner function shadows the imported name: legitimate local call remains correct, but the import falsely targets the decoy.
- Dependency declared but not installed: no false edge.
- Genuine relative import beside an identical-name decoy: correctly calls the real module.
A fix must preserve legitimate lexical shadows and real module/alias/workspace/ambient resolution.
Source explanation
In the tested upstream main and em.40 source:
context.isOutOfRepoImportinsrc/resolution/index.ts:879–883checks external syntax and absence of an indexed local module, then delegates toisDeclaredOutsidePackage.isDeclaredOutsidePackageatindex.ts:4674–4687returns false for an ordinary undeclared package without dependency metadata.isOutOfRepoBindingatname-matcher.ts:25486–25491therefore does not protect the external binding.- The exact-name path at
name-matcher.ts:14345–14375and14544–14552accepts the unrelated exported function.
The inheritance-only guard is insufficient for calls/imports; simply moving it to cover every reference could break lexical shadows. The correction needs import-boundary semantics rather than relying solely on dependency declarations.
Evidence and related work
- Current verified evidence/report: codegraph-qa PR #27.
- Focused report and limitations.
- Portable seven-case reproducer.
- Upstream verification/provenance.
- Upstream main results, upstream v1.6.2 results, em.40 results.
Related upstream #2101 is closed and covers fuzzy resolution with a declared dependency. This is an exact-match/missing-metadata variant of the same broad family; no claim that the variant is entirely novel. #2962 concerns a different spread-call defect and supplied the selected fixture.
This is pre-existing behavior, not a new em.40 regression. The broader QA run's 51 finding rows are not 51 newly confirmed bugs.
Status and limits
Evidence/report only; no resolver fix or deployment is included. No report has been submitted to the official upstream for this verified variant.
Plan: final verification and duplicate check on Tuesday, November 10; report upstream if everything still checks out. Native-kernel behavior, published npm/platform binaries, other languages and real-project prevalence remain unverified.
Activity
inth3shadows commentedon Nov 11, 2026
Filed upstream as colbymchenry#3271 (2026-11-11), re-verified on upstream main f72c9d2. No fix PR yet.