Repository navigation
Hold the gate's own state read until the late action is in the log - #75
Conversation
The render gate used to reach /api/state behind a networkidle navigation, which waited out the page's first poll and the append that rode on it. The news stream leaves the network never idle, so the gate now navigates on load and can reach /api/state while the page's first read is still in flight — whereupon it counts an empty log, waits for nothing, and reads a page 120px mid-move. That is what CI reported at run 33053132232. The window this test constructs is now stated on both sides: the action still goes in behind the page's first read, and the gate's own read is held until it has. A 0.4s delay on the page's read reproduces the CI failure exactly on the old test and passes on the new one at 2s, so the ordering is an arrangement rather than a margin. The premise assertion moves ahead of the gate's verdict, since a window that never opened makes that verdict say nothing.
leaf-agent
left a comment
There was a problem hiding this comment.
One observation on the hold's bound. The arrangement itself checks out: LeafHTTPServer subclasses ThreadingHTTPServer, so holding the gate's handler cannot starve the page's read that releases it; /api/news is a distinct path, so the held-open news stream never trips the /api/state predicate; and 10s sits inside SERVED_TIMEOUT_MS as claimed.
arrived.wait(10) discards its result, so the bound has two failure stories and only one of them is named. If the page's read never happens, landed stays empty and the premise assertion says exactly that — the case the comment above the wait describes. If the page's read merely lands after the bound expires, landed is populated, the premise assertion passes, and the gate — which by then read an empty log, found touched empty, skipped the lf-applied wait, and passed the MOVING wait because the move had not started — reports the drift widget's words over the paragraph below. That is the same four [light]/[print] overlap lines this PR set out to stop misreading as a rendering fault, reappearing under contention instead of under the ordering ad8bf50 removed. A single request stalling past 10s is within the contention envelope running-tend describes, so it is worth a name rather than a re-derivation.
Recording the wait's result costs two lines and turns that case into its own sentence. Suggestions inline.
Problem
cionmainis red attests/test_render_projection.py::test_the_render_gate_reads_a_page_that_has_finished_arriving, which reports the drift widget's words drawn over the paragraph below it in both[light]and[print]. The test builds a window — the action reaches the log after the page's first read has answered, so the gate must see a log with the action in it, count one touched widget, and wait for the caught-up stamp before reading anything. That window used to close on the far side ofpage.goto(url, wait_until="networkidle"): the gate's navigation waited out the page's first poll and the append the test hangs off it, so by the time the gate read/api/statefor itself the action was always in.ad8bf50moved the gate towait_until="load", because a page holding a news stream open is never network-idle. Nothing orders the two reads now. The page stamps itself upgraded in the same breath as it starts its first read and never awaits it, so the gate is free to reach/api/statewhile that read is still in flight — it then counts an empty log, waits for nothing, and reads the page mid-move. Under CI's load that is what happened.Solution
State the window on both sides in the test's own server, rather than resting on which request the machine happens to answer first. The action still goes in behind the page's first read (told from the gate's by the
Referera page fetch carries and anAPIRequestContextdoes not); the gate's own read is now held until it has. The hold is bounded at 10s, far inside the gate's 30s deadline for a served document, so a runtime that stopped reading state at startup is named by the premise assertion instead of by a gate whose server appeared to stop answering.The premise assertion also moves ahead of the gate's verdict: a verdict on a window that never opened says nothing, and reading it as an overlap failure is what made this failure look like a rendering fault.
The gate itself is unchanged. Its contract is the log as it stands at its own read, and it keeps that; only the test's arrangement rested on an ordering
ad8bf50removed.Testing
Reproduction and runs
The failure is a load-shaped race, so it was reproduced by giving the page's first
/api/statethe load: atime.sleep(0.4)in the handler beforesuper().do_GET()for that one request. On the old test that fails on the first try with exactly CI's four[light]/[print]overlap lines. The instrumented request log shows the mechanism directly — the gate's read arrives 21 ms after the page's, and 600 ms before the append:With the fix in place the same delay passes, and so does a 2s one, which is the difference between an arrangement and a margin.
tests/test_render_projection.py::test_the_render_gate_reads_a_page_that_has_finished_arriving— 5 consecutive runs, all greentests/test_render_projection.py --run-nightly— 72 passedtests/test_render_gate.py tests/test_render_startup.py --run-nightly— 107 passedruff check/ruff format --checkat the pinned 0.16.1 — cleanAutomated fix for failed run