Repository navigation
A user's update publishes its own obligation under page protocol 13 - #3229
Merged
Merged
Conversation
An update the user hands over now publishes an obligation record beside the ones
widgets and sign-off make: `update:<event-id>`, with `source: {kind: "update", id,
subject}` naming the input and the thread or widget it stands on, plus the usual
`thread`, `message`, `prompt` (no words of its own), `answer`, `status`, `end` and
`next_actor`. The agent is its next actor while it owes the update a reply or a
version, the user once a harness hands it back to send again, and nobody once a
reply answers it, which `answer.event` names. `obligations.response_address`
derives the operation that answers a record; nothing stores it.
What publishes one: the newest unanswered turn in an open thread, the newest
unsettled owed action on a widget's unit (a frozen widget's owes a reply, a page
widget's a version that writes it in), an update a harness handed back, and every
input a reply answered (answered by the first such reply in the log). Of turns the
user sent in a row only the newest publishes a record, and every workflow in the
run names it. An action that owes nothing, an unanswered turn in a thread resolved
first and a superseded failure publish none; a settled page action leaves the
inventory, since its widget's record carries the ending.
One fold, `workflows.handed_over`, emits the records and the workflows together, so
the run-of-turns, newest-per-unit and failure rules are written once.
`WorkReading.updates` serves the records beside `.workflows`; each view serves them
in its `obligations` after the widgets' and sign-off's, which they depend on.
The On lists are one selection by next actor (`served_state.queues`): On me is the
open records on the user (what the page asks, then updates to send again) plus the
user's to-dos; On <agent> is the open update records on the agent, in the order of
their strongest workflow, plus the agent's to-dos; Done is every closed record plus
the ended to-dos. The `resend`, `answer` and `work` row kinds are gone: every row but
a to-do's names a record by id, its kind the record's `source.kind`. A widget's
record turns the agent's only while a thread about it awaits the agent's word, whose
newest turn already publishes an update record, so On <agent> lists update records
alone and the widget is listed once, through the comment.
Thread attention reads the open records in the thread: a widget's on the user is
`needs_user/widget`, an update handed back `needs_user/resend`, any on the agent
`waiting` (`workflow` or `uncertain`), naming the strongest workflow serving it, else
an agent to-do. No reason changed name.
The workflow keeps its delivery stages and evidence and names the record it serves
(`obligation`); it no longer carries `answer`, `next_actor` or `holds_thread`.
`activity.obligations`, the answers the agent owes, is now built from the agent's
update records: each the workflow of the record's input with the record's id as
`obligation` and the owed `answer` (address plus the delivery's ref, received
mark or turn reservation). The Stop hook, `leaf status idle`, `current_responses`
and the deliveries read it unchanged in shape. The served state lists it as record
ids, which the Worker's agent dispatch and `leaf-dev journey` read; `page state`
prints each as `{id, answer}`, so an agent recovers what it owes, and the ref to
answer it with, without a delivery (conversation-loop.md says where).
In the browser, a send publishes its own local update record (the answer it is
owed, one per thread for the newest), which hides the server's update records in
that thread until the server reads the send, and a refused send or move publishes
the resend it leaves; `localQueues` lists those records like the server's.
What the user sees change, each rare:
- A. The agent working on the older of two messages in a row showed two On <agent>
rows (an answer row and a work row); it shows one, labelled Working.
- B. A widget action held by a to-do's start showed a work row beside the to-do's
row; it shows the to-do's alone.
- C. A start on an action that owes nothing (a card move with no question) loses its
On <agent> row and its thread's Working attention; the status line and the receipt
still show the work.
- D. A second reply to an already answered input adds no Done row of its own.
- E. A thread holding two handed-back updates, or a handed-back message and a
question the agent asked after it, shows a row for each on On me instead of one;
the thread reads as the question and `m` stops at it once.
- F. "update(s) with work started" leaves the status's "Waiting on <agent>" words.
Every other row word, count and label ("Waiting on me", "My turn to
resend/answer/retry", "N updates to send again", "N replies", "Sent 3m ago") is
unchanged.
The served state drops row kinds and workflow fields a page vendored at 11 reads,
so the page protocol moves to 12.
Measured on the served state (`full_state`) of the largest example, corpus.html
(one view): 1,297,561 bytes before, 1,300,953 after (+3,392, +0.26%). Its view's
`obligations` grew from 12,460 to 16,667 bytes (45 to 53 records, about 525 bytes
per update record) and its `queues` shrank from 9,401 to 8,587 bytes; Done holds 9
rows either way. ship-review.html: 20,080 to 21,325 bytes.
Tests: `test_update_obligations.py` holds the new contracts: two messages in a row
publish one record that both workflows name; a discussed widget is listed once,
through the comment's record (page and frozen); and the answers that hold the Stop
hook and refuse `idle` on a page with a run of two messages, a finished frozen
queue, a page pick, a draft edit and a handed-back message are exactly the ones the
previous code owed, which the same test passed against that tree.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # build/browser/application.ts # build/browser/contract.d.ts # build/browser/protocol-contract.d.ts # skills/leaf/assets/vendor/browser-runtime/application.js # skills/leaf/kernel/kernel.json # skills/leaf/kernel/runtime/bundle-queued-work.js # skills/leaf/references/conversation-loop.md # skills/leaf/references/module-reading.md # skills/leaf/scripts/leaf/served_state/browser.py # skills/leaf/scripts/leaf/served_state/queues.py # skills/leaf/scripts/leaf/served_state/state.schema.json # tests/runtime/thread-workflow.test.mjs
leaf-agent
approved these changes
Oct 20, 2026
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.
An update the user hands over now publishes an obligation record beside the ones widgets and sign-off make:
update:<event-id>, withsource: {kind: "update", id, subject}naming the input and the thread or widget it stands on, plus the usualthread,message,prompt(no words of its own),answer,status,endandnext_actor. The agent is its next actor while it owes the update a reply or a version, the user once a harness hands it back to send again, and nobody once a reply answers it, whichanswer.eventnames.obligations.response_addressderives the operation that answers a record; nothing stores it.What publishes one: the newest unanswered turn in an open thread, the newest unsettled owed action on a widget's unit (a frozen widget's owes a reply, a page widget's a version that writes it in), an update a harness handed back, and every input a reply answered (answered by the first such reply in the log). Of turns the user sent in a row only the newest publishes a record, and every workflow in the run names it. An action that owes nothing, an unanswered turn in a thread resolved first and a superseded failure publish none; a settled page action leaves the inventory, since its widget's record carries the ending.
One fold,
workflows.handed_over, emits the records and the workflows together, so the run-of-turns, newest-per-unit and failure rules are written once.WorkReading.updatesserves the records beside.workflows; each view serves them in itsobligationsafter the widgets' and sign-off's, which they depend on.The On lists are one selection by next actor (
served_state.queues): On me is the open records on the user (what the page asks, then updates to send again) plus the user's to-dos; On is the open update records on the agent, in the order of their strongest workflow, plus the agent's to-dos; Done is every closed record plus the ended to-dos. Theresend,answerandworkrow kinds are gone: every row but a to-do's names a record by id, its kind the record'ssource.kind. A widget's record turns the agent's only while a thread about it awaits the agent's word, whose newest turn already publishes an update record, so On lists update records alone and the widget is listed once, through the comment.Thread attention reads the open records in the thread: a widget's on the user is
needs_user/widget, an update handed backneeds_user/resend, any on the agentwaiting(workfloworuncertain), naming the strongest workflow serving it, else an agent to-do. No reason changed name.The workflow keeps its delivery stages and evidence and names the record it serves (
obligation); it no longer carriesanswer,next_actororholds_thread.activity.obligations, the answers the agent owes, is now built from the agent's update records: each the workflow of the record's input with the record's id asobligationand the owedanswer(address plus the delivery's ref, received mark or turn reservation). The Stop hook,leaf status idle,current_responsesand the deliveries read it unchanged in shape. The served state lists it as record ids, which the Worker's agent dispatch andleaf-dev journeyread;page stateprints each as{id, answer}, so an agent recovers what it owes, and the ref to answer it with, without a delivery (conversation-loop.md says where).In the browser, a send publishes its own local update record (the answer it is owed, one per thread for the newest), which hides the server's update records in that thread until the server reads the send, and a refused send or move publishes the resend it leaves;
localQueueslists those records like the server's.What the user sees change, each rare:
mstops at it once.The served state drops row kinds and workflow fields a page vendored at 11 reads, so the page protocol moves to 13 (main reached 12 with #3210).
Measured on the served state (
full_state) of the largest example, corpus.html (one view): 1,297,561 bytes before, 1,300,953 after (+3,392, +0.26%). Its view'sobligationsgrew from 12,460 to 16,667 bytes (45 to 53 records, about 525 bytes per update record) and itsqueuesshrank from 9,401 to 8,587 bytes; Done holds 9 rows either way. ship-review.html: 20,080 to 21,325 bytes.Tests:
test_update_obligations.pyholds the new contracts: two messages in a row publish one record that both workflows name; a discussed widget is listed once, through the comment's record (page and frozen); and the answers that hold the Stop hook and refuseidleon a page with a run of two messages, a finished frozen queue, a page pick, a draft edit and a handed-back message are exactly the ones the previous code owed, which the same test passed against that tree.