Repository navigation
test(mcp): replace fixed wait in handlers_mcp_coverage with await_until - #20137
Conversation
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 3d10ea3 Description read[DESCRIPTION-READ] 3953911262f4620985dc53e69ca2b540803b825ccfc1c09398d06d3172e9b268 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 |
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: |
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
The measure-start test waited for its stubbed background body with asyncio.wait_for(started.wait(), timeout=1), a fixed one-second bet that test_wait_discipline_ratchet.py counts against the file. Await the event with kiro_crew.testing.wait.await_until, whose lost-run bound is half the test's own timeout, and delete the file's line from wait_discipline_baseline.txt.
ebf4275 to
3d10ea3
Compare
|
Closing and reopening so CI runs on hosted runners: same-repo runs from this account queue on the fleet label without a runner (details on #19683). |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (2 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: replaces a fixed asyncio.wait_for timeout with await_until in one test and drops that file from the wait-discipline baseline; test files only.
Problem / Motivation
Goal: Make the last short fixed wait in
test/test_handlers_mcp_coverage.pywait for the event the stubbed code sets, so the test no longer depends on how fast the runner is.test_starting_a_pass_clears_the_previous_pass_countsreplaces the background measure-all body with a stub that sets anasyncio.Event, then waited for it withasyncio.wait_for(started.wait(), timeout=1)(line 3331 on main). One second is a bet that the runner is as fast as the machine the test was written on.test/test_wait_discipline_ratchet.pycounts that site against the file's line intest/wait_discipline_baseline.txt.Why it matters
A fixed short wait is the commonest cause of a flaky backend test in this repository (the module docstring of
test/test_wait_discipline_ratchet.pysays so), and it fails on slower CI runners first. Removing the site lowers the baseline, and the ratchet then keeps this file from gaining another.Not a goal
api_mcp_measure_start)._slow_update(test/test_handlers_mcp_coverage.py:2495) deliberately holds a worker thread so the cancellation lands mid-write. Thethreading.Eventwait passed toasyncio.to_threadintest_a_cancelled_request_still_waits_for_the_write_to_finish(test/test_handlers_mcp_coverage.py:2506) is not a signalawait_untilaccepts, because it takes anasyncio.Eventor a future. Both are a different mechanism from this change.What changed (motivation → approach → change)
The ratchet's rule is "wait on signals, not clocks": a test awaits the event the code emits, under a lost-run bound (half the test's own timeout by default) that only turns a hang into a named failure. The helper for an
asyncio.Eventiskiro_crew.testing.wait.await_until.test/test_handlers_mcp_coverage.pyimportsawait_untiland replaces the one site withawait await_until(started, what="the stubbed measure-all body starting")(line 3332 at this head).await_untilis a coroutine function, so theawaitin front of it stays.test/wait_discipline_baseline.txtloses the line1 test_handlers_mcp_coverage.py, which is now at zero.Rejected: keeping
wait_forand raising its number. The ratchet counts any ceiling under 30 s, and a larger constant is still a clock bet.Backwards compatibility
Removes nothing: this is a test-only change; no production code, public API or protocol is modified.
Tests
In short: with the baseline line deleted and the test file untouched the ratchet fails; with the site replaced it passes, and the file's own tests are unchanged.
pytest test/test_wait_discipline_ratchet.py -n0 -q:1 failed, 38 passed, with the reporttest/test_handlers_mcp_coverage.py: 0 -> 1and the sitetest/test_handlers_mcp_coverage.py:3331 wait_for(1s)(main's line numbers).test/test_handlers_mcp_coverage.pyat-n0, three runs:205 passedeach (39 ratchet tests and 166 in the file; the file had 166 before the change too).pytest test/test_handlers_mcp_coverage.py -n0 -W error::RuntimeWarning -W error::pytest.PytestUnraisableExceptionWarning:166 passed. With theawaitin front ofawait_untilremoved, the same flags fail that test oncoroutine 'await_until' was never awaited, so a droppedawaitwould be caught.test/test_handlers_memory_coverage.pyandtest/test_handlers_taskrunner_coverage.py, in one process at-n0:636 passed.isort --check-only,flake8andgit diff --checkare clean on the touched file. The file is listed in.github/black-baseline.txt, andblack --diffreports the same hunks before and after this change.Manual verification
N/A: unit coverage is sufficient. The change swaps one test wait for the repository's wait helper and touches no runtime code.
Related Issues
No issue exists; burn-down of the wait-discipline baseline (precedents #19928, #20014, #19527).
Pattern harvest
Not generalizable: this site is one more instance of the class the ratchet already catches (rule D1 of
docs/system-specs/common/testing-conventions.md), so the gate stops the class and no new rule is needed.Checklist