Skip to content

html func_start is unreachable end-to-end: the polyglot splitter consumes <script>/<style> tags before html's rules run #2549

Closed

Description

@squid-protocol

Summary

Found by the #1096 control corpus (Tier-2 batch): html's func_start rule (<script/<style tags) is unreachable in the end-to-end pipeline — every corpus html file records func_start = 0 despite 13 planted <script> tags that the raw regex matches.

Evidence (micro-repro, 2026-08-31)

Three one-tag files, scanned end-to-end:

file content struct_func_start state_flux
withjs.html <script>var x = 1;</script> 0 1
empty.html <script></script> 0 0
sty.html <style>body{...}</style> 0 0

withjs.html's state_flux = 1 is the tell: the script body was handed to the embedded-javascript rules (var counted), so the mid-file language switcher is consuming the <script ...> tag itself before html's own func_start rule ever sees it. finditer on the raw file matches 4 tags; the recorded count is 0.

Impact

html's func_start (and presumably the wiki matrix's html "41 signals" claim for it) is dead in production scans — the rule passes direct-detector unit tests but can never fire through galaxyscope. Any signal whose only html anchor is the script/style tag has the same exposure.

Fix shape

Count the tag in the html segment before (or as part of) handing the body to the embedded language — e.g. run html's func_start on the raw line stream pre-splice, or credit one func per spliced segment.

References

Activity

  1. added
    core-engine
    on Aug 31, 2026
  2. squid-protocol commented on Sep 6, 2026

    @squid-protocol
    OwnerAuthor

    The corpus-side half of this, and what it costs today

    Surfaced while sweeping the bias chart's STRUCTURE COUNTS group (#2669, engine main a59ecf6b / corpus main 2038a86). Recording it here rather than as its own issue, because the action item is downstream of this one.

    html reads functions_found 0 against a corpus median of 13 — a −100% red cell — while the rule fires nine times. func_start matches three <script openers in a.html, one in b.html, three in c.html, two in main.html, verified through the coding_analysis stream. None survives into the recorded equations.

    Two mechanisms stack, and this issue is only the first:

    1. The splitter takes the payload first — what this issue describes. <script> bodies go to the JavaScript lens, so anything inside the tag exercises JS's rules rather than html's.
    2. The corpus therefore planted the probe bodies empty. <script></script> carries the signal token and nothing else (a deliberate Rosetta to green: cause-first batch plan + multi-session coordination (child of #2560) #2669 A.2 decision, made because of (1)), so splice extracts no body, a matched opener with no body produces no function row, and function_count bakes 0. data/html/expected_signals.json says so in its own notes: "the tokens stay OUTSIDE <script> on purpose … a body inside the tag would exercise JavaScript's rules instead of html's."

    So the corpus authored around this limitation, and the −100% now reads as an extraction failure on the chart. Ledger: html-script-func-start-unreachable (this issue) and html-probe-bodies-are-empty-by-design.

    The order of operations is the point. Filling the twelve script bodies before this issue is fixed just routes the probes to the JavaScript lens — a green cell that measures JavaScript. So the corpus work is strictly blocked on this fix, and when it lands the pairing is: splitter leaves <script> payload with the html lens (or attributes the extracted function back to html) → data/html/ fills the twelve probe bodies → expected_signals.json re-blesses functions_found and the per-function descriptors → both ledger entries close. rosetta:rebless-owed.

    Worth noting for scoping: html is the only cell in the whole STRUCTURE COUNTS group where the engine genuinely finds nothing it could have found. sqlite and dockerfile over-count (#2792), markdown has no concept (#2795), cobol/css/jcl/kotlin/dockerfile are correct readings of real containers (#2796). This one is a rule that matches and a match that is thrown away.

  3. squid-protocol commented on Sep 7, 2026

    @squid-protocol
    OwnerAuthor

    PR #2847 opened.

    Root cause, precisely: both partitioners (Prism._partition_embedded_languages and StructuralExtractor._partition_segments) sliced the embedded segment from the trigger's own start, so the opening tag went to the JavaScript/CSS lens with the payload. coding_analysis only runs a language's rules over the segments left to that language, so html's func_start — anchored on the tag itself — was structurally unable to fire.

    Fix: the handshake's opening delimiter belongs to whichever language wrote it. The two markup entries in HANDSHAKE_REGISTRY now declare an open_delimiter, and the host segment ends at the tag's own >:

    before   html: "…<body>\n"            js: "<script>var x = 1;</script>"
    after    html: "…<body>\n<script>"    js: "var x = 1;</script>"
    

    The issue's own micro-repro now records func_start 1 on all three files, and withjs.html still records the JS body's signals — the payload handshake is intact. asm!( deliberately keeps its trigger: _find_balanced_end counts depth from the opening bracket.

    The "same exposure" prediction in the Impact section was right. func_start was the reported symptom, but the tag also carries src=, id=, name=, on*= and framework attributes, so io, import, api, events, ssr_boundaries, telemetry, args and dependency_injection were equally dead on those tags — 51 of the 291 golden-master diffs are them.

    And it corrects in the other direction too, which the issue didn't anticipate: an inline block's own first statement was invisible to any line-anchored embedded rule while the host's tag sat in front of it (css's globals, ^[ \t]*(?::root|html|body|\*), never saw the html{…} in wordpress wp-login.php's <style>html{background-color: transparent;}</style>), and JavaScript's state_mutation was matching ; mode= inside <script type="math/tex; mode=display"> on revealjs_decks/math.html — a false positive now gone.

    On the corpus-side comment above: its half (1) is fixed; half (2) is not, and is not this PR's business. Function extraction is unchanged — no html file's function list moved, because html's function_data is still the embedded functions the JS lens finds inside the block (which is also what the tree-sitter accuracy audit compares against). So functions_found stays 0 while the probe bodies are empty; keyword-rosetta's html-probe-bodies-are-empty-by-design is now the sole live cause of that cell, and filling the bodies is still the SPEC decision it describes. The corpus PR re-blesses func_start to 2/3/1/3 and retires html-script-func-start-unreachable.

    Filed separately from the same investigation: #2848 — Prism's copy of the registry compiles its triggers without re.M, so its partition never fires mid-file at all and embedded blocks are comment-stripped with the host's rules (55 JavaScript comment lines survive into code_stream across 12 corpus html files).

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-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions