Skip to content

Keep a session's hooks, follower and commands on the Leaf copy it loaded - #6758

Merged
max-sixty merged 2 commits into
mainfrom
keep-hooks-on-loaded-copy
Nov 22, 2026
Merged

max-sixty merged 2 commits into
mainfrom
keep-hooks-on-loaded-copy

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

A running Claude Code session's Leaf hooks, pages follower and bare leaf commands now run the plugin copy the session loaded, until /reload-plugins or a new process (a background job's wake, a resume) loads the copy Claude Code installed since. They used to hand themselves to the copy installed_plugins.json names, which left the hooks module and skills on the loaded copy while the Python ran another: 828 of 1,082 active minutes across 36 job processes over a day and a half.

Checkout selection is unchanged; whether to keep it is a separate decision, postponed for now. A selection whose checkout is gone now falls back to the session's own copy rather than the installed one. A loaded copy that lost its files refuses at bin/leaf, naming /reload-plugins, instead of running another copy. The newer-layer refusal now names /reload-plugins for Claude Code.

Worth weighing: a Leaf fix reaches a background job at its next wake and a terminal session at its next restart or reload, rather than at the next hook. When the newer Leaf behind a newer-layer refusal was a checkout ahead of the installed copy, the reload advice won't help, and the finding can't tell the two cases apart.

The maintainer chose this on the Leaf page about keeping a session on one version of Leaf (#8, first part). It supersedes #6575, which kept the hand-off and moved it into the shell launcher. Tests: tests/model/test_hook_registration.py (two tests rewritten for the new behaviour), the follower, module-restart, bridge, selection and newer-layer tests, and test_product_page.py, all passing. A fresh reviewer read the diff.

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

A running Claude Code session's hooks, pages follower and bare `leaf` commands
now run the plugin copy the session loaded, until `/reload-plugins` or a new
process of the session (a background job's wake, a resume) loads the copy
Claude Code has installed since. They used to hand themselves to the copy
`installed_plugins.json` names, which left the hooks module and skills, which
Claude Code reads only as it loads the plugin, on the loaded copy while the
Python ran another. The user chose this on 2026-11-22.

- `session_runtime.installed_launcher` and its rung in `delivering_launcher`
  go: a session's delivering Leaf is the checkout it selected, while that
  exists, or else its own copy. Checkout selection is unchanged
  (`select_launcher`, `select_checkout`, `hand_off_command` for a selected
  checkout, the Codex adapter, `leaf-dev preview --user`), and a selection
  whose checkout is gone falls back to the session's own copy.
- `bin/leaf` no longer reads `installed_plugins.json` for a copy that lost its
  files; such a copy refuses, naming `/reload-plugins`.
- The `newer-layer` refusal names `/reload-plugins` for Claude Code, since an
  older loaded copy can now meet a page a newer Leaf initialized, and
  `serving-pages.md` tells the agent the refusal says how to load a newer Leaf.
- Kept, since selection still needs them: `state.plugin_cache_copy`, the
  follower's EX_TEMPFAIL restart and the module's handling of exit 75 (a
  follower moves to a newly selected checkout, or off one whose worktree
  went), and `registry.kernel.installed_protocol` (a selected or
  `--plugin-dir` checkout can move past a protocol bump under a running
  follower).
- The session_runtime, carrier and hooks headers, `session-lifetime.md`,
  `bin/leaf`, `docs/how-it-works.html` and developing-leaf's landing note say
  what holds now. The user's choice not to check that the loaded module and
  the hooks' Python agree now rests on sessions whose hooks run a checkout,
  the only ones where the two can differ.

Tests:
- `test_an_older_installed_copy_delivers_through_the_copy_installed_since`
  becomes `test_a_bare_command_from_an_installed_copy_runs_only_a_selected_checkout`.
  It protects that a bare command from an installed copy runs that copy even
  with a newer one recorded, runs a checkout the session selected, leaves a
  hook to `hooks.main`, and that a checkout runs itself.
- `test_an_installed_copy_that_lost_its_project_runs_the_copy_installed_since`
  becomes `test_a_copy_that_lost_its_project_refuses_naming_the_reload`. It
  protects that such a copy refuses, naming `/reload-plugins`, and runs neither
  the recorded copy nor uv.
- Both fail on the previous code. The follower and bridge hand-off tests keep
  their assertions; their docstrings drop the installed copy, and
  `select_another_leaf` stands for another checkout, the only Leaf a session
  selects.
@max-sixty
max-sixty merged commit f04c1a4 into main Nov 22, 2026
6 checks passed
@max-sixty
max-sixty deleted the keep-hooks-on-loaded-copy branch November 22, 2026 20:28
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