Repository navigation
test(windows): wait on signals, not clocks -- test_runtime_cleanup_windows, test_windows_cleanup_capacity - #20014
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the Suggestions
[DESIGN-REVIEWED] 695838f Description read[DESCRIPTION-READ] 6bde2b579ea40b6a808beba0e4f4a0f8a5ed1d2d561af258d824e5b43d35243b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
5c82241 to
03c5885
Compare
…ndows, test_windows_cleanup_capacity Replace 43 short clock bets in two Windows-specific test files with signal waits using helpers from kiro_crew.testing.wait. - asyncio.wait_for(event.wait(), N) → await await_until(event) - asyncio.wait_for(coro, N) → await _bounded(coro, what=...) - asyncio.sleep(0.02) polling loop → await async_wait_until(predicate) - asyncio.timeout(N) context → await _bounded(coro, what=...) - time.sleep(0.02) sync poll (fixture teardown) → wait_until(predicate) - asyncio.sleep(0.01) heartbeat loop → asyncio.sleep(0) (loop yield) Two explicitly documented tight bounds remain (both # flake-ok): - _owned_tree teardown: await_until(task, timeout=10) -- 10 s grace before force-kill; worker exits in ms after "finish" is written. - _isolate_pending_windows_tree_cleanup: wait_until(pred, timeout=10) -- 10 s grace for process exit after terminate_process_handle. Both files drop to 0 sites; their lines removed from wait_discipline_baseline.txt. Part of #20013
03c5885 to
695838f
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change that replaces clock-based waits in two Windows cleanup test files with the shared wait helpers, and updates the wait-discipline baseline.
Problem / Motivation
Goal: Replace 43 short clock bets in two Windows-specific test files with waits on the real signals the code emits, so the wait-discipline ratchet accepts them and CI stops losing on slow runners.
test/test_runtime_cleanup_windows.py(25 sites) andtest/test_windows_cleanup_capacity.py(18 sites) held a combined 43asyncio.wait_for(coro, N<30)andsleep(N)polling loops. On a slow Windows CI runner, the 5 s / 10 s / 15 s ceilings were not lost-run bounds — they were the race that decided pass versus fail.Why it matters
Every short fixed wait in these files is a flake waiting to fire on the Windows runner, and these tests already carry Windows-specific marks (
pytest.mark.skipif(sys.platform != "win32")): the only real test runs happen on the slower platform.Not a goal
What changed (motivation → approach → change)
Each short
asyncio.wait_for(coro, N)is a clock bet: the test passes only if the runner is faster than N. The fix follows the pattern in #19248 and subsequent batch PRs (#19325 #19334 #19339 #19331 #19489 #19868 #19928):asyncio.wait_for(event.wait(), N)→await await_until(event)— events are first-class signals;await_untilawaits the event object directly under a lost-run bound (half the test's timeout).asyncio.wait_for(coro, N)→await _bounded(coro, what=…)— coroutines are wrapped inasyncio.ensure_future; a module-local_boundedhelper (identical to the one intest_acp_runtime.py) awaits the task withawait_untiland cancels + settles it on timeout.asyncio.sleep(0.02/0.01)in polling loop →await async_wait_until(predicate)— each polling loop is replaced with a predicate that returns the state the test is about to assert;async_wait_untilpolls under the default lost-run bound.asyncio.timeout(15)context manager →await _bounded(coro, what=…)— the body of theasync with asyncio.timeout(15):block was a singleawait coro, replaced directly.time.sleep(0.02)in sync polling loop (fixture teardown) →wait_until(predicate, timeout=10)— the one synchronous polling loop in_isolate_pending_windows_tree_cleanup's teardown is replaced withwait_until, the synchronous variant, with an explicit 10 s bound.asyncio.sleep(0.01)heartbeat loop →asyncio.sleep(0)— intest_slow_identity_read_leaves_the_event_loop_serving,other_session_workis a background ticker that only needs to yield the event loop;sleep(0)is sufficient and is not counted by the ratchet.Site counts
test/test_runtime_cleanup_windows.pytest/test_windows_cleanup_capacity.pyBoth entries removed from
test/wait_discipline_baseline.txt.Remaining sites
None. All 43 sites migrated to signal waits.
Tight bounds kept
Two bounds remain, both explicit and documented with
# flake-ok::_owned_treeteardown:await_until(_exit_task, timeout=10, what="worker cooperative exit")— 10 s grace period before the force-kill fallback. The worker subprocess exits in milliseconds oncefinishis written; the bound is a cleanup deadline that triggers the kill path, not the pass/fail gate. Ratchet does not countawait_until(timeout=...)._isolate_pending_windows_tree_cleanupteardown:wait_until(lambda: not _still_alive(), timeout=10)— 10 s grace for process exit afterterminate_process_handle. Same policy: triggers the survivor assertion, not the pass/fail decision. Ratchet does not countwait_until(timeout=...).Backwards compatibility
Removes nothing: this is a pure test-only change; no production code, public API, or protocol is modified.
Tests
test/test_wait_discipline_ratchet.pypasses after--write-baselinedrops the two now-zero entries.black,isort,flake8clean on both touched files.Manual verification
N/A — unit/integration coverage sufficient; the Windows-specific tests will run on the Windows CI runner.
Screenshots / video
N/A — no user-visible UI change.
Related Issues
Part of #20013
Pattern harvest
Not generalizable: each site was already an instance of the documented D1 class; the helpers already existed. The ratchet catches any regression.
Checklist