Repository navigation
fix(provider-process): kill a provider group its SIGKILLed supervisor leaves behind - #30997
Conversation
…oll instead of sleeping in tests
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7d091b1e-5701-462e-a045-48019b3a401b
📒 Files selected for processing: 14
src/main/acp/acp-agent-connection.test.tssrc/main/codex/codex-state-db-backfill-recovery-process.tssrc/main/jsonl-rpc/agent-connection.test.tssrc/main/opencode/opencode-launch-model-context.tssrc/main/provider-process/managed-provider-process.tssrc/main/provider-process/provider-group-orphan-guard.integration.test.tssrc/main/provider-process/provider-group-orphan-guard.test.tssrc/main/provider-process/provider-group-orphan-guard.tssrc/main/provider-process/provider-process-supervisor.test.tssrc/main/provider-process/provider-process-supervisor.tssrc/main/text-generation/commit-message-text-generation-model-discovery.test.tssrc/main/text-generation/source-control-agent-launch.test.tssrc/main/text-generation/source-control-agent-launch.tssrc/main/text-generation/source-control-local-process.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…ion adapter; re-prove same-second starts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1c623145-6448-41ff-9b00-5d53f472b849
📒 Files selected for processing: 12
src/main/codex/codex-app-server-client.test.tssrc/main/codex/codex-app-server-session.tssrc/main/codex/codex-state-db-backfill-recovery-process.tssrc/main/opencode/opencode-launch-model-context.tssrc/main/provider-process/managed-provider-process.tssrc/main/provider-process/provider-group-guard-launch-paths.test.tssrc/main/provider-process/provider-group-orphan-guard.integration.test.tssrc/main/provider-process/provider-group-orphan-guard.test.tssrc/main/provider-process/provider-group-orphan-guard.tssrc/main/provider-process/provider-process-row-read.test.tssrc/main/provider-process/provider-process-row-read.tssrc/main/text-generation/source-control-agent-launch.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| @@ -0,0 +1,221 @@ | |||
| import { hasUnambiguousStartTime } from '../pty-descendant-termination' | |||
| import { recordSelfInitiatedTreeKill } from '../crash-reporting/self-initiated-tree-kill-log' | |||
| import { readPosixProcessRow, type ProcessRowRead } from './provider-process-row-read' | |||
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
fd -a 'tsconfig.*cli.*json' config
rg -n 'provider-group-orphan-guard|provider-process-row-read|pty-process-table-parser|pty-descendant-termination|self-initiated-tree-kill-log' config/tsconfig*.jsonRepository: stablyai/orca
Length of output: 541
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- config/tsconfig.cli.json ---'
nl -ba config/tsconfig.cli.json | sed -n '1,140p'
printf '%s\n' '--- config/tsconfig.tc.cli.json ---'
nl -ba config/tsconfig.tc.cli.json | sed -n '1,140p'
printf '%s\n' '--- direct imports ---'
rg -n -F --glob '*.ts' -e "provider-group-orphan-guard" -e "provider-process-row-read" -e "managed-provider-process" src/main/provider-process config
printf '%s\n' '--- managed-provider-process import block ---'
nl -ba src/main/provider-process/managed-provider-process.ts | sed -n '1,90p'
printf '%s\n' '--- guard import block ---'
nl -ba src/main/provider-process/provider-group-orphan-guard.ts | sed -n '1,35p'Repository: stablyai/orca
Length of output: 18891
🏁 Script executed:
#!/bin/bash
set -e
rg -n -F --glob 'tsconfig.cli.json' -e '../src/main/provider-process/managed-provider-process.ts' -e '../src/main/provider-process/provider-executable-missing.ts' -e '../src/main/provider-process/provider-spawn-failure-report.ts' -e '../src/main/provider-process/provider-process-close.ts' configRepository: stablyai/orca
Length of output: 529
Add both provider-process modules to the CLI TypeScript project.
managed-provider-process.ts imports provider-group-orphan-guard.ts, which imports provider-process-row-read.ts. Add both files to the shared CLI file list so the extended CLI typecheck project includes the complete import chain.
Proposed fix
"../src/main/provider-process/managed-provider-process.ts",
+ "../src/main/provider-process/provider-group-orphan-guard.ts",
+ "../src/main/provider-process/provider-process-row-read.ts",
"../src/main/provider-process/provider-executable-missing.ts",🧰 Tools
🪛 GitHub Actions: PR 30997 | source 1300592aae78a16db276f08571250836a76877af | workflow 1300592aae78a16db276f08571250836a76877af | unit full / 13_static analysis and typecheck.txt
[error] 3-3: TypeScript TS6307: Imported file 'provider-process-row-read.ts' is not listed in project 'config/tsconfig.tc.cli.json'. Update the project's file list or include pattern.
[error] 3-3: TypeScript project configuration error: 'provider-group-orphan-guard.ts' is not listed in 'config/tsconfig.tc.cli.json'. Projects must list all files or use an include pattern.
🪛 GitHub Actions: PR 30997 | source 1300592aae78a16db276f08571250836a76877af | workflow 1300592aae78a16db276f08571250836a76877af | unit full / static analysis and typecheck
[error] 3-3: TypeScript TS6307: Imported file 'src/main/provider-process/provider-process-row-read.ts' is not listed in config/tsconfig.tc.cli.json. Add the file to the project file list or use an include pattern.
Source: Pipeline failures
…uard files in the CLI project
ELI5
Orca starts helper programs (for example a short-lived OpenCode server it asks which models are set up) through a small "babysitter" process. The babysitter stops the helper when the job is done, when it times out, or when Orca quits or crashes. The one case it could not handle was being killed itself with
kill -9(or by the system's out-of-memory killer): then nothing was left to stop the helper, and it kept running in the background forever. Now Orca itself steps in when that happens and stops the leftover helper, after checking it really is the same process it started.What Changed
Before: on macOS and Linux, if the babysitter process was force-killed, the helper and anything it started kept running with no owner, holding memory and a port until the user found and killed it.
After: Orca stops that leftover helper within a moment of seeing the babysitter die.
How it works:
/proc, which is precise to one clock tick. On macOS,psreports start times only to the whole second, so if the helper started in the same second as the lookup, Orca checks again after that second ends that the babysitter is still the parent and the group still matches. Otherwise a different process that reused the ID within that second could show the same start time. If the babysitter is gone by then, Orca records nothing./dev/nullin place of the channel, so on Linux the helper does not inherit it and keep it open.Why
Options considered:
opencode serve. It also leaves the helper running for the whole session.Windows: there is no babysitter on Windows; providers are started directly and stopped with a tree kill. So the gap this PR fixes does not exist there, and the new code only runs when a babysitter was started (
groupReportStdiois empty onwin32).SSH and WSL: the babysitter only runs for local launches on macOS and Linux. Remote providers go through the relay and are not affected. Orca never treats a failed or timed-out lookup as proof that a process exited or is safe to kill.
Linked Issue
N/A (maintainer change).
Visual Proof
N/A: this only affects background process cleanup, so there is nothing new to see in the UI.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New
provider-group-orphan-guard.integration.test.ts(POSIX) runs a real babysitter and a helper with a SIGTERM-ignoring grandchild,SIGKILLs the babysitter, and checks that Orca kills both the helper and the grandchild. Instead of fixed sleeps, the test polls until Orca has proven the helper's identity, with a generous timeout. It also checks that a normal stop leaves nothing to clean up, and that the channel closes while the helper is still running (which is what the Linux inheritance fix depends on).New
provider-group-guard-launch-paths.test.tsstarts a real babysitter through every production launch path and checks that Orca is watching each one. This test failed against the old Codex session launcher.New
provider-process-row-read.test.tscovers parsing Linux/proc/<pid>/statand reading a live process the same way twice.New
provider-group-orphan-guard.test.tsunit tests cover: a same-second replacement (the ID points to a stranger once the start second ends, so Orca records nothing and kills nothing), Linux start times skipping the wait, the warn-once for a missing channel, group already gone, matching leader, a leader-less group being left alone, a reused process ID with a different start time or group, a failed lookup, a group this user can't signal, a reported process the babysitter no longer parents, a start in the lookup's own second being looked up again after that second ends (and never recorded if it stays ambiguous), a malformed report, and a launch with no channel.Updated the existing stdio assertions for the extra channel. The provider-process, OpenCode, text-generation, Codex backfill, ACP, and JSON-lines suites pass, including the existing babysitter integration tests.
pnpm tc:node, oxlint, andpnpm run check:code-quality:changedpass. I ran these on macOS only; Linux and Windows are covered by CI.AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
/procon Linux andpson macOS. When the babysitter exits, Orca makes onekill(-pgid, 0)check, and runs a second lookup only if the group is still alive.Known limits (each one fails safe, meaning Orca kills nothing):
psasynchronously once per babysat launch on macOS (Linux reads/procinstead), plus one re-read after the start second ends when the start time is ambiguous.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)