Sub of #21367: an engine defect before More components' markdown card (#21474).
Context
On dev 32d592f333, the stream demo of examples/component/markdown (24-character chunks of its source) ends in another document than "Render instantly" from a cleared state:
## Why transcripts need this renders as a heading "Why tran" and a paragraph "scripts need this".
- The table has no head: its
<table> holds the old paragraph's text node | Surface | Layer | |---| beside the body rows (DOM read in the browser, 19 Nov: children of TABLE#…__md-7 are the comment …__md-7-c0, TBODY#…__md-7-c6 and that text).
Streaming LLM transcripts is what the component is for, so the example's demo shows the defect to everyone who presses its first button.
The Problem
Three faults in src/component/markdown/Parser.mjs, each reproduced in a unit spec:
#segment gives headings and breaks open: false even when their line is the unfinished last line, so a chunk boundary inside a heading settles it.
- The empty string after a final
\n counts as a blank line, so a paragraph, list, quote or table that ends in a newline settles before its next line arrives. A table header row then never meets its delimiter row.
#appendParse reuses the tail's id when the tail changes block type (paragraph → table), and child ids are numbered in creation order (-c0, -c1), so a re-parse hands one node's id to a node of another kind. The differ matches by id and keeps the old text node where the thead belongs. The same shift happens inside one growing block when an unclosed ** turns into strong or a padded table cell fills.
The Architectural Reality
Design authority: the parser's header, "Block sequence numbers never recycle — not within a value lifetime and not across resets — so a reset cannot birth two-nodes-one-id across batches", and its streaming model, in which only the open tail block re-parses.
Parser.mjs: #segment, #appendParse, #createBlock (the child id dispenser), #parseInline.
blockMeta.open feeds the component's virtualization: an open block's units can still change.
test/playwright/unit/component/markdown/Parser.spec.mjs pins "a streamed table promotes from the open tail paragraph when its delimiter arrives" with the paragraph's id on the table.
The Fix
- A heading or break stays open while its line is unfinished. A block that reaches the empty string after a final newline stays open, and its source keeps that newline, so the next append continues the exact suffix.
- A tail that turns into another block type becomes a new block under a fresh id.
- A child id carries its node's kind (
-t3, -li0, -strong2), so no id can name two kinds of node.
Acceptance Criteria
Out of Scope
- The markdown card in More components (#21474).
- The VDOM differ.
Avoided Traps
- Teaching the differ to replace a node whose id changes kind: the producer that gives one id to two kinds is at fault, and a differ that matches by id is right to trust ids.
Related
#21367 · #21474 · #13018 (the component) · #13045 (windowing)
Live latest-open + closed sweep: newest open read at 11:55Z (#21476 back to #21472) + open and closed searches ("markdown streaming heading OR markdown stream table"; "markdown parser stream OR MarkdownParser OR markdown table promote"; #13018 has no Out of Scope) on 19 Nov; no equivalent. Backlog band: 79 open before this filing (red); folded under #21367, whose rule files each engine defect as its leaf before the renewal. A2A claim sweep: latest messages to 11:41Z, all read-states; no claim on the markdown parser. MC sweep: "markdown streaming parser tail block settles … id reuse vdom differ", 5 results, the component's build sessions, no prior decision on these faults. Own-assignment sweep: #21474 holds the card, not the parser.
Retrieval Hint: "streamed markdown ends unlike its one-shot parse: heading cut mid-line, table header settles before its delimiter, one id across two node kinds"
Sub of #21367: an engine defect before More components' markdown card (#21474).
Context
On
dev32d592f333, the stream demo ofexamples/component/markdown(24-character chunks of its source) ends in another document than "Render instantly" from a cleared state:## Why transcripts need thisrenders as a heading "Why tran" and a paragraph "scripts need this".<table>holds the old paragraph's text node| Surface | Layer | |---|beside the body rows (DOM read in the browser, 19 Nov: children ofTABLE#…__md-7are the comment…__md-7-c0,TBODY#…__md-7-c6and that text).Streaming LLM transcripts is what the component is for, so the example's demo shows the defect to everyone who presses its first button.
The Problem
Three faults in
src/component/markdown/Parser.mjs, each reproduced in a unit spec:#segmentgives headings and breaksopen: falseeven when their line is the unfinished last line, so a chunk boundary inside a heading settles it.\ncounts as a blank line, so a paragraph, list, quote or table that ends in a newline settles before its next line arrives. A table header row then never meets its delimiter row.#appendParsereuses the tail's id when the tail changes block type (paragraph → table), and child ids are numbered in creation order (-c0,-c1), so a re-parse hands one node's id to a node of another kind. The differ matches by id and keeps the old text node where thetheadbelongs. The same shift happens inside one growing block when an unclosed**turns intostrongor a padded table cell fills.The Architectural Reality
Design authority: the parser's header, "Block sequence numbers never recycle — not within a value lifetime and not across resets — so a reset cannot birth two-nodes-one-id across batches", and its streaming model, in which only the open tail block re-parses.
Parser.mjs:#segment,#appendParse,#createBlock(the child id dispenser),#parseInline.blockMeta.openfeeds the component's virtualization: an open block'sunitscan still change.test/playwright/unit/component/markdown/Parser.spec.mjspins "a streamed table promotes from the open tail paragraph when its delimiter arrives" with the paragraph's id on the table.The Fix
-t3,-li0,-strong2), so no id can name two kinds of node.Acceptance Criteria
MarkdownStreamingCoherenceNL.spec.mjspass.Out of Scope
Avoided Traps
Related
#21367 · #21474 · #13018 (the component) · #13045 (windowing)
Live latest-open + closed sweep: newest open read at 11:55Z (#21476 back to #21472) + open and closed searches ("markdown streaming heading OR markdown stream table"; "markdown parser stream OR MarkdownParser OR markdown table promote"; #13018 has no Out of Scope) on 19 Nov; no equivalent. Backlog band: 79 open before this filing (red); folded under #21367, whose rule files each engine defect as its leaf before the renewal. A2A claim sweep: latest messages to 11:41Z, all read-states; no claim on the markdown parser. MC sweep: "markdown streaming parser tail block settles … id reuse vdom differ", 5 results, the component's build sessions, no prior decision on these faults. Own-assignment sweep: #21474 holds the card, not the parser.
Retrieval Hint: "streamed markdown ends unlike its one-shot parse: heading cut mid-line, table header settles before its delimiter, one id across two node kinds"