Repository navigation
Compose every delivered document once, from each host's Delivery - #1292
Merged
Merged
Conversation
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.
# Conflicts: # scripts/site.py
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
leaf-agent
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every delivered document is now composed once, by
compose_documentinrevision_delivery.py, and each host states what it adds as aDeliveryvalue: 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:
http.page_delivery. The website adds its link card, the MCP page server its readiness module, and a specimen itsdata-lf-contained,data-lf-user-scopeandinertmarks, each by overridingPageEndpoint._delivery.leaf:import map and embedded payload.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_headhook, and the two regex splices in_contentoverrides: the MCP ready signal'srfind("</body>")and the specimen's<html/<bodysubstitutions.SourceDocumentnow reads where the source'shtml,headandbodystart tags and its last</body>stand, and a source that leaves<html>implicit gets the tag written before its head.Behaviour that moved:
data-lf-runtimelike 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.mdbullet "Compose a delivered page's head once".🤖 Generated with Claude Code