Skip to content

Wait out bookkeeping posts in round_trip - #1016

Merged
max-sixty merged 3 commits into
mainfrom
round-trip-bookkeeping
Sep 23, 2026
Merged

max-sixty merged 3 commits into
mainfrom
round-trip-bookkeeping

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

test_opening_threads_acknowledges_the_first_visible_answer failed once on #1010's first CI attempt with no read event in the log. The cause is the harness wait, not the runtime.

round_trip treated a trip as over once the outbox held no attempt. Some posts skip the outbox: a bookkeeping event such as read (#987, delivery.js), the page's own error report, and a media upload (layer-client.js). So sending around a gesture whose event is a read returned as soon as the read's POST went out, and the log read behind it raced the server's append. Holding the read's POST for 300ms reproduces the CI failure every time (IndexError on _read_events(...)[-1]). 80 copies under -n 12 did not reproduce it on a Mac.

  • round_trip also requires every issued post to have ended (acked == sends), through a heard_back predicate on one ledger reading. The outbox condition still covers a failed post that the page will retry.
  • The read-state test holds the read before the server appends it, so every run hits this timing. While the read is held, it asserts that the ledger does not yet count as heard back. With the old predicate, that assertion fails on every run.
  • Three paint-failure tests (test_a_failed_ask_banner_paint…, test_a_failed_ask_list_paint…, test_a_failed_thread_list_update_retries…) held /api/event and released only the first request. The page's own error report of the injected failure was also held and never ended. The stricter round_trip exposed this. Those tests now wait with holding for both requests, then release both.

traffic.js's header, the round_trip comment, and tests/AGENTS.md now describe the wait as both conditions and list the posts that skip the outbox.

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

🤖 Generated with Claude Code

max-sixty and others added 2 commits September 23, 2026 09:16
`round_trip` judged a trip over when the outbox held no attempt, but a
bookkeeping event such as `read` never enters the outbox (PR #987). So
`sending` around a gesture whose own event is a read returned as soon as
the read's POST was issued, and the log read behind it raced the server's
append. That is how `test_opening_threads_acknowledges_the_first_visible_answer`
failed once on PR #1010 with no read in the log.

`round_trip` now also requires every issued post to have ended
(`acked == sends`), through a `heard_back` predicate on one ledger reading.
The outbox half still covers a failed post the page will retry.

The read-state test now holds the read before the server appends it, so
every run puts the log read on that edge; it asserts the ledger reads as
not heard back while the read is on the wire, which the old predicate
failed deterministically.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Three tests route /api/event into a list, inject a presentation failure,
and continue only the first held request. The page reports that failure
with its own `error` post, which the route also held and nobody released.
`round_trip` now counts every post until it ends, so that stranded report
made the final wait run out. Each test now continues every request it
held.

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

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release loops read a list nothing has pinned yet. Each of the three repaired tests now needs every held /api/event request released, because round_trip no longer returns while a post is outstanding — but for route in held reads that list at a moment no stated fact covers. holding(page, held, 1, …) guarantees one entry, and the page issues two posts: the gesture's event and the page's own error report (measured on this head: ['action', 'error'] in both widget tests, ['resolve', 'error'] in the conversations one). The error report is issued a beat after the gesture and its route reaches the driver later still — the gap holding exists to close. If it lands after the loop, page.unroute leaves it paused for good, acked never reaches sends, and round_trip spends its whole 30s deadline and fails: the same load-dependent shape this PR removes. One holding call states the count instead of taking it as it comes.

The new contract names a narrower rule than the code. read is the only kind carrying "bookkeeping": true in registry.json's $events.kinds, and it is not the only post that skips the outbox — reportPageError reaches postEvent directly ("sent bare rather than through post()", in layer-client.js), and so does uploadMedia. All three count sends and acked, and none of them enters pending. The three tests this PR had to repair were broken by the error report rather than by a bookkeeping event, so a reader who follows tests/AGENTS.md or the traffic.js header to work out why their round_trip now hangs is sent looking for the wrong kind.

The change itself holds up: I ran the four touched tests against the merged tree and they pass, and test is green on this head.

Comment thread tests/test_render_widgets.py Resolved
Comment thread tests/test_render_widgets.py Resolved
Comment thread tests/test_render_conversations.py Resolved
Comment thread tests/AGENTS.md Resolved
Comment thread skills/leaf/assets/runtime/traffic.js Resolved
The paint-failure tests now wait for both held requests before releasing
them, and the round_trip contract names the error report and media
uploads beside bookkeeping events.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 78b1925 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the round-trip-bookkeeping branch September 23, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants