Repository navigation
Description
What's broken
prism.py's _compile_regex_matrix() builds one shared regex per lexical family. For standard_block (29 languages), it only uses the first 3 of the family's 9 configured delimiter tokens:
# gitgalaxy/core/prism.py, _compile_regex_matrix()
if fam_key == "standard_block" and len(d) >= 3:
p = rf"({d[0]}[^\n]*|{d[1]}.*?{d[2]})"gitgalaxy_config.py's standard_block delimiter list is actually:
"standard_block": {"delimiters": ["//", "/*", "*/", "--", "--[[", "]]", "{-", "-}", "#"]},i.e. C-style (//, /* */), SQL/Lua-style (--, --[[ ]]), Haskell-style ({- -}), and a trailing #. Only d[0:3] (the C-style triplet) is ever used. This is already flagged in the code as a known, tracked-but-unfixed limitation (see the comment directly above the line above), left over from #386's fix, which corrected the family-name mismatch but didn't extend this specific branch to the full 9-token list.
Confirmed impact (reproduced against the real config, not a mock)
5 real languages are classified standard_block but don't use C-style delimiters at all: sqlite, lua, haskell, powershell, perl. For all 5, comments are never stripped -- they leak straight into code_stream:
p.split_streams("SELECT 1;\n-- this is a secret comment\nSELECT 2;\n", "sqlite")
# -> "secret comment" ends up in code_stream, NOT comment_streamVerified the same result for lua (--), haskell (--), powershell (#), and perl (#) with equivalent snippets.
Same class of impact #386 already described for the pre-fix state, just narrower: for these 5 languages specifically,
- Every regex-based structural/security signal (
high_risk_execution,hardcoded_secrets-adjacent detection,planned_debt, etc.) can be triggered by comment text, not just real code. coding_loccounts include comment-only lines.- Nothing separates documentation from code for these languages at all.
Proposed fix
Extend the standard_block branch to alternate across all 3 delimiter conventions instead of just the C-style one:
p = rf"({d[0]}[^\n]*|{d[1]}.*?{d[2]}|{d[3]}[^\n]*|{d[4]}.*?{d[5]}|{d[6]}.*?{d[7]}|{d[8]}[^\n]*)"Since this is one shared regex applied regardless of which specific standard_block language is being scanned, this should be safe for the other 24 C-style languages in the family (a SQL/Lua/Haskell-style comment token is vanishingly unlikely to appear as an unrelated token in C/Java/Go/etc. source), but that assumption should be verified with real fixtures per language, not assumed.
Why this needs deliberate handling, not a silent patch
Per #386's own acceptance criteria and #330's philosophy (referenced there): this will change coding_loc and every regex-signal count for real files in these 5 languages, which likely shifts golden_master.json. That update needs to be deliberate and reviewable, not a silent regen.
Acceptance criteria
-
standard_block's generic stripper correctly strips comments for a real snippet in each ofsqlite,lua,haskell,powershell,perl(test against realLANGUAGE_DEFINITIONS/LEXICAL_FAMILY_HEURISTICS, not a mock -- same discipline [BUG/CORE-ENGINE] Comment/code separation is completely broken for all 58 languages -- prism.py's family dispatch never matches the real taxonomy #386 established) - Confirm the fix doesn't introduce false-positive comment stripping in the 24 C-style
standard_blocklanguages (e.g. a--inside a string literal or an operator sequence) -
golden_master.jsondeliberately, reviewably updated to reflect corrected LOC/signal counts for repos containing these 5 languages
Activity
Close #622: strict tests for prism's real per-family comment stripping (
Fix #770: scheme's #| |# block comments are now actually stripped as …
Fix squid-protocol#621: split standard_block into sub-families instea…
feat(standards): implement Ada & SPARK structural signatures (#76) (#…
Add IBM DB2 SQL / SQL PL (db2_sql), resolving the .sql collision with…
Add IBM DB2 SQL / SQL PL (db2_sql), resolving the .sql collision with…