Skip to content

fix(crash-reporting): make the own-Chromium gate a real choke point, and stop a refusal leaking the root - #18459

Merged
nwparker merged 9 commits into
mainfrom
nwparker/main-process-tree-kill-choke-point
Sep 4, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/main-process-tree-kill-choke-point

Conversation

@nwparker

@nwparker nwparker commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​742 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​721
Prod 19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​264 $\color{#cf222e}{\Huge{\mathbf{−}}}$​100 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​164

Windows CI failure resolved on awin

Commit a205c896c55 fixes the live-test fixture; production code is unchanged. The fixture called its leaf detached but spawned it without detached: true. On Windows, root-handle termination can also reap that non-detached leaf through libuv job ownership. Immediate liveness checks could beat that cleanup and pass, while Windows CI observed the leaf already gone.

The leaf is now genuinely detached. Both refusal tests wait 250 ms after root exit before checking survival. A Node diagnostics-channel observer confirms the refused shared call spawns zero processes and the admitted call spawns the real taskkill; neither path is mocked.

Validation through Orca CLI on awin (Windows, Node 24.18.0, locked Vitest 4.1.11):

  • Direct root-handle probe: non-detached leaf dies; detached leaf survives, observed through 1.3 seconds after the kill.
  • Red/green: removing only detached: true from the strengthened test produces 2 failures / 2 passes; restoring it produces 4 passes.
  • Focused Windows suite: 129 passed, 2 platform skips across 10 files.
  • Fixed live suite repeated ten times: 40/40 tests passed.
  • macOS focused suite: 127 passed, 4 Windows skips. Node typecheck, lint, formatting and commit hooks pass.

This addresses CodeRabbit's descendant-survival CI comment without weakening the assertion or changing the production refusal path. The previous four-seat readiness review and blind peer ratings found no proven P0/P1 production regression. Its P2 scanner limitation and non-atomic PID admission risk remain disclosed below.

What

Follow-up to #18367, which merged without this work. #18367 merged at head 2d0c627ba08; the commit its body credited with closing all three round-3 blocking findings (9db1b4ce6ef) was committed 87 minutes after the merge and is not an ancestor of main. This PR ships that commit, rebased onto current main, plus the fixes for the three round-4 blocking findings. #18367's body has been corrected to describe only what it actually merged.

Two things, then.

1. Make the own-Chromium gate an actual choke point (9db1b4ce6ef, unchanged from its review except where round 4 required). #18367 shipped the gate wired into three families. Six more pid-addressed taskkill /pid <pid> /t /f families reachable from Electron main were ungated:

Site File
git-command-tree-kill src/main/git/command-runner/spawned-command-tree-kill.ts
notebook-cell-timeout src/main/ipc/notebook.ts
automation-precheck-timeout src/main/automations/precheck-runner.ts
codex-app-server-session-deadline src/main/codex/codex-app-server-session.ts
run-process-tree src/shared/child-process/process-tree-termination.ts
ephemeral-vm-recipe src/shared/ephemeral-vm-recipe-process.ts

The first three import admitSelfInitiatedTreeKill directly. The last three are compiled into the CLI and relay as well, so they reach the same guard through the process-tree-kill-gate seam (renamed from process-tree-kill-observer, notify/void → admit/boolean) that main installs at preflight; on every other host it admits unconditionally. src/main/main-process-tree-kill-gate.test.ts is the ratchet that keeps the set closed.

2. Round-4 fixes (8fc8aa22646), both of which are defects introduced by the round-3 remediation itself:

A refused kill no longer leaks the root it owns. Five of the six newly gated sites returned on refusal with no fallback, contradicting #18367's stated invariant that killRoot() still runs regardless. exec-file-capture.ts would resolve the abort/timeout while git.exe and its git-remote-https.exe descendants kept running against the repo; a timed-out notebook cell or automation precheck would be reported as stopped with its tree alive. All six now kill the root on the refusal path. The distinction that makes this safe: the gate refuses a pid-addressed tree walk, and the root kill is addressed by the child handle — uv_process_kill uses the Windows process HANDLE and is a no-op once Node has nulled _handle at exit — so it structurally cannot reach the recycled pid the refusal is about. The gate's doc comments now say "must not walk that pid's tree", not "must not kill", because the old wording is what five sites read.

The ring eviction no longer evicts the entry it just recorded. Round 3 replaced FIFO with a scope preference: evict the oldest non-pid-addressed kill first, so a window-close burst of group kills cannot drop the one entry that can explain a death. With the ring already saturated by pid-addressed kills the only non-pid-addressed element is the group kill just pushed at the tail, so splice removed it. That is reachable in an ordinary session — six routine families feed the ring win-taskkill-tree entries (pty-descendant-sweep on every Windows terminal close with an owned root, git-command-tree-kill on every aborted or timed-out git command, run-process-tree, codex-turn-added-roots, codex-rate-limit-probe, source-control-text-generation) and there is no age-based trimming. Eviction now excludes the newest entry and falls back to plain FIFO once every candidate is pid-addressed.

3. Round-6: the first Windows run (24330104f43, 376853aa526). Every earlier round disclosed that none of this had ever executed on Windows. It has now, on a real Windows 11 host (win32 x64, Node 24.18.0), and it found a defect no macOS run can see.

commit-message-text-generation-test-harness.ts branches on the real process.platform, and its win32 arm asserted expect(child.kill).not.toHaveBeenCalled() — precisely the contract 9bac44ee970 replaced when it stopped a refused tree kill leaking the commit-message agent. On macOS and Linux that arm is dead code, so the suite stayed green while the branch's own Windows behaviour was pinned to the old contract. On Windows it was nine failures across three files. The harness now asserts the handle-addressed root kill on every platform, waits for it (on win32 it lands after the tree walk, so a synchronous read is a tick early), and its ten call sites await it. Production code is unchanged by that commit.

Alongside it, src/main/windows-live-tree-kill.win32.test.ts runs the gate against real Windows process trees rather than a mocked taskkill, and is registered in the package_windows CI lane and WINDOWS_PACKAGE_TESTS as win32-test-lane-registration requires. It is the durable form of this round: the next change to the gate cannot repeat this.

Fix evidence

The three round-4 blocking findings

1. #18367 merged without 9db1b4ce6ef. Verified, not disputed:

$ gh pr view 18367 --json state,mergedAt,mergeCommit,headRefOid
MERGED / 2026-09-03T09:40:58Z / mergeCommit 7b530f1eb56 / headRefOid 2d0c627ba08

$ git log -1 --format='%h %cI' 9db1b4ce6ef
9db1b4ce6ef 2026-09-03T04:07:42-07:00      # 11:07 UTC, 87 min after the merge

$ git merge-base --is-ancestor 9db1b4ce6ef origin/main; echo $?
1                                          # NO

$ git cat-file -e origin/main:src/main/main-process-tree-kill-gate.test.ts
fatal: ... exists on disk, but not in 'origin/main'

$ git grep -l 'admitSelfInitiatedTreeKill\|admitProcessTreeKill' origin/main -- src
origin/main:src/main/claude-accounts/claude-login-process-termination.ts
origin/main:src/main/codex-accounts/service.ts
origin/main:src/main/crash-reporting/self-initiated-tree-kill-log.ts
origin/main:src/main/own-chromium-tree-kill-guard.test.ts
origin/main:src/main/own-chromium-tree-kill-guard.ts
origin/main:src/main/windows-process-tree-kill.ts

Zero occurrences in the six families above, and process-tree-kill-observer.ts (notify/void) is still what main carries. The merge was a squash of f05863afaf0..2d0c627ba08, so this branch is that squash's tail cherry-picked onto current main — it applied clean.

2. Refusal-path leak — red without the fix, at all six sites. src/main/refused-tree-kill-root-termination.test.ts drives each gated site with app.getAppMetrics() reporting the target pid, and asserts both that taskkill was never spawned and that the root was killed:

$ git stash push -- <the 6 production files>   # exports kept so the test still imports
$ ./node_modules/.bin/vitest run src/main/refused-tree-kill-root-termination.test.ts
 × kills the git command root when the tree walk is refused
 × kills the notebook cell root when the tree walk is refused
 × kills the automation precheck root when the tree walk is refused
 × kills the ephemeral-VM recipe root when the tree walk is refused
 × kills the codex app-server root when the deadline tree walk is refused
 × kills the runProcess root on both arms of the shared choke point
      Tests  6 failed (6)

$ git stash pop
      Tests  6 passed (6)

3. Ring self-eviction — red without the fix, using the reviewer's exact probe. 32 win-taskkill-tree/pty-descendant-sweep entries at goneAt−600s..−568s, then one win-pty-job/windows-pty-job-teardown at goneAt−50ms:

$ git checkout HEAD~1 -- src/main/crash-reporting/self-initiated-tree-kill-log.ts
$ ./node_modules/.bin/vitest run src/main/crash-reporting/self-initiated-tree-kill-log.test.ts
 × keeps the newest teardown when a session has saturated the ring with pid kills
AssertionError: expected undefined to be 1
      Tests  1 failed | 10 passed (11)

undefined is selfInitiatedGroupKillCount absent — the detail came back {}, byte-identical to the external-kill arm, which is the exact false clean round 3 blocked with the roles reversed. Both round-3's ordering (1 pid-addressed then 32 group) and round-4's (32 pid-addressed then 1 group) are now asserted, plus a third test pinning that a saturated all-pid ring evicts the oldest entry and not the newest.

Suites, typecheck, lint

$ ./node_modules/.bin/vitest run \
    src/main/refused-tree-kill-root-termination.test.ts \
    src/main/crash-reporting/self-initiated-tree-kill-log.test.ts \
    src/main/own-chromium-tree-kill-guard.test.ts \
    src/main/main-process-tree-kill-gate.test.ts \
    src/shared/child-process/process-tree-termination.test.ts \
    src/shared/child-process/child-process-import-boundary.test.ts \
    src/main/windows-pty-root-identity.test.ts \
    src/main/crash-reporting/process-gone-recorder.test.ts
 Test Files  8 passed (8)
      Tests  90 passed (90)

$ ./node_modules/.bin/vitest run src/main/ipc src/main/automations src/main/codex \
    src/main/git/command-runner src/shared/child-process
 Test Files  566 passed | 4 skipped (572)      # see "not proven" for the 1 environmental failure

$ ./node_modules/.bin/tsc -p config/tsconfig.node.json --noEmit    # exit 0
$ ./node_modules/.bin/tsc -p config/tsconfig.tc.cli.json --noEmit  # exit 0
$ ./node_modules/.bin/tsc -p config/tsconfig.tc.web.json --noEmit  # exit 0
$ ./node_modules/.bin/oxlint src                                   # exit 0

No max-lines suppression was added anywhere.

On a real Windows host

awin, Windows 11, win32 x64, Node 24.18.0, at pushed HEAD 376853aa526:

$ node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts \
    src/main/windows-live-tree-kill.win32.test.ts \
    src/main/refused-tree-kill-root-termination.test.ts \
    src/main/crash-reporting src/main/own-chromium-tree-kill-guard.test.ts \
    src/main/main-process-tree-kill-gate.test.ts src/shared/child-process \
    src/main/windows-pty-root-identity.test.ts src/main/text-generation \
    config/scripts/win32-test-lane-registration.test.mjs
 Test Files  1 failed | 55 passed (56)
      Tests  2 failed | 583 passed | 4 skipped (589)

The four live cases, against real detached process trees:

 ✓ admitted: taskkill reaps the root and its detached grandchild, and the kill is recorded
 ✓ refused: the tree survives, nothing is recorded, and the handle kill still reaps the root
 ✓ signalProcessTree refused: the root goes by handle and the barrier reports unverified
 ✓ signalProcessTree admitted: the whole tree goes and the barrier reports verified

The two remaining failures are pre-existing and not this branch's, proven on the same host:

$ git checkout origin/main -- src config
$ node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts \
    src/main/text-generation/commit-message-text-generation-model-discovery.test.ts
 FAIL  discovers dynamic models through the agent CLI
 FAIL  writes the Claude list_models request to stdin and parses the control response
      Tests  2 failed | 14 passed (16)

Both are argv/PATH-resolution expectations written for POSIX (cursor-agent vs its resolved absolute path). They fail identically at origin/main.

The regression this round fixed was, before the fix, eleven failures on that host and nine attributable to this branch; reverting only source-control-local-process.ts to origin/main dropped it to the same two.

Explicitly NOT proven

  • No packaged Orca on Windows. The Windows run above is vitest against a real Windows 11 host, including real process trees and a real taskkill /T /F. It is not a packaged app, so the gate has still never refused a kill aimed at a genuine Chromium pid in a running Orca — the getAppMetrics() set is stubbed in every case. Rebuilding native deps failed on that host (node-gyp), so nothing needing node-pty or windows-process-tree ran there either.
  • git-admission-storm-measurement.test.ts fails on this machine, at this HEAD and with every change on this branch stashed, with ENOENT: scandir '/var/folders/.../orca-git-storm-disabled-*/state' after a 5s timeout. Environmental, pre-existing, and independently reproduced at merge-base by the reviewer. refused-manual-run.test.ts and gh-spawn-boundary.test.ts fail only under parallel load and pass in isolation.
  • app.getAppMetrics() cost per force-kill on Windows. Measured on macOS only: 268 µs/call in Electron 43.4.1 with 6 metrics entries (3 hidden windows, 2000 warm calls; harness in the de-risk report). It is a synchronous call in main, so a Windows PTY close pays two of them (~0.5 ms); the Windows number itself is still unmeasured. After the de-risk commit the read no longer runs on macOS/Linux at all — see Trade-off 2.
  • That any of the 20 G2 field reports was Orca's doing. Unchanged from fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367: this creates the field that would answer it.

ELI5

Orca constantly starts little helper programs in the background on your behalf — running a check, fetching from a server, running a notebook cell, writing a commit message. When one of those hangs, times out, or you cancel it, Orca has to shut it down, and it has to shut down anything that helper itself started, or you get invisible leftovers chewing up your machine.

On Windows, Orca shuts those helpers down by their number. The problem is that Windows recycles numbers. So there is a real chance that the number Orca is about to reach for has quietly been handed to one of Orca's own windows — and Orca ends up shutting itself down. To you that looks like Orca crashing for no reason, with nothing in the report to say why.

So Orca learned to ask one question first: "wait, is that number one of mine?" If it is, back off. That question already existed, but it had only been wired into three of the nine places where Orca shuts a helper down. This change wires it into the rest, and adds an automatic check so that nobody can add a tenth place in future without wiring it in too.

Two things about backing off also needed fixing:

Backing off was doing too much. At most of those places, backing off meant doing nothing at all — so Orca would tell you the helper was stopped while it was actually still running in the background. In one case it also let go of a lock that other work was queued behind, so that work could start while the old helper was still going. The right behaviour is narrower. Orca should refuse to do the sweep ("that number, and everything underneath it, whatever that turns out to be"), but should still shut down the one program it is personally holding onto — that part can't hit the wrong thing, because Orca is holding it directly rather than looking it up by number. That's what it does now. The honest cost: anything that helper had itself started is left running instead of being cleaned up. That's a leftover, but a much smaller one than before, and much safer than the alternative.

Orca's notes about what it did were getting thrown away. Orca keeps a short list of the last 32 things it shut down, so that if it crashes moments later the report can say "actually, that was me". Closing a window can produce thirty entries at once, which would push the one useful entry off the end of the list. The list now keeps the entries that could actually explain a crash instead of blindly dropping the oldest one — including, importantly, the one written a split second ago.

Finally: none of this had ever actually been run on Windows, which is the only place any of it matters. It has now, on a real Windows machine, and that run immediately caught a mistake that was impossible to see on a Mac. Windows is now part of the automatic checks for this code, so the next change can't skip it.

Merge Risk

LOW. Both fixes make refused or evicted paths more conservative, and both are pinned by tests that are red without them.

  • The gate wiring in commit 1 is fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367's own reviewed work, cherry-picked with no conflicts.
  • The refusal fallback can only add a child.kill() on a path that previously did nothing. It cannot reach a Chromium process: the call is handle-addressed, and after exit Node has nulled _handle and it is a no-op.
  • signalProcessTree's two refusal arms now mirror the reaped-pid skip immediately above them exactly — killRoot(child, signal) then resolve false — so the termination barrier's meaning is unchanged.
  • Three module-private functions (terminateNotebookProcessTree, killLocalPrecheckProcessTree, killRecipeProcess) are exported so the refusal path is reachable from a test; each carries a one-line comment saying so. No call sites changed.
  • P2, not fixed here — the ratchet is call-site granular but not a call-graph check: main-process-tree-kill-gate.test.ts requires, per file, that gate admissions be at least the number of /pid call sites (ungatedKillSiteCount), keyed on the /pid argument rather than the program name so a taskkill spawned through a constant or variable is still counted. Two blind spots remain, both stated in the test's own header and unit-tested where testable: a file that pairs an ungated kill with a second admission of an already gated one, and a kill whose /pid argument is itself built from a variable. Resolving each site to its enclosing function (Follow-up 1) is what closes the first. Four sites sit on a shrink-only allowlist, each with a stated reason: the two browser-route Electron probes in src/main (reached only from *.electron.test.ts, and they kill the probe Electron they spawned), plus src/cli/handlers/interactive-login-interruption.ts and src/relay/subprocess-tree-termination.ts, which run on hosts with no Orca Chromium pid to reach and no reader for the ring.
  • P2, not fixed here — selfInitiatedTreeKillCount has a routine base rate. Every aborted or timed-out git command on Windows emits win-taskkill-tree, and killSpawnedCommandTree has 14 call sites. The selfInitiatedKills site string separates them; the count alone does not. fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367's body claimed both "this is the discriminating field" and, in Merge Risk, that "the count alone is not the clean discriminator the body describes" — the corrected body keeps only the second.
  • P2, not fixed here — app.getAppMetrics() is still read twice per Windows PTY close (windows-pty-root-identity.ts:150 default arg, then again inside terminateWindowsProcessTree).

Trade-offs

  1. The refusal fallback is a deliberate asymmetry. A refused site kills its root but not its tree, so descendants of a refused target are orphaned rather than reaped. That is strictly better than today's two options — leaking the whole tree (the bug) or running a pid-addressed sweep against a pid we just decided is suspect (the thing the gate exists to stop) — but it is not "nothing was leaked". codex-accounts/service.ts already had exactly this shape and is unchanged.

    One gated site has no handle to fall back to: codex-turn-added-roots (codex-structured-turn-processes.ts). The roots it kills are found by a process-table walk during turn cancellation, not spawned by Orca, so on a refusal nothing is killed and that subtree survives until the app-server exits. This is disclosed rather than fixed, deliberately: the only pid-addressed alternative is the walk the gate just refused. It is not silent — the self_tree_kill_refused_own_chromium crumb is written with site: 'codex-turn-added-roots' and the refused row stays in the post-kill remaining set, so terminateCodexTurnProcesses resolves false and the user sees cancelled: false for the turn. refused-tree-kill-root-termination.test.ts pins both. This was undisclosed before the de-risk pass.

  2. admitProcessTreeKill runs on the POSIX arm too, but main's gate never refuses it. signalProcessTree asks before process.kill(-pid), which on main was a record-only observer. An earlier revision of this PR let the own-Chromium check refuse that arm as well — new behaviour on macOS/Linux, where a stale getAppMetrics() entry plus pid reuse would have orphaned a whole process group that main reaps today. The de-risk commit scopes the refusal to win-taskkill-tree: a POSIX group can only contain processes Orca put there, so the arm is recorded and admitted exactly like the other three POSIX group kills in main (claude-login, codex teardown, PTY sweep). Because the scope check short-circuits, the synchronous getAppMetrics() read no longer happens on any macOS/Linux termination — the cost is Windows-only again, as fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367's Trade-off 2 originally framed it. The seam's POSIX refusal arm stays in process-tree-termination.ts as the contract for any future gate, with a test pinning that the installed one does not exercise it.

  3. Eviction is preference-ordered, not age-aware. A kill more than 5s old can never explain a later death, so the ring still carries dead weight; the reader filters by window, so this costs memory (32 small objects) rather than correctness. Age-based trimming was the other option the review offered and is the better long-term shape, but it changes what the ring holds rather than only which entry it drops, so it is deliberately not in a remediation PR.

  4. selfInitiatedTreeKillCount = 0 still does not mean "not us". Unchanged from fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367's Trade-off 4 and the module doc: the ring is per-process and only Electron main reads it, so daemon, relay and CLI kills record where nothing reads them. What remains uninstrumented after this PR is only the POSIX process.kill(-pid, …) group arms of the notebook, precheck, browser-route and ephemeral-VM kills, the relay's and CLI's own taskkills, and the browser-route Electron probes reached solely from *.electron.test.ts.

  5. The module doc's coalescing claim was wrong and is corrected. It said "the newest pid still rides the emitted crumb" without qualification. True of the retained in-memory ring entry (recordCoalescedCrashBreadcrumb stashes pending), false of the NDJSON/span trail the same doc calls the thing that survives into the diagnostic bundle — traceDurableBreadcrumb only fires on the first event of a coalesce window, so a same-site burst emits the first pid. fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367 disclosed this in its body; the shipped comment did not. It does now.

  6. No remote wire change, no host-boundary change. process-tree-kill-gate.ts has zero imports, so the CLI, relay and daemon bundles do not pull main-process code through it. The three new crash-report detail keys are additive optional fields in an existing bag that sanitizeCrashReportDetails passes through uncapped, so no capability negotiation is needed and an older client reading a newer bundle ignores them. installMainProcessTreeKillGate() runs before setAppEnvironment in preflight, which is safe because readOrcaChromiumProcessPids() reads hasAppEnvironment() lazily.

Adversarial review

5 round(s). Rounds 1-3 are recorded in #18367. Round 4 reviewed the merged artifact against the merged body and blocked on three findings; all three are closed here. Round 5 blocked on four; see below.

  • "PR fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367 is already merged, and it was merged one commit before the content its body claims as shipped." FIXED. Verified independently (transcript above): 9db1b4ce6ef postdates the merge by 87 minutes and is not an ancestor of origin/main; the ratchet file is absent there and all six families contain zero references to the gate. fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367's body now carries a correction banner, its "What" section no longer claims the six families or the ratchet, and its three round-3 "FIXED in 9db1b4c" entries and two "Done in 9db1b4c" follow-ups now point here instead. This PR ships the content.
  • "The round-3 eviction fix introduces a new false clean that is strictly worse than what shipped." FIXED, exactly as reported — the scope-preference splice removed the entry it had just pushed whenever the ring was saturated with pid-addressed kills, returning {} in the window-close scenario the 20 G2 reports come from, where main's plain FIFO returned the group count plus the pid. Eviction now never considers the newest entry and degrades to FIFO. The reviewer's ordering is a test; so is round 3's, so is the all-pid case.
  • "Five of the six newly gated sites return on refusal with no direct-child fallback, contradicting the PR's own invariant." FIXED at all six (the review named five; signalProcessTree's POSIX arm was the sixth). The review read claude-login-process-termination.ts as proof the omission was inconsistency rather than design, and that is right in effect though not in mechanism: claude-login's fallback is legitimate because its refused pid is a relayed login pid that may differ from child.pid, so child.kill() there targets a different process. At the other six the refused pid is child.pid — which is precisely why the handle-addressed kill is the correct fallback, and why the gate's contract wording needed fixing too.
  • Non-blocking taken: the coalescing claim in the module doc (Trade-off 5); real refusal tests for the four gates that were asserted only by string containment.
  • Non-blocking not taken, disclosed instead: the ratchet's string-containment weakness and its 'taskkill'/'/pid' literal pattern (Merge Risk); the double getAppMetrics() per PTY close (Merge Risk); age-aware eviction (Trade-off 3). The review's own positive verification — 17 tests red at merge-base 76836b30ea6, green at HEAD, tsc ×3 and oxlint clean, 524-file sweep with only pre-existing failures — is not restated here.

Round 5

  • "Round-3 blocking findings 1-3 are NOT closed in the shipped artifact; origin/main still lacks the ratchet and the gate seam, still ships the coverage doc that misdescribes four Windows pid-addressed taskkills as POSIX group kills, and still evicts plain-FIFO." ACCURATE, and this PR is the fix. Both are on this branch already (8598511a2fe corrects the coverage doc; 8fc8aa22646 makes eviction scope-aware). fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367 is merged and immutable, so the only vehicle is this PR — which is why it exists. Nothing further to do here beyond landing it.
  • "NOVEL: killSourceControlAgentProcess has no root-kill fallback on its win32 arm, so a gate refusal resolves having killed nothing while markProcessClosed releases the managed-home lock." FIXED (9bac44ee970). Confirmed exactly as reported: terminateWindowsProcessTree was the only termination on that arm, and both callers (source-control-local-process.ts, commit-message-model-discovery.ts) release the lock on the promise it returns. It is the seventh instance of the class 8fc8aa22646 fixed at six sites; it was missed because it reaches the taskkill through terminateWindowsProcessTree rather than spawning its own. refused-tree-kill-root-termination.test.ts now asserts the root kill at all seven sites; the new case is red against the old arm (expected "vi.fn()" to be called with arguments: [ 'SIGKILL' ]).
  • "The ratchet is file-granular, not call-site granular, so it does not support the guarantee stated in the shipped comments." FIXED (9bac44ee970), taking the follow-up below early rather than softening the comments. The scan now counts /pid call sites against gate admissions per file (ungatedKillSiteCount), so the reviewer's own probe — a second ungated taskkill /pid /t /f appended to windows-process-tree-kill.ts — now fails the suite. Keying on the /pid argument rather than a quoted 'taskkill' also closes the constant/variable program-name hole the review flagged in the same finding; both shapes are unit-tested. The three comments that claimed more than the old scan enforced now state the rule and its two remaining blind spots (a file that pairs an ungated kill with a second admission of an already gated one, and a /pid argument itself built from a variable).
  • "The branch as checked out (HEAD 9db1b4ce6ef) carries two defects that fix(crash-reporting): make the own-Chromium gate a real choke point, and stop a refusal leaking the root #18459 fixes, so this branch must not be merged." AGREED, and moot. That is nwparker/crash-self-tree-kill-breadcrumb, whose PR (fix(crash-reporting): record Orca-initiated tree kills so a killed renderer is decidable #18367) is already merged; the branch is stale and nothing will be merged from it. Both defects are fixed here, which the review states.
  • Non-blocking taken: the exception-safety asymmetry (admitSelfInitiatedTreeKill now wraps recording the way the admitProcessTreeKill seam already did, with the refusal decision taken before anything that can throw so a diagnostics failure cannot flip it); the guard's false-positive direction is now documented in orca-chromium-process-pids.ts, since a stale getAppMetrics() entry plus pid reuse is the mechanism the root-kill fallback exists to bound.
  • Non-blocking not taken, disclosed instead: recording before the kill rather than after (Trade-offs); the coalesced-burst span trail, already corrected in 8fc8aa22646; no Windows run at HEAD (Follow-up 3).

Round 6

Five findings carried in, each re-verified against this branch rather than #18367.

  1. "The own-Chromium guard is not a choke point: on shipped main it is wired into only 3 of 9 pid-addressed taskkill /pid X /t /f families." FIXED here, accurate about main. git grep -n "'/pid'" origin/main finds 3 gated of 9 in src/main; on this branch 7 of 9 are gated and the remaining 2 are the browser-route Electron probes, allowlisted with a stated reason. The ratchet is falsifiable: appending a bare ['/pid', String(pid), '/t', '/f'] to windows-process-tree-kill.ts fails main-process-tree-kill-gate.test.ts with that file named.
  2. "The module doc misdescribes what it misses — it calls the process.kill(-pid) calls in browser routes, notebooks, prechecks and ephemeral-VM recipes 'never instrumented', but on Windows all four route elsewhere." FIXED, and completed further. The doc already scoped that bullet to the POSIX group arms on this branch, which is true — all four take the gated taskkill path on win32. Re-verifying it exhaustively turned up one omission the finding did not name: readCommandStdout in src/main/ipc/app.ts issues an uninstrumented process.kill(-pid, 'SIGKILL') from Electron main (the macOS keyboard-input-source probe). It is now in the list.
  3. "The 32-slot FIFO ring can evict the single entry that discriminates self-kill from external kill." FIXED, red without the fix at the branch tip. Removing only the index < lastCandidate floor from evictOneSelfInitiatedTreeKill reproduces the reviewer's probe exactly: expected undefined to be 1 for selfInitiatedGroupKillCount, detail {}, byte-identical to the external-kill arm.
  4. "The refusal silently leaks the Windows commit-message agent's process tree: source-control-local-process.ts:33 has no child.kill() fallback." FIXED, red without the fix. Restoring the win32 return after terminateWindowsProcessTree fails refused-tree-kill-root-termination.test.ts with expected "vi.fn()" to be called with arguments: [ 'SIGKILL' ], calls 0. The Windows run then showed the fix was only half-landed: the harness that covers this code path still asserted the old contract on its win32 arm. See finding 5.
  5. "None of the shipped code has ever executed on Windows." FIXED, and it was the finding that paid. Full transcript above. It found nine real Windows-only failures at the branch tip, all traceable to finding 4's own fix being contradicted by a platform-branching test harness — the exact class of defect a macOS-only suite cannot report. Windows coverage is now permanent: windows-live-tree-kill.win32.test.ts in the package_windows lane.

Follow-ups

Carried forward from #18367, unchanged: benchmark app.getAppMetrics() on the force-kill path; close the non-Chromium half of #10680 (a recycle onto another Orca descendant still classifies own); make the daemon and relay breadcrumb rings readable; re-file the G2 cluster into its four fingerprints; rewrite crashAttribution when a pid-addressed kill matches the dead renderer.

New from this round:

  1. Make the ratchet a call-graph check. Round 5 took the counting half of this: the scan is now call-site granular rather than file granular. Still open is resolving each site to its enclosing function and requiring the gate on every path that reaches it, which is what closes the last blind spot (an ungated kill paired with a second admission of an already gated one in the same file).
  2. Age-trim the self-kill ring. Drop entries older than SELF_TREE_KILL_LOOKBACK_MS + SELF_TREE_KILL_LOOKAHEAD_MS behind the newest, so the ring holds only entries that could still explain a death and eviction preference stops mattering.
  3. Run the Windows arms at HEAD. Done in round 6 — see "On a real Windows host". What is still open is running them against a packaged Orca, where getAppMetrics() returns genuine Chromium pids rather than a stub, and rebuilding native deps on that host so the node-pty and windows-process-tree arms can run there too.

Round-3 review found the guard was not the choke point its own comments
claimed: six pid-addressed `taskkill /pid <pid> /t /f` families in main were
ungated and uninstrumented, so the stale-pid shape stayed producible and a
`selfInitiatedTreeKillCount: 0` could read as exculpatory when it was not.

- Gate the remaining main-process families: the git command-runner abort, the
  notebook-cell and automation-precheck timeouts.
- Turn the `src/shared` seam into the gate itself (`process-tree-kill-gate`), so
  the runProcess choke point, the codex app-server deadline kill and the
  ephemeral-VM recipe kill ask the same decision. Those three are compiled into
  the CLI/relay too and cannot import main; main installs the guard at preflight.
- Ratchet (`main-process-tree-kill-gate.test.ts`): a new pid-addressed taskkill
  in main that skips the gate fails, and the allowlist entries must still exist.
- Give pid-addressed kills eviction priority in the 32-entry ring: 32 routine
  `win-pty-job` teardowns from a window-close burst no longer evict the one
  entry that discriminates a self-kill from an external one.
- Correct the coverage doc, which described the uninstrumented Windows sites as
  POSIX `process.kill(-pid)` group kills and omitted the git and codex paths.
…it owns

A refusal must block the pid-addressed tree walk, not the termination. Five of
the six gated sites returned on refusal with no fallback, so a refused
`taskkill /pid /t /f` left git.exe, a timed-out notebook cell, an automation
precheck or an ephemeral-VM recipe running while the caller reported it stopped.
The root kill is addressed by the child handle, which cannot reach the recycled
pid the refusal is about, so it stays correct and required on that path.

Also fixes the ring eviction the scope preference introduced: with the ring
saturated by pid-addressed kills, the only non-pid-addressed entry is the one
just pushed, so the splice evicted itself and the detail came back `{}` --
byte-identical to the external-kill arm, in the window-close case the guard
exists for. Eviction now excludes the newest entry and falls back to FIFO.

Tests: refusal now asserts the root kill at all six sites, and the ring covers
the saturated-pid ordering as well as round 3's group-burst ordering.
@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: f6b099e0-e670-462e-be20-7d70746e44a8

📥 Commits

Reviewing files that changed from the base of the PR and between 376853a and b460160.

📒 Files selected for processing (1)
  • src/main/windows-live-tree-kill.win32.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared process-tree kill admission gate. Main-process callers install the own-Chromium guard and check admission before Windows taskkill walks or POSIX process-group signaling. Refused operations terminate only the owned root process. Crash reporting records kills through the gate and preferentially evicts routine group or job entries. Tests cover gate wiring, source coverage, ring eviction, Windows integration, root-process fallback behavior, asynchronous termination, and Windows test routing.

Merge Risk: 🟡 Moderate · up to b4601

The change gates process-tree termination to protect owned Chromium processes, but an unbound PID-admission window could still target a recycled PID and the Windows refusal fallback may terminate descendants that should survive. These behaviors should be resolved before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.89% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 24 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: making the own-Chromium gate a choke point and preventing refusal paths from leaking the owned root process.
Description check ✅ Passed The description is substantially complete and on topic. It explains the change, motivation, risks, testing, platform coverage, known limitations, linked issues, and follow-ups. It does not reproduce e…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: aef36fc2-c01f-447c-9717-fa89eefe3358

📥 Commits

Reviewing files that changed from the base of the PR and between 67e2234 and 8fc8aa2.

📒 Files selected for processing (17)
  • src/main/automations/precheck-runner.ts
  • src/main/codex/codex-app-server-session.ts
  • src/main/crash-reporting/self-initiated-tree-kill-log.test.ts
  • src/main/crash-reporting/self-initiated-tree-kill-log.ts
  • src/main/git/command-runner/spawned-command-tree-kill.ts
  • src/main/ipc/notebook.ts
  • src/main/main-process-tree-kill-gate.test.ts
  • src/main/own-chromium-tree-kill-guard.test.ts
  • src/main/own-chromium-tree-kill-guard.ts
  • src/main/refused-tree-kill-root-termination.test.ts
  • src/main/startup/main-process-preflight.ts
  • src/main/windows-process-tree-kill.ts
  • src/shared/child-process/process-tree-kill-gate.ts
  • src/shared/child-process/process-tree-kill-observer.ts
  • src/shared/child-process/process-tree-termination.test.ts
  • src/shared/child-process/process-tree-termination.ts
  • src/shared/ephemeral-vm-recipe-process.ts
💤 Files with no reviewable changes (1)
  • src/shared/child-process/process-tree-kill-observer.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

…sage agent, and count call sites

Two round-5 blocking findings, both open on main and on both branches.

`killSourceControlAgentProcess` had no root-kill fallback on its win32 arm: the
taskkill was the only termination, so once the own-Chromium gate could refuse it
the promise resolved having killed nothing. Both callers do
`terminationComplete ??= killSourceControlAgentProcess(child)` and then release
the managed-home lock on that promise, so a refusal left the local Codex/Claude
commit-message agent running while the caller reported it stopped -- the
lock-contention failure the taskkill was added for. Same fix as the six sibling
sites: the handle-addressed root kill cannot reach the recycled pid the refusal
is about, so it stays correct and required on that path.

The ratchet was file-granular, not call-site granular: one gate mention anywhere
in a file exempted every taskkill in it, which left the six files that now ask
the gate ratchet-blind -- the inverse of what it is for. It now counts `/pid`
call sites against gate admissions per file, so a second ungated kill inside an
existing family fails. Keying on the `/pid` argument rather than a quoted
`taskkill` also catches a kill whose program name comes from a constant. The
three comments that claimed more than the old scan enforced now state the rule
and its two remaining blind spots.

Also: the recording in `admitSelfInitiatedTreeKill` is now wrapped the way the
`admitProcessTreeKill` seam already wraps it, with the refusal decision taken
before anything that can throw so a diagnostics failure cannot flip it; and
`orca-chromium-process-pids` documents the false-positive direction (a stale
`getAppMetrics()` entry plus pid reuse refuses a live unrelated child), which is
the mechanism the root-kill fallback exists to bound.

Tests: refusal now asserts the root kill at all seven sites; the ratchet asserts
call-site counting and the constant-program form.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 0652ef50-06be-4323-ab3f-7ad7ce8f6a0e

📥 Commits

Reviewing files that changed from the base of the PR and between 8fc8aa2 and 9bac44e.

📒 Files selected for processing (6)
  • src/main/crash-reporting/self-initiated-tree-kill-log.ts
  • src/main/main-process-tree-kill-gate.test.ts
  • src/main/orca-chromium-process-pids.ts
  • src/main/own-chromium-tree-kill-guard.ts
  • src/main/refused-tree-kill-root-termination.test.ts
  • src/main/text-generation/source-control-local-process.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/main-process-tree-kill-gate.test.ts
  • src/main/crash-reporting/self-initiated-tree-kill-log.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.

if (readOrcaChromiumProcessPids().has(target.pid)) {
recordRefusedOwnChromiumTreeKill(target)
return false
const isOwnChromiumPid = readOrcaChromiumProcessPids().has(target.pid)

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.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 21303


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- target file ---'
cat -n src/main/own-chromium-tree-kill-guard.ts
printf '%s\n' '--- directly bound symbols and callers ---'
rg -n -C 4 \
  'readOrcaChromiumProcessPids|terminateWindowsProcessTree|own-chromium-tree-kill-guard|taskkill|target\.pid|isOwnChromiumPid' \
  src package.json
printf '%s\n' '--- relevant platform/process declarations ---'
rg -n -C 5 \
  'function (readOrcaChromiumProcessPids|terminateWindowsProcessTree)|const (readOrcaChromiumProcessPids|terminateWindowsProcessTree)|export .*readOrcaChromiumProcessPids|export .*terminateWindowsProcessTree|exec(File|Sync)|spawn(Sync)?|CreateToolhelp32Snapshot|OpenProcess|creation.?time|GetProcess' \
  src

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- target file ---'
cat -n src/main/own-chromium-tree-kill-guard.ts
printf '%s\n' '--- symbol definitions and uses in src/main ---'
rg -n -C 8 \
  'readOrcaChromiumProcessPids|terminateWindowsProcessTree|isOwnChromiumPid|taskkill|target\.pid' \
  src/main
printf '%s\n' '--- candidate files ---'
rg --files src/main | rg 'chromium|kill|process|pty'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- files defining the relevant operations ---'
rg -l \
  'terminateWindowsProcessTree|readOrcaChromiumProcessPids' \
  src/main \
  | sort -u
printf '%s\n' '--- Windows termination definitions ---'
rg -n -B 12 -A 45 \
  '^(export )?(async )?function terminateWindowsProcessTree|^(export )?const terminateWindowsProcessTree|terminateWindowsProcessTree\s*=' \
  src/main
printf '%s\n' '--- Chromium PID implementation ---'
rg -n -B 8 -A 80 \
  '^(export )?(function|const) readOrcaChromiumProcessPids|readOrcaChromiumProcessPids\s*=' \
  src/main/orca-chromium-process-pids.ts

Repository: stablyai/orca

Length of output: 5132


Bind admission to process identity, not only the PID value.

admitSelfInitiatedTreeKill checks readOrcaChromiumProcessPids() once, then terminateWindowsProcessTree passes the PID to asynchronous taskkill. If Windows reuses the PID for Chromium before taskkill runs, taskkill /T /F can terminate that Chromium process. Use a process handle, creation-time identity, or equivalent revalidation.

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

✅ No new issues found.

Reviewed changes

  • Own-Chromium gate extended to six more families. git-command-tree-kill, notebook-cell-timeout, and automation-precheck-timeout gate via a direct admitSelfInitiatedTreeKill; codex-app-server-session-deadline, run-process-tree, and ephemeral-vm-recipe gate via the renamed admitProcessTreeKill seam (the deleted process-tree-kill-observer.ts / notifyProcessTreeKill void path).
  • A refused kill no longer leaks the root it owns. All six refusal arms now fall back to a handle-addressed child.kill(), which — via uv_process_kill using the Windows process HANDLE, a no-op once _handle is nulled at exit — structurally cannot reach the recycled pid the refusal is about.
  • Ring eviction no longer self-evicts. evictOneSelfInitiatedTreeKill excludes the just-recorded entry (index < lastCandidate) and degrades to plain FIFO once every candidate is pid-addressed.
  • Choke-point ratchet. main-process-tree-kill-gate.test.ts string-scans src/main/src/shared/src/cli/src/relay for pid-addressed taskkill and requires the gate, backed by a shrinking allowlist and real refusal tests for the four previously textual-only gates.

I verified the eviction logic against the three new ring tests (pid-addressed survives a group burst, newest teardown survives a pid-saturated ring, all-pid ring evicts oldest not newest), confirmed the handle-addressed-kill safety claim against libuv/Node child.kill() semantics, and checked the allowlist entries — the two browser-route probe launchers are genuinely reachable only from *.electron.test.ts fixtures, and the CLI/relay entries run on hosts with no Chromium pids to protect. The disclosed trade-offs (ratchet is string-contain not call-graph, getAppMetrics() now also on the POSIX arm, refusal orphaning descendants, no age-based trimming) are accurately documented in the body and appropriately scoped as follow-ups rather than defects.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at 8fc8aa2)

  • Ratchet is now call-site granular. main-process-tree-kill-gate.test.ts counts /pid kill sites against gate admissions per file (ungatedKillSiteCount), keyed on the /pid argument literal rather than a quoted program name, so a second ungated taskkill in an already-gated file is caught and a taskkill spawned through a constant/variable is seen. Two new unit cases pin both shapes.
  • Seventh refusal fallback. killSourceControlAgentProcess now awaits the gated terminateWindowsProcessTree on win32 and then falls through to a handle-addressed child.kill('SIGKILL'), so a refused tree walk no longer resolves having killed nothing and leaking the managed-home lock. refused-tree-kill-root-termination.test.ts adds the matching case (red against the old arm) plus the execFileMock wiring.
  • Exception-safety on the guard. admitSelfInitiatedTreeKill takes the refusal decision (isOwnChromiumPid) before anything that can throw, wraps only the recording calls in a try/catch, and returns !isOwnChromiumPid, so a diagnostics failure can no longer flip or propagate into a termination.
  • Doc corrections. orca-chromium-process-pids.ts and the guard/module comments now state the false-positive direction of getAppMetrics() and the two remaining ratchet blind spots.

I re-verified the counting against every production /pid site: all eight main-process families show sites == admissions, the three allowlisted main/shared/cli/relay entries still legitimately lack the gate, and the two shared seam files (process-tree-termination.ts, ephemeral-vm-recipe-process.ts) balance via admitProcessTreeKill. The win32 fall-through (taskkill then child.kill('SIGKILL')) is a no-op on the already-reaped root and the correct root kill on refusal; the two disclosed blind spots (an ungated kill paired with a second admission of an already-gated one, and a /pid argument built from a variable) are accurately documented rather than hand-waved.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

… trees

Nothing on this branch had ever executed on Windows. The unit tests pin the
gate's decision against a mocked taskkill, which cannot show that the decision
does anything to a real process: that `/T /F` reaps a detached grandchild, that
a refusal leaves that tree standing, or that the handle-addressed root kill the
refusal path falls back to reaps the root while orphaning descendants.

Adds a win32-gated live test covering all four, registered in both the
`package_windows` CI lane and `WINDOWS_PACKAGE_TESTS` as
`win32-test-lane-registration` requires.

Also completes the coverage doc's "never instrumented" list, which omitted the
macOS keyboard-input-source probe's POSIX group kill in `ipc/app.ts`.

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: adaa23a5-dd56-4239-a5b4-ac97d44a9504

📥 Commits

Reviewing files that changed from the base of the PR and between 9bac44e and 2433010.

📒 Files selected for processing (4)
  • .github/workflows/pr.yml
  • config/scripts/pr-code-change-scope.mjs
  • src/main/crash-reporting/self-initiated-tree-kill-log.ts
  • src/main/windows-live-tree-kill.win32.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/crash-reporting/self-initiated-tree-kill-log.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

const { child, rootPid, leafPid } = await spawnLiveTree()
orcaChromiumPids = [rootPid]

await expect(signalProcessTree(child, 'SIGKILL')).resolves.toBe(false)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve descendant survival after a refused signalProcessTree call.

The Windows job fails at Line 161 because leafPid is dead after this call resolves false. A refusal must terminate only the owned root handle. It must not run a PID-addressed tree kill after refusal. Fix the refused signalProcessTree path instead of weakening the descendant-survival assertion.

Source: Pipeline failures

… arm

The first Windows run of this branch found nine failures the macOS suite
cannot see: `commit-message-text-generation-test-harness` asserts
`expect(child.kill).not.toHaveBeenCalled()` on `process.platform === 'win32'`,
which is the contract the previous commit deliberately replaced — and it
branches on the real platform, so it is dead code everywhere CI runs today.

The harness now asserts the handle-addressed root kill on every platform. On
win32 it lands after the tree walk, so the expectation waits rather than reading
one tick early, and its ten call sites await it. Red against the pre-fix arm at
all seven sites; the production code is unchanged.

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

Important

The new Windows-lane spec uses a raw recursive rmSync, which fails the repo's own windows-lane-tree-removal-boundary.test.ts ratchet (reproduced locally) and will fail CI — see the inline comment.

Reviewed changes (delta since the prior pullfrog review at 9bac44e)

  • Added a live Windows process-tree test. windows-live-tree-kill.win32.test.ts spawns a real node root whose grandchild writes its pid to disk, then pins the admitted/refused arms of both terminateWindowsProcessTree and signalProcessTree against a real taskkill — including the recorded-kill assertion on the admitted path and the orphaned-descendant asymmetry on the refusal path.
  • Registered the spec in both Windows-lane lists. The workflow's Test Windows-specific boundaries argv and WINDOWS_PACKAGE_TESTS in pr-code-change-scope.mjs, so the win32-test-lane-registration ratchet stays satisfied.
  • Corrected the coverage doc. self-initiated-tree-kill-log.ts now lists the macOS keyboard-input-source probe's process.kill(-pid) group kill in ipc/app.ts under the "never instrumented" arm.

ℹ️ Nitpicks

  • The new test's comments (:21-24, :73) call the grandchild "detached", but neither the root ({ stdio: 'ignore', windowsHide: true }) nor the leaf ({ stdio: 'ignore' }) is spawned with detached: true. It is a plain grandchild. The mechanism the test pins (taskkill /T /F walking the parent-child tree) is unaffected, but the wording overstates the setup.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

Reviewed changes (delta since the prior pullfrog review at 2433010)

  • Fixed the commit-message harness's win32 arm. createChildTerminationExpectation no longer asserts child.kill was not called on win32 (the contract 9bac44e replaced). It now asserts the handle-addressed root kill on every platform, using vi.waitFor on win32 where the kill lands after the awaited tree walk, with the tree-walk mock still checked synchronously.
  • Awaited all ten expectChildTerminated call sites. The cancellation, local-subprocess, and model-discovery tests now await the now-async helper, matching its new Promise<void> return.

No new issues found in this delta. I re-ran the three text-generation suites (29 tests) and they pass. The vi.waitFor under the fake-timer tests is safe here because vitest's vi.waitFor runs on real timers, and the win32-only test that sets process.platform manually does not route through expectChildTerminated.

The previously posted blocking finding — the raw recursive rmSync at src/main/windows-live-tree-kill.win32.test.ts:118 — is unaffected by this commit and remains open, so the PR is still not mergeable until that is addressed.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…e retrying helper

The new win32 spec teardown used a raw rmSync, which the windows-lane-tree-removal
boundary ratchet rejects — and which is exactly the EPERM the ratchet exists to
prevent, since this spec's marker directory is written by processes it has just
force-killed.

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

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at 376853a)

  • Replaced the raw recursive rmSync teardown with the retrying helper. windows-live-tree-kill.win32.test.ts now removes its marker directory through removeTreeSync from ../shared/windows-transient-lock-removal instead of a raw rmSync(markerDirectory, { recursive: true, force: true }), closing the windows-lane-tree-removal-boundary.test.ts ratchet failure the previous review flagged as blocking.

I confirmed the offending call and its rmSync import are both gone, the new removeTreeSync import resolves to the repo's retrying helper (which carries maxRetries: 8 for the late Windows handle release this teardown can hit), and the boundary ratchet now passes (5 passed). No other files or behavior changed in this commit.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…the handle-less codex site

The own-Chromium gate refused the POSIX process-group arm of
signalProcessTree as well, which was new macOS/Linux behaviour: a stale
getAppMetrics() entry plus pid reuse would orphan a group that main reaps
today. A POSIX group only holds what Orca put in it, so the refusal is now
scoped to win-taskkill-tree and the POSIX arm is recorded and admitted like
the other group kills in main. That also drops the synchronous
getAppMetrics() read from every POSIX termination.

codex-turn-added-roots kills roots found by a table walk, so a refusal has
no handle to fall back to. Pin that the refusal is visible - crumb written,
turn reported as not cancelled - rather than fixing what cannot be fixed.

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

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at b460160)

  • Scoped the own-Chromium refusal to the pid-addressed scope. admitSelfInitiatedTreeKill now refuses only win-taskkill-tree; the POSIX process.kill(-pid) arm of signalProcessTree is recorded and admitted like every other group kill in main. A stale getAppMetrics() entry can no longer orphan a macOS/Linux process group, and the synchronous read is short-circuited off every POSIX termination.
  • Disclosed the handle-less codex site. codex-turn-added-roots finds its roots by a process-table walk rather than a spawn, so a refusal has no child handle to fall back to. The commit documents this in codex-structured-turn-processes.ts and pins that a refusal stays visible (crumb written, turn reported as not cancelled) instead of resolving as if the tree had gone.
  • Split the shared-choke-point test and added the handle-less case. The POSIX arm now asserts group signaling (resolves true, process.kill(-pid) invoked, child.kill untouched) plus the recorded self_tree_kill crumb with scope: 'posix-process-group', and a new test drives terminateCodexTurnProcesses through a refused added root.

I verified the scope gating against every gate caller: all six direct admitSelfInitiatedTreeKill sites pass win-taskkill-tree, so pid-addressed taskkills are still refused on Windows, while win-pty-job never reaches the gate (record-only) and posix-process-group is only routed through signalProcessTree. The new target.scope === 'win-taskkill-tree' guard now matches isPidAddressedTreeKill exactly, so the refusal set and the discriminating selfInitiatedTreeKillCount field stay aligned. Ran the three affected suites (26 tests) green.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…-tree-kill-choke-point

# Conflicts:
#	src/main/orca-chromium-process-pids.ts
#	src/main/own-chromium-tree-kill-guard.test.ts

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

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at 38ab4ea)

  • Merged origin/main. The single new commit is a merge bringing main's crash-reporting work — including #18578, which adds the own_chromium_pids_unreadable coalesced crumb via recordUnreadableOwnChromiumMetrics — onto the branch.
  • Resolved the two conflicts correctly. orca-chromium-process-pids.ts keeps the branch's "the other direction is real too" false-positive note alongside main's "why failure stays open" comment and the new recorder, and own-chromium-tree-kill-guard.test.ts keeps the branch's codex app-server deadline cases plus main's leaves proof fail-open case.

I verified the conflict resolution is a faithful union of both sides (no markers left, no content dropped), that admitSelfInitiatedTreeKill still takes its refusal decision before anything can throw and now records the unreadable-metrics crumb only on the fail-open arm, and re-ran the ratchet, guard, refused-root, self-kill-log, and shared choke-point suites (44 tests) green.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

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

✅ No new issues found.

Reviewed changes (delta since the prior pullfrog review at 042f0d0)

  • Detached the Windows survival fixture. spawnLiveTree now spawns the grandchild with detached: true, windowsHide: true, so a root-handle kill can no longer reap the leaf through libuv job ownership. This is the fix for the Windows CI flake, and it makes the test's "detached grandchild" wording accurate.
  • Observed real spawns via the child_process diagnostics channel. The suite subscribes/unsubscribes observeSpawn per test and now asserts the refused signalProcessTree spawns zero processes while the admitted arm spawns the real taskkill (spawnfile === 'taskkill'), so neither arm is a mocked pass-through anymore.
  • Stabilized the refusal-survival assertion. Both refusal tests await sleep(250) after root exit before asserting the leaf survived, letting root-owned job cleanup finish.

Production code is unchanged by this commit; the delta is confined to windows-live-tree-kill.win32.test.ts. I confirmed the file collects cleanly (4 tests, describe.skip on Linux), the ChildProcess value import and diagnostics-channel plumbing typecheck, and the prior review's "detached" wording nit is now substantively accurate rather than softened.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 0a821e5 into main Sep 4, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…and stop a refusal leaking the root (stablyai#18459)

* fix(crash-reporting): make the own-Chromium gate a real choke point

Round-3 review found the guard was not the choke point its own comments
claimed: six pid-addressed `taskkill /pid <pid> /t /f` families in main were
ungated and uninstrumented, so the stale-pid shape stayed producible and a
`selfInitiatedTreeKillCount: 0` could read as exculpatory when it was not.

- Gate the remaining main-process families: the git command-runner abort, the
  notebook-cell and automation-precheck timeouts.
- Turn the `src/shared` seam into the gate itself (`process-tree-kill-gate`), so
  the runProcess choke point, the codex app-server deadline kill and the
  ephemeral-VM recipe kill ask the same decision. Those three are compiled into
  the CLI/relay too and cannot import main; main installs the guard at preflight.
- Ratchet (`main-process-tree-kill-gate.test.ts`): a new pid-addressed taskkill
  in main that skips the gate fails, and the allowlist entries must still exist.
- Give pid-addressed kills eviction priority in the 32-entry ring: 32 routine
  `win-pty-job` teardowns from a window-close burst no longer evict the one
  entry that discriminates a self-kill from an external one.
- Correct the coverage doc, which described the uninstrumented Windows sites as
  POSIX `process.kill(-pid)` group kills and omitted the git and codex paths.

* fix(crash-reporting): keep a refused tree-kill from leaking the root it owns

A refusal must block the pid-addressed tree walk, not the termination. Five of
the six gated sites returned on refusal with no fallback, so a refused
`taskkill /pid /t /f` left git.exe, a timed-out notebook cell, an automation
precheck or an ephemeral-VM recipe running while the caller reported it stopped.
The root kill is addressed by the child handle, which cannot reach the recycled
pid the refusal is about, so it stays correct and required on that path.

Also fixes the ring eviction the scope preference introduced: with the ring
saturated by pid-addressed kills, the only non-pid-addressed entry is the one
just pushed, so the splice evicted itself and the detail came back `{}` --
byte-identical to the external-kill arm, in the window-close case the guard
exists for. Eviction now excludes the newest entry and falls back to FIFO.

Tests: refusal now asserts the root kill at all six sites, and the ring covers
the saturated-pid ordering as well as round 3's group-burst ordering.

* fix(crash-reporting): stop a refused tree-kill leaking the commit-message agent, and count call sites

Two round-5 blocking findings, both open on main and on both branches.

`killSourceControlAgentProcess` had no root-kill fallback on its win32 arm: the
taskkill was the only termination, so once the own-Chromium gate could refuse it
the promise resolved having killed nothing. Both callers do
`terminationComplete ??= killSourceControlAgentProcess(child)` and then release
the managed-home lock on that promise, so a refusal left the local Codex/Claude
commit-message agent running while the caller reported it stopped -- the
lock-contention failure the taskkill was added for. Same fix as the six sibling
sites: the handle-addressed root kill cannot reach the recycled pid the refusal
is about, so it stays correct and required on that path.

The ratchet was file-granular, not call-site granular: one gate mention anywhere
in a file exempted every taskkill in it, which left the six files that now ask
the gate ratchet-blind -- the inverse of what it is for. It now counts `/pid`
call sites against gate admissions per file, so a second ungated kill inside an
existing family fails. Keying on the `/pid` argument rather than a quoted
`taskkill` also catches a kill whose program name comes from a constant. The
three comments that claimed more than the old scan enforced now state the rule
and its two remaining blind spots.

Also: the recording in `admitSelfInitiatedTreeKill` is now wrapped the way the
`admitProcessTreeKill` seam already wraps it, with the refusal decision taken
before anything that can throw so a diagnostics failure cannot flip it; and
`orca-chromium-process-pids` documents the false-positive direction (a stale
`getAppMetrics()` entry plus pid reuse refuses a live unrelated child), which is
the mechanism the root-kill fallback exists to bound.

Tests: refusal now asserts the root kill at all seven sites; the ratchet asserts
call-site counting and the constant-program form.

* test(crash-reporting): run the own-Chromium gate against real Windows trees

Nothing on this branch had ever executed on Windows. The unit tests pin the
gate's decision against a mocked taskkill, which cannot show that the decision
does anything to a real process: that `/T /F` reaps a detached grandchild, that
a refusal leaves that tree standing, or that the handle-addressed root kill the
refusal path falls back to reaps the root while orphaning descendants.

Adds a win32-gated live test covering all four, registered in both the
`package_windows` CI lane and `WINDOWS_PACKAGE_TESTS` as
`win32-test-lane-registration` requires.

Also completes the coverage doc's "never instrumented" list, which omitted the
macOS keyboard-input-source probe's POSIX group kill in `ipc/app.ts`.

* fix(crash-reporting): pin the commit-message root kill on the Windows arm

The first Windows run of this branch found nine failures the macOS suite
cannot see: `commit-message-text-generation-test-harness` asserts
`expect(child.kill).not.toHaveBeenCalled()` on `process.platform === 'win32'`,
which is the contract the previous commit deliberately replaced — and it
branches on the real platform, so it is dead code everywhere CI runs today.

The harness now asserts the handle-addressed root kill on every platform. On
win32 it lands after the tree walk, so the expectation waits rather than reading
one tick early, and its ten call sites await it. Red against the pre-fix arm at
all seven sites; the production code is unchanged.

* test(crash-reporting): remove the Windows lane marker tree through the retrying helper

The new win32 spec teardown used a raw rmSync, which the windows-lane-tree-removal
boundary ratchet rejects — and which is exactly the EPERM the ratchet exists to
prevent, since this spec's marker directory is written by processes it has just
force-killed.

* fix(crash-reporting): only refuse pid-addressed tree walks, disclose the handle-less codex site

The own-Chromium gate refused the POSIX process-group arm of
signalProcessTree as well, which was new macOS/Linux behaviour: a stale
getAppMetrics() entry plus pid reuse would orphan a group that main reaps
today. A POSIX group only holds what Orca put in it, so the refusal is now
scoped to win-taskkill-tree and the POSIX arm is recorded and admitted like
the other group kills in main. That also drops the synchronous
getAppMetrics() read from every POSIX termination.

codex-turn-added-roots kills roots found by a table walk, so a refusal has
no handle to fall back to. Pin that the refusal is visible - crumb written,
turn reported as not cancelled - rather than fixing what cannot be fixed.

* test(crash-reporting): detach the Windows survival fixture and observe real spawns
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.

1 participant