Skip to content

Bound load-sensitive tests by stated facts and the suite's deadline, raised to 60s - #1755

Merged
max-sixty merged 3 commits into
mainfrom
load-sensitive-tests
Oct 4, 2026
Merged

max-sixty merged 3 commits into
mainfrom
load-sensitive-tests

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

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) joined
    two page inits with 5s each. 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) 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_TIMEOUT as its hang bound, and a join
that runs out names the step that never finished. STATED_TIMEOUT rises
from 10s to 60s, since the timings above show ordinary work under load
running past 10s. No test expects a STATED_TIMEOUT wait to run out, so
the larger bound changes only how long a real hang takes to report.

With these changes, the same leaf-dev flake selection passed 18/18 for
every case at load 220-260.

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 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.

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

max-sixty and others added 2 commits October 4, 2026 14:36
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
@max-sixty max-sixty changed the title Wait on the fact, not a few seconds, in five load-sensitive tests Bound four load-sensitive tests by the suite's stated deadline, raised to 60s Oct 4, 2026
leaf-agent
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]>
@max-sixty max-sixty changed the title Bound four load-sensitive tests by the suite's stated deadline, raised to 60s Bound load-sensitive tests by stated facts and the suite's deadline, raised to 60s Oct 4, 2026
@max-sixty
max-sixty merged commit 5c90dad into main Oct 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the load-sensitive-tests branch October 4, 2026 22:53
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]>
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