Repository navigation
Description
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-cruciblethe same waytests/tools/crucible_check.pyalready
does (LANGUAGE_CRUCIBLE_PATHenv var, falling back to a sibling../language-crucible
checkout) and scandata/<lang>/for that language's source files. Pin to the same tag
crucible_check.py/update_golden_master.pyuse -- don't introduce a second, independently-
drifting pin for the same corpus. - Engine side: run
galaxyscope --db-onlyagainstlanguage-crucible/data/<lang>/(or reuse
an existing--db-onlyscan if one's already cached for that run -- check how
tests/tools/self_scan.py/crucible_check.pyavoid 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 justjavascript(see below) andpython... no -- Python already hasast_accuracy_audit.py
and doesn't need tree-sitter; start withjavascriptonly, 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'sast-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>.jsonper 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.pyyet -- it needslanguage-cruciblechecked out
locally (network dependency, same reasoncrucible_check.pyitself isn't part of the default
pytestrun). 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-statusskill's job, run per-language once this tool exists. - Don't attempt every language's node-map in this issue -- just
javascript(with apython-less
design that makes adding the next language a small, self-contained addition, not a refactor).
Activity