Skip to content

fix(symbols): refs find inline type imports, re-exported imports, and split type/value names - #486

Merged
byronwall merged 4 commits into
claude/findings-clifrom
claude/symbol-ref-gaps
Nov 28, 2026
Merged

byronwall merged 4 commits into
claude/findings-clifrom
claude/symbol-ref-gaps

Conversation

@byronwall

@byronwall byronwall commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

srcly refs and the Symbols view missed callers in three TypeScript cases. An agent that maps callers before it deletes a type could leave one of these callers behind. Now all three resolve to the declaration that TypeScript binds.

Before:

  • import("@/types/AnalysisProject").AnalysisSourceRow in a type gave no reference.
  • A module that imports a name and exports it again (import { A } …; export { A }) lost every caller that imported A through it.
  • export const EvidenceCollector = … and export type EvidenceCollector = … were one symbol, so a type use and a value use were the same reference.

After:

  • An inline type import names the export through the same module and export lookup as import type, barrels included. typeof import(…).v names the value.
  • A re-export of an imported name goes to the file that declares it, in the symbol index and in the Imports graph.
  • A type-only and a value-only declaration of one name are two symbols. The value keeps its id file#A, so the Imports graph, at and existing links do not change. The type is file#A@type. Each reference picks the side its position uses. A class or enum merged with an interface stays one symbol. In the client, Show references keeps @type, and Open code goes to the type's line.

Cause

The extractor resolved names only through static import bindings and one shared name table per file. find_definer stopped at a local export, even when that export named an import.

Proof

srcly refs on the three cases. Before is claude/duplicate-type; after is this branch. explorEDA is at f44a5c63.

# explorEDA: AnalysisSourceRow
before: 83 references from 59 symbols          (no analysisWorker.ts)
after:  84 references from 60 symbols
        - packages/explorEDA/src/lib/analysis/analysisWorker.ts:9 tables · type exact

# explorEDA: SavedDataStructure (re-exported by ExplorEda.tsx)
before: 185 references from 88 symbols         (no ExplorEdaProject.tsx)
after:  189 references from 90 symbols
        - packages/explorEDA/src/components/ExplorEdaProject.tsx:82, 86 ExplorEdaProjectProps · type exact
        - packages/explorEDA/src/components/ExplorEdaProject.tsx:229, 234 ExplorEdaProject.reported · type exact

# srcly: EvidenceCollector
before: 1 declaration (variable, line 325)
after:  2 declarations
        ## engine/src/analysis/program-evidence.ts:325 · variable EvidenceCollector (exported)
        2 references from 1 symbol: collectProgramEvidence · instantiate exact
        ## engine/src/analysis/program-evidence.ts:326 · type EvidenceCollector@type (exported)
        No references.

All references of every symbol in both repos, before and after (each (source, target, kind, line, resolution) row of build_symbol_index):

Repo Symbols References before → after Added Removed
explorEDA 11,803 → 11,803 47,501 → 47,524 23 0
srcly 15,583 → 15,584 48,590 → 48,590 1 1
  • I checked all 23 explorEDA additions. One is the inline import at analysisWorker.ts:9. The other 22 are callers through a module that imports and exports a name again: ForeignKey (8), ChartExportError (4), SavedDataStructure (4), ExplorEdaSidePanel (3), DatePreset (2) and focusChartInContainer (1).
  • srcly's one move is the alias's own reference to ProgramEvidenceCollector, which now starts from EvidenceCollector@type.
  • Imports graph (build_ts_edges): explorEDA has 14,154 → 14,156 edges (+18, −16). File-level edges to the re-exporting module become symbol edges to the defining file. srcly has 8,477 → 8,484 (+22, −15). Destructured exports such as export const [location, setLocation] = … now count as declarations, so their importers get symbol-level edges (for example App.tsx#AppContent → navigation/store.ts#location).

Tests: server/tests/test_symbol_index_ts.py adds one test per gap. They cover the inline import, the import then export again, and the type/value split. Each also holds the review's regression cases, and the cases fail on the commits before each fix. scripts/check.sh server passes (649 tests). Client pnpm typecheck passes, and src/navigation + src/symbols vitest passes (53 tests).

Survey moves: corpus edits only, with no analysis change. This PR edits server/app/services/symbols/typescript.py, index.py, deps/typescript_deps.py and the client files App.tsx, CodeModal.tsx, navigation/location.ts and symbols/contract.ts. The sample now traces the new _in_typeof and _type_parameter_bound (both assumed). Server: traces +3, assumed +2, partial +1, external-code stops +44. Client: budget-exhausted stops +1.

Review

Codex reviewed three rounds (gpt-6.2-sol). Round 3 ended with no P0 and 3 P1s.

  • Round 1 (4 P1, 3 P2), all fixed:
    • as and satisfies types.
    • A class extends ns.A now names the value.
    • A new A() receiver.
    • Show references keeps @type.
    • Destructured names count as declarations.
    • Export visibility is per namespace for split names.
    • Generic parameters shadow outer types.
  • Round 2 (4 P1, 3 P2): 4 P1 and 1 P2 fixed:
    • import(…).X is a type wherever tree-sitter puts it, except a promise's then, catch or finally.
    • An annotated split receiver.
    • Open code on a split type.
    • A code-viewer click on a declaration.
    • A nearer block alias beats an outer generic.
    • 2 P2 open (below).
  • Round 3 (3 P1, 3 P2): 1 P1 fixed after the round, without a further review. A split alias's receiver now follows what the alias names (type A = B gives B, InstanceType<typeof A> gives the value A), never a same-name value. The test is test_type_and_value_of_one_name_are_two_symbols.
  • Architecture note from round 3: take declaration ids and reference spans for srcly refs, the Imports graph and the Symbols view from the data-flow engine's TypeScript checker, resolve editor and treemap actions by source position, and leave unbound references unresolved. Most open findings below are tree-sitter edge cases that this change would remove.

Limits

  • Show references from the code viewer still searches by name. On a use of a split name (not its declaration), it opens the first hit.
  • keyof import(…).Row breaks tree-sitter's parse of the alias, so the reference comes from the file's module node, not the alias. It is still listed as a caller.

Open findings

  • P1 · diff · server/app/services/symbols/typescript.py:786 — pick<typeof import("./m").Row>() parses typeof as an expression, so a split name resolves to Row@type, not the value. An exported type named then, catch or finally is skipped. JSX type arguments <C<import("./m").Row> /> are missed. Open: needs a parse that keeps type positions (the checker, per the architecture note).
  • P1 · diff · client/src/components/CodeModal/CodeModal.tsx:225 — Show references on an annotation use of a split name, or on the type's treemap tile, opens the value when search ranks it first. Open: needs a lookup by source position.
  • P2 · diff · server/app/services/deps/typescript_deps.py:399 — A barrel that imports interface T, declares a local value T and exports { T } sends type and value users to the local value. Open: needs separate type and value targets for each export hop.
  • P2 · diff · server/app/services/symbols/typescript.py:795 — A forward reference to a block-local alias inside a function nested in outer<Row>() attaches to the module's Row. Open: block-local types are not predeclared.
  • P2 · diff · server/app/services/symbols/typescript.py:79 — With export default function A and export type A, a default import used as a type binds to A@type, and typeof import("./m").A binds to the default function. Open: visibility is not checked per public name.

Stack: srcly cleanup helpers, layer 4 of 4

This slice: Fixes three TypeScript symbol-index gaps, so srcly refs (#482) lists every caller.
Why it is its own layer: It changes the core symbol index, not the CLI, and needs its own review. It does not depend on #483 or #485. It sits on top because a stack is linear.
Full story: #482

🤖 Generated with Claude Code

@byronwall
byronwall added this pull request to stack #484 November 28, 2026 04:42
@byronwall byronwall changed the title claude/symbol ref gaps fix(symbols): refs find inline type imports, re-exported imports, and split type/value names Nov 28, 2026
byronwall and others added 4 commits November 28, 2026 00:05
…t type and value names

- `import("./m").Row` in a type names Row through the module and export
  resolver, barrels included; `typeof import("./m").v` names the value.
- `import { A } from "./a"; export { A }` resolves to ./a, so callers through
  that module reach the declaration (symbol index and import graph).
- A type-only and a value-only declaration of one name are two symbols: the
  value keeps `file#A`, the type is `file#A@type`, and each reference
  resolves in the namespace its position uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bility apart

Round 1 review fixes:
- `x as import("./m").T` and `satisfies` name the type; a class's
  `extends ns.A` names the value; a receiver from `new A()` is the value A.
- Generic parameters (`<Row>`) bind their own name, never an outer type.
- Destructured top-level names are declarations, so a re-export of one stays local.
- A split name is public per namespace; inline imports need a public export.
- The client keeps `@type` in Show references and drops it to find the code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e instance

Round 2 review fixes:
- `import("./m").X` names the type X wherever tree-sitter puts it (call type
  arguments, `keyof`, error nodes), except the promise's then/catch/finally.
- `x: A` with `type A = InstanceType<typeof A>` settles members on the value A.
- A `type A` in a nearer block wins over an outer generic `<A>`.
- Open code on a split type lands on its line; Show references in the code
  viewer picks the declaration on the clicked line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Round 3 finding: `x: A` with the split `type A = B` settled `x.run()` on
the value A. The alias now records its class (`type A = B` is B,
`InstanceType<typeof A>` is the value A), and the call follows that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@byronwall
byronwall force-pushed the claude/symbol-ref-gaps branch from 1bab538 to c7c3b6d Compare November 28, 2026 05:05
@byronwall
byronwall removed this pull request from stack #484 November 28, 2026 05:05
@byronwall
byronwall added this pull request to stack #480 November 28, 2026 05:05
@byronwall
byronwall merged commit f0fd3da into main Nov 28, 2026
11 of 12 checks passed
@byronwall
byronwall deleted the claude/symbol-ref-gaps branch November 28, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant