Repository navigation
fix(#2405): contain Mode-D scope desync + handle SerenityOS brace blocks - #2431
Merged
Merged
Conversation
Two changes to `_slice_by_keywords`, per the approved scope (Trigger 1 --
bare keyword used as a plain word in a command argument -- left for a
follow-up, needs full command-position awareness):
1. Shell brace-block guard. SerenityOS `/bin/Shell` (`#!/bin/Shell`, 3
corpus files) writes `if cond { ... }` / `for x in ... { ... }` with
no `then`/`do`/`fi`/`done`. Both the keyword (+1) and the trailing `{`
(+1) fired while only `}` (-1) closed -- a permanent +1 desync per
block that swallowed the rest of the file. When a loop/conditional
keyword sits on a line that ends in a bare `{` block opener, the brace
pair owns the scope, so drop the keyword's contribution. Safe for
POSIX (an `if`/`for` header never ends in a bare `{`).
2. Blast-radius containment. In the keyword-scoped shell / ruby / lua /
elixir dialects, a single opener/closer desync leaves one scope open
to EOF, so the remnant satellite can be almost the whole file --
hiding every function after the desync point. Re-scan the swallowed
span for `func_start` matches (Mode-A greedy label slice) and emit
those individually; only the first keeps the `_[Truncated]` marker.
Scoped to those four dialects: matlab's trailing-`function`-without-
`end` is a legitimate idiom (#1266), not a desync.
Result: shell 463 -> 466 funcs (3 truncations -> 1), lua 500 -> 517
(recovered from 8 pre-existing truncation spans; the spans' own markers
remain -- a separate lua Mode-D issue). Summary table: shell func recall
99.1% -> 99.6%, lua 78.7% -> 81.5%.
- tree-sitter-accuracy: lua --regenerate (improvement locked in); shell
extra_functions 14 -> 15 written from measure() (gate-overridden). The
+1 is `tree-sitter-bash` failing on SerenityOS `/bin/Shell` syntax
(`builtin.sh`: 4 real `name() {}` functions, tree-sitter parses 1,
has_error=True) -- documented as a 5th instance under Claim 3 in
docs/why_gitgalaxy_beats_ast_here.md.
- Differential Scan (crucible_check, full corpus): every file-level diff
is a lua or shell file; the ~315 other changes are all `Topological
Coordinates X/Z` recomputing from the shifted function graph, zero
other structural signals moved. Both golden masters re-blessed,
re-verified PASS.
- ast-accuracy / ruff / mypy: no change.
New: test_detector_mode_d_shell_serenity_brace_blocks,
test_detector_mode_d_blast_radius_containment.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
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 #2405 (Trigger 1 — bare keyword used as a plain word in an argument — left for a follow-up;
it needs full command-position awareness).
Two changes to
_slice_by_keywords1. Shell brace-block guard (SerenityOS
/bin/Shell)3 corpus files carry
#!/bin/Shelland writeif cond { ... }/for x in ... { ... }/match $x { ... }with nothen/do/fi/done. Both the keyword (+1) and the trailing{(+1) fired while only}(−1) closed → a permanent +1 desync per block that swallowed therest of the file. Fix: when a loop/conditional keyword sits on a line ending in a bare
{block opener, the brace pair owns the scope — drop the keyword's contribution. Safe for POSIX (an
if/forheader never ends in a bare{), no dialect detection needed.2. Blast-radius containment
In the keyword-scoped shell / ruby / lua / elixir dialects, a single desync leaves one scope open
to EOF, so the remnant satellite can be almost the whole file — hiding every function after the
desync. Fix: re-scan the swallowed span for
func_startmatches (Mode-A greedy label slice)and emit them individually; only the first keeps the
_[Truncated]marker. Scoped to those fourdialects — matlab's trailing-
function-without-endis a legitimate idiom (#1266), not a desync.Result
builtin.sh(SerenityOS) now yields 4 clean functions (_complete_unalias,__complete_job_spec,_complete_kill,_complete_cd);runulp.sh'scheckis recovered even thoughtstilldesyncs (Trigger 1). lua's +17 come from re-scanning its 8 pre-existing truncation spans.
tree-sitter-accuracy
--regenerate— improvement locked in.extra_functions: 14 → 15, written frommeasure()(gate-overridden). The +1 istree-sitter-bashfailing on SerenityOS/bin/Shellsyntax —builtin.shhas 4 realname() {}functions, tree-sitter recovers 1,has_error=True. Documented as a 5th instanceunder Claim 3 in
why_gitgalaxy_beats_ast_here.md(GitGalaxy correct, grammar structurallycan't).
Differential Scan
crucible_check.pyfull corpus: every file-level diff is a lua or shell file. The ~315changes on other files are all
Topological Coordinates X/Zrecomputing from the shiftedfunction graph — zero other structural signals moved. Both golden masters re-blessed, re-verified
PASSboth modes. ast-accuracy / ruff / mypy: no change. 6808 tests pass; 2 new detector tests.tri_comparison_chart.svgregenerated by the post-mergetri-comparison-history.ymljob, not here.🤖 Generated with Claude Code
https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S