Repository navigation
test(acp): replace the fixed wait in death_attribution with await_until - #20151
Conversation
test_response_wait_raise_carries_attribution awaited the response wait under asyncio.wait_for(..., timeout=5.0), a fixed ceiling that the wait-discipline ratchet counts. Await the wrapped task with kiro_crew.testing.wait.await_until instead: it bounds only a lost run and re-raises the task's own AcpProcessDied, so the attribution assertion is unchanged. Drop the file's baseline line (1 -> 0).
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 5fed0bf Description read[DESCRIPTION-READ] ad4097f204a4215e1bf4ba752163b050d730921c9b0ae707b07e8c2399249e35 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 |
First Principles 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: |
|
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: test-only change; replaces a fixed wait with await_until in test_acp_death_attribution and drops its wait-discipline baseline entry.
Problem / Motivation
Goal: Remove the one short fixed wait left in
test/test_acp_death_attribution.py, so the test waits on a signal under a lost-run bound instead of betting on the runner's speed, and take the file out of the wait-discipline baseline.test_response_wait_raise_carries_attributionran its response wait underasyncio.wait_for(h._wait_for_response(1, timeout=2.0), timeout=5.0). A fixed short ceiling like that 5 s one is the shapetest/test_wait_discipline_ratchet.pycounts: it names fixed short waits as the commonest cause of a flaky backend test in this repository, andtest/wait_discipline_baseline.txtlisted this file at 1.Why it matters
A 5 s ceiling decides pass versus fail on whichever CI runner is slowest. The ratchet only lets a file's count go down, so each site replaced by a signal wait removes one flake source for good and keeps the baseline honest.
Not a goal
timeout=2.0passed to_wait_for_responsestays. It is that method's own deadline argument (src/kiro_crew/acp/session_handle.py:4814), not a wait the test makes, and the ratchet does not count it. The poison sentinel is already on the queue when the method is called, so its firstget()returns it and the deadline is never reached.What changed (motivation → approach → change)
Symptom: the ratchet counts one short fixed wait in this file,
wait_for(5s). Cause: the test used a 5 sasyncio.wait_foras its bound on a wait that the code under test ends by itself: on reading the poison sentinel,_wait_for_responseraises through_died(src/kiro_crew/acp/session_handle.py:4840).Change, in
test/test_acp_death_attribution.py:await asyncio.wait_for(h._wait_for_response(1, timeout=2.0), timeout=5.0)becomesawait await_until(asyncio.ensure_future(h._wait_for_response(1, timeout=2.0)), what="the response wait ending on the poison sentinel").await_until(src/kiro_crew/testing/wait.py:490) takes an event or a future, so the coroutine is wrapped withasyncio.ensure_future, the idiom the tree already uses (for exampletest/test_stt_stream.pyandtest/test_piper_runtime.py).what; it never decides pass versus fail.signal.result()(src/kiro_crew/testing/wait.py:533), so the task's ownAcpProcessDiedstill reachespytest.raises(AcpProcessDied)and the"background runtime reap" in str(exc_info.value)assertion unchanged.1 test_acp_death_attribution.pyis removed fromtest/wait_discipline_baseline.txt(count 1 to 0).Rejected: raising the ceiling to 30 s. It would pass the ratchet but keeps a clock as the bound.
Backwards compatibility
Compatible: test-only change; no production code, public API or protocol is modified.
Removes nothing: no test is removed or weakened, and the assertions are the same lines as before.
Tests
In short: with the baseline line deleted and the test file untouched, the ratchet fails on this file; with the change it passes three runs in a row, and the file's own four tests still pass.
RED (baseline line deleted, test file unchanged),
python -m pytest test/test_wait_discipline_ratchet.py -n0:GREEN (with the change),
python -m pytest test/test_wait_discipline_ratchet.py test/test_acp_death_attribution.py -n0, three runs:43 passedeach.test/test_acp_death_attribution.pyalone: 4 passed before the change, 4 passed after.Also run on the change:
black --check --target-version py312,isort --check-onlyandflake8on the touched test file;scripts/check_agent_sdk_boundary.py;test/test_flake_pattern_ratchet.py; and the touched file followed bytest/test_acp_error_surface.pyandtest/test_acp_session_handle_capabilities.pyin one process (101 passed). The change patches no module global.Manual verification
N/A — unit coverage sufficient; the change only affects how one test waits.
Related Issues
No issue exists; burn-down of the wait-discipline baseline (precedents #19928, #20014, #19527).
Pattern harvest
Not generalizable: the site is one instance of the fixed-wait class that
test/test_wait_discipline_ratchet.pyalready enforces; the ratchet catches any regression.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)