fix(detector,apex): exclude new from func_start/args return-type prefix - #1968
Merged
Merged
Conversation
…efix (#1963) Apex's func_start and args regexes both accepted any identifier-shaped token followed by whitespace at line-start as an eligible optional return-type/ modifier prefix, with no exclusion for the `new` keyword. A multi-line SObject-builder call like: Account acct = (Account) TestFactory.createSObject( new Account(name = 'Original Name'), true ); had its `new Account(` line misparsed as "return type = new, function name = Account" -- passing #1221's gate, which only checks that SOME annotation/modifier/return-type-shaped token precedes the name, not that the token is real. tree-sitter never makes this mistake (it structurally distinguishes object_creation_expression from method_declaration). Fixed with `(?!new\b)` immediately before the optional prefix-consuming group in both regexes, mirroring csharp's own GHOST ARGS SHIELD precedent (csharp/java/groovy/dart already exclude `new` from their equivalent prefix groups -- apex was the one language in this family missing it). Found via the tri-comparison ledger sweep (apex/function/existence/agree[gitgalaxy]_vs[tree_sitter]); confirmed against the local apex-recipes corpus (6 occurrences across 2 files). crucible_check.py's ~80-repo differential scan surfaced a third, independent instance (xml/apex/IterationRecipes_Tests.cls, 3 more occurrences inside a List<Account>{...} initializer) that neither the ledger sample nor the local corpus had shown -- also resolved by the same fix, confirming it generalizes rather than being narrowly tailored. GitGalaxy's function count on the local corpus now matches tree-sitter exactly (38/38, zero name diffs; was 40/38 pre-fix). Golden master fixtures re-blessed via update_golden_master.py to reflect the intentional output change. Ledger, chart, points-of-interest doc, and docs/language_status/apex.md's §9 updated to reflect the fix (was diagnosed-only when originally committed). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
squid-protocol
added a commit
that referenced
this pull request
Aug 21, 2026
…kerfile fix) Resolves the merge conflict from #1968 landing on main after this branch forked -- both touched golden_master_audit.json / golden_master_zero_dep_audit.json / tri_comparison_chart.svg / tri_comparison_ledger.json / tri_comparison_points_of_interest.md. Regenerated fresh against the fully merged code (both apex's new ClassName( exclusion and dockerfile's Mode A routing fix) rather than hand-merging the generated files. crucible_check.py passes clean (full_precision + zero_dependency) against the merged state.
squid-protocol
added a commit
that referenced
this pull request
Aug 21, 2026
…1976) * Fix dockerfile func_start recall: route to Mode A, not brace search Dockerfile has no ScopeParsingRegistry entry and no brace-delimited instruction bodies at all, so it silently fell through to Mode_B_Braces in detector.py's _function_slice -- which only produced a named function when a literal `{` happened to appear by coincidence within its search window (almost always an unrelated LATER instruction's `${VAR}` template brace, not anything belonging to the matched RUN/CMD/ENTRYPOINT/HEALTHCHECK's own body). Confirmed via manual verification against language-crucible/data/dockerfile (dockerfile has no tree-sitter/ctags comparison tool): the raw func_start regex was 100% correct (71/71 vs. an independent grep), but the real pipeline's named function list only captured 15/71 of them, with bogus body/impact numbers on top. Routes dockerfile to Mode A (_slice_by_labels), the same greedy-to-next-match heuristic already proven for abap/cobol/fortran/ assembly -- correct here since every Dockerfile instruction really does end at the next instruction. Verified against the full ~80-repo crucible corpus (function_count now matches struct_func_start exactly everywhere, including a 5th real occurrence outside the dockerfile corpus itself), both golden masters re-blessed. Also updates docs/self_scan/manual_verification.json, tri_comparison_chart.svg/points_of_interest.md, and adds docs/language_status/dockerfile.md with the full verification writeup (including why no `class` entry was added -- named build-stage extraction doesn't exist yet, tracked as #1974 -- and two narrower follow-on issues found along the way, #1972 and #1973). Fixes case found via the tri-comparison-ledger-sweep skill's manual-verification fallback for gg-only languages. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Regenerate golden masters/chart against merged main (apex #1968 + dockerfile fix) Resolves the merge conflict from #1968 landing on main after this branch forked -- both touched golden_master_audit.json / golden_master_zero_dep_audit.json / tri_comparison_chart.svg / tri_comparison_ledger.json / tri_comparison_points_of_interest.md. Regenerated fresh against the fully merged code (both apex's new ClassName( exclusion and dockerfile's Mode A routing fix) rather than hand-merging the generated files. crucible_check.py passes clean (full_precision + zero_dependency) against the merged state. --------- Co-authored-by: Joe Esquibel <squid-protocol@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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
Fixes #1963, found via the tri-comparison ledger sweep for apex.
func_startandargsregexes both accepted any identifier-shaped token followed bywhitespace at line-start as an eligible optional return-type/modifier prefix, with no exclusion
for the
newkeyword.TestFactory.createSObject(\n new Account(name = 'X'),\n true\n)) had itsnew Account(line misparsed as a method definition namedAccount, with abogus 1-parameter arg count.
object_creation_expressionfrommethod_declaration.Fix
(?!new\b)immediately before the optional prefix-consuming group in bothfunc_startandargs, mirroring csharp's own GHOST ARGS SHIELD precedent -- csharp/java/groovy/dart alreadyexclude
newfrom their equivalent prefix groups; apex was the one language in this familymissing it.
Verification
apex-recipescorpus: 0 remaining false positives, GitGalaxy's function count nowmatches tree-sitter exactly (38/38, zero name diffs; was 40/38 pre-fix).
tests/extraction/languages/test_apex.py+test_apex_strict.py: 97/97 pass.crucible_check.py's ~80-repo differential scan surfaced a third, independent instance ofthe same bug (
xml/apex/IterationRecipes_Tests.cls, 3 more occurrences inside aList<Account>{...}initializer) that neither the ledger sample nor the local corpus hadshown -- also resolved by the same fix, confirming it generalizes correctly.
update_golden_master.py(both full-precision andzero-dependency modes) to reflect the intentional output change.
ruff_audit.py --ci/mypy_audit.py --ci: clean.Also updates the tri-comparison ledger/chart/points-of-interest doc and
docs/language_status/apex.md's §9 to reflect the fix (previously committed as diagnosed-only).Test plan
pytest tests/extraction/languages/test_apex.py tests/extraction/languages/test_apex_strict.py-- 97/97 passcrucible_check.py-- both modes PASS after re-blessingruff_audit.py --ci/mypy_audit.py --ci-- clean🤖 Generated with Claude Code