Skip to content

Derive every agent obligation from one workflow answer - #983

Merged
max-sixty merged 8 commits into
mainfrom
fix-obligation-model
Sep 23, 2026
Merged

max-sixty merged 8 commits into
mainfrom
fix-obligation-model

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Leaf had two readings of what the agent owes a reader, and they disagreed. Delivery minted response addresses of its own (a receipt for any unreceipted request, a reply or version from the workflow obligations), while Stop, leaf status idle, activity counts and the banner read requires_response off workflows. As a result:

  • a request never became a workflow, so Stop and idle let the agent leave with a receipt owed forever (the [receipt] recovery snapshot recorded acknowledged at stop: null)
  • a page Ask pick was delivered as "the page shows it as waiting on you" but never held the turn, and the page went closed with the pick still reading picked-up/ended
  • a tick before a multi-pick Ask's Done read as agent work ("1 update waiting") while asks.reader said the reader still owed the answer
  • Stop named a thread's root id, which leaf reply --for refuses
  • counts.total counted a failed response the reader must resend, so the banner said "1 saved … picks them up next turn"

The concept

Each workflow now carries answer, the addressed operation that settles it, replacing requires_response:

  • reply — a thread input, or a move in an answered Ask in thread markup
  • version — a thread opened as a request for change
  • markup — a page action that is part of its widget's answered Ask and that the authored markup does not yet record. The move writes the facet the Ask's answer verbs write, so every swiped card of a finished deck is owed, not only the finishing card
  • receipt — a request without its terminal receipt

The rule is single: a move whose next actor is the agent is owed its answer, and once acknowledged it blocks Stop and idle. Some reader moves hand nothing to the agent and are no workflow at all:

  • a move on an Ask the reader has not finished answering, such as a pick before Done or a swipe before the deck's finish
  • a page action that answers no Ask, such as an edit to a reader-owned draft or a moved card, which the log carries onto every later version

The same rule applies on the page and in thread markup.

The one agent-owed move without an address of its own is a thread input a newer input covers; the newest carries the thread's single answer.

delivery.current_responses reads the workflow answers, so delivery, page state, reply refusals, Stop and idle all name the same operation. Stop, idle and logged_id refusals print the exact command with the id its writer takes (leaf reply <page> --for <newest>, leaf receipt <page> <request> succeeded|failed, …). Activity counts only agent-owed moves, and replying counts as active.

Delivery guidance

$events.handling explains an event by its kind. The new $events.answering explains, per answer kind, how to write the answer the event owns, and a clause's when can read the event's obligation. An event that owes nothing gets no answering clauses and is told so. Rules that were written in several places now live in one:

  • the reply command lives in answering.reply
  • resolve etiquette and the exact version-thread resolve rule live in conversation-threads.md
  • the done rule lives in its delivery clause, and page-checkpoints.md no longer restates it

Behavior that moved

  • The [receipt] recovery specimen now blocks at Stop and refuses idle.
  • A page Ask answer holds the turn until a stamped version records it in the markup. authoring-revisions.md, page-checkpoints.md and event-batches.md state this.
  • Ticks before Done, and page actions that answer no Ask, mint no workflow, so they get no margin receipt.
  • examples/ship-review.html now records the reader's approval (chosen). The site build idles every example, and the seeded approval was otherwise the very state this change forbids: an idle page with an unanswered Ask pick. The corpus is regenerated.
  • The hosted website now starts an agent turn for page Ask answers and requests, because they are obligations. Its failure receipt still covers reply obligations only; a markup or receipt obligation left by a failed hosted turn stays owed and is skipped by the continuation scan, as before.

Tests

  • New: test_the_stop_remedy_names_the_id_its_writer_takes passes the id Stop prints to leaf reply --for.
  • New: test_a_page_pick_holds_the_turn_until_the_markup_records_it, which also checks that a draft edit owes nothing.
  • New: test_a_tick_before_done_hands_nothing_to_the_agent.
  • New: test_a_finished_deck_owes_every_card_the_reader_sorted and test_a_deck_in_a_thread_owes_nothing_until_it_is_finished.
  • The failed-response test now asserts every count is zero.
  • The handling snapshot table gains obligation cases and the answering clauses.

Snapshots regenerated: interaction recovery ×3, handling table, summary suggestion, waiting status, and hosted-agent instructions ×3.

Left for later, since they don't follow from this model change:

  • delivery calls the subject conversation and workflows call it thread, with a translation in agent_state
  • thread-attention ranking is written twice, in Python _apply_thread_attention and in JS projectThreadAttention (plus the browser-only next_actor: "none")
  • presence.js keeps its own 15-minute grace constant

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

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 22, 2026 23:49
Leaf had two readings of what the agent owes. Delivery minted response
addresses of its own (a receipt for any unreceipted request, a reply or a
version from the workflow obligations), while Stop, `leaf status idle`,
activity counts and the banner read `requires_response` off workflows.
They disagreed: a request never became a workflow, so Stop and idle let
the agent leave with a receipt owed forever; a page pick was delivered as
"waiting on you" but never held the turn; a tick before a multi-pick
Ask's Done read as agent work ("1 update waiting") while the Ask still
said the reader owed the answer; and Stop named a thread's root id that
`leaf reply --for` refuses.

Each workflow now carries `answer`, the addressed operation that settles
it, replacing `requires_response`:

- reply: a thread input, or a completed widget move in thread markup
- version: a thread opened as a request for change
- markup: a page action the authored markup does not yet record
- receipt: a request without its terminal receipt

The rule is single: a move whose next actor is the agent is owed its
answer and blocks Stop and idle once acknowledged. A move that does not
complete its Ask (a pick before Done) is no workflow at all. Delivery's
`current_responses` reads the workflow answers, so delivery, `page
state`, reply refusals, Stop and idle name the same operation; Stop and
idle print the exact command, addressed to the id its writer takes.

Activity counts only agent-owed moves, and `replying` counts as active,
so a failed response handed back to the reader no longer reads as
"1 saved … picks them up next turn".

Delivery guidance splits the same way. `$events.handling` explains an
event by kind; the new `$events.answering` explains, per answer kind,
how to write the answer the event owns, and a clause `when` can read the
event's `obligation`. An event owing nothing is told nothing about
answering. Duplicated rules move to one home: resolve etiquette stays in
conversation-threads.md, the version-thread rule's precise form stays
there too, and the `done` rule stays in its delivery clause.

Behavior that moved, with its tests:

- the [receipt] recovery specimen now blocks at Stop and refuses idle
- page picks hold the turn until a stamped version records them
  (`test_a_page_pick_holds_the_turn_until_the_markup_records_it`); the
  unrewritten arm of the version-takes-the-answer-back test now expects
  that hold
- ticks before Done mint no workflow
  (`test_a_tick_before_done_hands_nothing_to_the_agent`)
- Stop names `--for <newest input>`, which `leaf reply` accepts
  (`test_the_stop_remedy_names_the_id_its_writer_takes`)
- a failed response leaves every activity count at zero
- the hosted website now starts an agent turn for page picks and
  requests, since they are obligations

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	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
leaf-agent
leaf-agent previously approved these changes Sep 23, 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.

The PR's test job fails at Build website, before the website worker tests and the bundled-release measurement run. scripts/site.py's publish_examples prepares each worked example with final_status="idle". examples/ship-review.jsonl contains a page pick, b9e3a841 (choose on off-workaround-review), and the published markup doesn't record it. The new rule turns that pick into a markup obligation, so leaf status idle refuses:

leaf status .../examples/ship-review idle:
1 acknowledged reader move with no answer (a stamped version whose markup records action b9e3a841); answer before idling.

The core suite and the runtime folds passed in that same job. This is the only red check.

The rule is doing what the PR says it should, so the fixture has to change. Either the example writes the approval into its final version's markup, or it publishes in a state where the pick is still owed and so doesn't end idle. Which one depends on what the example is meant to show the reader.

@leaf-agent
leaf-agent dismissed their stale review September 23, 2026 07:30

CI failed — Build website: ship-review cannot idle with an owed page pick

A page action that answers no Ask, such as an edit to a reader-owned
draft, is carried by the log onto every later version and owes the agent
nothing, so it mints no workflow. A pick on a page Ask still owes the
version that records it. The site build idles every example, which
surfaced both: the feature gallery's draft edit no longer holds idle, and
ship-review now records the reader's approval in its markup.

The margin acknowledgment test drives a single-choice Ask, since a tick
in a group that waits for Done has no receipt.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

answers_ask asks whether a verb settles the widget's Ask, but the markup obligation is minted per unit. Where an Ask's answer spans units, only the settling unit keeps one. A swipe deck is the case: lf-swipe-deck.js emits queued === 1 ? "finish" : "swipe", so every card but the last carries swipe, which is not in the deck's answers: ["finish"]. After a three-card sort the page owes a version for the finishing card alone; stamp exactly that version and the page goes idle with the other two cards standing in keep in the log and still in queue in the authored markup, and nothing anywhere says so. Before this commit all three were owed.

The rule that holds for both shapes is the one the PR already states for a pick before Done — nothing is owed until the Ask is complete, and then the whole answer is. A swipe shares finish's facet and record in the deck's declaration, so "belongs to this Ask's answer" is derivable without naming a verb.

Reproduction

A three-card deck inside an lf-ask, published, then swipe card-a, swipe card-b, finish card-c, read through state_json:

# on 5907d841
[{"coordinate": ["triage", "card-c", "verdict"], "answer": {"kind": "markup", "action": "…"}}]

# on 5907d841^
[{"coordinate": ["triage", "card-a", "verdict"], "answer": {"kind": "markup", "action": "…"}},
 {"coordinate": ["triage", "card-b", "verdict"], "answer": {"kind": "markup", "action": "…"}},
 {"coordinate": ["triage", "card-c", "verdict"], "answer": {"kind": "markup", "action": "…"}}]

Stamping a v2 that moves only card-c into keep leaves workflows == [], and after the batch is acknowledged leaf status idle exits 0.

The second point is in the delivery guidance. The new action clause "The log carries the action onto every later version, so the page keeps it without an edit." carries only the not-a-thread predicate, so it is told for page actions that do owe markup — alongside the markup answering clause, which says the opposite. The regenerated handling snapshot shows both under pick on the page, and the docs/how-it-works.html sample ships them as h2 and h4 of one batch. The sentence this replaced carried the contrast itself ("The log carries the action onto every later version, but the page shows it as waiting on you…"); split in two, the reassurance stands alone and reads first.

Both are mechanical to fix and I can push them if you'd rather not: the clause needs its when to be an allOf of the existing not-a-thread test and {"not": {"required": ["obligation"]}}, matching the neighbouring "This move owes no answer of its own" clause, plus the handling snapshot and the how-it-works sample regenerated.

Everything else in the commit reads right. The narrowing is the correct model for a draft edit, the choose-attribute additions in test_delivery_claim_uses_the_projected_widget_receipt and the margin acknowledgment test are fixture corrections rather than lost coverage, and examples/ship-review.html recording the approval settles the site build's idle refusal from the previous round. CI test is green on this head, and locally tests/test_interact_contract.py tests/test_site.py tests/test_interact_document.py pass (531) as does tests/test_interact_session.py apart from two AF_UNIX cases this sandbox cannot run.

Comment thread skills/leaf/scripts/leaf/asks.py Resolved
Comment thread skills/leaf/assets/registry.json Resolved
max-sixty and others added 2 commits September 23, 2026 01:17
An Ask's answer can span units: a deck's cards are each swiped, and only
the last card's finish answers the Ask. The markup obligation now covers
every move that writes the facet the Ask's answer verbs write, and only
once the reader has answered the Ask, so a finished three-card sort owes
all three cards and a sort in progress owes nothing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	scripts/browser/generated/browser-runtime.js.map
#	scripts/browser/generated/browser-runtime.manifest.json
#	skills/leaf/assets/vendor/browser-runtime.js
#	tests/_regtest_outputs/test_website_server.test_hosted_agent_receives_the_response_instructions_and_delivery[receipt]__0/snapshot.yaml

@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.

canonical_workflows's frozen-thread branch still gates on ask_completion(...) is False, so the rule the new module docstring states — "a pick before the Done its group declares, a swipe before the deck's finish — hands nothing to the agent, so it is no workflow" — holds on the page and not in a thread. ask_completion answers None for any Ask that declares no until, and lf-swipe-deck declares answers: ["finish"] with no until, so one swipe on a deck in frozen thread markup mints a reply workflow with next_actor: "agent" while asks still names triage as the reader's own. That is the third bug the description lists — agent work claimed for a move the reader has not finished — surviving on the other side of the same function, and it is the half of the seam bf1c639 did not close: the page branch now asks ask_answered, the thread branch asks a predicate that only until can answer.

Passing the conversation's own reading to ask_answered is enough, and it changes nothing for the shapes that already work — an lf-options group with until keeps the completion reading verbatim, and one without it answers through answered_verb's folded chosen, as it does today. The inline suggestion carries it.

Reproduction and verification

A three-card lf-swipe-deck posted as comment markup, then one swipe, read through state_json on 553264b:

workflows: [(["triage", "card-a", "verdict"], {"kind": "reply", ...}, "agent")]
asks:      ["triage"]

After swipe card-b and finish card-c the thread holds three separate reply obligations, one per card, so the agent owes three leaf reply --for for one sort.

With the suggested gate the same sequence reads workflows: [] before the finish and all three cards after it — the deck behaves in a thread the way test_a_finished_deck_owes_every_card_the_reader_sorted pins it on the page. tests/test_interact_session.py tests/test_interact_contract.py pass with it applied (550 passed; the three AF_UNIX cases this sandbox cannot run fail either way).

Comment thread skills/leaf/scripts/leaf/workflows.py Resolved
…only to moves owing nothing

The frozen-thread branch gated only on an until verb, so a swipe on a
deck in thread markup minted a reply obligation while the Ask was still
the reader's. It now asks the same question as the page: the move is
part of the widget's Ask, and the reader has answered it.

The page-action clause saying the log carries the action now applies
only to moves that owe no answer; beside the markup answer clause it
contradicted it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Sep 23, 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.

Approving on the code, but nothing green stands behind it: GitHub never created a ci run for 782f6ae. The workflow's run list for this branch holds 553264b, 5907d84 and 0e57a0b and stops there, and the only run on this head is tend-review. So lint — the repository's one required check, per Working on the repository in CLAUDE.md — has no result here, and neither does test.

Locally on this head, tests/test_interact_contract.py tests/test_interact_session.py pass (551), apart from three AF_UNIX cases this sandbox cannot run.

# Conflicts:
#	scripts/browser/generated/browser-runtime.js.map
#	scripts/browser/generated/browser-runtime.manifest.json
#	skills/leaf/assets/registry.json
#	skills/leaf/assets/vendor/browser-runtime.js
#	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_interact_session.test_agent_sees_the_complete_interaction_recovery[version]__0/snapshot.yaml
#	tests/_regtest_outputs/test_website_server.test_hosted_agent_receives_the_response_instructions_and_delivery[reply]__0/snapshot.yaml
#	tests/_regtest_outputs/test_website_server.test_hosted_agent_receives_the_response_instructions_and_delivery[version]__0/snapshot.yaml
@max-sixty
max-sixty merged commit 19a0213 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix-obligation-model branch September 23, 2026 10:13
max-sixty added a commit that referenced this pull request Sep 23, 2026
#983 made every agent obligation one workflow `answer` and listed four
things it left undone. This PR finishes them.

## A failed hosted turn settles every move it was given

Before this PR, a hosted turn that failed wrote a failure receipt only
for moves owed a reply. A request, an answer to a page Ask, or a
conversation that asked for a version stayed owed with no turn coming
for it.

`conversation.fail_answer` is now the single writer the worker calls,
and it writes whatever failure the move's `answer` calls for:

- `reply`, `version`: a reply carrying `failure` in the conversation.
`cmd_reply` now accepts a host failure receipt in a version thread,
because a failure reply is the only reply that thread can take.
- `receipt`: a failed receipt. That is the request's own terminal
outcome, so its seat reopens and the reader can press it again.
- `markup`: a `pickup` with the new phase `failed` and a `failure` code.
The reader's Ask answer stays in the log. The workflow reads answered,
with a failed response, and its next actor is the reader until they
answer again or the markup records the answer.

`HostedTurn._receipt_unanswered` now covers every owed move in the
delivery (`codex.delivery_owed_moves`), not only replies. The worker
door and the continuation scan already went through
`write_failure_receipt`, so they get the same dispatch. The host failure
wording no longer says "message", since a request can now carry it.

## Thread attention is derived once

Python's `_apply_thread_attention` is the only place thread attention is
derived. The browser no longer has `projectThreadAttention` or the
browser-only `next_actor: "none"`. It changes the server's attention
only for unresolved local sends:

- a pending send makes its thread wait on that send (`foldThreads`)
- a standing reader Ask survives prose sent beside it (publisher, as
before)
- a refused send gives a thread the server left with the agent back to
the reader, with reason `recovery`

## One name for the subject

Workflow subjects and coordinates, update targets, and `status --on`
claims now all use `{"kind": "conversation"}`, the name delivery, `page
state` and the CLI already used. `agent_state`'s translation layer is
removed. The document kind `{"kind": "thread"}` for frozen thread markup
is a different concept and keeps its name. The `thread` field on Asks is
also unchanged.

## The working grace is served once

`served_state/page.py` now serves `working_grace_ms` from
`activity.WORKING_GRACE` alongside `now`. `presence.quietSince` reads
that value, so its 15-minute copy is gone. Nothing reads as quiet until
a state has arrived.

## Behavior that moved

- While a send is pending, its thread waits on that send, even if the
server has a stronger workflow such as a live reply. This lasts until
the log answers the send.
- A refused send's attention reason is `recovery`. It was `workflow`.
- `quietSince` uses `>=`, the same comparison Python's `_quiet` uses.
Its grace argument is removed.

## Tests

- New: `test_a_failed_turn_hands_every_kind_of_owed_move_back`,
parametrized over markup, receipt and version. A turn that completes
without answering must leave no obligations and nothing for the
continuation scan to pick up, and each move must end up in the shape its
answer takes. With the sweep limited to replies, all three cases fail.
-
`test_a_host_receipt_does_not_answer_input_an_agent_turn_already_claimed`
goes through `write_failure_receipt`.
- The runtime and publisher tests that asserted the old JS attention
re-derivation now assert that local sends adjust the server's attention.
- Subject kinds in fixtures are renamed.

Local runs: `tests/test_website_server.py`, the five `test_interact_*`
files touched, `npm run test:runtime`, the browser gate
(`check:browser`, `test:browser`) and pre-commit all pass. A keyword
selection over the render suites passed except two cases,
`test_a_growing_reply_keeps_its_send_in_the_list` and
`test_unit_claim_arrivals_share_one_window_with_the_open_page_map`. Both
also fail locally on the base commit 19a0213.

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

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 23, 2026
The scheduled [nightly
run](https://github.com/max-sixty/leaf/actions/runs/35851210059) on
`895a629c` failed nine browser cases. Five are covered by merged #1002
and #1003. The other four reproduce on current main at `3aa1888` and are
repaired here.

These are stale test arrangements after two intentional changes:

- A multiple-choice options tick no longer answers its Ask before Done
(#966). The margin-label paint test now uses a single-choice Ask, so the
pick produces the receipt whose label it measures.
- Only an answered Ask creates an agent workflow (#983). The export test
marks its draft `needed`, making its edit a real Ask answer before
checking that export strips the live pickup status. The two-unit arrival
test classifies two cards in a swipe-deck Ask, then checks their
distinct pickup and work pulses in the margin and Page Map. Ordinary
board moves no longer serve that role.
- The shipped triage-board rail test now creates and resolves an
anchored thread. It verifies that a real margin entry appears and
disappears without moving the readable column.

Verification: all four repaired cases and the neighboring receipt
lifecycle case pass together under `--run-nightly -n0` (5/5). Pre-commit
passes on the changed files.

> _This was written by Codex on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Sep 23, 2026
A page action that answers no Ask, such as a moved card or a draft edit,
now shows its Sent / Queued / Picked up receipt again. It still owes the
agent nothing: Stop, `leaf status idle`, and the banner's counts ignore
it.

## What #983 conflated

#983 made each workflow carry `answer`, the operation the agent owes a
move, and dropped every page action that owes nothing from the workflow
list. A workflow carries two separate readings, though:

- `stage` is delivery progress. `conversation-loop.md` promises it for
every reader move, and the margin, the Page Map and `leaf delivery
claim` read it.
- `answer` is the obligation, and Stop, `idle` and the counts read it.

Because the move itself was removed, a moved card lost its receipt and
`leaf delivery claim` on it reported no outstanding move. #1004 then
rewrote the four nightly cases to use Ask answers, so the suite no
longer covers these moves.

## The change

- A page action that answers no Ask keeps a workflow whose `answer` is
null. The workflow stays until the markup records the move or a later
version takes it in.
- Activity counts are now derived from owed answers alone (`outstanding`
= `obligations`). This keeps #983's guarantees: no Stop or idle block
and no pending count for a move that owes nothing. The remedy text and
the `answering` clauses are unchanged.
- A pick before Done still has no workflow. The reader has not handed it
over yet, and the Done carries the receipt. The rule that such a pick
hands the agent nothing still holds.
- A version settles a move only when its note supersedes the revision
the move was made on. A note stamped over that same revision was written
before the move reached anyone. The rule applies to recordless owed
verbs too, and they settled on log order alone before.
- `work_subject` now asks the workflow projection whether a widget has a
receipt, instead of calling `page_action_unsettled` a second time.
- `workflows.py`, `session-lifetime.md` and `conversation-loop.md` now
describe the two readings separately.

## Tests

- In `test_a_page_pick_holds_the_turn_until_the_markup_records_it`, the
draft edit now has a Sent receipt with a null answer that no count
reads, and the next version retires it.
- On the original tests, before #1004 rewrote them, the four nightly
cases pass with this change: each was confirmed passing on `19a02132^`,
failing on `19a02132`, and passing again here.
- On the merged branch, these all pass: `test_render_margin.py` in full
plus the aim and export cases (nightly included), and all of
`test_interact_session.py`. Before the merge, the interact files,
website server, semantic news, conversations, projection and navigation
suites also passed. The one failure,
`test_render_startup.py::test_a_widget_a_reply_carries_arrives_with_its_module`,
also fails on `origin/main` locally.

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

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

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 23, 2026
A card moved on a board the agent sent in a reply now gets the same
delivery receipt a moved card on the page gets, and like it owes the
agent nothing.

## What was wrong

`canonical_workflows` derived widget moves in two loops, one per
document. The frozen-thread loop kept only moves in an answered Ask.
#1005 gave page moves that owe nothing a receipt with a null `answer`,
but the second loop never picked up that rule. So a moved card or draft
edit in thread markup was delivered to the agent
(`requires_agent_attention` admits it) with no workflow behind it: it
had no Sent / Picked up receipt, and `leaf delivery claim` reported no
outstanding move.

## The change

- **One derivation for both documents.** One loop decides handover
(whether the Ask is answered) and obligation (`answers_ask`). The page
and a frozen thread differ only in what settles a move and which
operation answers an owed one:
- page: the markup records the move, or a later version supersedes it;
an owed move's answer is `markup`.
- frozen thread: the agent's next spoken turn there, which is the reply
addressed to an owed move, or for a move that owes nothing any agent
turn after it. A resolution that follows the move also settles it. An
owed move's answer is `reply`. A reaction is not a turn, and a host's
failure reply does not settle the move: it hands an owed frozen move
back to the reader as a failed workflow, the way a failed pickup hands
back a page move. Before, a failure reply settled such a move and left
no record.
- **Thread attention follows the obligation.** `holds_thread` states
what keeps a thread the agent's turn: every input and claim of the
thread itself, plus a frozen widget move while it is owed or the agent
is at work on it (Working or Replying). The thread's status comes from
those workflows. A frozen move that owes nothing shows its receipt on
the message that carries the widget. It does not make the thread the
agent's turn or set the thread's status. `at_work` is now one predicate
that both the filter and `priority` read.
- **Docs.** `workflows.py`, `session-lifetime.md`, and `events.md` state
the rule for both documents. `events.md` no longer says that interim
moves before an Ask's completion get receipts; they have had none since
#1005.

## Decision

The code has no product statement on whether a reader's move on a frozen
widget that answers no Ask owes the agent anything. I applied the page
rule: it owes nothing (`answer: null`), it keeps a delivery receipt, it
leaves Stop, `idle`, and counts alone, and it does not make the thread
wait on the agent. The frozen widget's state lives in the log for the
page's whole lifetime, so nothing is lost if the agent never answers,
which is the page rule's premise too. Before #983 every frozen move was
owed a reply. #983 dropped the ones that owe nothing entirely, receipt
included.

A resolved thread settles the moves made before its resolution,
including the Ask answer that resolved it. A move made after the
resolution is delivered like any other and keeps its receipt. Before, it
was delivered with no workflow.

## Behavior that moved

- A frozen-thread move that answers no Ask now has a workflow: `stage`
reports delivery, `answer` is null.
- A failure reply addressed to an owed frozen move now leaves it a
failed workflow, and the reader's turn.
- A thread whose only workflows owe nothing and are not Working has no
`attention`.
- Actions not authored by the reader no longer take part in the page's
newest-move-per-unit pick. They already did not in threads.

## Coverage for moved cards and draft edits on the page (task A)

#1006 already restored browser coverage at the real boundary. The Page
Map arrival test covers two moved cards reaching Picked up and Working.
The shipped-board margin test covers the moved card's margin status. The
export test covers a draft edit's receipt being dropped from a copy. No
new page test was needed. The browser test added here covers the
frozen-thread case.

## Tests

-
`test_interact_session.py::test_a_frozen_move_that_answers_no_ask_keeps_a_receipt_and_owes_nothing`:
a Sent receipt with a null answer, no obligation, no thread attention,
and no `obligation` in the delivery. `delivery claim` makes it Working
and the thread waits. An agent reaction leaves the receipt standing, and
the agent's next spoken turn settles it. A move made after the thread
resolves keeps its receipt.
- `test_frozen_widget_workflow_contributes_to_its_thread_attention` now
also covers a failure reply that hands the owed move back to the reader.
- `test_thread_attention_names_the_workflow_the_thread_waits_on`: an
input covered by a newer one keeps the thread's status while a reply
streams to it or after it is picked up, and a frozen move that owes
nothing never supplies the status.
-
`test_render_conversations.py::test_a_card_moved_on_a_board_in_a_reply_reports_delivery_on_that_reply`
(nightly): the reply carrying the board reads Sent, then Picked up,
while the thread status stays empty. The receipt leaves after the
agent's next turn.
- Bug-back: reverting `workflows.py` fails both new tests (no receipt),
and reverting `served_state/browser.py` fails both on the thread status.
Settling on `msgs` instead of `spoken_turns` fails on the reaction, and
dropping the failure-reply lookup fails the failure case.
- After the review fixes and a merge of main at `ee2f3ff1`: the
`test_interact_*` files and `test_website_server.py` pass. With
`--run-nightly`, `test_render_conversations.py`,
`test_render_projection.py`, `test_render_margin.py`,
`test_render_application_boundary.py`, `test_render_semantic_news.py`,
and `test_render_startup.py` pass (502). Pre-commit passes on the
changed files. No runtime JS changed.

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

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

---------

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