Skip to content

Compose every delivered document once, from each host's Delivery - #1292

Merged
max-sixty merged 6 commits into
mainfrom
agent-a0e5f2dd84d672fff
Sep 27, 2026
Merged

max-sixty merged 6 commits into
mainfrom
agent-a0e5f2dd84d672fff

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Every delivered document is now composed once, by compose_document in revision_delivery.py, and each host states what it adds as a Delivery value: the address its references go to (#1280), whether stylesheets are embedded, a policy for the document's nonce, an import map, the runtime's inline script, head metadata, the canonical page root, and marks on <html> and <body> and before </body>.

The hosts cut over:

  • The HTTP server and the published live shell build theirs with http.page_delivery. The website adds its link card, the MCP page server its readiness module, and a specimen its data-lf-contained, data-lf-user-scope and inert marks, each by overriding PageEndpoint._delivery.
  • Export passes its offline policy, leaf: import map and embedded payload.
  • The MCP snapshot and the direct MCP probe use exporting.embedding, which embeds styles and media and leaves modules as named.

This deletes runtime_document, supervised_document, head_open_end_offset, authorize_inline_scripts, inline_assets, the _document_head hook, and the two regex splices in _content overrides: the MCP ready signal's rfind("</body>") and the specimen's <html/<body substitutions. SourceDocument now reads where the source's html, head and body start tags and its last </body> stand, and a source that leaves <html> implicit gets the tag written before its head.

Behaviour that moved:

  • A served document now starts with a UTF-8 byte-order mark, as the export and the MCP snapshot did.
  • A specimen's marks and a host's attributes follow the source's own attributes on its start tag instead of being spliced in right after the tag name.
  • An exported file writes the theme before the adopted sheets rather than after, and marks its import map data-lf-runtime like the served one.

Startup, the corpus served locally, base (this branch with #1280 merged) against candidate, 11 alternating cold loads each in Chromium: requests and JavaScript requests by presentation are unchanged (250 / 229), and presented median is 3,855 / 3,776 ms. The served document grows by the 3-byte mark.

This deletes the TODO.md bullet "Compose a delivered page's head once".

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

🤖 Generated with Claude Code

max-sixty and others added 6 commits September 26, 2026 22:04
Every host now addresses what a document or resource names through one
parsed walk, `rebase_document(source, address)` in `revision_delivery.py`,
with an `address` function of its own: `DeliveryAddress(page_root,
asset_root)` for the live server, the MCP page server, the website
container and the published live shell, an embedding function for export
and the MCP snapshot, and the page root for frozen message markup and the
site's link check. The walk reads the same references capture reads
(`attribute_references` in `structure.py` now serves both), including
declarative shadow roots. Layer JavaScript is served as captured: the
document's import map sends its rooted `/runtime/`, `/vendor/` and
`/widgets/` imports to the revision, and the runtime finds its own files
beside the registry the delivery declares. The regex scopers in `http.py`,
their `addressed` guard, `deliver_document`, export's second walk
(`_bind_authored_modules`, the old `inline_assets` body) and `media.js`'s
split constants are gone.

Behaviour that moved:
- Media answers at the page root wherever a page names it. A document's
  `<img>`, `<a href>`, style and widget attributes used to point at the
  revision's captured copy while messages, drafts and widgets resolved the
  page root; now every context uses the page root, which every host serves.
- An authored module's string literals stay as written. The scoper used to
  rewrite a quoted Leaf route in them under a prefixed host; delivery now
  addresses only an authored module's imports.
- Layer modules keep their rooted imports and are no longer rewritten per
  request; stylesheets addressed for a revision are parsed once per server.

On the corpus served locally (15 alternating cold loads each), requests
and JavaScript requests by presentation are unchanged (250 / 229), bytes
fall by 3.4 KB, and HTML first byte drops from 85 to 38 ms median.

The head is still composed in three places; `TODO.md` keeps that half.
Every delivered document is now composed once, by `compose_document` in `revision_delivery.py`, and each host states what it adds as a `Delivery` value: the address its references go to (#1280), whether stylesheets are embedded, a policy for the document's nonce, an import map, the runtime's inline script, head metadata, the canonical page root, and marks on `<html>` and `<body>` and before `</body>`.

The hosts cut over:

- The HTTP server and the published live shell build theirs with `http.page_delivery`. The website adds its link card, the MCP page server its readiness module, and a specimen its `data-lf-contained`, `data-lf-user-scope` and `inert` marks, each by overriding `PageEndpoint._delivery`.
- Export passes its offline policy, `leaf:` import map and embedded payload.
- The MCP snapshot and the direct MCP probe use `exporting.embedding`, which embeds styles and media and leaves modules as named.

This deletes `runtime_document`, `supervised_document`, `head_open_end_offset`, `authorize_inline_scripts`, `inline_assets`, the `_document_head` hook, and the two regex splices in `_content` overrides: the MCP ready signal's `rfind("</body>")` and the specimen's `<html`/`<body` substitutions. `SourceDocument` now reads where the source's `html`, `head` and `body` start tags and its last `</body>` stand, and a source that leaves `<html>` implicit gets the tag written before its head.

Behaviour that moved:

- A served document now starts with a UTF-8 byte-order mark, as the export and the MCP snapshot did.
- A specimen's marks and a host's attributes follow the source's own attributes on its start tag instead of being spliced in right after the tag name.
- An exported file writes the theme before the adopted sheets rather than after, and marks its import map `data-lf-runtime` like the served one.

Startup, the corpus served locally, base (this branch with #1280 merged) against candidate, 11 alternating cold loads each in Chromium: requests and JavaScript requests by presentation are unchanged (250 / 229), and presented median is 3,855 / 3,776 ms. The served document grows by the 3-byte mark.

This deletes the `TODO.md` bullet "Compose a delivered page's head once".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	TODO.md
#	skills/leaf/scripts/leaf/exporting.py
#	skills/leaf/scripts/leaf/http.py
#	skills/leaf/scripts/leaf/live_shell.py
#	skills/leaf/scripts/leaf/revision_delivery.py
#	tests/test_live_shell_artifact.py
#	tests/test_mcp_app.py
#	tests/test_revision_delivery.py
@max-sixty
max-sixty merged commit 596ef6b into main Sep 27, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a0e5f2dd84d672fff branch September 27, 2026 07:07
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