Skip to content

Name each delivery's carrier, and route every answer through answer - #1080

Merged
max-sixty merged 6 commits into
mainfrom
carrier-aware-delivery
Sep 24, 2026
Merged

max-sixty merged 6 commits into
mainfrom
carrier-aware-delivery

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Which route acknowledges a delivery, and which route answers a thread reply, were each decided in several places. This moves both onto the delivery and the move's answer, so every consumer reads one fact.

The model

The envelope names its carrier and says once who acknowledges it. A delivery now carries carrier (wait, queue, app-server) and acknowledge. On wait, acknowledge is the instruction to the reader of the wait, phrased for how its harness runs the next wait: a background task for Claude Code, unified exec polled with write_stdin for Codex (Harness.run_ack). On queue and app-server, Leaf acknowledged the delivery itself, and the field is null. It sits ahead of batches, so output cut off partway still shows it.

Acknowledgement was a per-event handling clause keyed on carrier. It was a statement about the whole delivery, so a page pick with no comment beside it got no acknowledgement instruction even though its leaf wait batch needed one.

The answer route lives in answer. Answer kinds are reply, turn, markup and receipt. A turn answer is a thread reply that the claimant's App Server turn writes with its opening and final messages, under a reply attempt. Two places produce it:

  • freeze_delivery for the app-server carrier (delivery.carried_answer), so the delivery tells the agent before the turn binds anything
  • activity once a reply binding belongs to the claimant's session

Every consumer reads that answer: answer_command/unanswered, the leaf reply refusal (kind == "turn" and a different attempt), thread_obligation, the Stop hook (_turn_wrote reads the workflow's answer and its reply draft), stream_reply_target, and the registry, whose answering.turn replaces the carrier-keyed when on answering.reply. No $events clause reads carrier anymore.

One name. The delivered event field is answer, the same object leaf page state lists on the move's workflow. obligation.response and its as_of_seq are gone, and nothing read as_of_seq. The format is now leaf-delivery-v3.

Behavior that moved

  • A queued pointer that an App Server observer adopts no longer binds its reply to the turn. Its delivery was frozen for the queue and told the agent to answer with leaf reply. Before this change, leaf reply then refused it as the turn's. Now stream_reply_target returns only a turn answer, so the observer opens the turn on the delivery's pages, binds nothing, and leaf reply works. The prose override in host-codex-app-server.md is gone. Test: test_an_observed_queue_pointer_leaves_its_reply_to_leaf_reply.
  • Codex direct-wait recovery no longer contradicts itself. The Stop hook, leaf status idle and leaf wait --help stopped appending ACK_BATCH_INSTRUCTION ("run leaf wait --ack in the background") after Codex's "poll … with write_stdin". The delivery the poll yields states the Codex acknowledgement.
  • The watcher forwarding note no longer overrides the batch's handling. It says that the watcher ran the wait and acknowledges the batch, which is what the envelope's acknowledge says of whoever ran the wait.
  • Answer lists name the turn route as an answer kind. For example, the Stop hook shows "your turn's final message for X" from answer_command, where it used to check a separate turn_answers flag.
  • The turn answer carries attempt. leaf page state shows it on a bound move.
  • leaf reply --initiates on a thread whose reply is turn-bound says to finish in the final message, rather than saying to use --for, which would then refuse too.
  • The removed version answer kind is gone from ANSWER_KINDS, conversation-threads.md, and leaf.page's hosted instructions (worker/server.py), which also read obligation.response.

Tests and snapshots

The carrier and per-case snapshots were re-recorded. The when: carrier rows are gone; the App Server cases owe turn; each envelope shows carrier and acknowledge. Stop, idle and wait --help outputs lose the appended acknowledgement paragraph. test_pages_owing_the_same_thing_carry_one_copy_of_the_protocol now shares the answering protocol, since unpicked updates carry none. docs/how-it-works.html's sample delivery was rewritten to the new shape, and its test compares envelope keys and the acknowledgement too.

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

🤖 Generated with Claude Code

A delivery now names its `carrier` and says once, in `acknowledge`, how the
agent confirms it. Only the reader of a `leaf wait` acknowledges, and the
field phrases that for how its harness runs the next wait. On the queue and
App Server carriers, Leaf has already acknowledged, so the field is null. This
replaces the per-event wait clause in `$events.handling`, which a pick
delivered on its own never received.

A thread reply that the claimant's App Server turn writes is now its own answer
kind, `turn`, with the reply attempt. Freezing a delivery for App Server routes
the reply there, and so does `activity` once the reply binding belongs to the
claimant. The `leaf reply` refusal, `thread_obligation`, the Stop hook,
`answer_command`, `stream_reply_target`, and the registry's new
`answering.turn` all read that answer. They no longer check the binding, a
`turn_answers` flag, or the carrier. The delivered field is `answer`, the same
object as the workflow's. `obligation.response` and the unused `as_of_seq` are
gone, and the format is `leaf-delivery-v3`.

Behavior that moved:
- An App Server observer that adopts a queued pointer no longer binds its reply
  to the turn. That delivery names a plain reply, so `leaf reply` answers it
  instead of refusing it.
- Stop, `leaf status idle`, and `leaf wait --help` no longer append
  "run `leaf wait --ack` in the background". For a Codex direct wait, that
  sentence contradicted "poll with `write_stdin`".
- The watcher forwarding note and the App Server contract no longer override
  their deliveries in prose.
- The removed `version` answer kind is gone from ANSWER_KINDS, the thread
  reference, and the hosted instructions.

Tests: the carrier and per-case snapshots are re-recorded without the
`when: carrier` rows. Stop, idle, and help outputs lose the appended
acknowledgement paragraph. The shared-protocol test now shares the answering
protocol, because unpicked updates carry no protocol. The `_stream_answers`
and plain-reply stream-target tests now assert the `turn` answer. A new test
covers an observed queue pointer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Sep 24, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A collecting Codex record from the previous format still passes delivery_records(): RECORD_FORMAT remains leaf-codex-delivery-v1, while those records' captured events have obligation instead of answer. If that record is offered after this change, append_batch() counts no existing reply and offer_delivery() freezes a v3 envelope whose older event has no answer or answering instructions. An accepted pointer can then leave the user's move unanswered. Bump the record format so the reader drops these records and recollects the still unacknowledged page events. I can push that change if useful.

A collecting record holds captured events in the delivery's shape, which now
names each owed move's `answer` rather than `obligation`. A v1 record offered
after the change would freeze an event with no answer and no answering
clauses, so the record format moves to v2: `delivery_records` drops the old
record and the watch recaptures its unacknowledged events.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Sep 24, 2026
# Conflicts:
#	docs/how-it-works.html
#	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_website_server.test_hosted_agent_receives_the_response_instructions_and_delivery[receipt]__0/snapshot.yaml
@max-sixty
max-sixty merged commit bf3c081 into main Sep 24, 2026
4 checks passed
@max-sixty
max-sixty deleted the carrier-aware-delivery branch September 24, 2026 05:48
max-sixty added a commit that referenced this pull request Sep 26, 2026
…yer's registry once (#1221)

`leaf status idle` and the Stop hook each decided which acknowledged
user
moves still block the agent, and only the hook knew the two moves
another
turn answers: one a Codex carrier queued for a later turn (#459), and a
`turn` answer the open turn has finished, which a live carrier commits
once
the turn ends (#1080). So a turn that queued a batch could end but was
refused `leaf status idle` over the same move.

`activity.blocking_obligations(state, carried=)` is now the one rule,
read
by both; `session-lifetime.md` states it once. The prompt hook opens
`activity.acknowledged_obligations`, the queued ones included, as
before.

Two registry readings `vendoring.py` restated now come from
`registry/storage.py`:

- The recorded `$layer.packages` a bare `leaf page init` re-vendors with
is
read through `layer_packages`, whose check `layer_metadata` shares,
rather
than a copy of that rule with its own message. It reads the file as JSON
  and checks only the packages, so a page whose other `$layer` fields or
registry entries are broken can still be re-vendored, which is the
remedy
  `layer_metadata`'s errors name
  (`test_a_bare_re_vendor_replaces_a_broken_vendored_registry`).
- The candidate vocabulary `page init` checks a re-vendor against is
composed by `compose_candidate(page_dir, layer, widgets)`, the function
  `read_page_registry` composes the vendored layer with, rather than a
  second composition over the incoming layer.

`session._page_stamp` is renamed `_page_reading_or_none`: it wraps
`page_reading`, and `presence._page_stamp` is a different stamp.

Behaviour that moved:
- `leaf status idle` accepts a page whose only owed move is queued for a
later turn, and (with a live carrier) one whose turn answer the open
turn
has finished
(`test_idle_and_the_stop_hook_hold_the_agent_to_the_same_moves`).
- A malformed `$layer.packages` on re-init reports the registry reader's
  message.
-
`test_a_completed_stream_answers_its_event_even_when_the_reply_address_differs`
asserts through `blocking_obligations`, including the dead-carrier case.

🤖 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