Repository navigation
fix(acp): amend the death summary on the Windows teardown too - #12260
iamwhatever wants to merge 1 commit into
Conversation
`AcpRuntime.kill()` has TWO teardowns. POSIX runs the signal ladder; Windows runs the pinned-handle drain INSTEAD of that ladder and returns from `kill()` on its own. The reap amendment -- the line that replaces the pre-signal `[returncode=<not reaped>]` with the status the reap actually observed -- was wired onto the ladder only. So every Windows death reported `<not reaped>` about a process whose exit code it had just confirmed. The drain returns only once every member's exit is CONFIRMED, which is exactly what makes the root's status readable from the handle the caller still holds, so the information was there and never read. It matters past the log line: the summary rides `AcpProcessDied` into a turn's error and a cron's `last_error`, which is the surface an operator diagnoses a killed runtime from. One call, placed where the ladder places its own -- after the drain, before the handle is dropped, and AFTER the raise, because a drain that could not confirm has no status to claim and must keep the handle for the retry. The reason the gap shipped is a test one, and it is fixed here as well. `_neuter_kill_side_effects` stubbed `terminate_windows_asyncio_tree` as an `AsyncMock(return_value=True)` that never touches the handle -- asserting a guarantee the real drain keeps and the stub did not. Every test reaching the Windows branch was therefore judging the teardown against a drain that reaps nothing, which no production code can satisfy. The stub now awaits the handle, bounded, with a timeout that is not an error: a test pinning a handle that never exits is describing a status that stays unknown, and `<not reaped>` is then the honest answer. That combination is what made the four existing reap-amendment tests pass on Linux and macOS and fail on Windows. Three new tests close the coverage gap on every host by pinning `IS_WINDOWS`: the amendment lands at both severities, a drain that confirms no status claims none, and a drain that reaps the root but raises amends nothing and keeps the handle. Revert-verified: removing the one added call turns six of the eight red, and restoring it returns them to green.
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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 (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm the actual Windows CI shard goes green — local verification forced [DESIGN-REVIEWED] 06b5347 |
Opus 4.8 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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Confirm the Windows CI shard itself goes green — the revert-verification forced The description's core premise checks out in-repo: Inventory (4 items) — 4 justifiedIntent: make a killed runtime's death summary carry the exit code on Windows too, unwedging four red Windows CI tests on main — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 06b5347 |
|
[operator: iamwhatever] Closing as superseded by #12269, which merged as The two are the same diagnosis and the same remedy, reached separately: record the reap inside the Windows branch before the handle is dropped, and make the shared kill double drain the way the real It works: One thing in here that #12269 does not coverIts failed-drain test raises without setting async def _drain_fails(process):
raise OSError("Windows tree tracking retirement did not complete")
This PR's version reaps the root and then raises, which is the case that distinguishes them: async def _drain_fails(process):
# The root WAS reaped -- so the code is readable -- but the members could
# not be confirmed, which is the case the real drain raises on. That
# makes this test load-bearing: an amendment placed before the raise, or
# in a finally, would publish this -15.
process.returncode = -15
raise OSError("handle drain incomplete")plus Not reopening this PR for it and not smuggling it elsewhere — it is one test function against |
The ask
Backend Tests (Windows) (1)is red onmain's merge refs, with four failures intest/test_acp_runtime.py:each asserting
[returncode=-15]and getting[returncode=<not reaped>]. Green on Linux and macOS, red on Windows, deterministic. It surfaced on #12245, whose diff touches nothing undersrc/kiro_crew/acp/.Two PRs collided mid-air
AcpRuntime.kill()has two teardowns, and the reap amendment was wired onto one of them.if self._process and platform_compat.IS_WINDOWS:drains the pinned handles andreturns — deliberately, since the drain confirms every member's exit and there is no grace left to serve.self._note_reaped_after_kill(self._process.returncode)at the end of the POSIX ladder, plus the four tests, which assert the amendment unconditionally.#12188's CI was green on Windows because its merge ref predated #12005. The two only meet after both merged.
The product defect
On Windows the early
returnfires first and the amendment never runs, so every Windows death reports<not reaped>about a process whose exit code it had just confirmed. The drain returns only once every member's exit is CONFIRMED — that is precisely what makes the root's status readable from the handle the caller still holds. The information was there and nothing read it.It matters past one log line: the retained summary rides
AcpProcessDiedinto a turn's error and a cron'slast_error, which is the surface an operator diagnoses a killed runtime from.Fix: one call, placed where the ladder places its own — after the drain, before the handle is dropped, and after the raise, because a drain that could not confirm has no status to claim and must keep the handle for maintenance to retry.
_note_reaped_after_killwas already platform-neutral and idempotent (silent onNone, silent once the label is no longer<not reaped>), so nothing else moves.The test defect that let it ship
_neuter_kill_side_effectsstubbed the drain asAsyncMock(return_value=True)— returning True without touching the handle, asserting a guarantee the real drain keeps and the stub did not. Every test reaching the Windows branch was judging the teardown against a drain that reaps nothing, which no production code can satisfy: the fix alone does not turn those four green, because their own stub is the blocker.So the stub now awaits the handle, bounded, and a timeout is not an error — a test that pins a handle which never exits is describing a status that stays unknown, and
<not reaped>is then the honest answer. That is whattest_kill_keeps_the_label_when_no_status_ever_arrivesasserts, and it keeps asserting it on both platforms now rather than by accident on one.Coverage, so the two paths cannot drift again
The four existing tests only ever exercised the ladder on Linux and macOS. Three new tests pin
IS_WINDOWSso the Windows branch runs on every host:expected=False→ WARNING,expected=True→ INFO);finallyor before the raise would publish a status the teardown never confirmed.Verification
Revert-verified from an in-memory snapshot, with the Windows branch forced on so the host runs what the Windows shard runs:
No regression on the six ACP/Windows-teardown suites. This host carries a pre-existing cross-file
TimeoutErrorred in the KAS-readiness tests, unrelated and present on the base:origin/main(9dea438cfa)One fewer failure, five more passing — the four new test cases plus the one the fix clears.
test_acp_runtime.pyrun alone is green on both, with byte-identical failing sets.Gates:
check_comment_history.py,check_brand_name.py,check_subprocess_encoding.py,check_sync_io_in_async.py,check_loop_bound_locks.py,docs_lint.pyall pass;black --checkandflake8clean on both files. No spec change owed —docs/system-specs/modules/acp-client.mddoes not describe the kill teardown's death summary.Confirmed on real Windows
The harness above forces the branch on Linux; this PR's own CI runs it for real. All eight Windows backend shards are green, including shard 1 — the one that is red on every merge ref carrying both #12005 and #12188:
Pattern harvest
Rule candidate: review-prompt
Pattern: a step appended to the end of one branch of a platform/mode split, where the other branch returns early.
kill()splits onIS_WINDOWS; the Windows armreturns mid-function; a later change added a step at the end of the POSIX arm. Neither author was wrong in isolation and no test on the merged tree could see it, because the two landed in separate PRs whose CI never shared a tree. This is the same shape as the recurring "a correct guard wired at only some of its call sites" class, with a platform branch standing in for the call sites — so the reviewer prompt should ask, for any step added at the tail of a function that has an earlyreturnabove it, which of the exits reach it and whether each one owes the step.Rule candidate: semgrep
Pattern: a test double that returns a success sentinel without performing the side effect its real counterpart documents as its postcondition.
_neuter_kill_side_effectsstubbedterminate_windows_asyncio_treeasAsyncMock(return_value=True)while the real function's contract is "returns only once every member's exit is CONFIRMED". That stub is what made the four tests unsatisfiable on Windows: they asserted a status no implementation could produce under it, so the gap was invisible on the platforms CI is green on and the red, when it came, read as a product bug in whichever PR happened to surface it. A rule cannot read a docstring, but it can flag the narrow shape —AsyncMock(return_value=True)/MagicMock(return_value=True)substituted for a function whose name matches a reap, drain, flush, join or await-style verb — for a human to confirm the postcondition is honoured.Not generalizable: the specific merge-order collision. #12188's CI predating #12005 is what CI on a merge ref is for, and it did catch this on the next PR through. The gap worth closing is the two above, not the ordering.
Why no screenshot: backend-only change to a process-teardown path. No user-visible surface renders differently; the one string it corrects reaches a reader through a log line and an error message, both shown verbatim above.