Repository navigation
Description
Found while starting work on #587 (strict-parsing tests for html, part of epic #518).
The bug (two parts, same net effect)
Part 1: html is tagged "lexical_family": "line_exclusive", but its own inline comment
(gitgalaxy/standards/language_standards.py ~line 4763-4765) says:
Rationale: Uses SGML-style block delimiters () exclusively; no single-line anchor.
That's the literal definition of block_exclusive per how_to_add_a_language.md ("The language
possesses no native single-line comment syntax. All text must be enclosed. Examples: HTML,
XML.") -- the comment and the assigned value contradict each other. Confirmed empirically via
Prism.split_streams() against a realistic HTML sample containing a real <!-- ... --> comment:
the comment is never stripped at all -- it stays verbatim in code_stream, and
comment_stream comes back completely empty.
Part 2: block_exclusive's own delimiter config is broken anyway.
gitgalaxy/standards/gitgalaxy_config.py's LEXICAL_FAMILY_HEURISTICS:
"block_exclusive": {"delimiters": ["", "--!>"]},The opening delimiter is an empty string, and the only real token present is --!> (a rare
legacy HTML comment-close variant), not the actual <!--/--> pair. Tracing
prism.py's _compile_regex_matrix(): block_exclusive isn't specially handled anywhere in
the family-dispatch if/elif chain, so p stays "", if p: is falsy, and
REGEX_MATRIX["block_exclusive"] never gets populated at all. Downstream in
_strip_segment_comments(), pattern = self.REGEX_MATRIX.get(family) returns None, which hits
the if not pattern: early-return path -- the entire text passes through unchanged.
Net effect: retagging html to block_exclusive today, by itself, would be a no-op -- both
paths currently produce identical (non-functional) behavior. A real fix needs: (a) a genuine
block-only comment-stripping branch added to _compile_regex_matrix/_strip_segment_comments
(nothing today implements "strip <!-- ... -->, no line-comment fallback" -- the closest
analogue, standard_block, always assumes a combined line+block delimiter set), (b) fixing
block_exclusive's delimiter list to the real <!--/--> pair, and (c) retagging html (and
presumably xml, both named as this family's canonical examples in the doc) to use it.
Consequences of the current state
comment_streamis permanently empty for every HTML file scanned --doc_loc(Documentation
LOC, a cross-language risk-scoring input) is always 0 for HTML regardless of how
comment-heavy a real file is.- Any HTML structural signature capable of matching content that happens to sit inside a
<!-- -->comment is scanning live, uncommented code_stream text that happens to be dead --
e.g. an old disabled script (<!-- <script>...</script> -->) could inflate other signatures
(not justdead_code) as if it were still-active markup. html's owndead_coderegex (<!--[ \t]*<(?:div|script|style|...)) happens to still "work"
today because it was seemingly authored already assuming comments are never stripped -- it
searches for the literal<!--prefix directly in code_stream. This is a narrow, workaround-
shaped design (only catches a specific short list of tags immediately after the opener), not
evidence the pipeline is fine.
Scope
Not fixing this as part of #587 -- matches the epic's established pattern (#691 for markdown's
"never scanned" pipeline gate, #694/#697 for yaml/json/csv's gate and the ---truncation bug)
of keeping per-language strict-parsing issues narrowly scoped to the rules-dict regexes, and
filing real pipeline-level gaps as their own issue. #587 will proceed testing the 39 html
regexes against their actual observed behavior (code_stream containing the full unstripped
text, matching what dead_code's own design already assumes).
Part of the theme tracked by #386/#691/#694/#697 ("prism.py doesn't correctly honor per-language/
per-family delimiter config") -- same root cause class, different family this time
(block_exclusive never implemented at all, vs. those three being about line_exclusive's
dispatch/hardcoding specifically).
Activity
Fix #587: Strict parsing tests for html structural signatures (#734)
fix(html): Properly strip HTML block comments (Issue #733) (#758)
Fix #609: Strict parsing tests for scheme structural signatures (#771)