Skip to content

Add repo-wide symbol graph: find_definition/find_references (PR1: Rust) - #441

Merged
mohitranka merged 1 commit into
mainfrom
feat/knowledge-graph-pr1-rust
Aug 26, 2026
Merged

mohitranka merged 1 commit into
mainfrom
feat/knowledge-graph-pr1-rust

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

PR1 of 3 (per the design-review plan) for a new knowledge-graph feature: repo-wide find_definition/find_references tools backed by a persisted, syntactic-only symbol/edge index.

  • New crates/forge-graph crate — SQLite-backed store, Rust fact extraction via real tree_sitter::Query/QueryCursor matching (the first use of that API anywhere in forge; existing syntax highlighting in forge-syntax hand-walks the tree instead — called out explicitly as an intentional new pattern, not scope creep).
  • Core invariant, carried through an extended design review: never present a guess as a fact. A symbol name unique across the repo resolves with full confidence. A name matching multiple candidates (e.g. an ambiguous method call across unrelated types) returns the full honest candidate set instead of picking one. No INFERRED edge tier exists — v1 only ever records what tree-sitter can verify (imports, type/impl declarations, function/method definitions, call sites).
  • Two narrow tools — find_definition(symbol), find_references(symbol) — registered conditionally exactly like web_search (Option<Arc<dyn Tool>>, no handle → no tools), not a graph-query DSL.
  • New [tools.graph] config (enabled by default), a new RuntimeDataKind::Graph storage category, wired into open_session.
  • PR1 scope: Rust only, one synchronous full-repo build at session open. No live watcher yet (PR3), no other 4 languages yet (PR2).
  • Dogfood-validated against forge's own repo by hand before writing any wiring code — which surfaced and fixed a real bug: gitignored scratch worktrees under .claude/worktrees/ were being walked and indexed as false duplicate symbols. Regression test added.

Test plan

  • cargo fmt --all clean
  • cargo clippy --workspace --all-targets clean
  • cargo test --workspace green (full suite, exit 0)
  • 33 new tests: extraction correctness (imports/types/impls/functions/calls, method-vs-function classification), storage round-trip (unique/ambiguous/unresolvable/cleared-file cases), tool output formatting (unique/ambiguous/empty), end-to-end build against a real fixture repo, session wiring (enabled/disabled), config round-trip
  • Hand-validated against forge's own repo: find_definition/find_references on real symbols (AgentSession, tools_for_model, compress_tool_output) matched known call sites exactly

https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs

…ces (PR1: Rust)

Adds a new forge-graph crate backing find_definition/find_references —
a repo-wide, syntactic-only symbol/edge index. Facts are extracted via
real tree_sitter Query/QueryCursor matching (first use of that API in
forge; existing syntax highlighting hand-walks the tree instead).

The core invariant: never present a guess as a fact. A symbol name
unique across the repo resolves with full confidence; a name matching
multiple candidates (e.g. an ambiguous method call) returns the full
honest candidate set instead of picking one. No INFERRED edge tier
exists yet — v1 only ever records what tree-sitter can verify.

PR1 scope: Rust only, one synchronous full-repo build at session open
(no live watcher yet), both tools registered conditionally exactly
like web_search, enabled by default via a new [tools.graph] config.
Dogfood-validated against forge's own repo, which surfaced and fixed a
real bug: gitignored scratch worktrees under .claude/worktrees/ were
being indexed as false duplicate symbols.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
@mohitranka
mohitranka merged commit ea4c3b9 into main Aug 26, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 26, 2026
* Revert "feat(graph): live watcher, /graph toggle, and AgentSession wiring (PR3) (#443)"

This reverts commit aae0844.

* Revert "feat(graph): extend symbol graph to Python, Go, TypeScript, JavaScript (PR2) (#442)"

This reverts commit a58b6a2.

* Revert "feat(graph): add repo-wide symbol graph, find_definition/find_references (PR1: Rust) (#441)"

This reverts commit ea4c3b9.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ces (PR1: Rust) (#441)

Adds a new forge-graph crate backing find_definition/find_references —
a repo-wide, syntactic-only symbol/edge index. Facts are extracted via
real tree_sitter Query/QueryCursor matching (first use of that API in
forge; existing syntax highlighting hand-walks the tree instead).

The core invariant: never present a guess as a fact. A symbol name
unique across the repo resolves with full confidence; a name matching
multiple candidates (e.g. an ambiguous method call) returns the full
honest candidate set instead of picking one. No INFERRED edge tier
exists yet — v1 only ever records what tree-sitter can verify.

PR1 scope: Rust only, one synchronous full-repo build at session open
(no live watcher yet), both tools registered conditionally exactly
like web_search, enabled by default via a new [tools.graph] config.
Dogfood-validated against forge's own repo, which surfaced and fixed a
real bug: gitignored scratch worktrees under .claude/worktrees/ were
being indexed as false duplicate symbols.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
mohitranka added a commit that referenced this pull request Sep 11, 2026
* Revert "feat(graph): live watcher, /graph toggle, and AgentSession wiring (PR3) (#443)"

This reverts commit ec8c1ef.

* Revert "feat(graph): extend symbol graph to Python, Go, TypeScript, JavaScript (PR2) (#442)"

This reverts commit 0e813ab.

* Revert "feat(graph): add repo-wide symbol graph, find_definition/find_references (PR1: Rust) (#441)"

This reverts commit e18cf38.
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ces (PR1: Rust) (#441)

Adds a new forge-graph crate backing find_definition/find_references —
a repo-wide, syntactic-only symbol/edge index. Facts are extracted via
real tree_sitter Query/QueryCursor matching (first use of that API in
forge; existing syntax highlighting hand-walks the tree instead).

The core invariant: never present a guess as a fact. A symbol name
unique across the repo resolves with full confidence; a name matching
multiple candidates (e.g. an ambiguous method call) returns the full
honest candidate set instead of picking one. No INFERRED edge tier
exists yet — v1 only ever records what tree-sitter can verify.

PR1 scope: Rust only, one synchronous full-repo build at session open
(no live watcher yet), both tools registered conditionally exactly
like web_search, enabled by default via a new [tools.graph] config.
Dogfood-validated against forge's own repo, which surfaced and fixed a
real bug: gitignored scratch worktrees under .claude/worktrees/ were
being indexed as false duplicate symbols.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
mohitranka added a commit that referenced this pull request Sep 11, 2026
* Revert "feat(graph): live watcher, /graph toggle, and AgentSession wiring (PR3) (#443)"

This reverts commit c8048f9.

* Revert "feat(graph): extend symbol graph to Python, Go, TypeScript, JavaScript (PR2) (#442)"

This reverts commit b48bbbe.

* Revert "feat(graph): add repo-wide symbol graph, find_definition/find_references (PR1: Rust) (#441)"

This reverts commit f2acb05.
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