Repository navigation
Description
Summary
#1264 fixed detector.py's named-entity class extractor to reuse each language's own class_start rule (from language_standards.py) instead of one hardcoded, language-agnostic regex -- see _CLASS_START_NAMED_EXTRACTION_LANGS in gitgalaxy/core/detector.py. That switch is currently scoped to an allowlist of 18 languages verified clean via tests/tools/tree_sitter_accuracy_audit.py against the language-crucible corpus: apex, cpp, csharp, fortran, groovy, java, javascript, lua, makefile, matlab, php, powershell, python, scala, shell, solidity, tcl, typescript.
The remaining 13 languages with a tree-sitter baseline regressed when tried against their own class_start and were left on the legacy fallback regex pending real hardening:
| Language | Regression when switched to its own class_start |
Likely cause |
|---|---|---|
| c | found_classes 45→0, extra_classes 7→23 | class_start has no capture group (by design -- it also intentionally matches bare struct-TYPE-usage sites like struct foo_ops ops; for risk-signal purposes, epic #813/#822). Needs a real declaration-vs-usage distinction before it can safely name entities, not just an added capture group. |
| swift | found_classes 9→0 | class_start has no capture group at all (pure occurrence counting). Needs a capture group added around the name -- likely the simplest fix in this list. |
| zig | extra_classes 0→629 | Huge over-match. const X = struct {...} is zig's pervasive per-file-as-namespace idiom; class_start is probably firing on many declarations tree-sitter's class_node_types doesn't count as "classes". Needs investigation into what's actually matching before deciding whether to narrow the regex or the ground-truth scope. |
| go | extra_classes 0→69 | Likely legitimate type X struct/type X interface matches that tree-sitter's class_node_types for go doesn't fully cover, or GitGalaxy matching plain type aliases too broadly. Needs a real diff (same method used for csharp/fortran in #1264) before concluding which side is wrong. |
| css | extra_classes 0→90 | class_start in CSS means something different (selectors), not OOP classes -- almost certainly a ground-truth scope mismatch, not a detector bug. Worth confirming CSS should even be in scope for this kind of "class" extraction at all. |
| rust | extra_classes 10→25 | pub struct/enum/union/trait -- needs the same real-vs-noise diff method #1264 used for csharp (dump gg_classes - real_classes per file and inspect, not just trust the aggregate count). |
| perl | extra_classes 1→20 | package/role -- perl's package declarations are extremely common and may not all correspond to what tree-sitter's ground truth considers a "class". |
| dart | extra_classes 8→33 | Compound modifier stack (`abstract |
| haskell | extra_classes 0→15 | data/newtype/class/type -- haskell's class_start covers typeclasses AND data/newtype declarations, likely broader than tree-sitter's class_node_types scope. |
| html | extra_classes 0→4 | Small; probably an easy diff to run down. |
| kotlin | extra_classes 3→5 | Small; compound modifier stack like dart/scala. |
| objective-c | extra_classes 0→5 | Small; probably an easy diff to run down. |
| ruby | extra_classes 2→9 | class/module -- ruby's module keyword may be over-broad relative to tree-sitter's class_node_types. |
Precedent from #1264
For csharp (kept in the allowlist despite extra_classes: 0 -> 13), the per-file diff showed the "regression" was not a detector bug: 12 of the 13 were real enum declarations that csharp's own class_start intentionally treats as class-like risk-signal entities (by design, matching how TypeScript/Java also fold enums in), which tree-sitter's class_node_types for csharp deliberately excludes; the 13th was a real class name (LanguageParser) that tree-sitter's own C# grammar failed to parse due to error-recovery limits on that large file (confirmed directly against tree_sitter_language_pack). Do the same per-file diff for each language above before assuming the regex is broken -- the method is in #1264's PR description: query class_data vs a fresh tree-sitter walk per file, print gg_classes - real_classes and real_classes - gg_classes, and read the actual file content at those lines.
Suggested approach
Same shape as epic #813 (extraction hardening) / #1069 (strict-signature hardening) / #1227 (tree-sitter accuracy): one sub-issue per language (or a batch of the "small" ones together -- html/objective-c/kotlin/ruby all show single-digit extra_classes and may be quick), each ending with:
- Add the language to
_CLASS_START_NAMED_EXTRACTION_LANGSingitgalaxy/core/detector.py. python tests/tools/tree_sitter_accuracy_audit.py --lang <x> --regenerateto lock in the improved baseline.python tests/tools/crucible_check.py(both modes) before pushing, since this touches parsing logic.
C and Swift are the two most likely to need actual language_standards.py regex changes (not just measurement); the rest may turn out to be ground-truth scope mismatches like csharp's enums, fixable with no code change at all beyond flipping the allowlist.
Activity
squid-protocol commentedon Aug 12, 2026
Scaffolding done: tooling + a significant scope revision
Built out the process for this epic (checklist doc, offline triage script, skill, subagent -- PR incoming). While building the triage tool I found something that changes the priority order significantly.
7 of the 13 languages listed above aren't measuring class recall at all right now.
real_classesreads as 0 intree_sitter_accuracy_audit.pyfor go, css, zig, perl, kotlin, objective-c, and html -- not because those languages lack real class/struct/interface-shaped code (they obviously don't), but because the ground-truth extraction itself is broken or mismatched:_get_node_name-- the chosenclass_node_typesnode (type_declaration,class_declaration,class_interface,ContainerDecl) exists and matches real declarations, but has nonamefield itself; the name lives on a child (type_specfor go, a positionaltype_identifier/identifierchild for kotlin/objective-c) or an ancestor (VarDeclfor zig'sconst Foo = struct{}idiom). Same kind of fix as the Fortran/C-declarator/Make special cases already in_get_node_name-- just needs the same treatment for these four. Exact node structure for each is in the new doc.class_statement(the new Perl 5.38+classkeyword), but real-world corpus code (exiftool) uses the traditionalpackage Foo;idiom almost exclusively -- a different node type. Needs a judgment call on whether to addpackage_statementtoclass_node_types.rule_set/elementdon't have "names" the way GitGalaxy's ownclass_startregexes for those languages think about them (CSS selectors, a curated HTML tag list). Worth deciding whether these belong in this exercise at all.Only 6 languages currently have trustworthy ground truth to test a
class_startregex against: c, swift, rust, dart, ruby, haskell. Recommend treating the ground-truth fixes (go/kotlin/objective-c/zig, all intests/tools/tree_sitter_accuracy_audit.py, none touchlanguage_standards.py) as their own small batch of PRs, separate from and probably before the regex-hardening work on the 6 languages above.Full detail, per-language diagnosis table, and the recurring-cause checklist are in
tests/extraction/how_to_extend_class_start_named_extraction.md(landing in the scaffolding PR). New tool:python tests/tools/class_start_diff.py --lang <x>-- previews the real per-file extra/missing name diff for any language using the live pipeline's exact name-resolution algorithm, without needing to add it to the allowlist first.fix(core): class extractor never consulted per-language class_start, …
chore(tooling): scaffold epic #1295 -- diff script, checklist doc, sk…
chore(tooling): scaffold epic #1295 -- diff script, checklist doc, sk…
docs: update #1295 checklist doc for go/objective-c completion + kotl…
squid-protocol commentedon Aug 12, 2026
go and objective-c done -- PR #1344
Both were confirmed ground-truth measurement gaps (see the scaffolding comment above), not regex
bugs. Fixed
_get_node_nameintree_sitter_accuracy_audit.py:type_declarationhas nonamefield -- it's on the childtype_spec. Flipped into_CLASS_START_NAMED_EXTRACTION_LANGS:found_classes0→69,extra_classes0→0. The 15tree-sitter-only "missing" are all plain type aliases (
type WaitStatus uint32) that go's ownclass_startintentionally excludes (requiresstruct/interfaceto follow) -- a scopemismatch, not a recall bug, same shape as csharp's enum precedent in [TIER 1] Class detection is 0% across apex/csharp/fortran/solidity despite near-perfect function detection #1264.
class_interface/class_implementation/class_declarationhave nonamefield -- first positional
identifierchild is the name. Flipped into the allowlist:found_classes0→5,extra_classes0→0, a perfect match.crucible_check.pyboth modes clean, fullcore_engine/extractionsuite passes (6573 tests),audit_check.pyclean.Also found while there: kotlin and zig's ground-truth gaps are already fixed
Not by this PR -- as a side effect of #1313's earlier function-extraction work, which added
_get_node_namebranches for kotlin'sclass_declarationand zig'sContainerDeclthat alsohappen to resolve class names correctly.
real_classesnow reads 4 for kotlin and 642 for zig(previously 0 for both per the scaffolding comment above). Neither is flipped into the allowlist
yet:
found_classesis still 0,extra_classesis 5, all"Anonymous_Class"--class_starthas no capture group (same shape as C/Swift). Needs the regex workflow, not moremeasurement-tool work. Moved from the "fixable now" table to "ground truth already works" in
the checklist doc.
extra_classesis 10,missing_classesis 23 -- needs a real per-file diff (samemethod as csharp/fortran in [TIER 1] Class detection is 0% across apex/csharp/fortran/solidity despite near-perfect function detection #1264) before concluding what's over/under-matching. Also moved to
"ground truth already works."
Updated
tests/extraction/how_to_extend_class_start_named_extraction.md's tables to reflect allof this so the next pass doesn't re-derive it. Remaining: c, css, dart, haskell, html, kotlin,
perl, ruby, rust, swift, zig (11 languages) -- of these, c/swift/rust/dart/ruby/haskell/kotlin/
zig (8) are ready for the regex workflow now; css/html/perl (3) still need the judgment call
described in the doc.
fix(core): extend class_start named extraction to go and objective-c (#…
squid-protocol commentedon Aug 12, 2026
swift done -- PR #1361
Two fixes, not one:
class_starthad no capture group around the name -- added one, widened to a dotted chain so nested-type extensions (extension AFError.ParameterEncoderFailureReason { ... }) capture their full qualified name.protocol_declarationnode type, separate fromclass_declaration, whichNODE_MAPS["swift"]didn't include -- undercountedreal_classesby exactly the protocols with no same-namedextensionelsewhere in the corpus to accidentally surface them (e.g. Alamofire'sRequestDelegate).found_classes23→38,real_classes37→38,extra_classesstays 0 -- perfect match.crucible_check.py(both modes) clean, fullcore_engine/extractionsuite passes (6584 tests),audit_check.pyclean.Remaining per the doc's tables: c, css, dart, haskell, html, kotlin, perl, ruby, rust, zig (10 languages, swift now off the list). kotlin and zig both need the regex workflow (ground truth already fixed, per the previous comment) -- kotlin is the same no-capture-group shape swift just went through, likely another quick one.
docs: update class_start extraction checklist for swift (#1295)
fix(swift): wire swift into class_start named-entity extraction (#1361)
docs: update class_start extraction checklist for kotlin (#1295)
squid-protocol commentedon Aug 12, 2026
kotlin done -- PR #1365
Flagged as "likely another quick one" (same no-capture-group shape swift just went through) -- turned out to be three stacked bugs:
class_starthad no capture group at all -- added group 1 for the mainclass|interface|object|enum classbranch, group 2 forcompanion object's own optional name.fun interface Foo(SAM declarations, Kotlin 1.4+) wasn't recognized --funwas missing from the modifier list. Real recall gap, confirmed against okhttp'sfun interface Factory.objectdeclarations (includingactual/expectmultiplatform variants) get their ownobject_declarationnode type, notclass_declaration. Undercountedreal_classesby every object singleton in the corpus.found_classes3→7,real_classes4→7,extra_classesstays 0 -- perfect match. Golden master updated both modes (okhttp/Call.kt's class count 1→2, all other diffs downstream numeric fallout of that one signal change).crucible_check.pyclean, full suite passes,audit_check.pyclean.Remaining per the doc's tables: c, css, dart, haskell, html, perl, ruby, rust, zig (9 languages). zig's ground truth already works (
real_classes=642) but needs a real per-file diff before the regex workflow -- likely next since it's already unblocked.11 remaining items
squid-protocol commentedon Aug 12, 2026
Correction + final update: 11 of 13 done, css/html closed by design
My prior comment was stale (said "4 remain" / dart+ruby "pending merge" -- all 4 of that batch are
now merged: #1377 haskell, #1378 c, #1385 dart, #1386 ruby).
perl done -- PR #1393. Same shape as the other "quick" fixes this epic: no regex change, pure
ground-truth gap. Perl's own
class_startalready correctly matchespackage|class|role;NODE_MAPS["perl"]only targeted the brand-new Perl 5.38+classkeyword, which real-world code(bugzilla, exiftool) essentially never uses -- the traditional
package Foo::Bar;idiom is whatactually needed to be added.
real_classes0→20,extra_classes0 throughout, perfect match.css and html -- decided, not left open. Both were flagged from the start as needing a
judgment call rather than a quick fix. Checked what
class_data(this epic's target table)actually models:
class_name/inheritance_parents/method_count/state_entanglement-- a realOOP-class schema. Neither css selectors nor generic HTML elements fit that shape (no methods, no
code-structural inheritance) -- populating it with them would just be permanent
method_count=0/inheritance_parents=[]noise in any downstream query, not a data-completenesswin. Their
class_startnumeric signal (used in risk-scoring equations, a separate consumer)is completely unaffected -- this decision is scoped only to named extraction. Decision:
permanently out of scope, documented in the checklist doc's own "Decided: not extending css or
html" section so it doesn't get re-opened cold later.
Final state: 11/13 done (go, objective-c, swift, kotlin, zig, rust, haskell, c, ruby, dart,
perl). css/html closed by design. One small optional follow-up remains, documented not urgent:
ruby's
singleton_classhas no real name to resolve (3 occurrences total, cosmetic).Epic is effectively complete pending #1393's merge.
fix(perl): wire perl into class_start named-entity extraction (#1295) (…
fix(powershell): wire up class_start named extraction, clarify css/ht…
fix(scala): recognize private/protected modifiers on class_start
Fix/powershell css class recall graph (#1401)
docs(readme): tighten AST-vs-signature thesis, add measured tree-sitt…
squid-protocol commentedon Aug 13, 2026
Closing -- 11/13 languages done (go, objective-c, swift, kotlin, zig, rust, haskell, c, ruby, dart, perl), all confirmed wired into
_CLASS_START_NAMED_EXTRACTION_LANGSingitgalaxy/core/detector.py. Final language, perl, landed via #1393 (merged 2026-08-12). css and html are permanently out of scope by design (documented in the epic's checklist doc) -- neither fitsclass_data's OOP-class schema (no methods, no inheritance), so named extraction would just produce permanent noise; their existing numericclass_startrisk-scoring signal is unaffected. One optional cosmetic follow-up remains (ruby'ssingleton_classhas no real name to resolve, 3 occurrences total) but is low priority and not blocking closure.feat: recall/precision split, fix args-credit bug, redesign chart per…
fix(testing, rust): exclude impl_item from class ground truth (scope …
docs(self-scan): validate all 3 cobol tri-comparison ledger shapes (#…
fix(abap): two more real bugs found regenerating the tri-comparison c…
fix(cobol): add cobol to class_start named-extraction allowlist (#1923)
fix(detector): enforce #1295's css/html class-extraction scope decisi…