Repository navigation
Let the suite retire what it starts, and a paint answer for the region - #800
Conversation
`conversation/presentation.js` drives its paint through `clocked`, so a relative-time tick arriving while the pass waits on a frozen widget starts a second `renderReading`. `surfaceGeneration` settles which reading the page keeps — the newer one — and the first then returned early but resolved its ticket anyway, committing the region on a reading still being written and leaving that reading's failure with no ticket to travel on. The paint now waits for whichever reading the region last started, not the one it began itself, which is what makes its ticket true. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Three preview tests in `test_render_export.py` went red on a loaded machine and
green on a quiet one, which read as contention. Neither cause was.
`test_interrupting_a_live_preview_exits_without_a_traceback` and
`test_automation_preview_records_real_gestures_outside_the_task` timed out
whenever the run was launched as a shell's background job and passed whenever it
was launched in the foreground — 2/2 each way, with no concurrency in either. A
background job has SIGINT set to SIG_IGN, and an inherited SIG_IGN survives both
Python startup and `exec`, so every process the run spawns ignores the signal:
the interrupt landed on nothing, `communicate` waited out its ten seconds, and
the watcher outlived the run still serving its page. The run now catches SIGINT
itself, which is what `exec` resets to the default in each child. `spawn` ends
the group of a child given a session of its own, since `scripts/preview.py`
re-executes into `uv run` and the handle a test keeps names the launcher rather
than the watcher below it.
`test_a_detached_preview_restarts_under_its_original_codex_claim` misses its
thirty-second reload once `.tmp/previews` holds a few hundred entries, and the
suite was adding four per preview and removing one: `preview_slot` deleted the
page directory and left `<slot>.preview.{json,lock,log,state.lock}` beside it,
while `test_named_live_previews_serve_one_source_in_independent_runtime_slots`
named its two slots itself and so was swept by nothing. The fixture now discards
every slot in its namespace through the preview's own `retire_preview`, which
writes the stop flag the watcher polls and waits for the lease, so a watcher
that outlived its test is retired rather than having its page pulled from under
it. The named-slots test takes the fixture and derives its names from it.
Measured, two arms launched together on a machine under a sibling nightly: this
commit 59 passed and nothing left in `.tmp/previews`; 602e895 3 failed and 74
entries left.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
prettier writes the equivalent for-statement's empty third clause tight against the paren, which reads as a typo. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
renderReading rethrows when its own generation has been superseded — if (!current() || error instanceof RetainedThreadListError) throw error; — so a reading the page has already discarded still rejects. The new wait loop leaves on the first rejection it awaits, so when a clock tick starts a newer reading and the older one then fails its widget preparation, the pass ends on the discarded reading's error and never waits for the newer one. That is the same commit-over-a-page-still-being-written the change sets out to close, surviving on the failure path: the ticket fails soft into retainedThreadListProof while the newer reading is still writing the region.
Collecting the first failure and rethrowing once the loop has drained keeps both properties — suggestion inline. First-failure is also what whenDocumentPresented already promises in semantic-state.js: "it carries the first paint failure of the pass".
A superseded reading rejects rather than returning — `renderReading` rethrows as soon as its own generation is gone — so leaving the chase loop on the first rejection settled the ticket on a reading the page had already discarded, while its replacement was still writing the region. That is the commit-too-early the loop exists to close, surviving on the failure path. The loop keeps the first failure and raises it once the region is quiet, which is the first-failure `whenDocumentPresented` reports anyway. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ds (#823) #800's preview slots were one instance of a shape: a resource whose owner never gets the chance to take it back. This is the sweep of `tests/` for the rest of it, and what it found. ## A page nobody was listening to `watched` collects a page's console, its `pageerror`, and the window `error` events with no exception behind them, and until now each caller installed it. 38 test functions made a page and never did, so each of those tests was green about a page whose error channels nothing read. The `browser` fixture hands over a `WatchedBrowser`, whose `new_page` and `new_context` install the problem list, the `Traffic` ledger, and the interception arm in the call that makes the page. An init script has to precede the navigation it instruments, and a console entry from a page nobody listened to is gone, so none of the three can be added afterwards: where the page is made is the only place they fit. Turning it on found 21 pages that had been reporting into nothing. Each is a page its test deliberately broke, and each now says so where that happens — `consume_browser_errors` for a single fault, and `restarting` for the preview bootstraps, whose wording depends on which fetch was in flight when the service went away. A fault the page keeps meeting has no such point, so the two tests that refuse every `/api/state` consume after `page.close()`. `browser.unwatched` is the way past, for a page that is read for by whoever opened it: `render_version` collects its page's console and reports it as a finding, and `arrival_findings` does the same for the restore cases it walks, so a page either of them opens would otherwise be reported on twice. The context's own `page` event looked like the way to reach a popup, and it is not. Measured: a `page.route` inside that handler leaves the `add_init_script` after it without effect and says nothing about it. `opened_tab` remains how the suite meets a tab Chromium opened, and it makes that tab readable itself: `Page.context` hands back Playwright's own context rather than the one the fixture wrapped, so the tab seven tests assert on had none of the readings. ## The pages the tests were ending themselves That fixture ends a page as well as making one. It closes every context a test left open, and does it after reading what those pages reported, because closing cancels outstanding requests and stops event delivery. The tests closed their own page or context where they ended with it 227 times — in a `finally`, on the last line, or at the end of a loop the test ended in — which ran that close one step early: the reading it cut short was the test's own. They are gone, and with them the indentation the `try` wrapped each body in. A close inside a test stays, because there it is the gesture under test — a second tab shut to show what the first one still holds — and the assertions after it are what read it. So the rule is the ending rather than the call, and the guard reads every spelling of one — anywhere in a `finally`, and the line a test ends on, followed down through the block it ends in — on anything the browser fixture lent, following a page through whatever handed it over (`held_events`, `opened_tab`, a helper that returns one, a `for` over several) rather than keying on the names in a test's signature. Its single exception is the page that keeps making the fault its test is about, where the consume has to follow a close of its own. Fifteen of those `finally` blocks released a held route before closing, which is the case worth measuring: the released request finishes after the block that let it go, so its noise could reach a reading the close used to cut off. The fifteen passed five runs out of five at six workers without it, so the hold section now ends its release path at `unroute` and leaves the close to the fixture. ## The website adapter left its App Server behind `worker/server.py` starts a Codex App Server in a session of its own and closes it in a `finally`. uvicorn answers SIGTERM by stopping its loop, restoring the handler that preceded it, and re-raising, so the process dies before that `finally` runs. A container takes the App Server away with everything else. A host does not, and `scripts/verify_site.py local` runs this adapter on a host and stops it exactly that way: three App Servers were alive on a developer's machine 15 to 17 hours after the runs that started them, 95MB resident each, each having recreated the temporary directory its run had removed. `close_on_signal` closes the host on that path and then dies of the signal it was sent. The test that covered this boundary asserted the adapter's own death and nothing about what it started, so `test_the_adapter_takes_its_app_server_with_it_when_it_is_told_to_stop` runs the real adapter with a stand-in App Server and asserts both; without the fix it fails on the survivor. ## Resources the tests were holding by hand `socket_dir` owns a directory short enough for `sun_path`, the one file that cannot live under `tmp_path`, since pytest has spent most of the 104 bytes before a test's own files begin. Two tests made their own under `/tmp`, and the new website test wanted a third. `app_server` owns the websocket stand-in the Codex observer connects to: the server, the thread serving it, and the stop that ends both. Four tests held those three by hand, and one ran the stop on the last line of the test body, which is the line a failing assertion never reaches. `page_server` owns the `ProcessPageServer` an MCP host reads a run's pages through. Nine tests made one and closed it in a `finally` of their own, four of them beside a `page.close()` the browser fixture already does. The one test whose subject is the server going away — the app falling back to its snapshot — still closes it where the next assertion reads that. `_no_host_outlives_its_test` closes every `WebsiteCodexHost` a test made, as `_no_page_outlives_its_test` stops every page server. Thirty-nine website tests make a host and seven closed theirs; measured at teardown, four of the other thirty-two still held an App Server or the waiter lease over a Codex thread. It sweeps rather than asking for a fixture because the host is these tests' subject, built in each body with the paths that test needs. The three tests whose subject is closing keep their close. `test_the_resources_a_fixture_owns_are_taken_from_that_fixture` reads the suite for the calls these fixtures exist in place of, and for a `finally` that closes what the browser fixture will close, because a fixture cannot stop a test making or ending its own. ## What the sweep found nothing to fix in - Nothing in `tests/` writes into the checkout: an AST sweep over every write call rooted at `ROOT`, `PLUGIN_ROOT`, `SKILL_ROOT`, `EXAMPLES`, or `DOCS` comes back empty. `scripts/preview.py` is still the only writer there, and `preview_slot` owns what it leaves. - A detached Codex adapter ends with the test that started it. Measured with a test that starts one and releases nothing: it is gone three seconds later, because `_no_page_outlives_its_test` stops its page's server and a watch pass with no live page exits. The claim release in those tests is an assertion about the adapter rather than ownership of it. - `spawn` is the only caller of `subprocess.Popen` under `tests/`, and the state home each run claims into is `tmp_path_factory`'s. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Three preview tests in
test_render_export.pywent red on a loaded machine and green on a quiet one, which read as contention. Neither cause was.The interrupt landed on nothing
test_interrupting_a_live_preview_exits_without_a_tracebackandtest_automation_preview_records_real_gestures_outside_the_tasktimed out whenever the run was launched as a shell's background job, and passed whenever it was launched in the foreground — 2/2 each way, with no concurrency in either. A background job has SIGINT set toSIG_IGN, which is the shell's protection for a job no terminal can interrupt, and an inheritedSIG_IGNsurvives both Python startup andexec. So every process the run spawns ignores the signal too: the interrupt landed on nothing,communicatewaited out its ten seconds, and the watcher outlived the run still serving its page.The run now catches SIGINT itself, which is what
execresets to the default in each child — the disposition the interrupt is about.spawnends the group of a child given a session of its own, sincescripts/preview.pyre-executes intouv runand the handle a test keeps names the launcher rather than the watcher below it.The suite never took its preview slots back
test_a_detached_preview_restarts_under_its_original_codex_claimmisses its thirty-second reload once.tmp/previewsholds a few hundred entries, and the suite was adding four per preview and removing one:preview_slotdeleted the page directory and left<slot>.preview.{json,lock,log,state.lock}beside it, whiletest_named_live_previews_serve_one_source_in_independent_runtime_slotsnamed its two slots itself and so was swept by nothing.The fixture now discards every slot in its namespace through the preview's own
retire_preview, which writes the stop flag the watcher polls and then waits for the lease — so a watcher that outlived its test is retired rather than having its page pulled from under it. The named-slots test takes the fixture and derives its names from it.scripts/preview.pyis unchanged.Measured, two arms launched together on a machine under a sibling nightly: this branch 59 passed with nothing left in
.tmp/previews; 602e895 3 failed and left 74 entries.A conversation paint that answered for the wrong reading
conversation/presentation.jsdrives its paint throughclocked, so a relative-time tick arriving while the pass waits on a frozen widget starts a secondrenderReading.surfaceGenerationsettles which reading the page keeps — the newer one — and the first then returned early but resolved its ticket anyway, committing the region on a reading still being written and leaving that reading's failure with no ticket to travel on. The paint now waits for whichever reading the region last started, not the one it began itself, which is what makes its ticket true. It drains the region before raising anything, too: a superseded reading rejects rather than returning, so leaving on the first rejection would settle the ticket on a reading the page had already discarded while its replacement wrote the region — the same commit-too-early, surviving on the failure path. The first failure is kept and raised once the region is quiet, which is the first-failurewhenDocumentPresentedreports anyway. This is the follow-up #795 left open.Full nightly suite green at 2723, run backgrounded — the condition that used to fail.
🤖 Generated with Claude Code