Repository navigation
fix(csharp,objective-c): fix csharp func_start false positives, objc ground-truth gap - #1328
Merged
Merged
Conversation
…objc ground-truth gap (#1314) objective-c's measured 4.4% func_start precision was entirely a ground-truth bug in tree_sitter_accuracy_audit.py: Objective-C's method_definition/ method_declaration nodes have no "name" field in this grammar, so _get_node_name silently returned None for every real method and none of them ever entered real_functions -- every method GitGalaxy correctly found (traceOn, registerAccess, free, ...) then scored as a false "extra". GitGalaxy's own engine needed no change; fixing name extraction alone moves measured precision to 98.2% (108 -> 2 extra, both explainable: one is a legitimate extern C prototype, the other is a tree-sitter parse-error artifact on that specific file). csharp had a mix of both problems: - Ground truth was also missing constructor_declaration from func_node_types (csharp constructors are a distinct tree-sitter node type from method_declaration), scoring every real constructor as a false extra. - The engine itself had a real bug: func_start's "return type" token walk and its final "not a function" shield only excluded MODIFIER and control-flow keywords, not the contextual keywords that can directly precede a `(` in non-function C# 9+ constructs. `static (a, b) => ...` (static lambdas), `var (a, b) = Method(...)` (tuple deconstruction), `catch (Ex e) when (...)` (exception filters), and `x is Foo or Bar` (pattern combinators) were captured whole as phantom functions literally named "static"/"var"/"when"/"or". Separately, `foreach (var x in expr.Method())` and similar statement headers got silently swallowed token-by-token by the permissive walk, landing on the loop expression's own receiver+method as a fake function name (e.g. "changes. GetAddedProjects"). All confirmed against real corpus source (language-crucible/data/csharp/roslyn/{CSharpCompilation,Workspace}.cs) and reproduced independently in xml/powertoys/MainWindow.xaml.cs during golden-master regeneration. Measured csharp func precision moves 58.2% -> 63.4%; most of the remaining extra_functions (322/329) trace to tree-sitter's own parse failure on one 14k-line Roslyn source file (has_error=True), a ground-truth/corpus limitation rather than a GitGalaxy defect. Regenerated both tree-sitter accuracy baselines and both golden-master fixtures (func_start output changed for csharp across the differential corpus, as expected for a false-positive fix). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1314. Investigated both languages' reported func_start precision problems and found the root causes differ per language:
objective-c (4.4% → 98.2% measured precision): pure ground-truth bug, no engine change needed.
Objective-C's
method_definition/method_declarationtree-sitter nodes have no"name"field in this grammar, so_get_node_nameintree_sitter_accuracy_audit.pysilently returnedNonefor every real method, and none of them ever enteredreal_functions. Every method GitGalaxy correctly detected (traceOn,registerAccess,free, ...) then scored as a false "extra" — a 20:1-looking false-positive ratio that was entirely an artifact of the measurement tool, the same shape as #1313/#1311's precedents. Fixed_get_node_nameto read the selector's firstidentifierchild. Confirmed againstlanguage-crucible/data/objective-c/worldwideweb:found_functions5→111,extra_functions108→2 (the 2 remaining are a legitimateexternC prototype and a tree-sitter parse-error artifact on that file, not GitGalaxy bugs).csharp (58.2% → 63.4% measured precision): a mix of a ground-truth gap and a real engine bug.
Ground truth was missing
constructor_declarationfromfunc_node_types(a distinct tree-sitter node type frommethod_declaration), scoring every real C# constructor as a false extra.The real bug:
func_start's permissive "return type" token walk and its final "not a function" shield only excluded modifier/control-flow keywords, not the contextual keywords C# 9+ allows directly before a(:static (a, b) => ...(static lambdas)var (a, b) = Method(...)(tuple deconstruction)catch (Ex e) when (...)(exception filters)x is Foo or Bar(pattern combinators)These were captured whole as phantom functions literally named
"static"/"var"/"when"/"or". Separately,foreach (var x in expr.Method())-shaped statement headers got silently swallowed token-by-token by the same permissive walk, landing on the loop expression's own receiver+method as a fake function name (e.g."changes.GetAddedProjects").All confirmed against real corpus source (
language-crucible/data/csharp/roslyn/{CSharpCompilation,Workspace}.cs) and independently reproduced inxml/powertoys/MainWindow.xaml.csduring golden-master regeneration (removed a phantomhitTestGrid.Children.OfTypefunction there too).Most of csharp's remaining
extra_functions(322 of 329) trace to tree-sitter's own parse failure on one 14k-line Roslyn source file (LanguageParser.cs,has_error=Truefrom the very first line) — a ground-truth/corpus limitation, not something fixable on the GitGalaxy side.Changes
gitgalaxy/standards/language_standards.py: csharpfunc_startregex — extended both the per-token exclusion and the final "not a function" shield with the contextual-keyword set above; regenerated the tree-sitter-accuracy summary table in the module docstring.tests/tools/tree_sitter_accuracy_audit.py: objc_get_node_namefix; addedconstructor_declarationto csharp'sNODE_MAPS.tests/extraction/languages/test_csharp.py: 5 new invalid-case tests for the fixed false-positive shapes.tests/tree_sitter_accuracy_baseline_{csharp,objective-c}.json: regenerated via--regenerate.tests/golden_master_audit.json/tests/golden_master_zero_dep_audit.json: regenerated viaupdate_golden_master.py(real func_start output changed across the differential corpus for csharp, as expected for a false-positive fix).Test plan
pytest tests/extraction/languages/test_csharp.py tests/extraction/languages/test_csharp_strict.py tests/extraction/languages/test_objectivec.py tests/extraction/languages/test_objectivec_strict.py— all passpytest tests/— 6831 passed, 2 skipped, 11 xfailed, 3 xpassedtests/tools/audit_check.py— ruff/mypy/dead-key/ast-accuracy all clean against baselinestests/tools/crucible_check.py— full_precision and zero_dependency both PASS against the regenerated golden masters