Skip to content

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

Closed

Description

@squid-protocol

Problem

tests/tools/tree_sitter_accuracy_audit.py currently treats tree-sitter as an unconditional ground truth and only measures GitGalaxy against it (--history → docs/self_scan/tree_sitter_accuracy_history.csv, --chart → docs/self_scan/tree_sitter_accuracy_chart.svg, a 5-panel small-multiples bar chart: func recall, func precision, class recall, class precision, args exact-match — one bar per language per panel, GitGalaxy-only). Repeated investigation work has found specific, evidenced cases where tree-sitter's own parse has the gap, not GitGalaxy's (documented in docs/why_gitgalaxy_beats_ast_here.md Claims 1-3: JS Flow-typed error-recovery hallucinations, C macro hallucinations, Cython dialect blind spots, csharp/fortran parse-error cascades). Treating tree-sitter as unconditionally correct understates GitGalaxy's real accuracy in these cases and hides tree-sitter's own weaknesses.

Goal

Report both tools' recall/precision against the same shared ground truth, so the chart shows GitGalaxy's 5 bars and tree-sitter's 5 bars side by side per language per metric.

Key insight

real_functions/real_classes in measure() (tests/tools/tree_sitter_accuracy_audit.py, the walk() function around lines 1740-1835) is already NOT tree-sitter's raw parse — it's tree-sitter's parse with several already-evidenced corrections baked in during the walk (JS Flow-hallucination skip list, C macro-hallucination skip list, perl bodyless-forward-decl dedup, TS bodyless constructor/overload/catch-finally drops). Each correction already IS one of the documented blind spots. So Phase 1 doesn't need a new hand-curated gold corpus — it exposes what those corrections are already correcting for, by keeping an UNCORRECTED copy of the same walk and scoring it against the same reconciled ground truth using the existing _align_occurrences_by_line alignment function (the same one already used to score GitGalaxy).

Scope for Phase 1 (explicitly deferred: promoting parse-error-cascade-region matches into ground truth so tree-sitter's cascade-region recall loss becomes visible too; that's a separate fast-follow)

  1. In measure(), alongside real_funcs/real_classes, build a second uncorrected copy of the same walk (every node matching func_node_types/class_node_types with a resolvable name, no JS/C/perl/TS correction filters applied). Pair it against real_funcs/real_classes via the existing _align_occurrences_by_line, producing new metrics keys: ts_found_functions, ts_extra_functions, ts_found_classes, ts_extra_classes. Apply the existing blind_spot_ranges/trailing_error_start exclusion consistently to ts_extra_* too (ground truth itself is unchanged in this phase).

  2. For args: add a _get_param_count_declaration_only variant of _get_param_count (same function minus the shell/perl body-aware early-return branches — this reproduces exactly the "before" numbers from Claim 1's evidence table, e.g. shell 0%, perl 14.6%). Reuse the same paired occurrences already computed for args_comparable/args_exact_match (keep a node reference alongside each real_funcs occurrence so this doesn't require a re-walk) to compute ts_args_exact_match against the same args_comparable denominator GitGalaxy's own metric uses.

  3. None of this touches _GATED_METRICS, _ALL_BASELINE_KEYS, run_ci_check, or run_regenerate — the PR-time CI gate (.github/workflows/tree-sitter-accuracy-audit.yml) and baseline JSON schema (tests/tree_sitter_accuracy_baseline_*.json) stay exactly as-is. Tree-sitter's own numbers are informational only (not gated) — flow only through --history/--chart.

  4. Extend _HISTORY_RAW_FIELDS and the CSV header in docs/self_scan/tree_sitter_accuracy_history.csv with the 5 new fields (append-only; old rows simply lack the columns).

  5. Extend generate_chart_svg()/_CHART_METRICS so each language gets two adjacent bars per panel (GitGalaxy + tree-sitter) instead of one, ranked by GitGalaxy's value as today, each bar independently colored by its own value via the existing _rainbow_hex LUT, with a short "GG"/"TS" tag to distinguish them. Update the chart's scope-note text to state both series are scored against the same reconciled ground truth, and that cascade-region recall loss isn't yet visible (Phase 1 limitation).

  6. Doc cleanup: consolidate why_we_are_better_than_tree_sitter.md (repo root — currently a blanket, non-dated, non-evidence-disciplined "GitGalaxy is better than tree-sitter" writeup) into docs/why_gitgalaxy_beats_ast_here.md's existing narrow/dated Claim format, verifying each claim still holds against current baselines, then delete the root file.

No workflow YAML changes needed — .github/workflows/tree-sitter-accuracy-history.yml already runs --history/--chart/--summary-table generically and will pick up the new fields automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions