Skip to content

bug: native engine only stores 'call' AST nodes, missing 5 other kinds #306

@carlos-alm

Description

@carlos-alm

Found during dogfooding v3.0.0

Severity: Medium
Command: codegraph ast

Reproduction

npx codegraph build <repo> --engine native --no-incremental
npx codegraph ast --kind new      # "No AST nodes found."
npx codegraph ast --kind string   # "No AST nodes found."
npx codegraph ast --kind regex    # "No AST nodes found."
npx codegraph ast --kind throw    # "No AST nodes found."
npx codegraph ast --kind await    # "No AST nodes found."
npx codegraph ast --kind call     # 10703+ nodes found

Expected behavior

All 6 AST node kinds (call, new, string, regex, throw, await) should be stored when building with the native engine, matching the WASM engine behavior.

Actual behavior

Only call nodes are stored (24716 in the codegraph repo). The other 5 kinds are empty. The WASM engine correctly stores all 6 kinds for JS/TS/TSX files because it preserves the tree-sitter parse tree and performs a post-build AST walk in src/ast.js:buildAstNodes().

Root cause

The native Rust engine (crates/codegraph-core/) extracts only call_expression nodes (see src/extractors/javascript.rs). It does not preserve the parse tree, so the JavaScript-side AST walk in ast.js cannot extract new, string, regex, throw, and await nodes.

The JS-side code in ast.js checks for symbols._tree and only walks it for JS/TS/TSX files, but the native engine never sets _tree.

Suggested fix

Either:

  1. Extend the native Rust extractors to also capture new_expression, string, regex_pattern, throw_statement, and await_expression AST nodes
  2. Or document that --engine wasm is required for full AST node coverage

Option 1 is preferred for engine parity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdogfoodFound during dogfooding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions