Semantic Code Graph
The Semantic Code Graph builds a relationship layer on the symbol index (SymbolIndex), supplemented by vector retrieval, to help locate cross-file calls and module dependencies before planning and rewriting. Results depend on language parsing, file scope and index state; they do not represent the complete project.
Index Building
Indexes are built and queried per project root, isolated between projects. The kernel builds two kinds of indexes for each project:
- Symbol relationship index: parses symbols in the code and their relationships, covering three relation types — Calls, Implements, and DependsOn. Every relationship record contains a source symbol, a target symbol, and a relation type.
- Vector index: encodes snippets for semantic retrieval. The embedding path depends on configuration and available model resources; a specific bundled model or package size is not guaranteed. A lexical fallback is available when local model resources are unavailable. Configuring a provider embedding service sends relevant code snippets to that service; review its data policy first.
- Retrieval is hybrid: vector recall with an FTS5 keyword fallback; both carry the source file and a text preview, so results locate to a specific file directly.
Cross-File Reference Queries
All queries are bounded by the project root and initiated by symbol name:
| Query | Description |
|---|---|
| Callers | Who calls this symbol |
| Callees | Who this symbol calls |
| Implementations | Indexed implementations of an interface / trait |
| Module dependencies | Which downstreams a module depends on |
| Relationship subgraph | The relationship network expanding layer by layer around a symbol to depth N |
The two index types work together: vector retrieval handles semantically related fuzzy lookup, while graph queries follow recorded reference relationships. Missing relations and identically named symbols can affect results. Subgraph queries start from a central symbol and expand depth-first toward both callers and callees — commonly used to assess the blast radius of a change.
The relationship layer is the core deliverable of Semantic Code Graph Phase 1: the symbol index first extracts functions, types, and modules, then three kinds of relationship edges are built on top of it. All queries are read-only and never modify project code. Query implementation borrows the symbol index directly for read-only access; subgraph expansion deduplicates visited nodes, so even cyclic calls cannot cause an infinite loop.
Graph queries are distinct from LSP diagnostics, navigation and completion. Install language servers separately and check their connection state.
Working with RUSH
During the planning stage, the Planner of a RUSH Deep Task queries the code graph: it extracts symbol keywords from the task description, locates matching symbols, takes their one-level call relations (callers / callees), and injects a [Code Graph Impact Analysis] section into the planning context — so the affected-file list and risk assessment are grounded in graph evidence rather than pure model guesses. Typical scenarios:
- Before renaming a function, check indexed callers and supplement results with text searches and tests.
- Before changing a module interface, check recorded dependencies and manually confirm the affected scope.
- When getting familiar with an unfamiliar codebase, expand the relationship subgraph layer by layer from an entry symbol.
Tip for large projects: complete the current project's index and inspect retrieved results and task context. Coverage depends on language parsing, file scope and build state; all callers or dependencies are not guaranteed to be found. Planning can fall back without graph matches, but plans and verification results still require review.
Using It in the IDE
The code graph is reachable through the Call Hierarchy panel: place the cursor on a symbol in the editor and choose "Show Call Hierarchy" from the context menu (or press Shift+Alt+H, or open it via the command palette / the Call Hierarchy icon in the side bar). The panel supports:
- Caller / callee direction toggle: see who calls the symbol, or who it calls.
- Drill-down navigation: click a row's arrow to drill into that symbol; breadcrumb back one level.
- Click to jump: relation rows locate the source file at the exact line.
- Index status badge: shows the current symbol count, with one-click background rebuild.
The graph's query interfaces are also exposed through the kernel API. Related docs:
- RUSH Deep Task: consumes the graph automatically at planning time.
- Kernel API: the HTTP form of the query interfaces.