Skip to content

csharp class_start: extra_classes counts real, correctly-found classes inside LanguageParser.cs's known parse-error cascade (same family as #1427/#1567, never extended to classes) #1642

Closed

Description

@squid-protocol

Summary

tests/tools/tree_sitter_accuracy_audit.py --lang csharp reports class_precision 73.3% (found_classes=22, extra_classes=8). All 8 "extra classes" are in a single corpus file, roslyn/LanguageParser.cs: LanguageParser, NameOptions, ParseTypeMode, Precedence, ResetPoint, ScanTypeArgumentListKind, ScanTypeFlags, VariableFlags -- every one a real, correctly-named C# class/enum/struct confirmed present in the corpus source (e.g. private enum NameOptions at line 5997, internal sealed partial class LanguageParser : SyntaxParser at line 20).

Root cause

This is the same ground-truth blind spot as #1427/#1567 (csharp extra_functions), just never extended to the class comparison. tree-sitter-c-sharp's installed grammar fails to parse a C# 11 list-pattern + property-pattern construct partway through LanguageParser.cs; the resulting ERROR node cascade is severe enough that tree.root_node.type itself becomes "ERROR" (confirmed directly) rather than the normal compilation_unit -- i.e. _find_trailing_error_cascade_start correctly detects a cascade for this file (trailing_error_start computed, non-None), but that detection is currently only applied to the function comparison (measure(), line ~1811-1812: unmatched_gg = [occ for occ in unmatched_gg if occ[0] < trailing_error_start]). The class comparison (line ~1793-1794: metrics["extra_classes"] += len(gg_classes - real_classes)) has no equivalent filtering at all, so every real GitGalaxy-found class whose defining node never survived the cascade (including the outer LanguageParser class itself, whose body span covers the entire corrupted region and so never resolves into a proper class_declaration node at all, even though it starts at line 20 -- well before the cascade's textual start) gets counted as a false "extra".

This is precision-only; csharp's class_recall (91.7%) is a separate, already-understood/accepted limitation (ground truth is genuinely blind past the cascade) and isn't being touched by this fix.

Suggested fix

Extend the existing trailing_error_start gate to the class comparison. Caveat: unlike function_data, class_data (gitgalaxy/recorders/record_keeper.py) has no start_line column, so the precise per-occurrence line-based filtering functions use (occ[0] < trailing_error_start) isn't directly available for classes. Recommend a coarser, file-level version instead of a schema change: when trailing_error_start is not None for a file, skip adding that file's gg_classes - real_classes to extra_classes entirely (rather than trying to determine which individual GG-found class names fall before/after the cascade point). This is a strict scope match for the evidence here -- trailing_error_start for LanguageParser.cs resolves to line 1 (the cascade swallows the root node itself), so a file-level exclusion produces the identical outcome an occurrence-level one would for this file, without adding a start_line column to a production DB table just to serve one audit tool.

Out of scope

Scope note: this only affects the tree-sitter-accuracy measurement's class_precision number (epic #1261/#813's extraction-pillar naming accuracy), not GitGalaxy's actual risk-scoring output.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-positive
    on Aug 15, 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

    bugcore-enginetestingthreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions