Skip to content

fix: close the stdin of a dead runtime so its kiro-cli tree exits - #31476

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/19141-macos-session-close-orphans
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/19141-macos-session-close-orphans

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Closing a session on macOS ends its kiro-cli and everything below it, even when the process Kiro Crew started in front of kiro-cli died first.

On macOS, when the process Kiro Crew spawns for a session is a wrapper or launcher in front of kiro-cli, and that process dies during the initialize handshake, kiro-cli and everything below it keep running after the session is closed. Measured on macOS 26.7.2 with kiro-cli 3.1.0 started through such a wrapper launcher: kiro-cli, its engine and the launcher (reparented to PID 1) were still alive 14 minutes after the close, and exited only when the gateway stopped. A stock kiro-cli install, where the spawned process is kiro-cli itself, was not tested for this case. A kiro-cli kept alive this way would also keep alive any language server it had started.

Why it matters

Each leaked tree is a whole agent: kiro-cli, its engine and any MCP server it had started, holding memory and CPU until the gateway restarts, and every session whose start fails this way adds one more. #19141 shows what leftover processes cost on a Mac once they pile up: a load average above 100 and a machine that stopped responding.

Not a goal

  • Signalling a leaderless process group on macOS. The vouching read stays Linux-only, and this PR adds no signal, kill path or matcher.
  • Making kiro-cli's v3 engine start pyright in dashboard sessions, or changing how kiro-cli starts language servers.
  • The teardown other harnesses use (AcpClient): it already closes its pipes after every kill.
  • A close that races the automatic retry of a turn whose runtime died, which can bring the session back.

What changed (motivation → approach → change)

The process Kiro Crew spawns is not always the one that reads its stdin: a wrapper or launcher can sit in front of kiro-cli and hand it the same pipes. When that spawned root dies first, its descendants still hold the stdout and stderr pipes, so asyncio's transport never finishes and never closes stdin, and kiro-cli never reads EOF. Linux reaches that tree through the vouched group signal. macOS cannot vouch the group, so a tree whose root died before any descendant was recorded had nothing that ended it.

The POSIX kill in AcpRuntime aborts its own write end of the root's stdin before it drops the process handle (runtime_tree_kill._release_stdin). kiro-cli reads EOF and exits, and its engine follows. Nothing is signalled: only the holders of that pipe's other end, which are this spawn's own tree, see the EOF. It uses the stdin pipe's abort, because close waits for buffered bytes to drain, and not the subprocess transport's close, which would kill a root that is still running.

The ACP client spec records this release next to the leaderless-group rule it completes.

Backwards compatibility

Compatible: the kill sends exactly the signals it sent before, and closes one pipe end of the process it is tearing down.
Removes nothing: no record, path, key or function goes away; a pipe end the dead runtime no longer uses is released instead of being held until the gateway exits.

Tests

  • test/test_acp_runtime_kill.py::test_kill_releases_stdin_so_the_tree_a_dead_root_left_reads_eof starts a real root that exits at once and leaves a child holding its pipes and blocked on stdin. With both signal paths unable to reach anything (the macOS shape), kill() must still make that child exit. With the release removed the child is still running 60 s after kill(). The test's liveness check reads the kernel through functions bound at import, before any fixture or patch runs, so no stub on the kill path reaches it.

Proof: PROVEN test/test_acp_runtime_kill.py::test_kill_releases_stdin_so_the_tree_a_dead_root_left_reads_eof (head f9da353)

Determinism: 10/10 runs at -n0; 5/5 at -n 2 --dist loadgroup --max-worker-restart=2 beside test/test_pid_lifecycle_teardown.py and test/test_runtime_bindings.py; the whole file in a shuffled order (seed 4127), 22 passed. The flake-pattern ratchet passes, and the related backend set (8 files) passes.

Manual verification

macOS 26.7.2 (Apple silicon), kiro-cli 3.1.0, pyright 1.1.414, an isolated gateway on its own data home, sessions driven through the dashboard API on a project with .kiro/settings/lsp.json. On this machine the kiro-cli on PATH is a wrapper: the process the gateway spawns is that wrapper, which starts a launcher, which starts the real kiro-cli on the same stdin. Survivors were checked 60 s or more after each close.

Scenario Before (07ab5da) After (the fix on 07ab5da)
5 sessions, one prompt each, closed nothing from them left nothing from them left
kiro-cli killed mid-turn, then closed nothing left not run
the wrapper process right above kiro-cli killed while the session starts, then closed not run nothing left
spawned root killed after the handshake, while MCP servers start, then closed nothing left not run
spawned root killed mid-turn; the session was not closed and the turn retried on a fresh runtime killed tree gone in 0.9 s killed tree gone in 1.0 s
spawned root killed during the initialize handshake session closed 3.8 s later; launcher, kiro-cli and engine still alive at 14 min kiro-cli and engine gone 1.6 s after the kill, the rest of the tree by 4.2 s, 3 of 3 runs

In the last row's After runs the kill was the gateway's own cleanup of the failed handshake; two of the three sessions were then closed, after kiro-cli was already gone.

The same leak reproduces outside the gateway, through the same wrapper: with the parent holding the pipes, 4 of the 6 processes were still running 20 s after the spawned root was killed, and those 4 exited within 1.9 s once only stdin was closed.

The live runs used the fix on 07ab5da; the branch sits on 7c364bc. Between the two, of the three files only acp-client.md changed, in sections outside the kill path; runtime_tree_kill.py and the test file did not change.

Related Issues

Part of #19141

Sibling sweep

Swept: git grep -n "_process = None" -- src/kiro_crew; git grep -n "_proc = None" -- src/kiro_crew
Sibling: src/kiro_crew/acp/client_lifecycle.py -- not affected -- _reset_state closes stdin, stdout and stderr after every kill, a dead root included
Sibling: src/kiro_crew/imessage/rpc.py -- not affected -- close() closes stdin before it reaps the child
Sibling: src/kiro_crew/computer_use/overlay.py -- not affected -- its teardown closes stdin before it reaps the child
Sibling: src/kiro_crew/mcp_gateway/manager.py -- not affected -- the daemon is spawned with stdin set to DEVNULL
Sibling: src/kiro_crew/power.py -- not affected -- the child is spawned with stdin set to DEVNULL
Sibling: src/kiro_crew/instances/ssh_tunnel_manager_child.py -- not affected -- no stdin pipe is opened to the tunnel child
Sibling: src/kiro_crew/history_index_worker.py -- not affected -- a multiprocessing worker with no stdin pipe from the gateway

Pattern harvest

Rule candidate: review-prompt
Pattern: a teardown drops an asyncio subprocess handle spawned with stdin=PIPE without closing stdin, so descendants of a root that died first never read EOF.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 15:06
@bolichen97 bolichen97 added the ci:macos Run the on-demand macOS suite against this PR head label Nov 6, 2026
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 15:06
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f9da35325e629c6d0fc08d258e3bda89630bb025 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f9da35325e629c6d0fc08d258e3bda89630bb025 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. The change adds one pipe release inside the existing kill path. The defect has a measured reproduction, and a test that fails without the fix.

What this change ships

Inventory (3 items) — 3 justified

Intent: when a macOS session is closed, its kiro-cli tree exits, even if the launcher process in front of kiro-cli died first. This is a FIX.

  1. Closing a session whose runtime root died first now ends the kiro-cli tree left under it, because its stdin pipe is released — justified
  2. The ACP client spec records the stdin release next to the leaderless-group rule — justified
  3. A real-process test where a dead root leaves a child blocked on stdin — justified

[FIRST-PRINCIPLES-REVIEWED] f9da353

Description read

[DESCRIPTION-READ] ffbbb4ab606a171b409154eec137b430c6ed08b2a97c7dc98e3ef43b085ff2a1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of f9da35325e629c6d0fc08d258e3bda89630bb025 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the patch removes nothing, the release is limited to the gateway's own pipe end, and the macOS-only branch has live before-and-after runs.

[DESIGN-REVIEWED] f9da353

Description read

[DESCRIPTION-READ] bd788d92635ee7f74c11240a16c6497a4ba109c63ab09722d3a0709370f23b34

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.

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 15:13
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/19141-macos-session-close-orphans branch from 3e0d9b6 to 93fce4e Compare November 6, 2026 15:42
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/cli.md, docs/system-specs/modules/subagent.md, src/kiro_crew/acp/kas_agents.py, src/kiro_crew/acp/worker_pool.py, test/test_kas_agents_mcp_servers.py and test/test_worker_pool_cancel_reap.py since this head's CI started (85ce466 -> b3c17ad); CI re-running on 93fce4e. None of those is a file this PR changes, and the PR's own diff is byte-identical to the one on 3e0d9b6. The previous head's in-flight runs were cancelled before this push.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] On 3e0d9b6 the GPT 6.1 and Opus 5.5 lanes computed verdicts but could not publish them (the GitHub API rate limit hit while they read this PR). Both withheld verdicts report no blocking findings.

The Opus verdict carried one note: that the new test patches rt.platform_compat.get_process_start_id, the same module _still_running reads, so the post-kill wait would pass even with _release_stdin removed. That does not hold. The file's autouse _fast_kill_windows fixture replaces rt.platform_compat with a per-test _StubbedPlatformCompat instance, so the test's patches land on that stub, while _still_running reads the real kiro_crew.platform_compat. Checked by running the test with the _release_stdin(self._process) call removed: it fails at the post-kill wait (child <pid> still running after kill() at the end of the 90 s budget). prove.py reports PROVEN on 93fce4e. No code change.

@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 Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f9da353

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable f9da35325e629c6d0fc08d258e3bda89630bb025 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f9da353

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f9da35325e629c6d0fc08d258e3bda89630bb025 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/19141-macos-session-close-orphans branch from 93fce4e to 6a0fcd6 Compare November 6, 2026 16:28
@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 Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]
span=637212248979

  • rebutted: the stdin-release test stays green with the release removed

Rebutted: the stated mechanism does not hold. The file's autouse _fast_kill_windows fixture rebinds rt.platform_compat to a per-test _StubbedPlatformCompat() instance, and the runtime facade mirrors that write into runtime_tree_kill, so the test's monkeypatch.setattr(rt.platform_compat, ...) lines patch that stub, not the module.
_still_running reads the test module's own from kiro_crew import platform_compat, the real module, which no line of the test patches, so it compares the child's live start id with the one captured before any patch.
Measured: prove.py reverts the production hunks of runtime_tree_kill.py (the _release_stdin call and the function) in a throwaway worktree, and the test then fails at the post-kill wait with the child still running. It reports PROVEN on 93fce4e and again on the rebased 6a0fcd6, whose diff is byte-identical.
No code change.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased: main moved in docs/system-specs/modules/acp-client.md, docs/system-specs/modules/metrics.md, src/kiro_crew/acp/kas_secret_storage.py, src/kiro_crew/acp/liveness.py, src/kiro_crew/acp/session_handle_dispatch.py, src/kiro_crew/acp/session_handle_watchdog.py, test/test_acp_stale_recovery.py, test/test_acp_watchdog_working_bound.py and test/test_mcp_grant_kas.py since this head's CI started (b3c17ad -> 89a6107); CI re-running on 6a0fcd6. Of those, only acp-client.md is a file this PR changes, and main changed its watchdog section, not the kill-path text this PR adds. The related tests for those files and this PR's test file pass on the rebased head.

The new base also carries #31469, which raises the security package line budget. test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget failed in Backend Tests (Windows) (2) on 93fce4e because b3c17ad itself held 34,733 package lines against a 34,699 budget; this PR changes nothing under src/kiro_crew/security/. The PR's own diff is byte-identical to the one on 93fce4e, and that head's in-flight runs were cancelled before this push.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]
span=637212248979

  • rebutted: the post-kill wait and the cleanup read the real platform_compat, not the patched stub

Rebutted: the stated mechanism does not hold on this head. The autouse _fast_kill_windows fixture rebinds rt.platform_compat to a fresh _StubbedPlatformCompat() before the test body runs, so monkeypatch.setattr(rt.platform_compat, "get_process_start_id", ...) sets an attribute on that stub instance only.
_still_running and the finally cleanup call the test module's own from kiro_crew import platform_compat, the real module, which no line of the test patches. Checked at runtime on this head after the test body: rt.platform_compat is platform_compat is False, the stub's get_process_start_id(1) is None, the real module's is a live start id.
Measured: prove.py on this exact tree reverts the _release_stdin hunks of runtime_tree_kill.py in a throwaway worktree and the test fails at the post-kill wait with the child still running: PROVEN. With the hunks in place it passes in about 3 s.
No code change.

@bolichen97

Copy link
Copy Markdown
Contributor Author

/ai-review override fable 6a0fcd6 false-positive: agent: [operator: bolichen97] the test's liveness check and cleanup call the real kiro_crew.platform_compat; its patches land on the per-test _StubbedPlatformCompat that the autouse fixture binds to rt.platform_compat. With the _release_stdin hunks reverted the test fails its post-kill wait (prove.py PROVEN on this tree). Disposition: issuecomment-6690374257

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 recorded a false-positive release (class false-positive) for the fable AI finding on 6a0fcd6fc3ec727a0ee5d4e769f3281b02887a3b.

agent: [operator: bolichen97] the test's liveness check and cleanup call the real kiro_crew.platform_compat; its patches land on the per-test _StubbedPlatformCompat that the autouse fixture binds to rt.platform_compat. With the _release_stdin hunks reverted the test fails its post-kill wait (prove.py PROVEN on this tree). Disposition: issuecomment-6690374257

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/19141-macos-session-close-orphans branch from 2bac360 to bd4d2d6 Compare November 6, 2026 20:22
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]
span=637212248979

  • rebutted: the liveness oracle reads the real platform_compat; the line-717 patch lands on the per-test stub

Rebutted: the stated mechanism does not hold. During this test rt.platform_compat is not the module: the autouse _fast_kill_windows fixture (line 102) rebinds it to a fresh _StubbedPlatformCompat() before the body runs, so line 717 sets get_process_start_id on that stub instance only.
_still_running (line 680) and the finally cleanup call the test module's own from kiro_crew import platform_compat, the real module, which no line of the test patches, so they compare the child's live start id with the one captured before any patch.
Measured: prove.py reverts the _release_stdin hunks of runtime_tree_kill.py in a throwaway worktree and the test then fails at the post-kill wait with the child still running: PROVEN on 2bac360 and again on the rebased bd4d2d6, whose diff is byte-identical.
No code change. The same class was rebutted on 93fce4e and 6a0fcd6.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto #31625 (c0e9c2e -> 39717a0), the main fix this PR was waiting for: it raises the security package line budget that all three red shard-2 Backend Tests jobs on 2bac360 failed on (test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget, main's red, see the comment above). CI re-running on bd4d2d6.

This is the rebase onto a red-main fix, not a green-age re-sync, so it does not draw on the re-sync budget, which the three earlier re-syncs on this PR have spent. None of the three files this PR changes moved on main, and the PR's own diff is byte-identical to the one on 2bac360. On the rebased head the related backend tests plus the line-budget test pass locally (11 files, 788 tests) and prove.py reports PROVEN. No runs were in flight on 2bac360 when this push went out.

@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 Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The two red shard-7 Backend Tests jobs on bd4d2d6 (Linux 3.12 and Windows) are one test, test/test_pull_request_target_allowlist.py::test_only_the_allowed_workflows_use_pull_request_target, and the red is main's, not this PR's. #31396 moved .github/workflows/sensitive-change-review.yml onto pull_request_target after #31249 pinned the allowlist without it, so the test fails on this PR's base (39717a0) and on current main (ea5dedb). It fails the same way when run locally on this head, and this PR changes no workflow and not that test. Coverage Gate is red only because it requires those backend jobs to pass.

The fix is #31803. This PR waits for it: no push and no override for that red.

The five AI review lanes on bd4d2d6 (Design, First Principles, GPT 6.1, Opus 5.5, UX) failed before any of them produced a verdict: each one hit the shared GitHub API rate limit while reading this PR. Each lane has been re-run once.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]
span=637212248979

  • rebutted: the post-kill wait and the cleanup read the real platform_compat; line 717 patches the per-test stub

Rebutted: the stated mechanism does not hold. The autouse _fast_kill_windows fixture (test/test_acp_runtime_kill.py:102) runs before the body and rebinds rt.platform_compat to a fresh _StubbedPlatformCompat(), so during this test rt.platform_compat is not the module object and line 717 sets get_process_start_id on that stub instance only.
_still_running and the finally cleanup call the test module's own from kiro_crew import platform_compat, the real module. No line of the test writes to it; the stub's __getattr__ only reads through to it.
Measured on this head: prove.py reverts the _release_stdin hunks of runtime_tree_kill.py in a throwaway worktree, and the test then fails with the bug reintroduced: Proof: PROVEN test/test_acp_runtime_kill.py::test_kill_releases_stdin_so_the_tree_a_dead_root_left_reads_eof (head bd4d2d6dded5).
No code change. The same class was rebutted with the same evidence on 93fce4e, 6a0fcd6 and 2bac360.

@bolichen97

Copy link
Copy Markdown
Contributor Author

/ai-review override fable bd4d2d6 false-positive: agent: [operator: bolichen97] line 717 patches the per-test _StubbedPlatformCompat that the autouse _fast_kill_windows fixture binds to rt.platform_compat, not the module; the test's _still_running wait and finally cleanup read the real kiro_crew.platform_compat. prove.py is PROVEN on this head: with _release_stdin reverted the test fails.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 recorded a false-positive release (class false-positive) for the fable AI finding on bd4d2d6dded56693c97bfb30737672c0a56c55ee.

agent: [operator: bolichen97] line 717 patches the per-test _StubbedPlatformCompat that the autouse _fast_kill_windows fixture binds to rt.platform_compat, not the module; the test's _still_running wait and finally cleanup read the real kiro_crew.platform_compat. prove.py is PROVEN on this head: with _release_stdin reverted the test fails.

This decision applies only to this commit. A new push requires a new judgment.

When the process Kiro Crew spawned for a kiro-cli session is not the
one that reads its stdin (a wrapper or launcher sits in front of
kiro-cli) and it dies before its tree does, for example killed during
the initialize handshake, the descendants keep the write ends of
stdout and stderr. asyncio's subprocess transport then never sees
every pipe close, never finishes, and never closes stdin, so kiro-cli
reads no EOF. On macOS no member of the leaderless group can vouch for
it and no descendant was recorded yet, so nothing signals the tree
either: kiro-cli, its engine and any MCP server it had started keep
running after the session is closed, for the life of the gateway.

AcpRuntime's POSIX kill now aborts its own write end of the root's
stdin before it drops the handle. It signals nothing: only holders of
the pipe's other end, which are this spawn's own tree, see the EOF. It
uses the stdin pipe's abort rather than close, which waits for buffered
bytes to drain, and never the subprocess transport's close, which
kills a root that is still running.

Part of #19141
@bolichen97
bolichen97 force-pushed the fix/19141-macos-session-close-orphans branch from bd4d2d6 to f9da353 Compare November 6, 2026 22:37
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto main 7c364bc, which carries the fix for main's red test_pull_request_target_allowlist (#31803). This is the red-main rebase, not a green-age re-sync. The same commit also binds the test's liveness check to functions read at import, so no kill-path stub can reach it. CI is re-running on f9da353.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97]
span=637212248979
resolution: removed -- the oracle reads functions bound at import, before any fixture or patch runs, so no stub can reach it

  • fixed: the liveness check no longer looks up the names the kill-path stub shadows

fixed in f9da353: the test's liveness check now reads get_process_start_id and pid_is_zombie through names bound at import, so no fixture or patch can reach the oracle.
prove.py on the new head: PROVEN test/test_acp_runtime_kill.py::test_kill_releases_stdin_so_the_tree_a_dead_root_left_reads_eof (head f9da353).

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The five AI review lanes (Design, First Principles, UX, GPT 6.1, Opus 5.5) failed twice on head f9da353 on the CI installation token's API rate limit, before any of them posted a verdict (first at 23:08Z, then the rerun at 00:48Z). That is an infrastructure outage, not a review finding, so I re-ran each of the five lanes once more on the same head. No code change.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026

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

Approved for the on-call. Review lanes pass on f9da353, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 15ec103 into main Nov 7, 2026
104 of 119 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/19141-macos-session-close-orphans branch November 7, 2026 05:03

@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: fix (3 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: the runtime kill now aborts the write end of the dead root's stdin so the tree it left reads EOF and exits, with a regression test. 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.

buluoray pushed a commit that referenced this pull request Nov 7, 2026
…1476)

When the process Kiro Crew spawned for a kiro-cli session is not the
one that reads its stdin (a wrapper or launcher sits in front of
kiro-cli) and it dies before its tree does, for example killed during
the initialize handshake, the descendants keep the write ends of
stdout and stderr. asyncio's subprocess transport then never sees
every pipe close, never finishes, and never closes stdin, so kiro-cli
reads no EOF. On macOS no member of the leaderless group can vouch for
it and no descendant was recorded yet, so nothing signals the tree
either: kiro-cli, its engine and any MCP server it had started keep
running after the session is closed, for the life of the gateway.

AcpRuntime's POSIX kill now aborts its own write end of the root's
stdin before it drops the handle. It signals nothing: only holders of
the pipe's other end, which are this spawn's own tree, see the EOF. It
uses the stdin pipe's abort rather than close, which waits for buffered
bytes to drain, and never the subprocess transport's close, which
kills a root that is still running.

Part of #19141

(cherry picked from commit 15ec103)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:macos Run the on-demand macOS suite against this PR head 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