Skip to content

Report tree-sitter's own accuracy alongside GitGalaxy's - #1850

Merged
squid-protocol merged 1 commit into
mainfrom
tree-sitter-symmetric-comparison
Aug 18, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
tree-sitter-symmetric-comparison

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Aug 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #1849.

tests/tools/tree_sitter_accuracy_audit.py treated tree-sitter as an unconditional ground truth, measuring only GitGalaxy against it. Repeated investigation work has found specific, evidenced cases where tree-sitter's own parse has the gap instead (docs/why_gitgalaxy_beats_ast_here.md's Claims 1-3: JS Flow-typed hallucinations, C macro hallucinations, Cython dialect blind spots, csharp/fortran parse-error cascades). This PR makes the comparison symmetric: the chart shows GitGalaxy's 5 bars and tree-sitter's own 5 bars, per language, per metric, across three commits.

Commit 1 — precision-side symmetric measurement

  • measure(): keeps an uncorrected copy of the same tree-sitter walk (raw_ts_funcs/raw_ts_classes) alongside the existing corrected real_funcs/real_classes ground truth, and scores it the same way GitGalaxy is scored (_align_occurrences_by_line), producing ts_found_functions/ts_extra_functions/ts_found_classes/ts_extra_classes/ts_args_exact_match. The last one uses a new _get_param_count_declaration_only (reuses _get_param_count with lang="") — reproduces Claim 1's declaration-only baseline (shell 0%, perl ~18%) as a live measured number.
  • Scope: none of this touches the PR-gate baseline schema, _GATED_METRICS, or run_ci_check — tree-sitter's own numbers were informational only in this commit.
  • Doc cleanup: consolidates the root-level why_we_are_better_than_tree_sitter.md into docs/why_gitgalaxy_beats_ast_here.md as four newly-verified Claims (8-11).

Commit 2 — recall-side ground-truth promotion (Phase 2)

Commit 1's recall panels read 100% by construction for every language — ground truth was walked purely from tree-sitter's own tree, which structurally can't miss what it defines. This promotes GitGalaxy's own matches inside an already-identified blind-spot/cascade region directly into real_funcs/real_classes, extending the same trust the pre-existing extra_functions exclusion already placed there (Claims 3/6/7: #1427/#1567 csharp, #1709 fortran, rust macro_rules! bodies) from "don't penalize" to "count as found":

  • csharp: 647/965 tree-sitter recall (67.0%)
  • fortran: 123/143 (86.0%)
  • rust: 1775/1927 (92.1%)

Deliberately scoped to blind_spot_ranges (already lang-scoped to rust/fortran internally) plus trailing_error_start for csharp only — not every language the general cascade detector fires on. Verified an unscoped version also drifted c/cpp/javascript/powershell/python/tcl; none of those have the same source-level "fully blind" verification csharp does (Claim 3 explicitly documents javascript as the counter-example — its cascade "resyncs locally" rather than going fully blind, so blanket-promoting there risks blessing a genuine GitGalaxy false positive as ground truth). Scoping to lang == "csharp" for the cascade case brought the drift back down to exactly the 3 languages this was actually verified against.

This raises real_functions/found_functions/found_classes for csharp/fortran/rust — the gated baseline schema this time, unlike commit 1's purely-informational fields. Their 3 baselines are regenerated here as a deliberate, evidenced ground-truth improvement, per the repo's normal re-blessing protocol.

Also reworks the chart layout: rows share one alphabetical language order across all five panels (previously each panel was ranked independently by GitGalaxy's value), with a continuous full-width stripe band, so a single language's numbers can be read straight across instead of hunting for it at a different row in every column.

Commit 3 — per-cell diff badges, shared label column, GitGalaxy-only languages

Three more usability improvements, requested after reviewing the first two commits:

  • Diff badges: every cell where GitGalaxy's and tree-sitter's bars actually differ (both real values, not equal) gets an amber outline plus a "G"/"T" badge for whichever tool scored higher — letter AND color, not color alone, readable without relying on color perception. Footer note clarifies a "T" badge isn't a general verdict: for a language with no documented hallucination correction, tree-sitter's raw reading equals ground truth by construction, so any unrelated GitGalaxy precision defect alone triggers it.
  • Shared label column: the language name column moved out of each panel into one shared column at the far left, printed once instead of five times, matching the row order already unified in commit 2.
  • GitGalaxy-only languages: the chart now covers all 45 languages GitGalaxy extracts functions from, not just the 31 with a tree-sitter comparison — 14 more (abap, ada, agc_assembly, assembly, cobol, dockerfile, embedded_python, jcl, livecode, m4, scheme, sqlite, yacc, yaml), computed dynamically against LANGUAGE_DEFINITIONS/NODE_MAPS (_gg_only_langs), not hand-listed. A new measure_gg_only() runs the same corpus/engine-scan pipeline but skips the tree-sitter diff entirely (no NODE_MAPS entry to diff against) and renders GitGalaxy's raw found-count as a plain gray bar, tree-sitter side always n/a. Three of the fourteen (ada, embedded_python, sqlite) have no language-crucible corpus yet and render as an all-n/a stub row instead of crashing the run — fills in automatically once the corpus catches up, no code change needed.

CSV schema gains 2 more columns (gg_only, gg_only_data_available); the existing _migrate_history_csv_schema handles the header/backfill migration generically. Baseline-gated CI schema untouched — verified --all --ci still passes clean.

Test plan

  • python tests/tools/tree_sitter_accuracy_audit.py --lang javascript/shell/perl/csharp/c/fortran/rust — sanity-checked ts_* numbers by hand against documented gaps.
  • python tests/tools/tree_sitter_accuracy_audit.py --all --ci — passes clean (31/31) after each commit, confirming exactly the intended baseline drift (none in commits 1 and 3, csharp/fortran/rust only in commit 2).
  • Ad hoc script confirming an unscoped cascade-promotion drifted 6 additional, unverified languages (c/cpp/javascript/powershell/python/tcl) before scoping it to lang == "csharp".
  • python tests/tools/tree_sitter_accuracy_audit.py --history then --chart after each commit — regenerated CSV/SVG, visually confirmed via Inkscape PNG renders (paired bars, shared alphabetical row order, diff badges on real differences only, GitGalaxy-only rows rendering correctly including the awaiting-data stub state, no clipped labels).
  • ruff format ., python tests/ruff_audit.py --ci, python tests/mypy_audit.py --ci, python tests/dead_key_audit.py --ci — all clean, no new findings, after each commit.
  • Fact-checked Claims 9-11 (Go/Ruby/Rust) against current detector.py behavior with isolated scratch snippets before restating them.
  • Verified the history CSV migration preserves old rows byte-identical (only trailing blank-backfilled columns added) after each schema addition.

🤖 Generated with Claude Code

tests/tools/tree_sitter_accuracy_audit.py treated tree-sitter as an
unconditional ground truth, measuring only GitGalaxy against it.
Repeated investigation work has found specific, evidenced cases where
tree-sitter's own parse has the gap instead (docs/why_gitgalaxy_beats_ast_here.md's
Claims 1-3): JS Flow-typed hallucinations, C macro hallucinations,
Cython dialect blind spots, csharp/fortran parse-error cascades.

measure() already builds real_funcs/real_classes as tree-sitter's parse
with those exact corrections baked in during the walk -- so this keeps
an uncorrected copy of the same walk and scores it against the same
reconciled ground truth via the existing _align_occurrences_by_line,
producing ts_found_functions/ts_extra_functions/ts_found_classes/
ts_extra_classes/ts_args_exact_match (the last via a new
_get_param_count_declaration_only, reproducing Claim 1's declaration-
only baseline live). --chart now renders two stacked bars per language
per panel (GitGalaxy on top, tree-sitter's raw reading below), ranked
by GitGalaxy's value. Phase 1 scope: tree-sitter's recall panels read
100% by construction since ground truth is still walked from its own
tree -- promoting parse-error-cascade regions into ground truth so its
real recall loss becomes visible too is deferred to a follow-up.

None of this touches the PR-gate baseline schema or _GATED_METRICS --
tree-sitter's own numbers are informational, flowing only through
--history/--chart, not CI-gated.

Also consolidates why_we_are_better_than_tree_sitter.md (a root-level
doc that didn't follow this repo's narrow/dated/evidenced-claim
discipline) into docs/why_gitgalaxy_beats_ast_here.md as four verified
Claims (8-11); its TypeScript-signature content was deliberately not
carried forward since the ground truth treats those cases as not
comparable at all, not as tree-sitter missing them.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit b88a5a4 into main Aug 18, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the tree-sitter-symmetric-comparison branch August 18, 2026 15:14
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.

Report tree-sitter's own accuracy alongside GitGalaxy's in the accuracy chart/history

1 participant