Repository navigation
Description
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):
- More than one language per family where the family has meaningfully different delimiter conventions.
standard_blockin 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. - 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_protectioncovers this for at least one language already -- confirm it holds for the newly-added ones. block_exclusiveandnon_lexicalcurrently have no dedicated real-config test at all --xml(block_exclusive) andplaintext(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).- ReDoS immunity for the real per-family compiled patterns in
_compile_regex_matrix(), not just the mock-based ones already intest_prism_suppression_regex_bomb/test_prism_regex_matrix_calibration_edge_cases. - Watch for more dead/unreachable branches while in this code:
_compile_regex_matrix()also hasembedded_syntaxandmulti_style_dashbranches that don't match any reallexical_familyvalue currently in use (confirmed: onlystandard_block,line_exclusive,recursive_block,positional_anchored,block_exclusive,non_lexicalappear inLANGUAGE_DEFINITIONStoday) -- 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
Close squid-protocol#622: strict tests for prism's real per-family co…