Repository navigation
fix(perl): give perl its own brace-safe-stream shielding instead of falling through to C-family rules - #1458
Merged
Merged
Conversation
squid-protocol
enabled auto-merge (squash)
August 13, 2026 16:16
…alling through to C-family rules (#1437) perl was falling through to the generic C-family combined_pattern in _build_brace_safe_stream, which shields `//` as a line comment and `/* */` as a block comment -- neither exists in perl (`//` is the defined-or operator). Worse, the generic double/single-quote patterns were unbounded, so a stray escaped quote inside an unrelated s/.../.../ substitution regex (not a real string delimiter) could pair with the next unrelated escaped quote anywhere later in the file as a bogus "string", silently swallowing a `{` in between -- confirmed exact repro: CGI.pm's `s/^\"//g;` paired with `s/\"$//g;` ~15 lines apart, desyncing _slice_by_braces for every function after that point. Two Gemini/agy dispatch attempts on this issue both failed, each fixing only the narrower qr{}-shielding symptom the issue's own framing focused on while missing this broader generic-shield mismatch -- both produced a brace-imbalanced shield output and were correctly never committed. Root-caused directly after the second failure rather than dispatching a third attempt. Fix: perl gets its own combined_pattern branch (proper #-comment handling, no //, no /* */, both quote patterns bounded to {0,200} chars -- same idiom as the existing rust single-quote / scala backtick bounds) plus a separate pass for perl's brace-delimited quote-like operators (qr{}/m{}/s{}{}/tr{}{}/y{}{}/q{}/qq{}/qw{}/qx{}), reusing the existing _find_balanced_end helper instead of a new hand-rolled depth counter. found_functions 710->937 of 1005 real (recall 70.6%->93.2%), extra_functions unchanged at 1 (zero new false positives). Co-Authored-By: Claude Sonnet 5 <[email protected]>
squid-protocol
force-pushed
the
fix/perl-1437-qr-brace-shield
branch
from
August 13, 2026 17:23
fd10692 to
cfb8d08
Compare
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.
Summary
Fixes #1437.
func_startrecall for perl was 70.6% (710/1005). Root cause: perl was fallingthrough to
_build_brace_safe_stream's generic C-family shielding, which shields//as a linecomment and
/* */as a block comment -- neither exists in perl (//is the defined-oroperator). Worse, the generic double/single-quote patterns are unbounded, so a stray escaped quote
inside an unrelated
s/.../.../substitution regex (not a real string delimiter) could pair withthe next unrelated escaped quote anywhere later in the file as a bogus "string", silently
swallowing a
{in between and desyncing brace-depth counting for every function after thatpoint. Confirmed exact repro:
language-crucible/data/perl/bugzilla/CGI.pm'ss/^\"//g;pairedwith
s/\"$//g;~15 lines apart.Two failed attempts first
Two Gemini/agy dispatches on this issue both failed -- each fixed only the narrower
qr{...}-shielding symptom the issue's own original framing focused on, missing this broadergeneric-shield mismatch. Both produced a measurably brace-imbalanced shield output (confirmed via
direct open/close brace counting) and were correctly never committed, caught by the dispatching
subagent's own independent verification each time. Root-caused directly after the second failure
rather than dispatching a third attempt -- the lesson being that a diagnosis wrong at the root
doesn't get fixed by retrying the same narrow framing with tighter guardrails.
Fix
Perl gets its own
combined_patternbranch in_build_brace_safe_stream(proper#-commenthandling, no
//, no/* */, both quote patterns bounded to{0,200}chars -- same idiom as theexisting rust single-quote / scala backtick bounds already in this function) plus a separate pass
for perl's brace-delimited quote-like operators (
qr{}/m{}/s{}{}/tr{}{}/y{}{}/q{}/qq{}/qw{}/qx{}), reusing the existing_find_balanced_endhelper instead of a newhand-rolled depth counter (which is exactly what went wrong in both failed attempts).
Results
Zero new false positives -- the biggest recall win in this round of fixes.
Test plan
tests/extraction/languages/test_perl.py/test_perl_strict.py-- 102 passed (newpipeline-level regression test covers both the
s/.../.../cross-pairing repro and theqr{}internal-brace case)tree_sitter_accuracy_audit.py --lang perl --regenerate+--summary-tabletree_sitter_accuracy_audit.py --all --ci-- all 31 languages cleancrucible_check.py --mode both-- both golden masters blessed (large expected diff from+227 found functions), re-verified clean after
audit_check.py --ci --regenerate-- ruff/mypy/dead-key/ast-accuracy all clean (caught andfixed a real mypy
union-attrfinding on the new code, plus a ruff format pass)🤖 Generated with Claude Code + Gemini (Antigravity CLI)