Skip to content

web: a document without <html>/<body> extracts with no browser (board #142); load-independent harness tests - #380

Merged
SSFSKIM merged 1 commit into
mainfrom
web-bare-html
Oct 25, 2026
Merged

SSFSKIM merged 1 commit into
mainfrom
web-bare-html

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 25, 2026

Copy link
Copy Markdown
Owner

This PR covers board #142, a fix for the eval harness test flake, and a tech-debt entry. It ships at web 0.2.2, rebased onto main after #375 (render driver) and #377 (fetch hardening). The design's Decision Log (docs/doperpowers/specs/2026-10-25-web-fetch-design.md) has the decision and its evidence.

What behaves differently

A document without <html>/<body> extracts with no browser (board #142). linkedom builds only the structure a document's tags spell out, and HTML lets a page leave those tags out.

  • Before: linkedom made the page's first element the root and set the rest of the page beside it, or left the content beside an empty body. For rfc-editor's RFCs, a run of bare <pre> blocks, Defuddle then found 0 words. Only the Chromium render recovered them, so a host without Chromium saved an empty page.
  • Now: such a document is rebuilt with the tags a browser supplies. Its parsed nodes move into a fresh document with importNode: the leading head elements into <head> and the rest into <body>. The <html> and <body> attributes (lang) are kept. Nothing is written out and parsed again.
  • Unchanged: a document whose content is all in its <body> is parsed once, as before, even with scripts or styles outside it.
  • WEB_CHROME=none node web/bin/clip.mjs fetch https://www.rfc-editor.org/rfc/rfc8439.html now saves 14,648 words, not rendered, with no note. main's bundle saves 0 words with the note "rendering unavailable on this machine".

The eval harness timing tests no longer depend on machine load. test_a_process_deaf_to_the_interrupt_is_killed and its sibling test_the_limit_interrupts_so_the_result_line_is_written sent SIGINT at a 1 s limit counted from Popen. On a loaded machine that signal could reach the fake claude before it had set up its SIGINT handling. The fix is in the test only, with the harness unchanged:

  • A ReadyPopen returns once the fake child writes to a ready pipe, so the limit runs from there.
  • The child writes to that pipe after its handler is in place.
  • The upper-bound checks are now measured from readiness.

The sibling had the same race, so I fixed both. The Chromium render tests' 30 s limit is unchanged, since it is the product's limit.

Decisions and alternatives

  • Rebuild the DOM rather than wrap the source string. Wrapping the string in <html><body> would put <title> and <meta> in the body. It would also nest a second <html> for a page that has <html> but no <body>. Walking the top-level nodes is what a browser's parser does with omitted tags.
  • Move the nodes rather than serialize them. The first cut serialized the nodes and parsed the result. The review found that lossy, because linkedom writes a title's decoded text and attribute values unescaped. <title>How &lt;/title&gt;&lt;script&gt;</title> opened a script that swallowed the article (93 words became 0), and &amp;copy; in an attribute became ©. The nodes now move instead.
  • What triggers a rebuild: a root that is not <html>, or content outside <head>/<body> other than scripts, styles, comments and whitespace. On the first cut, a page with a script after </html> (blog.cloudflare.com, eval synthesis-5) took the rebuild path with identical output; it now parses once, as before.

Verified

  • Tests:
    • bash web/tests/run.sh on the rebased commit 8add3cb: exit 0. That is 137 clipper tests with 0 skipped (Chromium present), the bundle matching its source, 53 mod tests, and 55 eval tests.
    • The RunClaude tests passed in 10 of 10 repeated runs on this loaded Mac.
  • CI: ci-gate on 8add3cb is GREEN: https://github.com/SSFSKIM/doperpowers/actions/runs/40234402909
  • Review: doperpowers:reviewer-medium, two rounds. Round 1 found the lossy serialization above, now fixed. Round 2 found no material findings. It checked linkedom's import fidelity, including scripts, templates, declarative shadow roots, SVG, MathML and noscript, and Defuddle's use of the moved nodes.
  • New tests:
    • Fails on the old clipper: the clip test serving fixtures/bare-pre.html (the opening of RFC 8439 as served) under WEB_CHROME=none.
    • Regression guard for the rebuild path: the extraction test. It checks that four tagless variants of one page (no <body>; no <head>/<body>; no tags at all; no <html>) give the same body, title, description and language as the full page. The page carries the review's escaped title and &amp; attribute. All four variants take the rebuild path. The test fails on the serializing first cut.
  • Load simulation: I ran the RunClaude tests with fake children that sleep 3 s before setting up their signal handling. main's tests fail both times; the new ones pass.
  • Saved-document comparison: I extracted 50 saved documents before and after: the eval tasks' and reserves' pages, plus npm, PyPI, crates.io and bundlephobia package pages. Only RFC 8439 (code-3) changed, from 0 to 14,648 words, the same count the Chromium render gave. main's later commits do not touch extract.ts.
  • Live: RFC 8439 under WEB_CHROME=none, as above, with the rebased bundle.

Also

Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)

…the harness tests wait for their fake claude

Board #142. linkedom builds only the structure a document's tags spell
out, and HTML lets a page leave out <html> or <body>. When it does,
linkedom makes the page's first element the root and sets the rest of
the page beside it, or leaves the content beside an empty body. For
rfc-editor's RFCs, a run of bare <pre> blocks, Defuddle then found 0
words. Only the Chromium render recovered them, so a host without
Chromium saved an empty page.

Such a document is now rebuilt with the tags a browser supplies. Its
parsed nodes move into a fresh document with importNode: the leading
head elements into <head>, the rest into <body>. The <html> and <body>
attributes are copied. Nothing is written out and parsed again. A
document whose content is all in its <body> is parsed once, as before.

The branch's first cut serialized the nodes and parsed the result. The
review found that lossy, because linkedom writes a title's decoded text
and attribute values unescaped. An escaped "</title><script>" in a title
opened a script that swallowed the page.

Across 50 saved documents only RFC 8439 changes, from 0 words to
14,648, the render's count. Live under WEB_CHROME=none it saves with no
render.

The eval harness tests: test_a_process_deaf_to_the_interrupt_is_killed
and its sibling sent SIGINT at a 1 s limit counted from Popen. On a
loaded machine the signal could reach the fake claude before it had set
up its SIGINT handling, and the test failed. Popen now returns once the
fake claude writes to a ready pipe, so the limit runs from there. With
a 3 s start simulated, the old tests fail every time and the new ones
pass.

Sminos-Session: web-fetch-plugin#700c5e84 (doperpowers on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T21:16:19.768012Z 8add3cb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SSFSKIM
SSFSKIM merged commit 62c8683 into main Oct 25, 2026
6 checks passed
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