Repository navigation
Serve saved website state while page containers sleep - #2652
Merged
Merged
Conversation
Keep LEAF as the agent launcher locator so Pi sessions cannot redirect explicitly invoked checkout launchers. LEAF_HOST_LAUNCHER selects the host environment for commands and native hooks, before the local hook gate, while SessionEnd retains its standalone cleanup. Clear inherited host overrides in isolated task arms and tests. Exercise host argument/stdin/exit forwarding, self-selection through a symlink, relative-path refusal, and explicit checkout/cache identity under an unrelated LEAF locator.
leaf-agent
approved these changes
Oct 12, 2026
leaf-agent
approved these changes
Oct 12, 2026
Restoring each file through serial blob requests repeatedly fetched shared revision assets and exceeded the container startup budget. Capture the committed descriptors and unique chunks once in a retained TAR stream, consumed sequentially through Python stdlib before any local replacement. Keep one restore API and release chunk references on stream completion or cancellation. Cover shared chunks across pages and revisions, publication replacement, cancellation, and an incomplete archive preserving local inputs. Preserve failure-only container diagnostics for the full stopped-container wake/media gate.
leaf-agent
approved these changes
Oct 12, 2026
# Conflicts: # tests/model/test_arms.py
Python and browser URL serializers encode valid deferred keys differently, so exact URL-string lookup woke a container despite its response being stored. PageStore now derives one structured pathname/query identity for staging, commit comparison and delivery, independent of transport encoding. Extend the actual Worker router and SQLite recall regression with tilde, star, Unicode, slash, plus and irrelevant request parameters. The assertion failed without the change; Worker typecheck and all 82 tests pass.
leaf-agent
previously approved these changes
Oct 12, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 27, 2026
Website restore installs `LEAF_PAGE_COMMIT` directly, but the session fixture did not restore it. A later quiet Codex hook inherited that website provider and imported `jsonschema` and `turbohtml` when closing its page transaction. The fixture now clears and restores the provider alongside the other host overrides, keeping each test's host configuration local to that test. The ordered reproduction runs `test_website_restore_streams_shared_chunks_once_across_files_and_pages` followed by `test_codex_tool_hook_reads_a_quiet_page_without_the_page_model` with `-n0`: it fails before this change with the reported imports and passes afterward. All five focused checks (the saved-record process tests followed by the quiet-hook test), Python compilation and scoped pre-commit checks pass. The existing hook assertion and website publication behavior are preserved. The provider was introduced by #2652 to publish saved website records under the page lease; this repair keeps that intent and fixes test environment ownership. <details><summary>CI verification on eb1f22b</summary> The [pull-request CI](https://github.com/max-sixty/leaf/actions/runs/40471706357) passed. The [full Linux and macOS dispatch](https://github.com/max-sixty/leaf/actions/runs/40471710301) completed with the quiet-hook test passing on both platforms (Linux at 09:49:48 UTC; macOS at 11:02:16 UTC). Its other failures are browser/site checks, including the metadata-size diagnostic tracked in #4341 and unused-export diagnostic in #4250; the dispatch is red, not a full-suite pass. This diff changes only host-provider isolation in the test fixture, preserving product code and the failing tests' assertions. The automated review stopped at Tend's PR burst-limit preflight before an agent ran. This session reviewed the fixture diff and its setup/teardown behavior without findings; the change adds one environment reset to the existing isolation owner rather than special-casing hook imports or weakening coverage. </details> Closes #4251 — automated triage Co-authored-by: leaf-agent <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Nov 22, 2026
This week's duplicate sweep of `dev/`, `build/`, `tests/` and `worker/` (week 47) moves six duplicated helpers onto one home each and moves every caller. Behavior stays the same. The touched model tests, the dev js_facts tests and the Worker's routing, storage and index tests pass. A script compared the old and new outputs of the consolidated `leaf_dev` functions and the seeded-log reads across the corpus, and they match. | Question | Home | Copies removed (introducing PR) | |---|---|---| | Which stylesheets do the core and the bundled packages ship, leaving out vendored files? | new `interact_support.shipped_sheets` | `sheets()` in `test_interface_fonts.py` (#4804) and `test_theme_tokens.py` (#6025). Five inline loops in `test_interact_layer.py` (#3138, #3886) | | Run `tests/js_facts.mjs` | `interact_support.js_facts` (#2666) | its own subprocess call in `dev/tests/test_js_facts.py` (#5118) | | Lowercase hex of bytes in the Worker | `routing.hex`, which is `newSessionId` (#313) renamed, plus a `sha256Hex` in `storage.ts` | the publication-identity and chunk-digest copies in `storage.ts` (#2652) | | Is this pid alive? | `leaf.machine.pid_alive` | `_alive` in `tests/process/test_codex_tool.py` (#3331). `running()` in `test_interact_layer.py` (#1774) | | Read an example's seeded log | `read_event_lines(seed_log(source))` (#4484) | inline parsers in `test_render_pages.py`, `test_interact_product.py` (#924) and `test_render_gate.py` (#509). The last one split lines with `splitlines()`, which also breaks at U+2028 | | Paths of the bundled registries and packages; which registry keys name elements | `leaf.schema.ASSETS` / `BUNDLED_PACKAGES` / `DEFAULT_PACKAGE`, `leaf.registry.contract.is_element_name`, `docs.registries()` | `docs.py`'s own `ASSETS`/`PACKAGES` (#3593) and its `startswith("lf-")` checks (#2660). `logs usage`'s hand-written regex and registry list (#5970). `ROOT / "packages" / "default"` in `stills.py` (#3927) and `test_product_page.py` (#3593) | `is_element_name` and the two checks it replaces give the same answer for every key in the bundled registries today. A selector key such as `lf-options.selected` would have passed the `lf-` prefix test. <details><summary>Sets found and left alone</summary> - **Sets an open PR is changing.** Nothing in this diff overlaps another open PR's hunks. #6732 moves tests out of `test_render_gate.py`, `test_render_pages.py` and `test_interact_layer.py`, but none of the tests changed here. - **Changes to browser tests with nothing run to check them.** The WCAG contrast computation exists as about 11 copies across browser, journey and model tests. Other copies: about 9 `EDITOR_ROOTS` shadow-root keepers, the `/api/interaction` batch predicates, CDP `touch()` closures, one-line patch templates, reply-holding route handlers, and the `data-lf-entry` runtime-module import snippet in `dev/leaf_dev/states.py` and in tests. Each would mean editing browser tests that this sweep can't run on a shared host. They suit a sweep that can run those tests. - **Vendor bundling.** `build/browser/build.mjs` builds signals-core and Lit with esbuild calls that repeat `build/vendor.mjs`'s `bundle()`. Merging them changes build options and needs a full `check:browser` byte comparison, so it was left for a change that runs that. - **Copies that are near but not the same.** `_build.py`'s `check_links` repeats `leaf_website.released_path`, but it also needs the matched page's root and kind. The list of API-key variables an eval drops is repeated across Python and the Promptfoo configs, as subsets and supersets of one another. The Codex token-expiry check has different thresholds, 1 h and 60 s. - **Too small to be worth it.** Picking a free loopback port (`eval_user.py`, `interact_support.available_loopback_port`). The XDG state root in `leaf_dev.state_home` and `leaf.state.state_home`. The `settled` helper in two `tests/runtime` files. </details> 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.
Visitors can reopen saved website comments, choices, and private revisions while their page container sleeps. The next write wakes the container and restores its canonical page directory before admission. This durable-state extraction uses the environment boundary from the merged host launcher PR.
Python owns activation, event admission, activity, and state folds. A commit under the existing page lease publishes the page record together with frozen HTTP responses; the Worker serves those bytes while dormant. Durable Object storage holds content-addressed 1 MiB chunks, normalized file/response descriptors, one staged successor per page, and active delivery/restore references. Replacing a successor collects unreferenced chunks. File modification dates preserve revision publication dates. Public and dormant snapshots share the canonical no-process presence producer. Response identity uses pathname and sorted decoded query pairs, so Python and browser URL serializers cannot cause a dormant lookup miss.
Restoration uses one streamed TAR snapshot with descriptors and each referenced chunk once, through maintained
modern-tarand Python’s standard library. Descriptor capture and stream retention share one reading; cancellation and completion release references. Python validates completeness before replacing local inputs. A real Durable Object RPC → outbound handler → Python restoration transferred 470 files, 198 chunks and 13.20 MB in 1.772 seconds.Private state remains scoped to a website release. The browser retains its active tab when the private server is replaced, and activation reaches other tabs for that page and release. Regressions cover descriptors beyond SQLite’s 2 MB row limit, a 2.5 MiB private image, interrupted publications, successor cleanup, shared chunks across files/pages, incomplete snapshots, readers crossing publication replacement, and special-character deferred keys through the real Worker router and SQLite.
The measured tradeoff is a complete per-session record: the first heat-loss publication uploaded 12.43 MB; a second comment uploaded 10 KB. At 12 private revisions, a comment sent a 1.44 MB descriptor manifest twice and uploaded 816 KB, with the local commit taking 417 ms versus 29 ms without private history. These are loopback measurements, not Cloudflare latency. Image-aware recording or incremental history would add image coupling and publication/deletion bookkeeping; neither is needed for a demonstrated correctness case. Superseded release records are retained.
Current candidate validation:
pnpm run check:worker: 82 tests passed, TypeScript clean.Linux CI passed on the final head
c5c2ce1ed58e03d0a8a2b71bb4e0285d8d9ed372: 2064 Python tests passed, four skipped; bundle/runtime/Worker checks, pre-commit, the 105-page site build, deployment dry run, anduv run leaf-dev verify-site website-workerpassed. The unmodified normal-budget verifier read the private revised document, saved comment/choice and revision assets with the container stopped, then woke it for a media write and checked that the restored events and revision survived. Dormant presentation was 613 ms versus 941 ms running, with the same 790 KiB of code by presentation; timing is diagnostic. The exact-head automated review approved without findings; there are no review threads and no failed or running checks.The local Mac Docker gate remains limited by a startup failure reproduced on unchanged launcher/main base
ae73f43ca3aa: installed @cloudflare/containers 0.3.7 mishandles Miniflare’s startup error while native/healthreturns 200. Cold Python took 11.37 seconds before restoration on this Mac. The Linux gate completed with the stock SDK budget; no SDK workaround or budget change is included.