Repository navigation
Let hosts select the environment used by native Leaf hooks - #2641
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
previously approved these changes
Oct 12, 2026
This was referenced Oct 12, 2026
# Conflicts: # tests/model/test_arms.py
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
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](#2641). 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-tar` and 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. - Focused Python snapshot/restore/presence checks: seven passed; launcher-environment boundary: one passed. - Scoped pre-commit passed. - Fresh Claude whole-PR, semantic-key repair and base-integration reviews: MERGE; no further demonstrated underlying defect. [Linux CI passed on the final head `c5c2ce1ed58e03d0a8a2b71bb4e0285d8d9ed372`](https://github.com/max-sixty/leaf/actions/runs/38320644623/job/115047649763): 2064 Python tests passed, four skipped; bundle/runtime/Worker checks, pre-commit, the 105-page site build, deployment dry run, and `uv run leaf-dev verify-site website-worker` passed. 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](#2652 (review)); 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 `/health` returns 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. > _This was written by Codex on behalf of max-sixty_
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.
Native plugin hooks normally run the plugin's own uv environment. A website host needs those hooks to use its prepared environment, which also contains the website storage provider.
Add an absolute
LEAF_HOST_LAUNCHERoverride to the existing launcher. KeepLEAFas the agent's command locator, preserve standalone SessionEnd cleanup, and isolate the host override in development and test child processes. A redirected call consumes the selection, allowing a host wrapper to invoke Leaf without recursively selecting itself. Self and symlink aliases retain default dispatch.Validation: focused launcher/environment checks and applicable pre-commit pass. A wrapper regression fails on the old implementation and passes on this head. Independent Claude full-PR and repair review explicitly recommends merging with no further demonstrated underlying fix, after exercising command/hook forwarding, stdin/exit status, SessionEnd, wrapper/self/symlink selection, invalid paths and child isolation under macOS and Debian shells.
First part of the replacement for #2249; the durable website state PR builds on this launcher boundary and supplies its website producer.