feat(core): reverse callee index for dev_refs callers#38
Merged
Conversation
Add reverse callee index that maps callee names to their callers.
Built at index time from the same scan data as the dependency graph,
persisted inside dependency-graph.json as v2 format (single atomic
write prevents drift). Compound keys (file:name) for TS, bare names
for tree-sitter languages. Secondary name index for O(1) bare-name
lookups. Incremental updates via updateReverseIndexIncremental.
- New module: packages/core/src/map/reverse-index.ts
- CachedGraph v1→v2 (backward compatible — v1 loads with null reverse)
- serializeGraph/deserializeGraph updated for v2
- loadOrBuildGraph returns { graph, reverseIndex }
- All callers updated: map/index.ts, cli/refs.ts, refs-adapter.ts,
incremental-indexer.ts
- 25 new tests in reverse-index.test.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace broken semantic-search caller detection with reverse index lookups. Both CLI refs and MCP refs adapter now use lookupCallers/ lookupClassCallers from core instead of searching for the target name and scanning 100 candidates' callees. - CLI refs: loads reverse index via loadOrBuildGraph, uses lookupCallers - MCP refs adapter: caches reverse + name index alongside graph (60s TTL) - getCallersFromIndex replaces getCallers (no more SearchService call) - loadOrBuildGraph fallback now builds reverse index from docs - getDependencyGraph handles missing indexer gracefully - Updated refs-adapter tests with mock indexer for reverse index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
file:name) for TypeScript, bare names for tree-sitter languages. Secondary name index for O(1) bare-name lookupsdev refsand MCPdev_refsadapter. Previously returned "No callers found" for every functionBefore/After
Test plan
pnpm build— passespnpm test— 1789 tests pass (25 new)pnpm typecheck— passesdev refs "validateArgs"— shows 5 adapter callersdev refs "CompactFormatter"— shows constructor callerdev refs "SearchAdapter"— class aggregation worksdev refs "startFileWatcher"— shows caller from dev-agent-mcp.tsdev_refsreturns callers