Skip to content

fix: stop everything the deepseek gate probe started when it is killed - #35492

Merged
bolichen97 merged 1 commit into
mainfrom
fix/34019-deepseek-probe-tree-kill
Nov 12, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/34019-deepseek-probe-tree-kill

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: When Kiro Crew has to stop the DeepSeek harness it boots to check the gate, everything that harness started stops with it.

Before a DeepSeek chat starts, _verify_deepseek_gate boots dsh --profile acp once to read back the gate plugin's load marker. When the read-back times out, or dsh ignores stdin closing, the probe calls process.kill(). That ends only dsh itself, so anything dsh started keeps running with no parent.

Why it matters

Every chat start that reaches that kill can leave processes running on the operator's machine, holding memory and files, with nothing left that will stop them. #34237 fixed the same defect in the Strands probe; the DeepSeek probe still has it.

Not a goal

What changed (motivation → approach → change)

When Kiro Crew has to stop the DeepSeek harness it boots to check the gate, everything that harness started now stops with it. Before, only the harness's own process was stopped.

The probe used a single-process kill on a child that had no process group of its own, so the kill had nothing wider to reach. kill_popen_tree, the shared tree kill in platform_compat, already does the wider kill: the whole group on POSIX, taskkill /T /F on Windows, then the same direct kill as before.

In src/kiro_crew/acp/harness/deepseek.py the probe now starts in its own process group (start_new_session=IS_POSIX, creationflags=CREATE_NEW_PROCESS_GROUP, the same pair the Strands probe uses), and both places that stop it (the timeout after stdin closes and the error path) call platform_compat.kill_popen_tree. The bounded reap after the timeout kill is unchanged.

Backwards compatibility

Compatible: only a probe that is already being stopped behaves differently, and it now also stops what it started. The refusal text, the read-back budget and the session launch are unchanged.

Removes nothing: the probe still kills its direct child; the tree kill ends with that same kill.

Tests

  • test_a_probe_that_will_not_exit_is_killed_with_everything_it_started (new): a real stand-in dsh starts a worker, publishes the marker, then ignores stdin closing. After _verify_deepseek_gate returns, neither the stand-in nor its worker is running. On main the worker survives and the test fails. The test ends both processes in a finally from the pids they recorded, so a run stopped mid-probe (Ctrl+C, a timeout) leaves nothing running.
  • test_a_failure_while_the_probe_runs_ends_it_with_everything_it_started (new): the fake harness's poll() raises OSError, and the error path still stops it with the tree kill.
  • test_a_probe_whose_plugin_never_writes_a_marker_is_refused_and_ended: the shared fake Popen has no pid to signal, so the verifier helper records the tree kill on the fake, and the test asserts that the timeout path used the tree kill. Its other assertions are unchanged.
  • test_acp_strands_backend.py::test_a_probe_that_will_not_exit_is_killed_with_everything_it_started, the Strands test the new real-process test copies, ends its stand-in and worker in the same finally. Its assertion is unchanged.

Proof: PROVEN test/test_acp_deepseek_backend.py::test_a_probe_whose_plugin_never_writes_a_marker_is_refused_and_ended, test/test_acp_deepseek_backend.py::test_a_probe_that_will_not_exit_is_killed_with_everything_it_started, test/test_acp_deepseek_backend.py::test_a_failure_while_the_probe_runs_ends_it_with_everything_it_started (head 71f7860)

Determinism: the three DeepSeek tests above passed 20 times at -n0; they and the whole of test/test_acp_strands_backend.py, which holds the Strands real-process test, passed 10 times at -n 4 --dist loadgroup --max-worker-restart=2 beside test/test_acp_deepseek_backend_vault.py; and the whole DeepSeek file passed in a shuffled order (seed 2407). prove.py --per-hunk reverts each production hunk on its own and a test fails for every one.

Manual verification

N/A — unit coverage sufficient: the real-process test drives the real function with real child processes on Linux. The Windows arm is the shared kill_popen_tree (taskkill /T /F), and the same test runs in the Windows backend CI job.

Screenshots / video

N/A — the diff touches no frontend surface.

Related Issues

Closes #34019

Sibling sweep

Swept: git grep -nE "def verify[a-z]+_(gate|routing)|.kill()" -- src/kiro_crew/acp/
Sibling: src/kiro_crew/acp/harness/strands.py:757 -- not affected -- #34237 already stops this probe with the tree kill
Sibling: src/kiro_crew/acp/harness/pi.py:845 -- tracked in #35414
Sibling: src/kiro_crew/acp/harness/opencode.py:564 -- tracked in #35414
Sibling: src/kiro_crew/acp/client_permissions.py:217 -- not affected -- reads the session reply, starts no process
Sibling: src/kiro_crew/acp/client_lifecycle.py:551 -- not affected -- fallback after the session's tree kill already ran
Sibling: src/kiro_crew/acp/client_spawn_env.py:823 -- not affected -- a child still suspended at creation has started nothing
Sibling: src/kiro_crew/acp/session_handle_lifecycle.py:259 -- not affected -- a docstring naming runtime.kill(), not a kill site

Pattern harvest

Rule candidate: review-prompt
Pattern: a Popen probe stopped with process.kill() and no process group of its own, which leaves the probe's descendants running

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 19:17
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change moves the DeepSeek probe onto the same group-plus-tree-kill shape the Strands probe already uses, and both kill sites are covered.

[DESIGN-REVIEWED] 71f7860

Description read

[DESCRIPTION-READ] 850337f5128541eb0fe7ef8e24c8ce7095e5a0947ac00cdf5b6fd6db1e4ec59a

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 Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 71f78609a68b128073113d2cdb2c0cfb656f98ab — 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 fix uses the tree kill that already exists in platform_compat_kill.py:497, and the two sibling probes it leaves alone, pi and opencode, are tracked in #35414.

What this change ships

Inventory (4 items) — 3 justified

Intent: when Kiro Crew stops the DeepSeek gate probe, everything that probe started also stops (a FIX, closes #34019).

  1. A probe killed after a timeout now ends the processes it started too, not only dsh. — justified
  2. A probe stopped by an error during the read-back ends the processes it started too. — justified
  3. The probe now starts in its own process group or session, so the tree kill has a group to reach. — justified
  4. The Strands real-process test now cleans up its stand-in and worker in a finally. — rides along: test-only hygiene, already declared

[FIRST-PRINCIPLES-REVIEWED] 71f7860

Description read

[DESCRIPTION-READ] 89745c6183f6d461fc1c696e06b0fd1d0b7dd51e21bcbc72e63b15bc43894439

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 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 71f7860

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

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 71f7860

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

@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The DeepSeek gate probe now starts in its own process group and both of its kill sites (timeout and error path) use the shared kill_popen_tree, the same as the existing Strands probe fix. The change is minimal, matches the description, regresses no sibling path, and moves no trust boundary. A new real-process test would fail on main, and the fake-process tests assert the tree kill on both paths. The remaining gaps (no kill on every exit path, pid-reuse hygiene in test cleanup, pending CI) don't block.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 13e58d5f52 · 101 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Backend Tests (3.12, 8) and Backend Tests (Windows) (8) fail on test/test_mcp_remote_transport.py::TestRewriter::test_a_listed_remote_entry_passes_through_unwrapped and ::test_a_malformed_type_does_not_abort_the_rewrite. The same two tests fail on main (Windows shard 8 at 89530fe), and this PR does not touch that file. The fix is in flight in #35547 and #35541 (tracked in #35534); this PR waits for it, and Coverage Gate fails closed on the same shards. Analyze (actions) stopped on the CI installation's API rate limit, not on a finding.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 11, 2026
@bolichen97
bolichen97 force-pushed the fix/34019-deepseek-probe-tree-kill branch from d3f3fc3 to 13e58d5 Compare November 11, 2026 23:00
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/harness/deepseek.py since this head's CI ran (ee7a026 -> 6c11807), and main now carries #35541, the fix for the shard-8 red in test_mcp_remote_transport.py; CI re-running.
[operator: bolichen97]

@bolichen97

bolichen97 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the real-process kill test's stand-in cleanup

  • Make real probe cleanup unconditional span=14fd41435ae5

fixed in 13e58d5: the test ends the stand-in and its worker in a finally that reads the pids the stand-in recorded, so an interrupt during _verify_deepseek_gate, await_pids or await_gone still stops both.
Same class, same fix: the Strands probe test this one copies (test_acp_strands_backend.py); no other kill_leftovers(alive) site exists.
Residual: an interrupt in the few lines between the stand-in starting its worker and writing its pidfile leaves no pids to read; both 120 s sleeps then end on their own.

[operator: bolichen97]

The DeepSeek gate read-back boots dsh once and, when the read-back
times out or dsh ignores stdin closing, kills it with process.kill().
That ends only the direct child, so anything dsh started kept running
with no parent.

Start the probe in its own process group and stop it with the shared
platform_compat.kill_popen_tree at both kill sites, as the Strands
probe does, so the whole tree goes with it (taskkill /T /F on
Windows). The bounded reap, the refusal text and the read-back budget
are unchanged.

The real-process tests for this probe and for the Strands probe end
their stand-in and its worker in a finally, so a test stopped
mid-probe leaves nothing running.

Closes #34019
@bolichen97
bolichen97 force-pushed the fix/34019-deepseek-probe-tree-kill branch from 13e58d5 to 71f7860 Compare November 12, 2026 08:36
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/acp/client_permissions.py, src/kiro_crew/acp/client_start.py, src/kiro_crew/acp/harness/codex.py, src/kiro_crew/acp/runtime_spawn_launch.py, test/acp_launch_capture.py and test/test_codex_host_binary.py since this head's CI ran (6c11807 -> 758e63c), and main now carries #35625, the fix for the main reds in test_wait_discipline_ratchet.py and test_updates_handlers_facade.py (red on main at e8283ce in the same shards); CI re-running.
[operator: bolichen97]

@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 12, 2026

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

Approve on 71f7860. The DeepSeek gate probe starts in its own process group, and both of its kill paths call the shared tree kill, so a killed probe takes the processes it started with it. Since the last approved head, the product change is unchanged; the PR now also moves the cleanup in the DeepSeek and Strands real-process kill tests into a finally block, so an interrupted test run leaks nothing. Each of the three guard mutations turns a named test red. One backend shard failed once on a test in an unrelated file and passed on a single rerun; every check on this head is now green. Decisive lines: src/kiro_crew/acp/harness/deepseek.py:581-582, src/kiro_crew/acp/harness/deepseek.py:609, src/kiro_crew/acp/harness/deepseek.py:614, src/kiro_crew/platform_compat_kill.py:497-518, test/test_acp_deepseek_backend.py:371-383

@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 12, 2026
@bolichen97
bolichen97 merged commit 42dd6f0 into main Nov 12, 2026
154 of 156 checks passed
@bolichen97
bolichen97 deleted the fix/34019-deepseek-probe-tree-kill branch November 12, 2026 11:42
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
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.

DeepSeek gate read-back: killing a probe that will not exit ends only its direct child, so anything dsh started keeps running

3 participants