Repository navigation
Make event delivery ordered and retry-safe - #21
Conversation
`ci` on main has been going red in the undo tests, one at a time and a different one per run: `test_z_walks_back_through_gestures_rather_than_toggling_one` and `test_z_waits_for_the_gesture_the_log_has_not_taken` on run 32429171821, `test_a_rebuild_leaves_a_reader_standing_elsewhere_where_they_are` on its rerun, each reporting the page exactly as it stood before the press. `z` is the one press whose subject is read rather than pointed at, so the dispatcher holds it dead while the page holds a gesture the log has not taken (`unrecordedGesture`) — the trip its predecessor is still on included. Every other press acts on what is under the reader and can be made the moment the paint is there, and these tests were written that way: `round_trip` returns when the response lands, while `sending` is cleared and `undoing` dropped a turn later, when `post` has finished the poll it awaits. A `z` pressed in that gap is refused, and what the refusal leaves behind is the page an assertion on the un-undone state would find anyway — so the test reads a no-op as the wrong answer, or waits its budget out and calls it a hang. Nothing was wrong with the runtime; the gate is what keeps the walk from naming the gesture before the one the reader just made. So the press waits on the fact the page states. The line and the dispatcher ask one predicate (`live`), which is what makes the offer standing on the line the page saying this press will be taken — `undo(page)` waits for it, presses, and waits for the send to be counted before the trip, a `round_trip` read before the browser has reported the request being a wait on a page that has not started moving. Every site where the press is meant to act goes through it; the two that assert a press does nothing keep the bare keystroke they are about. The one assertion a retry cannot cover comes with it: the restored draft is compared exactly, because `to_have_text` collapses the blank line the authored text is there to bring back, so the collapsed reading now waits for the arrival and the exact one states what arrived.
leaf-agent
left a comment
There was a problem hiding this comment.
The diagnosis and the helper both look right to me: round_trip returns on the browser's response event while sending clears a microtask later and undoing a turn after that, so the old sites really were pressing into a window the dispatcher refuses, and the refusal leaves exactly the page an assertion on the un-undone state would find. Waiting on the line rather than on the preceding gesture's paint is the fix, and the sends > sent wait before round_trip is load-bearing — without it read >= sends is already true and round_trip returns on a page that has not started moving. Three things I'd raise, none of them blocking.
Three acting z presses landed on main after this branched. 267781d ("Settle threads by widget's standing answer") added test_a_withdrawal_a_tab_cannot_take_yet_..., test_a_withdrawal_restores_what_still_stands_not_what_stood_then and test_a_withdrawal_is_heard_by_a_tab_reading_a_later_version, and all three press z bare where the press is meant to act — so the merged tree, which is what CI runs and what lands, carries the norm plus three fresh exceptions to it. Two convert directly (undo(one) in the first, undo(pinned) in the third, each dropping the now-redundant round_trip after it). The second can't take the helper whole — its tab's polls are routed to refuse, so round_trip is the wrong wait there and the test says so — but the offer check before the press still applies. Happy to push that as a commit here if you'd rather it land with the norm than as a follow-up.
The line's promise trails the dispatcher by up to a paint. undo(page)'s first line rests on "no surface can promise a press the dispatcher refuses", and that holds for the predicate, not for its rendering: sendAction mutates sending with no paintKeys() on either edge, where undoLast calls it on both. So between a widget's send starting and the next paint, the line can still be offering undo while unrecordedGesture() is already true. For a reader that window is sub-frame and unreachable; for this helper it is the one way the wait can still read a stale offer and press into a refusal — with the difference that the failure now names itself ("the page never put the withdrawal in the wire") instead of reading as a wrong answer. One paintKeys() on each edge of sendAction, mirroring undoLast, would make the sentence in tests/CLAUDE.md true by construction rather than by whichever paint happens to be scheduled.
The wait is on a surface that also truncates by width. renderLine drops chips from the end of the walk when the room runs out, and the z row is page-level — outermost, so among the first to go. At the suite's 1200×900 default there's room; a future caller under a narrow viewport (the suite does set_viewport_size({"width": 400, ...}) elsewhere) would wait out its budget on a press that is perfectly live. Worth a clause in the helper's comment, since it's shared infrastructure now and the next caller has no reason to expect the line's width to be part of the contract.
How the repaint actually works out, in case it's useful later
For a widget gesture the sequence is: sendAction sets sending → post awaits poll() → the poll dispatches lf-actions → syncAsks → paintHere, which schedules an rAF while sending is still set → post resolves → sendAction's finally clears sending (a microtask) → the rAF fires and paints the chip back, with the predicate already true. So the chip's reappearance is a genuine statement that the press will be taken, which is what makes the helper sound. What isn't guaranteed is the other edge: lf-board drops the chip because #release() calls paintKeys() immediately before #send(), so its rAF lands after the send has started; other widgets get it only from the focus move their click happens to cause.
…main landed The line's offer is what `undo(page)` waits on, and it rested on `live` being one predicate rather than on the rendering keeping up: `sendAction` moved half of `unrecordedGesture` with no repaint on either edge, where `undoLast` calls `paintKeys()` on both of its own. So between a widget's send starting and whatever paint some other signal happened to schedule, the line could still offer `z` while the dispatcher was already refusing it. `lf-board` was covered by luck — `#release()` paints immediately before `#send()` — and every other widget by the focus move its click causes. Both edges now paint, so a key on screen is a key that works, and the helper's first wait is sound by construction. `267781d` landed three acting `z` presses after this branched, so the merged tree carried the norm plus three exceptions. Two take the helper whole. The third cannot — its tab's polls are routed to `refuse`, so `round_trip` is the wrong wait there and the test says so — but the offer check before the press applies, and it now has one.
|
All three taken, and main is merged in so the tree this describes is the tree CI runs. Pushed as The three presses from The paint. I did not add a gate for it, and that is a deliberate omission rather than an oversight. The window is sub-frame, and the existing The width. The helper's comment now says the line answers about room as well as liveness — Suite is green at the merged head: |
leaf-agent
left a comment
There was a problem hiding this comment.
Green at b6f6df6, and the three points from last round all landed. One new thing, from re-reading the predicate rather than the diff — non-blocking, and it may want to be its own PR.
unrecordedGesture()'s third term still has the unpainted edge this commit closes for its second. The predicate is undoing || sending.size > 0 || Boolean(document.querySelector(".lf-dragging")). undoing paints on both edges in undoLast, sending now does in sendAction — and .lf-dragging is written from four places in lf-board.js, two of which paint and two of which don't. The keyboard path does: #grab() adds the class and calls paintKeys() on the next line, under the comment that says why ("a grab is a press on an already-focused grip, so no focus event fires"), and #release() removes it and calls paintKeys(). The pointer path doesn't — the Sortable config's onStart ends on a bare this.classList.add("lf-dragging");, and onEnd opens on the matching remove and can leave at if (from === to && oldIndex === newIndex) return; before #send() is ever reached.
The window there is a whole drag rather than a frame, so it is wider than the one the commit's own comment is about, and it is the reader's to see. The luck that covered the other widgets doesn't reach it: the focus paint lands on the mousedown, and fallbackTolerance: 4 fires onStart after that. Nothing else is scheduled across the drag either — details below. So on a quiet board the z chip stands on the line for as long as the reader holds the card, over a press the dispatcher refuses. onEnd's early return is the same gap read backwards: a card dropped where it was picked up takes the class off with nothing following it.
Unlike the sending case, this one can be gated without the green-for-an-unstated-reason problem — though not in the journey test's existing drag, where the only prior gesture is a comment and undoable() skips those, so the assertion would pass on a line that never had the chip. It wants a board test that stages an action first: focus a grip, Enter/ArrowRight/Enter, round_trip, expect(...).to_contain_text("undo"), then pointer-drag that same card by the grip it left focused and assert not_to_contain_text("undo") between the move and the mouseup. The already-focused grip is the part that makes it deterministic — no focusin, so no paint but the missing one, and sending is empty because the first move round-tripped. I haven't run it, so that shape is a claim about the code, not a result.
The fix mirrors this PR: paintKeys() at the end of onStart and after the remove in onEnd. It reverts independently of sendAction's edges, so by one-concern-per-PR it probably belongs on its own — happy either way, say which and I'll open it.
Either way there's a line owed somewhere: keys()'s docblock states the duty ("A control whose keys change with its state declares every state's rows at once, each gated by its own row when, and calls paintKeys() when the state moves"), but it states it for a widget's own rows. .lf-dragging moves core's z row, and a twelfth widget that wears the class has nothing telling it so.
Why nothing else paints across the drag
Three candidates, none of which fire:
applyActions()returns at its ownif (document.querySelector(".lf-dragging")) return;before touching anything, so a poll's replay is not a paint here.syncAsks()is the unconditionalpaintHere()in that neighbourhood, but its callers are the first-render path and thelf-answeredlistener — not the poll loop. On a board with no ask being answered it doesn't run.renderLinehas no dragging gate of its own, so the chip is drawn fromwhen: () => !unrecordedGesture() && Boolean(undoable())and simply keeps whatever the last paint decided.
renderPanel's paintHere() is thread-driven, so it covers the drag only on a page where a comment happens to land mid-gesture.
|
Its own PR: #22, branched off Two things the review got wrong, both of which only showed up in the running. The test shape it proposed would have passed with the bug in. The already-focused grip is necessary for a different reason than the review gave, and it nearly cost the drag. The keyboard move that stages the gesture animates the card into its new column, and a The line owed to |
|
Third occurrence, on a commit that cannot have caused it: run 32439703608 on The branch is two commits behind main ( The failure, verbatimThe site is |
`7b41faf` and `287cb7c` each added a `z` that is meant to act — the fold test's reopen and the reject the second tab takes back — and both were written the way the rest of the suite was, as a bare press on the paint left by the round trip before it. That is the shape this branch converts: the press is refused while the page holds a gesture the log has not taken, and the refusal leaves behind exactly the page an assertion on the un-undone state would find, so the test reads a no-op as the wrong answer. Both take `undo()` whole. The reject one gains something beside the wait: its comment already said the press is offered here, and the helper's first line is that sentence as an assertion.
|
Fourth occurrence, and main has moved past the merge in The recurrence. run 32444366662 on What the merge brought. Four commits landed on main after The three presses that stay bare stay bare — the two the tests are about refusing, and the stale tab whose polls are stopped. Verification on this Linux runnerThe two converted tests, and then the family around them, at Bug-back, so neither conversion passes vacuously — the worry with a helper that opens on an That one cannot touch the fold test, whose
|
|
Fifth occurrence, and the first to land on a test this PR converted in its own first pass rather than in a merge — so the diff here already covers it and nothing new is needed. The recurrence. run 32444940294 on The commit cannot have caused it. Verification on this Linux runnerFour cores, so the eight-worker run is under about the contention CI's is. The failing test is green in isolation on The full suite at this PR's head The withdrawn-decision test passes there. The one failure is Nothing to fix on |
# Conflicts: # tests/test_render.py
leaf-agent
left a comment
There was a problem hiding this comment.
The incremental since b6f6df6 is e4aaf9e's two conversions plus two merges, and the conversions match what main added — 7b41faf's reopen and 287cb7c's reject, both acting presses. The four bare press("z") left in the file are the helper's own plus the three the tests are about refusing. One thing in the last merge is worth naming, because nothing on the PR says it.
26005a4 resolves its conflict by reverting 59bae22. Main's "Wait for accepted suggestion before undoing" added one line to test_a_withdrawn_decision_is_still_withdrawn_after_a_reload:
round_trip(page)
expect(page.locator("#sug-refill lf-old")).to_be_hidden()
page.keyboard.press("z")The merge took this branch's side of that hunk whole, so the merged tree is round_trip(page) then undo(page) with the assertion gone. git show 26005a4 --cc prints nothing for it — a resolution that takes one parent entirely leaves no combined-diff hunk — so the three-dot diff against main is the only place the revert shows.
I think the drop is right rather than merely defensible. That line waits for the accept's paint; undo()'s first line waits for !unrecordedGesture() && Boolean(undoable()), which is the predicate the dispatcher itself reads. On a fresh page there is no undo chip on the line until the accept is both in the log and out of sending, so the helper's wait implies everything the added assertion was buying, and the test's subject — the reload — never turned on the accept having painted first. Keeping both would leave a second, weaker wait for the same fact standing beside the one that states it, which is what the paragraph this PR adds to tests/CLAUDE.md argues against.
What's missing is that a reader can see it. The description tracks every other main commit this branch absorbed ("267781d landed three acting z presses…", and e4aaf9e's message does the same for the next two); this is the one that got reverted rather than absorbed, and it is the maintainer's. A sentence saying the line is superseded by the helper's first wait, with that reasoning, costs nothing and saves them re-deriving it from a combined diff that doesn't show the change.
Nothing else on the incremental. ci / test is still running on 26005a4; on a PR whose subject is that job, its result is the evidence, and it is not in yet.
|
Sixth occurrence, and this time main had moved far enough past The recurrence. run 32446311636 on The conflict is Verification at
|
|
Seventh occurrence, and this branch already carries it — The recurrence. run 32460214550 on The triggering commit cannot have caused it. What I checked on `0a4611e`
In The rest of the diff is |
|
Eighth occurrence, on a test this PR's own first pass converts, and The recurrence. run 32507562319 on
The six recurrences since this PR openedFour distinct tests over six red runs on six consecutive commits, each one a bare |
|
Ninth occurrence, on the same site as the eighth, and The recurrence. run 32514547746 on
The seven recurrences since this PR openedFour distinct tests over seven red runs on seven consecutive commits, each one a bare |
|
Tenth occurrence, on the site this PR's own first pass converts, and run 32525588277 on Every red
The two green runs in that window are I will stop tallying: further occurrences add nothing this comment does not already say, and each one costs a notification. If a later run fails on a site the diff here does not convert, that is new information and I will say so. |
z from the moment the line offers it
leaf-agent
left a comment
There was a problem hiding this comment.
9002594 replaces what the earlier commits on this branch were about, so this is a fresh read of the outbox rather than a follow-up on the undo() helper. The shape is right: one ordered list is a better answer than a promise chain plus a pending map that had to be reconciled through a later poll, and folding the read into the POST answer removes the "append succeeded, then a GET happened to see it" split the old round_trip had to model. Three things, the first of which I think is a real gap.
final is the only word that ends a retry, and it is spoken in one place while the door refuses in ten. deliver() retries forever unless it gets ok: false + final: true + a matching attempt, and only event_rejection writes that shape. Every other refusal /api/event can produce answers with a bare {"error": …}: the key gate in _answer (403 NO_KEY), the preview server's 403, and each shape gate in _post — unknown kind, unexpected fields, wrong field types, a bad comment anchor, a malformed attempt. All of them are deterministic, and all of them now put the page into a permanent 2-second POST loop. Inline below for the reachable one and what the fix looks like.
An accepted answer that fails to render is re-sent. The old post() carried a comment saying a fault in the render pipeline "is its own news and must not claim the send failed"; deliver()'s catch around receiveState now retries the POST instead. Suggestion inline.
retry: True on the 500 answer is read by nobody — neither deliver() nor Traffic._responded looks at it, and the field isn't in the registry's $events. Inline.
Nothing here blocks the design; I'd take all three as follow-ups on this branch rather than a separate PR, and I'm happy to push them if you'd rather not hand-apply. Two notes that aren't findings: ci / test is still running on this head, so the suite is not evidence yet, and #22 (the .lf-dragging edges) still stands after this — unrecordedGesture() keeps that third term — but its leaf.js hunk sits in the comment block this commit rewrote, so it will want a rebase.
|
The suite on run 32530249359: The wait above it names the fact it wants and reads a different one. Confirmed rather than inferred: with
|
`final` is the only word that ends a retry, and it was spoken in one place
while the door refused in ten. `event_rejection` covered the refusals that
reach `coordinate_event`; the key gate, the preview server's 403 and each
shape gate in `_post` answered with a bare `{"error": ...}`, which the
outbox reads as an incomplete answer — so a deterministic refusal became a
POST every `POLL_MS` for the life of the tab. The reachable one is the key:
`KEY_COOKIE` carries no `Max-Age` and the runtime navigates to the bare
version URL, so a tab restored after a browser restart has no key and every
widget is still live. Finality is now a property of the door having refused
rather than of the branch that decided it: the POSTed body is read in
`do_POST`, ahead of the one gate the door does not produce itself, and
`_refuse` writes every refusal through `event_rejection`.
An accepted answer that fails to render is no longer re-sent. The send
succeeded the moment the answer named the accepted event, so a fault in
`receiveState` is its own news; the comment `post()` used to carry said so
and the outbox dropped it along with the code.
`retry: True` on the 500 answer is gone. Nothing read it, and withholding
`final` already says retryable — a second word for one fact, free to
disagree with the one the browser reads.
`test_an_answer_carrying_an_older_pick_cannot_undo_a_newer_one` held its
first route by fetching the answer inside the handler, so the handler was
still inside that call when `Traffic.sends == 1` and the release reached for
a route the list hadn't got (CI run 32530249359). The hold keeps the request
in the wire instead, which is the arrangement `tests/CLAUDE.md` names, and
the answer it carries is the same one: the second pick cannot reach the
server behind an unresolved first.
|
All three taken, plus the red test the tally above named. Pushed as The refusal shape. The fix is the one the review preferred rather than the second-best: the POSTed body is read in The re-sent render fault. Applied as suggested. The path the review named isn't the way in —
The red suite. Same diagnosis as the tally: the handler was still inside Local run of What changed, by file
|
leaf-agent
left a comment
There was a problem hiding this comment.
The shape is what the last round asked for, and it is better than the second-best I named: final is now a property of the door having refused, _refuse is the one writer, and test_every_refusal_at_the_event_door_is_final_and_names_the_attempt reads the loop against the unlive-version case that could never have failed it. The retry removal and the render-fault return both land as described — I checked that nothing reads retry (deliver(), Traffic._responded, $events), and the announced/retryPause machinery is still live on the three branches that keep it. The test_render.py hold is the right correction too: route.continue_() leaves the request in the wire where route.fetch() kept the handler inside its own call, and the new sends == 1 assertion states the thing the test was resting on silently.
One finding, and it is the same failure this commit exists to close — reintroduced by where the body read moved to. Inline below, with a suggestion.
Reading the body in do_POST put it outside _answer's boundary, and one input escapes. _answer's docstring is explicit about what that boundary is for — "Unanswered, a fault drops the socket, socketserver buries the traceback in stderr nothing reads, and the banner says 'Server offline' about a server that is up". _read_posted now runs before it, and its except json.JSONDecodeError does not cover the one thing json.loads raises on bytes before the parse is reached: a body that is not UTF-8 gives UnicodeDecodeError, a ValueError but not a JSONDecodeError. handle() catches ConnectionError and nothing else, so it propagates out unanswered. I ran both sides of the commit against the same POST:
9002594: STATUS 500 b'{"error": "UnicodeDecodeError: \'utf-16-le\' codec can\'t decode byte 0x63 in position 4: truncated data"}'
d541c04: NO ANSWER: RemoteDisconnected: Remote end closed connection without response
A dropped socket is read by deliver() as postEvent throwing, which is "Connection lost — retrying your change…" and a POST every POLL_MS forever — the same permanent loop, on a deterministic input, arrived at from the other side. No browser sends it (postEvent stringifies an object), so this is a hand-written or a broken client rather than a reader; what makes it worth the line is that the old bare-{"error": …} answer was at least an answer, and this one is not.
The two refusals _read_posted does produce are the corner the new test doesn't reach. invalid JSON and event must be a JSON object go through _refuse with self.posted == {}, so event_rejection's if event.get("attempt") omits the attempt — and deliver() requires answer.attempt === event.attempt before it will treat a final as leave to put the gesture back, so those two land in the "Server answer was incomplete" retry too. That is inherent rather than a bug: there is no attempt to name in a body that wouldn't parse. But it is the one place the test's title isn't true of the door, and the eight cases in its list are all bodies that parse — which is why nothing in the gate had a chance to see the escape above. Worth a case for each, even if the assertion on them is weaker than the other eight.
Happy to push both if you'd rather they land here than as a follow-up. ci / test is still running on this head, so the suite isn't evidence yet; the new door test passes on its own here (3 passed).
`json.loads` decodes bytes before it parses, so a body that is not UTF-8 raises UnicodeDecodeError — a ValueError, never a JSONDecodeError. While the read lived in `_post`, `_answer`'s boundary caught it and answered 500; reading it in `do_POST` moved it in front of that boundary, and `handle()` catches only ConnectionError, so the request went unanswered. The outbox reads a dropped socket as a lost connection and re-posts the same attempt every poll for the life of the tab — the permanent loop this commit's predecessor exists to close, reached from the other side. Widening the clause to ValueError covers both and keeps the message honest: a body that cannot be decoded is not valid JSON either. `test_every_refusal_at_the_event_door_is_final_and_names_the_attempt` gains the three refusals decided before the body is a dict at all, which its eight cases could not reach — every one of those parses. They assert the door's shape minus the attempt, there being nothing in an unreadable body to read one out of.
|
Pushed The reachable asker got a test, and moved out of the fold. The 02:35 review worked out the shared-draft case in a The rest of the wrapping. The two suggestions were the two widest paragraphs, not all of them: the paragraph above the first ran to 84 and the whole section below sat at 85–92 in a file wrapped at ~80. Same words, re-wrapped together. The correction that landed while I was polling is right, and I have not acted on it. Review 4998856212 points out that What I verified locally
|
The absent-receipt prose named "a version the page has since retired" in three places, and publishing cannot produce that: `published_versions` filters `list_versions`, version files are immutable and never removed, so the live set only grows. A version a tab was served stays live for the life of the page. So the prose names the reachable refusals instead — a reply refused for an unknown parent its tab had not read yet, an action refused by a registry the page has since re-vendored — and the regression's docstring says outright that it drives the mirror of the reader's case, a version refused before it was published and re-pressed after, because that is the gate a test can walk the door through directly. `execute_event`'s own comment carried the same unreachable reading in the other direction. Its example is now one the log really does produce: a retried undo the first request already appended, which `undo_error` would refuse as a gesture already taken back. Also the two mid-paragraph strandings the re-wrap left at its joins, reflowed with the words unchanged.
leaf-agent
left a comment
There was a problem hiding this comment.
4561bdb replaces the unreachable retirement reading in all three places, and the two examples it puts there hold at the door. execute_event's is now something the log really produces: the first request appends the undo, so taken_back holds its target and a retry would earn has already been taken back — which is exactly what the accepted-attempt lookup above it is there to outrank. Both re-wraps landed with the word sequence unchanged (checked by token diff, not by eye).
One clause is left over from the old reading. The framing is "the ground a refusal stood on moves as the log grows", and the second example named under it — an action refused by a registry the page has since re-vendored — is not the log growing: action_contract_error takes its registry from load_registry(self.page_dir), so what moved is the page directory. It is reachable, for a reason worth having written down somewhere: handler_for captures layer once at construction, so after a re-vendor a live server still answers with the pre-re-vendor generation, _post's Leaf-Layer comparison passes, and the same request then reads the fresh registry off disk. The clause sits in three places — CLAUDE.md, the coordinate_event comment, and the regression's docstring, which states it most flatly as "the refusals whose ground the log really does move under (… action_contract_error behind a re-vendor)".
Two ways out, and the suggestions inline take the cheaper one — "moves under it", which covers both examples and leaves the examples alone. The other is to keep "as the log grows" and swap the example for the branch of that same function which is one: action_widget_tags folds each message's markup into the id→tag map, so unknown action widget flips to accepted the moment a thread's markup carrying that widget reaches the log. Either way the docstring's parenthetical wants the same edit.
"The ground a refusal stood on moves as the log grows" was written for the `unknown parent` example and does not cover the one beside it: a re-vendored registry moves the page directory, not the log. `load_registry` reads it off disk on every request while `handler_for` captured `layer` once, so the same request passes the generation check and then meets a fresher contract. "Moves under it" is true of both, and leaves the examples alone.
|
Pushed The retirement reading is gone from all four places, not three. The clause I put the examples under was too narrow, and This branch no longer merges into What I verified locally
|
leaf-agent
left a comment
There was a problem hiding this comment.
f4cf5d6 is both suggestions applied verbatim, and 451eae0's release-then-unroute is placed right: deliver() races postEvent against entry.read, so once the poll wins, the POST answer is abandoned before res.json() is ever called — fulfilling after the verdict cannot paint, and asserting after it would be green by construction. I scanned the rest of the file too: every other held.append(route) test releases through continue_, fulfill, abort, or refuse, so these five were the only strands left.
The hang 451eae0 is written against is not the hang the suite has. I ran uv run pytest tests --run-nightly on this head. It reached ~98% and then deadlocked for twenty minutes with no browser process alive, in test_a_claim_transfer_stops_a_waiter_already_inside_a_poll — a launcher test that never opens a page. /proc/locks named both sides: the leaf wait watcher held the write flock on page-locks/<hash>.claim.lock while blocked in a pipe read on the test's status.json FIFO, and the pytest worker was queued behind it on that same lock, inside interact.claim_page(page).
The mechanism is the two reads of status.json in PageWatch. tick takes the first one outside the lock as observed, and that is the read the test means to hold — but _read reads it again inside flocked(claim_lock(page_dir)), and the FIFO's open rendezvous takes whichever read gets there first. Caught on the inner one, the watcher holds the claim lock until the test writes the FIFO, which it only does after claim_page returns — so the two wait on each other with nothing to break the tie. Nothing between claim_lock and _read changes in fa59396..451eae0, so this is a race on main that the branch is meeting, not one it introduced.
That matters for the paragraph 451eae0 adds to tests/CLAUDE.md, because the branch's own history contradicts its causal sentence. All five stranded holds were already present at e0ee8bf, whose ci / test went green in 8m16s; the hangs start at the very next commit, cc1d561, and every ci / test since has been stuck in the suite step. So "Leaving it there stranded Chromium during the Linux worker's session teardown" is the one clause I can't ground — the release is still worth keeping on its own terms, but as written the norm sends the next reader to the wrong subsystem. Naming what the hold actually is (a live route handler the test no longer needs) without claiming the teardown symptom would keep the paragraph and drop the part that isn't evidence.
This head has no ci run. 451eae0, f4cf5d6, 4561bdb, and 1a5169a each produced a tend-review run and no ci run at all; the last ci to start on this branch was 362023c's, which was cancelled. The three before it were the hung ones — I cancelled them, since they had been sitting in the test step for three hours and are the likeliest thing holding the branch's runner slots. Worth confirming a fresh ci fires before treating any of this as verified; nothing on this head has been through the gate.
One other thing a reader of the merged tree will hit: main is red independently of this PR, on test_z_walks_back_through_gestures_rather_than_toggling_one (tests/test_render.py:15060, assert 'Rewritten.' == 'First line o... of the note.') in run 32549479170.
Reproduction notes
Environment: this runner (4 cores), uv sync --frozen plus the pinned Chromium headless shell, on 451eae0.
The deadlock evidence, read live while the run was stuck:
/proc/locks
23: FLOCK ADVISORY WRITE 54595 08:01:9476083 0 EOF
23: -> FLOCK ADVISORY WRITE 53375 08:01:9476083 0 EOF
54595 interact.py wait .../test_a_claim_transfer_stops_a_0/codex-page
wchan=anon_pipe_read
fd 5 -> .../page-locks/3a4aeae22b0b71f320e4624896d497a6.claim.lock
fd 8 -> .../test_a_claim_transfer_stops_a_0/codex-page/status.json (the FIFO)
53375 pytest worker gw5
wchan=locks_lock_inode_wait
fd 16 -> .../page-locks/3a4aeae22b0b71f320e4624896d497a6.claim.lock
Seven of the eight xdist workers were parked in futex_do_wait with no headless_shell process anywhere, which is what ruled the browser layer out before I looked at the locks.
It is a race, not a certainty: the test passes in 2–4s on its own, and twelve consecutive isolated runs with four CPU burners loading the box did not reproduce it. It needs the FIFO's open to land on the in-lock read, which is why the full suite reaches it and a focused run does not.
The commits I checked the five held routes against:
e0ee8bf— all five strands present,ci / testsuccess in 8m16s (run 32543990152).cc1d561,c816b99,e3c795a— first three hangs, all stuck in🧪 Test suite(lintgreen on each).
leaf-agent
left a comment
There was a problem hiding this comment.
Why this branch had no CI for five commits — and what cleared it. pull_request-triggered workflows only dispatch once GitHub can compute refs/pull/N/merge. From 362023c onward the PR was mergeable: false / "dirty", so that ref froze at 278d3e7 (the merge of 362023c into fa59396, 02:44) and ci simply never fired on 1a5169a, 4561bdb, f4cf5d6, 451eae0, or 75cced9 — no run, no red, nothing on the PR to say the gate was missing. 75cced9 didn't fix it, because main had moved to 871edb2 and conflicted again. a987440 does: the PR is mergeable: true, the merge ref recomputed to 681253e, and ci started on it at 06:03 — the first run on this branch since 02:44. Worth recognising the shape next time, since the symptom is silence rather than failure.
Same cause, second effect: every tend-review run in that window checked out the frozen refs/pull/21/merge, so each one read the tree from 02:44 rather than the commit it was reviewing. I read the head commits directly instead.
What I checked while the gate was down. On 75cced9 — the head when this run started, carrying the 29-hunk resolution against cf35cb0 — pre-commit run --all-files was green, tests/test_interact.py gave 447 passed, and tests/test_render.py --run-nightly gave 511 passed, including test_z_walks_back_through_gestures_rather_than_toggling_one, which is what cf35cb0's own ci went red on. On the current a987440, tests/test_interact.py gives 456 passed; the browser suite there is the running ci's to answer. The resolution reads sound in the places the two designs actually collided — execute_event folding _matching_attempt into the held append lock in place of the standalone accepted_attempt, and main's StateProjection facet model displacing BROWSER_EVENT_FIELDS — and 09a40d6 only had five hunks to settle against 871edb2, against 29 the merge before it.
One thing the resolution kept twice — inline on interact.py.
Evidence and notes
Environment: this runner (4 cores), uv sync --frozen, pinned Chromium headless shell.
The dispatch mechanism. gh api repos/max-sixty/leaf/pulls/21 at 75cced9 → {"mergeable": false, "mergeable_state": "dirty"}; git ls-remote origin 'refs/pull/21/*' → refs/pull/21/merge 278d3e7…, and git log -1 278d3e7 → Merge 362023c into fa59396. gh api .../workflows/ci.yaml/runs?branch=fix/ci-32429171821 listed 362023c (cancelled, 02:44) as the newest and nothing after it, while tend-review — pull_request_target, which needs no merge ref — ran on all five later commits. After a987440: {"mergeable": true}, refs/pull/21/merge 681253e…, and an in_progress ci run on a987440.
Runs. 75cced9: pytest tests/test_interact.py -q → 447 passed, 6 skipped; pytest tests/test_render.py -q --run-nightly -n4 → 511 passed in 8m39s; pre-commit run --all-files → all 11 hooks passed. a987440: pytest tests/test_interact.py -q → 456 passed, 6 skipped.
One local failure that was never this PR's. On 75cced9, test_demo_recording_drives_the_browser_journey failed for me whenever test_product_page.py and test_site.py ran together under -n4 (could not select 'Backfill history' in #p2). It failed identically on both merge parents, passed inside cf35cb0's own 8-worker CI run, and is fixed on main by waiting for all three readiness stamps rather than lfUpgraded alone in scripts/record-demo.py. a987440 carries that fix, so it is moot now — noting it only so a later reader doesn't re-chase it.
The claim-lock deadlock from the last review did not recur across these runs, but it is a race and a clean run is weak evidence either way.
The four `**/api/state*` unroutes still in the file arrived with main's merge — #21's own new tests — so the comment saying the `**/api/event` unroutes are the boundary was true of what this branch converted and false of the file it left. Convert them rather than write the exception down: the norm is absolute, and a survivor reads as one that was checked and found safe. Two are the converted shape exactly — refuse, lift, refuse again — which `CutOff` could not express because `restore` is one-way. `cut()` is the other half of that switch. Two lift a handler that answers as well as refuses, so the switch is a flag the handler reads at its top and continues on, written where the answers are.
## Problem `.lf-dragging` is half of [`unaccountedGesture()`](https://github.com/max-sixty/leaf/blob/85631b307072a9fb7135c4b01e9e66820d47a4b1/plugins/leaf/skills/leaf/assets/leaf.js#L10031), so a widget wearing it moves core's `z` row — and `lf-board` wrote the class from four places, of which only the two on the keyboard path painted. `#grab` added it and called `paintKeys()` on the next line, under the comment that says why; `#release` removed it and called `paintKeys()`. The pointer path did neither: Sortable's `onStart` ended on a bare `classList.add`, and `onEnd` opened on the matching `remove` and could leave at its `from === to && oldIndex === newIndex` early return before `#send` was ever reached. The window on the first edge is a whole gesture rather than a frame, and nothing else covers it: the focus paint lands on the mousedown and `fallbackTolerance: 4` fires `onStart` after it, `reconcileState()` returns at its own `.lf-dragging` gate so a poll's replay is not a paint, and `syncAsks()` is not in the poll loop. So on a quiet board the line went on offering `undo` for as long as the reader held the card, over a press the dispatcher was already refusing. `onEnd` is the same gap read backwards: a card dropped where it was picked up takes the class off with nothing following it, so the offer stayed withheld from a press that was live. ## Solution The paint moves to the class, in core: `dragging(el, on)` toggles `.lf-dragging` and calls `paintKeys()`, and `lf-board`'s four sites become `dragging(this, true/false)` — the two that already painted along with the two that didn't. Core owning the writer is what closes the gap for the widget after this one. The class is core's own vocabulary and core is its only reader (`unaccountedGesture`, and the replay gate in `reconcileState`), so a duty stated in prose — "whoever moves the state paints" — would leave the twelfth widget to learn it from a docblock or not at all, with a paint that never happened as the symptom: invisible to the file lint, which doesn't read modules, and to `version check --render`, which has no wrong artifact to compare against. That is the shape `CLAUDE.md` names under **The widget list is never closed** ("Before gating an obligation every adopter must remember, ask whether the declaration already states enough for the layer to do it once"), and the resolution the `data-lf-state` mark already took. Here it needs no declaration at all, because the class is already the layer's. The paint coalesces to a frame, which is what lets one call stand for everything else the same gesture moved: the widget's own rows in `#grab`, where the grab is a press on an already-focused grip and no focus event fires, and — on the drop that does send — a frame landing after `#send` has stated what is in flight, so it still reads as a gesture the log has not taken. `onEnd` keeps the call ahead of its branches, because the branch that returns early is the one with no send behind it. ## Testing `test_a_pointer_drag_stops_the_line_offering_the_press_it_refuses` stages a keyboard move so there is a gesture to take back, then pointer-drags that same card by the grip the move left focused — so the mousedown lands on an already-focused control and fires no focusin, leaving the paint under test as the only one that could clear the offer. It reads the line once at each edge, and each read fails on its own edge with that edge's paint removed. <details><summary>Two ways this test passed while proving nothing, and what fixed each</summary> **The read has to be once, not `expect`.** Written as `expect(...).not_to_contain_text("undo")`, the mid-drag assertion passed with the fix removed — and so did the assertion after the drop. A probe against unmodified `main` shows why: mid-drag the class is on and the line still says `z undo`, for the whole 0.9s the probe watched, so the defect is real — but `expect` re-asks for five seconds, and a version poll two seconds out repaints the line whatever the drag did. That is `tests/CLAUDE.md`'s "a state the page passes through is not a state to poll for", read the other way round: the page passes through the *asserted* state on its way back from a paint nobody asked for. `_painted_line` consumes the frame `paintHere` coalesces to and reads once. ``` main, mid-drag: ['lf-dragging', '⏎ / space grab the card … z undo … esc let go …'] main, after drop: ['', '⏎ / space press it … esc let go …'] ← no undo row ``` **A box measured across the FLIP is a box the card has left.** The keyboard move animates the card into its new column, and `bounding_box()` taken across that read x=737 where the settled answer was x=1092. The press lands on the grip at that instant and the pointer is somewhere else by the mousemove after it, so Sortable never starts the drag — and the failure arrives as `wait_for_selector("lf-board.lf-dragging")` timing out on a page nobody dragged, thirty seconds later and nowhere near the cause. The test waits for the card's own animations to empty first. **Bug-back.** Each edge on its own at `dbb520f`, when the paint sat in `lf-board`: ``` onStart paint removed: AssertionError: the line offered a press the dispatcher refuses for the length of a drag onEnd paint removed: AssertionError: the drop that sent nothing left the line refusing a press that is live ``` And with the paint now in one place, dropping `paintKeys()` from `dragging` takes out the same assertion (`1 failed, 24 passed` over `-k "board or dragging or pointer_drag"`). **The suite**, run the way CI runs it on this Linux runner: `869 passed, 6 skipped in 590.59s`. `pre-commit` is clean on both changed files. One run in between failed `test_a_withdrawn_decision_is_still_withdrawn_after_a_reload`, which passes alone and passed on the unmodified branch head under the same load — a contention failure on a page this branch does not touch. </details> Found reviewing #21, which closes the same shape of gap for `sending` — the other term of the same predicate. This one reverts independently of that, so it is on its own branch off `main`; the two touch `leaf.js` in different places. Merged with `main` at #21, which renamed `unrecordedGesture` to `unaccountedGesture` and moved the `.lf-dragging` replay gate into `reconcileState` — the names above are the post-#21 ones, and the mechanism is unchanged under them. --------- Co-authored-by: leaf-agent <[email protected]>
## Problem [Run 32553975712](https://github.com/max-sixty/leaf/actions/runs/32553975712) failed `test_a_decision_travels_between_tabs_and_the_log_has_the_last_word` — `expect(tab.locator("#sug-thistle lf-new")).to_be_hidden()`, actual `visible` — with the log holding the reject the assertion is about. The cause is the test's own instrument: `page.unroute` drops its handler while a request is in its hands, and that request is then neither continued nor refused. It never comes back, and nothing in the page times it out. The lost poll is not the cost. A send ends in a poll of its own, so a lift landing inside that poll leaves `post` awaiting forever — the widget the gesture was made on stays in `sending`, `reconcileState` skips it for the rest of the tab's life, and the page sits at `aria-busy` disagreeing with the log about a decision the log has taken. Here the cut-off tab rejects a suggestion the log already holds an accept for, `third.unroute("**/api/state")` lands inside the reject's own poll, and that tab never folds again. ## Solution A refusal stays on the page for its whole life and answers every request it receives; lifting changes which answer, not whether there is one. `CutOff` keeps that handler installed and switches polling between refusal and continuation. On current `main`, eleven of the twelve polling-route lifts now use this pattern. The remaining `arrive()` unroute is safe because no send or later wait depends on that page, and the next call navigates away. ## Testing The original failure reproduced four times in 48 loaded runs; the fix passed the same 48 runs. The current-main merge passed 13 affected browser tests. After the final conversion and simplification, the three directly changed tests passed and `pre-commit` was clean. <details><summary>The reading that named it</summary> Three tabs, `third` being the one cut off. `polls` counts entries to `poll()`, `asked`/`heard` are `Traffic`'s counts of what the browser reported: ``` DIAG traffic third {'sends': 1, 'acked': 1, 'asked': 6, 'heard': 6, 'read': 1} DIAG third {"state": null, "busy": "true", "stage": "minted", "polls": [{"n": 1, "stage": "json"}, {"n": 2, "stage": "json"}, {"n": 3, "at": 3664, "stage": "fetch"}, <-- never returns {"n": 4, "stage": "json"}, {"n": 5, "stage": "json"}, {"n": 6, "stage": "json"}, {"n": 7, "stage": "json"}]} DIAG first {"state": "reject", "busy": null, "stage": "polled"} DIAG second {"state": "reject", "busy": null, "stage": null} DIAG log: [note, sug-refill accept, sug-thistle accept, sug-thistle reject] ``` Seven polls, six requests: the third one's `fetch` was never issued to the network the browser reports on, and never settled. `post` therefore never reached its `return minted`, `sendAction`'s `finally` never ran, and `sending` kept `sug-thistle` out of every later reconciliation — the timer polls beside it kept working the whole time, which is why `told(third)` returned and only the widget was wrong. </details> <details><summary>What this does not change</summary> The runtime's own behaviour under a poll that never returns is untouched: a stalled connection would pin a widget the same way, since `post` awaits the read it ends with and `sending` is released only behind it. That is reachable without any instrument, and #21 is already reworking that path, so it is left alone here rather than changed underneath it. </details> --- Automated fix for [failed run](https://github.com/max-sixty/leaf/actions/runs/32553975712) --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
`notes/workspace-followups.md` has been presenting finished work as the plan since 9 September. It opens with "Start #2, #3 and #4 as one coordinated contract batch; run the review-queue simplification #8 alongside it" — all four of those shipped that week — and carries thirteen briefs, each with a live "Next task" and "Done when", for work `TODO.md` dropped as complete. This removes them and leaves the six `TODO.md` still links: #11, #14, #19, #20, #22 and #23. The trim follows the convention #666 set and the reason `CLAUDE.md` gives for it: a note is never a second specification for shipped behavior. #666 removed #6, #7, #16 and #17 the same way, rewriting the two `Owner / dependencies` lines in surviving briefs that named them; it simply did not reach the rest. Each removal is evidenced by the commit that took the item out of `TODO.md`, not by a reading of the current code: | Brief | Removed from `TODO.md` by | | --- | --- | | #1, #3, #5 | [`0f7f06a6`](0f7f06a) — "Completed workspace items #1, #3, and #5 are removed from `TODO.md`" | | #2, #4, #8, #9 | [`28b5da99`](28b5da9) — "the completed #2, #4, #6, #8, #9, and #17 backlog entries are removed while preserving the deferred evaluation work" | | #13, #15 | [`6df40353`](6df4035) — "closes three bounded workspace follow-ups" | | #10, #12 | [`c9eaa2c6`](c9eaa2c) — the continuation cue and the adaptive Threads placement | | #18, #21 | [`e46c8b93`](e46c8b9) — the monitoring workspace and its package-owned root | Alongside the briefs, three group headings are now empty and go; the `Suggested work packages` table loses the rows whose whole scope landed; and four cross-references that named a removed ID are rewritten — #14's dependency on the Threads-placement experiment, #20's ordering behind #8, and the two sentences in `Reproduction record` and `Browser evidence` that pointed at briefs no longer here. #14 needed more than a rewritten pointer. The experiment it waited on was settled in two steps, and only the first removed an ID: [PR #520](#520) kept the adaptive placement and deferred the modal-focus work to #24, which landed in [PR #536](#536) as inertness, dialog semantics and focus containment for a covering workspace. That is the surface #14 exists to verify, so its `Done when` — "Avoid imposing a modal focus trap on a nonmodal panel" — described the containment #536 shipped as the defect to avoid. It now states the containment the shipped modality requires, and the dependency line names both settlements. The dated evidence sections themselves stay. They are the record of what was read in a browser on 8 September, not a plan, and the note's own header scopes them to that date. No test covers `notes/`, and this changes no behavior, so there is nothing to regress. `pre-commit` passes on the file; the `TODO.md` → note anchors all still resolve, and no surviving text references a removed ID. --------- Co-authored-by: leaf-agent <[email protected]>
…output (#2500) The Worker, its container (`worker/leaf_website`) and the site build (`dev/leaf_dev/site.py`) are Leaf's own code, ship in one release, and `leaf-dev verify-site website-worker` drives them together on every PR and before each deploy. Several checks on that path validated values one of them produced for another, as if it came from the internet. They go; validation of what does come from the internet (startup reports, interaction batches, request cookies, sample ids, page-fault bodies) stays. Part of the complication-weight sweep (#26 there, and the dev half of #21). **Removed** - **Site manifest:** the Zod schemas and `parseSiteManifest` in `worker/src/routing.ts` become TypeScript interfaces. `site.py` constructs every field the schema checked (the asset path from the release, the state from the current revision, the image from a media file `check_links` proves resolves, title and description refused at build). - **Agent start/fail protocol:** no longer validated at both ends. The Worker's failure code is typed `WorkerFailure = "rate_limited" | "startup_failed"`, so "only the container writes `turn_failed`" is a type on the one producer; `askContainer` reduces to ok → `json()`. The container reads `posted["event"]` and `posted["failure"]` directly; an unknown code still fails at `FAILURE_RECEIPTS[failure]` and an unknown event at admission. No public path reaches these routes: the Worker 404s every `/_leaf/` path, `pageRoute` forwards only API, layer, session and vendored-file paths, and the container matches routes exactly. - **`OPENAI_API_KEY` runtime check:** `wrangler.toml` requires the secret, so deploy refuses without it. - The shape check on the sample URL the container returns, three routing guards on values already checked or freshly generated, `_finish_turn`'s stderr line repeating `turn_stream_completed`, and `_select_page`'s `events.jsonl` check. - **Dev catalog readers:** `example_data.py` and `site.py` stop explaining dead example routes and missing captions, which `check_links` refuses or a `None` access reports; `example_previews.py`'s fallback is `min(glob)`. **Behavior change:** a build or container bug in these fields now fails as a routing or Python error in `verify-site` instead of a named validation error. The container's private `/_leaf/agent/fail` route would accept `turn_failed` if something posted it; only the Worker's type and the route's unreachability rule that out. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
… a reply to a withdrawn message (#2507) Python code that restated a rule a stronger mechanism already enforces, explained malformed agent input the agent would fix from a plain refusal, or recovered from states no Leaf writer produces. It goes; what stops bad input passing silently into admitted events, stored decisions or anchors stays. One confirmed bug is fixed on the way. Part of the complication-weight sweep (#19–#24 and #30 there). **Bug: a reply to a withdrawn message opened a phantom thread.** Admission checked a reply's `parent` against every message in the log, withdrawn ones included, while the thread fold drops withdrawn ones; so a reply to a reaction the user took back was admitted and landed in a second thread named after the withdrawn reaction. `_parent_error` now refuses a withdrawn parent, and `UndoReading` counts any child, a reaction included, as standing on a reaction, so every standing message's parent stands. The fold reached the phantom through recovery written for a torn opening line, which the writer cannot produce (it fsyncs before returning an id and repairs a torn tail before the next append); that recovery goes from `build_threads`, `seat_root`, `thread_context` and `logged_id`, with its two tests. **Restated rules (#19):** the start line's one-line rule now lives once in the kernel registry, including a progress reply's `start`; `record_pickup`'s phase, `cmd_wait`'s argument pair, `deferred_value`'s re-checks, the `Unresolvable` catch, the JSX refusal (the browser check reports it), the `check_app_server_endpoint` alias, the entries-are-dicts check and the `user_views` JSON round trip (now `deepcopy`) go. **#20:** the `fcntl` ImportError fallback goes; Leaf runs only on POSIX and a plain import fails as early. **#21:** `capture_anchor` refuses a missing quote with one message instead of diagnosing fences, removed words and data bodies (the retired- and gone-section refusals stay); `leaf data set` no longer explains empty stdin; `task open` no longer explains a thread subject the schema refuses. **#22, #24:** `activity._moment` stops tolerating timestamps no Leaf writer produces; the interaction log stops re-validating on read what it validated on write: it skips a torn line, and marks a split record whose parts don't join into the entry they name as `interaction_unreadable` (ingress checks each part, not the whole). **Rules moved to their owners (#30):** the layer's `$` fact shapes are one `LAYER_FACTS_SCHEMA`, leaving only cross-references and what a schema can't say in code; `delivery.pending_batches` is gone for `hook_transport.read_plans`; `codex run --handshake` is required; the `RANK` pattern and identity fields' non-emptiness are in `detail_schema`. Patterns that replaced a `fullmatch` end with `(?![\s\S])`, because Python's `re` lets `$` match before a final newline. `lf-suggestion`'s rules stay in Python: no existing declaration can say how many slots it holds or that it can't nest. **Behavior changes:** a reply or reaction to a withdrawn message is refused; a reaction to a reaction blocks undoing the parent reaction; refusals read as the schema's or parser's message; a log that already holds an orphaned message (possible only from the bug above) now fails to read instead of showing a phantom thread. The browser runtime's half of #23 is in the runtime cuts PR, which follows this one. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
…is HTML's phrasing less what draws its own box; shipped chips gain their spaces Where words are read (#21). The runtime found the element a run of words is read in after the walk, by climbing each text node's parents past inline tags, so a staged widget's top-level `<span>` climbed to its shadow root and stopped there: two widgets side by side under a `<div>`, each holding a `<span>`, read "alpha beta" before they staged and "alphabeta" after, where the file's reading kept "alpha beta". The reading walk now carries that element in its context (`enter`, `words`), as passages.py carries each element's block, across shadow roots as across the light tree, and a slot's words are read among the words where the slot draws them. Each segment carries it; a space stands between two runs read in different elements or across a line break (`spacedFrom`), in the raw reading as in `quoteFrom`. `segmentTextBlock` and its climb go. Which elements join words (#20). `$passages.inline` listed 28 tags and missed `<output>`, so `alpha<output>beta</output>gamma`, drawn and found by both browsers as one word, read "alpha beta gamma". It goes. `$passages.phrasing` comes in as on link-previews (4b056fc), JSON and `why-` text alike, so that merge is trivial, with `$passages.apart`: the phrasing elements drawn as boxes of their own, each with its reason, from the review's table of what each engine draws and finds (controls: button, select, datalist, textarea, meter, progress; embedded content: audio, video, canvas, iframe, object, picture, svg). Every other phrasing element, and a widget declared `x-inline`, runs into the words beside it: output, label, slot and a ruby's base among them. Both readings derive the set from the two facts (`JOINS_WORDS`, `JOINS_WORDS_TAGS`). An element outside the set, a text block or a widget among them, reads its words apart, inside a text block too: `alpha<button>beta</button>gamma` in a `<p>` now reads "alpha beta gamma" in both. The file's reading no longer reads text blocks at all, so `why-blocks` stops claiming they decide spacing. link-previews' `why-phrasing` says only the browser reads the list; that sentence changes at the merge, since the file's reading now reads it too. Said values. An `x-says` value is drawn as its element's caption (lf-sample), label (lf-column) or popover (lf-gloss), never among the element's words. The file's reading read one apart only outside a text block and the browser's never did, so a label beside its element's own words read "Headbody" in the browser and "Head body" in the file, and a gloss's tip in a paragraph "glossTip" in both. Both now read every said value apart (`enter`'s `SAID`, `_said`). Shipped chips (#19). The option chips in examples/heat-loss.html, adjacent `<small>` elements with nothing between them, draw as separate boxes but read "£180one afternoon", so search for "£180 one afternoon" found them on main and not here. They now have whitespace between them, as do the same chips in three of packages/default/registry.json's `x-example`s, the site nav's example in docs/package/registry.json, and four figure captions in docs/ui.html whose label is a block by CSS alone. No other adjacent chips stand in examples/, docs/, packages/ or skills/. tests/quote_cases.json gains an output, a ruby's base, a widget's slot drawing two spans, a button's label in a text block, two staged widgets side by side, as one word and as two, and a said label and a said tip; its browser side renders said values. Both runtimes answer all 27. A runtime test holds that a slot's words run into the shadow tree's words around it. Tests, each failing on c8bddac in Chromium and Firefox: - test_page_search_finds_words_an_output_runs_into (#20); - test_page_search_reads_two_staged_widgets_side_by_side_apart (#21), with the shared staged cases failing in the browser's runtime test on c8bddac and passing in Python there and here; - test_page_search_reads_a_said_label_apart_from_its_elements_words.
…ed glide's scroll at its last frame (#6116) Two browser timers decided what the reader saw by how fast the machine ran. This change ends each of them on an event instead. **Holding the reading place (`SETTLING_MS`, version.js).** After a layout shift, such as a width change, the runtime puts the reader's place back each time late widget layout lands, and it stopped doing so after 1 s whatever was still preparing. In a probe in Chromium and Firefox, a widget that prepared for 1.5 s moved the line being read by 200 px. The window now closes after the last widget preparation has landed and one quiet rendering update has passed, when the reader's input ends the last hold, or on a revision. The 1 s cap runs only while nothing is preparing, for a page that never settles, such as an animated chart. Preparations of 1.5 s and 4 s now keep the line in place. **Scroll-end fallback (80 ms and two frames, arrivals.js).** `scrollend` already ends every scroll that moves the box, in Chromium, Firefox and WebKit. The fallback decides only scrolls that get none, mostly Leaf's own glides, whose last frames move less than a pixel. A glide whose last write moves nothing now ends right there, so the scroll a `d` press makes ends in about 145 ms instead of about 230 ms in Chromium and Firefox. WebKit's last glide frame still moves the box, so it is unchanged. What to weigh: - A widget preparation that never ends keeps the window open, though with no per-frame work, until the reader acts, a revision arrives or 12 size changes land. - A CPU-starved Firefox still loses a key pressed during a scroll: it applied the key's scroll up to 800 ms late, so the 80 ms ended the reader's scroll before it moved (10 of 10 under heavy background load, 0 of 8 at normal priority). No event says a scroll won't come. Ending on `scrollend` alone would need a backstop of about 8 s and rules predicting which inputs move nothing, so the 80 ms stays. - The controller now subscribes to preparations once, when it starts. A subscription per window missed a preparation that began just before the window opened, so the window stayed open and put back a later, unrelated change. - No browser test covers a slow preparation, because tests can't reach `holdRendering`. The evidence for it is the probes. Max asked for this ("research #21") in a review of timers that race a slow machine. Codex reviewed it three times. It found a frame pause over 1 s that still closed the window early, a per-frame loop left running after the last hold ended, and an expired cap's queued close racing a preparation that began within it. Each is fixed, with a probe showing the line move before the fix and hold after it. Tests: `pnpm run test:runtime` (992), including a new arrivals assertion that fails on main; `check:browser`; seven reading-place browser tests, including the never-settles one; four scroll tests, two in Firefox. > _This was written by Claude Code on behalf of max-sixty_
The original
zrace exposed several independent answers to whether a browser event was sent, accepted, read, projected, and safe to undo. This change replaces them with one ordered, idempotent client outbox and one server-side execution record per attempt. Ambiguous responses retry the same attempt; acceptance advances delivery order; replay and undo stay gated until a complete authoritative projection accounts for that attempt.Recorded state now has one semantic model. Registry declarations name coordinates as
(owner widget, unit, facet); one projector combines the authored baseline, surviving action/report winners, and unresolved recorded outbox actions. Whole-widget reconstruction preserves ordered siblings and nested ownership, terminal refusals remain tombstoned until their correction commits, recordless actions paint only after acceptance, and a failed state render rolls global history back to the last complete read.The server authenticates before reading event bodies, validates mutable history and appends under one log lock, coordinates concurrent copies of an attempt, returns accepted state in the POST response, and expresses deterministic refusals in the outbox protocol. The browser rejects an attempt reused for two active gestures before it can account the wrong payload.
Coverage includes lost and delayed responses, concurrent retries and undos, definitive refusals, poll-proven acceptance, send serialization, stale and malformed state, authoritative replay and undo, semantic facet precedence, nested/thread widgets, sibling position composition, live-gesture deferral, and refusal recovery. The exact integrated local suite reports 997 passed and 1 skipped; all pre-commit hooks pass.