Skip to content

[BUG/CORE-ENGINE] standard_block comment stripping only covers C-style delimiters -- sqlite, lua, haskell, powershell, perl get zero comment/code separation #621

Closed

Description

@squid-protocol

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_stream

Verified 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_loc counts 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

Activity

  1. added
    bug
    core-engine
    on Jul 26, 2026
  2. added 2 commits that reference this issue on Jul 26, 2026
  3. added this to the v2.4.6 milestone on Aug 1, 2026
  4. added a commit that references this issue on Aug 4, 2026
    b71ff49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions