Repository navigation
Re-vendor a session's page an older Leaf vendored instead of refusing it - #2812
Merged
Merged
Conversation
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
reviewed
Oct 14, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The restart needs to fence page ownership before it stops the service.
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]>
leaf-agent
approved these changes
Oct 14, 2026
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]>
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 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 initthe 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_layerre-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: thepage checkerrors that keep index.html from activating, or why the re-vendor was refused.cli.resolve_dir(every page command butserver stopand the privateserver _servechild) and fromhook_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_servertakes 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.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 initdoes 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 starton an older page, the re-captured update, and the three races.