Skip to content

Write each journey step more than one harness takes once, over Terminal - #5255

Merged
max-sixty merged 4 commits into
mainfrom
agent-a54dd35d476e17932
Nov 3, 2026
Merged

max-sixty merged 4 commits into
mainfrom
agent-a54dd35d476e17932

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf-dev journey wrote each harness step's contract once but implemented it per harness: mid-turn three times, escape and quit twice, setup three times, each on top of the shared Terminal base class. This puts those steps, and release's wait for the session to settle, on Terminal once. Each harness module now supplies only its primitives (session, say, work, hear, idle, listening, and where it has them press_escape and leave) and its own steps. By a line diff, the change removes 414 lines of code and adds 293 (net −121), and adds 29 lines of docstring prose net, mostly the shared steps' contracts.

How the tooling behaves now

  • Terminal.setup, release, mid_turn, escape and quit (dev/leaf_dev/commands/journey.py) own those steps' checks. The harness modules call them in their own order and add only what is particular to their harness: Claude Code's PostToolBatch check after mid-turn, Pi's requirement that its abort closes the claim's turn, and the Codex queue's check that the mid-turn comment is answered before the user's turn's final response, now a hook (on_final) around the shared step.
  • Terminal.user_turn types the user's own turn and returns the turn the page's claim opened for it, replacing the work()-then-read-the-claim pair the steps repeated. review_scenario gains the page readings every module open-coded: claimed, picked_up (the turns whose opened pickup took a comment) and activity.
  • Terminal.titled formats the page server's title record one way for every harness, where Codex and Pi each had their own.
  • journey_chart.TARGET_NAMES is gone: each HARNESS_TARGETS entry is a HarnessTarget carrying its chart title, harness and transport.
  • ClaudeCode takes its session id at construction, so claude-code-session passes --session-id as the journey does and sets its page up through the shared setup step, rather than learning the id from the page's claim.

Checks that changed

One implementation per step means one set of checks per step. Where the harnesses' copies disagreed, the shared step keeps the stronger check, and every target passes it:

  • Claude Code's setup, release, mid-turn and escape now wait for the session to stay idle through QUIET (10 s), as Codex and Pi already did. That adds five 10 s waits to a run; steps[].seconds grow, and milestones and reply breakdowns don't change.
  • mid-turn requires, on every harness, that the comment is picked up in the user's turn, answered before that turn ends, and starts no turn of its own. Claude Code and Codex App Server gain the last two; App Server's kept runs, three before this branch and its run here, all show the comment entering the user's turn. Pi's "no second run" is now read from the page's claim rather than Pi's run counter. App Server's check that the claim names the user's turn by App Server's id now follows from the claim's turn being unchanged and every step's end-of-step check, rather than a poll.
  • escape, on Claude Code and Pi, requires the session to stay idle through QUIET with a watch on its pages, no turn to open, and the page's status to read listening. It returns whether the claim's turn stayed open: Pi requires it closed, as before; Claude Code, where Escape runs no Stop hook, prints it.

Runs

Each target this touches passed leaf-dev journey on this branch, over HTTP, case waiting: claude-code (12 steps) and codex-queue (8) on the first commit, pi (6) and codex-app-server (8) on both.

The claude-code run is also the real run #5238 left owed. Its kept sample carries comment.milestones from response_times.page_timings, and journey-chart charts it: the release ask was picked up after 0.41 s, titled after 2.47 s, its work started after 16.1 s, its revision published after 21.5 s and it was answered after 28.9 s. The reply's breakdown puts 2.5 s of the 28.9 s on Leaf (delivery 0.4 s, commands 1.0 s, hooks 1.2 s) and 26.0 s on the model. The fix commit's only Claude Code change, escape's new check that no turn opens after Escape, reads the same claim that run's escape line printed as the turn staying open.

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

…turn entry on every harness

Escape now requires that no turn opens after it with no new input (the claim's
turn is unchanged), which every harness holds, and returns whether the claim's
turn stayed open: Pi requires it closed, as before the shared step, and Claude
Code prints it. Mid-turn requires the comment to enter the user's turn on every
harness, Codex App Server included, whose kept runs all show it doing so; that
also restores the App Server check that the claim names the user's turn. The
Codex queue's final-response hook reads the comment's id only once it exists.
claude-code-session sets up its page through the shared setup step.
@max-sixty
max-sixty merged commit e6aafd0 into main Nov 3, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-a54dd35d476e17932 branch November 3, 2026 22:13
max-sixty added a commit that referenced this pull request Nov 4, 2026
…check every harness's steps with one set of checks (#5265)

`leaf-dev journey` computed each reply's breakdown twice, and wrote its
checks between steps once per harness. This leaves one of each,
finishing what #5238 (milestones through `response_times.page_timings`)
and #5255 (shared steps on `Terminal`) left.

## How the tooling behaves now

- **One reply breakdown.** `response_times.page_timings` takes a reader
of the answering session's record (`records`). By default it reads the
Claude Code transcript on this machine (`transcript_of`), as `leaf-dev
response-times` always has. The journey passes its terminal's record
when it builds the sample and keeps each row's `reply`. `User.commands`,
the `commands` closure in `user_at` and the journey's own
`reply_breakdown` call are gone. The per-step timing lines read no
session record (`no_record`). They used to parse the transcript at every
step, and cache its first read for the rest of the run, so later reads
were stale.
- **One rule for a fork's answer.** `page_timings` reads `fork_reply`
records. An input a fork of the conversation answered gets no reply
breakdown, pickup wait or `leaf_commands_s`, since the session spent
nothing on it. The journey used to apply this rule to the breakdown
alone. `response-times` applied it nowhere: it computed a breakdown
whose delivery ran past the reply, such as a 4 s reply with 20 s of
delivery in the fork test. No page on this machine had a fork reply in
the last two weeks (6 hand-overs only), so `response-times`' numbers
don't move today.
- **One set of checks between steps.** `Terminal.between`
(`dev/leaf_dev/commands/journey.py`) requires what every harness must
hold after a step. Every comment the steps have named has one answer and
a pickup. The claim names the session, with its turn closed. Leaf
listens for the session within 60 s. The page server has titled the
thread of each comment the step named. `Terminal.passed` records a step
after those checks, setup included. Claude Code adds its checks on Stop
hooks, printed deliveries and the rows Leaf puts in the conversation;
Codex adds its checks on the claim's turn, the keyed URL and the
preview. Pi adds nothing.
- **A failed title fails at once.** `Terminal.titled` reads the page
server's `thread_title_failed` record too, so a step whose title failed
stops with the request's error at once, rather than after the 3-minute
title patience with no cause.
- `reply_phases.pickup_wait` now treats a turn start's `origin` as
optional, as the module's record contract says. Codex and Pi records
reach it now, and they carry none.

## Checks that changed

- Codex now requires its adapter to be listening between steps, and
Claude Code requires the page server's title on every comment. Both pass
live (below).
- Pi's listening check now waits up to 60 s, Claude Code's existing
bound, where before it read once.
- Claude Code's setup step runs Claude Code's own checks and keeps its
own `shown` rows, which used to be counted in `release`'s.
- In a sample, `reply` carries `case`, and a comment a fork answered has
`"reply": null` rather than no `reply` key.

## Runs

Each target passed `leaf-dev journey` over HTTP, case `waiting`:
`claude-code` (13 steps), `codex-queue` (8) and `codex-app-server` (8)
at f2be41a, and `pi` (6) at 5eae388, whose difference from f2be41a
is in `response-times` paths a journey without forks doesn't read. The
three also passed before review, at 45354f0 and ed3cc82. The last
commit changes only what `titled` does when the page server's title
fails, checked against a kept run with a failed title. For every run,
each comment's `reply` in the kept sample equals the breakdown the old
path computes from that run's evidence (the terminal's records in
`trace.jsonl`, and the page's log and diagnostics): 12 of 12 for Claude
Code, 7 of 7 for each Codex transport and 4 of 4 for Pi. The 16 earlier
runs kept on this machine (Claude Code and Codex) agree on all 132
comments.

Across these runs the page server titled all 48 comments within 1.3–3.2
s: Haiku on Claude Code, gpt-6-luna on Codex, gpt-6.1-sol on Pi. In the
earlier kept runs, 2 of 27 Claude Code titles failed when `claude -p`
timed out after 60 s on a loaded machine (2026-11-01). The new check
fails a Claude Code journey when that happens.

`dev/tests/model/test_journey.py` and `test_response_times.py` pass. The
fork case now goes through `page_timings`' rule, and fails without it.
The touched product test
(`test_codex_app_server.py::test_a_completed_stream_reply_survives_the_claim_advancing`)
and website test
(`test_website_server.py::test_a_title_written_after_the_reply_is_still_timed`)
pass by node id.

By line, classified with Python's tokenizer: code −225 +213, docstrings
and comments −88 +133, tests −12 +25.

> _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