Skip to content

test(acp): replace the fixed wait in death_attribution with await_until - #20151

Merged
javenciu merged 1 commit into
mainfrom
test/wait-discipline-acp-death-attribution
Oct 14, 2026
Merged

javenciu merged 1 commit into
mainfrom
test/wait-discipline-acp-death-attribution

Conversation

@javenciu

Copy link
Copy Markdown
Contributor

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_attribution ran its response wait under asyncio.wait_for(h._wait_for_response(1, timeout=2.0), timeout=5.0). A fixed short ceiling like that 5 s one is the shape test/test_wait_discipline_ratchet.py counts: it names fixed short waits as the commonest cause of a flaky backend test in this repository, and test/wait_discipline_baseline.txt listed 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

  • The timeout=2.0 passed to _wait_for_response stays. 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 first get() returns it and the deadline is never reached.
  • Other files in the baseline: each is a separate change.
  • No production code, no new helper, no assertion change.

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 s asyncio.wait_for as its bound on a wait that the code under test ends by itself: on reading the poison sentinel, _wait_for_response raises 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) becomes await 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 with asyncio.ensure_future, the idiom the tree already uses (for example test/test_stt_stream.py and test/test_piper_runtime.py).
  • The bound is the helper's lost-run bound, half the running test's own timeout. It only turns a hang into a failure that names what; it never decides pass versus fail.
  • The helper returns signal.result() (src/kiro_crew/testing/wait.py:533), so the task's own AcpProcessDied still reaches pytest.raises(AcpProcessDied) and the "background runtime reap" in str(exc_info.value) assertion unchanged.
  • 1 test_acp_death_attribution.py is removed from test/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:

test/test_acp_death_attribution.py: 0 -> 1
    test/test_acp_death_attribution.py:89  wait_for(5s)
1 failed, 38 passed

GREEN (with the change), python -m pytest test/test_wait_discipline_ratchet.py test/test_acp_death_attribution.py -n0, three runs: 43 passed each. test/test_acp_death_attribution.py alone: 4 passed before the change, 4 passed after.

Also run on the change: black --check --target-version py312, isort --check-only and flake8 on the touched test file; scripts/check_agent_sdk_boundary.py; test/test_flake_pattern_ratchet.py; and the touched file followed by test/test_acp_error_surface.py and test/test_acp_session_handle_capabilities.py in 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.py already enforces; the ratchet catches any regression.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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).
@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners October 14, 2026 06:17
@javenciu
javenciu requested a review from mbriones98 October 14, 2026 06:17
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5fed0bf

Verdict parsed from the review's SHA-scoped output markers for commit 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5fed0bf

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5fed0bf62cace1c2fa505f4468c60c39cd82b1bf: <one-sentence reason>

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 14, 2026
@javenciu

Copy link
Copy Markdown
Contributor Author

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).

@javenciu javenciu closed this Oct 14, 2026
@javenciu javenciu reopened this Oct 14, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 14, 2026
@javenciu
javenciu enabled auto-merge (squash) October 14, 2026 09:47

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@javenciu
javenciu merged commit 5368817 into main Oct 14, 2026
112 of 174 checks passed
@javenciu
javenciu deleted the test/wait-discipline-acp-death-attribution branch October 14, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants