Skip to content

Strict/exact tests for prism.py's real per-family comment stripping (replaces the per-language lexical-delimiter checklist items) #622

Closed

Description

@squid-protocol

Part of #518.

Why this replaces the lexical-delimiter checklist item

The 48 per-language issues under #518 originally each had a checklist item for _line_anchor/_inline_comment/_block_start/_block_end. Those 4 rule keys turned out to be dead config -- confirmed via grep -rn across all of gitgalaxy/, nothing ever reads them off LANGUAGE_DEFINITIONS. The real comment-stripping engine (prism.py's _strip_segment_comments) dispatches purely on the lexical_family string against a separate, family-level delimiter table in gitgalaxy_config.py's LEXICAL_FAMILY_HEURISTICS. That's the actual surface worth testing thoroughly -- this issue tracks that, and the per-language issues have been updated to drop the dead checklist item.

Current state

tests/core_engine/test_prism.py already has real-config regression coverage from #386 (test_prism_strips_comments_against_the_real_config) -- one language per family, for 4 of 6 families: standard_block (c), line_exclusive (python), recursive_block (rust), positional_anchored (cobol). Not covered at all: block_exclusive, non_lexical.

While scoping this, already found and filed as a concrete bug: #621 -- standard_block's generic stripper only uses 3 of its 9 configured delimiter tokens, so 5 real languages (sqlite, lua, haskell, powershell, perl) get zero comment stripping at all today. That's the highest-value thing to fix here; this issue is the broader sweep around it.

What's needed

For each of the 6 real lexical families (standard_block, line_exclusive, recursive_block, positional_anchored, block_exclusive, non_lexical):

  1. More than one language per family where the family has meaningfully different delimiter conventions. standard_block in particular (see [BUG/CORE-ENGINE] standard_block comment stripping only covers C-style delimiters -- sqlite, lua, haskell, powershell, perl get zero comment/code separation #621) needs a representative from each of its 3 comment-syntax sub-styles (C-style, SQL/Lua-style, Haskell-style), not just one C-style smoke test.
  2. Negative tests: a comment-shaped token inside a string literal must NOT be stripped as a comment (e.g. "this -- is not a comment" in a SQL string). test_prism_string_shield_protection covers this for at least one language already -- confirm it holds for the newly-added ones.
  3. block_exclusive and non_lexical currently have no dedicated real-config test at all -- xml (block_exclusive) and plaintext (non_lexical) both happen to have zero structural signatures, so they were skipped in the per-language issues, but comment/code separation for them is still worth confirming (or confirming it's intentionally a no-op).
  4. ReDoS immunity for the real per-family compiled patterns in _compile_regex_matrix(), not just the mock-based ones already in test_prism_suppression_regex_bomb / test_prism_regex_matrix_calibration_edge_cases.
  5. Watch for more dead/unreachable branches while in this code: _compile_regex_matrix() also has embedded_syntax and multi_style_dash branches that don't match any real lexical_family value currently in use (confirmed: only standard_block, line_exclusive, recursive_block, positional_anchored, block_exclusive, non_lexical appear in LANGUAGE_DEFINITIONS today) -- worth a comment noting they're currently unreachable via real config the same way this issue is fixing the last real gap, rather than silently deleting them (they may be for a planned future family).

Tests land in tests/core_engine/test_prism.py, alongside the existing #386 regression test.

Activity

  1. added
    testing
    core-engine
    on Jul 26, 2026
  2. added this to the v2.4.6 milestone on Aug 1, 2026
  3. added a commit that references this issue on Aug 4, 2026
    65f8b18
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

    core-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions