Skip to content

Accept classic and async scripts by deferring them, report scrollbar room as advice, and let a fixed box cross the column - #4554

Merged
max-sixty merged 6 commits into
mainfrom
leaf-out-of-the-way
Oct 28, 2026
Merged

max-sixty merged 6 commits into
mainfrom
leaf-out-of-the-way

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Three more refusals lifted under "Primitives, not a template" (SOUL.md), each decided by the maintainer after the plain-HTML corpus from #4546 surfaced it.

Behavior that changes

  • Classic and async scripts are accepted. page check refused a classic script that wasn't defer src (parser-blocking-script) and any async script (async-script), because either could run before the runtime's module read the page and before it listened for errors. Delivery now holds every authored script until then instead (revision_delivery._deferred): a classic script gains defer, an inline one by moving its text to a deferred data: URL that keeps its global scope (lines padded and sourceURL=index.html, so errors name their line), and async goes. Leaf's own data-lf-runtime scripts are untouched. A page gives up running mid-parse: document.write does nothing, a script sees the whole page, and an inline onload can fire before the function it calls exists; page-behavior.md says so. The runtime is unchanged.
  • A scrollbar collision is advice. The render gate still names a horizontally scrolling row with less than 15px below its last line, the width a macOS overlay scrollbar takes under the pointer, but no longer refuses the page: the bar covers the row only while the pointer is on it, the page shows the same outside Leaf, and the room is the author's call.
  • A fixed box may cross the column's edge. past-column read a position: fixed box overlapping main's edge, such as a badge pinned to the window's corner, as content spilling into the margin. A fixed box hangs off the window and can't scroll the page sideways, so it now answers for itself wherever it stands. One drawn over the prose is still named by covered-words.

The plain-page corpus drops all three obstacles, and its four pages written as modules only because of the script refusal are plain <script> again.

Design note

The first implementation of the script change read the authored page from a second, cached fetch of the delivered document and matched it to the live DOM, with an early error buffer across the prepaint and layer client. Deferring at delivery keeps the one rule the refusal stood for (every page script runs after the runtime has read the page) with about 40 lines in delivery and no runtime change, so it replaced that.

Checks

pnpm run check, pnpm run test:runtime, the delivery and document model tests, the corpus (8 expected failures, every pin matching), and the render-gate, column and journey tests each change touches. The script diff test and the early-error test pass with deferral and fail without it; the fixed-box assertion fails on the old rule. Codex reviewed both commits; its two findings (a journey still expecting the fixed-box refusal, and the author guidance understating what deferral changes) are fixed.

This was written by Claude Code on behalf of max-sixty

…oss the column's edge

The render gate refused a horizontally scrolling row with less than 15px below its last line, and a position: fixed box that straddled main's content edge. The first is now advice: the overlay bar covers the row only under the pointer, the page shows it outside Leaf, and the room is the author's call. A fixed box now answers for itself wherever it stands, since it hangs off the window and can't scroll the page sideways. The plain-page corpus drops both obstacles.
… its source

`page check` refused a classic script that wasn't `defer src`
(`parser-blocking-script`) and any `async` script (`async-script`), the
commonest scripts on the web, because each can run before the runtime's
module: the runtime took its authored baseline from the live `main` and
heard page errors only once its own modules listened. By the user's
decision both refusals and their finding text are gone, and the runtime
now reads the authored page from its source and hears errors from the
document's first script.

- Delivery marks a document whose scripts can run before the runtime
  (`lf-early-scripts`, `revision_delivery.early_scripts`). On such a page
  `version.js` reads the delivered document back with `force-cache`, the
  navigation's own response in the browser's HTTP cache, parses it as a
  comparison parses another version, and matches it to the live copy
  with the patch's own `matchNodes`. A node a script made stands for
  nothing authored, as a module's output does; a source node a script
  removed stands for no live node. The `html`/`body` attributes and head
  nodes come from the source too. Boot waits for that read beside the
  overlay import it already awaits. Pages without the mark are unchanged.
- The prepaint keeps every window error and unhandled rejection from the
  first script until `layer-client.js` takes them, and the runtime
  reports them once it knows its revision (`reportEarlyFaults`), so plain
  `page check` and the agent's log hear a parse-time throw with its
  throw site, as they hear a module's.

Measured on the plain `script` page: the source read is one fetch
answered from the HTTP cache (transferSize 0 in Chromium and Firefox),
185 KB parsed, no long frame, and presentation within noise of the same
page written as a module (257-274 ms against 254-261 ms, three runs each).

Tests: the refusal tests now pin that every script kind activates, and a
delivery test pins which scripts carry the mark. The script-words diff
test runs for a classic script as for a module, and now also checks that
a content-only revision keeps the script's words standing, which fails
with the live baseline. A new readiness test has `page check` report a
classic script's parse-time throw and rejection, which fails without the
early-fault report. The plain-page corpus drops the obstacle; its four
pages written as modules for this refusal are plain `<script>` again,
and the `script` page now pins the two theme obstacles it reveals.
Shipped instructions no longer steer page code to modules except for
imports.
# Conflicts:
#	tests/browser/test_plain_pages.py
…ng the authored page from a second fetch

Accepting classic and async scripts first moved the runtime's authored baseline to a re-fetch of the delivered document from the HTTP cache, matched against the live copy, with an early error buffer in the prepaint. That added a second baseline path, a cache dependency with a fallback on a miss, and a fault hand-off across three modules.

Delivery now holds each script until the runtime has read the page instead, which keeps the one rule the refusal stood for: every page script runs after the runtime's module and while it listens. A classic script gains defer, an inline one by moving its text to a deferred data: file (global scope and sloppy mode kept, lines padded and sourceURL naming index.html so errors name their line), and async goes. Leaf's own runtime scripts are untouched. What a page gives up is running mid-parse, so document.write is ignored; page-behavior.md says so.

The runtime, prepaint and version changes are reverted. The diff and early-fault browser tests pass with deferral and fail without it.
…ferring a script changes for an author

The column journey asserted past-column for a fixed box crossing the column's edge, which the exemption lifts; it now asserts that box isn't read as a spill (it is still named for the prose it covers). page-behavior.md says that a deferred script sees the whole page and that an inline handler can fire before the function it calls exists.
@max-sixty
max-sixty merged commit 500b22f into main Oct 28, 2026
4 checks passed
@max-sixty
max-sixty deleted the leaf-out-of-the-way branch October 28, 2026 05:15
max-sixty added a commit that referenced this pull request Oct 28, 2026
… delivery uses (#4619)

`page check` now reports everything wrong with a page in one run, and
the CSS it refuses is decided by the same reader delivery uses, so
nothing passes the check and then fails at delivery. Part of the
"Primitives, not a template" survey (`SOUL.md`), after #4490, #4546 and
#4554.

## Behavior that changes

- **Markup errors no longer hide page-file problems.** A page with a
markup error stopped there, so a missing `page/` file or broken
stylesheet surfaced only on the next run. Capture now runs beside markup
validation over one walk of the document, and each problem is reported
once, by the check that owns it (`validation/source.py`,
`revision_artifact._collect`).
- **A broken `page/registry.json` reports one problem per declaration.**
The registry stopped at its first error. It now collects the first
problem in each widget entry and each missing layer fact
(`registry/state.gathering()`), so a registry with several bad entries
takes at most a few runs instead of one per entry. `RegistryError` and
the layer refusals carry a list of findings. A boolean attribute schema
(`true`/`false`) reads as typeless instead of crashing the check.
- **One reader judges CSS syntax.** `revision_artifact._read_css`, the
reader delivery rewrites sheets with, decides `css-syntax` for pages,
messages, templates and declarative shadow roots alike; the walk check
and delivery share (`structure.delivered_elements`/`delivered_sheets`)
means a sheet the check skips is one delivery skips too.
- **A declaration the browser drops is advice on a page.** `css-dropped`
(for example `color: ;` or a stray `broken;`) no longer refuses a page:
the browser ignores the declaration, the page renders the same outside
Leaf, and the author sees the finding. A package's stylesheet still
refuses it, since packages are maintained code (`layer._stylesheet`).
`validation.md` says so.

## Checks

The model tests for authored markup, the layer and registry contracts,
media, vocabulary, document and layer inspection, module delivery and
page inspection (885 passed, after merging current `main`), and `pnpm
run check`. Codex reviewed each commit; its findings (the two CSS
parsers disagreeing, a problem reported twice, the template and
shadow-root walks diverging, a crash on boolean schemas, several missing
layer facts merged into one finding) are fixed here.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants