Skip to content

Re-vendor a session's page an older Leaf vendored instead of refusing it - #2812

Merged
max-sixty merged 3 commits into
mainfrom
auto-revendor
Oct 14, 2026
Merged

max-sixty merged 3 commits into
mainfrom
auto-revendor

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A plugin update that bumps the page protocol reaches running sessions (Claude Code reloads plugins in place), and every page such a session held then refused each command until the agent ran the leaf page init the refusal named, while the user's comments waited. That re-vendor keeps the page's log and source, so the first Leaf to act for the page's session now makes it itself.

  • vendoring.renew_layer re-vendors a page vendored at an older page protocol, for the session holding it or when no live session does, and never takes back a page a newer Leaf vendored. It rechecks both under the locks the re-vendor holds, so a newer Leaf's re-vendor or a takeover in between wins. A layer documenting an x- key this Leaf does not admit stays refused, since the key may be one a newer Leaf added at the same protocol. It reports only what is left for the agent: the page check errors that keep index.html from activating, or why the re-vendor was refused.
  • It runs from cli.resolve_dir (every page command but server stop and the private server _serve child) and from hook_transport.read_plans (prompt and Stop hooks, using the claim's harness since a hook's environment does not name its session). The Stop hook continues the turn when the re-vendor leaves something to do.
  • hosting.restarting_server takes the harness it restarts for, and its stop carries the claim it decided for: a session that takes the page meanwhile keeps its service, and the re-vendor is refused.
  • An owed answer whose reference points into a delivery an older Leaf wrote now counts as having no usable reference, so the hooks capture that update again rather than pointing the turn at a delivery it cannot read.

Measured end to end: a page served by a protocol-3 Leaf for a Claude Code session, whose first prompt hook under this Leaf re-vendored it in 1.1 s, restarted its server at the same URL on the new runtime, and handed the pending comment over. Re-vendoring a protocol-1 page silently drops its to-dos and prose asks (the #2506 rename); a manual page init does the same, and AGENTS.md "Stage" rules out an old-record validator.

Tests: the refusal tests now cover a page a newer Leaf vendored or another session holds; new tests cover the prompt hook's and a command's re-vendor, server start on an older page, the re-captured update, and the three races.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits October 13, 2026 19:52
A plugin update that bumps the page protocol reaches running sessions (Claude Code
reloads plugins in place), and every page they hold then refused each command
until the agent ran the `leaf page init` the refusal named, while the user's
comments waited. That re-vendor keeps the log and the source, so it needs no
judgment: the first Leaf to act for the page's session now makes it
(`vendoring.renew_layer`), from a command naming the page (`cli.resolve_dir`) or a
prompt or Stop hook (`hook_transport.read_plans`). It says only what is left for
the agent: the `page check` errors that keep index.html from activating under the
new layer, or why the re-vendor was refused; the Stop hook continues the turn for
either.

Only the holding session renews a page, or any caller while no live session
holds it, since another session may still run the older Leaf. A Leaf never takes
back a page a newer one vendored, so a process started before the update cannot
ping-pong the page and reload the user's tabs. Both readings are taken again
under the page lock and transaction the re-vendor holds, so a newer Leaf's
re-vendor or another session's takeover in between wins. `restarting_server` takes the
harness it restarts for, since a hook's environment does not name its session.

An update an older Leaf delivered and the turn has not answered owed its answer
through a reference into that older delivery, which this Leaf cannot read; the
hooks now treat such a reference as unusable and capture the update again.

Tests: a page an older Leaf vendored is now re-vendored by the prompt hook, by
`server start` and by any page command of the holding session; the refusal tests
now cover a page a newer Leaf vendored or another session holds.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The restart needs to fence page ownership before it stops the service.

Comment thread skills/leaf/scripts/leaf/vendoring.py Resolved
A session can take the page between the restart's ownership decision and its
stop, and the stop then disabled that session's service. The stop now carries
the claim it decided for (`cmd_stop`'s owner), and the restart refuses once the
claim has moved, leaving the new owner's service running.

A layer documenting an x- key this Leaf does not admit is no longer renewed: the
key may be one a newer Leaf added at the same protocol, which a re-vendor here
would strip, so it stays refused naming `leaf page init`, as
`test_check_refuses_a_vendored_entry_declaring_a_key_this_leaf_does_not_admit`
expects.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 1f39920 into main Oct 14, 2026
5 checks passed
@max-sixty
max-sixty deleted the auto-revendor branch October 14, 2026 03:35
max-sixty added a commit that referenced this pull request Oct 14, 2026
#2812 made the session holding a page vendored at an older page protocol
re-vendor it on its first command or hook. AGENTS.md "Pages across Leaf
updates" and `layer.incompatible_layer`'s docstring still said only that
a Leaf refuses such a page; both now name `vendoring.renew_layer` as the
exception. The other references (`serving-pages.md`,
`layer-registry.md`, `delivery.py`, `hook_transport.py`) were updated in
#2812.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 14, 2026
The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38507012987) failed
its preview startup test because the test held the page transaction lock
while waiting for the preview server to stop. Since #2812, stopping
checks the page's claim inside that transaction, so the stop could not
complete and the test never arranged the interrupted fetch it meant to
examine.

The test now aborts its first registry fetch when a runtime edit starts
the preview replacement. It records that the startup notice was visible
even if recovery navigates to a new document, then checks that the
replacement serves the edited theme at the same address. This keeps the
failure and recovery behavior under test without blocking the
claim-guarded stop.

The failing test reproduced on the original `main` tree and passes on
this branch against current `main` (`uv run pytest -q -n0
tests/browser/test_render_export.py::test_a_service_that_goes_away_mid_start_says_only_that_and_comes_back`).
Pre-commit checks pass. The run's other failure, the async projection
wake case, passes on merged #2830 and on current `main`.

Co-authored-by: leaf-agent <[email protected]>
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