Skip to content

fix: inert bounds how far text directives read, and counts a ::: closer only where it closes - #111

Merged
sloweyyy merged 1 commit into
mainfrom
fix/inert-bounds-what-directives-read
Oct 8, 2026
Merged

sloweyyy merged 1 commit into
mainfrom
fix/inert-bounds-what-directives-read

Conversation

@sloweyyy

@sloweyyy sloweyyy commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Fixes R7-1 (High), R7-2 (High) and R7-5 from the review of #102–#104. All of it is in the cost guard in packages/core/src/inert.ts, which publishes a page as one inert code block rather than spend seconds parsing it.

Text directives (R7-1, R7-5)

  • fix: a chain of text directives, and ::: nested inside a quote or never closed, are too costly to parse #102 counted where a text directive could start: : before a letter, 200 a paragraph. Timing micromark shows the cost is how far each one reads. A :name{ scans its attributes on to the }, or to the end of its paragraph, across lines and through #, . and {. Per reading:
    • :a{# ×10,000: 11.5 s
    • 200 :a{# + 990,000 chars: 2.4 s, passed the old limit
    • the same behind a <div> + fence, which opens nothing: 3 s
    • :name[, a bare :name, std::, CSS a:hover{…}, and a :page_id table: milliseconds, though the old count turned the table into a code block
  • Now each :name{ adds what it reads, up to its } or its paragraph's end, and the whole text is bounded at 2,000,000. It's counted in code too, because of the HTML-block fence trick.
  • The three :-count limits are gone. A table of 300 :page_id routes, 2,500 lines of C++ std::, 2,500 CSS :hover{…} rules, 3,000 INFO:root: lines, and 100 paragraphs each with an unclosed :kbd{#… are all parsed normally.
  • The worst inputs just under the budget take 100–130 ms.

Asides (R7-2)

  • A ::: closer indented four or more spaces is code, and one inside a quote can't close an aside opened outside it. Both were counted as closing, so ":::a\n :::\n" ×10,000 nested 10,000 deep (about 100 s) while the guard saw depth 1.
  • A closer now counts only when indented under four spaces and at the same quote depth as its opener. Quoted asides that are properly closed are still fine (300 of them in the normal set).

Evals: the reviewer's inputs and the variants above, in the costly and normal sets. 6 new mutants; the 2 count mutants removed and 1 aside mutant repointed (404). All inert.ts mutants are red.

Gate: typecheck clean, 776 evals passed.

Co-Authored-By: Truong Le Vinh Phuc truonglevinhphuc2006@gmail.com

…er only where it closes

From review R7 of #102.

Text directives: the limit counted where one could start (`:` before a letter), not how
far each read.
- 200 `:a{#` before 990,000 characters passed it and took 2.4 s a reading. Behind a fence
  inside an HTML block, which opens nothing, 2,000 took 3 s.
- A table of `/pages/:page_id` routes, `std::` code and log lines turned a whole page into
  a code block.
- Now each `:name{` reads on to its `}`, or to its paragraph's end, across lines. What
  they all read is bounded in the whole text (2,000,000), in code too.

Asides: a `:::` closer indented four spaces, or in another quote, closed nothing in
micromark but was counted as closing. 10,000 nested ran about 100 s. A closer now counts
only under four spaces of indent, in the same quote as its opener.

Co-Authored-By: Truong Le Vinh Phuc <truonglevinhphuc2006@gmail.com>
@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptorium Ready Ready Preview Oct 8, 2026 3:34am UTC

This branch was successfully deployed

1 active deployment
Preview — b4847b16 Deployed Oct 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant