Skip to content

tree_sitter_accuracy_audit.py: ruby's singleton_class ground truth resolves to no name, inflating extra_classes #1406

Closed

Description

@squid-protocol

What

tests/tree_sitter_accuracy_baseline_ruby.json shows ruby class_start precision at 83.3% with extra_classes=9, but this is a ground-truth measurement gap in tests/tools/tree_sitter_accuracy_audit.py itself (Class 6 bug type per tests/extraction/how_to_extend_class_start_named_extraction.md's checklist), not a real GitGalaxy engine false-positive. Already flagged as a known, low-priority follow-up in a prior session but never formally filed.

Evidence

NODE_MAPS["ruby"]["class_node_types"] already includes "singleton_class" (the class << self node type), but _get_node_name (~line 638) has no case for singleton_class -- it has no name field at all. Confirmed by walking a real parse tree: a singleton_class node's children are literally class, <<, and self (or an arbitrary target expression), with no name-field child. The function falls through every existing branch and resolves to None.

Meanwhile, GitGalaxy's own class_start regex for ruby (gitgalaxy/standards/language_standards.py) already correctly matches class << self and captures its name as the literal string "<< self" (confirmed: re.finditer against " class << self\n" returns group 1 = '<< self'). Because ground truth produces None for the same real class GitGalaxy correctly names "<< self", the diff logic can't match them up, and GitGalaxy's correct extraction gets miscounted as an extra_classes false positive.

Suggested fix shape

Add a singleton_class branch to _get_node_name, mirroring the existing media_statement → "media" precedent (#1313) a few lines below it: reconstruct the exact string "<< " + <target>.text from the node's children (the target is almost always self in real code; the regex supports << @ivar too, so handle that shape if easy, but note that self is the only shape confirmed in the corpus -- 3 occurrences total, all << self) so the resolved name exactly matches what GitGalaxy's own regex captures.

Related

#1261 (parent epic), #1295 (class_start named-extraction epic, where this gap was first noticed and documented as a quick pickup), #1313 (the media_statement precedent to mirror).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions