Repository navigation
fix(engine): the markup handshake's open tag belongs to the host (#2549) - #2847
Merged
Merged
Conversation
The polyglot splitter handed the whole `<script ...> ... </script>` element to the JavaScript lens, opening tag included, and the same for `<style>`/CSS. Since `coding_analysis` only runs a language's rules over the segments left to that language, html's `func_start` -- whose only anchor IS that tag -- matched the raw file but could never fire once the splitter had run: all 38 corpus html files recorded `func_start = 0` while the rule passed its direct-detector unit tests. The handshake's opening delimiter belongs to whichever language wrote it. The two markup entries now declare an `open_delimiter` (MARKUP_OPEN_TAG_TAIL) and both partitioners end the host segment at the tag's own `>`, so only the payload goes to the embedded lens. Quoted attribute values are skipped (`<script data-tpl="a>b">` is not cut short) and an unresolvable tag falls back to the pre-#2549 boundary. `asm!(` declares no open delimiter on purpose: `_find_balanced_end` counts depth from the opening bracket. `func_start` was the reported symptom; the tag also carries `src=`, `id=`, `name=`, `on*=` and framework attributes, so io/import/api/events/ssr_boundaries/telemetry/ args/dependency_injection gained them too. The correction runs both ways: css's line-anchored `globals` finally sees the `html{...}` opening an inline `<style>` block, and JavaScript's `state_mutation` stops matching `; mode=` inside `<script type="math/tex; mode=display">`. Function extraction is unchanged -- no html file's function list moves. Both golden masters re-blessed: 291 differences, every one attributed above or a mass/topology ripple of it (`spec_match` 0% -> 100% on 29 html files is #2655's "nothing to specify" guard correctly no longer firing). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
squid-protocol
force-pushed
the
fix/2549-html-script-func-start
branch
from
September 7, 2026 14:43
ac19bf5 to
a29e5fd
Compare
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2549.
The bug
The polyglot splitter handed the whole
<script …> … </script>element to the JavaScriptlens — opening tag included — and the same for
<style>/CSS. Both partitioners did it(
Prism._partition_embedded_languagesfor the streams,StructuralExtractor._partition_segmentsfor the counts), and
coding_analysisonly ever runs a language's rules over the segments left tothat language. So html's
func_start, whose only anchor is that tag, matched the raw file andcould never fire once the splitter had run: all 38 corpus html files recorded
func_start = 0, andthe rule passed its direct-detector unit tests while being dead in every real scan.
The fix
The handshake's opening delimiter belongs to whichever language wrote it.
<script defer>is html;only what follows the
>is JavaScript. The two markup entries inHANDSHAKE_REGISTRYnow declarean
open_delimiter(_lens_config.MARKUP_OPEN_TAG_TAIL), and both partitioners end the hostsegment at the tag's own
>instead of at the trigger:MARKUP_OPEN_TAG_TAILskips quoted attribute values, so<script data-tpl="a>b">is not cutshort. Its three alternatives are disjoint on the first character, so the star cannot
re-partition a prefix — linear, no backtracking ambiguity.
to the pre-html func_start is unreachable end-to-end: the polyglot splitter consumes <script>/<style> tags before html's rules run #2549 boundary, so no input can land the split mid-attribute.
asm!() deliberately declares no open delimiter:_find_balanced_endcounts depth from the opening bracket, so that bracket has to stay insidethe embedded segment.
</script>stays with the embedded segment; nothing in html's rule set matches it,and moving it would churn the fixtures for no measured gain.
What moved, and why
crucible_check.py/scope_check.py --expect html,php,…vsorigin/main: 291 differences,html 251, php 5, 35 repo-wide rollups. Attribution, all of it one cause:
func_start(Function/Method Declarations)io,import,api,events,ssr_boundaries,telemetry,args,dependency_injectionsrc=,id=,name=,on*=, framework attributes — every html rule anchored on the tag was equally dead, which the issue predicted ("any signal whose only html anchor is the script/style tag has the same exposure")globals+1 (php/wordpress/wp-login.php)^[ \t]*(?::root|html|body|\*)never saw thehtml{…}in<style>html{background-color: transparent;}</style>state_mutation−1 (revealjs_decks/math.html); mode=inside<script type="math/tex; mode=display">spec_match0% → 100%_calc_spec_alignmentreturns 0 whenfunc_start + class_start == 0(#2655's "nothing to specify" guard), so these files were scoring the empty-file value. They have entities now and no[SPEC-n]tags, which is 100% exposure — the same reading every other language gets<script>line inside a php function's body now belongs to the php segmentFunction extraction is unchanged. No html file's
5. Function Analysismoved: html'sfunction_datais still the embedded functions the JS lens finds inside the block, which is whattree_sitter_accuracy_audit.pycompares against.functions_foundfor html therefore stays 0 onthe control corpus — the probe bodies are empty by design, which is keyword-rosetta's own separate
decision (
html-probe-bodies-are-empty-by-design), not this fix's business.Verification
tests/core_engine/test_handshake_issue_2549.py— 9 new cases: the boundary in bothpartitioners,
<style>, the quoted->attribute, the unterminated-tag fallback,asm!(unchanged, the issue's own micro-repro end to end, the script body still reaching the JS lens,
and Non-executable
<script type=...>blocks: audit walk over-counted (fixed), htmlfunc_startover-anchors (open) #2492's non-executabletypestill raising nothing (its negative lookahead now runs where italways meant to).
pytest tests/— 8022 passed, 0 failed.ruff_audit.py --ci,mypy_audit.py --ci,audit_check.py --regenerate— clean.crucible_check.py --update --yesafter the uncapped diffabove was scoped.
tri_comparison_chart.py --all --ciandtree_sitter_accuracy_audit.py --ci --all— see below.Cross-repo
keyword-rosetta owes the paired re-bless (
rosetta:rebless-owed): html's manifest bakesfunc_start0 on four files and the ledger carrieshtml-script-func-start-unreachable. Thecorpus PR flips that entry to
still_reproduces: false, re-blessesfunc_startto 2/3/1/3 (thenine
<script>tags), and records the live cause of nine-against-the-SPEC's-thirteen ashtml-func-start-counts-script-elements. It opens after this merges, per the no-pins flow.Found on the way out, filed separately, deliberately not fixed here:
Prism's copy of thehandshake registry compiles its triggers with
re.Ionly, where the detector addsre.M— soPrism's partition never fires on a mid-file
<script>, and an embedded block is comment-strippedwith the host's rules. A
// eval("nope");line inside a mid-file<script>recordshigh_risk_execution: 1; the identical block at offset 0 records nothing.