Skip to content

[TIER 2] Verify tree-sitter accuracy measurement's own ground truth for C before treating found_functions=0 as a GitGalaxy defect #1265

Closed

Description

@squid-protocol

Summary

The C language baseline shows real_functions=0 across 31 real C corpus files (tree-sitter's own parse found zero real functions), yet the same corpus's struct/class detection is healthy. This is implausible for 31 real C files and suggests a measurement artifact rather than a GitGalaxy defect.

Related epic: #1261

Measurements

From tests/tree_sitter_accuracy_baseline_c.json:

  • files_scanned: 31
  • real_functions: 0 (tree-sitter found zero functions)
  • found_functions: 0
  • extra_functions: 1687
  • real_classes: 79 (tree-sitter found 79 structs/classes)
  • found_classes: 45
  • extra_classes: 7

What's suspicious

  • A real 31-file C codebase with zero functions (only structs/classes) is implausible -- C programs are primarily composed of functions.
  • The same corpus's struct/class extraction (45/79 = 57% recall) suggests the corpus and measurement tool are generally working.
  • GitGalaxy's C regex reports 1,687 false positives: if it's matching something legitimately wrong (macro invocations, typedef lines, etc.), that's a real finding. But not necessarily a function extraction defect.

Action

Before writing any "fix" for GitGalaxy's C func_start regex, verify the measurement tool's own ground truth:

  1. Check tests/tools/tree_sitter_accuracy_audit.py's file-language classification:

    • Are all 31 scanned files correctly identified as C (vs. C headers, C++, or other languages)?
    • Does the measurement harness correctly distinguish .c from .h files, or is it lumping headers (which often have zero functions) into the count?
  2. Check the run_engine_scan() function or equivalent:

    • Is the language field in file_data correctly populated from the manifest or file extension for each file?
    • Are there any language-detection mismatches between tree-sitter's classification and GitGalaxy's?
  3. If all 31 files are genuinely classified as C and genuinely contain zero functions:

  4. If there IS a mismatch or misclassification:

    • Document the mismatch and file a SEPARATE sub-issue once the ground truth is clarified.

Notes

  • This is filed as Tier 2 (measurement validation) rather than Tier 1 (defect) because the evidence suggests the measurement may be the problem, not the engine.
  • Do NOT assume the 1,687 false positives are wrong until the ground truth is confirmed -- that might legitimately expose a precision issue once we know what we're actually measuring.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    on Aug 11, 2026
  2. squid-protocol commented on Aug 11, 2026

    @squid-protocol
    OwnerAuthor

    Diagnosis: confirmed measurement-tool bug, not a GitGalaxy defect. Fixed in #1280.

    Traced the root cause empirically against the real language-crucible/data/c corpus (the same 31 files this baseline measures).

    Root cause: _get_node_name() in tests/tools/tree_sitter_accuracy_audit.py extracts a node's name via node.child_by_field_name("name"), with special-case fallbacks only for JS arrow functions, Fortran statements, and Make rules. tree-sitter-c's function_definition node has no name field at all — the identifier sits two levels deep, at function_definition → declarator (function_declarator) → declarator (identifier), with an extra pointer_declarator layer for pointer-returning functions. There's no special case for it, so the fast path always returns None.

    Confirmed two ways:

    1. Synthetic snippets: every function_definition node returns name_field=None.
    2. The real corpus: walking all 31 scanned .c/.h files found 1,790 real function_definition nodes, of which 0 exposed a usable name field.

    That's deterministic and corpus-content-independent — real_functions was always going to be 0 for C regardless of what's in the files. It also explains found_functions=0: nothing can ever match against an empty real_funcs set, so every one of GitGalaxy's genuinely-found function names got misclassified as a false positive ("extra"). 1,687 is in fact close to the true 1,790 real function definitions (~94%) — GitGalaxy's C func_start regex was working fine the whole time.

    Also ruled out this issue's other hypothesis (header-heavy/misclassified corpus): all 31 scanned files are exactly the 22 .c + 9 .h files in the corpus, correctly classified as c. Not a language-detection bug.

    Bonus finding: the same tool had a second, distinct bug in the C++ baseline — NODE_MAPS["cpp"] included "template_function" in func_node_types, but that node type is a template instantiation expression (e.g. const_cast<Node*>, cast_to<Window>), not a function definition. 34 of the 87 "real_functions" counted for C++ were actually casts/instantiations.

    Fixed in #1280 (_unwrap_c_style_declarator helper + dropping template_function from cpp's node map). Regenerated baselines:

    • c: real_functions 0→1776, found_functions 0→1670, extra_functions 1687→17 (94% recall, 99% precision).
    • cpp: real_functions 87→1187, found_functions 5→253 (21% recall) — this is a real, previously-invisible GitGalaxy C++ recall gap now correctly surfaced for the first time. Not fixed in fix(testing): tree-sitter accuracy audit couldn't name C/C++ functions #1280 (that's an engine-hardening task, not a measurement fix) — worth a separate follow-up issue against the C++ func_start regex.
    • objective-c: same root-cause bug (tree-sitter-objc's C-derived function_definition), fixed incidentally.

    No change was made to GitGalaxy's C func_start regex — per this issue's own Action item 3, the 1,687 "false positives" weren't real.

  3. added 3 commits that reference this issue on Aug 11, 2026
    e0eb02a
    2880d6b
    1e8db53
  4. added a commit that references this issue on Aug 13, 2026
    491f38e
  5. 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-enginepriority: mediumtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions