Repository navigation
feat(symbols): bind TypeScript references with the engine's checker - #487
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to tree-sitter ids Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecker after a passing failure Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
byronwall
force-pushed
the
claude/checker-symbol-index-plan
branch
from
November 28, 2026 05:28
1a99821 to
0dfc8a4
Compare
…e every resolution option Codex round 1: join a declaration by the line of its name, not its body; Show references sends the identifier's first column and matches a declaration at its name; a workspace package's built .d.ts follows its own path to src and the export path there (namespace and member uses too); a config that resolves modules differently binds in its own Program; implements and an interface's extends bind the type side; x["run"]() is a reference; a cached checker index holds only while the engine's program hash matches; an anonymous export default function is file#default; a member id passes through Show references. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lause names, track configs Codex round 2: the checker sends each target's name column and the join matches it exactly; a union's member binds every class's own member; import and export clause names and recursive calls are positions for Show references, not edges; a checked class takes its bases from checker extends edges only; config edits join the cache key and refresh the engine, and a cached fallback holds only while the engine is still missing; baseUrl wins over an inherited paths base; a declaration map beats the dist→src convention; satisfies keeps a callee a call; the workspace fixture is tracked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
byronwall
enabled auto-merge (squash)
November 28, 2026 06:00
…efault anchors, Python lookups Codex round 3: a type-only import or export clause names the type side; a reference with no enclosing declaration is module code; a union keeps its local members when an external one comes first; an anonymous default function anchors after 'default' in both binders; Python files keep tree-sitter's position lookup in a checker index; file names compare in TypeScript's '/' spelling; the workspace fixture's imports come first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ration map's sourceRoot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
srcly refs, Symbols mode and Show references now bind TypeScript names with the data-flow engine's TypeScript checker, not by name. Member calls through parameters, props, inferred and union receivers now reach their methods and fields. Name guesses that pointed at the wrong symbol are gone. Show references in the code viewer opens the symbol bound at the caret, not the first search hit.What you'll see
srcly refsand the Symbols status line say which binder ran: "bound by the TypeScript checker", or "bound by tree-sitter names (reason)" when Node, the engine or a tsconfig is missing.SavedDataStructuregoes from 189 to 252 references; most of the new ones are member reads through types tree-sitter could not see.file#Name,file#Class.member,file#Name@type), so links,at=and the Imports graph are the same.How it works
symbolRefs, walks every identifier and reports the declaration the checker binds it to: its file, name, name position and meaning (valueortype). Python joins that to the tree-sitter symbol whose name is at the same position. An unbound name stays out of the graph, counted by reason.paths,baseUrl,moduleResolution, conditions) gets its own Program..d.tsis followed to its source: through the declaration map, elsedist/x.d.ts→src/x.ts.srcly refsstart the engine. Nothing else does, so the base scan is unchanged.Proof
Show references on
Rowinexport let typed: import("./m").Row: the focus isRow@type, referenced bytyped(line 8) and by the JSX type argument intag(line 9). #486 missed that JSX type argument. Thetypeofuse opens the value instead (second e2e case).Every TypeScript reference in two repos, both binders.
cd server && SRCLY_ENGINE_DEV=1 uv run python scripts/compare_binders.py <root>. A reference is (source file, line, target id).f44a5c63read → typeon explorEDA), calls through re-exports and closures, and interface method calls.BodyWalker.literal. Others are JSX tags (<span>,<line>) bound to locals of the same name.declare functiondeclarations (the index keeps no symbol for them), untrackedengine/tmpoutput, and one tree-sitter parse gap in explorEDA'sFieldListRow.tsx.docs/intent/checker-symbol-index/README.md("Proof result").srcly refson the #486 cases:Cost of
symbolRefs, one cold run each. Command:cd engine && node --expose-gc --max-old-space-size=4096 --import tsx scripts/symbol-refs-probe.ts --root <repo>. Heap is measured after a full GC; development Mac.These were measured before the round-2 and round-3 fixes, which add a union walk and clause names. The final
compare_bindersruns took 21 s (srcly) and 18 s (explorEDA) for the whole checker index, including Python's join.Tests:
engine/test/srcly/symbol-refs.test.ts: two fixtures, one case for each fix(symbols): refs find inline type imports, re-exported imports, and split type/value names #486 finding and Codex finding.server/tests/test_symbol_checker_join.py: the join, shadowing, positions, module code and Python lookups.client/e2e/symbols.spec.ts, "Show references by position" (2 tests).scripts/check.sh --changedpassed for client, engine and server.Survey moves: corpus edits only, with no analysis change. This PR adds new server and client code (
server/app/services/symbols/checker.py,index.py,models.py, the symbols router;CodeModal.tsx,SymbolsView.tsx,symbols/api.ts). The sampled server traces move by +3 traces, +3 partial, +2 budget-exhausted stops and +92 external-code stops. Client and value-flow-basics do not move.Review
Codex ran three rounds (
gpt-6.2-sol). Round 3 ended with no P0.Round 1 (7 P1, 3 P2): all fixed. Changes:
.d.tsfiles map by path.implementsand interfaceextendsbind the type side.x["run"]()is a reference.export default () => …isfile#default.Round 2 (8 P1, 2 P2): all fixed. Changes:
baseUrlprecedence.satisfies.Round 3 (9 P1, 2 P2): fixed after the round, without a further review:
sourceRoot.The rest are listed below.
Round 3 architecture note: build the checker index as one project-aware snapshot. TypeScript would supply project ownership, declaration identity and enclosing declarations, and both graph edges and Show references would come from the same records. This PR is close to that, except for project ownership (the first open finding).
Close step: it asked only for tests. Most are in the two fixtures and the join tests. The cross-project ones (an app alone compared with the monorepo) are not added.
Limits
read → typecounts grow on union-heavy code.Open findings
~/xalias binds through the root'spaths. Open: needs per-file config ownership in the engine's tsconfig discovery, which every op shares..d.tswith no declaration map maps by thedist→srcconvention, so a same-named export in an unrelatedsrc/x.tscan take the caller. Declined for now: without the convention, explorEDA's app → package callers disappear, and tree-sitter's Imports graph makes the same guess.🤖 Generated with Claude Code