Repository navigation
Bound load-sensitive tests by stated facts and the suite's deadline, raised to 60s - #1755
Merged
Merged
Conversation
Five Python tests failed in a local everyday-gate run at load ~200 on 18 cores and passed alone. `leaf-dev flake` reproduced every one at load ~230 (18 copies each). None is a product race: each test either bounded real work by a deadline shorter than that work takes on a busy machine, or read a handover file the moment it existed, before its writer had filled it. Deadlines shorter than the work they bound: - `test_concurrent_page_init_serializes_creation` (17/18 failed) joined two `page init`s with 5s each. Timed under the same load, the two inits took 14-25s together. - `test_a_later_codex_start_names_the_running_transport` (17/18) gave three `leaf codex start` commands `STATED_TIMEOUT`, 10s; they took 15-20s. - `test_stop_does_not_wait_forever_on_a_server_started_after_its_transition` (9/18 for each owned case) asserted the resumed stop returned within a 3s join; it took up to 12s. Its held stop also gave up after 10s while the test was still starting the successor server. - `test_sample_allocations_share_no_parent_lock_and_keep_one_log_reading` (2/18) gave each sample allocation, which writes the whole runtime into the child, 5s. Each of these now uses `STATED_TIMEOUT` as its hang bound, and a join that runs out names the step that never finished. `STATED_TIMEOUT` rises from 10s to 60s: the timings above show 10s is shorter than ordinary work takes under load, so a failure at 10s did not mean the fact was missing. No test expects a `STATED_TIMEOUT` wait to run out, so the larger bound changes only how long a real hang takes to report. Handover files read before they were written: - `test_serving_connects_codex_feedback_before_handing_over_its_url` (4 of 324 runs failed, with `JSONDecodeError` on an empty file) polled for `ready.json` and the fake Codex CLI's `queued.json` to exist, then read them. Both writers opened the file in place, so a read between creating and filling it saw nothing. The test program now writes through `leaf.state.write_json`, and the `codex_queue` fixture writes to a sibling file and renames it into place. With each writer held for 2s between creating and filling its file, the old in-place write fails the test every time and the renamed write passes. After the change, the same `leaf-dev flake` selection passed 18/18 for every case at load 220-260. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # tests/interact_support.py # tests/test_interact_preview.py
leaf-agent
previously approved these changes
Oct 4, 2026
`test_a_watch_wakes_on_what_its_pass_read_moving` showed that `Watch.await_news` woke on news by asserting it returned in under 30s of its 60s timeout, which a slow enough machine fails though the watch woke on news. `await_news` now returns True when what the last pass read moved, or the page set changed, and False when its timeout ran out with nothing moved. The test asserts that value in all three cases and no longer reads the clock. With the watch made blind to movement, the append case returns False and the test fails. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 4, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 5, 2026
#1755 raised `STATED_TIMEOUT` to 60s as the suite's one hang bound, but about 230 Python-side waits still fixed their own literal deadline (3-120s), sized to how long the work took where each was written. On a loaded runner those fail a correct product. - Every hang bound on work that should complete takes `STATED_TIMEOUT`, or `COMPOSITE_TIMEOUT` (twice it) for the subprocesses that took 90-120s: a nested pytest run, a preview building and serving a page, a hook launched through uv. Browser-side Python polls in the render harness and the read-state test take `SERVED_TIMEOUT_MS`. Waits whose expiry said nothing now name the missing fact, and bare joins assert that their thread finished. - `test_a_python_side_wait_takes_the_suites_deadline` reads `tests/` and rejects a literal deadline on the standard library's blocking waits, `wait_for`, and `monotonic() + N`. One `test_render_gate.py` site is listed while another change holds that file. - Three waits that waited out an absence now wait on a decided outcome. The re-vendor serialization helper and the concurrent-undo test used 2s and 1s windows; they now see the taker waiting on the held lock through `interact_support.lock_contention`, which tries a blocking `flock` without blocking first and states the refusal. The Codex observer fixture used a 0.1s `recv` to catch an approval reply; it now reads everything the observer sends until it closes the connection. - `test_concurrent_page_init_serializes_creation` checked `calls == 1` right after the second init announced itself, before it reached the lock, so it passed with the page lock made shared. It now holds the first creation until the second is found waiting on the page's lock or seen creating. With the lock shared (`LOCK_SH` in `page_locked`), the old test passes and the new one fails ("the second init began creating while the first held the page"). - The cold SessionEnd test bounds the hook with the suite's deadline rather than the harness's 3s: the transaction stays held for the run, so a hook that waited on it would never return. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five Python tests failed in a local everyday-gate run at load ~200 on 18
cores and passed alone.
leaf-dev flake(18 concurrent copies each)reproduced every one at load ~230. None is a product race, and nothing
hung. Four bounded real work by a deadline shorter than that work takes on
a busy machine. The fifth read handover files before their writers had
filled them, which #1705 has since fixed on main the same way this branch
did, by writing them through
leaf.state.write_json.The four deadlines, with the base failure rate and the durations timed
under the same load:
test_concurrent_page_init_serializes_creation(17/18 failed) joinedtwo
page inits with 5s each. The two inits took 14-25s together.test_a_later_codex_start_names_the_running_transport(17/18) gavethree
leaf codex startcommandsSTATED_TIMEOUT, 10s. They took15-20s.
test_stop_does_not_wait_forever_on_a_server_started_after_its_transition(9/18 for each owned case) required the resumed stop to return within a
3s join. It took up to 12s. Its held stop also gave up after 10s while
the test was still starting the successor server.
test_sample_allocations_share_no_parent_lock_and_keep_one_log_reading(2/18) gave each sample allocation, which writes the whole runtime into
the child, 5s.
Each of these now uses
STATED_TIMEOUTas its hang bound, and a jointhat runs out names the step that never finished.
STATED_TIMEOUTrisesfrom 10s to 60s, since the timings above show ordinary work under load
running past 10s. No test expects a
STATED_TIMEOUTwait to run out, sothe larger bound changes only how long a real hang takes to report.
With these changes, the same
leaf-dev flakeselection passed 18/18 forevery case at load 220-260.
test_a_watch_wakes_on_what_its_pass_read_movingshowed thatWatch.await_newswoke on news by asserting it returned in under 30s ofits 60s timeout, which a slow enough machine fails though the watch woke
on news.
await_newsnow returns True when what the last pass readmoved, or the page set changed, and False when its timeout ran out with
nothing moved. The test asserts that value instead of reading the clock.
With the watch made blind to movement, the append case returns False and
the test fails. It passed 18/18 under
leaf-dev flake.