Skip to content

Build generalized tests/tools/tree_sitter_accuracy_audit.py + per-language node-map registry #1228

Closed

Description

@squid-protocol

Part of the tree-sitter accuracy epic (#1227).

What to build

tests/tools/tree_sitter_accuracy_audit.py, mirroring tests/ast_accuracy_audit.py's shape
(same CLI: no-args full report, --ci terse regression gate, --regenerate to bless a new
baseline) but generalized to take a --lang <name> argument and swap the ground-truth engine:

  • Corpus: resolve language-crucible the same way tests/tools/crucible_check.py already
    does (LANGUAGE_CRUCIBLE_PATH env var, falling back to a sibling ../language-crucible
    checkout) and scan data/<lang>/ for that language's source files. Pin to the same tag
    crucible_check.py/update_golden_master.py use -- don't introduce a second, independently-
    drifting pin for the same corpus.
  • Engine side: run galaxyscope --db-only against language-crucible/data/<lang>/ (or reuse
    an existing --db-only scan if one's already cached for that run -- check how
    tests/tools/self_scan.py/crucible_check.py avoid redundant scans before writing a new
    scanning path from scratch).
  • Ground-truth side: parse each file with tree_sitter_language_pack.get_parser(<ts_lang>)
    and walk the tree per a per-language node-map config -- a small dict per language giving:
    the tree-sitter grammar name if it differs from GitGalaxy's own language key (e.g.
    shell->bash), the function-like node type(s), the class-like node type(s), the field name
    holding the identifier, and the field name (or child-counting method) for parameter count. Start
    with just javascript (see below) and python... no -- Python already has ast_accuracy_audit.py
    and doesn't need tree-sitter; start with javascript only, matching an existing entry to
    validate against, then leave the registry easy to extend one language at a time.
  • Diff/metrics: same shape as ast_accuracy_audit.py -- found/extra functions and classes,
    args-count exact-match rate, verbose sample output of mismatches. Reuse its _regressions/
    _ground_truth_drift/report-printing logic directly if the shapes line up closely enough to
    share code (a shared base module) rather than copy-pasting the whole file -- but don't force a
    shared abstraction if Python's ast-specific pieces (its _real_arg_count, its class-of-node
    isinstance checks) don't generalize cleanly; two clear, separately-readable scripts beat one
    awkward shared one for a two-instance abstraction.
  • Baseline: tests/tree_sitter_accuracy_baseline_<lang>.json per language (own file per
    language, not one combined JSON, so a PR only touching one language's baseline shows a small
    diff) -- same baseline-gated "regression floor, not zero-tolerance" contract as
    ruff_audit.py/mypy_audit.py/dead_key_audit.py/ast_accuracy_audit.py.

Correctness check before calling this done

Run it against javascript and confirm the numbers land close to what PR #1223's ad hoc pass
already measured and wrote into docs/language_status/javascript.md §9 (function recall 90.9%/
67.5%, precision 84.7%/92.8%, 100% args-match) -- note the corpus differs (this uses
language-crucible's data/javascript/{jquery,react,threejs}, not the ad hoc pass's fresh
expressjs/express + site/js/ clone), so exact numbers won't match, but the methodology should
produce a plausible, explainable result on real code with no crashes. If language-crucible's
JS files hit the same #1220 (--db-only synthetic risk_vector) crash pattern, confirm it's
already fixed (PR #1220, merged) rather than re-diagnosing it.

Explicitly out of scope here

  • Don't wire this into --ci/audit_check.py yet -- it needs language-crucible checked out
    locally (network dependency, same reason crucible_check.py itself isn't part of the default
    pytest run). Decide CI wiring, if any, as a follow-up once a few languages have baselines.
  • Don't write any docs/language_status/<lang>.md §9 content in this issue -- that's the
    language-status skill's job, run per-language once this tool exists.
  • Don't attempt every language's node-map in this issue -- just javascript (with a python-less
    design that makes adding the next language a small, self-contained addition, not a refactor).

Activity

  1. added
    testing
    core-engine
    on Aug 10, 2026
  2. added this to the v2.4.8 milestone on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions