tests: await scheduler passes instead of sleeping past the tick #20

Manually merged
krisbuild merged 1 commit from faster-test-waits into main 2026-09-27 20:20:27 +02:00
Owner

Negative assertions ("nothing was dispatched" or "nothing was cancelled") waited out a fixed 2.5–5 s so that a 2 s scheduler tick had surely run. That was ~90 s of the kb-control-plane suite's 138 s serial time.

  • Pass counter: the scheduler bumps AppState::passes (a watch channel) after every pass.
  • common::settle(&server): wakes the scheduler and waits for a whole pass that started after the call. It waits for two passes, because one already in flight may have read the world before the change. The assertion then allows only QUIET (300 ms) for an already-sent message to arrive over loopback.
  • Ingestion waits: where the step before a negative assertion is an agent event over the WebSocket (e2e succeed(build), replay succeed(retry), expand_needs' expansion, pr_events' eval), the test first waits for it to land with common::wait_task_state (moved up from inflight_dedup). Without that, the settled pass might not have seen the event and the negative would pass vacuously.
  • Changed sites: 21 negative waits across inflight_dedup, e2e, cancel_rerun, replay, supersession, pr_events and expand_needs, plus the pruning poll in events.
  • Overlap with #19: this includes #19's pr_events eval wait. Whichever lands second needs a one-line merge, since both add wait_task_state to common.
kb-control-plane it before after
serial (RUST_TEST_THREADS=1, what CI gets today) ~115–138 s 55 s
16 threads 12.4 s ~7.2 s

Checks: cargo clippy --workspace --all-targets -D warnings is clean, cargo test --workspace passes, and the control-plane suite passed 8/8 looped runs.

🤖 Generated with Claude Code

Negative assertions ("nothing was dispatched" or "nothing was cancelled") waited out a fixed 2.5–5 s so that a 2 s scheduler tick had surely run. That was ~90 s of the kb-control-plane suite's 138 s serial time. - **Pass counter:** the scheduler bumps `AppState::passes` (a `watch` channel) after every pass. - **`common::settle(&server)`:** wakes the scheduler and waits for a whole pass that *started after* the call. It waits for two passes, because one already in flight may have read the world before the change. The assertion then allows only `QUIET` (300 ms) for an already-sent message to arrive over loopback. - **Ingestion waits:** where the step before a negative assertion is an agent event over the WebSocket (e2e `succeed(build)`, replay `succeed(retry)`, expand_needs' expansion, pr_events' eval), the test first waits for it to land with `common::wait_task_state` (moved up from inflight_dedup). Without that, the settled pass might not have seen the event and the negative would pass vacuously. - **Changed sites:** 21 negative waits across inflight_dedup, e2e, cancel_rerun, replay, supersession, pr_events and expand_needs, plus the pruning poll in events. - **Overlap with #19:** this includes #19's pr_events eval wait. Whichever lands second needs a one-line merge, since both add `wait_task_state` to `common`. | kb-control-plane `it` | before | after | |---|---|---| | serial (`RUST_TEST_THREADS=1`, what CI gets today) | ~115–138 s | 55 s | | 16 threads | 12.4 s | ~7.2 s | Checks: `cargo clippy --workspace --all-targets -D warnings` is clean, `cargo test --workspace` passes, and the control-plane suite passed 8/8 looped runs. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tests: await scheduler passes instead of sleeping past the tick
All checks were successful
krisbuild/kris/krisbuild/nix/hello cached
krisbuild/kris/krisbuild/nix/workspace-deps cached
krisbuild/kris/krisbuild/nix/test-deps cached
krisbuild/kris/krisbuild/nix/world cached
krisbuild/kris/krisbuild/nix/clippy succeeded
krisbuild/kris/krisbuild/nix/test succeeded
krisbuild/kris/krisbuild/nix/build succeeded
krisbuild/kris/krisbuild/nix/kb-check succeeded
krisbuild/kris/krisbuild krisbuild kris/krisbuild: all tasks succeeded
krisbuild/queue merged
8b0f3da3ed
Negative assertions ("nothing was dispatched / cancelled") waited out a
fixed 2.5-5 s window so that a 2 s scheduler tick had surely run. The
scheduler now counts completed passes (`AppState::passes`, a watch
channel), and `common::settle` wakes it and waits for a whole pass that
started after the call; the assertion then only allows `QUIET` (300 ms)
for an already-sent message to arrive. Where the preceding step is an
agent event over the WebSocket, the test first waits for it to land
(`common::wait_task_state`, moved up from inflight_dedup), so the pass
is one that saw it.

kb-control-plane suite: 138 s serial / 12.4 s on 16 threads before,
55 s / ~7 s after.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

@krisbuild r+ p=7

@krisbuild r+ p=7
krisbuild manually merged commit 1066fa92da into main 2026-09-27 20:20:27 +02:00
Collaborator

Merged as 1066fa92da.

Merged as 1066fa92da63.
kris referenced this pull request from a commit 2026-09-27 20:29:59 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kris/krisbuild!20
No description provided.