Repository navigation
fix(objective-c): recover bodyless @interface method declarations - #1332
Merged
Merged
Conversation
…ons (#1314 follow-up) func_start's own regex already matched every bodyless @interface method declaration correctly (`- setupWindow;`, `+ newAnchor:(Anchor*)anAnchor;`) -- the gap was entirely downstream in detector.py's generic Mode-B brace-only fallback, which requires an actual `{` within the search window and silently drops any match that never finds one. Since bodyless declarations are terminated by `;`, not `{...}`, and are the ENTIRE public surface of every objc header (not an edge case), this dropped 38 of 38 real interface methods in language-crucible's HyperText.h -- 0% recall on that file, invisible until the #1314 ground-truth fix made real_functions non-zero for objc. Same architectural gap already fixed for rust (#1319) and csharp (#789): added an objc-specific branch treating a bare `;` as a valid terminator. Scoped tightly to func_start's `-`/`+`-prefixed method alternative (capture group 1) only -- that alternative is unambiguous, since nothing but a real method signature can start with a bare `-`/`+`. The regex's OTHER alternative (plain C-style prototypes, group 2) keeps the original brace-only behavior: it has no exclusion shield and can already match a bare two-token call/return statement (`return foo(x);`), currently harmless only because the brace-only path drops it when no `{` follows -- extending bodyless-`;` acceptance there too would resurrect that latent false-positive class. Also fixed two smaller, related gaps surfaced by the same investigation: - tree_sitter_accuracy_audit.py's `_get_param_count` had no handling for objc's method_definition/method_declaration nodes (no "parameters" field in this grammar), so every real method's ground-truth arg count measured as 0 -- a ground-truth gap, not a GitGalaxy defect. - detector.py's `_count_colon_selector_segments` required `:` and `(` to be immediately adjacent characters, undercounting real corpus code that writes `applyStyle: (HTStyle *)style` with a space after the colon. Net effect on language-crucible's objective-c corpus: found_functions 111->149 (real_functions stays 151), func recall 73.5%->98.7%, args_exact_match 73->110 (of 149). Remaining args mismatches trace to a separate, riskier gap (fully untyped keyword-message params, e.g. `back:sender` with no `(Type)` annotation at all) intentionally not chased here -- loosening the args regex to make the type annotation optional risks false-matching ternary expressions (`cond ? a : b`) elsewhere in a method body; left as a known, documented follow-up rather than a rushed fix. Regenerated the objective-c tree-sitter accuracy baseline and both golden-master fixtures (function counts/args changed for objective-c across the differential corpus, as expected for a recall fix). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This was referenced Aug 12, 2026
Closed
squid-protocol
added a commit
that referenced
this pull request
Aug 12, 2026
…pting them The previous commit accepted a bare `;` terminator for the C-style prototype alternative (mirroring #1332's fix for the `-`/`+` method alternative), recovering prototypes like `extern void write_rtf_header(...)` as func_start matches. tree-sitter-accuracy-audit flagged this as a regression: tree-sitter's own C/objc grammar parses a bodyless prototype as a `declaration` node, not `function_definition` -- the ground truth this repo measures against never counted prototypes as real functions, since they have no executable logic to score in the first place. Reworked to the issue's own suggested alternative: explicitly exclude bodyless C-style prototypes from func_start's scope, rather than trying to recover them. This still fixes the original bug (a real prototype previously found only by accident, with a bogus body span stolen from unrelated nearby code) -- it's now correctly never matched at all, instead of sometimes matched with a wrong body. Real C-style function *definitions* (with an actual `{...}` body) are unaffected, since their own `{` always arrives before any `;`. Bonus: this also surfaced and fixed a second instance of the same bug that the earlier corpus check missed -- `WWW_nameOfFile` in worldwideweb/HyperManager.m, another bodyless `extern` prototype that was being misattributed a body from a later unrelated brace. tree_sitter_accuracy_audit --all --ci now passes clean for all 31 languages (objective-c actually improved beyond its prior baseline: 2 pre-existing extra_functions -> 1). Golden masters re-blessed accordingly. Co-Authored-By: Claude Sonnet 5 <[email protected]>
squid-protocol
added a commit
that referenced
this pull request
Aug 12, 2026
…1357) * fix(objective-c): recover bodyless C-style prototypes in func_start (#1336) The C-style prototype alternative of objc's func_start regex (e.g. `extern void write_rtf_header(NXStream* rtfStream);`) was left brace-only when #1332 fixed the sibling `-`/`+` method alternative, since it had no exclusion shield and could already match a bare two-token call/return statement (`return foo(x);`). Real prototypes were only ever found by accident when a `{` happened to appear later in the search window, and grabbed whatever unrelated `{...}` block was nearest (in the corpus case, an `@interface` block's own ivar list several lines later) as a bogus body. Fix: add a "not a function" keyword shield (mirroring `branch`'s own control-flow keyword set) to the regex, closing off the bare-statement false-positive class outright. With that shield in place, detector.py can safely accept a bare `;` terminator for this alternative too, the same way #1332 did for the method alternative. Verified against language-crucible/data/objective-c/worldwideweb/HyperText.h: write_rtf_header now correctly spans just its own line (was lines 19-30, stealing the @interface block's ivar list). Golden masters re-blessed: +1 real prototype recovered in HyperText.h, and 2 latent `return foo();` false positives removed from HyperText.m (HTStyleForRun, HTSave) that this same shield closes off as a side effect. Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix(objective-c): exclude bodyless C-style prototypes instead of accepting them The previous commit accepted a bare `;` terminator for the C-style prototype alternative (mirroring #1332's fix for the `-`/`+` method alternative), recovering prototypes like `extern void write_rtf_header(...)` as func_start matches. tree-sitter-accuracy-audit flagged this as a regression: tree-sitter's own C/objc grammar parses a bodyless prototype as a `declaration` node, not `function_definition` -- the ground truth this repo measures against never counted prototypes as real functions, since they have no executable logic to score in the first place. Reworked to the issue's own suggested alternative: explicitly exclude bodyless C-style prototypes from func_start's scope, rather than trying to recover them. This still fixes the original bug (a real prototype previously found only by accident, with a bogus body span stolen from unrelated nearby code) -- it's now correctly never matched at all, instead of sometimes matched with a wrong body. Real C-style function *definitions* (with an actual `{...}` body) are unaffected, since their own `{` always arrives before any `;`. Bonus: this also surfaced and fixed a second instance of the same bug that the earlier corpus check missed -- `WWW_nameOfFile` in worldwideweb/HyperManager.m, another bodyless `extern` prototype that was being misattributed a body from a later unrelated brace. tree_sitter_accuracy_audit --all --ci now passes clean for all 31 languages (objective-c actually improved beyond its prior baseline: 2 pre-existing extra_functions -> 1). Golden masters re-blessed accordingly. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Joe Esquibel <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
This was referenced Aug 17, 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
Follow-up to #1314 / #1328 (that PR merged while this fix was still in progress, so it's split out as its own PR rather than force-pushing into a closed one).
While verifying #1328's objc ground-truth fix against
language-crucible/data/objective-c/worldwideweb,real_functionsfor objc jumped from 5 (the old, broken measurement) to 151 -- which exposed a genuine, previously-invisible recall gap:HyperText.h's@interfaceblock was measuring 1/38 real methods found (2.6% recall), i.e. GitGalaxy was silently dropping almost the entire public surface of every objc header.Root cause:
func_start's regex already matches every bodyless@interfacemethod declaration correctly (- setupWindow;,+ newAnchor:(Anchor*)anAnchor;) -- confirmed by testing the regex directly. The gap was entirely downstream indetector.py's generic Mode-B fallback, which requires finding an actual{within its search window and silently drops any match that never finds one. Since bodyless declarations are terminated by;, not{...}, and this shape is the entire content of an objc header (not an edge case), every declaration in the file was dropped.This is the same architectural gap already fixed for rust (#1319) and csharp (#789, both
elif lang_id == ...branches in the same function). Added an objc-specific branch that accepts a bare;as a valid terminator -- but scoped tightly tofunc_start's-/+-prefixed method alternative (capture group 1) only, since that alternative is unambiguous (nothing but a real method signature can start with a bare-/+). The regex's other alternative (plain C-style prototypes, group 2) keeps the original brace-only behavior, since it has no exclusion shield and can already match a bare two-token statement (return foo(x);) -- confirmed this would regress if given the same bodyless-;treatment.Also fixed two smaller gaps the same investigation surfaced:
tree_sitter_accuracy_audit.py's_get_param_counthad no handling for objc'smethod_definition/method_declarationnodes, so every real method's ground-truth arg count measured as 0 (ground-truth gap, ~matches objective-c func_start (4.4% precision) and csharp func_start (58.2% precision) have large, confirmed-real false-positive rates #1314's_get_node_namegap in shape).detector.py's_count_colon_selector_segmentsrequired:and(to be immediately adjacent, undercounting real corpus code written asapplyStyle: (HTStyle *)style(space after the colon).Net effect on the language-crucible objective-c corpus:
found_functions111→149 (real_functionsstays 151), func recall 73.5%→98.7%,args_exact_match73→110 (of 149).Not chased here: the remaining args mismatches trace to fully untyped keyword-message params (
back:sender, no(Type)annotation at all -- a common older Objective-C target-action idiom). Loosening the args regex to make the type annotation optional risks false-matching ternary expressions (cond ? a : b) elsewhere in a method body, so it's left as a known, documented follow-up rather than a rushed fix.Changes
gitgalaxy/core/detector.py: newelif lang_id == "objective-c" and match.group(1) is not None:branch (bodyless-;terminator support); whitespace-tolerant fix in_count_colon_selector_segments.tests/core_engine/test_detector.py: new pipeline-level test proving bodyless@interfacedeclarations get extracted end-to-end; 2 new whitespace cases for the colon-selector counter unit test.tests/tools/tree_sitter_accuracy_audit.py:_get_param_countfix for objc's method nodes.tests/tree_sitter_accuracy_baseline_objective-c.json: regenerated.gitgalaxy/standards/language_standards.py: regenerated summary table (objc row only).tests/golden_master_audit.json/tests/golden_master_zero_dep_audit.json: regenerated (real function/args counts changed for objective-c across the differential corpus, as expected for a recall fix).tests/ruff_audit_baseline.json: pure line-shift regen from the detector.py insertion (no new findings).Test plan
pytest tests/core_engine/test_detector.py— all pass (114 tests, includes 2 new)pytest tests/— 6832 passed, 2 skipped, 11 xfailed, 3 xpassedtests/tools/audit_check.py— ruff/mypy/dead-key/ast-accuracy all cleantests/tools/crucible_check.py— full_precision and zero_dependency both PASS against the regenerated golden masters