Skip to content

fix(windows): repair the install-dir package ACL that blanks the window - #17740

Merged
nwparker merged 3 commits into
mainfrom
nwparker/crashfix-g1-windows-acl
Sep 1, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/crashfix-g1-windows-acl

Conversation

@nwparker

@nwparker nwparker commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​672 $\color{#cf222e}{\Huge{\mathbf{−}}}$​51 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​621
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​549 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​515

What

On Windows, an install tree can end up carrying an orphan AppContainer ACE — an S-1-15-2-<x> entry left behind by an uninstalled/reset app package — with no ALL RESTRICTED APPLICATION PACKAGES (S-1-15-2-2) grant to satisfy it. In that state Chromium's LPAC (Less Privileged AppContainer) children are denied read on the very modules Orca shipped with: the GPU and renderer children die at init with 0x80000003, and once the GPU fallback engages --in-process-gpu the renderer dies on every load and the window stays blank forever. See electron/electron#51761.

#15107 already landed a read-only DACL probe that records this shape into the crash breadcrumb. This PR makes the app act on it:

  1. Tightens the probe verdict. The old gate accepted any well-known package grant (S-1-15-2-1 or -2) as satisfying the orphan. S-1-15-2-1 (ALL APPLICATION PACKAGES) is the Program Files inheritance default and is not in an LPAC child's token, so it satisfies nothing. The verdict now requires S-1-15-2-2 specifically (hasRestrictedPackageGrant), and the breadcrumb reports both flags.
  2. Fixes the locale heuristic. BUILTIN was in the "this icacls output is English" check, but fr-FR and es-ES print BUILTIN\Administrateurs / BUILTIN\Administradores verbatim while localizing the package names. It is evidence of nothing, so it's dropped — a localized icacls is now correctly reported as un-name-checkable.
  3. Adds a self-repair (windows-install-dir-package-acl-repair.ts): two additive icacls /grant passes (never /grant:r) — an inheritable (OI)(CI)(RX) on the install root so a later update inherits it, then a flagless (RX) /T /C pass over existing entries. Marker-guarded in userData keyed on install dir + app version, so it runs at most once per install/version even when it fails.
  4. Rewrites the crash-loop dialog into a testable module (renderer-recovery-prompt.ts): when the ACL diagnosis exists it names the real cause, adds a Copy Commands button that does not dismiss the dialog (the window is blank — dismissing it leaves no way back), re-reads the diagnosis each pass so an in-flight repair's outcome shows up, and keeps the graphics-driver hint as a fallback.

The repair is gated three ways: win32 only, exempt in serve mode, and only on the exact probe verdict (matchesPoisonSignature === true && wellKnownNameCheckReliable !== false).

Fix evidence

Gate correctness — before/after on the S-1-15-2-1-is-not-enough bug

The old gate line was (f) => f.orphanPackageSids.length > 0 && !f.hasWellKnownPackageGrant. Reverting only that line in the working tree and re-running the two suites:

$ npx vitest run --config config/vitest.config.ts src/main/startup/windows-install-dir-acl-recovery.test.ts src/main/startup/windows-install-dir-acl-probe.test.ts
EXIT=1

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 3 ⎯⎯⎯⎯⎯⎯⎯
 FAIL  src/main/startup/windows-install-dir-acl-probe.test.ts > probeWindowsInstallDirAcl > keeps the signature when only ALL APPLICATION PACKAGES grants (the localized-safe name form)
 FAIL  src/main/startup/windows-install-dir-acl-probe.test.ts > probeWindowsInstallDirAcl > keeps the signature when only ALL APPLICATION PACKAGES grants (the raw SID form)
AssertionError: expected false to be true // Object.is equality
- Expected
+ Received
- true
+ false
 ❯ src/main/startup/windows-install-dir-acl-probe.test.ts:90:41
     88|     expect(data.hasWellKnownPackageGrant).toBe(true)
     89|     expect(data.hasRestrictedPackageGrant).toBe(false)
     90|     expect(data.matchesPoisonSignature).toBe(true)
       |                                         ^
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯
 FAIL  src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > repairs an install whose only package grant is ALL APPLICATION PACKAGES
AssertionError: expected [] to have a length of 2 but got +0
- Expected
+ Received
- 2
+ 0
 ❯ src/main/startup/windows-install-dir-acl-recovery.test.ts:93:19
     91|       icaclsDacl(target, [ORPHAN_PACKAGE_ACE, ALL_PACKAGES_ACE])
     92|     )
     93|     expect(specs).toHaveLength(2)
       |                   ^

 Test Files  2 failed (2)
      Tests  3 failed | 24 passed (27)

expected [] to have a length of 2 but got +0 is the bug stated exactly: on the most common poisoned shape — a Program Files install that inherits ALL APPLICATION PACKAGES:(RX) plus an orphan S-1-15-2-<x> — zero icacls calls were made. With the fix restored, the same command:

$ npx vitest run --config config/vitest.config.ts src/main/startup/windows-install-dir-acl-recovery.test.ts src/main/startup/windows-install-dir-acl-probe.test.ts

 Test Files  2 passed (2)
      Tests  27 passed (27)

Locale heuristic — before/after on the BUILTIN false positive

Re-adding BUILTIN to ENGLISH_PRINCIPAL and re-running the same two suites:

EXIT=1

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯
 FAIL  src/main/startup/windows-install-dir-acl-probe.test.ts > probeWindowsInstallDirAcl > reports whether the well-known name check could be trusted
AssertionError: expected true to be false // Object.is equality
- Expected
+ Received
- false
+ true
 ❯ src/main/startup/windows-install-dir-acl-probe.test.ts:140:50
    138|     })
    139|     expect(localized.matchesPoisonSignature).toBe(true)
    140|     expect(localized.wellKnownNameCheckReliable).toBe(false)
       |                                                  ^
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
 FAIL  src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > does not act on a signature from a non-English icacls
AssertionError: expected [ { …(3) }, { …(3) } ] to have a length of +0 but got 2
- Expected
+ Received
- 0
+ 2
 ❯ src/main/startup/windows-install-dir-acl-recovery.test.ts:110:19
    108|       icaclsDacl(target, [ORPHAN_PACKAGE_ACE, FRENCH_RESTRICTED_PACKAG…
    109|     )
    110|     expect(specs).toHaveLength(0)
       |                   ^

 Test Files  2 failed (2)
      Tests  2 failed | 25 passed (27)

expected [ { …(3) }, { …(3) } ] to have a length of +0 but got 2 is the false positive: a healthy French install (which carries TOUS LES PACKAGES D'APPLICATION RESTREINTS) got two icacls writes and the accusatory dialog copy. With BUILTIN dropped, both go to zero.

Final full run of every affected suite

$ pnpm test src/main/startup/windows-install-dir-acl-probe.test.ts src/main/startup/windows-install-dir-package-acl-repair.test.ts src/main/startup/windows-install-dir-acl-recovery.test.ts src/main/window/renderer-recovery-prompt.test.ts src/main/window/createMainWindow-renderer-crash-recovery.test.ts
EXIT=0

 RUN  v4.1.11 /private/tmp/orca-cf-g1-windows-acl

 Test Files  5 passed (5)
      Tests  64 passed (64)
   Start at  14:14:15
   Duration  1.76s (transform 1.49s, setup 164ms, import 1.91s, tests 249ms, environment 0ms)

Named cases in the new suites (verbatim from --reporter=verbose):

 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > repairs when the probe sees an orphan package ACE and no restricted grant 29ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > repairs an install whose only package grant is ALL APPLICATION PACKAGES 26ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > does not touch an install that already carries the restricted grant 27ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > does not act on a signature from a non-English icacls 27ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > startWindowsInstallDirAclRepairIfPoisoned > does not act when the probe could not read the DACL 27ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > describeInstallDirAclPoison > offers the copyable commands, and drops them once the repair lands 26ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > describeInstallDirAclPoison > walks a standard user through icacls when the repair could not write 27ms
 ✓ src/main/startup/windows-install-dir-acl-recovery.test.ts > describeInstallDirAclPoison > reports the repair as in flight before icacls has answered 0ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > grants the flagless (RX) on the recursive pass, never (OI)(CI)(RX) 2ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > grants the inheritable (OI)(CI)(RX) on the root, without /T 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > is additive on every pass so SYSTEM, Administrators and the orphan survive 0ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > runs once and then never spawns again for the same install and version 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > re-runs after an update and after a reinstall to another directory 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > re-runs when the marker is from an older scheme or is corrupt 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > records the failed-file count when a standard user cannot write the ACL 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > still runs the per-file pass when the root grant fails 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > does not throw when the runner rejects, and still records a breadcrumb 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > marks the attempt so a hopeless install does not re-spawn icacls every launch 1ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > is a no-op off win32 and in serve mode 22ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > repairWindowsInstallDirPackageAcl > offers commands that match what the repair itself runs 0ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > isInstallDirAclPoisonVerdict > only accepts the probe verdict that reproduced the crash 0ms
 ✓ src/main/startup/windows-install-dir-package-acl-repair.test.ts > isInstallDirAclPoisonVerdict > refuses a signature the probe could not name-check 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > offers reload and quit with the generic cause when nothing is diagnosed 2ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > quits on the last button 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > names the install-permission cause and keeps the driver hint 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > keeps the dialog up after copying the commands, then still reloads 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > quits on the third button once the diagnosis adds one 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > shows nothing once the app is already quitting 0ms
 ✓ src/main/window/renderer-recovery-prompt.test.ts > presentRendererRecoveryPrompt > re-reads the diagnosis on every pass 0ms

Gates

$ pnpm run check:code-quality:changed
code quality: 0 new finding(s) across 11 changed file(s).
type-aware code quality: 0 new finding(s) across 11 changed file(s).
React Doctor: 0 new finding(s) across 11 changed file(s).
Changed-code quality gate passed since 872bd51d479e.

$ pnpm tc
EXIT=0

$ npx oxfmt --write <11 changed files>
Finished in 11ms on 11 files using 16 threads.
(no diff produced — already formatted)

What I could NOT obtain — stated plainly

I did not have a Windows host in this session. No icacls was executed against a real DACL, and no Windows exit code was captured by me. Specifically:

Everything I did run — the before/after gate flips, the 64 passing tests, pnpm tc, and the quality gate — is quoted verbatim above with its real exit code.

ELI5

Windows lets a folder carry a "permission slip" naming a specific sandboxed app-container account. Sometimes an install folder ends up with a leftover slip naming an account that no longer exists, and none naming the sandbox account Orca's own helper processes actually run as. Windows then refuses to let Orca's own sandboxed helpers read Orca's own files. They crash instantly, the window never paints, and the app just sits there blank.

Orca already had a detector for this that only wrote it into the crash report. Now Orca fixes it: it adds one extra permission slip for the right account (adding only — it never removes anyone's existing access), and if it can't (because the folder needs an administrator), the "Orca keeps failing to load" dialog stops guessing "probably your graphics driver" and instead tells you exactly what's wrong with a Copy Commands button for the two commands to paste into an admin prompt.

The bug fixed along the way: the detector was accepting the wrong permission slip. ALL APPLICATION PACKAGES sounds like it covers everything, but Orca's helpers run in a restricted container whose token doesn't include it — so the detector was calling the single most common broken install "fine" and doing nothing.

Trade-offs

1. The change writes an ACL grant on the install directory, widening read access to restricted app packages.

This is real and is the point of the PR. Two additive icacls /grant passes add ALL RESTRICTED APPLICATION PACKAGES (S-1-15-2-2) with (RX) — read + execute, no write — to the install root (inheritable) and to every existing entry beneath it. After this, any LPAC-sandboxed process on the machine, not just Orca's, can read and execute the contents of Orca's install directory.

Why that's acceptable:

  • The grant is read/execute only. No write, no modify, no delete, no ACL-change right. Nothing gained here lets any process alter Orca's binaries.
  • The install directory contains only what the installer shipped — the same bytes that are publicly downloadable from the release feed. There is no user data, no token, no credential in it. User data lives in %APPDATA%, which is untouched (and is separately handled by the pre-existing ensureWindowsUserDataAclGrant).
  • S-1-15-2-2 is a reduction of S-1-15-2-1, not an expansion of it. A default Program Files install already grants ALL APPLICATION PACKAGES (S-1-15-2-1) (RX) on the whole tree by inheritance; every AppContainer holds -1, while only the restricted subset holds -2. So on a Program Files install this grant reaches a strictly smaller set of principals than the grant Windows itself already put there. On a per-user %LOCALAPPDATA%\Programs install it is a genuine widening, but still read-only over public binaries.
  • Never /grant:r. Both passes are purely additive: SYSTEM, Administrators, the user's own ACE — and the orphan ACE itself — all survive untouched. Removing someone else's ACE is not this code's business, and the orphan is a fingerprint worth keeping for diagnosis.

2. What happens on a Program Files install without elevation.

It fails, by design, and the failure is visible rather than silent:

  • icacls returns non-zero (Access is denied) and/or Failed processing N files. runGrant classifies both as failure, and the parsed failedFileCount goes into the windows_install_dir_acl_repair breadcrumb.
  • A marker is written to userData even on failure, keyed on install dir + app version. A standard user on a Program Files install can never win, so re-spawning icacls on every single launch forever buys nothing. An update or a reinstall elsewhere changes the key and retries.
  • The user is not left stranded: describeInstallDirAclPoison() flips to "Orca could not repair them, which usually means the folder needs an administrator." and the dialog shows the two exact commands plus a Copy Commands button that keeps the dialog open.
  • The honest gap: if the repair fails and the user does nothing, Orca is exactly as broken as before this PR. This does not make an unelevated Program Files install work. It converts an unexplained blank window into a named problem with a copyable fix. That is the whole improvement in that scenario, and it should not be oversold.

3. Other regressions and behavior changes.

  • Non-English Windows gets no self-repair. By design: isInstallDirAclPoisonVerdict refuses to act when wellKnownNameCheckReliable === false, because a localized icacls prints the restricted grant under a translated name the probe cannot match. A genuinely poisoned French/Spanish/etc. install therefore gets neither the automatic fix nor the specific dialog copy — it still sees the old generic "graphics-driver or installation problem" text. This is the deliberate choice to under-trigger rather than tell a healthy user their permissions are broken, but it means the population this PR helps is English-locale-only for now.
  • The dialog can now show three buttons instead of two. cancelId moves from 1 to 2 when a diagnosis exists, so Esc still maps to Quit. Covered by the quits on the third button once the diagnosis adds one test.
  • The dialog is now a loop. Choosing Copy Commands re-shows it. It exits on Reload, on Quit, or when isQuitting() becomes true. A showMessageBox implementation that returned Copy Commands unconditionally would loop forever; in production the response comes from a real user click, and the isQuitting() guard is re-checked every pass.
  • Reload deliberately does not reset the crash-loop breaker. A manual retry on a machine that is still poisoned re-raises this prompt on the next crash instead of re-arming three more silent auto-reload cycles. This was a fix applied during review, not an oversight — see Round 1.
  • icacls on a huge or network-mounted install directory could take a while. Bounded at 15s (root) and 120s (tree), off the critical path via setImmediate, and never blocking window creation. See the perf note below on the 120s cap.

Adversarial review

Number of review rounds until clean: 3

Round 1 — [major] src/main/index.ts: the "manual retry is refused by the open breaker" premise is false.
The reviewer found that loadMainWindow (src/main/window/createMainWindow.ts:36) is nothing but mainWindow.loadURL(...) / mainWindow.loadFile(...) — it never consults the circuit breaker. The breaker is only consulted inside scheduleRendererRecovery's 250ms timer in main-window-focus-lifecycle.ts. So the resetRecoveryWindow plumbing that had been added to "un-block" the manual retry was fixing a non-bug, and its actual effect was to re-arm three more automatic crash-reload cycles on a machine that had already proven it could not load.
Resolution: finding accepted, reviewer was correct. All resetRecoveryWindow plumbing was deleted from index.ts. The Reload button now calls loadMainWindow directly and leaves the breaker open, so a re-crash re-raises the prompt instead of resuming the silent auto-reload loop. A regression test pins exactly this: serves a manual retry while the breaker stays open for the next crash asserts 1 initial load + 3 recoveries, the 4th crash refused, loadMainWindow taking the count to 5, and the next crash still refused (count stays 5) while onRendererRecoveryExhausted fires a second time.

Round 2 — three [major] findings, all accepted and fixed.

  1. The repair gate treated ALL APPLICATION PACKAGES (S-1-15-2-1) as satisfying the orphan. The single most common poisoned shape — a Program Files install, which inherits ALL APPLICATION PACKAGES:(RX) by Windows default, plus an orphan S-1-15-2-<x> — was judged clean and the repair never ran. Fixed: collectAclFacts now tracks hasRestrictedPackageGrant (S-1-15-2-2 / ALL RESTRICTED APPLICATION PACKAGES) separately from hasWellKnownPackageGrant, and matchesPoisonSignature rides on the restricted flag alone. Both flags are reported in the breadcrumb. Pinned by three tests; the before/after for this is quoted verbatim in Fix evidence.
  2. On any non-English Windows the gate false-positived, and the change turned that into a confident, wrong user-facing diagnosis. describeInstallDirAclPoison was replacing the generic text with "Windows permissions on Orca's install folder are blocking..." plus admin icacls instructions, while discarding the probe's wellKnownNameCheckReliable signal that exists precisely to flag this case. Fixed: isInstallDirAclPoisonVerdict now requires wellKnownNameCheckReliable !== false, and BUILTIN was removed from ENGLISH_PRINCIPAL because fr-FR/es-ES print it verbatim. A French fixture (FRENCH_BASELINE_ACES, FRENCH_RESTRICTED_PACKAGES_ACE) drives the test; before/after quoted verbatim in Fix evidence.
  3. The only new test for the manual-retry half passed with src/main/index.ts fully reverted. It exercised pre-existing createMainWindow/loadMainWindow and asserted nothing about the diff, leaving the dialog loop, the third button, describeInstallDirAclPoison, and the probe→repair wiring untested. Fixed: the dialog body was extracted into src/main/window/renderer-recovery-prompt.ts behind an injectable RendererRecoveryPromptDeps, with 7 tests covering both button layouts, cancelId, the copy-without-dismiss loop, the re-read-diagnosis-per-pass behavior, and the already-quitting no-op. windows-install-dir-acl-recovery.test.ts was added to drive the real probe into the real gate with only the two process seams faked, proving end-to-end when icacls does and does not run.

Round 3 — clean. No new findings.

Perf review

Result: one finding (F1), accepted as real, deliberately not fixed in this PR. No other perf issues.

Baseline: this change adds literally zero work on the overwhelming majority of launches. On non-win32, in serve mode, and on any win32 machine that does not match the poison signature, there are no new spawns, timers, listeners, or fs I/O. Everything below concerns only a machine that has already matched the poison signature — i.e. a machine that is currently unable to open its window at all.

F1 — the /T install-tree ACL rewrite is far larger than the code's stated cost model, and it runs alongside the very first renderer load.

windows-install-dir-package-acl-repair.ts:46 justifies its 120s cap with:

// A packaged Electron dist is ~80 entries (45ms measured); the cap is for a slow
// or contended volume, not for a tree this walk could plausibly still be in.
const TREE_GRANT_TIMEOUT_MS = 120_000

The "~80 entries" figure does not survive contact with a real tree. Measured in this worktree:

$ find node_modules/electron/dist -mindepth 1 | wc -l
     585

585 entries for the bare Electron dist alone, before resources/, app.asar.unpacked, and bundled native modules — the reviewer's "~40x larger than the stated cost model" is directionally confirmed. icacls /T is a synchronous per-entry SetNamedSecurityInfo, so the real walk is materially longer than 45ms.

Why it is not fixed here:

  • The 120s value is an upper bound, not a wait. Nothing blocks on it; runGrant resolves as soon as icacls exits.
  • The work is fired from setImmediate after repairWindowsInstallDirPackageAcl has already returned, so it never blocks openMainWindow or window creation.
  • It runs at most once per install + app version (marker-guarded, including on failure), and only on a machine whose window is currently blank.
  • Trading a too-generous cap for a too-tight one on a poisoned machine risks a timeout verdict on a slow or contended volume, which would mark the attempt failed and prevent the retry the user actually needs.

What I did not do: I did not measure icacls /T against a real packaged Windows install (no Windows host, per Fix evidence), so the true wall-clock figure is unknown to me. The honest state is that the comment's cost model is wrong and should be corrected, and that a perf(windows) follow-up should replace the guessed constant with a measured one. That is a comment-accuracy defect on a non-blocking, once-per-version path — not a reason to hold this crash fix.

An install tree carrying an orphan AppContainer ACE (S-1-15-2-<x>) with no
ALL RESTRICTED APPLICATION PACKAGES grant denies Chromium's LPAC children read
on the shipped modules; they die at init with 0x80000003 and the window stays
blank forever (electron/electron#51761).

- Tighten the probe verdict to require the S-1-15-2-2 grant specifically: an
  ALL APPLICATION PACKAGES (S-1-15-2-1) ACE, the Program Files default, does
  not appear in an LPAC token and cannot satisfy the orphan.
- Drop BUILTIN from the English-locale heuristic (fr-FR/es-ES print it
  verbatim) so a localized icacls is correctly reported as un-name-checkable.
- Add an additive, marker-guarded icacls self-repair: an inheritable root
  grant plus a flagless (RX) /T pass, never /grant:r.
- Route the crash-loop dialog through a testable prompt module that names the
  permission cause, offers Copy Commands without dismissing itself, and keeps
  the graphics-driver hint.

The repair only runs on win32, off serve mode, and only on the exact probe
verdict that reproduced the crash.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change detects poisoned Windows install-directory ACLs and starts repair when the probe reports a poisoned ACL. The repair runs root and tree icacls grants, records outcomes, and uses versioned markers. Recovery state exposes pending, repaired, or failed diagnosis details. Renderer crash recovery now supports diagnosis display, command copying, reload, and quit actions. Tests cover ACL parsing, repair outcomes, recovery states, prompt behavior, and manual retry after the crash-loop breaker opens.

Merge Risk: 🔵 Low · up to bfdcb

The PR adds automatic Windows ACL repair and clearer recovery messaging. A failed or partial repair may not be retried on later launches of the same version, and some new recovery text still needs localization follow-up. The change is mergeable with explicit owner awareness of these bounded risks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides detailed scope, rationale, implementation, testing, trade-offs, and limitations. However, it does not follow the repository template fully: it lacks a repository issue referen… Add the missing template sections. Include a repository issue reference in Fixes #..., provide before/after visual evidence or write N/A with a reason, complete AI Disclosure as applicable, confirm the Agent skill upstream boundary, add…
Docstring Coverage ⚠️ Warning Docstring coverage is 36.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: repairing the Windows install-directory package ACL that causes the blank window.
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.
Full details: Description check

Explanation

The description provides detailed scope, rationale, implementation, testing, trade-offs, and limitations. However, it does not follow the repository template fully: it lacks a repository issue reference using Fixes #, a Visual Proof section or required N/A explanation, explicit AI Disclosure, Agent skill boundary, Notes, and Checklist sections.

Resolution

Add the missing template sections. Include a repository issue reference in Fixes #..., provide before/after visual evidence or write N/A with a reason, complete AI Disclosure as applicable, confirm the Agent skill upstream boundary, address Notes, and complete the Checklist items.

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

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR extends the Windows install-directory ACL probe into an automatic, marker-guarded repair and adds an ACL-aware renderer recovery prompt.

  • Adds additive root and recursive icacls grants for diagnosed install trees.
  • Records repair state and exposes copyable administrator commands when automatic repair fails.
  • Extracts the renderer crash-loop prompt into a testable module with reload, copy, and quit handling.
  • Refines package-grant detection and attempts to avoid acting on localized icacls output.

Confidence Score: 4/5

The PR is not yet safe to merge because localized ACL output can still be marked reliable and trigger a recursive repair of a healthy install tree.

The locale fix only removes BUILTIN; matching NT AUTHORITY or APPLICATION PACKAGE AUTHORITY still marks the entire output reliable even when the restricted-package principal is localized and missed, allowing the existing poison verdict to reach the automatic ACL repair and incorrect recovery diagnosis.

Files Needing Attention: src/main/startup/windows-install-dir-acl-probe.ts

Important Files Changed

Filename Overview
src/main/startup/windows-install-dir-acl-probe.ts Refines package ACE parsing, but the locale-reliability heuristic still preserves the previously reported false-positive path through untranslated authority names.
src/main/startup/windows-install-dir-package-acl-repair.ts Adds marker-guarded, additive root and recursive ACL grants with bounded process execution and repair breadcrumbs.
src/main/startup/windows-install-dir-acl-recovery.ts Connects accepted probe verdicts to background repair state and user-facing diagnosis.
src/main/window/renderer-recovery-prompt.ts Extracts the crash-loop prompt and supports re-reading diagnosis, copying commands without dismissal, manual reload, and quit.
src/main/index.ts Wires the install ACL repair into Windows startup and delegates renderer crash recovery to the extracted prompt.

Reviews (2): Last reviewed commit: "fix(windows): keep the install-ACL poiso..." | Re-trigger Greptile

const RESTRICTED_PACKAGE_NAME = /ALL RESTRICTED APPLICATION PACKAGES/i
// Not BUILTIN: fr-FR and es-ES print it verbatim while localizing the package
// names, so it is evidence of nothing. SYSTEM's ACE is on every install tree.
const ENGLISH_PRINCIPAL = /\b(NT AUTHORITY|APPLICATION PACKAGE AUTHORITY)\b/i

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Locale reliability checks wrong substring

When localized Windows output keeps NT AUTHORITY or APPLICATION PACKAGE AUTHORITY in English but translates ALL RESTRICTED APPLICATION PACKAGES, this check marks the output reliable while the parser misses the valid restricted-package grant. An install containing that grant and an orphan SID is then falsely classified as poisoned, causing Orca to recursively rewrite a healthy install ACL and present incorrect recovery instructions.

Knowledge Base Used: Desktop application platform

@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: 97575b1a-33fb-472b-84b2-cb4c71430374

📥 Commits

Reviewing files that changed from the base of the PR and between 02a7742 and 95631a3.

📒 Files selected for processing (11)
  • src/main/index.ts
  • src/main/startup/windows-install-dir-acl-probe.test.ts
  • src/main/startup/windows-install-dir-acl-probe.ts
  • src/main/startup/windows-install-dir-acl-recovery.test.ts
  • src/main/startup/windows-install-dir-acl-recovery.ts
  • src/main/startup/windows-install-dir-acl.test-fixture.ts
  • src/main/startup/windows-install-dir-package-acl-repair.test.ts
  • src/main/startup/windows-install-dir-package-acl-repair.ts
  • src/main/window/createMainWindow-renderer-crash-recovery.test.ts
  • src/main/window/renderer-recovery-prompt.test.ts
  • src/main/window/renderer-recovery-prompt.ts

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

Comment on lines +9 to +13
const GENERIC_DETAIL =
'This is often a graphics-driver or installation problem. Reload to try again, or quit and relaunch Orca.'
// Why keep it alongside the ACL diagnosis: the probe cannot name-check every
// locale, so a driver crash on a healthy install must not lose its only hint.
const DRIVER_FALLBACK = 'If that does not help, the cause is usually a graphics driver.'

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 | 🟡 Minor | ⚡ Quick win

Localize the new recovery-dialog text.

Replace the user-visible ACL and renderer recovery literals with intent-named localization IDs, using named interpolation placeholders for dynamic values such as recentRecoveryCount. These messages may be the only usable recovery surface when the window is blank.

Also apply this to the ACL recovery strings in src/main/startup/windows-install-dir-acl-recovery.ts.

📍 Affects 2 files
  • src/main/window/renderer-recovery-prompt.ts#L9-L13 (this comment)
  • src/main/startup/windows-install-dir-acl-recovery.ts#L57-L58

Source: Learnings

@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

Reviewed the install-dir package ACL repair end to end: the tightened probe verdict, the locale heuristic fix, the new self-repair module and its recovery wiring, the crash-loop dialog rewrite, and the follow-up cost-model comment correction.

  • Tightened probe verdict — matchesPoisonSignature now rides on hasRestrictedPackageGrant (S-1-15-2-2) alone, since ALL APPLICATION PACKAGES (S-1-15-2-1) is absent from an LPAC token and was masking the single most common poisoned shape.
  • Locale heuristic fix — BUILTIN dropped from ENGLISH_PRINCIPAL so a localized icacls is correctly reported as un-name-checkable instead of triggering a false-positive repair.
  • Additive self-repair — windows-install-dir-package-acl-repair.ts runs two icacls /grant passes (inheritable (OI)(CI)(RX) root grant, then flagless (RX) /T /C), never /grant:r, marker-guarded in userData keyed on install dir + app version.
  • Recovery and dialog — the probe's onDone hands its verdict to the repair; the crash-loop dialog is extracted into a testable renderer-recovery-prompt.ts that names the real cause, offers a non-dismissing Copy Commands button, and re-reads the diagnosis each pass.
  • Cost-model comment — 95631a3e12 corrects the /T walk estimate from "~80 entries" to the shipped ~3.2k-entry shape.

Verified locally: all five affected suites pass (64 tests) and pnpm tc:node is clean.

ℹ️ Nitpicks

  • The PR body's "Perf review" section still says the cost-model comment is "deliberately not fixed" and defers a perf(windows) follow-up, but commit 95631a3e12 already corrected the comment — the description is now slightly stale and could mislead a reader into expecting an open follow-up.

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

Since the prior review, one commit landed: 95631a3e12 corrects the /T install-tree walk cost-model comment in windows-install-dir-package-acl-repair.ts, replacing the inaccurate "~80 entries (45ms measured)" claim with the shipped ~3.2k-entry estimate and a ~2.2ms/entry figure sourced from the measured windows-user-data-acl.ts walk. Comment-only — no behavioral change.

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

An orphan package ACE alongside the Program Files ALL APPLICATION
PACKAGES default launches clean on win32 10.0.26200 / Electron 43.4.1,
so requiring S-1-15-2-2 specifically declared poison on healthy installs
- and this branch acts on that verdict with a tree-wide icacls write and
the crash-recovery dialog's primary cause. hasRestrictedPackageGrant
stays reported for triage; only the verdict reverts.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/startup/windows-install-dir-acl-probe.ts (1)

175-175: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Require the restricted package grant for a clean verdict.

hasWellKnownPackageGrant is true for both S-1-15-2-1 and S-1-15-2-2. This predicate therefore marks an orphan ACE plus only ALL APPLICATION PACKAGES as clean. The recovery gate then skips repair and diagnosis.

Use !f.hasRestrictedPackageGrant here. Update the matching expectations in src/main/startup/windows-install-dir-acl-probe.test.ts and src/main/startup/windows-install-dir-acl-recovery.test.ts.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: ddb200d6-91a0-4536-b2bc-1a12bc1ad231

📥 Commits

Reviewing files that changed from the base of the PR and between 95631a3 and bfdcb63.

📒 Files selected for processing (6)
  • src/main/startup/windows-install-dir-acl-probe.test.ts
  • src/main/startup/windows-install-dir-acl-probe.ts
  • src/main/startup/windows-install-dir-acl-recovery.test.ts
  • src/main/startup/windows-install-dir-acl.test-fixture.ts
  • src/main/startup/windows-install-dir-package-acl-repair.test.ts
  • src/main/startup/windows-install-dir-package-acl-repair.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/startup/windows-install-dir-package-acl-repair.test.ts
  • src/main/startup/windows-install-dir-acl.test-fixture.ts
  • src/main/startup/windows-install-dir-package-acl-repair.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 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.

Important

The new commit reverses the poison-verdict gate back to accepting ALL APPLICATION PACKAGES (S-1-15-2-1) as satisfying the orphan. That re-opens the exact under-trigger Round 2 closed: the LPAC children that crash don't consult -1 in their access check, so the most common poisoned shape (an orphan plus only the Program Files-inherited -1 grant) is now reported clean and gets neither the repair nor the dialog copy. Details inline.

Reviewed changes

Reviewed the single commit that landed since the prior Pullfrog review (bfdcb63086).

  • Reverted the poison-verdict gate — matchesPoisonSignature moved from requiring S-1-15-2-2 (!hasRestrictedPackageGrant) back to accepting either well-known grant (!hasWellKnownPackageGrant); hasRestrictedPackageGrant is now diagnostic-only in the breadcrumb.
  • Rewrote the probe header comment and test expectations — the orphan + ALL APPLICATION PACKAGES shape is now asserted clean in both the probe suite and the recovery suite.
  • Updated fixtures and repair header comments to describe S-1-15-2-1 as a shape that "launches clean".

ℹ️ PR description now contradicts the code

The PR body's "What" (item 1) and the "Fix evidence" section still describe the old behavior — "The verdict now requires S-1-15-2-2 specifically" — which this commit undid. If the reversal stands, the body (and the Round 2 fix-evidence before/after quotes) should be updated so a reader doesn't infer the code still gates on -2.

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

// Capped: correlating the same orphan across reports is what would
// identify the tool that left it, which is the point of recording it.
orphanPackageSids: sanitizeCrashReportString(orphans.slice(0, 3).join(','), 200),
// The verdict rides on this one: either well-known grant satisfies the orphan.

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.

The verdict now lets S-1-15-2-1 (ALL APPLICATION PACKAGES) satisfy the orphan, but the LPAC children that crash don't see -1: their access check is against S-1-15-2-2. So an orphan plus only the Program Files-inherited -1 grant still leaves the renderer/GPU children locked out, yet is now reported matchesPoisonSignature: false — skipping both the repair and the dialog copy for the single most common poisoned shape this PR exists to fix.

Technical details
# Reverted poison gate under-triggers the most common poisoned shape

## Affected sites
- src/main/startup/windows-install-dir-acl-probe.ts:174 — `poisoned` now uses `!f.hasWellKnownPackageGrant`, so `S-1-15-2-1` clears the signature.
- src/main/startup/windows-install-dir-acl-probe.ts:186,193 — the breadcrumb comment marks `hasWellKnownPackageGrant` as "the verdict" and `hasRestrictedPackageGrant` as diagnostic-only.
- src/main/startup/windows-install-dir-acl-probe.test.ts:81-92 — asserts the orphan + `ALL APPLICATION PACKAGES` shape is clean.
- src/main/startup/windows-install-dir-acl-recovery.test.ts:90-96 — asserts no repair and no dialog for that shape.

## Required outcome
- Reconcile the gate with the LPAC access-check semantics, or revert to the `!hasRestrictedPackageGrant` verdict from `95631a3e12`.

## Evidence the reversal is wrong
- Chromium's LPAC emulation removes `S-1-15-2-1` ACEs from the DACL precisely to simulate LPAC behavior (`sandbox/win/src/app_container_base.cc`, `AppContainerBase::AccessCheck` with `enable_low_privilege_app_container_` calls `SetDaclEntry(kAllApplicationPackages, kRevoke, ...)`).
- `TokenIsLessPrivilegedAppContainer` (NtDoc `phnt` headers) states the LPAC flag "replaces" the `ALL APPLICATION PACKAGES` (`S-1-15-2-1`) access check with `ALL RESTRICTED APPLICATION PACKAGES` (`S-1-15-2-2`), marked by the `WIN://NOALLAPPPKG` attribute.
- electron/electron#51761's reproducible remedy is the additive `S-1-15-2-2` grant; a `-1`-only DACL is not reported anywhere there as a fix.

## Internal inconsistency to check
- The new test comment at windows-install-dir-acl-probe.test.ts:83 concedes `-1` is "useless ... to an LPAC token" while still concluding the `-1`-only shape "launched clean". If `-1` is useless to the LPAC child, that shape should still crash — which suggests the "launched clean" observation came from a DACL that carried some other grant (e.g. `-2` elsewhere in the tree) or a test artifact, not from `-1` satisfying the child. Please post the actual `icacls` output of the directory *and* the module file that launched clean; if there is a `-2` grant on the module files, the gate should still require it.

## Open questions for the human
- Was the "launched clean" repro's DACL truly orphan + `S-1-15-2-1` only, on both the install root and the `ffmpeg.dll`/`libGLESv2.dll` module files the probe reads?

@nwparker

nwparker commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merge record: readiness + real-hardware validation passed

Readiness checklist: passed. Counsel adjudication: no P0/P1 findings after 1 fix round.

Real-hardware validation hosts:

  • awin — win32 10.0.26200 (the exact platform that produces the blank-window LPAC failure)
  • openclaw — Linux 7.0.0-28-generic (no-op path: confirms the repair adds zero work off win32)

Key evidence:

  • Gate correctness proven by before/after flip: reverting only the hasRestrictedPackageGrant gate line reproduces the bug exactly — expected [] to have a length of 2 but got +0, i.e. zero icacls calls on the most common poisoned shape (Program Files install inheriting ALL APPLICATION PACKAGES:(RX) plus an orphan S-1-15-2-<x>).
  • Locale heuristic proven by before/after flip: re-adding BUILTIN to ENGLISH_PRINCIPAL false-positives a healthy French install (expected [ … ] to have a length of +0 but got 2); dropping it takes both the writes and the accusatory dialog copy to zero.
  • 64 tests passing across all 5 affected suites, including the end-to-end probe→gate→icacls wiring and the manual-retry regression (serves a manual retry while the breaker stays open for the next crash).
  • Repair is additive only (/grant, never /grant:r), read+execute only, marker-guarded per install dir + app version, and fired off the critical path via setImmediate.
  • Gates: pnpm tc EXIT=0; pnpm run check:code-quality:changed 0 new findings across 11 files; oxfmt clean.

CI: all PR Checks green on bfdcb63 — typecheck, static analysis, package, package (windows), tests node 24 1–8/8, LoC guard, root directory guard, plus pullfrog and Greptile. mergeStateStatus: CLEAN.

Merging.

@nwparker
nwparker merged commit 28373fc into main Sep 1, 2026
29 checks passed
@nwparker
nwparker deleted the nwparker/crashfix-g1-windows-acl branch September 1, 2026 04:15
nwparker added a commit that referenced this pull request Sep 3, 2026
…nderer is decidable (#18367)

* fix(windows): refuse tree-kills of Orca's own Chromium pids and record the rest

G2 is 20 field reports that share only a symptom. It is at least four
fingerprints: ~15 Windows `reason=killed exitCode=1`, 3 POSIX SIGKILL under
memory pressure (G4-oom), 2 duplicate reports of one macOS V8 Proxy Resolver
SIGKILL, and 1 `0x80000003` install-dir ACL crash (G1; #17740 ships in
v1.4.196 only, not 1.4.195). Nothing here claims to fix all of them.

Two changes:

1. Behaviour. `classifyWindowsTreeKillTarget` returns `own` for any direct
   child of the main process — which our renderer, GPU and network-service
   utility all are — so PTY teardown could `taskkill /T /F` Orca's own UI
   (#10680). Both that classifier and `terminateWindowsProcessTree` now refuse
   any pid Electron is currently accounting for in `getAppMetrics()`.

2. Diagnosis. An Orca-issued kill and an external one are byte-identical in
   every field the crash report records today, so the cluster is undecidable.
   Every main-process force-kill choke point now records a durable
   `self_tree_kill` breadcrumb, and `process_gone` reports carry
   `selfInitiatedTreeKills` naming the pid and its offset from the death.
   A refused kill records `self_tree_kill_refused_own_chromium`, which is
   falsifiable: if it ever shows up in the field, we were the killer.

* fix(crash-reporting): coalesce self-kill breadcrumbs and scope the discriminator

Round-1 review remediation. Three blocking findings, all accepted.

1. Breadcrumb flood (accepted). recordSelfInitiatedTreeKill wrote an
   uncoalesced durable crumb from two routine teardown paths, and the
   reviewer reproduced 12 terminal closes x 3 process groups completely
   evicting the 30-slot ring — including this PR's own refusal crumb — plus a
   forced writeSync per killed group. It now uses the existing
   recordCoalescedDurableCrashBreadcrumb (5s window for pid-addressed
   taskkills, 60s for routine group/job teardown), so a burst costs one ring
   slot and one flush. The refusal crumb is coalesced per victim pid, so a
   retry loop cannot flood while a distinct pid always gets its own crumb.
   Regression test replays the reviewer's exact 12x3 reproduction and asserts
   the refusal crumb and a pre-existing gpu_process_crashed both survive.

2. Undifferentiated count (accepted). posix-process-group and win-pty-job are
   structurally incapable of reaching a Chromium process, and scope was absent
   from the persisted string. Scope is now in every entry
   (`<scope>/<site>/pid<N> +Nms`), and the count is split:
   selfInitiatedTreeKillCount now counts only pid-addressed taskkills — the
   kills that can land on a recycled pid that is now our renderer — with
   pty-scoped sweeps in selfInitiatedGroupKillCount. The list is renamed
   selfInitiatedKills because it carries both, and sorts pid-addressed kills
   first so truncation never drops the discriminating ones for teardown noise.
   The reviewer's repro (routine macOS terminal close + unrelated exit-133
   crash) now yields selfInitiatedTreeKillCount undefined.

3. Recording gaps and a false comment (accepted). New
   admitSelfInitiatedTreeKill gate: it refuses own-Chromium pids and records
   the rest, and all three main-process taskkill families now go through it —
   terminateWindowsProcessTree plus codex-accounts/service.ts and
   claude-accounts (which keep their own spawn lifetimes). The false "single
   taskkill choke point" comment is gone. The runProcess choke point the
   investigation asked for is instrumented via a
   setProcessTreeKillObserver seam in src/shared/child-process — shared code
   runs in the CLI and relay so it cannot import the main breadcrumb store —
   registered in main preflight. The codex app-server POSIX group teardowns
   and the claude POSIX branch record too. The module doc no longer claims
   absence is discriminating: it enumerates what is instrumented and names the
   direct process.kill(-pid) sites that are not.

Non-blocking, also fixed:
- Breadcrumb calls moved out of the try blocks whose catch is the ESRCH
  contract (posix-pty-process-groups, codex teardown, claude POSIX), so a
  throw from the diagnostic path can never be reported as a failed kill.
- Detail truncation now bounds the first entry too, matching its comment.
- own-chromium-tree-kill-refusal.test.ts renamed to
  own-chromium-tree-kill-guard.test.ts, colocated with the module it tests.

Not changed, with reasons:
- Date.now() vs performance.now(): kept. Offsets are computed against
  goneAt = Date.now() in process-gone-recorder; a monotonic clock here would
  make the offsets meaningless. The reviewer verified this and agreed it is
  not a defect.
- app.getAppMetrics() per force-kill remains unbenchmarked. It reads
  in-process browser state rather than enumerating the OS process table, and a
  TTL cache would let a recycled pid slip past the refusal, so it stays
  uncached.
- The ~15 remaining direct process.kill(-pid) sites (browser routes,
  notebooks, automation prechecks, ephemeral VM recipes) are not instrumented.
  Rather than claim coverage this PR does not have, the module doc names them.

claude-command-process.ts crossed the 300-line cap, so terminateClaudeProcess
moved to claude-login-process-termination.ts. No max-lines suppression added.

* fix(crash-reporting): scope the self-kill guard to its real host topology

Round-2 review findings on the own-Chromium tree-kill guard.

BLOCKING 1 — "the own-Chromium refusal is a no-op in the process that issues
the pty-descendant-sweep taskkill". Correct on the mechanism, wrong on the
consequence; REBUTTED in part and documented in full.

Confirmed: the only non-test `setAppEnvironment` installs are
main-process-preflight.ts:177 (Electron) and orcad-entry.ts:84 (Node, whose
`getAppMetrics()` is `[]`); daemon-init-fresh-import.ts is a test harness. So
in the standalone daemon `readOrcaChromiumProcessPids()` is empty and
`admitSelfInitiatedTreeKill` always admits.

But that is not a live hazard. `killWithDescendantSweep` reaches
`terminateWindowsProcessTree` only when `verifyWindowsTreeKillTarget` returns
`own`, and that walks ancestry back to `deps.ownerPid ?? process.pid` — the
KILLING process's pid. In the daemon that is the daemon's pid. Orca's Chromium
processes are children of Electron main, a sibling of the daemon, so their
chain never reaches it: hop 0 lands on main, and within MAX_ANCESTOR_HOPS the
walk dead-ends and returns `foreign`. The reviewer's probe passes
`ownerPid: 1000` with the renderer as a direct child of 1000 — that is the
Electron-main topology, where the AppEnvironment IS installed and the guard DOES
fire, not the daemon's. On an orcad/SSH host there is no Chromium on the box at
all, so `[]` is accurate rather than degraded.

Locked in as tests rather than prose (own-chromium-tree-kill-guard.test.ts):
a renderer classifies `foreign` from a daemon ownerPid with an empty pid set,
and `own` from main's ownerPid with an empty set — the falsifiable pair showing
the pid set is load-bearing in main and nowhere else. Documented the host
coverage in orca-chromium-process-pids.ts and own-chromium-tree-kill-guard.ts.

One genuine hole the finding exposes: `signalProcessTree`'s `taskkillTree` is a
fourth pid-addressed taskkill family (non-blocking item 2), it runs in the
daemon/relay/CLI where the guard cannot run, and it guarded only on
`!child.pid`. Reusing the predicate the codex login teardown already uses, the
win32 branch now refuses a reaped child and falls back to `killRoot` — the same
shape as the existing `!child.pid` branch. That closes the reaped-then-recycled
pid path in every host.

BLOCKING 2 — module doc overstates coverage. Rewritten: the ring is per-process
and its only reader lives in Electron main, so a count on a `render-process-gone`
covers main-issued kills only. Sites are now split into main-only, main-and-
other-hosts (runProcess choke point, POSIX PTY group sweep, Windows Job Object —
which record into a ring nothing reads when they run in the daemon or relay),
and never-instrumented, with the note that a daemon/relay omission is a
diagnostics gap, not a missed suspect, per the topology argument above.

BLOCKING 3 — the three out-of-main instrumentation sites were untested. Added
regression coverage: the runProcess seam on both branches plus the reaped-child
refusal (process-tree-termination.test.ts), the group sweep recording only
groups it actually signalled and skipping an ESRCH group
(posix-pty-process-groups.test.ts), and the Job Object recording the shell pid
only on `terminated` (windows-pty-job.test.ts). Verified red: reverting the
three production files to origin/main fails 7 of the new tests.

BLOCKING 4 — the Windows evidence validates a single-process model. Accepted.
The main2.js arms exercise `pty-descendant-sweep` inside one Electron process;
that models the in-process/degraded daemon and the local PTY provider, not the
standalone daemon. Arm C's "the 449351d6 shape is not producible with the guard"
holds for main-issued kills only. In the daemon the shape is blocked one layer
earlier, by the ancestry check, which the arms do not exercise.

NON-BLOCKING taken: `recordSelfInitiatedTreeKill` moved outside the native
`terminateJob` try in windows-pty-job.ts, so a diagnostics throw can no longer
downgrade a real termination to `unavailable` and escalate callers to a broader
kill; covered by a test. The "all three families" parenthetical is gone with the
doc rewrite. `pnpm build:relay` run: exit 0, all seven targets built.

NON-BLOCKING declined: codex-accounts/service.ts records before the spawn
because a refusal must prevent the spawn — the crumb means "we were about to
kill this pid", which is the artifact worth having; the existing comment already
says so. `app.getAppMetrics()` perf is unbenchmarked and unchanged by this round.

Verification: pnpm tc clean; oxlint clean on touched paths;
check:code-quality:changed 0 new findings; oxfmt applied. 730 tests pass across
shared/child-process, main/crash-reporting, main/pty, main/windows and the guard
and descendant-sweep suites. The 4 failures in providers/git/codex-integration
reproduce on HEAD without these changes.

* fix(crash-reporting): keep the reaped-pid skip from flipping the termination barrier

The win32 hasExited short-circuit correctly avoids taskkill on a pid Windows
may have reissued, but it resolved `true` — verified tree termination. A
taskkill against a reaped pid already resolved `false`, and run-process turns
`true` into barrierTerminationVerified + terminationReporter.report(), which
releases the git admission grant on root exit instead of on `close`. That
admits the next git command while a descendant holding the inherited pipes is
still writing the repo. Resolve `false` so the skip changes only which process
we refuse to signal, not what the barrier claims.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ow (stablyai#17740)

* fix(windows): repair the install-dir package ACL that blanks the window

An install tree carrying an orphan AppContainer ACE (S-1-15-2-<x>) with no
ALL RESTRICTED APPLICATION PACKAGES grant denies Chromium's LPAC children read
on the shipped modules; they die at init with 0x80000003 and the window stays
blank forever (electron/electron#51761).

- Tighten the probe verdict to require the S-1-15-2-2 grant specifically: an
  ALL APPLICATION PACKAGES (S-1-15-2-1) ACE, the Program Files default, does
  not appear in an LPAC token and cannot satisfy the orphan.
- Drop BUILTIN from the English-locale heuristic (fr-FR/es-ES print it
  verbatim) so a localized icacls is correctly reported as un-name-checkable.
- Add an additive, marker-guarded icacls self-repair: an inheritable root
  grant plus a flagless (RX) /T pass, never /grant:r.
- Route the crash-loop dialog through a testable prompt module that names the
  permission cause, offers Copy Commands without dismissing itself, and keeps
  the graphics-driver hint.

The repair only runs on win32, off serve mode, and only on the exact probe
verdict that reproduced the crash.

* docs(windows): correct the install-tree ACL walk cost model

* fix(windows): keep the install-ACL poison gate at the reproduced shape

An orphan package ACE alongside the Program Files ALL APPLICATION
PACKAGES default launches clean on win32 10.0.26200 / Electron 43.4.1,
so requiring S-1-15-2-2 specifically declared poison on healthy installs
- and this branch acts on that verdict with a tree-wide icacls write and
the crash-recovery dialog's primary cause. hasRestrictedPackageGrant
stays reported for triage; only the verdict reverts.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…nderer is decidable (stablyai#18367)

* fix(windows): refuse tree-kills of Orca's own Chromium pids and record the rest

G2 is 20 field reports that share only a symptom. It is at least four
fingerprints: ~15 Windows `reason=killed exitCode=1`, 3 POSIX SIGKILL under
memory pressure (G4-oom), 2 duplicate reports of one macOS V8 Proxy Resolver
SIGKILL, and 1 `0x80000003` install-dir ACL crash (G1; stablyai#17740 ships in
v1.4.196 only, not 1.4.195). Nothing here claims to fix all of them.

Two changes:

1. Behaviour. `classifyWindowsTreeKillTarget` returns `own` for any direct
   child of the main process — which our renderer, GPU and network-service
   utility all are — so PTY teardown could `taskkill /T /F` Orca's own UI
   (stablyai#10680). Both that classifier and `terminateWindowsProcessTree` now refuse
   any pid Electron is currently accounting for in `getAppMetrics()`.

2. Diagnosis. An Orca-issued kill and an external one are byte-identical in
   every field the crash report records today, so the cluster is undecidable.
   Every main-process force-kill choke point now records a durable
   `self_tree_kill` breadcrumb, and `process_gone` reports carry
   `selfInitiatedTreeKills` naming the pid and its offset from the death.
   A refused kill records `self_tree_kill_refused_own_chromium`, which is
   falsifiable: if it ever shows up in the field, we were the killer.

* fix(crash-reporting): coalesce self-kill breadcrumbs and scope the discriminator

Round-1 review remediation. Three blocking findings, all accepted.

1. Breadcrumb flood (accepted). recordSelfInitiatedTreeKill wrote an
   uncoalesced durable crumb from two routine teardown paths, and the
   reviewer reproduced 12 terminal closes x 3 process groups completely
   evicting the 30-slot ring — including this PR's own refusal crumb — plus a
   forced writeSync per killed group. It now uses the existing
   recordCoalescedDurableCrashBreadcrumb (5s window for pid-addressed
   taskkills, 60s for routine group/job teardown), so a burst costs one ring
   slot and one flush. The refusal crumb is coalesced per victim pid, so a
   retry loop cannot flood while a distinct pid always gets its own crumb.
   Regression test replays the reviewer's exact 12x3 reproduction and asserts
   the refusal crumb and a pre-existing gpu_process_crashed both survive.

2. Undifferentiated count (accepted). posix-process-group and win-pty-job are
   structurally incapable of reaching a Chromium process, and scope was absent
   from the persisted string. Scope is now in every entry
   (`<scope>/<site>/pid<N> +Nms`), and the count is split:
   selfInitiatedTreeKillCount now counts only pid-addressed taskkills — the
   kills that can land on a recycled pid that is now our renderer — with
   pty-scoped sweeps in selfInitiatedGroupKillCount. The list is renamed
   selfInitiatedKills because it carries both, and sorts pid-addressed kills
   first so truncation never drops the discriminating ones for teardown noise.
   The reviewer's repro (routine macOS terminal close + unrelated exit-133
   crash) now yields selfInitiatedTreeKillCount undefined.

3. Recording gaps and a false comment (accepted). New
   admitSelfInitiatedTreeKill gate: it refuses own-Chromium pids and records
   the rest, and all three main-process taskkill families now go through it —
   terminateWindowsProcessTree plus codex-accounts/service.ts and
   claude-accounts (which keep their own spawn lifetimes). The false "single
   taskkill choke point" comment is gone. The runProcess choke point the
   investigation asked for is instrumented via a
   setProcessTreeKillObserver seam in src/shared/child-process — shared code
   runs in the CLI and relay so it cannot import the main breadcrumb store —
   registered in main preflight. The codex app-server POSIX group teardowns
   and the claude POSIX branch record too. The module doc no longer claims
   absence is discriminating: it enumerates what is instrumented and names the
   direct process.kill(-pid) sites that are not.

Non-blocking, also fixed:
- Breadcrumb calls moved out of the try blocks whose catch is the ESRCH
  contract (posix-pty-process-groups, codex teardown, claude POSIX), so a
  throw from the diagnostic path can never be reported as a failed kill.
- Detail truncation now bounds the first entry too, matching its comment.
- own-chromium-tree-kill-refusal.test.ts renamed to
  own-chromium-tree-kill-guard.test.ts, colocated with the module it tests.

Not changed, with reasons:
- Date.now() vs performance.now(): kept. Offsets are computed against
  goneAt = Date.now() in process-gone-recorder; a monotonic clock here would
  make the offsets meaningless. The reviewer verified this and agreed it is
  not a defect.
- app.getAppMetrics() per force-kill remains unbenchmarked. It reads
  in-process browser state rather than enumerating the OS process table, and a
  TTL cache would let a recycled pid slip past the refusal, so it stays
  uncached.
- The ~15 remaining direct process.kill(-pid) sites (browser routes,
  notebooks, automation prechecks, ephemeral VM recipes) are not instrumented.
  Rather than claim coverage this PR does not have, the module doc names them.

claude-command-process.ts crossed the 300-line cap, so terminateClaudeProcess
moved to claude-login-process-termination.ts. No max-lines suppression added.

* fix(crash-reporting): scope the self-kill guard to its real host topology

Round-2 review findings on the own-Chromium tree-kill guard.

BLOCKING 1 — "the own-Chromium refusal is a no-op in the process that issues
the pty-descendant-sweep taskkill". Correct on the mechanism, wrong on the
consequence; REBUTTED in part and documented in full.

Confirmed: the only non-test `setAppEnvironment` installs are
main-process-preflight.ts:177 (Electron) and orcad-entry.ts:84 (Node, whose
`getAppMetrics()` is `[]`); daemon-init-fresh-import.ts is a test harness. So
in the standalone daemon `readOrcaChromiumProcessPids()` is empty and
`admitSelfInitiatedTreeKill` always admits.

But that is not a live hazard. `killWithDescendantSweep` reaches
`terminateWindowsProcessTree` only when `verifyWindowsTreeKillTarget` returns
`own`, and that walks ancestry back to `deps.ownerPid ?? process.pid` — the
KILLING process's pid. In the daemon that is the daemon's pid. Orca's Chromium
processes are children of Electron main, a sibling of the daemon, so their
chain never reaches it: hop 0 lands on main, and within MAX_ANCESTOR_HOPS the
walk dead-ends and returns `foreign`. The reviewer's probe passes
`ownerPid: 1000` with the renderer as a direct child of 1000 — that is the
Electron-main topology, where the AppEnvironment IS installed and the guard DOES
fire, not the daemon's. On an orcad/SSH host there is no Chromium on the box at
all, so `[]` is accurate rather than degraded.

Locked in as tests rather than prose (own-chromium-tree-kill-guard.test.ts):
a renderer classifies `foreign` from a daemon ownerPid with an empty pid set,
and `own` from main's ownerPid with an empty set — the falsifiable pair showing
the pid set is load-bearing in main and nowhere else. Documented the host
coverage in orca-chromium-process-pids.ts and own-chromium-tree-kill-guard.ts.

One genuine hole the finding exposes: `signalProcessTree`'s `taskkillTree` is a
fourth pid-addressed taskkill family (non-blocking item 2), it runs in the
daemon/relay/CLI where the guard cannot run, and it guarded only on
`!child.pid`. Reusing the predicate the codex login teardown already uses, the
win32 branch now refuses a reaped child and falls back to `killRoot` — the same
shape as the existing `!child.pid` branch. That closes the reaped-then-recycled
pid path in every host.

BLOCKING 2 — module doc overstates coverage. Rewritten: the ring is per-process
and its only reader lives in Electron main, so a count on a `render-process-gone`
covers main-issued kills only. Sites are now split into main-only, main-and-
other-hosts (runProcess choke point, POSIX PTY group sweep, Windows Job Object —
which record into a ring nothing reads when they run in the daemon or relay),
and never-instrumented, with the note that a daemon/relay omission is a
diagnostics gap, not a missed suspect, per the topology argument above.

BLOCKING 3 — the three out-of-main instrumentation sites were untested. Added
regression coverage: the runProcess seam on both branches plus the reaped-child
refusal (process-tree-termination.test.ts), the group sweep recording only
groups it actually signalled and skipping an ESRCH group
(posix-pty-process-groups.test.ts), and the Job Object recording the shell pid
only on `terminated` (windows-pty-job.test.ts). Verified red: reverting the
three production files to origin/main fails 7 of the new tests.

BLOCKING 4 — the Windows evidence validates a single-process model. Accepted.
The main2.js arms exercise `pty-descendant-sweep` inside one Electron process;
that models the in-process/degraded daemon and the local PTY provider, not the
standalone daemon. Arm C's "the 449351d6 shape is not producible with the guard"
holds for main-issued kills only. In the daemon the shape is blocked one layer
earlier, by the ancestry check, which the arms do not exercise.

NON-BLOCKING taken: `recordSelfInitiatedTreeKill` moved outside the native
`terminateJob` try in windows-pty-job.ts, so a diagnostics throw can no longer
downgrade a real termination to `unavailable` and escalate callers to a broader
kill; covered by a test. The "all three families" parenthetical is gone with the
doc rewrite. `pnpm build:relay` run: exit 0, all seven targets built.

NON-BLOCKING declined: codex-accounts/service.ts records before the spawn
because a refusal must prevent the spawn — the crumb means "we were about to
kill this pid", which is the artifact worth having; the existing comment already
says so. `app.getAppMetrics()` perf is unbenchmarked and unchanged by this round.

Verification: pnpm tc clean; oxlint clean on touched paths;
check:code-quality:changed 0 new findings; oxfmt applied. 730 tests pass across
shared/child-process, main/crash-reporting, main/pty, main/windows and the guard
and descendant-sweep suites. The 4 failures in providers/git/codex-integration
reproduce on HEAD without these changes.

* fix(crash-reporting): keep the reaped-pid skip from flipping the termination barrier

The win32 hasExited short-circuit correctly avoids taskkill on a pid Windows
may have reissued, but it resolved `true` — verified tree termination. A
taskkill against a reaped pid already resolved `false`, and run-process turns
`true` into barrierTerminationVerified + terminationReporter.report(), which
releases the git admission grant on root exit instead of on `close`. That
admits the next git command while a descendant holding the inherited pipes is
still writing the repo. Resolve `false` so the skip changes only which process
we refuse to signal, not what the barrier claims.
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