Repository navigation
Say in How it works which copy of Leaf a session runs, and follow Codex's and Pi's in-place updates to it - #6782
Merged
Merged
Conversation
…ges, servers and skill text follow that copy The rule lived only in session-lifetime.md and module headers. How it works now states it for a reader of the mechanism: the copy the hooks run ($CLAUDE_PLUGIN_ROOT/bin/leaf, the copy Claude Code loaded) is the session's one reference, and at the next hook Leaf brings each page's protocol, each page's server and the agent's skill text to it.
…d the agent back to the skill whenever its content changes A session's one reference is the copy its hooks run. Codex keeps one clone at plugins/cache/<marketplace>/leaf/local and replaces it in place: on this machine it was cloned afresh at that path twice in twelve minutes, each time with a new inode and commit and no .venv. `state.plugin_cache_copy` accepted only a hex version directory, so Codex's copy read as a checkout: the prompt hook never restarted a server an older Codex copy started (`reconnect.to_restart`), every claim selected Codex's own copy as a "checkout" (`session_runtime.select_checkout`), and a bare command never handed off to a checkout the session selected (`hand_off_command`). The test now accepts any version component. `layer.payload_provenance` takes the commit from the directory name only for a copy without `.git`, and reads an installed clone as clean without a `git status`: Codex strips the `.agents/skills` link and adds its install record, so every Codex copy read dirty, and the status was the costliest Git call the prompt hook now makes to learn which Leaf it runs (230-420 ms on Codex's clone at a load of 55, against 160 ms for the other two together). The skill mark records a digest of `skills/leaf/` (about 1 ms per hook) in place of the plugin root, so an in-place update triggers the reread and the notice no longer reads the previous copy's tree, which may be gone. `mark_root`/`root` becomes `mark_skill`/`skill`, and `copy_changed` becomes `skill_changed`, whose notice no longer says the hooks run another copy. A session whose hooks run a checkout now also gets the notice after an edit to that checkout's skill. `server.another_leaf_serving` (commit only, for `page check`) and `hosting.other_serving_leaf` (path and commit, for restarts) answered one question two ways. `server.other_serving_leaf` is now the one test, against the Leaf the process runs (`layer.running_leaf`), and `page check`'s `another-leaf-serving` note uses it, naming the server's path and commit. The note now also fires for a server another path started at the same commit, which `server start` restarts. Prose: `vendoring.renew_layer` lists every renewal point (a write command, the prompt hook serving a page again, and each hook that reads the session's pages, tool boundaries included), and `layer.py`, `layer-registry.md` and `serving-pages.md` follow it; read commands don't renew. `session-lifetime.md` gains "Which Leaf runs a session", which says Codex updates in place and why a Leaf is told apart by path and commit, and that Codex's delivery adapter keeps the code it started with across such an update. `layer-registry.md` no longer says `session_runtime.py` selects the Leaf a session's hooks run. How it works says Codex and Pi update their copy in place. Tests: the restart test covers Codex's copy at another commit (restarts) and at its own (doesn't); the skill test drives an in-place edit of a Codex-shaped copy and a deleted previous copy; the provenance test reads a Codex-shaped clone's commit from Git and reads it clean; the page-check note names path and commit; the fixture server records this Leaf as a real server does.
…reload-plugins does to it The header said Claude Code loads the module "from the installed plugin"; it loads it from the copy the session's process loaded, whose bin/leaf the hooks run (`$.plugin.root`). `sessionOf` said a module loaded or reloaded mid-session sees no session.start. A probe on Claude Code 2.1.330 showed otherwise: a /reload-plugins that moves to a new installed copy changes the module's arguments, which include pluginRoot (isDeepStrictEqual), so Claude Code retires the old instance, whose follower gets SIGTERM, then loads a new instance from the new root and raises session.start on it. A reload that changes nothing keeps the instance and its follower, which also covers a plugin loaded in place from a directory, since its path doesn't change. The lazy read stays for a resumed or cleared session, which raises no session.start.
The skill-reread notice compared only a digest of the skill, so a session developing Leaf got the notice each time it edited its own checkout's skill. The record a session's hooks keep is now the Leaf they ran, by plugin root, with the skill it ships, by `layer.files_identity` in place of a second tree digest. The notice fires when the skill differs and either the root differs or the root is an installed copy, which only its harness writes, as Codex's copy updated in place is. An edit to a checkout's own skill no longer notifies. Also from the review: rebuild the protocol baseline the clerk record's new description changed; correct How it works where it overstated (Claude Code may delete a running process's copy, the prompt hook restarts a server only where both copies are installed and the deadline allows, a checkout stays selected until the process ends or selects another, the skill record lasts while the session holds a page); move the `/reload-plugins` lifecycle note into the `claude-code.ts` header; and split the "Leaf updates" paragraph of serving-pages.md.
…s and rereads the skill Pi installs a git package as a clone at `~/.pi/agent/git/<host>/<path>`, or a project's `.pi/git/<host>/<path>`, and updates it with `git reset --hard` and `git clean -fdx` (Pi 1.5.0's `package-manager.js`, `getGitInstallRoot` and `ensureGitRef`). Leaf took that clone for a checkout, so after a Pi update the prompt hook left the page server on the old code, and since the previous commit the skill-reread notice stayed silent too. `state.plugin_cache_copy` becomes `state.installed_copy` and also matches Pi's location. The skill test now covers Pi's in-place update and a hand-off to a checkout whose skill differs, which the previous commit's test no longer exercised. How it works says the skill record lasts while the session lives or holds a page, and that a selected checkout lasts until the session ends, it selects another or the checkout's launcher is gone.
leaf-agent
approved these changes
Nov 22, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 23, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
…e Code renews Leaf's hooks module A hook whose skill differs from the previous hook's now tells the agent to read the skill again whatever copy ships it, a checkout the session's hooks run included. Before, a checkout at the same root was exempt, on the guess that a session running a checkout is the one editing its skill, so a merge or branch switch that changed the skill under a `--plugin-dir` session went unnoticed (the gap #6782 named). An edit the session makes to that skill now draws the notice too. Three texts said Claude Code keeps the hooks module until `/reload-plugins`. Measured at 2.1.332 with a probe mod loaded by `--plugin-dir` in an interactive session: a save to the module file renewed the instance within seconds (register and session.start ran again, and the child the old instance spawned was killed); a save to any other file, a SKILL.md or a data file, renewed nothing, and neither did `/reload-plugins` or `/reload-plugins --force` after it. A module can't import JSON ("not named like code and was not loaded"), so Claude Code can't learn that Leaf's Python or kernel registry moved. The follower's restart on a protocol move (`_moved_on`, #5796) therefore stays: it is the one part of running a checkout in place that Claude Code can't do for Leaf. The skill-notice test now expects the notice for an edited checkout skill.
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
Leaf no longer tells the agent to read the leaf skill again when the skill
its session's hooks ship changes. The skill text the agent read is the
harness's to keep or renew; Claude Code 2.1.332 has `/reload-skills`
("Pick up skills added or changed on disk during this session").
The maintainer asked how much the notice costs to maintain and proposed
dropping it. It landed on 2026-11-22 (#6757) and has needed a change in
each of #6782 (Codex's and Pi's in-place updates), #7061 and the previous
commit on this branch (a checkout's own skill). Over the last 30 days 444
of main's 2,093 commits touched skills/leaf, so nearly every update a
session picked up made it reread SKILL.md and its references. A command
whose interface changed still reports that through its own error or
`--help`, which is the agent's path for any command it misremembers.
Each hook now records only the root of the Leaf it runs (`leases.mark_root`,
`sessions/<digest>.root`), which `state.hooks_root` reads for a checkout's
right to act for the session and for a server's follow to another copy. The
hook no longer hashes the skill's 33 files on every call. The record's file
is renamed from `.skill` to `.root`. An older Leaf at this protocol reads only
`.skill`, so across the one update that ships this commit a page server from
the older copy doesn't see the newer copy's root and stays where it is, which
two versions of Leaf at one protocol may. The clerk queue's schema description drops the
notice, an annotation the protocol baseline carries without a bump.
The notice after a compaction (`hooks.reload_skill`) stays: it covers the
text a compaction dropped, not a skill that changed.
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.
How it works gains a section, "Which Leaf a session runs": a session's one reference is the copy of Leaf its hooks run, and at the next hook each page's protocol, each page's server and the skill text the agent read are brought to that copy. This makes the code follow that rule in Codex and Pi too.
Claude Code installs each update as a new directory, so a path names a version. Codex and Pi keep one copy and update it in place, so Leaf now tells two copies apart by path and commit (
server.other_serving_leaf,layer.payload_provenance), andstate.installed_copy(formerlyplugin_cache_copy) also recognizes Pi's git clone at~/.pi/agent/git/<host>/<path>or a project's.pi/git/<host>/<path>. The prompt hook's server restart and the skill reread therefore fire after Codex's or Pi's update, where before they never did. The reread compares the skill's content and fires only when the hooks run another Leaf, so editing a checkout's own skill stays quiet. Four texts that misstated when a page is renewed are corrected, and two tests of "another Leaf serves this page" become one.To weigh: Pi's clone location and its in-place update (
git reset --hard,git clean -fdx) were read from Pi 1.5.0'spackage-manager.js, not run, since there's no Pi install here. A merge or branch switch that changes the skill in a checkout the session runs still goes unnoticed, as on main.The maintainer asked for the rule to be explicit in How it works and for the code to match it. Two independent reviews read the branch, and their findings are fixed. Focused model tests pass, and so do the
claude-code,codex-app-serverandcodex-queueagent journeys.