Skip to content

Extend symbol graph to Python, Go, TypeScript, JavaScript (PR2) - #442

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

mohitranka merged 1 commit into
mainfrom
feat/knowledge-graph-pr2-multilang

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

PR2 of 3 for the knowledge-graph feature (PR1: #441). Extends find_definition/find_references from Rust-only to all 5 languages forge-syntax already tree-sitter-parses.

  • New extractors for Python, Go, TypeScript, JavaScript — each follows PR1's Rust extractor pattern exactly: tree_sitter::Query/QueryCursor matching, one .scm file per fact type per language, same honest-ambiguity resolution (a name matching multiple candidates returns every real one, never a guess).
  • lib.rs's build pipeline generalized from a Rust-only walker to dispatching on file extension across all 5 languages, grouping symbols per language before a shared cross-language edge-resolution pass.
  • Store/tool/session layers are untouched — they were already language-agnostic by construction, per the plan.

Two real grammar divergences caught by testing, not assumed away:

  • Go: struct embedding (the closest analog to implements Go has) needs the !name negated-field query predicate to tell an embedded field apart from a named field of the same type.
  • JavaScript: class_heritage wraps the base class expression directly, unlike TypeScript's grammar which wraps it in an extends_clause — a shared query would have silently returned nothing for JS extends. Caught immediately by the test suite, fixed, verified.

Test plan

  • cargo fmt --all clean
  • cargo clippy --workspace --all-targets clean
  • cargo test --workspace green (full suite, exit 0)
  • 40 tests in forge-graph: per-language extraction correctness (imports/types/impl-or-extends/functions-vs-methods/calls) for all 5 languages, plus a new cross-language integration test building one repo containing all 5 languages together and confirming each resolves without cross-language leakage or collision
  • Dogfood-validated: full build of forge's own repo completes in 4.3s (release), every lookup resolves correctly including symbols from this session's own work (GraphHandle, RustExtractor)

https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs

…t (PR2)

Adds the remaining 4 of the 5 languages find_definition/find_references
cover, following PR1's Rust extractor pattern exactly: tree_sitter
Query/QueryCursor extraction, honest ambiguity handling, one .scm file
per fact type per language. lib.rs's build pipeline generalizes from
Rust-only to dispatching on file extension across all 5 languages,
grouping symbols per language before a shared cross-language edge-
resolution pass.

Two real grammar divergences caught by testing and fixed:
- Go: struct embedding (implements-by-embedding) needs the `!name`
  negated-field query predicate to distinguish an embedded field from
  a named one of the same type.
- JavaScript: `class_heritage` wraps the base class expression
  directly, unlike TypeScript's grammar which wraps it in an
  `extends_clause` — a naive shared query would have silently returned
  nothing for JS `extends`.

Dogfood-validated: full build of forge's own repo (all 5 languages
present) completes in 4.3s in release mode, with every lookup
resolving correctly including symbols from this session's own work.

Claude-Session: https://claude.ai/code/session_01Tb5bxZgFovoKct29q9VEgs
@mohitranka
mohitranka merged commit a58b6a2 into main Aug 26, 2026
7 checks passed
@mohitranka
mohitranka deleted the feat/knowledge-graph-pr2-multilang branch August 26, 2026 07:25
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
…t (PR2) (#442)

Adds the remaining 4 of the 5 languages find_definition/find_references
cover, following PR1's Rust extractor pattern exactly: tree_sitter
Query/QueryCursor extraction, honest ambiguity handling, one .scm file
per fact type per language. lib.rs's build pipeline generalizes from
Rust-only to dispatching on file extension across all 5 languages,
grouping symbols per language before a shared cross-language edge-
resolution pass.

Two real grammar divergences caught by testing and fixed:
- Go: struct embedding (implements-by-embedding) needs the `!name`
  negated-field query predicate to distinguish an embedded field from
  a named one of the same type.
- JavaScript: `class_heritage` wraps the base class expression
  directly, unlike TypeScript's grammar which wraps it in an
  `extends_clause` — a naive shared query would have silently returned
  nothing for JS `extends`.

Dogfood-validated: full build of forge's own repo (all 5 languages
present) completes in 4.3s in release mode, with every lookup
resolving correctly including symbols from this session's own work.

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
…t (PR2) (#442)

Adds the remaining 4 of the 5 languages find_definition/find_references
cover, following PR1's Rust extractor pattern exactly: tree_sitter
Query/QueryCursor extraction, honest ambiguity handling, one .scm file
per fact type per language. lib.rs's build pipeline generalizes from
Rust-only to dispatching on file extension across all 5 languages,
grouping symbols per language before a shared cross-language edge-
resolution pass.

Two real grammar divergences caught by testing and fixed:
- Go: struct embedding (implements-by-embedding) needs the `!name`
  negated-field query predicate to distinguish an embedded field from
  a named one of the same type.
- JavaScript: `class_heritage` wraps the base class expression
  directly, unlike TypeScript's grammar which wraps it in an
  `extends_clause` — a naive shared query would have silently returned
  nothing for JS `extends`.

Dogfood-validated: full build of forge's own repo (all 5 languages
present) completes in 4.3s in release mode, with every lookup
resolving correctly including symbols from this session's own work.

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