Repository navigation
Address a revision's resources by their content, so a reload after an agent's edit fetches no runtime again - #6066
Merged
Merged
Conversation
… agent's edit fetches no runtime again A page server answered the resources a document runs (the runtime, the composed layer and registry, and the revision's captured page files) under `/revisions/<revision name>/<execution identity>/`. The revision name changes with every save, and an agent saves one at each edit, so the year-long immutable cache never carried across revisions: the user's next load fetched all 309 runtime scripts and the theme again. The name in the path dates from when each revision captured its own copy of the runtime; #3448 moved the runtime out of the capture and kept the path. The address is now `/revisions/<identity>/` (`http.assets_path`). The identity (`runtime_selection.executing`) covers every byte served beneath it: the runtime, the layer files and registry, the captured files other than media by the digests their manifest records, and the page widget aliases. Revisions that change only their document share it. A revision that changes a page module, its declarations or its layer selection gets a new one, and so does a server running another Leaf, so an address still names one set of bytes. Media answers at the page root under its own digest, so the identity leaves it out and adding an image keeps the address. A server finds the revision that executes under an identity by trying the newest first, and keeps each revision's identity it computes in the page's memory (`http._Executions`), so a tab still showing an older revision costs one walk of the revisions after it, not one per request. The website's container serves the revisions a visitor's session saves at the same address, and the responses it saves for a sleeping container follow it (`storage._responses` calls `assets_path`); published revisions keep their release paths. A reload after a new revision, headless Chromium on loopback, median of 5 reloads per run, two runs per arm alternating base and head (`leaf-dev bench` pages built from each checkout, one line appended to `index.html` between reloads): | Page | transferred | main-thread task ms | same-revision reload, ms | | --- | --- | --- | --- | | asks 64 | 8.31 MB → 0.41 MB | 483, 484 → 394, 393 | 375–386 | | events 256 | 8.23 MB → 0.33 MB | 284, 286 → 185, 198 | 184–212 | What head still moves after a revision is the document (189 KB), the stamped version's document the change view compares against (189 KB on asks 64) and the state read. The main-thread time saved is, by inference, the work of loading and compiling the same scripts again under new URLs; script time alone went 127 → 100 ms on asks 64. What to weigh: the first request for an identity this process hasn't computed walks the page's revisions, once per process: 0.14 s on a page of 60 revisions, 0.84 s on one of 300. A tab sends one after a restart when it shows an older revision whose page code changed since, or when it runs another Leaf. Later requests take 1–2 ms on both arms. A resource path also no longer says which revision loaded it; the document's address still does. Tests: `test_revisions_that_change_only_their_document_share_their_resources` fails on main at the shared-address assertion and passes here. Run by name: the process server tests on revisions, samples and previews, the website route and saved-record tests, the model delivery, live shell, distribution and layer modules, the smoke tier, the journeys that read an asset path, and the browser tests whose path parsing changed. `dev/tests/journeys/test_interact_preview.py::test_preview_publishes_companion_edits_at_its_existing_url` failed on main, since it built the path from the runtime identity; it now reads the address from the document's `data-lf-entry` and passes. Not run: the full browser and journey tiers, Firefox, and the website's delivery checks (site build, Worker dry run, `leaf-dev site verify`).
…one search, and record in a tab's session start what it runs Review fixes for the shared resource address. Media. The execution identity leaves media out, since media answers at the page root under its own digest, but the address still served each revision's captured media, from whichever revision the search found. After an agent swapped an image on leaf.page, `storage._responses` listed the old image under the shared address, the newest revision no longer held it, and every later save failed with "cannot publish saved page response revisions/…/media/….png: 404". The address now serves no media, which nothing named there: documents and the runtime name media at the page root (`DeliveryAddress`). `_responses` lists none under it. `test_a_session_that_swaps_an_image_goes_on_saving` fails before this change with that error and passes after it. Behavior change: `<assets>/media/<name>` answers 404, so the recordings journey and the range test now check the page root, and a captured page file, instead. Search. The cache was keyed by revision name and shared by every server in a process, so a live server serving a revision under a replaced package copy overwrote the identity a frozen preview had recorded for it, and the preview's own theme.css answered 404; the frozen-preview journey now serves both and fails on the old cache. The cache now indexes each identity by a revision that executes under it, so a document's requests find their revision at once. An address this process hasn't served, which a tab from before a restart or under another runtime names, is searched for newest first, each revision's identity computed once however many requests ask (`page_memory.once`). The layer's files are digested once per composition (`LayerComposition.files_digest`) rather than once per revision. On a page of 300 revisions whose first revision runs other page code (the reviewer's `walk.py`, fresh server each time), head vs main: | Request | main | before these fixes | head | | --- | --- | --- | --- | | revision 1's leaf.js, first | 75 ms | 0.84 s | 408 ms | | 16 concurrent, wall | 127 ms | 9.4 s | 408 ms | | an identity no revision has, first, then again | — | 0.83 s, 2 ms | 357 ms, 1 ms | | cold browser opening revision 1, presented | 391 ms | 1.68 s | 368 ms | Session start. A tab's `session_start` observation now records the revision its document is (`lf-revision`) and the runtime identity it runs, which resource paths named before the address became one identity, so a reload stays attributable to a new revision or a restart under another Leaf. Tests: the new saved-records test, the extended frozen-preview journey, the process server tests on revisions, samples, media and previews, the website route and saved-record tests, the model delivery, layer and distribution modules, the journeys that read an asset path, smoke, the browser tests whose path parsing changed, and `pnpm run test:runtime`.
The comment on `layerRoot` (`runtime/context.js`) said the entry names the immutable revision; since the shared resource address, it names an immutable address a page server shares among revisions that differ only in their document.
max-sixty
marked this pull request as ready for review
November 15, 2026 20:46
leaf-agent
approved these changes
Nov 15, 2026
This was referenced Nov 15, 2026
Merged
leaf-agent
added a commit
that referenced
this pull request
Nov 16, 2026
…s, matching #6066's URLs (#6080) #6066 moved a revision's resources from `/revisions/<a>/<b>/…` to `/revisions/<identity>/…`. The write watch's stack-frame cleaner ([`tests/write_watch.js`](https://github.com/max-sixty/leaf/blob/052cfd55dc1d3cb8b0c6184cb738bbb0473a2669/tests/write_watch.js#L518)) still stripped two path segments after `revisions/`, so it also cut off `runtime/` and `vendor/`. The two allowed no-op scroll writes, `stopWhereItStands` in `runtime/arrivals.js` and CodeMirror's measure in `vendor/codemirror.*`, stopped matching `EXPECTED_SCROLLS`. Every test whose page stopped a scroll under way, or measured a scrolled editor, then failed its teardown with `unmoved scroll: … from stopWhereItStands (arrivals.js:379:7)` or `… LeafEditorView.measure (codemirror.esm.js…)`. That covered 20 of the 23 teardown errors in [run 43766062952](https://github.com/max-sixty/leaf/actions/runs/43766062952). The cleaner now strips the single identity segment, so the watch judges the same writes it did before #6066. On current `main`, `test_the_reading_keys_accumulate_and_reverse` and `test_a_tall_local_comment_survives_its_panes_scroll_behavior_and_return` fail with those teardown errors. With this change they pass, along with both browsers of `test_a_landing_that_moves_nothing_stops_a_scroll_still_under_way` and `tests/browser/test_render_write_watch.py` (which checks that a genuine `unmoved-scroll` is still reported). This fixes one of the run's causes. `test_show_from_on_me_lands_in_the_card_it_opens` is a separate regression from #6056, filed as #6081. The colour failures are fixed on `main` by #6075. Refs #3985 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
A page server answered the resources a document runs (the runtime, the
composed layer and registry, and the revision's captured page files)
under
/revisions/<revision name>/<execution identity>/. The revisionname changes with every save, and an agent saves one at each edit, so
the year-long immutable cache never carried across revisions: the user's
next load fetched all 309 runtime scripts and the theme again. The name
in the path dates from when each revision captured its own copy of the
runtime; #3448 moved the runtime out of the capture and kept the path.
The address is now
/revisions/<identity>/(http.assets_path). Theidentity (
runtime_selection.executing) covers every byte servedthere: the runtime, the layer's files (digested once per composition)
and the revision's registry, the captured files other than media by the
digests their manifest records, and the page widget aliases. Revisions
that change only their document share it. A revision that changes a
page module, its declarations or its layer selection gets a new one,
and so does a server running another Leaf, so an address still names
one set of bytes. Media answers only at the page root, under its own
digest, which is where documents and the runtime already named it: the
address serves none, so adding or swapping an image keeps the address.
A server finds the revision behind an address through an index of each
identity it has computed (
http._Executions). Serving a documentrecords its revision there, so the requests the document's load makes,
for the newest revision or any older one or stamped version, find it at
once. An address this process hasn't served a document for, which a
tab from before a restart or under another Leaf names, is searched for
among the revisions, newest first, with each revision's identity
computed once however many requests ask (
page_memory.once) and kept.The website's container serves the revisions a visitor's session saves
at the same address, and the responses it saves for a sleeping container
follow it (
storage._responsescallsassets_pathand lists media onlyat the page root); published revisions keep their release paths.
A tab's
session_startobservation now records the revision itsdocument is and the runtime it runs, which resource paths named before
the address became one identity, so a reload stays attributable to a new
revision or to a restart under another Leaf. The live document is served
at
/, so its address alone doesn't say which revision it is.Evidence
A reload after a new revision, headless Chromium on loopback, median of
5 reloads per run, two runs per arm alternating base and head
(
leaf-dev benchpages built from each checkout, one line appended toindex.htmlbetween reloads):Review measured the same reload by phase: 7.60 MB → 0.22 MB loaded
before the page shows the server's state, which it shows at 367 ms
rather than 597 ms. What head still moves after a revision is the
document (189 KB), the stamped version's document the change view
compares against (189 KB on asks 64) and the state read. The main-thread
time saved is, by inference, the work of loading and compiling the same
scripts again under new URLs; script time alone went 127 → 100 ms on
asks 64.
What to weigh
The search runs only for an address this process hasn't served a
document for. On a page of 300 revisions whose first revision runs other
page code, a fresh server, main vs head: revision 1's
leaf.js75 →408 ms for the first request and 1 ms after; 16 concurrent first
requests 127 → 408 ms wall; an identity no revision has, 357 ms once,
then 1 ms. A cold browser opening revision 1's document presents at
391 ms on main and 368 ms on head. Pages on this Mac have a median of
18 revisions, p90 about 75 and at most 377.
The address no longer serves media:
<assets>/media/<name>answers404, and the tests that read a captured copy of a recording there now
read the page root and a captured page file.
Tests
test_revisions_that_change_only_their_document_share_their_resourcesfails on main at the shared-address assertion;
test_a_session_that_swaps_an_image_goes_on_savingfails before themedia fix with "cannot publish saved page response
revisions/…/media/….png: 404"; the frozen-preview journey, which now
serves the same revision from a live server beside the preview, fails
with a cache keyed by revision name. All three pass here. Run by name:
the process server tests on revisions, samples, media and previews, the
website route and saved-record tests, the model delivery, layer and
distribution modules, the journeys that read an asset path, smoke, the
browser tests whose path parsing changed, and
pnpm run test:runtime.dev/tests/journeys/test_interact_preview.py::test_preview_publishes_companion_edits_at_its_existing_urlfailed on main, since it built the path from the runtime identity; it
now reads the address from the document's
data-lf-entryand passes.Review's site build and the Worker's dry-run deploy passed. Its
leaf-dev site verifyrun timed out at the container's activation read(
GET /api/view, 120 s), before the step that saves a private revision,so it never exercised this change. Not run: the full browser and
journey tiers and Firefox.
Left as they are: a published release still writes a full tree per
revision (
live_shell), so moving between a published page's versionson leaf.page fetches the runtime again; and a local
lf-sampleloads theruntime under its own capability path, so each sample in a gallery
fetches it once. Both are separate changes.
Part of #5194