Repository navigation
Let a widget's facts reach the page, said again when a version or another tab moves them - #7425
Conversation
…ther tab moves them A widget's declaration now lists, under `facts`, the static functions of its class whose values the page keeps, each with the JSON Schema of its value. Each act and undo carries the values as `facts`, which replaces the top-level `answered` #7325 added. Where the state or markup moves without a gesture of the tab's own (a version, a `restated` mark, another tab's act), a tab showing the newest version works the facts out again (`host/widget-facts.js`) and posts a new bookkeeping `facts` event with the values that differ from the kept ones. Admission refuses one that changes nothing, or that names an older revision, so tabs that agree leave one event, and it wakes no one. The server keeps each widget's latest values (`obligations.widget_facts`), lapses them when a version restates the widget's decisions, reads `answered` from them, serves them per view and shows them on elements in `leaf page state`. A widget that declares `awaits` lists `"answered": {"type": "boolean"}`. Leaf's default word for `answered` stays for a class with no static. Page protocol 63. `lf-options multiple` now records on Done the options it covered and the picks among them, and answers only while Done stands on the set the group shows. A checklist given a step, or a pick restated after Done, asks again with its other picks kept; a pick the user changes after Done waits on Done again too, where before it stayed answered, since the two leave the same widget state. Tests that expected Done's empty detail, a pressed Done after its pick was refused, or `answered` on an event now expect the new shapes. The maintainer chose this design (level C) on the deck-fixes page. > _This was written by Claude Code on behalf of max-sixty_
… field requires > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
left a comment
There was a problem hiding this comment.
Two points in browser/runtime/host/widget-facts.js. The first is a defect in a case the PR says it closes. The second is a cost against root AGENTS.md, "Responsiveness".
A send refused as stale-facts is never repeated at the newer revision. sent holds the facts it sent, and a refusal leaves that entry in place. Suppose the agent writes r6, which adds a checklist step, and soon after writes r7, which restates nothing. The tab adopts r6, works out answered: false, and posts the event at r6. If r7 is admitted before that POST arrives, the server refuses the event as stale and the tab adopts r7. The server still keeps answered: true, because r7 lapsed nothing, so the facts differ. But the tab works out the same {answered: false}, sent.get(id) === facts, and it skips the send. The question stays off On Me while the widget shows it unanswered, until the user's next gesture on it. This is the "checklist given a new step asks again" case. Two versions written in quick succession are an ordinary agent pattern, for example a rewrite after a failed check. Keying sent on the revision as well (inline) fixes it. Two tabs that disagree still each say their word once per revision, so they don't overtake each other. A test in widget-facts.test.mjs could send at one revision, get "refused", then adopt a newer reading with the same kept values.
Each reading walks every widget that declares facts. On every adopted reading or document, reconcile loops over root.effective.widgets. For each widget that declares facts it serializes the worked-out values and the kept values to compare them, and the module header says so ("a reading costs each widget a comparison"). Every click brings a reading, so the cost of a click grows with the number of asking widgets on the page. Root AGENTS.md, "Responsiveness", asks that such a pass "runs only for what changed … and the pass never searches the page for changes". The folded/descriptor/revision identity check already skips recomputing facts. Only the comparison with kept forces the full walk, because each reading's facts objects are new. A narrower form would compare only the widgets whose kept entry, folded state or descriptor changed between two readings, or have the server name the widgets whose facts it changed. If the walk is cheap enough on the largest leaf-dev bench page to accept, the module header should say that, rather than the rule silently not applying here.
…mpare only widgets something moved A `facts` event refused as stale left the tab's dedupe holding the same facts, so on the newer version, where the page still kept the old word, the tab said nothing: a checklist given a step by one version and then rewritten by another stayed answered. The dedupe now keys on the version too. Each reading now skips a widget whose state, descriptor, version and kept value all hold their identity, so a reading costs each widget that declares facts one identity check. > _This was written by Claude Code on behalf of max-sixty_
…s word the page has moved past A version that restates an element now takes back every action resting on it together with the earlier decisions each of those had replaced at its coordinate (`InForce`), so no replaced decision comes back to decide the widget. What a user sees differently: a pick the user replaced, or an accept or reject they superseded, no longer returns when the agent restates its replacement, and the question asks again with nothing picked; a board card whose destination column is restated falls back to its markup place rather than to its previous move. This reverses #2515's rule that a note retracting only an answer's superseder gives the coordinate back to that answer; that PR gave no product reason, and SOUL.md keeps a choice effective until the user changes it. Every reader of liveness now reads `InForce`: served undo candidates read the projection's `in_force`, and `sample_events` admits the log through it. Two ways a widget's kept facts could be overridden by a stale word are closed. A gesture made on a version older than the one the widget's kept facts were said on leaves those standing (`obligations.widget_facts`), as a tab still on v1 pressing Done no longer answers a question v2 reopened. A `facts` event now names the seq of the reading it was worked out from (`through`), and admission refuses it as `stale-facts` once a gesture or another word on the widget landed after that reading, so a word sent just before a press can't land after it and reopen the question. A tab says a refused or unreached word again at its next reading. module-state.md points at lf-options' `answered` rather than copying it, and How it works says a version asks again once a tab shows it. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
left a comment
There was a problem hiding this comment.
An undo that lands after a version's retraction brings back the pick the PR says stays taken back. The user picks a, then b. Version r2 restates b, and the walk takes back both picks. A tab that hasn't yet adopted r2's reading still offers Undo on b, and UndoReading.error admits that undo, since b was never withdrawn. The fold then gets withdrawn = {b} up front. It never admits b, so b's arrival never retracts a, and a decides the question again. I ran it with the helpers in test_obligations.py: chose("a"), chose("b"), restating("b"), then {"kind": "undo", "undoes": "e2"}. The r2 projection goes from actions: [] to ['e1'], and the obligation reads done with answer ['a']. That contradicts the new InForce docstring ("none of them comes back to decide the coordinate") and test_restating_the_option_picked_brings_back_no_pick_the_user_replaced. It also breaks the docstring's claim that the fold and the ordered walk "agree on where the walk ends": the walk withdraws nothing on that undo and leaves the coordinate empty.
This commit made browser_undo_candidates stop offering an action that isn't in projection.in_force. The door doesn't refuse one, so undo_error's docstring ("The browser offers exactly the gestures this reading admits") no longer holds. Refusing an undo whose target is no longer in force at the door, the same reading the candidates use, would close both gaps. The refusal would show the stale tab the server's state. A model test of this ordering would pin it.
# Conflicts: # browser/runtime/host/application.js
leaf-agent
left a comment
There was a problem hiding this comment.
Reverting the cascade resolves the undo-after-retraction finding from the last review: events.py, projection.py, thread_context.py and document.py now match the merge base. The new told_facts rule has a cost the PR description doesn't name, though. It makes one of the description's claims true in one direction only.
Two tabs acting at once converge only when the right answer is "asks". Here is the other direction. Tab B picks a and presses Done on {a, b}. At the same moment, tab A, which hasn't seen either act, picks a. A's act carries answered: false, because no Done stands in its view, and that act lands last. The folded state is now picks {a} with Done covering {a, b} and {a}, so isAnswered says true and every tab works out answered: true. told_facts drops that word and admission refuses it as unchanged-facts. The question stays on On Me until the user presses Done again. I ran this with the helpers in test_obligations.py: [chose("a"), done(["a", "b"], ["a"]), chose("a")] reads waiting/user with kept {"answered": false}, and then told(True, through=3, revision=1) is refused.
This is the same cost the description accepts for a version that removes the uncovered option, and it's rare. But the squash puts the description on main as the commit message, and it says "two tabs acting at once converge once one tab reports". That sentence should say convergence holds only toward asking again. Otherwise it should name this case next to the removed-option one.
…facts again as a gesture leaves the ledger An undo's word on a widget was read as said on the version of the action it took back, which is wrong whenever the user undoes on a newer version than the one they acted on: a version-2 undo of a pick made on version 1 lost its word to an older one, so a question could stay open or read answered against the state the undo left. The browser's undo now names the revision it was made on, as an action does, and `widget_facts` reads that revision. `reportFacts` looked at a widget only when a reading or document arrived, so a widget it skipped while a gesture of the tab's own was on its way waited for the page's next event once the gesture left the ledger. Its effect now follows the ledger too. > _This was written by Claude Code on behalf of max-sixty_
# Conflicts: # browser/runtime/state/semantic-application.js
|
Re the review on 47fd4b8: the description now says convergence holds only toward asking again. Its opening says that when two tabs agree a question is answered, it asks until Done is pressed again, and the
|
|
Thanks. That resolves my finding on 47fd4b8. The opening now limits convergence to the reopening direction, and the |
# Conflicts: # browser/runtime/host/widget-state.js # browser/runtime/records/obligations/answer.js # browser/runtime/records/pending/dispatch.js
# Conflicts: # packages/default/widgets/lf-options.js
…ed option `statics.answered` and the commands' Done reading took every `lf-option` child as an authored option, an added one still drawn included. Right after the user undoes an `add`, the gesture's facts are worked out before Effect UI redraws, so the undone option counted as one Done never covered: the undo carried `answered: false` while the view, reading `inputs`, drew Done pressed, and no later word could answer it again. `authoredOptions` now holds the rule `inputs` applied (skip `data-lf-added`), and `shownOptions` and `inputs` both read it.
) Three rules now decide whether a widget's question is answered, and what the user's decisions on it come to when a version restates something (`events.md`, "Widget answers"): 1. **A gesture carries its word.** Each act and undo carries the widget's `answered`, worked out by its class in the gesture's task, and the latest gesture in force decides. This is #7325's shape. 2. **A rewrite takes back only itself.** A version marking an element `restated` takes it out of the user's decisions resting on it. A pick set loses that option and keeps the rest, and restating the `lf-options` itself keeps every pick. Any other decision resting on it goes, such as a draft's words or a Done, and no key falls back to a decision the user replaced. This is #7452, which this PR replaces, minus its rule that also took out the decisions before a removed one, which only a hand-written log reached. 3. **A restating version asks again.** A note marking a widget or an element inside it reopens the widget's question until the user's next gesture on it, read from the version alone. A version that edits markup without restating asks nothing again. What goes: the `facts` declaration key and bookkeeping event, with `through`, the `stale-facts` and `unchanged-facts` refusals, `told_facts`, the rule that a gesture on an older version leaves kept facts standing, undo's `revision`, `host/widget-facts.ts`, the served and `page state` facts, and lf-options' "Done covers the set shown". `InForce`'s up-front mode and `action_retracted` go too, as in #7452. Page protocol 64. ## Why restate only Across the state home's 458 page logs, 884 versions changed the markup of an answered `lf-options`. 574 settled it, 260 wrote the user's pick into `selected`, and 34 changed wording or a label. Only about 3 added options without restating and might have meant to ask again. Every version whose note says it asks again used `restated`. Reopening on any markup change would have reopened about 300 answers the agent had just recorded. ## The case table | The user's acts | The version | Result | | --- | --- | --- | | single choice: a, then b | restates b | nothing picked, asks again | | single choice: a, then b | restates a | b picked, asks again | | multiple: a, a+b, Done | restates b | a picked, asks again | | multiple: a, a+b, then untick a | restates b | nothing picked, asks again | | multiple: Done, then a pick changes | — | stays answered | | checklist answered | adds a step, restates nothing | stays answered | | checklist answered | adds a step, restates the group | every pick kept, Done gone, asks again | | two tabs: B picks a and presses Done; A, behind, picks a last | — | A's word stands: asks again, Done still pressed in B | Each row is a test in `tests/model/test_restatement.py`. ## What a user sees differently from #7425 - A checklist given a step stays answered unless the version restates the group, which asks again and keeps every pick. - A pick changed after Done keeps the question answered. - Restating an option of a `multiple` group whose Done stands asks again while Done still shows pressed, so answering takes two presses, as with the two crossing tabs. No log in the state home has restated an option of a `multiple` group with Done standing. - A restated single choice keeps its pick, which takes two presses to confirm, so `$restated` tells authors to mark the picked option where the user should choose afresh. ## Size Against the merge base: Python +274 −428, browser TypeScript +79 −293 and its compiled JavaScript +67 −250, package JavaScript +26 −88, registries and schema +23 −99, tests +680 −1104, docs +136 −185. `uv run leaf-dev interface --base`: Declaration keys: removes `facts`. > _This was written by Claude Code on behalf of max-sixty_
A widget's declaration now lists, under a new key
facts, the static functions of its class whose values the page keeps, each with the JSON Schema of its value. Each act and undo carries the values asfacts, replacing the top-levelansweredfrom #7325. Where the widget's state or markup moves without a gesture of the tab's own (a version, arestatedmark, another tab's act), a tab showing the newest version works the facts out again (host/widget-facts.js) and posts a new bookkeeping event,facts, with the values that differ from the kept ones andthrough, the seq of the reading it worked from. It wakes no one. The server keeps each widget's latest values, lapses them when a version restates the widget's decisions, readsansweredfrom them, serves them per view, andleaf page stateshows them on each element. A widget that declaresawaitsmust list"answered": {"type": "boolean"}. Page protocol 63.This closes what #7325 left open: a checklist given a new step asks again with its decided steps kept, and restating a picked option of a
multiplegroup after Done asks again. When two tabs act at once, the page takes up the word they agree on once one tab reports it, if that word reopens the question. If they agree it is answered, the question asks until Done is pressed again (first rule below).Rules that keep a stale word from overriding a fresh one (
obligations.widget_facts,event_contracts._facts_event_error):factsevent may say a question is open again but never that it is answered (obligations.told_facts): an answer is the user's act, and its word travels on that act. So when a version restates the pick the user made in place of an earlier one, and the earlier pick decides the widget again as it did before this PR, the question still asks. The cost is a question that asks until Done is pressed again, although every tab works out that it is answered. Two cases reach it:answered: false. Every tab then works out true,told_factsdrops that word, and the question waits on Done again.revision, optional on the record), as an action does.factsevent naming an older revision, or worked out before a gesture or another word on the widget landed (stale-facts), so a word sent just before a press can't land after it. It also refuses one that changes nothing, so tabs that agree leave one event. A tab says a word again only after such a refusal, once the widget moved, or after a send that never arrived, and it looks at a widget again when a reading, a version or one of its own gestures leaving the ledger moves it.What a user sees differently:
lf-options multiplerecords on Done the options it covered and the picks among them, and answers only while Done stands on the set the group shows. So a pick the user changes after Done also waits on Done again, where before it stayed answered: a user unpicking after Done and a version taking a pick back leave the same widget state.Worth weighing: Leaf still says
answeredfor a class with nostatic answered, so a plain element asks without one. A value stays stale while no tab shows the version that moved it, the cost the C design accepted. RootAGENTS.md's "Responsiveness" is unchanged: a press still answers in its own task. An Effect UI widget lists its fact statics indefineWidget'sstatics, which it assigns to the class as it doeslfPatch, so lf-options, now on Effect UI (#7417), keepsstatic answeredthere andwidgetFactsfinds it.uv run leaf-dev interface --base: Declaration keys: addsfacts.Tests: model tests for each case above and for undeclared facts, invalid values and
page stateshowing facts; runtime tests for lf-options' rule andreportFacts; the browser and journey tests that post events or read answers, obligations or restatements, by node id.