Repository navigation
Write each journey step more than one harness takes once, over Terminal - #5255
Merged
Merged
Conversation
…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.
… final-response hook is the queue's alone
leaf-agent
approved these changes
Nov 3, 2026
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_
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.
leaf-dev journeywrote each harness step's contract once but implemented it per harness:mid-turnthree times,escapeandquittwice,setupthree times, each on top of the sharedTerminalbase class. This puts those steps, andrelease's wait for the session to settle, onTerminalonce. Each harness module now supplies only its primitives (session,say,work,hear,idle,listening, and where it has thempress_escapeandleave) 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,escapeandquit(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 aftermid-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_turntypes the user's own turn and returns the turn the page's claim opened for it, replacing thework()-then-read-the-claim pair the steps repeated.review_scenariogains the page readings every module open-coded:claimed,picked_up(the turns whose opened pickup took a comment) andactivity.Terminal.titledformats the page server's title record one way for every harness, where Codex and Pi each had their own.journey_chart.TARGET_NAMESis gone: eachHARNESS_TARGETSentry is aHarnessTargetcarrying its chart title, harness and transport.ClaudeCodetakes its session id at construction, soclaude-code-sessionpasses--session-idas the journey does and sets its page up through the sharedsetupstep, 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:
setup,release,mid-turnandescapenow wait for the session to stay idle throughQUIET(10 s), as Codex and Pi already did. That adds five 10 s waits to a run;steps[].secondsgrow, and milestones and reply breakdowns don't change.mid-turnrequires, 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 throughQUIETwith a watch on its pages, no turn to open, and the page's status to readlistening. 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 journeyon this branch, over HTTP, casewaiting:claude-code(12 steps) andcodex-queue(8) on the first commit,pi(6) andcodex-app-server(8) on both.The
claude-coderun is also the real run #5238 left owed. Its kept sample carriescomment.milestonesfromresponse_times.page_timings, andjourney-chartcharts 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'sescapeline printed as the turn staying open.