Skip to content

fix(windows): restore a CIM fallback for relay hosts with no native binding - #16550

Merged
nwparker merged 1 commit into
mainfrom
fix-1.4.189-rc-final-scan-findings
Aug 26, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix-1.4.189-rc-final-scan-findings

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca needs to know what program is actually running inside a terminal pane — is that Claude, or Codex, or just a plain shell sitting at a prompt? On Windows the only way to answer that is to ask the OS for the list of every running process and look at what's underneath the pane's shell.

There are two ways to ask Windows for that list:

  1. The fast way — a small compiled C++ add-on (@vscode/windows-process-tree) that asks the OS directly. Takes ~16 ms.
  2. The slow way — launch powershell.exe and have it run a Get-CimInstance Win32_Process query. Takes ~1.4 s and starts a whole extra process every time.

Orca used to do it the slow way. #15749 switched it to the fast way, which was the right call — the slow way was causing real damage (see "Why the fast way exists" below).

Here's what got missed. When you use Orca against a remote machine over SSH, Orca ships a small program called the relay to that machine and runs it there. The relay only installs two native add-ons on the remote host: node-pty and @parcel/watcher. Nobody added the new process-table add-on to that list.

So on a Windows machine used as an SSH host, the fast way isn't there at all. The code asks for it, doesn't find it, gives up — and because the slow way had been deleted, there's no way left to answer the question. Every pane on that machine falls back to reporting the shell's name instead of the agent's. Forever, until the relay restarts (and then it fails again).

This PR puts the slow way back, but only as a parachute: it's used exclusively on machines where the fast add-on isn't installed. Your local Windows machine still uses the fast way and is completely unaffected.

An analogy: #15749 replaced the stairs with an elevator. Great — except the elevator was never installed in the remote building, and the stairs had already been demolished. This rebuilds the stairs, and only in buildings with no elevator.


The bug in detail

#15749 moved the Windows process table onto @vscode/windows-process-tree. Relay deployment installs only node-pty and @parcel/watcher (RELAY_NATIVE_DEPS, src/main/ssh/ssh-relay-deploy.ts:700), and the addon isn't in the relay bundle's esbuild externals either (config/scripts/build-relay.mjs:81) — it's resolved at runtime through createRequire, so esbuild can't see it and the build succeeds while the runtime require fails.

The chain on a Windows SSH host:

src/relay/pty-shell-utils.ts:294,310   getForegroundProcessName
  → resolveWindowsAgentForegroundProcess
  → queryWindowsPaneProcessInventory     windows-foreground-process-rows.ts:56-68
  → readWindowsProcessTable              rejects: "windows process table unavailable"
  → catch → return null
  → falls back to node-pty's reported name

cachedModule latches null on first failure with no production re-probe, so it never recovers within the life of the relay process.

#15749 is not in v1.4.188 (git merge-base --is-ancestor 057fbfcffc9 v1.4.188 → false). It's in origin/adhoc/1.4.189-cherrypicks and is the only windows-process-table commit in that delta, so 1.4.189 is the first release that would carry this.

Verified on real Windows hardware

Windows 11 x64, 1486 processes, run from the actual deployed relay directory on a Windows SSH host (~/.orca-remote/relay-*, whose node_modules contains only @parcel/watcher, node-pty and transitives — no @vscode scope at all):

result
createRequire(...)('@vscode/windows-process-tree') MODULE_NOT_FOUND
require('node-pty') (control) resolves
before — windows-process-table.ts from main, bundled with the relay's esbuild externals nativeAvailable=false; rejects in 0 ms, "windows process table unavailable", every call
after — same bundle, with this change nativeAvailable=false; 1485 rows in 1.1–1.35 s, own pid present, claude.exe rows with full command lines

Also checked on that host: windowsPowerShellPath() resolves (SystemRoot=C:\WINDOWS), the absolute powershell.exe path exists and executes from the relay process, and the function has no Electron dependency. Separately, out/relay/win32-x64/relay.js was built and grepped to confirm the module really is in the shipped bundle with the require left as a runtime call.

Why not just add it to RELAY_NATIVE_DEPS

  • The package ships no prebuilds for arbitrary hosts, so it builds from source via node-gyp and needs MSVC + the Windows SDK + Python + Spectre-mitigated libs on every Windows SSH host. installNativeDeps throws on failure and the toolchain-skip retry is Linux-gated (ssh-relay-deploy.ts:1026 → throw at :1071), so Windows relay deploy would break outright.
  • pnpm patches don't cross SSH. Even where it built, the remote would get the unpatched 1024-process enumeration cap — the exact truncation perf(windows): read the process table natively instead of forking PowerShell #15749 was written to remove.

Why the fast way exists (what we must not undo)

The header of windows-process-table.ts records what the PowerShell reader cost. Seven independent readers each forked powershell.exe:

None of that changes for local Windows. This PR reintroduces PowerShell on relay hosts only, where the alternative is no answer at all.

The fix

Restore the Get-CimInstance Win32_Process scan in src/main/windows/windows-process-table-cim-scan.ts, engaged from windows-process-table.ts only when the module cannot be required. The gate is deliberately narrow:

  • absence only — a binding that loads but fails, wedges, or returns an unreadable table still rejects, so a blocked reader never starts forking a shell at the caller's poll rate;
  • a fallback that also fails still rejects, so "unavailable" never degrades into "nothing is running";
  • the scan keeps the native path's self-presence guard — a table missing our own pid is truncated or permission-filtered, not empty, and is rejected.

Constants (timeoutMs: 3000, maxOutputBytes: 8 MiB) match the pre-#15749 reader exactly (git show 057fbfcffc9^:src/main/providers/windows-foreground-process-rows.ts lines 6, 230–231). The scan goes through runProcess, which pins windowsHide (no flashing console windows) and kills the child on timeout — so it self-heals and doesn't need the native path's 30 s wedge cooldown, which guards a different failure mode (the vendored addon latches a global flag and leaks a callback per call).

memoryBytes is undefined on this path. It has zero consumers — grep finds only an unrelated local in src/main/memory/collector.ts.

The ratchet

src/main/ssh/relay-native-dependency-coverage.test.ts reads the real esbuild module graph from the relay entry and asserts every native addon it reaches is either in RELAY_NATIVE_DEPS or listed with the reason its absence is safe.

This is the test that should have existed before #15749. Its relay tests passed because they inject a fake module through __setWindowsProcessTreeLoaderForTests, so nothing ever exercised the real require.

Confirmed non-vacuous: removing the DEGRADES_WITHOUT_INSTALL entry fails it with expected [ '@vscode/windows-process-tree' ] to deeply equal [].


User-facing trade-offs

Who is affected: only people using a Windows machine as an SSH remote host. Local Windows, macOS, and Linux behavior is byte-for-byte unchanged — the native path is still taken everywhere it exists.

What gets better on those hosts:

  • Agent panes identify correctly again (claude, codex, …) instead of showing the shell name. This also restores anything keyed off agent identity — pane titles, agent status, and idle/working detection.
  • Port-panel rows regain process-name and command-line attribution (local-workspace-port-scanner.ts:499).
  • verifyWindowsTreeKillTarget can answer again, so the taskkill /T /F at pty-descendant-termination.ts:275 resumes running. On main it always answers unknown, which is not permission to kill, so descendants that escaped the pane's job object survive teardown. (The job-object path runs first and normally covers this, so it's a secondary effect.)

What gets worse on those hosts — the real cost:

Trade-off Detail
A powershell.exe spawn every ~1.4–1.9 s Only while agent panes are actively being watched. Bounded by a 500 ms TTL + single-flight cache, so the ceiling is roughly 30–45 scans/min no matter how many panes are open.
CPU on the remote host Each scan is a PowerShell cold start plus a WMI query — ~1.4 s of work at 1486 processes. Noticeable on a small or busy remote box.
PowerShell Transcription logging If the host has Transcription enabled by Group Policy, every one of those scans gets written to disk. This is the #15209 exposure, and it returns on relay hosts only. Orgs running that policy on their SSH hosts should know.
Slower identity refresh Agent detection on relay hosts refreshes off a ~1.4 s scan rather than a ~16 ms one, so a pane's title can lag a fast agent switch.
No console windows Not a trade-off — runProcess pins windowsHide, so nothing flashes on screen.

Where it still degrades (no worse than main): on a very busy host the scan can exceed the 3 s timeout or the 8 MiB output cap. At 1486 processes I measured 1.36 s and 4.76 MiB, so headroom is ~2× on time and ~1.7× on bytes. On overflow, createOutputSink truncates silently, the truncated JSON fails to parse, and the read rejects — degrading to today's behavior rather than reporting a wrong table. Both limits are exact 1.4.188 parity, not new.

The honest summary: this trades ~1.4 s of remote CPU every couple of seconds for agent recognition working at all on Windows SSH hosts. The native fast path stays unavailable there until prebuilds or a remote toolchain story is solved; that gap is documented in docs/reference/windows-process-enumeration.md.


Risk and rollback

Low. The change is additive and gated on a condition that is false on every machine that has the addon — local Windows takes an identical code path to main. On macOS/Linux the process.platform === 'win32' guard means the fallback is never even constructed.

To roll back, revert this commit; relay hosts return to reporting shell names.

Validation

  • pnpm tc clean
  • 821 tests pass across src/main/windows/, the new ratchet, src/relay/pty-shell-utils.test.ts, src/main/providers/, and the child-process import boundary
  • oxlint clean
  • full CI green, including package (windows), all 16 shards, e2e, and SSH docker watcher isolation
  • real-hardware before/after above

Scope note

This branch previously carried three unrelated changes at 616d2a4ec8c (now replaced): a worktree push-target remote-rollback fix, a dropdown-menu shadow CSS fix, and their tests. They were dropped so this stays a clean cherry-pick into the release.

The dropdown CSS bug is real and still on main — shadow-[0_12px_28px_rgba(0,0,0,0.22)],inset_...] has a stray )] that breaks the light-mode shadow, at src/renderer/src/components/ui/dropdown-menu.tsx:35 and :211. Both dropped changes deserve their own PRs.

Follow-ups (deliberately not in this PR)

  1. No failure cooldown on the CIM path. If PowerShell is blocked by policy, the scan retries at the caller's poll rate rather than backing off. Not added here because it's a deviation from the 1.4.188 behavior this PR is restoring, which is the whole safety argument for cherry-picking it. Worth adding on main.
  2. Widen the timeout / output cap. ~2× and ~1.7× headroom is thinner than the docs' 706 ms figure implies.
  3. Solve prebuilds for @vscode/windows-process-tree so relay hosts can have the fast path too.
  4. Stale doc figure. windows-process-enumeration.md quotes 706 ms p50 for the CIM scan, measured at 1050 processes; at 1486 it's 1.36 s.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown

Too many files changed for review (124 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@coderabbitai

coderabbitai Bot commented Aug 26, 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: Pro Plus

Run ID: 5161f5eb-1937-4c44-97d9-8cf256e59f49

📥 Commits

Reviewing files that changed from the base of the PR and between f72dcb9 and e4084a7.

📒 Files selected for processing (7)
  • docs/reference/windows-process-enumeration.md
  • src/main/ssh/relay-native-dependency-coverage.test.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/windows/windows-process-table-cim-scan.test.ts
  • src/main/windows/windows-process-table-cim-scan.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/windows/windows-process-table-cim-scan.ts
  • src/main/windows/windows-process-table-cim-scan.test.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/windows/windows-process-table.ts
  • src/main/ssh/relay-native-dependency-coverage.test.ts
  • src/main/windows/windows-process-table.test.ts

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


📝 Walkthrough

Walkthrough

The PR adds a PowerShell CIM fallback for Windows process enumeration when the native process-tree module is unavailable. It validates JSON output, process identifiers, command data, execution limits, and current-process presence. Tests cover parsing, fallback selection, native precedence, error propagation, and platform behavior. Relay dependency tests analyze reachable native addons and verify configured versions. Documentation records the fallback behavior and relay dependency coverage.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 142 functions across 56 files. (1 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides a detailed, relevant explanation of the bug, implementation, trade-offs, testing, and rollback plan, but it does not follow the repository template. It omits required section … Reformat the description to include every template section. Add a valid linked issue using the required “Fixes #” format, add “N/A” with a reason under Visual Proof if no visual change exists, complete or explicitly address AI Disclosure, R…
✅ 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 identifies the Windows CIM fallback and its purpose for relay hosts without the native binding.
Full details: Docstring Coverage

Explanation

Docstring coverage is 12.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 142 functions across 56 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description provides a detailed, relevant explanation of the bug, implementation, trade-offs, testing, and rollback plan, but it does not follow the repository template. It omits required section headings and content for Linked Issue, Visual Proof with an explicit N/A statement, AI Disclosure, Review, Agent skill upstream boundary, and Checklist.

Resolution

Reformat the description to include every template section. Add a valid linked issue using the required “Fixes #” format, add “N/A” with a reason under Visual Proof if no visual change exists, complete or explicitly address AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist, and place the testing details under Testing.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (6)
src/main/ipc/pty/provider/local-configure.ts (1)

104-106: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: drop the duplicate markClaudePtyExited call.

clearProviderPtyState already calls markClaudePtyExited(id). The repeat here (and in bind-listeners.ts, liveness.ts) suggests the guard is owned by two layers.

       clearProviderPtyState(id)
       ptyOwnership.delete(id)
-      markClaudePtyExited(id)
src/main/ipc/pty/provider/listener-lifecycle.ts (1)

97-106: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Null the references before invoking the unsubscribe callbacks.

If one unsubscribe throws, the later ones never run and the stale references remain, which re-creates the duplicate-listener leak described at Lines 3-6.

♻️ Proposed refactor
 export function unbindLocalProviderListeners(): void {
-  localDataUnsub?.()
-  localExitUnsub?.()
-  localBackgroundStreamUnsub?.()
-  localWriteUnavailableUnsub?.()
-  localDataUnsub = null
-  localExitUnsub = null
-  localBackgroundStreamUnsub = null
-  localWriteUnavailableUnsub = null
+  const unsubs = [
+    localDataUnsub,
+    localExitUnsub,
+    localBackgroundStreamUnsub,
+    localWriteUnavailableUnsub
+  ]
+  localDataUnsub = null
+  localExitUnsub = null
+  localBackgroundStreamUnsub = null
+  localWriteUnavailableUnsub = null
+  for (const unsub of unsubs) {
+    try {
+      unsub?.()
+    } catch (error) {
+      console.warn('[pty] provider listener unsubscribe failed', error)
+    }
+  }
 }
src/main/ipc/pty/ipc/spawn-env-codex.ts (1)

54-97: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the repeated Codex-home selection expression.

The same getCompatibleSelectedCodexHomePath(ctx.codexSelectionTarget, ctx.deps.getSelectedCodexHomePath?.(...)) shape appears four times with only launchAgent and unavailableManagedHomePath differing. A single local helper that takes those two values removes the duplication and keeps the argument list in one place.

src/main/ipc/pty/ipc/spawn-commit-persist.ts (1)

86-91: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Handle the missing registerPreAllocatedHandleForPty case.

ctx.agentTeamsLeaderHandle is cleared only when the runtime exposes registerPreAllocatedHandleForPty. If the method is absent, the pre-allocated handle is neither registered nor released, so the leader handle stays owned by nobody. Add an else branch that releases or explicitly retains the handle.

src/main/ipc/pty/host-env/path.ts (1)

28-29: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Reuse resolvePathEnvKey for the PATH key.

When env contains only path on Windows, the current logic writes PATH and leaves env.path unchanged. Windows uses the first case-insensitive key, so the shim can remain absent from the effective PATH.

♻️ Proposed refactor
-  const currentPathKey = env.PATH !== undefined || env.Path === undefined ? 'PATH' : 'Path'
+  const currentPathKey = resolvePathEnvKey(env, process.platform)
src/main/ipc/pty/ipc/spawn-begin.ts (1)

26-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Compute the pane key once.

initialPaneKey (Lines 26-35) and earlyPaneKey (Lines 62-71) use identical predicates and inputs. Extract one local pane-key resolution and reuse it for both the Codex-home snapshot and the reservation key.

♻️ Proposed refactor
-  const initialLeafId =
-    typeof args.leafId === 'string' && isTerminalLeafId(args.leafId) ? args.leafId : null
-  const initialPaneKey =
+  const leafId =
+    typeof args.leafId === 'string' && isTerminalLeafId(args.leafId) ? args.leafId : null
+  const paneKey =
     typeof args.worktreeId === 'string' &&
     typeof args.tabId === 'string' &&
     isValidTerminalTabId(args.tabId) &&
     args.tabId.length <= 512 &&
-    initialLeafId
-      ? makePaneKey(args.tabId, initialLeafId)
+    leafId
+      ? makePaneKey(args.tabId, leafId)
       : null

Then use paneKey at Lines 38, 72-76, and 89-98 and delete the early* duplicates.

Also applies to: 62-76


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f15cc56-245c-4622-ba27-bc08edc3b998

📥 Commits

Reviewing files that changed from the base of the PR and between b57b812 and 616d2a4ec8c58eacec32b4b65483d03e2e3fff56.

📒 Files selected for processing (124)
  • config/max-lines-baseline.txt
  • docs/reference/windows-process-enumeration.md
  • src/main/ipc/pty-applied-size-reporting.test.ts
  • src/main/ipc/pty-buffer-snapshot-dispatch.test.ts
  • src/main/ipc/pty-controller-spawn-admission.test.ts
  • src/main/ipc/pty-daemon-controller-teardown.test.ts
  • src/main/ipc/pty-daemon-ssh-lease-lifecycle.test.ts
  • src/main/ipc/pty-ipc-hidden-delivery-gate.test.ts
  • src/main/ipc/pty-ipc-producer-flow-control.test.ts
  • src/main/ipc/pty-listener-teardown-and-orphans.test.ts
  • src/main/ipc/pty-pane-claim-arbitration.test.ts
  • src/main/ipc/pty-pane-materialization-race.test.ts
  • src/main/ipc/pty-runtime-kill-and-exit.test.ts
  • src/main/ipc/pty-serializer-settlement-mapping.test.ts
  • src/main/ipc/pty-session-liveness-and-ownership.test.ts
  • src/main/ipc/pty-spawn-runtime-handle-binding.test.ts
  • src/main/ipc/pty-startup-barrier-ordering.test.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/pty/delivery/accept.ts
  • src/main/ipc/pty/delivery/accounting.ts
  • src/main/ipc/pty/delivery/constants.ts
  • src/main/ipc/pty/delivery/debug-snapshot.ts
  • src/main/ipc/pty/delivery/debug.ts
  • src/main/ipc/pty/delivery/exit.ts
  • src/main/ipc/pty/delivery/flush.ts
  • src/main/ipc/pty/delivery/hidden-transition.ts
  • src/main/ipc/pty/delivery/interactive.ts
  • src/main/ipc/pty/delivery/lifecycle-reset.ts
  • src/main/ipc/pty/delivery/payload.ts
  • src/main/ipc/pty/delivery/pending.ts
  • src/main/ipc/pty/delivery/producer-sync.ts
  • src/main/ipc/pty/delivery/ssh-intake.ts
  • src/main/ipc/pty/delivery/visibility-state.ts
  • src/main/ipc/pty/delivery/wire-session.ts
  • src/main/ipc/pty/host-env/assembly.ts
  • src/main/ipc/pty/host-env/codex-home.ts
  • src/main/ipc/pty/host-env/codex-resume.ts
  • src/main/ipc/pty/host-env/fresh-spawn-routing.ts
  • src/main/ipc/pty/host-env/path.ts
  • src/main/ipc/pty/host-env/pi-agent.ts
  • src/main/ipc/pty/host-env/spawn-cwd.ts
  • src/main/ipc/pty/host-env/spawn-env-keys.ts
  • src/main/ipc/pty/host-env/types.ts
  • src/main/ipc/pty/ipc/inspect.ts
  • src/main/ipc/pty/ipc/resize-visibility.ts
  • src/main/ipc/pty/ipc/serialize-buffer.ts
  • src/main/ipc/pty/ipc/snapshot.ts
  • src/main/ipc/pty/ipc/spawn-begin.ts
  • src/main/ipc/pty/ipc/spawn-commit-persist.ts
  • src/main/ipc/pty/ipc/spawn-commit.ts
  • src/main/ipc/pty/ipc/spawn-env-codex.ts
  • src/main/ipc/pty/ipc/spawn-env.ts
  • src/main/ipc/pty/ipc/spawn-execute.ts
  • src/main/ipc/pty/ipc/spawn-options.ts
  • src/main/ipc/pty/ipc/spawn-preflight.ts
  • src/main/ipc/pty/ipc/spawn-run.ts
  • src/main/ipc/pty/ipc/spawn-state.ts
  • src/main/ipc/pty/ipc/spawn-types.ts
  • src/main/ipc/pty/ipc/spawn.ts
  • src/main/ipc/pty/ipc/write-input.ts
  • src/main/ipc/pty/ipc/write.ts
  • src/main/ipc/pty/kill-all.ts
  • src/main/ipc/pty/pane/adopt-stable.ts
  • src/main/ipc/pty/pane/agent-session-owners.ts
  • src/main/ipc/pty/pane/key-state.ts
  • src/main/ipc/pty/pane/launch-authority.ts
  • src/main/ipc/pty/pane/serializer-state.ts
  • src/main/ipc/pty/pane/spawn-reservation.ts
  • src/main/ipc/pty/pane/stable-owner.ts
  • src/main/ipc/pty/provider/bind-listeners.ts
  • src/main/ipc/pty/provider/listener-lifecycle.ts
  • src/main/ipc/pty/provider/liveness.ts
  • src/main/ipc/pty/provider/local-configure.ts
  • src/main/ipc/pty/provider/ownership-state.ts
  • src/main/ipc/pty/provider/registry.ts
  • src/main/ipc/pty/provider/shutdown-detect.ts
  • src/main/ipc/pty/provider/state-cleanup.ts
  • src/main/ipc/pty/register-handlers.ts
  • src/main/ipc/pty/register-headless-runtime.ts
  • src/main/ipc/pty/runtime/controller-deps.ts
  • src/main/ipc/pty/runtime/controller.ts
  • src/main/ipc/pty/runtime/kill.ts
  • src/main/ipc/pty/runtime/operations.ts
  • src/main/ipc/pty/runtime/spawn-commit.ts
  • src/main/ipc/pty/runtime/spawn-early.ts
  • src/main/ipc/pty/runtime/spawn-execute.ts
  • src/main/ipc/pty/runtime/spawn-options.ts
  • src/main/ipc/pty/runtime/spawn-preflight.ts
  • src/main/ipc/pty/runtime/spawn-state.ts
  • src/main/ipc/pty/runtime/spawn.ts
  • src/main/ipc/pty/session.ts
  • src/main/ipc/worktree-push-target-setup.test.ts
  • src/main/ipc/worktree-push-target-setup.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees-ssh-fork-push-target-remote.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/skills/skill-upload-retained-paths.ts
  • src/main/skills/skill-upload-session-admission-regression.test.ts
  • src/main/skills/skill-upload-session-record.ts
  • src/main/skills/skill-upload-session-service.ts
  • src/main/ssh/relay-native-dependency-coverage.test.ts
  • src/main/ssh/ssh-connection-sftp-namespace.test.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/windows/windows-process-table-cim-scan.test.ts
  • src/main/windows/windows-process-table-cim-scan.ts
  • src/main/windows/windows-process-table.test.ts
  • src/main/windows/windows-process-table.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/settings/Settings.tsx
  • src/renderer/src/components/settings/SettingsSidebar.test.tsx
  • src/renderer/src/components/settings/SettingsSidebar.tsx
  • src/renderer/src/components/sidebar/sleep-worktree-activation-race.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.test.ts
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/ui/dropdown-menu.tsx
  • src/renderer/src/lib/active-agent-note-send.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/sidebar-worktree-activation.test.ts
  • src/renderer/src/lib/sidebar-worktree-activation.ts
  • src/renderer/src/runtime/host-live-terminal-probe.ts
  • src/renderer/src/runtime/host-session-mirror-empty-inventory-settle.test.ts
  • src/renderer/src/runtime/host-session-mirror-settle-census.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync-window-visibility.test.tsx
  • src/renderer/src/runtime/web-session-tabs-sync.ts
💤 Files with no reviewable changes (3)
  • src/renderer/src/components/settings/Settings.tsx
  • config/max-lines-baseline.txt
  • src/renderer/src/components/settings/SettingsSidebar.test.tsx

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

`src/main/ssh/relay-native-dependency-coverage.test.ts` asserts that every
native addon reachable from the relay entry is either installed on relay hosts
or listed there with the reason its absence is safe. That test exists because
#15749 shipped this gap: the relay tests injected a fake module through

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Keep the issue reference in the paragraph.

Line 65 begins with #15749, so Markdown renders it as a heading. Prefix it with issue or escape the hash.

🧰 Tools
🪛 markdownlint-cli2 (0.23.2)

[warning] 65-65: No space after hash on atx style heading

(MD018, no-missing-space-atx)

Source: Linters/SAST tools

Comment on lines +11 to +25
const runtimeSpawn =
readRepoSource('src/main/ipc/pty/runtime/spawn.ts') +
readRepoSource('src/main/ipc/pty/runtime/spawn-early.ts') +
readRepoSource('src/main/ipc/pty/runtime/spawn-preflight.ts')

const rendererSource =
readRepoSource('src/main/ipc/pty/ipc/spawn.ts') +
readRepoSource('src/main/ipc/pty/ipc/spawn-begin.ts') +
readRepoSource('src/main/ipc/pty/ipc/spawn-preflight.ts')
const rendererSpawnStart = rendererSource.indexOf("ipcMain.handle('pty:spawn'")
const rendererSpawn = rendererSource.slice(rendererSpawnStart)

for (const spawnBlock of [runtimeSpawn, rendererSpawn]) {
const barrierIndex = spawnBlock.indexOf(
'const startupPromise = getLocalPtyStartupPromise(args.connectionId)'
)
const providerIndex = spawnBlock.indexOf('const provider = getProvider(args.connectionId)')
const barrierIndex = spawnBlock.indexOf('getLocalPtyStartupPromise(args.connectionId)')
const providerIndex = spawnBlock.indexOf('getProvider(args.connectionId)')

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

Test invocation order, not concatenated source order. This assembly always places spawn-early.ts before spawn-preflight.ts, so the test can pass after a reversed runtime call order; block startup and assert provider resolution waits.

Comment on lines +180 to +192
const existingRawLength = existing.rawLength ?? existing.data.length
const next: PendingPtyData = {
data: existing.data + data,
...(!preservesSeq || existing.transformed || transformed
? { rawLength: existingRawLength + rawLength, transformed: true as const }
: {}),
...(nextContainsBackgroundOutput ? { containsBackgroundOutput: true } : {})
}
updatePendingProjectionAdmissions(next, projectionState)
if (typeof existing.startSeq === 'number') {
next.startSeq = existing.startSeq
}
return dropOversizedPendingPtyData(session, id, next)

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C4 '\bappendPendingPtyData\s*\(' --type=ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- applicable repository conventions ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
  case "$f" in
    *learnings*) continue ;;
    *) printf '\n### %s\n' "$f"; cat "$f" ;;
  esac
done
printf '%s\n' '--- pending.ts outline ---'
ast-grep outline src/main/ipc/pty/delivery/pending.ts
printf '%s\n' '--- changed area and nearby definitions ---'
cat -n src/main/ipc/pty/delivery/pending.ts | sed -n '130,225p'
printf '%s\n' '--- pending API references ---'
rg -n -C3 'appendPending|PendingPtyData|rawLength|preservesSeq' src/main/ipc/pty src --glob '*.{ts,tsx}'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- pending.ts symbols and relevant implementation ---'
ast-grep outline src/main/ipc/pty/delivery/pending.ts
cat -n src/main/ipc/pty/delivery/pending.ts | sed -n '1,225p'
printf '%s\n' '--- direct pending API references in main PTY code ---'
rg -n -C4 'PendingPtyData|pendingPty|appendPending|enqueuePending|preservesSeq|rawLength' src/main/ipc/pty --glob '*.{ts,tsx}' \
  -g '!**/*.test.ts' -g '!**/*.spec.ts'
printf '%s\n' '--- repository-owned convention files by path ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -not -path '*/learnings/*' -print

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- accept path ---'
cat -n src/main/ipc/pty/delivery/accept.ts | sed -n '50,180p'
printf '%s\n' '--- pending flush path ---'
cat -n src/main/ipc/pty/delivery/flush.ts | sed -n '140,205p'
printf '%s\n' '--- payload construction ---'
cat -n src/main/ipc/pty/delivery/payload.ts | sed -n '1,35p'
printf '%s\n' '--- rawLength producers with transformed metadata ---'
rg -n -C5 'sequenceChars|rawLength|transformed' src/main/ipc/pty/provider src/main/ssh-pty-output-intake.ts src/main --glob '*.{ts,tsx}' \
  -g '!**/*.test.ts' -g '!**/*.spec.ts' | head -n 260

Repository: stablyai/orca

Length of output: 30534


Preserve rawLength when merging pending PTY data.

When acceptPtyDataForRenderer first queues data with rawLength !== data.length and transformed === false, a later preserving append omits rawLength. The pending flush then derives the payload sequence from rendered length and loses the earlier sequence delta.

Comment on lines +183 to +196
restoreOrStripOverlayEnv(baseEnv, {
primary: 'PI_CODING_AGENT_DIR',
overlay: 'ORCA_PI_CODING_AGENT_DIR',
source: 'ORCA_PI_SOURCE_AGENT_DIR'
})
restoreOrStripOverlayEnv(baseEnv, {
primary: 'PI_CODING_AGENT_DIR',
overlay: 'ORCA_OMP_CODING_AGENT_DIR',
source: 'ORCA_OMP_SOURCE_AGENT_DIR'
})
delete baseEnv.ORCA_OMP_STATUS_EXTENSION
delete baseEnv.ORCA_PRIME_AGENT_SOURCE_AGENT_DIR
delete baseEnv.ORCA_PRIME_AGENT_STATUS_EXTENSION
}

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

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
ast-grep run --pattern 'export function restoreOrStripOverlayEnv($$$) { $$$ }' --lang typescript src/main/ipc/pty/host-env/pi-agent.ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- helper references ---'
rg -n --glob '*.ts' 'restoreOrStripOverlayEnv' src/main/ipc/pty/host-env
printf '%s\n' '--- assembly context ---'
sed -n '150,215p' src/main/ipc/pty/host-env/assembly.ts

Repository: stablyai/orca

Length of output: 3543


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- assembly import ---'
sed -n '1,40p' src/main/ipc/pty/host-env/assembly.ts
printf '%s\n' '--- helper implementation ---'
sed -n '125,180p' src/main/ipc/pty/host-env/pi-agent.ts

Repository: stablyai/orca

Length of output: 4376


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- exact source/overlay references ---'
rg -n --glob '*.{ts,tsx,js,jsx}' 'ORCA_(PI|OMP)_(SOURCE_AGENT_DIR|CODING_AGENT_DIR)|PI_CODING_AGENT_DIR' src shared
printf '%s\n' '--- preceding assembly calls ---'
sed -n '85,120p' src/main/ipc/pty/host-env/assembly.ts

Repository: stablyai/orca

Length of output: 26672


Handle the shared PI_CODING_AGENT_DIR cleanup in one decision. restoreOrStripOverlayEnv assigns primary from each call's source value, or deletes it when it matches that call's overlay. Therefore, the second call can overwrite the Pi value with ORCA_OMP_SOURCE_AGENT_DIR or delete it when the OMP overlay matches.

Comment on lines +91 to +110
if (session.mainWindow.isDestroyed()) {
return Promise.resolve(null)
}

const requestId = randomUUID()
return new Promise<SerializeResult>((resolve) => {
const timeout = setTimeout(() => {
settleSerializeRequest(session, requestId, null)
}, 750)
session.pendingSerializeRequests.set(requestId, { resolve, timeout })
const payload: {
requestId: string
ptyId: string
opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean }
} = { requestId, ptyId }
if (opts) {
payload.opts = opts
}
session.mainWindow.webContents.send('pty:serializeBuffer:request', payload)
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Treat a destroyed webContents like a destroyed window.

Line 91 returns null when the window is destroyed. Line 109 then sends on webContents without the same check. mainWindow.isDestroyed() can be false while the webContents is already destroyed during teardown, and send then throws. The throw escapes the Promise executor, so the caller sees a rejection instead of the documented null result.

🛡️ Proposed fix
 export function requestSerializedBuffer(
   session: PtyIpcSession,
   ptyId: string,
   opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean }
 ): Promise<SerializeResult> {
-  if (session.mainWindow.isDestroyed()) {
+  if (
+    session.mainWindow.isDestroyed() ||
+    (typeof session.mainWindow.webContents.isDestroyed === 'function' &&
+      session.mainWindow.webContents.isDestroyed())
+  ) {
     return Promise.resolve(null)
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (session.mainWindow.isDestroyed()) {
return Promise.resolve(null)
}
const requestId = randomUUID()
return new Promise<SerializeResult>((resolve) => {
const timeout = setTimeout(() => {
settleSerializeRequest(session, requestId, null)
}, 750)
session.pendingSerializeRequests.set(requestId, { resolve, timeout })
const payload: {
requestId: string
ptyId: string
opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean }
} = { requestId, ptyId }
if (opts) {
payload.opts = opts
}
session.mainWindow.webContents.send('pty:serializeBuffer:request', payload)
})
if (
session.mainWindow.isDestroyed() ||
(typeof session.mainWindow.webContents.isDestroyed === 'function' &&
session.mainWindow.webContents.isDestroyed())
) {
return Promise.resolve(null)
}
const requestId = randomUUID()
return new Promise<SerializeResult>((resolve) => {
const timeout = setTimeout(() => {
settleSerializeRequest(session, requestId, null)
}, 750)
session.pendingSerializeRequests.set(requestId, { resolve, timeout })
const payload: {
requestId: string
ptyId: string
opts?: { scrollbackRows?: number; altScreenForcesZeroRows?: boolean }
} = { requestId, ptyId }
if (opts) {
payload.opts = opts
}
session.mainWindow.webContents.send('pty:serializeBuffer:request', payload)
})

Comment on lines +32 to +47
export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null {
const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : ''
if (!isValidPaneKey(normalizedPaneKey)) {
return null
}
// Why: a re-registered ptyId would otherwise leave its old paneKey pointing here.
const previousPaneKey = ptyPaneKey.get(ptyId)
if (previousPaneKey && previousPaneKey !== normalizedPaneKey) {
if (paneKeyPtyId.get(previousPaneKey) === ptyId) {
paneKeyPtyId.delete(previousPaneKey)
}
}
ptyPaneKey.set(ptyId, normalizedPaneKey)
paneKeyPtyId.set(normalizedPaneKey, ptyId)
return normalizedPaneKey
}

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

Also clear the previous ptyId when a paneKey moves to a new PTY.

The function clears the stale reverse entry for a re-registered ptyId, but not the stale forward entry when the same paneKey moves from ptyId A to ptyId B. ptyPaneKey keeps A -> paneKey, so a later teardown of A runs the paneKey teardown listeners for a paneKey that B now owns and clears B's paneKey-scoped state.

🐛 Proposed fix
   ptyPaneKey.set(ptyId, normalizedPaneKey)
+  const previousPtyId = paneKeyPtyId.get(normalizedPaneKey)
+  if (previousPtyId && previousPtyId !== ptyId && ptyPaneKey.get(previousPtyId) === normalizedPaneKey) {
+    ptyPaneKey.delete(previousPtyId)
+  }
   paneKeyPtyId.set(normalizedPaneKey, ptyId)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null {
const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : ''
if (!isValidPaneKey(normalizedPaneKey)) {
return null
}
// Why: a re-registered ptyId would otherwise leave its old paneKey pointing here.
const previousPaneKey = ptyPaneKey.get(ptyId)
if (previousPaneKey && previousPaneKey !== normalizedPaneKey) {
if (paneKeyPtyId.get(previousPaneKey) === ptyId) {
paneKeyPtyId.delete(previousPaneKey)
}
}
ptyPaneKey.set(ptyId, normalizedPaneKey)
paneKeyPtyId.set(normalizedPaneKey, ptyId)
return normalizedPaneKey
}
export function rememberPaneKeyForPty(ptyId: string, paneKey: unknown): string | null {
const normalizedPaneKey = typeof paneKey === 'string' ? paneKey.trim() : ''
if (!isValidPaneKey(normalizedPaneKey)) {
return null
}
// Why: a re-registered ptyId would otherwise leave its old paneKey pointing here.
const previousPaneKey = ptyPaneKey.get(ptyId)
if (previousPaneKey && previousPaneKey !== normalizedPaneKey) {
if (paneKeyPtyId.get(previousPaneKey) === ptyId) {
paneKeyPtyId.delete(previousPaneKey)
}
}
ptyPaneKey.set(ptyId, normalizedPaneKey)
const previousPtyId = paneKeyPtyId.get(normalizedPaneKey)
if (previousPtyId && previousPtyId !== ptyId && ptyPaneKey.get(previousPtyId) === normalizedPaneKey) {
ptyPaneKey.delete(previousPtyId)
}
paneKeyPtyId.set(normalizedPaneKey, ptyId)
return normalizedPaneKey
}

Comment on lines +55 to +57
const sequenceBeforeProviderSpawn = expectedPtyId
? (ctx.deps.runtime?.getPtyOutputSequence?.(expectedPtyId) ?? 0)
: 0

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect the reconcile contract and its baseline argument.
rg -nP --type=ts -C 20 'synchronizePtyOutputSequenceFromProvider\s*\(' -g '!**/*.test.ts'

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- changed function context ---'
sed -n '1,230p' src/main/ipc/pty/runtime/spawn-execute.ts
printf '%s\n' '--- candidate definitions and calls ---'
rg -n -S 'synchronizePtyOutputSequence|snapshotKittyFlagsCoverReconciledSeq|spawnForStablePane|expectedPtyId|stablePaneOwnerCandidate' src/main

Repository: stablyai/orca

Length of output: 21354


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- runtime synchronization contract ---'
sed -n '12235,12325p' src/main/runtime/orca-runtime.ts
printf '%s\n' '--- stable-pane spawn flow ---'
sed -n '240,390p' src/main/ipc/pty/pane/stable-owner.ts
printf '%s\n' '--- focused sequence tests ---'
sed -n '9930,10100p' src/main/runtime/orca-runtime.test.ts

Repository: stablyai/orca

Length of output: 12079


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- remainder of synchronization contract ---'
sed -n '12305,12375p' src/main/runtime/orca-runtime.ts
printf '%s\n' '--- stable-owner retirement and fresh-spawn callers ---'
sed -n '1,320p' src/main/ipc/pty/pane/stable-owner.ts
printf '%s\n' '--- runtime-spawn tests and sequence assertions ---'
rg -n -C 12 'sequenceBeforeProviderSpawn|snapshotKittyFlagsCoverReconciledSeq|fresh.*spawn|stable.*owner|owner.*retir' src/main/ipc/pty/runtime src/main/ipc/pty/pane --glob '*test.ts'

Repository: stablyai/orca

Length of output: 13680


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- snapshot flag producer and consumer ---'
sed -n '210,265p' src/main/ipc/pty/runtime/spawn-options.ts
sed -n '275,320p' src/main/ipc/pty/runtime/spawn-commit.ts
printf '%s\n' '--- sequence and provider-state helpers ---'
rg -n -C 8 'getPtyOutputSequence\(|ptyOutputSequenceById|providerSnapshotPreferredPtys|snapshotKittyFlagsCoverReconciledSeq' src/main/runtime/orca-runtime.ts src/main/ipc/pty/runtime
printf '%s\n' '--- runtime spawn entry points ---'
rg -n -C 15 'executeRuntimePtySpawn\(' src/main/ipc/pty

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- spawn result sequence contract ---'
rg -n -C 8 'providerSequence' src/main/providers src/main/ipc/pty src/main/daemon --glob '*.ts' --glob '!**/*.test.ts' | head -160
printf '%s\n' '--- fresh-spawn sequence handling ---'
rg -n -C 10 'onFreshSpawn|providerSequence:|generation: .*(continued|reset)' src/main/providers src/main/ipc/pty --glob '*.ts' --glob '!**/*.test.ts' | head -220

Repository: stablyai/orca

Length of output: 19942


Use a zero baseline when spawnForStablePane returns a different PTY id. sequenceBeforeProviderSpawn belongs to the retired owner. Reusing it can classify early output on the fresh PTY as pre-spawn output and publish stale kitty flags with an invalid snapshotSeq. Derive the baseline from ctx.result.id; use zero when the id differs.

* `unverifiable` is a verdict, never a synonym for `none`: loss of contact
* with the execution host is no evidence a host-owned PTY exited.
*/
export type HostLiveTerminalProbeVerdict = 'live' | 'none' | 'unverifiable'

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

Use the SSH verdict vocabulary consistently. Replace none and unavailable with unverifiable in the probe and missing-host handling. The execution boundary permits only live, unverifiable, and exited; using synonyms can break consumers that rely on the established verdict contract.

📍 Affects 2 files
  • src/renderer/src/runtime/host-live-terminal-probe.ts#L15-L15 (this comment)
  • src/main/ipc/pty-session-liveness-and-ownership.test.ts#L94-L107

Source: Coding guidelines

…inding

#15749 moved the Windows process table onto @vscode/windows-process-tree,
but relay deployment installs only node-pty and @parcel/watcher, so a
Windows SSH host has no binding at all. Every read rejected, and agent
recognition reads a rejection as "no evidence" -- so agent panes on those
hosts identified as powershell.exe/cmd.exe for the life of the relay.

Verified on real Windows hardware (1486 processes): from the deployed
relay directory the require is MODULE_NOT_FOUND, and the pre-fix table
rejects instantly with "windows process table unavailable". With this
change the same bundle returns 1485 rows in 1.1-1.35s with agent command
lines intact.

Not fixed by adding the package to RELAY_NATIVE_DEPS: it ships no
prebuilds, so that would put a from-source node-gyp build (MSVC + SDK +
Spectre-mitigated libs) on the critical path of every Windows relay
deploy, and pnpm patches do not cross SSH, so the remote would get the
unpatched 1024-process cap regardless -- the exact truncation #15749
existed to remove.

The gate is narrow: absence only. A binding that loads but fails, wedges,
or returns an unreadable table still rejects, so a blocked reader never
starts forking a shell at the caller's poll rate. A fallback that also
fails rejects too, and the scan keeps the native path's self-presence
guard, so "unavailable" never degrades into "nothing is running".

relay-native-dependency-coverage.test.ts asserts every native addon
reachable from the relay entry is either installed on relay hosts or
listed with the reason its absence is safe. #15749's relay tests passed
because they inject a fake module loader, so nothing exercised the real
require; this reads the actual esbuild module graph instead.
@nwparker
nwparker force-pushed the fix-1.4.189-rc-final-scan-findings branch from 616d2a4 to e4084a7 Compare August 26, 2026 05:48
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nwparker nwparker changed the title fix: Windows process fallback on relay and push-target remote cleanup fix(windows): restore a CIM fallback for relay hosts with no native binding Aug 26, 2026
@nwparker

Copy link
Copy Markdown
Contributor

Took this over for the release cut — force-pushed the branch down to just the Windows relay fix.

What changed: the previous head 616d2a4ec8c was based off a stale rc, so GitHub showed ~100 files / +12.5k / −8.2k and the PR was CONFLICTING. It's now 7 files, +415/−3, rebased on main, MERGEABLE. The diagnosis and the fix approach in that commit were both correct — I kept them essentially as written.

Dropped from this branch (recoverable at 616d2a4ec8c, they deserve their own PRs so this stays cherry-pickable):

  • the worktree push-target remote-rollback fix + tests
  • the dropdown-menu shadow CSS fix — this one is a real bug still on main (src/renderer/src/components/ui/dropdown-menu.tsx:35 and :211 have a stray )] inside shadow-[...], which breaks the light-mode shadow)

Verified on real Windows hardware rather than only against injected fakes — full before/after in the description. Short version, from the actual deployed relay directory on a Windows SSH host (1486 processes): the require is MODULE_NOT_FOUND, main rejects in 0 ms with windows process table unavailable on every call, and the patched module returns 1485 rows in 1.1–1.35 s with claude.exe command lines intact.

Two things worth knowing before this merges:

  1. The scan is slower than the docs say. windows-process-enumeration.md quotes 706 ms p50 for the CIM path (measured at 1050 processes). At 1486 processes it's 1.36 s, and output is 4.76 MiB against the 8 MiB cap. Both constants match the pre-perf(windows): read the process table natively instead of forking PowerShell #15749 reader exactly, so this is 1.4.188 parity, not a new risk — but the headroom is ~2x on time and ~1.7x on bytes. On a busier host the scan times out or gets silently truncated by createOutputSink, the JSON fails to parse, and the read rejects — i.e. it fails back to today's behavior rather than reporting a wrong table. Safe, but worth a follow-up to widen.
  2. Relay hosts go back to forking PowerShell. The 500 ms snapshot TTL is single-flight, so the rate is bounded by scan duration: roughly 0.7 scans/sec while agent panes are polling. That's the [Bug]: orca-terminal-daemon spawns powershell.exe every ~2s to poll Win32_Process, floods PowerShell Transcription logs under enterprise GPO (unaffected by Resource Manager toggle) #15209 PowerShell-Transcription exposure again, on relay hosts only. Local Windows keeps the native path. There's no way around it without solving prebuilds for @vscode/windows-process-tree; the doc records it as a tracked gap.

@nwparker

Copy link
Copy Markdown
Contributor

Ran this past two more frontier models as independent reviewers. Neither found a defect in the fix, but both surfaced things worth recording. Summary of what I accepted, what I'm deferring, and what I'm rejecting.

Accepted — precision corrections to the original report:

  • The degraded pane name isn't specifically powershell.exe/cmd.exe. pty-shell-utils.ts:305-311 returns whatever node-pty reported as fallbackProcess. In practice shouldInspectWindowsAgentForeground only runs the scan when that name is a shell or an agent wrapper, so it's usually a shell — but it can be node.exe or a wrapper name too.
  • "Permanently" means for the life of the relay process. cachedModule latches null with no production re-probe; a relay restart re-evaluates (and still fails, until this lands).

Accepted — the blast radius is genuinely fail-safe. Both reviewers went looking for a path that reads the rejection as "process dead" and neither found one, which matches what I found: queryWindowsPaneProcessInventory maps failure to null (windows-foreground-process-rows.ts:56-80), foreground resolution reports available:false rather than empty, local-pty-provider.ts:1462-1519 keeps the last recognized agent through degraded scans, foreground-process-tracker has independent Job Object liveness, and windows-pty-root-identity.ts resolves to unknown — which is explicitly not authorization to force-kill. So the severity case rests on loss of remote agent identity, not on unsafe teardown. One real secondary effect: because verifyWindowsTreeKillTarget always answers unknown on these hosts, the taskkill /T /F at pty-descendant-termination.ts:275 never runs, so descendants that escaped the pane's job object survive teardown. The job-object path runs first and normally covers it.

Deferring — no failure cooldown on the CIM path. Correctly observed: the native path has a 30 s wedgedUntilMs cooldown and this path has none, so a host where PowerShell is blocked by policy retries at the caller's poll rate. Two reasons I'm not adding one here. The native cooldown exists for a failure mode that doesn't apply — the vendored module latches a global requestInProgress and leaks a callback per call, which is why one probe per 30 s is the only safe retry; runProcess owns its timeout and kills the child, so this path self-heals (the module's own comment at windows-process-table.ts:81-90 says exactly that). And a cooldown is a deviation from 1.4.188 behavior, which is the entire safety argument for cherry-picking this. Worth adding as a follow-up on main, not in the release fix.

Rejecting "not mergeable as-is." The three majors raised — no cooldown, PowerShell spawn rate, 8 MiB silent truncation — are all exact 1.4.188 characteristics, not defects this change introduces. The spawn-rate and truncation ones are already in the description. On truncation specifically: createOutputSink truncates without erroring, but the truncated JSON then fails to parse and the read rejects, so it degrades to today's behavior rather than reporting a wrong table.

Not corroboration: one reviewer couldn't build the relay bundle (path error) and reached its conclusion from static import reachability alone. The MODULE_NOT_FOUND on real hardware and the out/relay/win32-x64/relay.js grep in the description are what actually close that gap.

CI: two shards failed on worktree-git-common-watch.test.ts and updater.startup-scheduling.test.ts — both untouched by this PR, both timing-sensitive, both pass locally. Re-running.

@nwparker
nwparker merged commit e4d95e0 into main Aug 26, 2026
98 of 101 checks passed
@nwparker
nwparker deleted the fix-1.4.189-rc-final-scan-findings branch August 26, 2026 06:15
nwparker added a commit that referenced this pull request Aug 26, 2026
…16569)

A push target that reuses an existing Orca-created fork remote inherits
ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`),
so the final worktree to be deleted can remove it. Rollback then reused
that same flag to decide whether to undo its own work -- but a reused
remote was not added by this call, and a live sibling worktree is still
pushing to it. A failed fetch during create therefore deleted a remote
another worktree depends on.

Track `remoteAddedHere` separately: ownership stays inherited for
cleanup, while rollback only removes a remote this call actually added.
Both the local and the SSH path had the same bug and are fixed together.

Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of
that branch so the release fix in #16550 stayed a clean cherry-pick.
nwparker added a commit that referenced this pull request Aug 26, 2026
The CIM fallback from #16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.
nwparker added a commit that referenced this pull request Aug 26, 2026
The CIM fallback from #16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.
nwparker added a commit that referenced this pull request Aug 26, 2026
…16598)

* feat(windows): let a relay host bind the native process table directly

The CIM fallback from #16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.

* build(relay): ship the Windows process-table addon to relay hosts

The CIM scan restored correctness on Windows SSH hosts, but it costs a
powershell.exe and ~1.4s per read where the native addon costs ~57ms. It
was always the floor, not the destination.

The addon cannot be npm-installed on a relay host: it carries a
binding.gyp, so npm rebuilds from source and the build wants
Spectre-mitigated libraries even where MSVC is already present. The
binary inside the published tarball loads, but predates our patch and
still caps enumeration at 1024 processes -- on a 1486-process host it
returned exactly 1024 rows with the querying process among the missing,
which reads as unavailable only under load. No published alternative
clears the bar either; the one fork with a working prebuild story still
carries the same cap.

So build it where a compiler exists and ship the result. The build script
refuses unpatched source -- checking the source rather than trusting the
install, because the Spectre hunk fails loudly while the 1024 hunk fails
silently -- and verifies the PE machine field so a cross-build cannot
emit host arch for another target.

The artifact is optional: hashed when present so a relay carrying it
never shares an immutable directory with one that does not, and never
probed, since requiring a file only a Windows build machine can produce
would make a correct relay read as MISSING and redeploy forever. Builds
on any other OS keep using the scan, unchanged.

arm64 cross-compiles from the x64 runner but needs the optional MSVC
ARM64 toolset, so it stays best-effort: a runner image without that
component should cost arm64 relays the fast path, not fail the release
the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a
per-arch list rather than a flag for exactly that reason.

* build(relay): require the arm64 process-table addon too

The arm64 cross-compile is no longer unproven. On a Windows x64 machine
with the MSVC v143 ARM64 build tools component installed, node-gyp
--arch=arm64 produces a genuine ARM64 image:

  x64    machine=0x8664  152064 bytes
  arm64  machine=0xaa64  139776 bytes

So arm64 stops being best-effort and joins x64 in the required list. It
was only best-effort because the component is optional and I had not seen
it succeed; a runner image without it now fails the build with MSB8020
naming the missing component, and that step runs before the long
packaging step so the failure costs seconds rather than twenty minutes.

The env var stays a per-arch list rather than reverting to a flag, so a
future arch can land best-effort before being promoted the same way.
AmethystLiang added a commit that referenced this pull request Aug 26, 2026
…inding (#16550)

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
(cherry picked from commit e4d95e0)
Pierre-Mike pushed a commit to Pierre-Mike/orca that referenced this pull request Aug 26, 2026
…tablyai#16569)

A push target that reuses an existing Orca-created fork remote inherits
ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`),
so the final worktree to be deleted can remove it. Rollback then reused
that same flag to decide whether to undo its own work -- but a reused
remote was not added by this call, and a live sibling worktree is still
pushing to it. A failed fetch during create therefore deleted a remote
another worktree depends on.

Track `remoteAddedHere` separately: ownership stays inherited for
cleanup, while rollback only removes a remote this call actually added.
Both the local and the SSH path had the same bug and are fixed together.

Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of
that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.

(cherry picked from commit 1c9fb84)
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…inding (stablyai#16550)

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…tablyai#16569)

A push target that reuses an existing Orca-created fork remote inherits
ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`),
so the final worktree to be deleted can remove it. Rollback then reused
that same flag to decide whether to undo its own work -- but a reused
remote was not added by this call, and a live sibling worktree is still
pushing to it. A failed fetch during create therefore deleted a remote
another worktree depends on.

Track `remoteAddedHere` separately: ownership stays inherited for
cleanup, while rollback only removes a remote this call actually added.
Both the local and the SSH path had the same bug and are fixed together.

Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of
that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
…tablyai#16598)

* feat(windows): let a relay host bind the native process table directly

The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.

* build(relay): ship the Windows process-table addon to relay hosts

The CIM scan restored correctness on Windows SSH hosts, but it costs a
powershell.exe and ~1.4s per read where the native addon costs ~57ms. It
was always the floor, not the destination.

The addon cannot be npm-installed on a relay host: it carries a
binding.gyp, so npm rebuilds from source and the build wants
Spectre-mitigated libraries even where MSVC is already present. The
binary inside the published tarball loads, but predates our patch and
still caps enumeration at 1024 processes -- on a 1486-process host it
returned exactly 1024 rows with the querying process among the missing,
which reads as unavailable only under load. No published alternative
clears the bar either; the one fork with a working prebuild story still
carries the same cap.

So build it where a compiler exists and ship the result. The build script
refuses unpatched source -- checking the source rather than trusting the
install, because the Spectre hunk fails loudly while the 1024 hunk fails
silently -- and verifies the PE machine field so a cross-build cannot
emit host arch for another target.

The artifact is optional: hashed when present so a relay carrying it
never shares an immutable directory with one that does not, and never
probed, since requiring a file only a Windows build machine can produce
would make a correct relay read as MISSING and redeploy forever. Builds
on any other OS keep using the scan, unchanged.

arm64 cross-compiles from the x64 runner but needs the optional MSVC
ARM64 toolset, so it stays best-effort: a runner image without that
component should cost arm64 relays the fast path, not fail the release
the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a
per-arch list rather than a flag for exactly that reason.

* build(relay): require the arm64 process-table addon too

The arm64 cross-compile is no longer unproven. On a Windows x64 machine
with the MSVC v143 ARM64 build tools component installed, node-gyp
--arch=arm64 produces a genuine ARM64 image:

  x64    machine=0x8664  152064 bytes
  arm64  machine=0xaa64  139776 bytes

So arm64 stops being best-effort and joins x64 in the required list. It
was only best-effort because the component is optional and I had not seen
it succeed; a runner image without it now fails the build with MSB8020
naming the missing component, and that step runs before the long
packaging step so the failure costs seconds rather than twenty minutes.

The env var stays a per-arch list rather than reverting to a flag, so a
future arch can land best-effort before being promoted the same way.
rahuljangirworks pushed a commit to rahuljangirworks/veer that referenced this pull request Aug 27, 2026
…tablyai#16598)

* feat(windows): let a relay host bind the native process table directly

The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.

* build(relay): ship the Windows process-table addon to relay hosts

The CIM scan restored correctness on Windows SSH hosts, but it costs a
powershell.exe and ~1.4s per read where the native addon costs ~57ms. It
was always the floor, not the destination.

The addon cannot be npm-installed on a relay host: it carries a
binding.gyp, so npm rebuilds from source and the build wants
Spectre-mitigated libraries even where MSVC is already present. The
binary inside the published tarball loads, but predates our patch and
still caps enumeration at 1024 processes -- on a 1486-process host it
returned exactly 1024 rows with the querying process among the missing,
which reads as unavailable only under load. No published alternative
clears the bar either; the one fork with a working prebuild story still
carries the same cap.

So build it where a compiler exists and ship the result. The build script
refuses unpatched source -- checking the source rather than trusting the
install, because the Spectre hunk fails loudly while the 1024 hunk fails
silently -- and verifies the PE machine field so a cross-build cannot
emit host arch for another target.

The artifact is optional: hashed when present so a relay carrying it
never shares an immutable directory with one that does not, and never
probed, since requiring a file only a Windows build machine can produce
would make a correct relay read as MISSING and redeploy forever. Builds
on any other OS keep using the scan, unchanged.

arm64 cross-compiles from the x64 runner but needs the optional MSVC
ARM64 toolset, so it stays best-effort: a runner image without that
component should cost arm64 relays the fast path, not fail the release
the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a
per-arch list rather than a flag for exactly that reason.

* build(relay): require the arm64 process-table addon too

The arm64 cross-compile is no longer unproven. On a Windows x64 machine
with the MSVC v143 ARM64 build tools component installed, node-gyp
--arch=arm64 produces a genuine ARM64 image:

  x64    machine=0x8664  152064 bytes
  arm64  machine=0xaa64  139776 bytes

So arm64 stops being best-effort and joins x64 in the required list. It
was only best-effort because the component is optional and I had not seen
it succeed; a runner image without it now fails the build with MSB8020
naming the missing component, and that step runs before the long
packaging step so the failure costs seconds rather than twenty minutes.

The env var stays a per-arch list rather than reverting to a flag, so a
future arch can land best-effort before being promoted the same way.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 28, 2026
…inding (stablyai#16550)

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
(cherry picked from commit e4d95e0)
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 28, 2026
…tablyai#16569)

A push target that reuses an existing Orca-created fork remote inherits
ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`),
so the final worktree to be deleted can remove it. Rollback then reused
that same flag to decide whether to undo its own work -- but a reused
remote was not added by this call, and a live sibling worktree is still
pushing to it. A failed fetch during create therefore deleted a remote
another worktree depends on.

Track `remoteAddedHere` separately: ownership stays inherited for
cleanup, while rollback only removes a remote this call actually added.
Both the local and the SSH path had the same bug and are fixed together.

Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of
that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.

(cherry picked from commit 1c9fb84)
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 28, 2026
…tablyai#16598)

* feat(windows): let a relay host bind the native process table directly

The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.

* build(relay): ship the Windows process-table addon to relay hosts

The CIM scan restored correctness on Windows SSH hosts, but it costs a
powershell.exe and ~1.4s per read where the native addon costs ~57ms. It
was always the floor, not the destination.

The addon cannot be npm-installed on a relay host: it carries a
binding.gyp, so npm rebuilds from source and the build wants
Spectre-mitigated libraries even where MSVC is already present. The
binary inside the published tarball loads, but predates our patch and
still caps enumeration at 1024 processes -- on a 1486-process host it
returned exactly 1024 rows with the querying process among the missing,
which reads as unavailable only under load. No published alternative
clears the bar either; the one fork with a working prebuild story still
carries the same cap.

So build it where a compiler exists and ship the result. The build script
refuses unpatched source -- checking the source rather than trusting the
install, because the Spectre hunk fails loudly while the 1024 hunk fails
silently -- and verifies the PE machine field so a cross-build cannot
emit host arch for another target.

The artifact is optional: hashed when present so a relay carrying it
never shares an immutable directory with one that does not, and never
probed, since requiring a file only a Windows build machine can produce
would make a correct relay read as MISSING and redeploy forever. Builds
on any other OS keep using the scan, unchanged.

arm64 cross-compiles from the x64 runner but needs the optional MSVC
ARM64 toolset, so it stays best-effort: a runner image without that
component should cost arm64 relays the fast path, not fail the release
the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a
per-arch list rather than a flag for exactly that reason.

* build(relay): require the arm64 process-table addon too

The arm64 cross-compile is no longer unproven. On a Windows x64 machine
with the MSVC v143 ARM64 build tools component installed, node-gyp
--arch=arm64 produces a genuine ARM64 image:

  x64    machine=0x8664  152064 bytes
  arm64  machine=0xaa64  139776 bytes

So arm64 stops being best-effort and joins x64 in the required list. It
was only best-effort because the component is optional and I had not seen
it succeed; a runner image without it now fails the build with MSB8020
naming the missing component, and that step runs before the long
packaging step so the failure costs seconds rather than twenty minutes.

The env var stays a per-arch list rather than reverting to a flag, so a
future arch can land best-effort before being promoted the same way.

(cherry picked from commit 19e9ec6)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…inding (stablyai#16550)

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#16569)

A push target that reuses an existing Orca-created fork remote inherits
ownership of it (`remoteCreated = isRemoteCreatedByKnownWorktree(...)`),
so the final worktree to be deleted can remove it. Rollback then reused
that same flag to decide whether to undo its own work -- but a reused
remote was not added by this call, and a live sibling worktree is still
pushing to it. A failed fetch during create therefore deleted a remote
another worktree depends on.

Track `remoteAddedHere` separately: ownership stays inherited for
cleanup, while rollback only removes a remote this call actually added.
Both the local and the SSH path had the same bug and are fixed together.

Original work by Jinjing (AmethystLiang) in 616d2a4ec8c; split out of
that branch so the release fix in stablyai#16550 stayed a clean cherry-pick.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#16598)

* feat(windows): let a relay host bind the native process table directly

The CIM fallback from stablyai#16550 answers on relay hosts, but it costs a
powershell.exe and ~1.4s per scan where the native reader costs ~57ms.
It is a parachute, not the destination.

Teach the loader a second source: the desktop app keeps resolving the
npm package, and a relay host -- which has none of our node_modules --
binds a bare `windows-process-tree.node` staged beside the bundle. The
CIM scan stays as the last resort, so a host with neither is unchanged.

Bind the addon directly rather than its package wrapper. lib/index.js
adds only a queue over getProcessList, and that queue is the wedge this
module already defends against: it latches a module-global
requestInProgress with no try/catch. We hold our own single-flight and
deadline, so going straight to the addon drops the duplicate.

Measured on a Windows 11 SSH host with ~1490 processes, running the
relay-externals bundle from the deployed relay directory:

  no addon staged   nativeAvailable=false  1247ms  (CIM)
  addon staged      nativeAvailable=true     57ms  memory restored

Degradation was exercised on that host, not just in fakes: a truncated
upload, a text file, and a foreign-arch ELF each fall through to the
scan rather than throwing, and restoring a good addon recovers. A file
that loads but lacks getProcessList is rejected by shape, because
binding to it would reject every read forever where falling through
still answers.

No artifact is staged yet, so this is inert until the packaging change
lands: today every relay takes the same CIM path it does now.

* build(relay): ship the Windows process-table addon to relay hosts

The CIM scan restored correctness on Windows SSH hosts, but it costs a
powershell.exe and ~1.4s per read where the native addon costs ~57ms. It
was always the floor, not the destination.

The addon cannot be npm-installed on a relay host: it carries a
binding.gyp, so npm rebuilds from source and the build wants
Spectre-mitigated libraries even where MSVC is already present. The
binary inside the published tarball loads, but predates our patch and
still caps enumeration at 1024 processes -- on a 1486-process host it
returned exactly 1024 rows with the querying process among the missing,
which reads as unavailable only under load. No published alternative
clears the bar either; the one fork with a working prebuild story still
carries the same cap.

So build it where a compiler exists and ship the result. The build script
refuses unpatched source -- checking the source rather than trusting the
install, because the Spectre hunk fails loudly while the 1024 hunk fails
silently -- and verifies the PE machine field so a cross-build cannot
emit host arch for another target.

The artifact is optional: hashed when present so a relay carrying it
never shares an immutable directory with one that does not, and never
probed, since requiring a file only a Windows build machine can produce
would make a correct relay read as MISSING and redeploy forever. Builds
on any other OS keep using the scan, unchanged.

arm64 cross-compiles from the x64 runner but needs the optional MSVC
ARM64 toolset, so it stays best-effort: a runner image without that
component should cost arm64 relays the fast path, not fail the release
the x64 relay is riding on. ORCA_REQUIRE_RELAY_NATIVE_ADDONS is a
per-arch list rather than a flag for exactly that reason.

* build(relay): require the arm64 process-table addon too

The arm64 cross-compile is no longer unproven. On a Windows x64 machine
with the MSVC v143 ARM64 build tools component installed, node-gyp
--arch=arm64 produces a genuine ARM64 image:

  x64    machine=0x8664  152064 bytes
  arm64  machine=0xaa64  139776 bytes

So arm64 stops being best-effort and joins x64 in the required list. It
was only best-effort because the component is optional and I had not seen
it succeed; a runner image without it now fails the build with MSB8020
naming the missing component, and that step runs before the long
packaging step so the failure costs seconds rather than twenty minutes.

The env var stays a per-arch list rather than reverting to a flag, so a
future arch can land best-effort before being promoted the same way.
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.

2 participants