orca/docs
Lesley Murfin 4d6c291eff
fix(windows): stop main-thread PowerShell ACL storm on env-store reads (#5011)
* fix(windows): stop main-thread PowerShell storm on env-store reads

Two changes fix the v1.4.52+ Windows performance regression (#4901 regression
against #4840) where 49 powershell.exe processes were spawned in 27 seconds
during load, saturating the Electron main thread and causing black terminals
and runtimeEnvironments:call timeouts.

Root cause: `readEnvironmentStore` calls `hardenExistingSecureFile` on every
read. The env-store parent directory's mtime churns constantly (every secure
write updates it), so the mtime-keyed idempotency cache never matched →
`bestEffortRestrictWindowsPath` (powershell, ~1-1.5s synchronous) fired on
every call. After #4901, the remote-runtime tab-sync loop reads the store
~2×/s, turning sporadic mtime misses into a continuous main-thread storm.

Fix 1 – path-cached directory hardening: add `hardenedDirectoryPathsThisProcess
(Set<string>)` that caches directory hardening by PATH for the process lifetime.
A directory's required ACL does not change when its mtime changes; only file
hardening retains the metadata-keyed cache so post-rename inode changes are
detected correctly.

Fix 2 – async ACL application: replace `execFileSync(powershell.exe, ...)` with
`execFile` (fire-and-forget). PowerShell cold-start is ~1-1.5s; the function is
already named `bestEffortRestrictWindowsPath` so async/optimistic caching is
correct. `applySecurePathRestriction` returns `true` optimistically on win32 so
the cache entry is written before the background process completes.

Tests: new regression tests verify the directory is hardened exactly once even
when its mtime changes between calls, that unchanged files are not re-hardened,
and that ACL application goes through async execFile (not execFileSync).

* fix(windows): apply credential-file ACL synchronously on write path

Follow-up rigor on the env-store PowerShell ACL storm fix (#5006). The
read-path storm fix (path-cached async directory hardening + async file
re-harden) is retained, but switching ALL ACL application to async opened a
narrow Windows-only security window: because writeFileSync({mode}) is a no-op
on Windows, writeSecureFile returned with the credential file still carrying
the parent directory's inherited (broader) ACL for the ~1-1.5s PowerShell
cold-start, affecting the e2ee keypair, device registry, and runtime env auth
store.

Fix: apply the credential FILE's ACL synchronously (execFileSync) on the
infrequent write path, before the atomic rename publishes it, and cache the
path as hardened only on confirmed success so a failed apply retries. Keep the
DIRECTORY hardening async + path-cached for the process lifetime (that is what
killed the #4901/#5006 main-thread storm). The read path's existing-file
re-harden stays async + metadata-cached (fires at most once per file, no storm).

Also:
- Document the dir-path cache process-lifetime known limitation (deleted+
  recreated dir not re-hardened until restart).
- Remove the redundant double dir-cache write in writeSecureFile.
- Add docs/windows-secure-file-acl-hardening.md describing the sync-file/
  async-dir model and a manual Windows e2e test plan (the cross-platform
  Playwright harness runs on Linux and cannot reach the PowerShell path).

Tests (src/shared/secure-file.test.ts, 13 passing): credential file hardened
synchronously while dir stays async (no async file-ACL window); failed sync
file-ACL apply is not cached and retries; dir hardened exactly once across many
writes despite mtime churn; no PowerShell spawned on non-win32.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: keep POSIX secure directory hardening metadata-aware

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
2026-06-09 01:47:29 -07:00
..
assets Update README feature showcase hero 2026-06-09 00:13:44 -07:00
readme Update mobile download links to 0.0.12 2026-06-04 16:11:51 -04:00
reference fix: address review findings (#4865) 2026-06-07 22:17:52 -07:00
STYLEGUIDE.md Update UI style guide 2026-06-08 20:25:32 -07:00
automations-navigation-stack.md
compact-worktree-card-setting-graduation.md Graduate compact worktree card setting (#4924) 2026-06-08 17:37:11 -07:00
configurable-open-in-menu.md
droid-orchestration-group.md Add Droid orchestration routing (#4624) 2026-06-04 10:00:11 -07:00
failed-automation-rerun-action.md Add failed automation rerun action (#2913) 2026-05-27 11:28:16 -07:00
floating-terminal-panel-position-persistence.md fix: persist floating terminal panel bounds (#3828) 2026-05-30 11:59:19 -07:00
image-viewer-pinch-zoom.md Add image viewer pinch zoom (#3531) 2026-05-31 14:07:15 -07:00
linear-issues-load-more.md Add Linear issue load more (#4437) 2026-06-01 23:35:47 -07:00
linear-scope-selector.md Improve Linear scope selection (#3850) 2026-05-30 12:55:13 -07:00
new-worktree-sidebar-reveal.md Reveal new worktrees in sidebar (#2804) 2026-05-25 18:40:19 -07:00
orchestration-reset-scope-validation.md Validate orchestration reset scope (#2960) 2026-05-27 21:40:33 -04:00
persist-tree-view-source-control.md
refresh-github-issues-after-create.md Refresh GitHub issues after creation (#3018) 2026-05-28 21:14:58 -04:00
remote-web-paste-activity-fixes.md Fix remote paste and workspace activity (#3521) 2026-05-30 03:35:56 -04:00
renderer-memory-profile-2026-06-01.md Handle ANSI redraw controls in terminal previews (#4418) 2026-06-01 16:21:11 -07:00
show-full-tab-title-tooltip.md Show full tab titles in tab tooltips (#2986) 2026-05-28 11:16:32 -07:00
ssh-config-target-compatibility.md Improve SSH config target handling (#3899) 2026-05-30 13:10:39 -07:00
ssh-handler-reregistration-port-forwards.md Fix SSH handler re-registration port forwards (#2963) 2026-05-27 21:04:30 -07:00
terminal-main-owned-state.md Recover hidden terminal output from main-owned state (#2848) 2026-05-26 16:01:56 -07:00
windows-secure-file-acl-hardening.md fix(windows): stop main-thread PowerShell ACL storm on env-store reads (#5011) 2026-06-09 01:47:29 -07:00
worktree-delete-preflight.md
worktree-sidebar-drag-autoscroll.md Add workspace sidebar drag autoscroll (#3027) 2026-05-28 21:52:08 -07:00