Repository navigation
Refine Lit application authority - #747
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The admitted gate holds while the drag is live, but nothing repaints the banner when it clears, so Approve stays disabled after the guard has already released.
Measured on this head, with the answer still held outside the log:
projectionDeferred() |
asks.unanswered |
admittedUnansweredAsks |
approvalBlockingAsks() |
button | |
|---|---|---|---|---|---|
| during drag | true |
[] |
['release-decision'] |
['release-decision'] |
disabled |
1.5s after lf-dragging is removed |
false |
[] |
['release-decision'] |
[] |
still disabled, titled "Answer every Ask before approving this work" |
After the release approvalBlockingAsks() is empty, so the guard is no longer what holds the button — the banner is showing paint from before the drag. runtime/projection-watch.js drives paintApproval from watchSemantic and the presentation-readiness event only, and clearing the drag gate is neither: onDeferredReady → retryProjection → invalidateDom repaints projection chrome without publishing a semantic epoch. runtime/widget-controller.js already has the matching resume for its own drag deferral — it listens for DRAGGING_CHANGED and replays the held renders — and the approval face has no equivalent.
That missing resume is the seam rather than an oversight. The root CLAUDE.md puts drag with the mechanical browser owners ("Their renderings are not semantic authority, and repainting them does not create a semantic epoch"), and asks/model.js's own header says the selection boundary "cannot change which Asks exist or whether they await the reader". Reading projectionDeferred() inside the selector makes a semantic reading change with no publication to carry it, so the stale paint follows from the design rather than from a forgotten call site.
The reachable case is an in-flight answer plus a drag that ends without a gesture of its own — a cancelled lf-board drag — which leaves Approve disabled and captioned "Answer every Ask before approving this work" until the answer's admission lands. Either wire the approval repaint to the same DRAGGING_CHANGED resume the widget controller uses, or keep the gate out of the selector and let the deferral hold the whole banner.
Secondary, and outside this diff: the wire inventory the title retires is still on the wire. served_state/document.py still sends "asks": document.asks in every browser document view, and with WireAsks gone nothing reads it — the append door's own guard recomputes from read_document, and no test asserts it. (browser_conversation's block is different: event_endpoint.py still reads it.) Happy to push that deletion onto this branch if you want it here.
leaf-agent
left a comment
There was a problem hiding this comment.
The name and docstring of test_deferred_projection_keeps_approval_behind_admission now state the inverse of what the test asserts. At the flipped assertion the answer is still held outside the log — held[0].continue_() is three lines later — and the test claims the button is enabled and titled "Approve this work; the page stays open for follow-up". So an optimistic answer does unlock the irreversible command; what holds it is deferred projection paint, which is what approvalBlockingAsks actually reads and what the comment above it says ("A deferred projection has not committed the optimistic answer to the document yet"). Admission never enters it.
That matters more than wording because this test is the gate's only statement of its own contract. Someone reading the docstring as written would see the new to_be_enabled() as the regression rather than the repair, and a future change that unlocks approval during the drag would still satisfy the name.
The fix is the two lines above the hunk, so I can't attach a suggestion to them:
def test_deferred_projection_holds_approval_until_its_paint_lands(browser, serve):
"""Deferred projection paint, not admission, holds the irreversible approval."""Happy to push that onto the branch if you'd rather not hand-apply it.
…gain (#808) `TODO.md` #4. `application.ts` folded the whole Ask reading a second time — which Asks a document holds, which of them the reader still owes, every declared target's awaiting value, and each thread's `awaits_reader` — over DOM-captured descriptors, while `leaf.asks` folds all of it under the page transaction that answers every state read. The browser copy is gone and the wire is what it reads. Deleted: `deriveAsks` (176 lines), `deriveThreadReaderObligations` (55), the ask predicates between them, `admittedUnansweredAsks` with the approval gate's `projectionDeferred` branch, and `askDescriptor` / `conversationDescriptor` / `retirementAncestors` in `widget-descriptors.js`, which existed only to feed them. In their place, `normalizedAsks` maps the wire's records to the public `{id, tag, sourceId, sourceTag, thread}` shape, page asks before thread asks. `served_state/document.py` serializes the page reading it has been computing and dropping since #747, and `served_state/conversation.py` builds its own through one `_AskReducer` rather than two. Each listed Ask now names the `source` that answers it beside the surface the reader is sent to, which is what the browser's records carried and the wire did not; `leaf state` shows both as well. The two copies of the `when` predicate disagreed: Python asks whether an attribute is present and TypeScript asked whether it was non-null, so an attribute a value record had set to `null` read differently on each side. Python's reading is now the only one, and the browser's action-availability gate and the server's POST door read the same `unanswered_awaiting` map. ## What moves on screen **The Ask reading is no longer optimistic, and that is the one judgement call in this change.** A reader still sees their own gesture in its widget at once — the pick, the cleared pick, the swiped card, the withdrawn classification, the controls rebuilt by an Undo — because the unresolved-attempt ledger, `foldThreads`' pending branch, the DOM-captured authored baseline and `foldWidgetStates` all stay. But the Asks tray, the banner count, the `a`/`A` walk, the approval gate and an action's `requires` gate now turn over when the state that gesture's own POST returns is adopted, where they used to turn over as the gesture was sent. Keeping them optimistic is what the deleted code was for: doing it exactly needs the answer verbs, the `until` verb, the nonempty-facet rule, the completion containers, the rollup tree and the existence reading — which is the duplication itself. Against a local server the gap is one short round trip: answering and withdrawing an answer on `review-a-plan` in Chrome moved `Asks 0/1` and the Approve control with no visible lag, console clean. Eight tests asserted the reading at the held-POST moment and now assert it on the log's answer, and `CLAUDE.md`'s cross-runtime invariant now says which gestures the page can draw for itself and which wait for the log. Revert that paragraph and those eight tests together if the optimism should stay. One case is not that delay and is fixed rather than accepted (leaf-agent found it): a thread carrying a frozen Ask the reader still owes used to lose its "awaits you" mark the moment they started sending a reply and take it back when the reply landed — true → false → true, reversing direction rather than lagging. A thread the server still names in the reader's Ask list now keeps `awaits_reader` over `foldThreads`' pending-reply branch, read off that same list rather than folded again. ## A correction to the item `TODO.md` #4 also said `foldProjection` re-folds the winner resolution although the wire carries `actions` / `reports` / `desired`. It does not: it has consumed those id lists since #525. Its only re-derivation is `recompute()`, which runs solely for coordinates a pending entry touches, to reveal the next durable winner when a local undo withdraws the server's — the pending ledger's own work. Removing that would take a wire addition (per-coordinate ordered eligible candidates), not a deletion, so it stayed. ## Validation - `uv run pytest tests` — 1,145 passed on this head - `uv run pytest tests --run-nightly` on the first commit — 2,723 passed, 1 failure (`test_render_export.py::test_a_detached_preview_restarts_under_its_original_codex_claim`) traced to a `leaf ack` waiter left standing by my own earlier `scripts/preview.py` run; `tests/test_render_export.py` is 59/59 green with that state cleared, and 59/59 on the merge base as a control - `npm run check:browser` and `npm run test:browser` — 55 passed - `uv run pre-commit run --all-files` - Chrome, `review-a-plan` preview: answered the Ask, watched `Asks 0/1` → `1/1` and Approve enable; deselected, watched both reverse - `test_a_live_revision_reapplies_the_authored_conversation_seat_predicate` read `openAsks()` straight after `sending(...)` and failed 1 in 3 alone, because the Ask list is the applied state's now and `round_trip` returns one beat before `applyAcceptedState` finishes; it reads through `told(page)` and is 4/4 > _This was written by Claude Code on behalf of @max-sixty_ --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Follow up on the Lit authority review by removing the unread document Ask inventory from the browser wire and its consumer, preserving the admitted-state approval guard and repainting it when deferred projection paint resumes, pinning the intentional two-pass provisional widget render, and deleting the superseded descriptor helper.
Validation: 1,130 ordinary tests; 151 affected nightly browser tests; 53 browser-framework tests; pre-commit.