Skip to content

Write each delivery's handling for the carrier that freezes it - #1068

Merged
max-sixty merged 4 commits into
mainfrom
codex-app-server-terms
Sep 24, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex-app-server-terms

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Each delivery now carries only the instructions for the route that delivers it. Clauses used to state conditions Leaf already settles at freeze time:

  • "Acknowledge … by your host contract's route where it leaves acknowledgement to you"
  • "In a Codex task Leaf observes over App Server, your final message is the reply instead"
  • "If this event's conversation has a null title"

In paired verify_site.py local runs on 2026-09-23, the leaf.page agent ignored those hedges. It invented leaf delivery ack, $LEAF ack and leaf acknowledge, and it posted an early leaf reply.

Clause selection. A clause's when now reads the event's conversation, which is its thread's digest, and the carrier delivering it (wait, queue or app-server), alongside the record and its obligation. Each clause now states one case:

acknowledgement reply
leaf wait leaf wait --ack <delivery-id> leaf reply before other work
Codex queue none (the adapter acknowledges) leaf reply before other work
Codex App Server none the turn's first and final messages

The title clause appears only when the thread has no title. The Markdown line is now its own clause, and every carrier gets it. summary_hint is now read from the digest.

Handling is written at freeze time, not at capture. It is added by freeze_delivery(carrier=…) and offer_delivery(…, carrier). A Codex record collects batches before the adapter knows which transport will offer them. Before this change, a record captured under one transport and offered over the other after a restart told the agent the wrong route. In the App Server → queue direction, nothing posted the "final message" reply.

Watcher route. The preface in codex-watcher.md now tells the page task to skip the leaf wait --ack clause that a forwarded batch carries.

Tests. Behavior that moved:

  • The per-case table (test_each_case_of_an_event_is_told_what_the_snapshot_shows) adds cases for queue, App Server, and titled and untitled threads.
  • The carrier snapshot now freezes the queue route through the adapter's own path. The three carriers now differ.
  • Tests that rebuilt the when input now pass carrier and conversation.
  • The "collecting record without handling" drop test is gone, since collecting records no longer hold handling.
  • I re-recorded the recovery, summary and hosted-delivery snapshots, and the sample delivery in docs/how-it-works.html.

Evidence.

  • The delivery, Codex, website-server and docs suites pass (1273 tests).
  • One local verify_site.py run passed before the merge with Stream an App Server turn's opening message as the start of its reply #1057, whose opening-message rule the App Server clause now follows. The hosted agent ran 2 commands and 1 file edit. It invented no acknowledgement command and posted no early leaf reply. That is one run.

Gaps.

  • There are no paired Claude Code runs yet to check that acknowledgement stays prompt. That check is in TODO.md.
  • An App Server delivery that was already offered keeps its frozen handling if the adapter restarts on the queue. A delivery never changes under its id.
  • ANSWER_ASK_INSTRUCTION, used for Stop-hook and idle refusals, still says "in a Codex task Leaf observes over App Server…".

🤖 Generated with Claude Code

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

max-sixty and others added 4 commits September 23, 2026 17:44
A delivery's handling clauses spelled out conditions Leaf already settles
when it freezes the delivery: "acknowledge by your host contract's route
where it leaves acknowledgement to you", "in a Codex task Leaf observes over
App Server, your final message is the reply instead", "if this event's
conversation has a null title". Paired verify_site runs had the leaf.page
agent invent `leaf delivery ack` and post an early `leaf reply` anyway.

A clause's `when` now reads the event's `conversation` digest and the
`carrier` delivering it (`wait`, `queue`, `app-server`) beside the record and
its obligation, and the clauses state one case each:

- only `leaf wait` deliveries ask for acknowledgement, naming
  `leaf wait --ack <delivery-id>`;
- App Server deliveries say the final message is the reply; the others say
  to answer with `leaf reply` first;
- the naming clause appears only when the thread has no title.

Handling moves from capture to the freeze (`freeze_delivery(carrier=...)`,
`offer_delivery(..., carrier)`): a Codex record collects batches before the
adapter knows which transport will offer them, so a record captured under one
transport and offered by another could not be told the wrong route.

The watcher preface now says to skip the `leaf wait --ack` clause the
forwarded batch carries. Tests: the per-case walkthrough adds queue, App
Server and titled/untitled cases; the carrier snapshot freezes the queue
route on its own; tests that rebuilt the `when` input pass carrier and
conversation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	docs/how-it-works.html
#	skills/leaf/assets/registry.json
#	tests/_regtest_outputs/test_interact_contract.test_each_case_of_an_event_is_told_what_the_snapshot_shows__0/snapshot.yaml
#	tests/_regtest_outputs/test_interact_session.test_agent_sees_a_real_summary_suggestion__0/snapshot.yaml
#	tests/_regtest_outputs/test_interact_session.test_agent_sees_the_complete_interaction_recovery[reply]__0/snapshot.yaml
#	tests/_regtest_outputs/test_website_server.test_hosted_agent_receives_the_response_instructions_and_delivery[reply]__0/snapshot.yaml
# Conflicts:
#	docs/how-it-works.html
#	tests/_regtest_outputs/test_interact_contract.test_each_carrier_hands_the_agent_what_the_snapshot_shows__0/snapshot.yaml
#	tests/_regtest_outputs/test_interact_contract.test_each_case_of_an_event_is_told_what_the_snapshot_shows__0/snapshot.yaml
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 9bcfb51 into main Sep 24, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex-app-server-terms branch September 24, 2026 01:28
max-sixty added a commit that referenced this pull request Sep 24, 2026
scripts/eval_claude_delivery.py runs headless Claude Code sessions, one
with a base ref's plugin and one with this checkout's, at the same time.
Each serves the same page, starts its background `leaf wait`, and gets
one real comment over HTTP. The script reports seconds from the comment
to pickup and to the first reply, the actions before `leaf wait --ack`,
and any acknowledgement command the agent invented. `claude -p` keeps a
background shell alive while stdin stays open, so each session runs with
`--input-format stream-json` and the comment arrives through Claude
Code's own task notification.

A session ends 20 s after the turn the comment woke, or at a ten-minute
deadline that kills it and marks the run timed out. A failed run stops
its session and server either way.

It is basic and imperfect: four rounds, one page, one comment shape, a
fresh session, and substring scoring. Its docstring lists these limits.

It settles the TODO item on checking each carrier's delivery route after
#1068, which this change removes:

- App Server: 4 of 4 `verify_site.py local` runs passed. None invented
an
  acknowledgement command or posted an early `leaf reply`.
- Claude Code: 4 paired rounds against a7cd8cd, the commit before
#1068.
  Every run in both arms acknowledged as its first action after reading
the envelope, and none invented a command. Pickup took 8, 7, 11 and 8 s
  before and 5, 5, 10 and 9 s after. A smoke run of this script against
  main gave the same picture.


🤖 Generated with [Claude Code](https://claude.com/claude-code)

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