Repository navigation
Fix #621: standard_block comment stripping corrupted 5 languages (and my first attempt broke 24 others) - #625
Merged
Conversation
…ne regex
sqlite/lua/haskell/powershell/perl were classified "standard_block" but
don't use its C-style // and /* */ delimiters -- they got zero comment
stripping (empirically confirmed against the real config). Each language's
own comment even already said which family it was SUPPOSED to be in
("UPGRADED: Maps to Family 5 (Hybrid Dash)", "Family 4 (Hybrid Hash)",
"Family 6 (Polyglot)") -- the lexical_family VALUE just never matched,
same class of drift as the python/json copy-paste bug found earlier.
The first attempted fix (add all 9 of standard_block's configured
delimiter tokens to its one shared regex) was rejected after the golden
crucible caught it: `--` is a decrement operator and `#` is a preprocessor
directive in C-family languages, not a comment marker, so a shared regex
corrupted real code (`i-- > 0` and `#include <vector>` both got swallowed
into the comment stream, collapsing real signal counts to 0 for an
affected C++ file in the crucible corpus).
Fixed properly instead, by giving incompatible conventions their own
families so no regex is ever shared across them:
- multi_style_dash (sqlite, lua): -- line, plus /* */ and --[[ ]] blocks.
- embedded_syntax (powershell): # line, plus <# #> block.
- recursive_block_haskell (haskell): -- line, {- -} block -- reuses
recursive_block's iterative inside-out peel algorithm (Rust/Swift/Dart/
Scala) with Haskell's own tokens, since Haskell's blocks genuinely nest
(confirmed: nested {- {- inner -} outer -} now peels correctly).
- perl moved to the existing line_exclusive family (needed no new family
at all; its full "Polyglot" POD-block vision from the original comment
-- =head/=cut -- remains a known, separate, unfixed gap).
Also fixed a stale top-of-file comment in gitgalaxy_config.py claiming
LEXICAL_FAMILY_HEURISTICS isn't what drives comment/code separation --
confirmed via galaxyscope.py that it's exactly what's passed into Prism.
Golden master fixtures (both full-precision and zero-dependency) updated
via the sanctioned tests/tools/update_golden_master.py, reviewed before
blessing: all drift traces to the 5 corrected languages plus expected
global-ranking/z-score ripple (leaderboard reordering, one flagged-artifact
count dropping by exactly 1 from a resolved false-positive). No direct
signal-count corruption for any unrelated language in either fixture.
Full suite (916 tests), ruff audit, mypy audit, and both golden-crucible
modes all pass.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
4 tasks done
squid-protocol
added a commit
that referenced
this pull request
Jul 26, 2026
#627) Fills the remaining gaps #622 called out, on top of what #625 already covered for the standard_block split: - block_exclusive (xml) and non_lexical (plaintext) now have a dedicated real-config test, not just the existing mock-based bypass test. Also added a test documenting a latent (not live) gap: neither family has an entry in _compile_regex_matrix()'s branch list, so a FUTURE language assigned either family without also being added to split_streams()'s hardcoded "prose bypass" list would silently get zero comment stripping -- same failure shape as #386/#621, just not triggered by anything in the real config today. - ReDoS immunity tests against the REAL compiled patterns for standard_block/multi_style_dash/embedded_syntax/line_exclusive/ recursive_block_haskell (previously only the mock-config branch-selection logic and the unrelated suppression-tag regex had pathological-payload coverage). - String-literal shielding tests for haskell and powershell, extending the one #621 added for lua to the other two new families. Full suite (920 tests), ruff audit, mypy audit, and both golden-crucible modes pass. No source changes -- test-only, so the golden master fixtures are untouched. Closes #622. Co-authored-by: Joe Esquibel <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
The bug (#621)
sqlite,lua,haskell,powershell, andperlwere all classifiedlexical_family: "standard_block", but that family's shared regex only used C-style////* */delimiters. None of these 5 languages use those -- they got zero comment/code separation at all, confirmed empirically against the real config before this fix. Notably, each of these 5 languages' own source comment already named the family it was supposed to be in ("Maps to Family 5 (Hybrid Dash)", "Family 4 (Hybrid Hash)", "Family 6 (Polyglot)") -- thelexical_familyvalue just never matched, the same class of drift as thepython/jsoncopy-paste bug found while scaffolding the per-language test issues.First attempt was wrong -- caught by the golden crucible
My first fix added all 9 of
standard_block's configured delimiter tokens to its one shared regex. That's what #621 itself proposed, and it's wrong:standard_blockcovers 29 languages sharing one compiled regex, and--is a decrement operator /#is a preprocessor directive in C-family languages, not a comment marker. The shared regex started swallowing real C++ code:The golden-crucible regression test caught this immediately -- a real C++ file's import/cast/macro counts collapsed to 0. Reverted before it ever got committed.
The actual fix: split into sub-families, don't share one regex across incompatible conventions
multi_style_dash(sqlite,lua):--line comments, plus/* */and--[[ ]]block forms.embedded_syntax(powershell):#line comments, plus<# #>blocks.recursive_block_haskell(haskell):--line,{- -}block -- reuses the existing iterative inside-out peel algorithm (recursive_block, used by Rust/Swift/Dart/Scala) with Haskell's own tokens, since Haskell's blocks genuinely nest (its own comment said so explicitly). Confirmed nested{- {- inner -} outer -}now peels correctly, inside-out.perlmoved to the existingline_exclusivefamily -- needed no new family at all, since that family already leads with#. Its fuller "Polyglot" vision from the original comment (POD blocks,=head/=cut) is a known, separate, unfixed gap -- noted in the source, not solved here.Also fixed a stale comment at the top of
gitgalaxy_config.pythat claimedLEXICAL_FAMILY_HEURISTICSisn't what drives comment/code separation -- confirmed viagalaxyscope.pythat it's exactly what gets passed intoPrism.Golden master fixtures
Updated both
tests/golden_master_audit.json(full-precision) andtests/golden_master_zero_dep_audit.json(zero-dependency) via the sanctionedtests/tools/update_golden_master.py, after manually reviewing the diffs in both modes:Test plan
pytest tests/-- 916 passedpython tests/ruff_audit.py --ci-- clean (148-finding baseline, no new)python tests/mypy_audit.py --ci-- cleanruff format --checkon all modified source filespytest -m golden_cruciblepasses in both full-precision and zero-dependency venvstest_prism.py: line + block comments for all 5 languages against the real config, Haskell nesting correctness, C-family (cpp/c/javascript) unaffected including the specific decrement-operator/preprocessor case that broke in the first attempt, string-literal shielding for the new dash/hash patternsCloses #621.
🤖 Generated with Claude Code