Repository navigation
Description
Summary
Found while investigating perl's func_start accuracy gap (937/1063 real = 88.1% recall): perl POD documentation blocks are never stripped from the code stream (pre-existing, noted directly in gitgalaxy/standards/language_standards.py's perl entry comment: lexical_family: "line_exclusive" has no POD marker support). POD prose routinely contains English contractions with apostrophes ("doesn't", "don't", "it's", "can't") which detector.py's perl-specific brace-safety shield (added by #1437, the _build_brace_safe_stream method's elif lang_id == "perl": branch) reads as an OPENING single-quote string delimiter. It then searches up to 200 chars forward for the next literal ' to close it -- which is often the opening quote of a real string statement further down (e.g. $self->{'parse_queue'}), and blanks every character in between. Any real sub name { ... } declaration falling inside that phantom-string span gets completely erased before the func_start regex ever sees it.
Confirmed repro
Load language-crucible/data/perl/spamassassin/Message.pm, call Prism.split_streams to get code_stream, then StructuralExtractor('perl', LANGUAGE_DEFINITIONS)._build_brace_safe_stream(code_stream, 'perl'). Print lines 845-855 in the shielded output:
spamassassin/Message.pm::parse_body (real sub at line 850, correct small body):
- Line 846's POD prose:
doesn't have a root node ... - The apostrophe opens a phantom string
- String doesn't close until a real quote several lines later
- Line 850's
sub parse_body {is blanked down to spaces - COMPLETELY MISSING from GitGalaxy's function_data output for that file
spamassassin/SpamAssassin.pm::init_learner (real sub at line 779):
- Same failure, same mechanism
- POD prose "don't" at line 773 opens the phantom string
- Blanks through line 779's
sub init_learner {
Both are confirmed via direct _build_brace_safe_stream output inspection: the shielded region shows apostrophe-opened span turned to blank spaces, sub declarations included.
This is very likely the dominant cause of perl's func_recall gap (937/1063 = 88.1%) -- exact fraction isn't confirmed, just the mechanism and these two reproducible cases.
Root cause
File: gitgalaxy/core/detector.py, method _build_brace_safe_stream, the perl-specific branch.
The bounded single-quote shield (r'"(?:\\.|[^"\\]){0,200}"|' r"'(?:\\.|[^'\\]){0,200}'" r"|#[^\n]*") exists to shield real perl string literals before the brace-balance scan runs (so a literal {/} inside a string doesn't desync the scanner). But a bare apostrophe in POD prose (never stripped) opens a phantom string match with no guarantee the closing apostrophe exists within the 200-char lookahead window -- it just searches forward until it finds one, often swallowing real code in between.
Architecture & related work
This is the SAME shielding-corruption bug CLASS as #1517 (an ambiguous delimiter swallowing real code), but a DIFFERENT specific mechanism:
- perl func_start block-slicing: _line (mojo/Template.pm) swallows 432 extra lines through the CLI pipeline but not via direct _function_slice #1517:
qq{...@{[expr]}...}interpolation collision in prism.py'ssplit_streams - This: POD-apostrophe in detector.py's
_build_brace_safe_stream
Two possible fix directions (leave the choice to whoever picks it up):
-
Root architectural fix (bigger change): strip POD blocks as their own documentation-stream family in prism.py, the same way comments are already stripped. Fixes the root gap for other symptoms too, but gated behind lexical_family design work.
-
Narrow targeted fix (lower-risk): tighten just this one shield regex so a bare apostrophe only opens a string when it looks like a real string open (preceded by whitespace/operator/paren, followed by non-space). This method already uses this same disambiguation shape elsewhere for rust lifetimes vs strings.
Labels & scope
This affects func_start block-boundary accuracy for perl; unknown how many total functions in the corpus are lost to this mechanism (only visible because these two cases have tiny real bodies, making the wrong spans glaring). Not a regression from #1437 (confirmed present before that issue too by checking if message.pm appears in golden_master before #1437 landed) -- pre-existing gap, just more impactful than originally estimated.
References: #1517, #1519 (related but separate root causes and code paths).
Activity
fix(zig): apostrophes in `\\`-continuation help strings blank real fu…
docs: full tri-comparison ledger sweep -- 49 shapes resolved, 0 unval…
fix(typescript): recognize negation-body arrows, optional method sign…
fix(perl): strip POD documentation blocks before structural scanning (#…