Skip to content

Fix Codex turn tracking and atomic claim discovery - #2046

Merged
max-sixty merged 6 commits into
mainfrom
codex/fix-feedback-turn-discovery
Oct 8, 2026
Merged

max-sixty merged 6 commits into
mainfrom
codex/fix-feedback-turn-discovery

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Codex can resume an interrupted task with empty input without running UserPromptSubmit. Leaf previously retained the closed turn and queued new feedback for a later turn. Hooks and the queue adapter now reconcile ordered native transcript starts and endings through the existing session lifecycle owner, preserving provider identity and source timestamps while rejecting stale or foreign evidence.

Codex's tool and Stop hooks share the existing delivery reservation. A resume that immediately finishes can therefore pick up feedback in its resumed turn. Pointer reads confirm only the exact reserved turn, and the queue respects an active hook reservation independently of prior tool-hook capability. Lost page ownership keeps collected deliveries inactive.

App Server notifications could also reopen a completed predecessor after a newer turn ended. The observer now retains lightweight terminal identities after retiring live folds and limits ordinary item updates to the current lifecycle. This rejects late background output, stale running snapshots, and unresolved historical folds that no longer own live authority, while historical delivery completion can still settle its exact answer.

Claim publication also committed ownership before its discovery locator was ready. Prepare discovery first and commit ownership once in the canonical payload; named watches follow prepared targets and retain changes that arrive during subscription registration. Failed preparation preserves the previous owner, and resident writers keep the same canonical path.

Regression coverage exercises empty-input resume through either first hook, exact-turn receipt and queue reservation, partial transcript tails, cold and incremental readings, late callbacks, failed claim publication, and native watcher ordering. The real Codex verifier exercises an empty-input resume whose first boundary is Stop. All 161 targeted tests and configured pre-commit checks pass. Native Codex journeys pass on the integrated fix through both App Server and queue transports, including empty-input resume and restart recovery. Integrated native Claude Code, its hooks module, and Pi journeys pass, including held-input interruption recovery. CI runs the complete landing gates. The existing 15-minute quiet-turn fallback remains a separate limit.

This was written by Codex on behalf of max-sixty

Observe native empty-input resume starts through the shared lifecycle owner so feedback enters the resumed turn instead of the idle queue. Prepare discovery before committing ownership, and watch prepared canonical targets through registration races. Tests cover partial and stale transcript evidence, failed claim preparation, and native subscription ordering.
leaf-agent
leaf-agent previously approved these changes Oct 8, 2026
Use the existing hook delivery reservation at both tool and Stop boundaries. Keep between-step capability separate from exact-turn reservation and receipt, so a first-Stop offer is accepted in its turn and cannot be stolen by the idle queue. Inactive ownership still leaves collected records untouched.

Regression coverage includes first-Stop resume, no prior tool-hook proof, stale pointer reads, and ownership transfer. Queue recovery fixtures now end the offered turn before handing its unread pointer to the queue; generic Stop policy races run under their claimed Claude Code harness.
Skip the interrupted test command rather than banning every tool: a delivery pointer must still be read to prove same-turn pickup. The retained native transcript confirmed Stop injected the pointer, but the blanket tool ban confounded the acceptance check.
leaf-agent
leaf-agent previously approved these changes Oct 8, 2026
Late background tool output can arrive after a newer turn has completed. Retain lightweight provider terminal identities after retiring live folds, and allow ordinary item notifications to update only a fold matching the subscription epoch. Historical folds still settle their exact immutable delivery without acquiring live authority.

Regression cases cover terminal predecessors, stale running snapshots and starts, closed lifecycle initialization, unloaded historical items, unknown background output, and a superseded fold retained after a missed completion. Integration preserves the accepted Pi TurnStart and canonical receipt-based watcher changes from main.
@max-sixty max-sixty changed the title Fix resumed Codex feedback and atomic claim discovery Fix Codex turn tracking and atomic claim discovery Oct 8, 2026
leaf-agent
leaf-agent previously approved these changes Oct 8, 2026
@max-sixty
max-sixty merged commit 7e1ba42 into main Oct 8, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/fix-feedback-turn-discovery branch October 8, 2026 10:26
max-sixty added a commit that referenced this pull request Oct 9, 2026
…wser user end (#2144)

`leaf-dev journey TARGET` is now the one command that runs a real
session of a harness or the website and checks and times what the user's
comments get. `verify-claude-code-task`, `verify-codex-task` and
`verify-pi-task` are folded into it and deleted.

There were three launchers for "a real session of harness X": the
journey's headless `claude -p`, the Claude Code tmux driver, and
`codex_task.Task`. The journey timed one comment through a browser but
ran Claude Code headless, unlike a user's session. The verifiers ran the
realistic sessions and checked several moments, but timed nothing per
comment. Now each target runs its most realistic session, and every step
is both checked and timed.

### Targets

- `claude-code`: interactive Claude Code in tmux; `--hooks-module` turns
on the plugin's hooks module.
- `codex-app-server` and `codex-queue`: a Codex task on each transport.
The queue transport is the desktop app's route and had no journey
before. `--preview` keeps `verify-codex-task`'s preview checks.
- `pi`: a real Pi session.
- `website-adapter` (was `local`): leaf.page's adapter on this host.
- `website-worker` (was `wrangler`): the built site through the local
Worker and a page container. The rename covers `verify-site`, `ci.yaml`,
`publish-site.yaml`, `AGENTS.md` and the docs.
- Or a website origin.

### The user's end: HTTP or `--browser`

One axis applies to every step:

- **HTTP**, the default for harness targets, starts no browser. Each
comment is posted as the page's tab posts one, and checked and timed
from the event log on the page server's clock: picked up (`opened`,
separate from `queued` per #2080), work started, progress, published,
titled, replied. Across the runs below, a browser adds only 0.1–0.6 s to
a harness reply.
- **`--browser`**, the only end for website targets, is the whole
unmocked journey. Every comment is typed as a user types it: a page
comment in the banner's comment card, an anchored one on its selected
passage. The page records when each reply showed: its message in view,
its thread's row, or its news notice once the page has applied the
reply. The release ask's reload is checked and profiled.

Both ends share one `User` and one release check (`run_journey`): an end
only sends the ask, and the shared code waits on the turn, the title and
the answer.

### What each harness checks

Every check the verifiers made still runs:

- each comment is answered once;
- a comment sent during a turn is picked up in it (Codex: on the queue
transport);
- Escape closes the turn, and a comment after it is answered;
- restart and resume recover (Codex: #2046's Stop-first resume);
- quitting ends the claim.

Claude Code's permission prompts are answered and recorded on the step's
sample. Detection of the user's command is scoped to the run's own tmux
pane, so journeys can run side by side.

### Where to look

- `dev/leaf_dev/journey.py`: targets, the two ends, the shared release
check, step samples, `journey-chart`.
- `dev/leaf_dev/journey_claude_code.py`, `journey_codex.py`,
`journey_pi.py`: each harness's session and steps (from the verifiers).
- `dev/leaf_dev/verify_site_browser.js`: the page's record of when each
reply showed.
- `tests/test_journey.py`: step readings at both ends, prompt matching,
transcript and Pi trace parsing, a no-Chrome check over HTTP.

### Runs

Every target passed a real run, one at a time:

- over HTTP: claude-code, codex-app-server, codex-queue and pi;
- with `--browser`: claude-code, codex-queue and website-adapter.

`website-worker` was not run locally (no Docker); CI's `verify-site
website-worker` covers it.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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