Repository navigation
test(startup): wait on signals, not clocks -- test_mcp_gatewayd_coverage, test_workflows_startup - #19928
Conversation
…age, test_workflows_startup
6aec3df to
ce18003
Compare
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: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS
[DESIGN-REVIEWED] ce18003 Description read[DESCRIPTION-READ] 20b43e692f1a2e0547186b2b483720a0a460acb01d777eefffafece7467a8431 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 |
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: |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (4 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: moves two startup test files from clock sleeps to signal waits and drops them from the black and wait-discipline baselines, test hygiene only.
Problem / Motivation
Goal:
test/test_mcp_gatewayd_coverage.pyandtest/test_workflows_startup.pywait on the signal the code emits, never on a clock, so a slow runner can no longer red them.Between them the two files held 63 short fixed waits:
asyncio.wait_for(task, 5)on tasks and futures,asyncio.wait_for(event.wait(), 5)on asyncio Events, polling loops ofasyncio.sleep(0.01)over 200 turns waiting for sweepers to fire, andasyncio.sleep(0.005)inside a composite polling helper. Each bet that CI is as fast as the machine the test was written on. #19248 added the helpers and froze the counts; this burns down all 63 of them.Why it matters
A lost bet reds a pull request that did not touch these files. The gatewayd sweeper tests (polling loop +
wait_forpairs) and the startup initialization tests (event/future/gather waits) are the densest cluster of such bets in the gateway and workflow areas.Not a goal
test/and the baselines changes.test/wait_discipline_baseline.txt. Sibling batches take them.What changed (motivation → approach → change)
Every wait now rides on the thing it was waiting for, under the helpers' lost-run bound (half the test's timeout; expiry fails by name, quoting the signal and the last state read).
asyncio.Eventthe code sets (entered,cancelled,executed, ...)wait_for(event.wait(), 5)await_until(event)asyncio.shield(task)wait_for(task, 5..15)await_until(task)asyncio.gather(task, return_exceptions=True)wait_for(gather(...), 5..15)await_until(gather(...))wait_for(coro, 5)await_until(create_task(coro))sleep(0.01))sleep(0.01)async_wait_until(lambda: condition)_await_restart_write(entered set, startup raised, or initializer settled without the write)while not entered.is_set(): ... await sleep(0.005)with a 60 s clock guardasync_wait_until(_settled)-- the async predicate raises the same assertions directly; the default_timeout() lost-run bound replaces the clock guardThe
cancellation_delivered()local coroutine in one test (which polledinitializer.cancelling()withasyncio.sleep(0)) is folded intoasync_wait_until(lambda: initializer.cancelling())-- shorter and carries the lost-run bound.Black baseline:
test_mcp_gatewayd_coverage.pywas in.github/black-baseline.txt(unformatted). Running black as part of this migration made it clean, so its line is removed from the baseline.File-by-file:
test_mcp_gatewayd_coverage.py: 32 → 0 (21wait_foron tasks/coroutines, 9 polling loops withsleep(0.01), 2async_wait_untilreplacements for composite polling)test_workflows_startup.py: 31 → 0 (30wait_foron events/tasks/gathers/coroutines, 1sleep(0.005)in helper)Both wait-discipline baseline lines deleted from
test/wait_discipline_baseline.txt. One line removed from.github/black-baseline.txt.Backwards compatibility
Compatible: test-only change. No product code, no public helper's contract.
_HANG_GUARD_SECS(a module-level constant private totest_workflows_startup.py) is removed with the polling loop that read it.Tests
Both files: 212 tests total (158 gatewayd + 54 startup), run 3× at default worker count, all green.
test/test_wait_discipline_ratchet.pyfully green; neither file appears in the baseline any longer. Black, isort, flake8 on touched files: green.test_flake_pattern_ratchet.py: 53 passed.Determinism proof (3 ×
-qruns, all 212 passed):Manual verification
N/A -- unit coverage sufficient: the change is to the tests' own waits, and the tests prove them.
Related Issues
Part of #19926
Part of the wait-discipline burn-down behind #19248.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)