/** * Checkpoint streaming Markdown — pure logic for rendering a GROWING message * without re-running the full pipeline (marked → hljs → copy buttons → * DOMPurify) over the whole text on every delta. * * Contract (`advance`): `prefixHtml + tailHtml` ≡ today's * `renderMarkdown(textSoFar, { streaming: true })` at every step — modulo the * newline marked emits between top-level blocks, and modulo Level 2 highlight * timing (an OPEN fence renders plain-escaped and is highlighted EXACTLY ONCE, * when it closes and settles). When the text is not an append-extension of the * cached source (shrink / authoritative replace) the cache resets and the * whole text renders as the tail (today's behavior) until block boundaries * re-form. * * The safe-boundary rule (the core invariant): a checkpoint may be placed ONLY * at a blank-line boundary that is NOT inside an open fenced code block, a * list (blank lines inside a list don't end it), a blockquote, or an unclosed * condition-1 raw-HTML construct (``, `