Skip to content

fix(crash-reporting): stop claiming kills that never landed, and leave proof when the own-Chromium pid set is unreadable - #18578

Merged
nwparker merged 3 commits into
mainfrom
nwparker/crash-18367-leftovers
Sep 4, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/crash-18367-leftovers

Conversation

@nwparker

@nwparker nwparker commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What

Two CodeRabbit findings from #18367 that are live on main and are not addressed by #18459. #18367 merged early (as 7b530f1eb56) before its own remediation round; #18459 carries the choke-point work, but neither of these two.

1. terminatePosixTree claimed a group kill that never landed. The codex app-server teardown's snapshot path recorded a self_tree_kill breadcrumb even when the group signal proved the group was already gone. Its default signalGroup swallowed every process.kill(-pgid, 'SIGKILL') error and the recordSelfInitiatedTreeKill call sat unconditionally below it, so an ESRCH — positive proof that this teardown killed nothing — still credited Orca with a group kill inside the five-second render-process-gone attribution window that #18367 exists to make decidable.

2. An unreadable Chromium pid set was indistinguishable from "no Chromium here". readOrcaChromiumProcessPids returns an empty set when getAppMetrics() throws. That decision is kept (see Trade-offs — failing closed is much worse), but the empty set was byte-identical to the legitimate Node-host case, so the fail-open left no trace in a field bundle. Now it emits a coalesced durable own_chromium_pids_unreadable crumb.

Two other CodeRabbit findings on #18367 are REFUTED here, not fixed — own-chromium-tree-kill-guard.ts:35 / process-tree-termination.ts:89 ("record accepted kills only after taskkill succeeds") and the "fail closed" half of orca-chromium-process-pids.ts:34. Both are declined on evidence, and complying with either would introduce a worse bug than the one it fixes. Reasoning and numbers are in Refuted findings below. Do not read this PR as "all bot comments addressed".

Finding 1 is the one member of the "record before the kill is proven" family that is both wrong and cheaply fixable: the signal is synchronous, so success is knowable at zero cost, and three siblings already do it correctly.

Fix evidence

Finding 1 is not a new convention — it makes the outlier match the three group-kill sites that already record only on a proven signal:

Site Records on proven signal?
terminateDedicatedPosixGroup (same file, codex-app-server-process-teardown.ts:29) yes — catch returns before the record, commented "Outside the try: that catch is the ESRCH contract, not a breadcrumb handler"
forceKillPosixPtyProcessGroups (pty/posix-pty-process-groups.ts:130) yes — isProcessAlreadyGone skips the record
claude-login-process-termination.ts:79 yes — guarded by a signaledGroup flag
terminatePosixTree (codex-app-server-process-teardown.ts:139) no — this PR

does not claim a snapshot group that was already gone drives the production default, not an injected seam — the swallow being tested lives in the default lambda, so an injected throwing dep would not reach it. It uses pgid 2_147_483_647 (above pid_max on every supported POSIX host) so process.kill(-pgid) raises a real ESRCH.

RED without the production hunk. Run in a throwaway detached worktree with only src/main/codex/codex-app-server-process-teardown.ts restored to its origin/main content, so nothing else could perturb the result:

 FAIL  src/main/codex/codex-app-server-process-teardown.test.ts > terminateCodexAppServerProcessTree > does not claim a snapshot group that was already gone
AssertionError: expected [ { pid: 2147483647, …(3) } ] to deeply equal []

- Expected
+ Received

- []
+ [
+   {
+     "at": 1788499221650,
+     "pid": 2147483647,
+     "scope": "posix-process-group",
+     "site": "codex-app-server-teardown",
+   },
+ ]

 ❯ src/main/codex/codex-app-server-process-teardown.test.ts:157:52
 Test Files  1 failed (1)
      Tests  1 failed | 8 passed (9)

RED without the finding-2 hunk, same method on src/main/orca-chromium-process-pids.ts:

- ObjectContaining {
-     "data": ObjectContaining { "cause": "getAppMetrics unavailable" },
-     "name": "own_chromium_pids_unreadable",
-   },
- ]
+ []
 ❯ src/main/own-chromium-tree-kill-guard.test.ts:172:7
 Test Files  1 failed (1)
      Tests  1 failed | 9 passed (10)

GREEN with both, plus the surrounding suites:

vitest run --config config/vitest.config.ts src/main/codex/ src/main/crash-reporting/ \
  src/shared/child-process/ src/main/own-chromium-tree-kill-guard.test.ts \
  src/main/windows-process-tree-kill.test.ts src/main/pty/posix-pty-process-groups.test.ts \
  src/main/windows/windows-pty-job.test.ts src/main/claude-accounts/ src/main/codex-accounts/ \
  src/main/text-generation/ src/main/windows-pty-root-identity.test.ts
 Test Files  217 passed | 3 skipped (220)
      Tests  2208 passed | 36 skipped (2244)

tsc -p config/tsconfig.node.json --noEmit   -> exit 0
oxlint <all four touched files>             -> exit 0
oxfmt --check <all four touched files>      -> "All matched files use the correct format."

ELI5

When Orca force-kills a group of processes it writes a note: "I did this." If a renderer dies right after, those notes are the list of suspects the crash report prints.

Finding 1: this path wrote the note even when the group had already exited and Orca's signal bounced off nothing — a suspect that was never at the scene. Now the note is only written when the signal actually reached something.

Finding 2: before killing anything, Orca asks Electron "which processes are my own windows?" so it never kills one by accident. If that question fails, Orca gets back an empty answer — which looks exactly like the honest answer on a machine that has no windows at all. Orca still proceeds (refusing everything would strand real processes), but it now writes down that the question failed, so nobody later reads "no windows here" and believes it.

Honest scope on finding 1: this is a POSIX group kill, so it lands in selfInitiatedGroupKillCount and the selfInitiatedKills string, not in selfInitiatedTreeKillCount — the pid-addressed, Windows-only field that actually decides whether a render-process-gone was Orca's. A process group cannot contain a Chromium process Orca did not put there, so this can never have caused a wrong verdict; it added a phantom entry to the evidence list a human reads next to it. Worth fixing because the list is the artifact, and because three sibling call sites already get this right — not because it was masking a crash.

Refuted findings

"Record accepted kills only after taskkill succeeds" (coderabbit own-chromium-tree-kill-guard.ts:35, process-tree-termination.ts:89) — refuted.

The record is read at render-process-gone time by findSelfInitiatedTreeKills, over [-SELF_TREE_KILL_LOOKBACK_MS, +SELF_TREE_KILL_LOOKAHEAD_MS] = [-5000ms, +250ms]. The kill causes the death, so the death arrives before taskkill.exe exits. terminateWindowsProcessTree tolerates that exit for WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS = 5000 ms by design. Recording on the success callback therefore stamps at up to 5000 ms after goneAt — outside a 250 ms lookahead — so the crash report would say "no self-initiated kill" for a kill Orca definitely issued.

That is a false negative in exactly the #10680 scenario the feature was built for, which is strictly worse than the bounded false positive being guarded against. The bot is optimising the cheap error at the cost of the expensive one. Additionally, "each caller's confirmed-success path" does not exist for several gated sites — codex-accounts/service.ts (execFileSync), the browser-route probes (spawnSync), and the fire-and-forget spawn arms in precheck-runner.ts / ipc/notebook.ts / git/command-runner — so complying would mean restructuring five teardowns to buy a worse signal.

POSIX is the exception, and that is the whole of finding 1 above: process.kill(-pgid) is synchronous, so there is no latency to lose and no reason to record early.

"Fail closed when Chromium metrics cannot be read" (coderabbit orca-chromium-process-pids.ts:34) — refuted; the epistemic half taken.

A refusal is not free. terminateWindowsProcessTree resolves without killing on refusal, and killSourceControlAgentProcess (text-generation/source-control-local-process.ts:32-34 on main) returns that straight to a caller that then runs markProcessClosed and releases the managed-home lock with the agent still alive. Failing closed would convert one transient getAppMetrics() throw into refusing every pid-addressed tree kill in main — orphaning every PTY, git, codex and notebook tree on Windows and tripping that lock bug — to prevent a hypothetical. getAppMetrics() is a synchronous in-process Electron call; a throw means main is already broken.

What the bot was actually right about is that the failure was invisible: an empty set from a throw was byte-identical to the legitimate "no Chromium on this host". That half is fixed (finding 2).

Still open, pre-existing, not regressions: identity-bound termination (Job Object / handle) instead of a pid — coderabbit own-chromium-tree-kill-guard.ts:34 and process-tree-termination.ts:38. Accurate, unfixed on main and unfixed in #18459. The PID check-to-use window predates #18367, which narrows rather than closes it. Tracked as the non-Chromium half of #10680; out of scope for a diagnostics fix.

Trade-offs

  • Finding 2 stays fail-open, deliberately. CodeRabbit asked to fail closed on a getAppMetrics() throw. That is worse, and concretely so: a refusal is not free. terminateWindowsProcessTree resolves without killing on refusal, and killSourceControlAgentProcess (text-generation/source-control-local-process.ts:32-34) returns that straight to a caller that then runs markProcessClosed and releases the managed-home lock with the agent still alive. Failing closed would trade one unreadable metrics table for every PTY, git, codex and notebook tree in main leaking at once, plus that lock bug — to prevent a hypothetical. getAppMetrics() is a synchronous in-process Electron call; a throw there means main is already broken. The crumb answers the reviewer's real complaint (we could not tell) without buying the leak.
  • Record-before-attempt on the Windows arms is correct and is left alone. taskkill.exe is an out-of-process spawn whose exit can trail the renderer's death by more than SELF_TREE_KILL_LOOKAHEAD_MS (250 ms) — routinely so under EDR, and by design up to WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS (5 s) when it wedges. Recording on the success callback would move the crumb outside the window for the kills that did land, converting a bounded false-positive into a false-negative in exactly the scenario the feature was built for. Several gated sites (codex-accounts/service.ts execFileSync, the browser-route spawnSync probes, the fire-and-forget spawn arms) have no confirmed-success path to move it to without restructuring five teardowns. POSIX is different only because the signal is synchronous.
  • No error-code discrimination on finding 1. Any throw skips the record, not just ESRCH. terminateDedicatedPosixGroup distinguishes ESRCH because it uses it as a return value; here the value is only "did we kill something", and an EPERM is equally not-a-kill. This also keeps the arm safe if it ever runs on a host where process.kill(-pgid) is unsupported.
  • Termination behaviour is unchanged by both hunks. The throw is still swallowed; the wrapper still gets SIGKILL and the function still resolves true. Only the breadcrumb moved. Confirmed by the adjacent assertions in the new tests (target.kill last called with SIGKILL, resolves true).
  • Diagnostics-only in blast radius: finding 1 can only remove a false suspect, never suppress a true one; finding 2 only adds a crumb and changes no decision.

Adversarial review

  • Does skipping the record hide a kill we really made? No. The record is skipped only on a throw, and a throw means process.kill delivered no signal to any process — the group either did not exist or we lacked permission. Neither is a kill.
  • Could the group have been killed by the descendant sweep just above, making the crumb legitimate? The descendant sweep records nothing and signals individual pids, not the group. The crumb's scope is posix-process-group and its pid is snapshot.rootPgid; claiming that specific mechanism when it did not fire is the defect.
  • Does the impossible-pgid test flake? 2_147_483_647 exceeds pid_max on Linux (2^22 ceiling) and macOS (99998), so ESRCH is structural, not probabilistic. This spec is not in the package (windows) lane's list, so that arm is Linux/macOS-verified only; the fix intentionally does not branch on the error code, so any throw on any host takes the same path.
  • Can the finding-2 crumb itself break a kill? No. readOrcaChromiumProcessPids() is called by admitSelfInitiatedTreeKill outside its own try, so a throw from the breadcrumb path would propagate into the caller and turn an admitted kill into a thrown one. The recorder is therefore wrapped in its own try/catch, matching the existing "diagnostics must never fail a termination" rule in process-tree-kill-observer.ts.
  • Does the finding-2 crumb flood the ring? The gate reads the pid set on every tree kill, so a persistently broken metrics table would otherwise evict the 30-slot breadcrumb ring it shares with the refusal crumb. It is coalesced on a fixed key at 60 s, the same shape the refusal and group-kill crumbs already use.
  • New import cycle or bundle edge? No. own-chromium-tree-kill-guard.ts already imports both orca-chromium-process-pids and (transitively, via self-initiated-tree-kill-log) durable-crash-breadcrumb, so the daemon/orcad paths already carry it. tsc -p config/tsconfig.node.json is clean.
  • Ratchet interaction: no new node:child_process import, no new raw recursive rm, no max-lines change, and no breadcrumb-name registry exists that would need updating.
  • Wire/SSH/folder-workspace: none — this is main-process-local diagnostics state. No RPC params, stream opcodes, or published content change, so no remote wire-compatibility surface.

Follow-ups

…that was already gone

terminatePosixTree's default group signal swallowed every process.kill error and
then recorded a self_tree_kill unconditionally, so an ESRCH — proof the group was
already gone and this teardown killed nothing — still put a suspect in the
five-second render-process-gone attribution window.

Every sibling group-kill in the tree already records only on a proven signal:
terminateDedicatedPosixGroup in this same file, forceKillPosixPtyProcessGroups,
and the claude account-login teardown. This makes the outlier match them.
@nwparker

nwparker commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Disposition of the seven bot findings on #18367

#18367 merged early (7b530f1eb56), before its own remediation. Going through every substantive bot comment left on it. One is correct and fixed here; four are refuted with evidence; two are real but pre-existing and tracked.

# Bot / anchor Disposition
1 coderabbit codex-app-server-process-teardown.ts:143 — propagate group-signal failure before recording FIXED HERE
6 pullfrog codex-app-server-process-teardown.ts:139 — records on ESRCH, unlike forceKillPosixPtyProcessGroups FIXED HERE (same defect)
3 coderabbit own-chromium-tree-kill-guard.ts:35 — record only after taskkill succeeds WONTFIX — refuted
5 coderabbit process-tree-termination.ts:89 — emit win-taskkill-tree only after taskkill succeeds WONTFIX — refuted (same)
2 coderabbit orca-chromium-process-pids.ts:34 — fail closed when getAppMetrics() throws Decision refuted, gap closed HERE
4 coderabbit own-chromium-tree-kill-guard.ts:34 — bind to a stable process identity Pre-existing, tracked (#10680)
7 coderabbit process-tree-termination.ts:38 — PID-reuse window, bind to handle/Job Object Pre-existing, tracked (same)

1 / 6 — correct, fixed. pullfrog's diagnosis is exact: the default signalGroup swallowed the process.kill error and the breadcrumb sat unconditionally below it. It is also an inconsistency rather than a design choice — terminateDedicatedPosixGroup in the same file already records outside its catch, and so do forceKillPosixPtyProcessGroups and the claude account-login teardown. This PR makes the outlier match them, with a test that drives the real process.kill(-pgid) (the swallow is in the production default, so an injected throwing dep never reaches it) and is red without the fix.

3 / 5 — refuted on timing. These are the Windows taskkill arms, where record-before-attempt is the correct order, not an oversight:

  • taskkill.exe is an out-of-process spawn. Its exit trails the renderer's death by the process-creation cost, which under behavioural EDR routinely exceeds SELF_TREE_KILL_LOOKAHEAD_MS (250 ms), and by design reaches WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS (5 s) when it wedges.
  • findSelfInitiatedTreeKills accepts a crumb only in [-5000, +250] ms around goneAt. Recording on the success callback puts the crumb outside that window precisely for the kills that did land.
  • So the proposal trades a bounded false positive for a false negative in the exact scenario the feature was built for: deciding whether a reason=killed exitCode=1 renderer death was ours. A missing crumb is unrecoverable; a spurious one is visible next to its site string, and the count alone was never the discriminator.

The POSIX arm is different only because process.kill is synchronous — success is knowable at zero latency cost. That asymmetry is why finding 1/6 is fixed and 3/5 is not.

2 — the prescription is refuted, but it pointed at a real gap, now closed. Failing closed would refuse every tree kill on that host. Since a refusal only kills the root through its child handle, that orphans the descendants of every PTY, git, codex and notebook teardown for as long as the fault lasts — and on main a refusal inside killSourceControlAgentProcess resolves having killed nothing while the caller releases the managed-home lock. That is a guaranteed multi-subsystem leak traded against a hypothetical mis-kill, so fail-open stays.

The part of the finding that was right: the empty set was byte-identical to "this host has no Chromium", so the fail-open was invisible in a field bundle — nobody could tell the gate had stopped being able to judge. This PR adds a coalesced durable own_chromium_pids_unreadable crumb. Decision unchanged, evidence added.

4 / 7 — real, but not a regression. Both describe the check-to-use window on a pid-addressed kill. Verified pre-existing: git show 7b530f1eb56^:src/shared/child-process/process-tree-termination.ts and …:src/main/windows-process-tree-kill.ts both already spawn taskkill /pid … /t /f. #18367 narrows the window (adds the hasExited check and the own-Chromium refusal); it does not open it. Closing it needs Job Object / handle binding — the non-Chromium half of #10680, carried as a follow-up on both PRs.

Unrelated to the bots: #18459 (the rest of the #18367 remediation) was red on test / tests node 24 5/8 — its new windows-live-tree-kill.win32.test.ts teardown used a raw rmSync, which the repo's own windows-lane-tree-removal-boundary ratchet rejects, and which is exactly the EPERM that ratchet exists to prevent given the marker directory is written by processes that spec has just force-killed. Fixed on that branch in b460160bbd1.

…t be read

`readOrcaChromiumProcessPids` returns an empty set when `getAppMetrics()`
throws, which is the right decision — refusing every kill would orphan every
PTY, git, codex and notebook tree main tears down, and on main a refusal from
`killSourceControlAgentProcess` releases the managed-home lock with the agent
still alive. But the empty set was byte-identical to "no Chromium on this
host", so the fail-open was invisible in a field bundle.

Keeps the decision, adds a coalesced durable `own_chromium_pids_unreadable`
crumb so the two cases are distinguishable. Coalesced because the gate reads
this set on every tree kill.
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 7242de82-24a8-42d1-ac7d-603c98db1700

📥 Commits

Reviewing files that changed from the base of the PR and between 4345023 and 8c56dc2.

📒 Files selected for processing (1)
  • src/main/codex/codex-app-server-process-teardown.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/codex/codex-app-server-process-teardown.ts

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


📝 Walkthrough

Walkthrough

The POSIX teardown path now propagates process-group signal errors and records self-initiated kill attribution only after successful signaling. Tests cover absent and reachable groups. Chromium metrics read failures now create coalesced durable crash breadcrumbs while returning an empty set and preserving fail-open kill admission. A new test verifies these behaviors and records the original error cause.

Merge Risk: ⚪ Minimal · up to 8c56d

Process-teardown crash attribution is made more accurate, and unreadable Chromium metrics now leave durable diagnostic context without changing termination admission. No concrete current-head merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed scope, rationale, testing evidence, trade-offs, and follow-ups. However, it does not use most required template sections, including Linked Issue with a Fixes referenc… Add the missing required template sections. Include a Fixes #... issue reference, state N/A with a reason under Visual Proof, complete the Testing checklist, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Check…
✅ Passed checks (3 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 summarizes both primary changes: preventing false kill attribution and recording unreadable Chromium PID metrics. It is specific and related to the changeset.
Full details: Description check

Explanation

The description provides detailed scope, rationale, testing evidence, trade-offs, and follow-ups. However, it does not use most required template sections, including Linked Issue with a Fixes reference, Visual Proof or N/A, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Add the missing required template sections. Include a Fixes #... issue reference, state N/A with a reason under Visual Proof, complete the Testing checklist, address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

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

@nwparker nwparker changed the title fix(crash-reporting): stop the codex POSIX teardown claiming a group that was already gone fix(crash-reporting): stop claiming kills that never landed, and leave proof when the own-Chromium pid set is unreadable Sep 4, 2026
@nwparker

nwparker commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the seven bot findings on #18367 (all verified against origin/main and against #18459's branch, not taken on trust).

Fixed here

  • coderabbit codex-app-server-process-teardown.ts:143 + pullfrog :139 (the same defect) — correct, fixed. terminatePosixTree recorded a posix-process-group kill after a swallowed process.kill(-pgid). pullfrog's comparison to forceKillPosixPtyProcessGroups was the right one, and it undersold the case: three siblings already record only on a proven signal, one of them (terminateDedicatedPosixGroup) in the same file. Now matches them. Test is RED without the hunk (output in the PR body).
  • coderabbit orca-chromium-process-pids.ts:34 — half taken. The decision stays fail-open; see below. The epistemics were a fair hit: an empty set from a throw was byte-identical to "no Chromium on this host". Now emits a coalesced durable own_chromium_pids_unreadable crumb.

Refuted, with reasons

  • coderabbit orca-chromium-process-pids.ts:34, the "fail closed" half — declined. Refusing on a metrics throw is not free. terminateWindowsProcessTree resolves without killing on refusal, and killSourceControlAgentProcess returns that straight to a caller that then releases the managed-home lock with the agent alive. Failing closed trades one unreadable metrics table for every PTY, git, codex and notebook tree in main leaking at once, to prevent a hypothetical.
  • coderabbit own-chromium-tree-kill-guard.ts:35 and process-tree-termination.ts:89 ("record only after taskkill succeeds") — declined, and it would introduce a worse bug. The record is read at render-process-gone time over [-5000ms, +250ms]. taskkill.exe is an out-of-process spawn whose exit trails the death it caused, by design up to WINDOWS_PROCESS_TREE_KILL_TIMEOUT_MS (5 s) when it wedges — far outside a 250 ms lookahead. Recording on the success callback turns kills that did land into false negatives, which is precisely the Windows PTY teardown: ancestry own is not true root identity (PID recycle into Orca tree) #10680 case the feature exists for. Several gated sites (execFileSync, spawnSync, fire-and-forget spawn) have no confirmed-success path to move it to. The bounded false positive is the deliberate cheaper error; POSIX was fixed above only because its signal is synchronous.

Open, pre-existing, not regressions

Separately: #18459's CI was red on src/shared/windows-lane-tree-removal-boundary.test.ts because its new win32 spec used a raw rmSync. Fixed on that branch by routing through removeTreeSync (b460160bbd1) rather than exempting the file; the ratchet now passes and the PR reports MERGEABLE.

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

🧹 Nitpick comments (1)
src/main/own-chromium-tree-kill-guard.test.ts (1)

157-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert ring retention, not only coalescing.

The assertion at Line 157 filters for own_chromium_pids_unreadable, so it proves only that repeated failures produce one matching breadcrumb. It does not prove that existing breadcrumbs remain in the shared 30-entry ring. Populate the ring near capacity, exercise failures across the coalescing interval, and assert that a sentinel breadcrumb remains.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: efa2de29-a6ce-4311-8b22-eec51bdf9752

📥 Commits

Reviewing files that changed from the base of the PR and between 8854b5d and 4345023.

📒 Files selected for processing (4)
  • src/main/codex/codex-app-server-process-teardown.test.ts
  • src/main/codex/codex-app-server-process-teardown.ts
  • src/main/orca-chromium-process-pids.ts
  • src/main/own-chromium-tree-kill-guard.test.ts

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

@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

  • terminatePosixTree records only on a proven group signal — the default signalGroup lambda no longer swallows process.kill(-pgid, 'SIGKILL') errors; the call is wrapped in a try/catch that sets groupSignalled only on a non-throwing signal, and recordSelfInitiatedTreeKill is gated on it. An ESRCH (group already gone) no longer credits Orca with a kill it never issued, matching the terminateDedicatedPosixGroup sibling.
  • Unreadable Chromium metrics now leave proof — readOrcaChromiumProcessPids emits a coalesced durable own_chromium_pids_unreadable crumb when getAppMetrics() throws, distinguishing an unreadable metrics table from the legitimate "no Chromium here" empty set, while staying deliberately fail-open.
  • Tests — two new tests in codex-app-server-process-teardown.test.ts (one exercising the real process.kill against an unreachable pgid, one asserting the record on a proven signal) and one in own-chromium-tree-kill-guard.test.ts (pins coalescing while still admitting the kill).

The changes are correct and minimal: termination behavior is unchanged (the wrapper still gets SIGKILL, the function still resolves true), only the breadcrumb moves. The scope of finding 1 is honestly documented (posix-process-group lands in selfInitiatedGroupKillCount, not the Windows-only selfInitiatedTreeKillCount). The fail-open rationale and the record-before-attempt decision on the Windows arms are well-reasoned. I verified the two touched suites pass locally (19 tests), and confirmed no new import cycle (durable-crash-breadcrumb was already reachable via own-chromium-tree-kill-guard).

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

@nwparker
nwparker merged commit 9acfba4 into main Sep 4, 2026
27 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…e proof when the own-Chromium pid set is unreadable (stablyai#18578)

* fix(crash-reporting): stop the codex POSIX teardown claiming a group that was already gone

terminatePosixTree's default group signal swallowed every process.kill error and
then recorded a self_tree_kill unconditionally, so an ESRCH — proof the group was
already gone and this teardown killed nothing — still put a suspect in the
five-second render-process-gone attribution window.

Every sibling group-kill in the tree already records only on a proven signal:
terminateDedicatedPosixGroup in this same file, forceKillPosixPtyProcessGroups,
and the claude account-login teardown. This makes the outlier match them.

* fix(crash-reporting): leave proof when the own-Chromium pid set cannot be read

`readOrcaChromiumProcessPids` returns an empty set when `getAppMetrics()`
throws, which is the right decision — refusing every kill would orphan every
PTY, git, codex and notebook tree main tears down, and on main a refusal from
`killSourceControlAgentProcess` releases the managed-home lock with the agent
still alive. But the empty set was byte-identical to "no Chromium on this
host", so the fail-open was invisible in a field bundle.

Keeps the decision, adds a coalesced durable `own_chromium_pids_unreadable`
crumb so the two cases are distinguishable. Coalesced because the gate reads
this set on every tree kill.

* style(crash-reporting): tighten the group-signal comments to the WHY
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