Skip to content

fix(acp): record the reap on the Windows teardown branch too - #12269

Merged
iamwhatever merged 1 commit into
mainfrom
fix/windows-reap-amendment
Sep 20, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/windows-reap-amendment

Conversation

@bolichen97

@bolichen97 bolichen97 commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #12247 — Backend Tests (Windows) (1) is red on every open PR whose base is current main, 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_kill fills 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 real terminate_windows_asyncio_tree awaits it (platform_compat.py) — 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, 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.

File Change
src/kiro_crew/acp/runtime.py +7 — record the reap in the Windows branch
test/test_acp_runtime.py +80/-2 — faithful drain double, 2 platform-forced regression tests
docs/system-specs/modules/acp-client.md +25 — document the amendment and the both-branches requirement

Why 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:

  • The tests never ask Windows to produce -15. They supply it: proc.wait is replaced with a function that assigns proc.returncode = -15 on a MagicMock. Substituting 1 would fail identically.
  • _note_reaped_after_kill has exactly one call site (runtime.py), and the Windows branch returns 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 AcpProcessDied into a turn's error text and a cron's last_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_tree enters runtime.py in 1e40f7f0f5 (#12005), which is where the early return comes from. #12188 supplied the assertions.

when (UTC) what
Sep 20 05:45–05:51 #12188's Backend Tests (Windows) (1) runs green — its last Windows run
Sep 20 08:17 #12005 merges, adding the Windows branch that returns early
Sep 20 08:24 #12188 merges, 7 minutes later, without re-running Windows

Each 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:

variant result
production fix reverted, faithful double new test fails on the placeholder
faithful double reverted, production fix kept the four existing tests fail with the CI annotations' own assertion text (assert '[returncode=-15]' in 'killed (warm mint teardown) [..., and assert False for the reason test)
both present 4 existing + 2 new pass

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

  • 21 related test files (every test referencing the death summary, the amendment, the Windows drain, the kill double, or AcpProcessDied): 3243 passed, 19 skipped. After the rebase, the 5 closest files: 474 passed.
  • black (pinned 26.3.1), check_subprocess_encoding.py, isort, flake8, mypy --platform linux (1654 files), comment-history with COMMENT_HISTORY_BASE_REF=origin/main, docs-lint: all green.
  • Rebased onto 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.py is 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 return inside 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.

@bolichen97
bolichen97 requested review from a team and Zedmor September 20, 2026 09:59
@bolichen97

Copy link
Copy Markdown
Contributor Author

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.
Not a goal: changing what the amendment records, the drain's own contract, or the POSIX ladder; relaxing any existing assertion to clear the lane.

@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Confirm the actual Backend Tests (Windows) shard runs green on this PR, since local verification was macOS with the branch forced.

[DESIGN-REVIEWED] f478413

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f478413

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

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

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of f4784137c1316b81cea10ca687513d4d2e6f01e3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

All verification forced IS_WINDOWS via monkeypatch on macOS — confirm the four previously-red assertions actually pass on a real Windows shard.

Not justified as shipped

  • Item 4 — undeclared: test_kill_keeps_the_label_when_no_status_ever_arrives now pins IS_WINDOWS=False; the description's file table ("faithful drain double, 2 platform-forced regression tests") never mentions it. Harm-free rider: the faithful double makes that POSIX-contract test wrong on the Windows shard without the pin.

What this change ships

Inventory (5 items) — 4 justified

Intent: make a killed runtime's death summary carry the real exit status on Windows instead of <not reaped>, unwedging the red Windows CI lane — a FIX (linked issue #12247; provenance verified: on base _note_reaped_after_kill had one call site and the Windows branch returned 63 lines above it).

  1. A killed runtime's death summary on Windows now shows the real exit code — justified
  2. The shared kill test double drains the Windows tree the way the real drain does — justified
  3. Two new tests force the Windows branch in every CI lane, both directions — justified
  4. An existing POSIX-contract test now forces the POSIX branch — undeclared, rides along with item 2
  5. acp-client.md documents the amendment and the both-branches requirement — justified

[FIRST-PRINCIPLES-REVIEWED] f478413

@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of f4784137c1316b81cea10ca687513d4d2e6f01e3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f478413

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

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 20, 2026
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
@bolichen97
bolichen97 force-pushed the fix/windows-reap-amendment branch from 9ed0add to f478413 Compare September 20, 2026 10:16
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 20, 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 Sep 20, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 20, 2026 11:04

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@iamwhatever
iamwhatever merged commit 954fb69 into main Sep 20, 2026
135 of 138 checks passed
@iamwhatever
iamwhatever deleted the fix/windows-reap-amendment branch September 20, 2026 11:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 20, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend Tests (Windows) (1): four test_acp_runtime kill-summary tests assert a POSIX signal returncode Windows cannot produce

2 participants