Repository navigation
fix(acp): record the reap on the Windows teardown branch too - #12269
Conversation
|
Intent: Make a killed runtime's retained exit status reach a Windows operator, by recording the reap on the teardown branch that returns before the shared amendment — and make the Windows drain test double faithful enough that the existing assertions about that status can hold on Windows. |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Confirm the actual [DESIGN-REVIEWED] f478413 |
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 All verification forced Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: make a killed runtime's death summary carry the real exit status on Windows instead of
[FIRST-PRINCIPLES-REVIEWED] f478413 |
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: |
A killed runtime's death line is written before the signal, so its retained summary carries `[returncode=<not reaped>]` and `_note_reaped_after_kill` replaces the placeholder once the reap completes. That call sits after the POSIX signal ladder, and `_kill_inner`'s Windows branch returns 63 lines before reaching it, so on Windows the amendment never runs for any returncode. The consequence is not log-only. The summary outlives the log and rides `AcpProcessDied` into a turn's error text and a cron's `last_error`, so a Windows operator diagnosing a killed runtime is told the exit status is unavailable when the drain above has already confirmed it. Windows is where a reaped root is hardest to diagnose, and it is the platform with no status. The fix records the reap inside that branch, before the handle is dropped. The drain returns only once every member's exit is CONFIRMED, so the status is knowable at exactly that point; its failure path raises instead, which keeps the placeholder true for a tree it could not confirm. The shared kill test double is the second half. It stubs the Windows drain with a mock that returns without awaiting `process.wait()`, while the real `terminate_windows_asyncio_tree` awaits it — and that await is what populates `returncode`. So the double handed the Windows branch a process whose status is unreadable, and four existing assertions about the post-reap status failed on the Windows shard alone: the double disagreeing with the code rather than the code being wrong. The stand-in now drains the way the real one does. Each half is load-bearing, shown by reverting one at a time with the branch forced through `platform_compat.IS_WINDOWS`: - production fix reverted, faithful double: the new test fails on the placeholder - faithful double reverted, production fix kept: the four existing tests fail with the CI annotations' own assertion text - both present: 4 existing + 2 new pass Two regression tests force the branch on every platform rather than leaving it to the Windows shards, because a branch one CI lane reaches is a branch whose loss is invisible in every other lane. The second pins the refusal direction: a drain that raised leaves `<not reaped>` standing and logs no amendment. The owning spec gains the amendment it never documented, including that it must be called from both teardown branches and what the test double's drain has to do. Fixes #12247
9ed0add to
f478413
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean (the single Semgrep annotation on this head is GitHub's own .github:1 runner-image migration notice, level=notice, not a finding), security checklist all-NO, AI reviewers green on head SHA f478413, readiness label applied after the head commit. Category: adds the missing _note_reaped_after_kill(process.returncode) call on the Windows teardown branch so the death line stops reading returncode=<not reaped> after a confirmed drain — 7 added production lines, one call to an existing helper, no isolation, auth or gate surface touched. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/acp-client.md.
…dev#12269) A killed runtime's death line is written before the signal, so its retained summary carries `[returncode=<not reaped>]` and `_note_reaped_after_kill` replaces the placeholder once the reap completes. That call sits after the POSIX signal ladder, and `_kill_inner`'s Windows branch returns 63 lines before reaching it, so on Windows the amendment never runs for any returncode. The consequence is not log-only. The summary outlives the log and rides `AcpProcessDied` into a turn's error text and a cron's `last_error`, so a Windows operator diagnosing a killed runtime is told the exit status is unavailable when the drain above has already confirmed it. Windows is where a reaped root is hardest to diagnose, and it is the platform with no status. The fix records the reap inside that branch, before the handle is dropped. The drain returns only once every member's exit is CONFIRMED, so the status is knowable at exactly that point; its failure path raises instead, which keeps the placeholder true for a tree it could not confirm. The shared kill test double is the second half. It stubs the Windows drain with a mock that returns without awaiting `process.wait()`, while the real `terminate_windows_asyncio_tree` awaits it — and that await is what populates `returncode`. So the double handed the Windows branch a process whose status is unreadable, and four existing assertions about the post-reap status failed on the Windows shard alone: the double disagreeing with the code rather than the code being wrong. The stand-in now drains the way the real one does. Each half is load-bearing, shown by reverting one at a time with the branch forced through `platform_compat.IS_WINDOWS`: - production fix reverted, faithful double: the new test fails on the placeholder - faithful double reverted, production fix kept: the four existing tests fail with the CI annotations' own assertion text - both present: 4 existing + 2 new pass Two regression tests force the branch on every platform rather than leaving it to the Windows shards, because a branch one CI lane reaches is a branch whose loss is invisible in every other lane. The second pins the refusal direction: a drain that raised leaves `<not reaped>` standing and logs no amendment. The owning spec gains the amendment it never documented, including that it must be called from both teardown branches and what the test double's drain has to do. Fixes kirodotdev#12247
Fixes #12247 —
Backend Tests (Windows) (1)is red on every open PR whose base is currentmain, and it is a real product gap rather than a test's platform assumption.What changed
A killed runtime's death line is written before the signal, so its retained summary says
[returncode=<not reaped>]and_note_reaped_after_killfills the status in once the reap completes. That call sits after the POSIX signal ladder, and_kill_inner's Windows branch returns 63 lines before reaching it — so on Windows the amendment never runs, for any returncode.The fix records the reap inside that branch, before the handle is dropped. The drain above returns only once every member's exit is CONFIRMED, so the status is knowable at exactly that point; the drain's failure path raises instead, keeping the placeholder true for a tree it could not confirm.
The shared kill test double is the second half. It stubbed the Windows drain with a mock returning without awaiting
process.wait(), while the realterminate_windows_asyncio_treeawaits it (platform_compat.py) — and that await is what populatesreturncode. So the double handed the Windows branch a process whose status is unreadable, and four existing assertions about the post-reap status failed on the Windows shard alone: the double disagreeing with the code, not the code being wrong. The stand-in now drains the way the real one does.The owning spec gains the amendment it never documented, including that it must be reached from both teardown branches and what the test double's drain has to do.
src/kiro_crew/acp/runtime.pytest/test_acp_runtime.pydocs/system-specs/modules/acp-client.mdWhy this is not a test-assumption fix
#12247's mechanism reads the failure as the tests asking for a POSIX signal returncode Windows cannot produce. Two facts disagree, both read from the tree:
-15. They supply it:proc.waitis replaced with a function that assignsproc.returncode = -15on aMagicMock. Substituting1would fail identically._note_reaped_after_killhas exactly one call site (runtime.py), and the Windows branchreturns before it. The amendment is skipped for every returncode, so<not reaped>is the pre-signal placeholder never being overwritten rather than the correct Windows reading of the state.The consequence is not log-only. The summary outlives the log and rides
AcpProcessDiedinto a turn's error text and a cron'slast_error. Windows is where a reaped root is hardest to diagnose, and it is the platform with no status.That matters for the shape of the fix: relaxing the four assertions — skipping them on Windows, or accepting
<not reaped>there — turns the lane green and makes the gap permanent and invisible.Why neither author's CI could see it
terminate_windows_asyncio_treeentersruntime.pyin1e40f7f0f5(#12005), which is where the earlyreturncomes from. #12188 supplied the assertions.Backend Tests (Windows) (1)runs green — its last Windows runEach was green on its own base; they are red together.
Non-vacuity
Both halves are load-bearing, shown by reverting one at a time with the branch forced through
platform_compat.IS_WINDOWS:assert '[returncode=-15]' in 'killed (warm mint teardown) [..., andassert Falsefor the reason test)The middle row is the important one: it reproduces CI's exact four failures on macOS, so the fix is verified against the observed failure rather than against a theory of it.
Two regression tests force the branch on every platform rather than leaving it to the Windows shards, because a branch one CI lane reaches is a branch whose loss is invisible in every other lane. The second pins the refusal direction: a drain that raised leaves
<not reaped>standing and logs no amendment.Verification
AcpProcessDied): 3243 passed, 19 skipped. After the rebase, the 5 closest files: 474 passed.check_subprocess_encoding.py, isort, flake8, mypy--platform linux(1654 files), comment-history withCOMMENT_HISTORY_BASE_REF=origin/main, docs-lint: all green.4dfbfb04a8; no file overlap with anything main added since the branch point, and no open PR touches either changed source file.Two deviations stated rather than hidden: the profile's scoped-test gate expands to the whole suite here (
runtime.pyis imported broadly) and the box allowed one xdist worker, so the 21-file related set above was run instead of a full local suite; and the model-pinned local review lanes were not dispatched, per a standing instruction in this workspace not to use subagents — the diff self-review was done directly.Pattern harvest
Rule candidate: review-prompt — a platform-gated
returninside a teardown or cleanup path must be checked against the shared epilogue below it, and any test double standing in for that path must reach the same awaits the real one does, or the branch ships unexercised on the platform it exists for.Two mechanisms, one shape: a per-platform branch that
returns early inherits none of the shared epilogue below it, and a test double that is simpler than the thing it replaces hides exactly the platform where that matters. The double was the load-bearing half — without fixing it the production fix is invisible, and with only the double fixed the tests still fail, which is why a fix touching one of them would have read as incomplete in either direction.The general guard is the one this PR adopts rather than proposes: pin a platform-gated branch with the platform forced, so the branch is exercised in every lane instead of one.