Fix shell Mode-D quote/heredoc shielding; validate all shell tri-comparison shapes - #2406
Merged
Merged
Conversation
…arison shapes
Shell tri-comparison-ledger-sweep. Two engine bugs in `_apply_literal_shield`
were desyncing `_slice_by_keywords`' depth stack so hard that one bad token
swallowed the rest of the file into a single `<name>_[Truncated]` satellite:
1. `--` and `//` were in shell's comment-marker set. In shell `--` is the
end-of-options delimiter (`alert --stop ...`) and `//` has no comment
meaning; both are everywhere in ordinary commands. ` --flag "..."` got
eaten as a "comment", orphaning the opening quote of a multi-line string
and corrupting every subsequent quote/keyword count. One `alert --stop
"..."` in haiku/HardwareChecker.sh cost 10 top-level functions.
2. A quoted heredoc delimiter (`sed 's/^X//' << 'SHAR_EOF'`) was rewritten
to `<< ''` by the quote pass before the heredoc state-machine could
register it, leaving the whole heredoc body (C source, a shar archive)
live to corrupt scope. Fixed by matching a real heredoc opener before the
quote alternatives and returning it verbatim.
Shell func recall against tree-sitter+ctags: the
`agree[ctags,tree_sitter]_vs[gitgalaxy]` shape drops 16 -> 4, and
`agree[gitgalaxy]_vs[ctags,tree_sitter]` (over-detection) 7 -> 3. Both
golden masters re-blessed (shell func counts up + global spatial-map ripple);
crucible_check PASS both modes.
Ledger: all 5 shell shapes now `status: validated` with real `verdict` text
(the prior sweep's scratch script had written the investigation into a
non-schema `notes` field and left `verdict` null). Cleared a malformed
`credit_tools: ["gitgalaxy"]` on the `args/agree[none]` shape. Corrected the
`agree[ctags]` verdict ("array" -> "scalar" assignments).
Residual shell misses filed as #2405 (bare keyword in a command argument;
SerenityOS brace syntax). Not GitGalaxy bugs, documented instead:
- why_gitgalaxy_beats_ast_here.md Claim 3 gains a fourth instance: a `;`
inside `${var:+word;}` cascades tree-sitter-bash into a zero-function parse.
- ctags_reader.py shell KIND-MAP note: ctags' Sh parser tags scalar
assignments (`GREP_OPTS=`) as functions.
.gitignore: backstop `/language-crucible*/` so a stray in-repo corpus clone
can't poison the golden masters.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
squid-protocol
added a commit
that referenced
this pull request
Aug 29, 2026
…2422) #2415 (aperture infra_path_pattern left-boundary fix) newly included ~20 real source files across the corpus, but tree-sitter-accuracy-audit.yml does not trigger on aperture.py, so it merged without regenerating the affected baselines. `tree_sitter_accuracy_audit.py --all --ci` has been red on main for every detector.py/prism.py/language_standards.py PR since. Every number here is `measure()`'s own output, not hand-edited. No engine code changes. - shell: 31.6% -> 99.1% func recall, 68.3% -> 97.0% precision. This is #2401 / #2406's shell Mode-D fixes finally reflected in the baseline (found_functions 140 -> 449, extra 65 -> 14); the +6 files / +10 real functions from #2415 are a small part of it. - powershell: func recall/precision unchanged (100%/100%); +3 files, args_exact_match 234 -> 252 of 257. - c 99.0 -> 99.7% · lua 78.2 -> 78.7% · tcl 98.6 -> 100.0% · ruby args_exact_match 115 -> 121 -- all `found_functions` improvements from the +1 file each, already passing --ci ("improved on ..."), locked in here so the summary table stays honest. - html: N/A -> 0.0% func precision. `cpython_jinja/layout.html` (a Jinja template, new via #2415) has a `<style>` block; html's func_start intentionally anchors on `<style>`/`<script>` element boundaries, which tree-sitter-html models as inert raw_text, so it shows as extra_functions 0 -> 1. Baseline written from measure() output with the regression gate overridden -- same maintainer-override shape as commit 9011de4 (lua class precision 0.0%). Whether html func-precision should be forced N/A like css/html class-precision already is: filed as #2421. Summary table in language_standards.py's docstring regenerated to match. Claude-Session: https://claude.ai/code/session_019Zm1uVBpVEZJ9SB7bWFR8S 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.
What
tri-comparison-ledger-sweepfor shell — investigate every GitGalaxy-vs-tree-sitter-vs-ctagsdisagreement shape for shell, fix GitGalaxy where it's the one that's wrong, and land a real
verdicton every shape.Engine fixes (
gitgalaxy/core/detector.py,_apply_literal_shield)Two bugs were desyncing
_slice_by_keywords' Mode-D depth stack so badly that one mishandledtoken swallowed the rest of the file into a single
<name>_[Truncated]satellite:--and//were in shell's comment-marker set. In shell--is the end-of-optionsdelimiter (
alert --stop …,git checkout -- file) and//has no comment meaning — bothappear constantly in ordinary commands.
--flag "…got eaten as a "comment", orphaning theopening quote of a real (often multi-line) string and corrupting every subsequent quote/keyword
count. One
alert --stop "…"inhaiku/HardwareChecker.shcost 10 top-level functions.Fixed: shell/bash comment marker is
#only (mirrors the existing matlab special-case).Quoted heredoc delimiters were destroyed before the heredoc state-machine saw them.
sed 's/^X//' << 'SHAR_EOF'→ the quote pass rewrote'SHAR_EOF'to''first, so step 2'sheredoc detector saw
<< ''and never registered the heredoc — the whole body (C source, ashar archive) stayed live. Fixed: match a real heredoc opener before the quote alternatives
and return it verbatim (
preserve_newlines).Effect: the
shell/function/existence/agree[ctags,tree_sitter]_vs[gitgalaxy]recall-gap shapedrops 16 → 4; the
agree[gitgalaxy]_vs[ctags,tree_sitter]over-detection shape 7 → 3.Both golden masters re-blessed (shell func counts up + global spatial-map ripple);
crucible_check.pyPASS both modes; shell/ruby/perl/core extraction + strict suites green;ruff / mypy / dead-key baselines clean.
Ledger — all 5 shell shapes now
status: validatedwith real verdictsThe prior sweep's scratch script had written its findings into a non-schema
notesfield and leftverdictnull on 4 of 5 shapes, and set a malformedcredit_tools: ["gitgalaxy"]on anagree[none]shape (no defined effect — printed a warning every chart run). All corrected:agree[gitgalaxy]_vs[ctags,tree_sitter](3)_[Truncated]desync artifacts, zero real GG-only funcs — residual triggers filed as #2405agree[ctags,tree_sitter]_vs[gitgalaxy](4)zgrepis the deliberatescope_depth==0limit;t/check/__complete_job_specare #2405agree[ctags,gitgalaxy]_vs[tree_sitter](11)agree[ctags]_vs[gitgalaxy,tree_sitter](44)sub-style helpersargs/agree[none]_vs[gitgalaxy,tree_sitter](10)$Nproxy (Claim 1); tree-sitter's flat1is the artifact; malformed credit clearedNot GitGalaxy bugs — documented
docs/why_gitgalaxy_beats_ast_here.md— Claim 3 gains a fourth confirmed instance: a;inside a
${var:+word}/${var:-word}parameter expansion makestree-sitter-bashsethas_errorand emit zerofunction_definitionnodes for the whole file.${codes:+$codes;}in
moby/check-config.shcosts it 11 ordinary top-level functions GitGalaxy and ctags both find.tests/tools/ctags_reader.py— shell KIND-MAP note: ctags' Sh parser tags bare scalarassignments (
GREP_OPTS=,FILTERED_ENV=) asf-kind functions.Follow-up
argument (
echo … limit **for** $routine) is counted as a scope opener; SerenityOS Shell bracesyntax; plus a suggested blast-radius containment (re-scan an EOF-open span at depth 0).
Housekeeping
.gitignore: backstop/language-crucible*/so a stray in-repo corpus clone can't poison thegolden masters (see
.claude/rules/golden-master-guidelines.md).🤖 Generated with Claude Code