Skip to content

[TIER 1] C++ func_start: 1,147 false positives against only 5/87 real functions found #1263

Closed

Description

@squid-protocol

Summary

GitGalaxy's C++ func_start regex has a severe dual failure: 5.7% recall (only 5 real functions found out of 87) AND 0.4% precision (1,147 spurious matches vs. 87 real functions in corpus).

Related epic: #1261

Measurements

From tests/tree_sitter_accuracy_baseline_cpp.json:

  • files_scanned: 29
  • real_functions: 87
  • found_functions: 5 (5.7% recall)
  • extra_functions: 1147 (massive false-positive burden)
  • real_classes: 140
  • found_classes: 138
  • extra_classes: 29
  • args_comparable: 5
  • args_exact_match: 0

What this means

Unlike a narrow regex that simply misses some valid patterns (Tier 3), this regex is both:

  • Broken at detection: missing 82 out of 87 real definitions
  • Broken at precision: matching ~13x as many false positives as there are real functions in the entire corpus

This suggests the regex is matching something systematically wrong: likely function calls, template instantiations, constructor initializer lists, or macro expansions rather than actual definitions.

Action

  1. Examine the C++ func_start regex in gitgalaxy/standards/language_standards.py
  2. Examine real C++ function definitions in language-crucible/data/cpp (29 files) to identify valid definition patterns
  3. Sample some of the 1,147 false positives: trace which syntactic elements they're matching (use tests/tools/tree_sitter_accuracy_audit.py with verbose output if available, or inspect manually)
  4. Follow the harden-language-extraction skill's methodology (gitgalaxy/standards/how_to_add_a_language.md)
  5. Before pushing, run python tests/tools/crucible_check.py to confirm no cross-language regressions

Notes

  • C++ is structurally complex (templates, macros, multiple definition syntaxes) but the corpus should be representative. Precision/recall both failing simultaneously is an unusual pattern worth investigating carefully.
  • Class detection on the same files is working (138/140 = 99%), which rules out "the corpus is just hard" as the explanation.

Activity

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

    @squid-protocol
    OwnerAuthor

    Fixed in #1281 (stacked on #1280, which needs to merge first).

    Investigation found the original 5.7%/0.4% numbers were already stale measurement-tool artifacts — #1265/PR #1280 fixed a bug where the tree-sitter ground truth couldn't name any C/C++ function at all. Correctly measured, this issue's real baseline was actually 91%/94% recall/precision, not 5.7%/0.4%.

    From there, three real engine bugs (not measurement bugs) were found and fixed in #1281:

    1. cpp func_start's return-type loop only matched Type* name(), not the equally-common Type *name()/Type * name() styles — this alone was the largest recall gap (many missed pointer/reference-returning getters).
    2. _extract_name dropped the class qualifier on operator overloads (Array::Iterator::operator* → operator*), colliding same-symbol operators across classes.
    3. _extract_name's cleanup charset was missing ~, colliding qualified destructors with their own class's constructor.

    Final measured state: 93% recall, 95% precision on the pinned corpus (up from the corrected-but-still-broken 91%/94% baseline). See #1281 for residual known gaps (parse-error files, macro-wrapped control flow, conversion operators, lambda-initializer ambiguity) and #1282 for a separately-filed C/C++ args-counting bug found along the way.

  3. 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: hightestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions