Skip to content

c class_start: extra_classes measures the tool's own synthetic 'Anonymous_Class' placeholder against tree-sitter, understating class_precision #1641

Closed

Description

@squid-protocol

Summary

tests/tools/tree_sitter_accuracy_audit.py --lang c reports class_precision 78.2% (found_classes=61, extra_classes=17). All 17 "extra classes" (100%) are the exact same literal name: Anonymous_Class, one per file, across all 17 affected corpus files (cpython, doom, micropython, sqlite/lemon.c).

This is not a GitGalaxy engine false-positive. It's the exact same measurement-tool blind spot already fixed for functions via _SYNTHETIC_GG_FUNC_NAMES = frozenset({"Anonymous_Block", "__global_context__"}) (see that constant's own comment, matlab/shell), just never extended to the class comparison.

Root cause

gitgalaxy/core/detector.py's _resolve_class_start_match (line ~432) falls back to the literal string "Anonymous_Class" as the reported name whenever c's class_start regex matches a struct/union/enum with no capturable tag name -- most commonly typedef struct { ... } Foo;, an extremely common real C idiom (epic #813/#822 deliberately made the tag name optional so this shape is found, just not named). This is intentional, correct behavior for the engine: the struct genuinely exists, GitGalaxy just can't invent a name tree-sitter didn't give it either.

tree_sitter_accuracy_audit.py's class-comparison step (measure(), around line 1783-1794) builds gg_classes directly from class_data.class_name with no equivalent exclusion set, so every Anonymous_Class row is compared by literal string against tree-sitter's real_classes set -- which, by construction, can never contain the string "Anonymous_Class" (tree-sitter reports real node text, not GitGalaxy's placeholder), so it's counted as a permanent false "extra" every time GitGalaxy correctly identifies an anonymous struct/union/enum.

Confirmed via direct diff script over language-crucible/data/c/*: 17/17 extra_classes are literally 'Anonymous_Class', zero other names.

Suggested fix

Add a _SYNTHETIC_GG_CLASS_NAMES = frozenset({"Anonymous_Class"}) in tests/tools/tree_sitter_accuracy_audit.py, filtered out when building gg_classes, mirroring the existing _SYNTHETIC_GG_FUNC_NAMES filter applied to gg_funcs_by_name a few lines above it. Audit-tool-only change; no gitgalaxy/ engine code needs to change.

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