Repository navigation
Load the Claude Code module again, and learn a fork's cache rewrite from the main thread's usage - #5947
Merged
Conversation
…ewrite from the main thread's own usage Claude Code 2.1.325 refuses to load a hooks module whose `$.env.get` names its variable other than by a literal. #5907 read the route's variables in a loop, so 2.1.325 loaded none of the module: no band, no turn-end check and no thread-reply fork. `readRoute` now spells each name at its call, and `claude plugin validate` lists them as the module's env reads. A turn-end check at low effort counted as a rewrite of the prompt cache when it wrote more than it read. On Vertex such a fork still reads the system prompt and tools (28k tokens in #5904's repro), so a rewrite of a conversation shorter than that went unseen. The `turn.step` hook now keeps how much of the main thread's last request its response left in the cache (`cached`, also in each fork's diagnostics `request`), and a check that reads less than that is a rewrite. In 103 checks at low from sessions at xhigh on Opus 5.5, where per-message effort keeps the cache, every fork read at least that much, as did each of the 12 checks in a claude-code journey on 2.1.325. Only an answered check counts, since a fork the API refused reports no tokens read, and only while no other main-thread request has gone out since the one `cached` measures. A stored rewrite lapsed only into a check in a conversation of at most 20 messages, which never comes: of 902 checks on the maintainer's machine, none came before a conversation's 46th message, and no session's first before its 194th. So a backend that gained per-message effort was never found again. The next check after the seven-day lapse now asks at low whatever the conversation's size, which costs one rewrite of it per backend per lapse where the backend still lacks per-message effort. The test driver's `turn.step` now answers with a response carrying usage, a fork can come back refused (`forkRefused`), and the tests' main-thread request carries 200 messages, as long as a session's first check comes in. Behaviour changes held by tests: a small rewrite is caught, a lapsed answer is asked again in a long conversation, a re-asked rewrite renews, and a refused check stores nothing.
…rrent door names Claude Code 2.1.322 renamed session.append's doors: the model's reply now arrives by `response` and a tool's result by `tool-result`, so the module's `model` matcher caught nothing, and a fork's `row` and `sent` named the turn's first user row. A turn-end check's or line fork's diagnostics then pointed a replay at the turn's opening prompt rather than its final reply. The module now follows every door of a row the model reads, as 16434b2 on send-pickup-latency does; Claude Code 2.1.325's `claude plugin validate` reported the stale name and now reports nothing for the module.
leaf-agent
previously approved these changes
Nov 14, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
#5816 (open) also rewrites this session.append door list, and the two disagree. #5816 drops tool-message because on a machine with managed settings cc-plugin-sec-default sends Skill bodies on that door past person-level handlers, which shows the skipped-hook notice at each session's first Skill call. It also keeps queue and notice. This PR keeps tool-message and drops queue, and doesn't add notice. Main already has tool-message, so this isn't a regression, but whichever lands second needs to settle the list. Its comment's "Claude Code tells the user when one of those sends a row past a handler" is the same notice #5816 is avoiding.
#5816 settles the same list with evidence from a machine with managed settings, where the security plugin sends Skill bodies on `tool-message` past a person's handlers, so this branch keeps main's list.
leaf-agent
previously approved these changes
Nov 14, 2026
… here, not from 2.1.325 2.1.322, 2.1.323 and 2.1.325 all refuse main's module (claude plugin validate), so #5907's loop broke the module for every session since it landed.
leaf-agent
previously approved these changes
Nov 14, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
A new `newest-harnesses` job, on the daily schedule and on dispatch, installs `@anthropic-ai/claude-code@latest` and `@earendil-works/pi-coding-agent@latest` and runs `pnpm run check:hooks`. The pins move with Dependabot's weekly npm group, while a user's Claude Code updates itself as each release ships, so a release that refuses `hooks/claude-code.ts` or changes the API `hooks/pi.ts` uses now turns the daily run red for tend within a day. Rehearsed locally on this branch's tree with #5947's module: Claude Code 2.1.325 and Pi 1.5.2 installed, and the check passed.
# Conflicts: # tests/claude_code_driver.mjs
leaf-agent
approved these changes
Nov 14, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
…nd daily at the newest release (#5952) CI now fails wherever Claude Code would refuse to load `hooks/claude-code.ts`. `pnpm run check:hooks` also runs `claude plugin validate .` from a pinned `@anthropic-ai/claude-code` (2.1.325), on every run. The daily scheduled `test` job then runs the same check again after installing the newest Claude Code and Pi. A release that refuses the module, or changes the API `hooks/pi.ts` uses, then turns the daily run red for tend within a day, instead of waiting for Dependabot's weekly bump of the pin while users' Claude Code updates itself. Until now nothing in CI asked Claude Code: the module's tests run in a Node stand-in, and `hooks/tsconfig.json` leaves the module out. That gap let #5907's `$.env.get(name)` loop through. Claude Code refuses a module whose `$.env.get` takes anything but a string literal (2.1.305 already did), so every session that loaded the module from an install since #5907 has had no band, no turn-end clerk and no thread forks. The refusal shows only in Claude Code's debug log, so all Max saw was an empty band in a session he resumed today. #5947, now on main, spells each name out, so the check passes on this branch; before it merged, the check failed in CI with exactly that refusal. The nightly harness scan in `running-tend` now reads Pi's releases too, since `hooks/pi.ts` depends on Pi's API. The package's postinstall copies its platform binary into place, so `pnpm-workspace.yaml` allows its build; pnpm hard-links the 347 MB binary from its store, so a worktree adds no copy. Max asked why the band was missing, then for the nightly check against each harness's newest release, and for Pi in the nightly scan. Checks: `pnpm run check:hooks` failed in CI with only that refusal before #5947 and passes locally after it; the newest-release step's commands, rehearsed locally with #5947's module, installed Claude Code 2.1.325 and Pi 1.5.2 and passed; `pnpm run test:browser` and pre-commit pass. The `test` job's one failure, `test_receipts.py::test_ack_rearm_reports_when_its_only_page_transfers_after_selection`, is inherited: a watchdog warning (`InotifyEmitter.queue_events() called when the thread is inactive`) on a waiter's stderr broke the test's JSON parse, in code this PR doesn't touch. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
…kend reads the cache (#5960) Leaf's two conversation forks (the turn-end check and the thread-reply line) no longer ask `$.model.fork` for `low` effort. They think at the session's effort, which reads the prompt cache on every backend, and their prompts ask them to answer straight away without thinking it over, as Claude Code's `ModelForkRequest.effort` docs suggest. That removes the per-backend learning from #5892/#5907/#5947 (route variables, a stored answer in `$.store`, a weekly lapse, a cache-warmth window) and the `effort` plumbing through `clerk.py`, `forks.py` and their diagnostics. A TODO in `runFork` marks the switch back to `low` once Claude Code carries a change of effort per message on every backend without an env var. What it costs, from `leaf-dev eval 'turn-end-check*' 'fork-reply*' --base` (one sample per case, xhigh with the quick-answer request against the low fork): - **Turn-end check:** 15/15 passed, as low did. It wrote 1.62× low's output (95% 1.26–2.09) and took 1.23× its time (1.10–1.38). The check runs off the turn's path. - **Reply line:** 7/7 passed, against low's 6/7. It wrote 1.49× the output (0.91–2.44) and took 1.09× the time (0.94–1.25), about 4 s a line. To weigh: the turn-end check is roughly a quarter slower than at `low`. In exchange, Vertex and proxy sessions stop paying a conversation rewrite to learn their backend. Max asked for the effort change to go in favour of the prompt. The claude-code journey passes, and Codex reviewed it; its two findings, an unused driver clock and a stale comment, are fixed. `tests/process/test_interact_claude_code_module.py`, `tests/model/test_clerk.py` and `tests/model/test_forks.py` pass. > _This was written by Claude Code on behalf of max-sixty_
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.
Claude Code refuses to load a hooks module whose
$.env.gettakes anything but a literal name, and #5907 read the route variables in a loop. Since #5907 landed, Leaf's Claude Code module hasn't loaded in any session: no band, no turn-end check, no thread-reply fork.claude plugin validaterefuses main's module at 2.1.322, 2.1.323 and 2.1.325.readRoutenow spells each name out. The claude-code journey passes with this branch, where it failed at setup on main (hooks module did not load). #5952 adds that validation to CI and should merge after this.The PR also tightens the effort learning from #5892/#5907, which keeps turn-end checks from rewriting the prompt cache on Vertex:
turn.stepresult, recorded asrequest.cachedin each fork's diagnostics). Before, the test was "wrote more than it read", which misses a rewrite of a conversation shorter than the system prompt and tools the fork still reads (28k tokens on Vertex in A fork's change of effort rewrites the prompt cache on backends without per-message effort, such as Vertex #5904's repro). In 103 real checks where the cache held, plus 12 in the journey, every fork read at leastcached. Only answered checks count: a refused fork reports zero reads.The module's stale
session.appenddoor names, which 2.1.325'sclaude plugin validatereports, are left to #5816.Max asked whether the Vertex caching issue could be fixed. Codex reviewed the change; its two findings, the refused fork and a step racing the fork, are fixed here.
tests/process/test_interact_claude_code_module.pypasses (18); the new cases fail on main.