fix(#2409,#2410): livecode func_start -- Mode D routing + LiveCode Builder handlers - #2420
Merged
Merged
Conversation
…ilder handlers livecode extracted exactly ONE named function from ~900 real handlers across the 98-file language-crucible corpus. Two root causes, one PR: #2410 -- no ScopeParsingRegistry entry, so livecode fell through to Mode B brace-slicing. LiveCode has no braces (`end <name>` terminators), so `_slice_by_braces` produced 1 FunctionNode for the whole corpus despite 781 correct raw `func_start` signals. Added a `mode_d` entry with statement-anchored openers (`on`/`command`/`function`/`getprop`/`setprop`/ `handler` + `repeat`/`if`/`switch`/`try`/`unsafe`), a bare `end` closer, and a `function_opener` for nested-handler detection. Anchoring makes `next repeat` / `exit repeat` / `else if` / `else` fall out for free; a dedicated `_slice_by_keywords` guard handles `if COND then <statement>` one-liners (no `end if`). Same routing-only failure class as MATLAB #1266 / yacc #2351. Also added a `livecode` branch to `_extract_semantic_name`. #2409 -- `func_start` / `args` only knew LiveCode Script's unparenthesized `on|command|function|getprop|setprop <name>` form. Added a second alternation arm for LiveCode Builder `.lcb` `[public|private] handler <name>(...)` -- parenthesized, typed. `foreign handler` (344 FFI binding declarations, C-prototype shaped, no body) and `handler type <Name>()` (function-pointer typedefs) are excluded by construction, per the design decision on #2409. Verification (independent-scanner name-diff, whole corpus): 934 real handler definitions, 934 GG named functions, ZERO false positives, ZERO missed. `.livecodescript` ~815, `.lcb` 121 real `handler` defs. manual_verification.json: livecode `function` 1 -> 934/934 (PRECISION record for handler existence; chart's staleness anchor). Func Found / Func Precision panels go from `0/N` to real; `934/934**` + GitGalaxy badge. `gg_args_found` 2 -> 950. Differential Scan (crucible_check.py, full ~80-repo corpus): every diff is livecode or its downstream ripple -- livecode's one monster function splits into ~934 correctly-sized ones, so its global mass share DROPS ~18x and `dominant_language` corrects `livecode` -> `c`. Zero unrelated-language diffs. Both golden masters re-blessed, re-verified PASS both modes. ast_accuracy / ruff / mypy / dead-key: no change. One body-extent limitation filed as #2419 (does not affect the 934/934 existence count): exactly 1 handler over-extends its body because `_apply_literal_shield` mis-reads `/*` / `*/` inside a LiveCode string literal -- a narrow shield edge, its own PR. tri_comparison_chart.svg / ledger.json are regenerated by the post-merge tri-comparison-history.yml job, not here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S
Contributor
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.
Fixes #2409, fixes #2410.
Problem
livecodeextracted exactly one named function from ~900 real handlers across the 98-filelanguage-cruciblecorpus.escape)func_startraw signals.lcbhandlersTwo root causes, one PR (they're inseparable)
#2410 — no
ScopeParsingRegistryentry → Mode B brace-slice fallthroughLiveCode has no braces (
end <name>terminators), so_slice_by_bracesproduced oneFunctionNodefor the whole corpus. Added amode_dentry:on/command/function/getprop/setprop/handler+repeat/if/switch/try/unsafe), bareendcloser,function_openerfor nestedhandlers. Anchoring is required here (unlike other mode_d configs) because the bare
endcloser also spells
end if/end repeat/end handler, andfunctionis a LiveCode operator.next repeat/exit repeat/else if/elsefall out for free._slice_by_keywordsguard handlesif COND then <statement>one-liners (noend if), analogous to the Ruby/Elixir inline-modifier guard.livecodebranch in_extract_semantic_name.Same routing-only failure class as MATLAB #1266 / yacc #2351.
#2409 —
.lcbhandlersyntax invisible tofunc_start/argsAdded a second alternation arm for LiveCode Builder
[public|private] handler <name>(...)—parenthesized, typed.
foreign handler(344 FFI binding declarations — C-prototype shaped,binds to "<builtin>", no body) andhandler type <Name>()(function-pointer typedefs) areexcluded by construction (the design decision on #2409: parallel to a C header prototype not
being a definition).
Verification
Independent-scanner name-diff over the whole corpus (ground truth = every real handler
definition header, from a line scanner sharing no implementation with
func_start):934 real handler defs · 934 GG named functions · 0 false positives · 0 missed.
(
.livecodescript~815,.lcb121 realhandlerdefs.)manual_verification.json: livecodefunction1 → 934/934(PRECISION record for handlerexistence, the chart's staleness anchor). Func Found / Func Precision panels go
0/N → 934/934**+ GitGalaxy badge.gg_args_found2 → 950.crucible_check.py, full ~80-repo corpus): every diff is livecode orits downstream ripple. livecode's one monster function splits into ~934 correctly-sized ones,
so its global mass share drops ~18× and
dominant_languagecorrectslivecode → c.Zero unrelated-language diffs. Both golden masters re-blessed, re-verified
PASSboth modes.ast_accuracy/ruff/mypy/dead-key: no change.One limitation, filed separately (#2419)
Exactly 1 of the 934 (
addExternalFromFilein the 2183-linerevsaveasandroidstandalone.livecodescript) over-extends its body because_apply_literal_shieldmis-reads
/*/*/sitting inside that file's string literals ("Android/*","*/R.java"),blanking the handler's own
endlines. A narrow shield edge, not a Mode D gap — every otherhandler slices cleanly — and it does not affect the 934/934 handler-existence count. Its
own PR.
Tests
tests/core_engine/+tests/extraction/full: 6803 passed. New:test_detector_mode_d_livecode_script_handlers,test_detector_mode_d_livecode_builder_handlers,.lcbhandlercases intest_livecode.py(func_start + args, incl.foreign handler/handler typeexclusions).tri_comparison_chart.svg/tri_comparison_ledger.jsonare regenerated by the post-mergetri-comparison-history.ymljob, not here (language_standards.py/detector.pyaretri-comparison-audit.ymltrigger paths, but that job only measures js/ts/zig and neverregenerates the chart).
🤖 Generated with Claude Code
https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S