Skip to content

Let hosts select the environment used by native Leaf hooks - #2641

Merged
max-sixty merged 4 commits into
mainfrom
codex/website-host-launcher
Oct 12, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/website-host-launcher

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

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_LAUNCHER override to the existing launcher. Keep LEAF as 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.

This was written by Codex on behalf of max-sixty

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
leaf-agent previously approved these changes Oct 12, 2026
@max-sixty
max-sixty merged commit 1e64adc into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the codex/website-host-launcher branch October 12, 2026 23:26
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_
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