Skip to content

Check each turn end against the page from a skill reference, and let the fork fix a few stale words - #4900

Merged
max-sixty merged 32 commits into
mainfrom
fork-questions-prose
Nov 4, 2026
Merged

max-sixty merged 32 commits into
mainfrom
fork-questions-prose

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

The turn-end fork (Leaf's clerk, src/leaf/clerk.py, run from hooks/claude-code.ts as each Claude Code turn ends) now checks the session's pages against the conversation in three ways: it puts On me what the agent left to the user, fixes a few out-of-date words on a page itself and tells the agent, and passes the agent the rest of what it finds out of date. Before, it only looked for asks missing from On me, with its questions written as strings in Python.

What the fork is asked

The prompt is now prose in the shipped skill, skills/leaf/references/turn-end-check.md, sent verbatim with each page's text and On me. For asks, the fork reads the same On me rule the agent follows (conversation-loop.md, "The On lists") rather than a wording of its own, so the clerk applies Leaf's standard policy. It also names three kinds of finding for the agent: a page that still says what the work has since changed, an On me item the user already answered elsewhere, and work promised or set running that no page shows. Each finding reaches the agent once, as hook context at its next step, and the fork is told to leave out a finding an earlier message already passed on. Status lines are left out for now: the fork restated stale ones 15 of 15 in replay, but Leaf can't yet write one truthfully after the turn closes (activity._start_age), and no recorded session had one go stale.

Fixes the fork makes

A stale finding may carry an edit: the page's exact words and their replacement. Leaf makes it only while no new turn has opened and only where the page shows the words once, then tells the agent the old and new words, so the agent can change them back or carry the change to a page it builds from another file. Leaf places the edit by its own passage reading rather than a text search: it marks each place in index.html the words could come from, rereads the page, and takes the mark that lands where the fork quoted. So a copy in the <title>, a script, a style, a comment, a widget's tip or a draft body the user rewrote is never the one changed. It swaps only the changing words, keeping the source's whitespace, refuses a fix that would move a line inside <pre>, checks the page then reads exactly as asked with the same block breaks, and saves through the usual activation, restoring the files on any failure.

What each fork leaves behind

Claude Code keeps no copy of a $.model.fork exchange, only its token counts in the debug log. So each page the session holds now gets a turn_end_check record in its diagnostics (observations.jsonl) per fork, as a thread-reply fork's fork_reply does: what the fork named on that page, verbatim, the records Leaf wrote, the passages it changed, how many lines it told the agent, why it wrote no records where it didn't, and the fork's usage and time. A clean turn end, a fork with no answer, and an answer the schema refuses each get one too. The hooks module now hands Leaf the fork's usage, time and failure, and, for both this record and a thread reply's fork_reply, the request $.model.fork resent: the model and effort the main thread's last turn.step named, how many messages it carried, and the newest transcript rows stored as it went out (sent) and by the time of the fork (row), from session.append. The fork reads the conversation as it would next go out, so a replay cuts at sent while a tool call runs and at row otherwise. A turn-end fork therefore reads the turn's final reply: notes/fork-replies.md measured it, and in a journey run the only row holding the words an ask quoted was that reply.

Shared code

  • projection.logged_words and PageReading.passages() are the one way to read a page's words with the log's rewrites, retirements and created widgets applied. Thread anchoring, to-do placement (work.py), the render gate, sample fixtures' anchors, the reanchoring check between revisions and the clerk all use it. To-do placement now also sees widgets the user created on the page.
  • publishing.replaced_authored_files writes new authored inputs and restores them if anything after fails; page stamp --replace and the clerk share it.
  • page_passages reports where block breaks fall (Passages.breaks), which the fork's page text and the fix check use.

Measured

On eight recorded turn ends whose pages could be rebuilt, the fork gave edits for 26 of 34 stale findings. Run through clerk.fixed_source, 24 changed the words where the user reads them and 2 were refused (their words cross a link or code span); none changed anything else. That replay skips each page's history and the final activation. For repeats, with the finding's line put where Leaf delivers it, the fork named an unchanged stale lede again in 6 of 6 runs without the sentence and left it out in 6 of 6 with it.

The fork eval

uv run leaf-dev eval 'turn-end-check*' 'fork-reply*' --harness claude-code scores both forks, this turn-end check and the thread-reply fork, on 21 constructed cases: 14 for turn ends and 7 for thread replies, each a short conversation written for one decision (evals/workflows/fork_eval.yaml). The executor (dev/leaf_dev/fork_eval.py) renders each conversation as a Claude Code transcript and resumes it with the tool definitions kept and every call blocked by a hook. Each arm's own Leaf builds the question and takes the answer, and the case is scored on what Leaf took: the records it wrote, the findings its turn_end_check note lists, and the fork_reply note's outcome. A judge reads every item, and an edit counts only where the labelled words are gone from the page as the user reads it. --base compares the merge base. The fork_reply note gains refused, so a hand-over the fork chose is told apart from an answer Leaf refused.

On this branch every case passes. stale-omission, a page that leaves out a fact the work added, failed all 8 runs at first: the fork named the page stale, with an edit adding the fact. The reference now says "A page that doesn't yet mention something isn't stale; the agent decides what to add", and with it the case passed 8 of 8 and a run of all 14 turn-end cases passed every one. On main, whose clerk takes no findings, the four finding cases fail every run. A fork costs about $0.08, and one run of every case about 3 minutes and $3 with the judges. Constructed cases can't show the drift late in a long session that the check exists for; the forks' diagnostics notes stay the evidence for that.

Testing

tests/model/test_clerk.py covers placement case by case (title, tip, reference, spacing, line breaks, entities, private-use characters, dropped and inserted words, wrapped and styled text, comments), the refusals, a body the user rewrote, line endings, and findings without an edit; switching placement back to a plain first match fails six of them. The focused suites for forks, anchors, to-dos, stamp --replace, the skill's routes and the Claude Code hooks module pass.

leaf-dev journey claude-code passed all 12 steps on the branch, twice, the second time with the diagnostics records; main passed the same run. In that second run the records show 9 of the 12 forks naming asks, all questions the agent left in its replies, such as "if you'd like, I'll add ids to them". The journey's user had opened another turn before 8 of those answers arrived, so Leaf wrote nothing for them; the last fork put 4 questions On me. An earlier branch run failed dropped on a second "Leaf: new input" wake 90 ms after the first, which the turn had already answered. The branch doesn't change the watch or the wake path, so I take it for an intermittent race, though one run on main can't rule out a rate difference.

Weak points

  • The fork's edit wording is measured once, on eight turn ends.
  • The mark-and-reread placement is subtle, though three review rounds went through it.
  • Outside <pre>, a line break counts as a space, so text styled white-space: pre could lose one.
  • Leaf keeps no record of what it passed on, so after a compaction drops a finding's line it can come back once.

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

The fork Leaf makes at each Claude Code turn end reads its questions from
an f-string in `src/leaf/clerk.py`. Max asked for them as prose in the
skill, which is easier to review and to watch change. This adds
`skills/leaf/references/turn-end-check.md` with the shipped question
(asks waiting on the user, in the thread-and-step form on the
on-me-paved-road branch) and the three he picked on 2026-10-31:

- a page behind the work or the conversation;
- an On me item the user answered elsewhere or the work made moot;
- promised or running work no page shows;

plus restating a status line that no longer describes the work. Leaf
writes the asks and the status line itself; the other findings go to the
agent as messages, since only the agent may revise the page or open its
own to-dos.

SKILL.md routes the reference for an agent puzzled by one of the check's
messages. `clerk.py` doesn't read the file yet: wiring it waits for
on-me-paved-road, which rewrites `fork_prompt` and its answer schema, so
the two don't conflict.
…findings

`clerk.fork_prompt` now sends `skills/leaf/references/turn-end-check.md`
verbatim, followed by each page's facts and the answer's form, in place
of the f-string that held the question. The page's facts gain the items
the agent has started, each with its status line, which the status
question needs.

The answer gains `findings` and `status` beside `asks`, and Leaf routes
them as the user split them on 2026-10-31:

- asks go On me as before;
- a status line is restated as the agent's own start of the item, but
  only while the turn's end hasn't retired the line, which after a turn
  means the session works on in the background. A start written after a
  turn that left nothing running would read as the agent at work for the
  working grace;
- `stale`, `settled` and `unshown` findings reach the agent as queued
  lines at its next step, with the fork's summary, the turn it read and
  the words it rests on. They still reach it once another turn has
  opened; only records keep the drop.

The clerk's header rewrites the 2026-10-29 record that rejected an
advisor, since findings the agent acts on reverse it for those alone.
How it works lists the new checks and says who acts on each. The clerk
record's description, and the hooks module's debug line, now count
records and lines rather than asks.
… name a finding's turn by whether one has opened since

A refusal partway through a page's asks left the records before it on
the page without telling the agent; each written record now queues its
line whatever stops the rest. A finding's line said when the fork's
turn opened, a time the agent can't match to anything; it now says
whether the user has spoken since. A started update in an untitled
thread reads as the replay measured it.
…oop at it

Replaying the draft on 21 recorded turn ends three times each
(REPORT4.md) kept the asks at 63 of 63 and found the out-of-date and
unshown-work questions precise, with failures where the fork hedged
about what a page might say, named a chat reply as stale, reported the
agent's own wait loops as unshown work, and wrote questions past four
sentences. The wording for each changed, and a replay of the cases that
failed (fork5.py) cleared those findings at the cost of one hedged but
true one, losing no ask. "Name every one" did nothing measurable and
stays out.

conversation-loop.md, which owns the On lists, now says the check also
passes the agent what else it found, and points at the reference.
The user chose to leave them out until a session shows a started
item's line going stale while its work runs in the background. The
fork is good at them: replayed with each started line swapped for one
the conversation shows is over (fork6.py), it restated 15 of 15, and
it left all 9 runs with current lines alone. But no line in the 21
recorded turn ends had gone stale, and a start Leaf writes after the
turn closes keeps the page reading working for the working grace after
the background work stops, since activity._start_age dates a start's
hold by when it was written rather than by the turn it names.

The answer loses `status`, the clerk loses `_restate` and its test,
and the reference and How it works drop the status-line check. The
fork still sees the items the page shows started, as work under way
for the unshown-work question.
The user asked that the fork implement Leaf's standard policy rather
than a rule of its own: whether a suggested follow-up goes On me is the
On me rule's question, not the fork's. The asks section restated that
rule in its own words, so the two could drift. Leaf now sends the fork
the rule as the agent reads it, the paragraph that opens
conversation-loop.md's "The On lists" (`clerk.on_me_rule`), and the
asks section names what that rule puts On me.

Replayed once on the eight turn ends with labelled asks and four clean
ones (fork9.py), it named the same asks as the earlier wording: all 21
labelled asks, and nothing at the clean turn ends.
…store

`projection.logged_words` is what the log in force changes in a page's words: the
outcome each decided suggestion stands under, each body the user rewrote, and the
children their actions created. `PageReading.passages()` reads the page under it, as
the user reads it. `leaf thread create` captures against it, the render gate's
verbatim reading uses `logged_words`, and the to-do seat check in work.py reads
`passages()`. That check didn't pass the created children before, so a widget among
them now reads as `thread create` reads it.

`publishing.replaced_authored_files` installs replacement authored inputs for a block
that checks and publishes them, and restores the previous inputs if the write or the
block raises. `stamp --replace` uses it, and so does the clerk's next change.
The user asked (2026-10-31) that the fork make small fixes itself, such as a lede
still saying work is running, and tell the agent what it changed, so the agent keeps
control. That reverses, for fixes of a few words, the 10-29 rejection of a clerk that
rewrites the page; the clerk.py header records it.

The fork now reads each page's words as the user reads them, a block to a line
(`page_text`, using the new `Passages.breaks`), and a stale finding may carry an
`edit`: the page's words and their replacement. `edit` is optional in the answer's
schema, since a fork that leaves it off another kind of finding would otherwise lose
its whole answer. Leaf makes the fix only while no turn has opened since the fork
read the conversation, and only where the page shows the words once. It swaps just
the words that change, at the place the user reads them, keeping the source's
whitespace between them, checks the page then reads as asked with as many blocks,
and publishes it as an agent's save is checked, restoring the source if that check
fails or raises. The agent's line gives the old and new words. A fix Leaf can't place,
or that would drop a line break among the changed words, reaches the agent as the
finding alone.

Where the words stand is the passage reading's answer, not a pattern's. A first
version searched the source for the words, and a review found it changing a
`<title>`, a script string, a stylesheet, a comment, the "30" in "2030" and a draft's
hidden authored body, while telling the agent it had changed the visible words.
`_place` puts a private-use character neither the source nor the reading holds just
before each place the source may write the changing words (in text, or in the value
of an attribute a widget shows), reads the marked page, and takes the mark that
stands where the user reads them. A second review found the whitespace and mark
collisions the current version handles. Tests cover each of those cases, and
flipping back to "first match, no reading check" fails six of the first set.

Measured: replaying fork8's 26 edits through `fixed_source` on their pages' sources
(`~/.tmp/leaf.agent-channels/replay/place8.py`): 24 land where the user reads them,
and 2, whose changing words cross a link or a code span, are refused. None lands
anywhere else. That replay reads each page with its own registry and no log changes,
and doesn't run the save's check. The fork8 replay itself showed the fork its own
block-per-line text, which Leaf's text blocks match closely, but not this exact
rendering.
A third review found an insertion beside a line break in a `<pre>` landing on the
wrong line: "build make" → "build --fast make" in `make build\nmake deploy` attached
the flag to the second command, and the reading's check passed it, since collapsed
text can't show a line. In a `<pre>`, a fix that changes how many words stand among
or beside a line break is now refused; outside one, a line break is a space, so a
fix may drop the wrap the source had there. That replaces the rule refusing any fix
that dropped a line break, wherever it stood.

Also from that review: a place in an `x-says` value is found by bisecting the sorted
values, which took a page with 3,000 tips from 1.13 s to 0.15 s per fix, and a word
beside `_` emphasis counts as whole. The fork8 replay through `fixed_source` still
makes 24 of its 26 edits.
# Conflicts:
#	build/browser/protocol-baseline.json
#	src/leaf/clerk.py
#	src/leaf/hook_transport.py
Each finding reaches the agent as hook context at its next step, so it sits in the
conversation every later fork reads. Without a word on it, the fork named an
unchanged stale lede again at each turn end: replaying the two turn ends after the
line was delivered, whose agent left the lede alone, three times each, it named it
again in 6 of 6 runs. With this sentence it left it out in 6 of 6, and kept the
other findings, missing one of them in 1 of 6 runs.

Leaf keeps no record of what it passed on, so after a compaction drops the earlier
line, the finding can come back once. Max chose that over repeating a finding until
the page changes.
leaf-agent
leaf-agent previously approved these changes Nov 1, 2026
…ks for a command

`runs` walks the session pane's descendants for the user's sleep command. A child
exiting during that walk makes macOS refuse its arguments (`sysctl(KERN_PROCARGS2)`
returns EINVAL), which psutil raises as AccessDenied, not NoSuchProcess, so the
journey died in `mid-turn` with a traceback instead of checking the step. Skip that
process as an exited one.
leaf-agent
leaf-agent previously approved these changes Nov 1, 2026
Claude Code keeps no copy of a `$.model.fork` exchange: a journey session's home,
whose clerk forked at every turn end, holds the prompt nowhere, and its debug log
keeps only each fork's token counts. So nothing could say what a fork named or how
well it judged. In the claude-code journey the clerk dropped asks at most turn ends,
since a turn had opened, and what they were was lost.

Each page the session holds now gets a `turn_end_check` diagnostics record per
fork, as a fork reply's `fork_reply` record does: what the fork named on that page,
verbatim, the records Leaf wrote, the passages it changed, how many lines it told
the agent, why it wrote no records where it didn't, and the fork's usage and time.
A page where the fork found nothing gets one too, so an audit has the clean turn
ends, and so does a fork that gave no answer or one `ANSWER` refuses, with its
reason. The hooks module now hands Leaf the fork's usage and time, and a fork that
gave no answer, rather than only logging it.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
A replay of a fork cuts the session's transcript where the fork read it and runs
the model and effort the fork ran with, but neither the clerk's `turn_end_check`
nor a thread reply's `fork_reply` record said where that was, so a replay inferred
the cut from the time and assumed the effort.

`$.model.fork` resends the main thread's last request, so the hooks module keeps
that request as each main-thread `turn.step` names it, its model, its effort and
how many messages it carries, and the newest row the main thread stored, the
transcript's own id from `session.append`. Both forks hand it to Leaf as `request`,
and both records keep it. A subagent's steps and rows don't move it.

The test driver now runs a streaming event's hook as the async generator Claude
Code's declarations require of it.
`row`, the newest row stored by the time of the fork, can postdate the request
`$.model.fork` resends, so the session that built the thread-reply fork proposed
naming the row stored as the request went out instead. But a turn-end fork reads
the turn's final reply, stored after that request went out: in a claude-code
journey run today, the words an ask quoted stood in one transcript row, the turn's
final reply, and `row` was the turn_duration notice after it. Mid-tool, where an
in-flight tool_use follows the request, which row the fork reads is unmeasured.

So the request keeps both: `sent`, the newest row as the last main-thread request
went out, and `row`, the newest by the time of the fork. A replay cuts at whichever
the live notes show the fork read.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
The fork reads the conversation as it would next go out: with a tool call running,
to the row stored as the last request went out (`sent`), since the call's tool_use
can't go out before its result; otherwise to the newest row (`row`), a turn's final
reply included. notes/fork-replies.md measured both, and a turn-end ask in today's
claude-code journey quoted only the final reply. The hooks module's `request` says
so once; the clerk and forks headers point to it, so a replay applies the rule
rather than waiting on live notes.
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
max-sixty added a commit that referenced this pull request Nov 3, 2026
#5066)

A `leaf-dev journey claude-code` run on #4900 failed its `dropped` step
with two "Leaf: new input" wakes 90 ms apart for one comment (`{'Stop
hook wake': 2, 'empty': 1}`). Both rows were background-watch wakes, so
admission's nudge played no part. The run's transcript, Claude Code's
debug log and the page's watch records show the sequence:

- The Stop hook's watch woke the session for the comment.
- Escape cancelled that wake's prompt while another prompt hook slept,
as the step intends, after Leaf's prompt hook had handed the comment
over.
- Claude Code queued the wake again and submitted it 46 ms after the
Escape under a new prompt id. Its prompt hook handed the comment over
again, and a turn answered it.
- Around the Escape, the dropped prompt's own watch, which Claude Code's
prompt registration starts and which outlives Escape, made a pass,
prompted by the thread title the server wrote 55 ms before the Escape.
It read Claude Code's `idle`, took the dropped turn for one Escape had
stopped, and woke the session too. Claude Code queued that wake into the
answering turn and attached it at the next tool boundary, where it had
nothing to hand over.

## The change

`later_turn_wakes` read `idle` as the end of a turn that nothing
follows. That holds for a turn Escape stops while it runs. It doesn't
hold for a queued prompt, such as a wake, that Escape drops during its
prompt hooks: Claude Code submits that prompt again, and its hooks start
the watch that takes over. A watch now treats such an ending as it
already treated a Stop's: it wakes only if no successor has come within
the hooks' time (20 s).

Claude Code's transcript tells the two endings apart. It writes a
prompt's record, which names its `promptId`, only once the prompt's
hooks let it through, and writes nothing of a dropped prompt
(`harness.claude_code_prompt_dropped`, behind the new
`Harness.prompt_dropped`). The watch now receives the hook payload,
which names the transcript.

Every wake is kept. A typed prompt Escape drops goes back to the
composer and is not submitted again (probed on 2.1.316), so its watch
still wakes the session for what the dropped prompt was handed: about 20
s after the Escape rather than at its next look within 5 s, or not at
all if the user sends the prompt again first, whose own hook hands the
input over. A payload naming no transcript, or a transcript that can't
be read, reads as not dropped and keeps the immediate wake.

## Evidence

-
`test_a_prompt_escape_dropped_is_handed_its_input_again_after_one_wake`
replaces the test that asserted the dropped prompt's watch wakes. Its
`[queued]` case reproduces the journey's interleaving, a title write
between the Escape and the resubmission, and fails without the new rule
("the dropped prompt's watch woke the session"); `[typed]` checks the
wake still comes once no successor does.
- Focused suites pass: `test_wait.py`, `test_hooks.py`,
`test_hook_registration.py`, the layer contract's route test and
`test_interact_pi.py` (134 passed).
- `leaf-dev journey claude-code` passed all 12 steps twice with no empty
wake or notice, and `--forks` passed its 6 steps. In those runs no
dropped prompt's watch looked between the Escape and the resubmission,
so they show the change breaks no step (`woken`, whose Escape stops a
running turn, was still picked up 3.0 s after it) rather than
reproducing the race; the `[queued]` test does that.

## Not changed

Admission's nudge can still interleave with a Stop hook's watch where no
watch holds the session's lease at a Stop, as after the turn that first
claims a page: input admitted between the Stop hook closing the turn and
the Stop's watch taking the lease is nudged, and the watch then wakes
for it too. A scratch model test reproduced it; no run has shown it. The
watch can't skip its wake on the nudge's mark (`messaged_ending`)
without risking a lost wake, since a nudge that lands starts a turn only
where `Harness.input_wakes` says so, which takes `crossSessionInbound:
accept` in the user's settings.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	dev/leaf_dev/journey_claude_code.py
#	src/leaf/hook_transport.py
#	tests/process/test_interact_claude_code_module.py
The last two callers that assembled the log's rewrites, retirements and created
children by hand now take them from `projection.logged_words`, the one reading of a
page's words with the log applied. No behavior changes.
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
`leaf-dev eval 'turn-end-check*' 'fork-reply*' --harness claude-code --base`
now replays both Claude Code forks, the clerk's turn-end check and a held
thread's reply, on short constructed conversations: twelve turn-end cases,
each decision the prompt asks about with a guardrail whose right answer
names nothing, and seven reply cases, two to answer and five to hand over.

The executor (`dev/leaf_dev/fork_eval.py`) builds each case's page and
session with the arm's own Leaf, asks the arm's `leaf hook --fork` for the
prompt as the hooks module does, renders the conversation as a Claude Code
transcript and resumes it once with `claude -p --tools ""` in a fresh home
and cwd, then hands the answer back to the arm's Leaf, so a refused answer
fails and a stale passage's edit lands through `clerk.fixed_source`.
Turn-end items are matched to labels by the words they rest on; the text
judge reads the items no label settles. A background command's transcript
record carries no task id, so the resumed fork hears no stopped-task notice
and the prompt needs no replay-only sentence.

First run, Opus 5.5 at medium effort: the candidate passed 52 of 57 (3
repeats); the two failing cases had a case bug (a settled-open fixture that
contradicted its own question) and a scorer bug (a finding of another kind
on the labelled words marked as a repeat), both fixed and rerun 6 of 6. On
main, whose clerk has no findings, the four finding cases fail 0 of 2 each
and the ask and guardrail cases pass. Forks cost a median $0.04 each,
priced from usage.

The clerk's and forks' headers name the command for scoring a prompt change.
The fork eval scored items by re-reading the fork's answer itself, so an
item named for a page the session doesn't hold still counted, a reply Leaf
refused counted as handed over, and an edit counted as landed whenever the
changed span sat inside the labelled words ("2" -> "3" passed, a right edit
whose suffix `_changed` trims failed). It now scores what the arm's Leaf
took: the asks it wrote, the findings its `turn_end_check` note lists for a
held page, and the outcome its `fork_reply` note records after the answer
goes through `forks.take`, with the lane held until then. An edit lands when
Leaf changed the page and the page, read as the user reads it, no longer
shows the labelled words. Every item and change goes to the judge, which now
also reads whether a question or step says the right thing; the reply judge
fails stated observations the conversation lacks and allows explanations
consistent with it. Labels match on an ask's title and text, and each
guardrail shares its words with its positive case.

`forks.take` now notes why it refused an answer (`refused`), as the clerk's
notes do, so an audit can tell a refusal from the fork's own hand-over.

The fork keeps Claude Code's tool definitions, as a live fork resends the
session's: `claude_child` takes a permission mode, don't-ask mode denies
what needs permission, tools that reach outside the fork's directory are
denied by name, `--max-turns 1` turns any call into a failed case, and
`--exclude-dynamic-system-prompt-sections` keeps the prefix cached across
cases. A probe run cost $0.07-0.09 a fork. `total_cost_usd` prices only the
fork but bills hour-long cache writes at the five-minute rate, so `price()`
stays.

Cases: a step guardrail (`ask-step-done`); the shown `search/cache.py` edit
checks the flag the page and agent name; the fallback plan is a paragraph
and three steps, so removing it needs more than an edit; the unshown case's
lede no longer says production is next; the passed-on Leaf line is rendered
by the arm's `clerk._found`. The per-case model and effort and the YAML's
model are gone (author model, medium effort), and the arm's Python runs one
way. One broad smoke test replaces the helper test.

The previous commit's message should have said the four finding cases pass
0 of 2 on main.
Two fixture contradictions drew fair findings from the fork and judge
failures that weren't the prompt's. The cache page's lede said the search
API caches results with LRU while the shown change serves only where the
`search.cache` flag is `lru`; it now says so. And the pages and the agent
said TTL "keeps results within four minutes" where the simulation reported
a four-minute p95 with a 300-second TTL; they now say every result is under
five minutes old.

On the candidate the five ask cases then passed 4 of 5; `ask-step-done`
failed on a finding that the page omits where the flag is on, which the
prompt's stale passages don't cover.
A reply whose markup Leaf refused was handed over without `refused` in the
`fork_reply` note, so it passed a hand-over case; `forks._post` now notes
why, as `take` does for a refused answer.

The fork's tools are now blocked by one `PreToolUse` hook in its settings,
matching every tool, in place of don't-ask mode and a hand-kept deny list:
every call is refused, read-only ones included, and all 25 definitions stay
in the request (probed with a prompt asking for a Bash and a Read call).
`claude_child` loses the permission parameter it gained for don't-ask mode.
A fork that calls a tool now fails each check rather than raising a provider
error, and prices are keyed by model, failing on one they lack.

`ask-step-done` measured two decisions; the agent now writes the staging
flag onto the page, so it measures only the step guardrail, and the step's
words take `search cache`, so a step titled by its effect matches. The new
`stale-omission` case keeps the old conversation: the work adds a fact the
page doesn't mention and nothing contradicts, so the right answer is no
finding.
The reply judge fails a reply that says all ten failures were the KeyError
when the output shows one, but the agent's own reply in the conversation
already says so, so a fork restating it failed for the fixture's gap. The
output now lists each failure. Not rerun: the round's budget was spent.
A run whose fork called a tool, or whose answer Leaf refused, leaves no text
for the judge, and the items rubric's fallback, "No items and no changes.",
passed it, so the items-right column read pass on runs that fail. Both
rubrics now fall back to "The fork gave no usable answer.", which they
fail. Checked through Promptfoo's judge path on a stand-in run with no
answer: items-right failed.
# Conflicts:
#	evals/README.md
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
The fork named a page stale for not yet mentioning a fact the work added, and gave an
edit adding the fact: the `stale-omission` case failed in 8 of 8 runs. Adding to a page
is the agent's call, so the stale bullet now says a page that doesn't yet mention
something isn't stale. With the sentence the case passed 5 of 5, and the other
turn-end cases still pass.
leaf-agent
leaf-agent previously approved these changes Nov 4, 2026
# Conflicts:
#	src/leaf/passages.py
leaf-agent
leaf-agent previously approved these changes Nov 4, 2026
# Conflicts:
#	src/leaf/clerk.py
#	tests/model/test_clerk.py
#	tests/process/test_interact_claude_code_module.py
@max-sixty
max-sixty merged commit 52c7000 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the fork-questions-prose branch November 4, 2026 07:47
max-sixty added a commit that referenced this pull request Nov 4, 2026
)

Everything On me is now answered by the widget or thread that asks it.
Leaf no longer puts a to-do on the user with a Done of its own, so a
widget is never given an answer it doesn't declare. A step such as
trying a build is asked in a thread, and the user's reply or a 👍 answers
it.

Before, `leaf task create <subject> --on user` put a to-do on the user
on any thread, element or widget that had no open obligation, and the
turn-end check did the same for each step it found. On me then offered
that item a generic Done: on an `lf-code` block or a paragraph, the only
answer was a check mark the widget never offered. This reverses the
user's 2026-10 choice to keep such to-dos for steps.

## The rule, and where it lives

- **On me holds obligations only.** Each comes from a widget that
declares `x-awaits` (any widget: bundled, from a package or the page's
own), an agent message sent with `--obligation`, or an update to send
again. On the page, each is answered only through its source: the
widget's declared actions, or a reply or settling reaction in the
thread. A multi-select `lf-options` keeps its Done, since that is the
widget's own control. An answer the user gives elsewhere, such as in
chat, the agent still records with `leaf task end`.
- **Content that asks nothing** (a paragraph, a chart) and a step the
user takes get a thread whose message carries `--obligation`.
- The rule is stated in `obligations.py`'s header, the `x-awaits` key in
`browser/registry.json`, How it works ("On me and the agent's list",
with a new paragraph on what can ask), `conversation-loop.md` ("The On
lists", where the to-do row becomes an "action the user takes" row asked
in a thread) and `authoring-on-me.md`. `todos.py`'s header records the
decision.

## What goes

- **Protocol 39 → 40.** A `todo` event has no `owner`; `todo_end` is the
agent's alone, is no longer browser-postable or undoable, and its
handling clause for the user's Done is gone. A Leaf at 39 would misread
a 40 log and the reverse, hence the bump. (`main` took 38 → 39 for an
undoable edit in #5221.)
- **Model.** `user_task_obligations`, the `todo` obligation source,
`--on`, the `duplicate-obligation`/`users-question`/`agents-todo`
refusals, and `owner` on served to-dos. `queues.on_user` rows are
`widget`, `message` or `update`; to-do rows stay on On <agent>.
- **Clerk.** The fork's answer has no `kind`. Every ask, a step
included, is a thread question whose message says what to do and asks
for a reply. `turn-end-check.md` (#4900) asks the fork that way, and the
fork eval (`dev/leaf_dev/fork_eval.py`,
`evals/workflows/fork_eval.yaml`) labels the step cases as questions.
- **Browser.** The To-do Done on panel rows, On me cards and a thread's
head; the `x` key and its "On a to-do waiting on me" stance;
`queueActions.done` (public package API); local `todo_end` folding and
its undo words; `offers`; `showOnMe`, which #5223 had extended to land
`m` on a page to-do's card; the `done` action face and `checked` icon. A
stance's exit is always Close's ✕, since no stance names another action
now. The margin card's grid loses the row the to-do header held;
`leaf-dev probe review-a-plan --do drive:card-by-keyboard --base`
measures identical child boxes in both arms.

## A cost this keeps

A reply answers a step's question whatever it says. A to-do stayed open
until Done, so "where do I get the build?" left the step On me; now that
reply answers the question, and a plan step naming it reads done until
the agent asks again with `--obligation` and points the step at the new
question. `conversation-loop.md` tells the agent to ask again, and the
clerk's header records the trade.

## Tests and evals

Behavior changed on purpose:

- `todo-on-the-user` becomes `step-on-the-user-takes-a-thread` (pass: a
thread message with `--obligation`).
- `closeout-asks-take-their-route` now requires the `/reload-plugins`
step as a thread question.
- `on-lists-read-todo-records` puts the phone build on the user as a
question.
- Tests that protected to-dos on the user (their Done, `x`, undo of
Done, the To-do placeholder, the thread-head line, and #5223's page
to-do on its card) are deleted. Tests that used one as a convenient On
me item now use a question in a thread.

On the candidate tree (Claude Code, 2 runs each):
`step-on-the-user-takes-a-thread` 2/2, `closeout-asks-take-their-route`
2/2, `on-lists-read-todo-records` 1/2. The failed run listed both user
items correctly and failed on the agent side, doubting that the
benchmark re-run was under way. No base arm was run: the base
instructions route a step through `leaf task create --on user`, which
these rubrics now fail by construction.

`pnpm run check:browser`, `pnpm run test:runtime` (775) and the model
selections covering to-dos, the clerk, obligations, hooks, undo and the
protocol pass, as do the resolved browser tests and #5232's
Back-from-an-obligation tests.
`test_an_item_arriving_above_takes_its_walk_place_and_moves_no_card_read`
fails here and on `main` alike since #5318: the card read moves down by
the new card's height (116px on `main`, 95px here), so the list no
longer holds its place when an item arrives above.

> _This was written by Claude Code on behalf of max-sixty_
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