Skip to content

fix(ssh): relay fallback runs Orca's pinned Node by default, never a host npm install - #26303

Merged
OrcaWin merged 10 commits into
OrcaWin/phase35from
OrcaWin/p35-relay-fallback-pinned-node-default
Oct 8, 2026
Merged

OrcaWin merged 10 commits into
OrcaWin/phase35from
OrcaWin/p35-relay-fallback-pinned-node-default

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

false

Files Added Deleted Net
Test 31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1418 $\color{#cf222e}{\Huge{\mathbf{−}}}$​105 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1313
Prod 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​668 $\color{#cf222e}{\Huge{\mathbf{−}}}$​150 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​518

ELI5

When Orca can't put its managed server on an SSH host, it falls back to an older "relay" program. By default that relay used whatever Node.js the host had and then compiled terminal support on the host with npm. That needs a compiler, internet access, a POSIX login shell and a working npm, and many hosts have none of those. Now the fallback first tries Orca's own Node.js with prebuilt terminal add-ons, so nothing gets compiled on hosts where that works. Where it doesn't, the connect does exactly what it did before. No host ends up worse off than it was.

What Changed

Before: the relay runtime came from resolveSshRemoteRuntime. It chose the no-compile ladder (rungs A/B/C) only when this connect had recorded that the managed server can't run. Many relay-route outcomes never record that: an unclassified deploy failure or deferral, live or unverifiable relay terminals, a changed source, or a refusal. All of those got DEFAULT_SSH_REMOTE_RUNTIME = 'legacy'. That meant a host Node found through a POSIX login-shell probe, then npm install plus node-gyp on the host. Users saw "relay cannot find node-pty", connect failures on offline or non-admin hosts, failures with Nushell login shells, and a degraded install that left node-pty out. Even the opt-in ladder dropped to legacy after rung C.

After. The PR keeps one rule: no host does worse than it did before this PR.

  • DEFAULT_SSH_REMOTE_RUNTIME is now 'pinned-node'. Every relay connect tries the no-compile rungs first:

    • A: Orca's pinned Node, uploaded by hash with slot prebuilds.
    • B: the glibc 2.17 compat runtime.
    • C: a host Node 18+ with Orca's N-API prebuilds, no npm.

    Wherever one of these runs, nothing is compiled on the host.

  • Any answer a rung gets from the host steps down; anything unanswered stays retryable.

    • A rung steps down when the host answered it with a failure. That includes a classified refusal, and also any unclassified failure: a command that ran and exited non-zero (tar ENOSPC or quota, the extract and hash markers), an SFTP status error, an unverified Windows promote, or a self-test that failed outside every refusal class. Unclassified failures step down as install_failed, which is never persisted.
    • System-ssh transfers carry the host's answer as well. A system-ssh directory upload and a system sftp batch now throw SystemSshCommandExitError with the host's exit status, so a remote tar ENOSPC or a Windows sftp permission refusal steps down like any other answered failure. These stay retryable: ssh exit 255, signals, lost-connection diagnostics, and a local tar failure on its own input (a missing directory or an unreadable file), which is blamed on the client, not on the remote tar that saw its truncated stream. When local tar fails only because the host side closed first (BSD tar exits 1 with "Write error" and no signal), the remote's answer is kept.
    • Nothing steps down once the relay launch has been issued, because a relay may already be running. To keep that rule from stranding a host, the warm-path check for a cached runtime now also runs it (--version) in the same command, reporting a refusal the way promotion does. A cached runtime that the host's exec policy or a removed library has broken since the install therefore steps down before launch, with no extra round trip, instead of hanging at launch on every reconnect.
  • If A, B and C are all refused, the connect falls back to the old default. That is the host-Node relay (legacy), shown on the card as an unsupported configuration. This covers every refusal and answered failure, including noexec. Exec denial can be specific to one binary (for example, AppArmor allowing /usr/bin/node but denying uploaded binaries), so a proved noexec skips B and C, which load from the same tree, and goes straight to the old default. Windows has no B or C yet, so it falls back right after A.

  • Rung D is reached only when that old default itself answers with a failure. Rung D is plain SSH terminals plus SFTP, with a classified reason. The connect reaches it in two cases:

    • The default's strict probe gets a reply that the host has no usable Node.js 18+ with npm.
    • The default's install answers with a failure before launch.

    The old default failed the connect in both cases, so D's outcome is at least as good as before by construction. A noexec proved earlier in the pass still gives D the "home mounted noexec" wording.
    A refused channel (MaxSessions), a session limit, a timeout, an unconfirmed termination, an SFTP connection loss, an ssh exit 255 or user abort is never treated as an answer. Those stay retryable connect failures, the same outcome as before. The launch reuses the Node path the probe found, so Windows doesn't resolve Node twice.

  • Refusals the host can fix are remembered for 24 hours. These are missing_lib, security_software, and noexec on Windows (application control). They are persisted with the time they were proved and replayed for 24 hours. A host that still blocks Orca's runtime isn't re-uploaded to (30-48 MB, and another antivirus/EDR hit) on every connect. A repaired host gets rung A back after the window, or as soon as its SSH settings change. Refusals that are fixed facts about the host (libc_floor, illegal_instruction, wrong_libc) and POSIX noexec stay persisted under the host key, as before.

  • Rung D messages depend on the cause. A client that couldn't prepare Orca's runtime gets its own wording. Windows gets Windows wording and never the POSIX "mounted noexec" text. A host with no Node is told to install Node.js 18+ with npm.

  • NixOS hosts: NixOS's stub loader refuses Orca's generic Linux Node with exit 127 and "Could not start dynamically linked executable". That answer is now classified as wrong_libc, so the connect steps on to the host's Nix Node (rung C) instead of failing at rung A.

  • Plain SSH mode (rung D) no longer reports a terminal it never saw as exited. It reports "absent" only for shells it started and saw exit. Any other terminal, such as one still running on the earlier relay, is reported as unverifiable, so the pane is kept rather than retired.

  • The opt-in path is unchanged. You can still choose the host-npm path per host (remoteRuntime: 'legacy', shown as "Host Node") or with ORCA_SSH_REMOTE_RUNTIME=legacy. Hosts on "Auto" store no setting, so they follow the new default.

  • The card says when a relay runs on host Node. Main publishes an optional hostNodeRuntime flag on the connection state. It is suppressed while the host is served by its managed server.

    • On a host that opted in, the card says "Unsupported configuration… Set Runtime to Auto…".
    • On an Auto host that fell back, it says "Orca-managed Node isn't available for this connection…" instead.
  • resolveConnectRemoteRuntime and its managedServerUnavailable gate are removed. They were only there to choose between the two defaults.

  • Departure from the decision record (w1-00). The record said a refused rung C should land on D, never a host npm install. Review rounds 2-5 found host types where that is worse than before: a client without Orca's artifacts, Windows, an unidentified libc, a Node that C's N-API floor refuses, an unclassified install failure, and an exec denial that only applies to some binaries. The coordinator therefore set the rule above, so the host-npm path stays the fallback for those hosts, marked unsupported. It is never the first thing tried.

Nothing on the relay wire changes. The relay version string already includes the runtime digest. The new hostNodeRuntime flag on the published SSH connection state is optional: older clients ignore it, and the paired-client admission accepts only a literal true. An older relay left behind by the switch is handled by the existing previous-relay census and router: its terminals are held or routed, never respawned.

Why

This reuses the ladder, rung planner, prebuilt add-ons and pinned Node store that already exist. Rung A takes the host-Node probe, npm, node-gyp and host network access out of the default path, and those are the shared cause behind every linked issue. I considered three alternatives:

  • Recording a classification on more on-connect outcomes. Every outcome we missed would still run the host-npm path.
  • Settling rung D after C, or after a proved noexec. Five review rounds each found host types where that was worse than the old default.
  • Failing the connect as retryable when the ladder can't decide. Retrying can't fix a missing build artifact or a Windows host with no B or C.

Falling back to exactly the old default keeps the improvement where Orca's runtime works, and keeps every other host as it was.

Linked Issue

Fixes #20386
Fixes #22159
Fixes #23554
Fixes #24226

Related (not closed here): #1693, #7715.

Visual Proof

N/A. The change is in how the runtime is chosen. The only user-visible text is the rung D reason, and the tests cover it.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Unit tests:

    • resolveSshRemoteRuntime with nothing set now returns pinned-node. The per-host setting and the env override still win.
    • relayRuntimeLadder has no legacy rung.
    • nextRelayRuntimeStep alone still steps a refused rung C to D. relayRuntimeStepAfterRefusal turns that into the host-Node fallback unless there is proof (round 4).
    • The new rung D message is covered.
  • deployAndLaunchRelay with no runtime setting and nothing recorded launches on the pinned Node and never runs the native-deps install. The host-npm suites now opt in to legacy explicitly. (Later rounds changed what happens after C refuses: see round 4.)

  • Before the fix, 8 of these tests fail.

  • Real host (Docker SSH): I ran a Debian 12 arm64 container over real SSH using the hostile-host fixture. The host has no Node.js, and npm, cc, gcc and make are replaced by shims that log any call. The SSH target has no runtime setting.

    • With the fix, the deploy uploaded Orca's pinned Node (~/.orca-remote/runtimes/node-0f8949…/bin/node) and landed on rung A. The remote terminal echoed, a second connect reused the runtime, and the shim log was empty.
    • With ORCA_SSH_REMOTE_RUNTIME=legacy (the old default), the same host failed with Node.js not found on remote host. Orca relay requires Node.js 18+ and npm, which is the failure these issues report.
    • The repo's Linux Docker cells are x64 and expect a Linux Docker host, so I used an ad hoc arm64 cell with a linux-arm64-glibc template slot taken from a CI build. That cell isn't committed.
  • Real host (loopback): I ran the hostile-host matrix cell macos-arm64-local-sshd (ORCA_RUN_SSH_HOSTILE_HOSTS=1). It deploys for real over a loopback sshd whose PATH has npm, cc and make replaced by shims that fail the test if called. The fixture target now carries no remoteRuntime, so it tests the default.

    • With the fix, it lands on rung A on darwin-arm64.
    • Without the fix, it fails with toolchain invoked: make BUILDTYPE=Release -C build; settled on nothing, expected A.
  • The committed Linux Docker cells (x64 Debian/Alma/Alpine/CentOS 7/no-egress) run in .github/workflows/ssh-hostile-hosts.yml.

  • New tests: the opt-in deploy records the Host Node marker and a ladder deploy clears it; the connect publishes hostNodeRuntime and drops it once the host is managed; admission accepts only true; the card renders the warning only for flagged states. Before the fix, 5 of these fail.

  • Review follow-ups:

    • NixOS stub-loader classification: a classifier case, an install-level step-down, and a deploy test where a host Nix Node reaches rung C (3 fail without the fix).
    • A plain-SSH provider and runtime-controller test: a PTY id rung D never minted probes as null, not false (2 fail without the fix).
    • The rung D message offers Host Node only for a host-side refusal and never for artifacts_unavailable, target_unresolved or windows_host_unsupported (4 fail without the fix).
  • Round-2 follow-ups:

    • With the template missing (A and C refuse artifacts_unavailable), the connect launches the host-Node relay. It marks the relay unsupported, writes no persisted decision and doesn't settle D. A proved noexec after a client gap still lands on D.
    • On Windows, rung A refusals (missing_lib, security_software, noexec, artifacts_unavailable) keep the host-Node relay and never try C.
    • Windows rung D wording.
    • Ladder unit tests for both cases.
    • The card's fallback notice.
    • Ran pnpm test src/main/ssh src/main/ipc src/main/providers src/shared plus the card test: 22640 passed. The only failures were 2 timing tests in src/shared under load; both pass when run alone. pnpm tc, oxlint and pnpm run check:code-quality:changed pass.
  • Round-3 follow-ups:

    • At deploy level: a client artifact gap followed by rung C host_node_missing settles D, and the host-Node path is never tried. A host-Node fallback whose strict probe proves no Node settles D. A Windows host with no Node settles D with Windows wording and reason no_runtime. On Windows, an unanswered probe stays a retryable failure. A persisted Windows security_software refusal is not replayed and not re-persisted.
    • In the pinned-runtime tests: a Windows security_software refusal ages out of the memory cache, while illegal_instruction keeps replaying.
    • In the node-resolution tests: strict resolution throws RemoteNodeNotFoundError only when every probe answered, and rethrows probes that went unanswered (Windows and POSIX).
    • pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm run audit:anti-slop pass.
    • The affected SSH suites pass: 117 tests in the ladder, deploy, resolution and pinned-runtime files, plus 45 node-resolution tests. In the broad local run, only timeouts failed: the machine's load average was about 370, and none of the failing files are touched here.
  • CI e2e (ssh docker watcher isolation): the e2e build deliberately ships no out/orcad-template. A template there would switch every SSH Docker journey onto the managed-server route, not the relay. The orcad e2e jobs build their own template into a path the app doesn't read by default. So the relay suite exercises the client-artifact case: the connect gets the host-Node relay, exactly as before this PR. Rung A on real hosts is covered by the hostile-host Docker cells and the loopback cell above.

  • Round 4: the "never worse" invariant.

    • ssh-relay-runtime-never-worse.test.ts is a table of 22 host types. For each one it compares the outcome before this PR with the outcome now, using the same step function the deploy loop calls. It asserts the new outcome is never worse, that no host where an Orca rung runs gets a host compile, and that plain SSH happens only with proof.
    • The host types: POSIX with a compiler, with Node but no compiler, and with no Node; an offline client and a missing template, each with and without host Node; glibc 2.17; musl; musl without libstdc++; an unidentified libc; a host Node below C's N-API level; NixOS; a noexec home; Windows with and without Node; Windows blocked by antivirus, with and without Node; Windows AppLocker; a Windows offline client; and a channel-open failure, both at the fallback probe and at rung A.
    • The round-3 code fails this table on the unidentified-libc and N-API-floor rows.
    • Deploy level: when A, B and C refuse, the connect launches the host-Node relay and resolves Node once. A client gap with no host Node settles D only after the fallback's strict probe. A Windows security_software refusal is persisted with its time, replayed, and expires after 24 hours.
    • Resolver level: a refused channel (MaxSessions, reason 2) is rethrown, not read as "no Node".
    • The hostile-host cell alpine-musl-no-libstdcxx now also expects the fallback's host_node_missing before rung D.
    • Locally, src/main/ssh, src/main/ipc, src/main/providers, the SSH persistence tests and the card test pass: 10879 tests. pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm run audit:anti-slop also pass.
  • Round 5: the invariant across every combination.

    • ssh-relay-runtime-never-worse.test.ts now builds every combination instead of hand-picking host types: Linux and Windows × every A answer (launch or one of 9 refusals, install_failed included) × 3 B answers × 7 C answers × 4 outcomes for the old default (launch, no Node, install fails, launch fails). That is 1680 hosts, plus named review cases.
    • The named cases: A install_failed (ENOSPC) with a working host Node, an executable-only denial with a working host Node, a noexec home with the old default launching and failing, an unidentified libc, Windows blocked by antivirus with no Node, and a channel-open failure on every exec.
    • For every host it asserts four things: the outcome is never worse than before; nothing compiles on the host when rung A runs; plain SSH appears only when the old default answered with a failure; and a lost transport stays retryable.
    • The round-4 code fails it on the noexec and executable-denial rows.
    • ssh-relay-host-answered-failure.test.ts pins which errors count as answered and which stay retryable.
    • Deploy level: ENOSPC at A reaches the host-Node relay. A lost channel at A stays retryable without stepping down. A proved noexec reaches the fallback and lands on D (home noexec) only on its answer.
    • The hostile-host cell ubuntu2204-node20-noexec-home now expects A noexec, then the fallback's host_node_missing, before D. Its Node 20 has no npm. This cell runs in the SSH hostile hosts CI job.
    • Locally, src/main/ssh, src/main/ipc, src/main/providers, the SSH persistence tests, and the shared SSH and telemetry tests pass: 10759 tests. pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm run audit:anti-slop also pass.
  • Round 6:

    • ssh-relay-answered-failure-producers.test.ts uses the real producers, not hand-built errors:
      • a real uploadDirectoryViaSystemSsh with real local tar and a stand-in ssh that answers ENOSPC (exit 2, answered), exits 255 (retryable), or receives a local tar failure (blamed locally, retryable);
      • a real runSftpBatch with a permission refusal (answered) and a lost connection (retryable);
      • the real warm-check shell command against a cached runtime whose binary now exits 127 for a missing library or 126 for an exec denial. Without --version, that runtime still reports READY. With it, the check reports a refusal classified as missing_lib or noexec.
    • Round 7: a real tar run on 8 MiB of incompressible data against a stand-in ssh that exits early with ENOSPC (three attempts per run) keeps the remote's typed answer. The round-6 code fails it with BSD tar.
    • Install test: ensurePinnedRelayRuntime refuses such a cached runtime before launch, without reinstalling.
    • The never-worse table gains four named cases: a cached runtime that lost a library, a cached runtime now denied by exec policy, system-ssh ENOSPC, and a Windows sftp refusal.
    • Locally, src/main/ssh, src/main/ipc, src/main/providers, the SSH persistence tests, and the shared SSH and telemetry tests pass: 10774 tests. pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm run audit:anti-slop also pass.
    • Not yet verified: the Windows warm-check PowerShell. No pwsh is available locally, so it is not parse-checked here. It reuses the promote script's own run-and-report lines.
    • Limit: a cached runtime that passes --version but whose relay then fails after launch still fails the connect without stepping down, by design, so that no second relay is started beside one that may be running.
  • pnpm test src/main/ssh src/main/ipc src/renderer/src/components/settings src/renderer/src/store/slices passed 14388 tests. The only failures were 3 timing-sensitive tests in orcad-remote-shell-commands.integration.test.ts under load; that file passes 30/30 when run alone. pnpm tc, oxlint, pnpm run check:code-quality:changed and the localization verifiers all pass.

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: this is SSH-only. Under the SSH execution boundary, terminals from an older relay are held or routed, never respawned.
  • Windows hosts: these run rung A (win32 pinned Node). B and C don't exist on Windows yet, so any rung A refusal falls back to the host-Node relay, as before this PR, marked unsupported. They reach rung D only if that fallback proves there is no Node, and then get Windows wording.
  • Plain SSH and an earlier relay: rung D doesn't route to an earlier relay's terminals, because no Orca runtime runs there to bridge them. Those terminals stay unverifiable. They aren't marked exited and their leases aren't retired, so the next connect that gets a runtime can reattach them.
  • Mixed versions: an older client keeps its own default. Nothing new crosses the wire.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

m4air and others added 2 commits October 7, 2026 12:02
…r a host npm install

A host whose connect falls back to the relay route now gets the A/B/C ladder
(Orca's uploaded Node and prebuilt addons) unless it opts into Host Node. A
refused rung C steps to rung D with an actionable reason instead of compiling
native deps on the host.
…he SSH host card

The relay fallback now defaults to Orca's pinned Node ladder; the host-npm path is
reachable only by an explicit per-host Runtime or ORCA_SSH_REMOTE_RUNTIME override.
When a relay actually launches on it, main publishes hostNodeRuntime on the
connection state (optional, admitted field-by-field for paired clients) and the
SSH host card shows an unsupported-configuration warning.
@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 7, 2026 22:00
m4air added 8 commits October 7, 2026 15:21
…erify

- NixOS's stub loader refusing Orca's generic Linux Node (exit 127, 'Could not
  start dynamically linked executable') is classified wrong_libc, so the ladder
  steps on to the host Node instead of failing the connect at rung A.
- In plain SSH mode the shell provider answers absent only for shells it saw
  exit; a PTY id it never minted (one an earlier relay may still run) is
  unverifiable, never exited.
- The rung D message offers Host Node only when the host's own Node refused the
  prebuilt addons, and calls it an unsupported configuration; a download,
  unresolved-host or Windows refusal gets no Host Node advice.
A client without Orca's runtime artifacts (a dev, e2e or source build with no
orcad template, or an offline client) refused rungs A and C with
artifacts_unavailable, and the connect settled on rung D. That reason describes
the client, so it now lands on the host-Node relay it had before the ladder,
marked unsupported, and persists no host decision. A proved noexec still lands
on D.

Windows hosts have no rung B or C yet, so any rung A refusal there keeps the
host-Node relay too. The rung D message is worded from the host OS: Windows
gets no noexec-mount wording and is offered Host Node.
…le refusals expire

The host-Node relay the ladder chooses in place of D (a client artifact gap,
or a Windows rung A refusal) hard-failed the connect when the host had no
Node: the resolver threw a plain Error, which plain SSH mode does not admit.
The fallback now proves host Node with a strict probe first; an answered
"no Node" settles D with a classified, host-OS worded reason, and an
unanswered probe stays a retryable failure. A gap no longer rewrites D to
host Node once rung C proved host_node_missing.

Mutable pinned-runtime refusals (missing_lib, security_software, and noexec
on Windows) are no longer persisted and replay from memory for ten minutes
only, so a repaired host gets rung A back. The in-memory refusal cache moves
to ssh-relay-pinned-refusal-cache.ts.
Restructure the relay runtime ladder around one invariant: A, B and C are tried
first, and any refusal past them falls back to exactly the pre-ladder default,
the host-Node relay marked unsupported. That covers an unidentified libc, a
client artifact gap, Windows, mutable refusals and a C N-API floor the npm build
would not have hit. Rung D is reached only when that fallback proves the host
has no usable Node, or a proved noexec home would defeat it too.

Strict host-Node resolution now treats only a command that ran and exited as an
answer, so a refused channel (MaxSessions), session limit or timeout stays a
retryable failure instead of a 'no Node' verdict. The launch reuses the Node the
fallback probe found.

Mutable refusals (missing_lib, security_software, Windows noexec) persist again
with their proof time and replay for 24 hours, so a host that still blocks
Orca's runtime is not re-uploaded to on every connect, while a repaired one gets
rung A back. A table-driven test asserts the invariant per host class.
…and D only past it

Two shortcuts skipped the pre-ladder default. An answered but unclassified
install failure (tar ENOSPC, an extract or hash marker, an unverified Windows
promote, a self-test that failed outside every refusal class) aborted the
connect on every attempt; it now steps down as a non-persisted install_failed.
Only unanswered failures (abort, timeout, channel-open, session limit, an
unconfirmed termination, SFTP connection loss, ssh exit 255) stay retryable,
and nothing steps down once a relay launch was issued.

A proved noexec no longer jumps to D: exec denial can be per binary (AppArmor
allowing /usr/bin/node), so it skips B and C, which load from the same tree,
and reaches the host-Node fallback. D now follows only that fallback answering
with a failure, so its outcome is a superset of the default's by construction.

The never-worse test is now the cross-product of every A, B, C and host-Node
answer on Linux and Windows, plus named review cases.
… down before launch

System-ssh directory upload and system sftp threw plain Errors that dropped the
host's exit status, so a remote tar ENOSPC or a Windows sftp permission refusal
aborted the connect instead of stepping down. The remote side now throws
SystemSshCommandExitError (ssh exit 255, signals and lost-connection
diagnostics stay retryable), and a local tar failure is still blamed on the
client rather than the remote tar that saw its truncated stream.

The warm runtime check only tested that the verified executable existed, so a
cached runtime that the host's exec policy or a removed library had since broken
was launched and hung on every reconnect. The same command now also runs it and
reports a refusal the way promotion does, so it steps down before any launch,
with no extra round trip.
…o it

When the host's tar exits early (ENOSPC, a refusal), BSD tar on macOS exits 1
with 'Write error' and no signal, so the upload rethrew the local error and
dropped the typed remote exit, aborting the connect. The remote answer now wins
whenever local tar finished, was signalled, failed after ssh closed, or reported
a write or pipe error; a local tar that failed on its own input first is still
the client's fault.
…nstalls; probe each Node once

The noexec-home cell failed on 'npm --version': under the never-worse ladder a
proved noexec reaches the strict host-Node fallback, whose probe asks npm its
version before settling D. The cells now judge install and compile calls (npm
install/ci, node-gyp, cc, make) and allow '<tool> --version' / '-v'.

The probe ran twice because the login shell named the Node the path probe had
already rejected. Candidate checks are now memoized per resolution, for the
host-Node fallback and rung C alike.
@OrcaWin
OrcaWin merged commit bb27aad into OrcaWin/phase35 Oct 8, 2026
61 checks passed
OrcaWin added a commit that referenced this pull request Oct 8, 2026
* fix(remote-runtime): stop arm64 Linux servers dropping clients every heartbeat (empty WebSocket write EFAULT) (#26200)

* fix(remote-runtime): never write an empty WebSocket payload on its own (arm64 Electron EFAULT)

Patch [email protected] Sender.sendFrame so a frame with an empty payload is written
as its header alone. Under Electron on arm64 kernels with 39-bit virtual
addresses, socket.write() of a zero-length buffer fails with EFAULT and kills
the connection, so every empty heartbeat ping, auto-pong and close dropped
the remote runtime with 1006. Wire bytes are unchanged.

* test(remote-runtime): run the ws empty-payload guard on real Node

Bun resolves 'ws' to its built-in client, so under the Bun test project the
guard exercised Bun's implementation instead of the patched package.

---------

Co-authored-by: m4air <[email protected]>

* fix(orcad): ship the session scanner child so agent session history lists on orcad hosts (#26309)

orcad built every forked child except session-scanner-service-entry.js, so
aiVault.listSessions always failed on an orcad host. The resolver also skipped
the adjacent entry whenever isPackaged was true, so shipping the file alone
would not have been enough.

- build every ORCAD_CHILD_ENTRY_POINTS entry from one loop and add the scanner
- add it to ORCAD_ARTIFACTS so a deploy missing it fails integrity checks
- share one forked-child path resolver (asar layout vs flat app root) between
  the watcher and the scanner
- smoke-fork the built scanner during build-orcad under both runtimes

Fixes #24105

Co-authored-by: m4air <[email protected]>

* fix(remote-runtime): one owner for a remote pane's binding and recovery (#26308)

A remote pane no longer latches in connecting on terminal_not_found, holds
keystrokes typed during same-terminal recovery instead of dropping them,
reports transport-owned retries so the pane is not remounted mid-retry, and
no longer infers absence from an inventory that predates the leaf.

Co-authored-by: m4air <[email protected]>

* ci(e2e): move apt off the Azure mirror on runner images that use a mirror list (#26335)

Ubuntu 24.04 runner images resolve apt sources through /etc/apt/apt-mirrors.txt, so rewriting only the source lists left package downloads on azure.archive.ubuntu.com, which intermittently fails ('Ign:' on every package). Rewrite the mirror list too, and retry the install once with --fix-missing.

Co-authored-by: m4air <[email protected]>

* fix(terminal): remote snapshot replay keeps scrollback it cannot replace (#26319)

Desktop subscribers of a remote terminal received screen-only snapshots,
and every pushed snapshot replay cleared the pane's scrollback with ESC[3J.
A reconnect, a remount, or a recovery after a dropped frame therefore wiped
history the host never resent.

- Host: desktop subscribe snapshots use the same scrollback-row ladder as
  mobile, and SnapshotStart now carries an optional scrollbackRows field.
- Client: a pushed snapshot clears scrollback only when the host says it
  carries history; screen-only images (scrollbackRows 0, or older hosts
  that omit the field) repaint the screen and keep the pane's history.

Co-authored-by: m4air <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

* fix(daemon): clean launch env, validate client frames, fit the socket path (#26306)

* fix(daemon): clean launch env, validate client frames, fit the socket path

- Drop Chromium's DBUS_SESSION_BUS_ADDRESS=disabled: marker from the daemon,
  its systemd-run scope launch and every PTY env (#25580, #21119).
- Use the durable user-manager scope only when that manager outlives the
  caller: lingering on, or the caller already runs inside it (#24201).
- Shape-check hello and request frames, and catch request rejections, so a
  malformed frame closes one connection instead of the daemon (#17841).
- Move the daemon socket to a short per-uid private dir when the data root
  would overflow sun_path (#17840).

* fix(daemon): validate a relocated socket dir before any connect, not just before bind

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>

* fix(ssh): keep crediting a PTY after its recovery delivery is canceled (#26341)

A canceled recovery delivery released its source spans while the renderer
and model could still settle them; the stale projection then threw on every
later ACK, so the next delivery was never credited and the relay paused the
PTY for good. Settling or transferring a span of a closed delivery is now a
no-op.

Co-authored-by: m4air <[email protected]>

* fix(rpc): deny-by-default caller permissions and a scoped SSH bridge credential (#26337)

* fix(rpc): deny-by-default caller permissions and a scoped SSH bridge credential

Every RPC method now declares a required permission, and RpcDispatcher checks it
against the caller's scope on every transport (owner, mobile, paired runtime,
SSH bridge). The SSH relay bridge no longer spawns the client CLI with owner
authority: each invocation gets a short-lived credential bound to its SSH target,
revoked when the child exits. Without the new per-host opt-in, that credential
reaches only its own host's terminals; with it, workspace methods but never
desktop control, accounts, settings writes, skill install/share, pairing or host
admin. Paired runtime clients need a pairing-time grant (orca serve
--grant-desktop-control) for computer.* actions.

Fixes #23835
Fixes #25259
Refs #18269

* fix(rpc): let a bridged SSH worker report to its own coordinator; allowlist paired-runtime permissions

Without the per-host opt-in, orchestration send/ask/reply/check/inbox now pass when the caller is a
terminal on the bridged host, binding pane key, payload Dispatch, run and recipient to that caller's
own orchestration (recipient off-host only as the creator of its active Dispatch).

Paired runtime clients get an explicit standard permission set; pairing-admin and desktop-control
are grant-only.

* fix(rpc): resolve a bridged SSH caller's own Run and Dispatch mailboxes before admission

Mail routing stores a worker's follow-ups under dispatch:<id> and worker
questions under run:<id>, so comparing the original recipient to the caller's
terminal handle refused an SSH worker replying to its coordinator, an SSH
coordinator answering its own Run's question, and explicit sends to the
caller's own run:/dispatch: address. The bridge now resolves the exact
mailboxes the caller's live pane and process read (as check does) and admits
replies and recipients against those.

* refactor(rpc): parse SSH bridge selectors with a typed schema instead of Reflect.get

---------

Co-authored-by: m4air <[email protected]>

* fix(projects): remove a project only on the host the user picked (#26340)

* fix(projects): remove a project only on the host the user picked

removeProject now requires a hostId and matches that host's row exactly.
The bare-id fallbacks (unique candidate, focused host) could resolve to
another host's live project and delete it. Orphaned SSH purge and group
deletion now pass each row's own host.

Fixes #13071

* fix(projects): group delete removes only the group's member rows

Same-id rows on other hosts outside the group were removed because membership
was rebuilt from bare ids after the cascade cleared it. Capture (id, host)
member pairs before deletion and remove only those.

* fix(projects): never let a stale catalog widen a project removal to every host

The renderer chose id-only `repos:remove` when its own catalog showed no
same-id row on another host. A stale catalog (another window, a paired
client, or a pending refresh) hid that row, and main then deleted every
host's registration and saved workspace metadata.

- The local catalog route now always calls `repos:removeForHost` with the
  owner row's host, for local, direct SSH, git and folder projects.
- `Store.removeProject` refuses an id that rows on more than one host share,
  so no id-only caller can delete another host's row.
- Setup rollbacks remove the just-created row by its host.

---------

Co-authored-by: m4air <[email protected]>

* fix(serve): load SSH targets on a headless serve; a user Quit only closes serve-hosted windows (#26348)

* fix(serve): load SSH targets on a headless serve; a user Quit only closes serve-hosted windows

- launchServeMode registers the SSH handler layer before RPC binds, so a windowless
  'orca serve' lists and connects the profile's SSH targets (#25886, #8489).
- Under serve, the app-menu Quit/Exit, tray Quit and renderer-recovery Quit close the desktop
  windows instead of quitting the process (#15537). Signals, supervisor stops, relaunches and
  update installs still quit normally; on macOS a signal reaches before-quit the same way
  Cmd-Q does, so the guard lives on the user commands, not in before-quit.

* fix(serve): SSH profiles serve on Electron; native macOS quits and frozen windows no longer trap or stop serve

- orca serve: a profile with saved SSH targets stays on the Electron host by default, since
  orcad has no SSH stack yet (#25886, #8489). ORCA_SERVE_RUNTIME=orcad still forces orcad.
- macOS serve: Dock > Quit, app-switcher Cmd-Q and other native terminates only close the
  desktop windows (#15537). Signals, supervisor stops, relaunches, update installs and
  logout/shutdown still quit.
- The serve signal listeners now reclaim SIGINT/SIGTERM/SIGHUP from Electron's native handler.
  Any signal that had a Node listener before app ready was left with Electron's handler, so
  these listeners never ran.
- A serve user Quit closing a frozen renderer's window arms the same 10s ack deadline as a
  desktop quit, and skips minimize-to-tray.

* fix(serve): stay on Electron when the profile's SSH targets cannot be read yet

A valid older-schema profile is rejected by the read-only probe, and the
selector took that as "no SSH", so a default serve before the first
migration started orcad with an empty SSH registry. Fail closed instead.

* refactor(window): type user-Quit close marks as a named window slice, not object

* test(serve): pass the desktop-control grant default in the headless SSH launch fixture

* test(serve): run the serve-selection SQLite fixtures in the Node runtime project

---------

Co-authored-by: m4air <[email protected]>

* fix(terminal): keep the main-process terminal tail linear under TUI redraw floods (#26316)

* fix(terminal): keep the main-process terminal tail linear under TUI redraw floods

Full-width in-place row rewrites rebuilt the row string per character
(O(width^2)), a long chunk past the line cap spliced the row array once
per newline (O(lines x cap)), and multi-frame chunks summed every
cursor-up so they fell back to the whole-tail path. Rows now hold
mutable cells joined once, capped rows are dropped in batches, and the
redraw window uses the net cursor reach.

Fixes #11315

* fix(terminal): do not rebuild a redraw row the cursor only revisits

Rows stayed cell arrays once touched and re-joined on every newline, so a
cursor revisiting one wide row thousands of times cost O(width) per
newline. Runs now splice into the row string, a row switches to cells
only after 32 edits between snapshots, and cells are joined once and
dropped.

* fix(terminal): keep one cached row per chunk so unchanged redraw revisits cost O(1)

A row now keeps its cells, right-trimmed snapshot and content end across
newlines and only invalidates them on a real content change; identical
writes leave it clean. Adds a work-accounting matrix over restore, the
append path and live onPtyData, plus a per-character row oracle fuzz.

* fix(terminal): return redraw rows to flat strings with cached snapshots

Cells made every changed snapshot a full-width join, which was far slower
than the old flat-string splice. Rows are flat strings again, written one
run at a time; each keeps a cached right-trimmed snapshot and content end
that only a real change invalidates, so identical rewrites and cursor-only
revisits stay O(1). A wall-time test now times every review probe against
a vendored copy of the old row model on restore, append and onPtyData.

* test(terminal): read runtime leaf and PTY tail through typed members

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>

* fix(ssh): relay fallback runs Orca's pinned Node by default, never a host npm install (#26303)

* fix(ssh): relay fallback runs the pinned Node ladder by default, never a host npm install

A host whose connect falls back to the relay route now gets the A/B/C ladder
(Orca's uploaded Node and prebuilt addons) unless it opts into Host Node. A
refused rung C steps to rung D with an actionable reason instead of compiling
native deps on the host.

* fix(ssh): mark the opt-in Host Node relay runtime as unsupported on the SSH host card

The relay fallback now defaults to Orca's pinned Node ladder; the host-npm path is
reachable only by an explicit per-host Runtime or ORCA_SSH_REMOTE_RUNTIME override.
When a relay actually launches on it, main publishes hostNodeRuntime on the
connection state (optional, admitted field-by-field for paired clients) and the
SSH host card shows an unsupported-configuration warning.

* fix(ssh): keep the relay runtime ladder honest about what it cannot verify

- NixOS's stub loader refusing Orca's generic Linux Node (exit 127, 'Could not
  start dynamically linked executable') is classified wrong_libc, so the ladder
  steps on to the host Node instead of failing the connect at rung A.
- In plain SSH mode the shell provider answers absent only for shells it saw
  exit; a PTY id it never minted (one an earlier relay may still run) is
  unverifiable, never exited.
- The rung D message offers Host Node only when the host's own Node refused the
  prebuilt addons, and calls it an unsupported configuration; a download,
  unresolved-host or Windows refusal gets no Host Node advice.

* fix(ssh): keep the host-Node relay where the ladder can't judge the host

A client without Orca's runtime artifacts (a dev, e2e or source build with no
orcad template, or an offline client) refused rungs A and C with
artifacts_unavailable, and the connect settled on rung D. That reason describes
the client, so it now lands on the host-Node relay it had before the ladder,
marked unsupported, and persists no host decision. A proved noexec still lands
on D.

Windows hosts have no rung B or C yet, so any rung A refusal there keeps the
host-Node relay too. The rung D message is worded from the host OS: Windows
gets no noexec-mount wording and is offered Host Node.

* fix(ssh): a host-Node fallback with no Node settles rung D, and mutable refusals expire

The host-Node relay the ladder chooses in place of D (a client artifact gap,
or a Windows rung A refusal) hard-failed the connect when the host had no
Node: the resolver threw a plain Error, which plain SSH mode does not admit.
The fallback now proves host Node with a strict probe first; an answered
"no Node" settles D with a classified, host-OS worded reason, and an
unanswered probe stays a retryable failure. A gap no longer rewrites D to
host Node once rung C proved host_node_missing.

Mutable pinned-runtime refusals (missing_lib, security_software, and noexec
on Windows) are no longer persisted and replay from memory for ten minutes
only, so a repaired host gets rung A back. The in-memory refusal cache moves
to ssh-relay-pinned-refusal-cache.ts.

* fix(ssh): no host does worse than the pre-ladder host-Node default

Restructure the relay runtime ladder around one invariant: A, B and C are tried
first, and any refusal past them falls back to exactly the pre-ladder default,
the host-Node relay marked unsupported. That covers an unidentified libc, a
client artifact gap, Windows, mutable refusals and a C N-API floor the npm build
would not have hit. Rung D is reached only when that fallback proves the host
has no usable Node, or a proved noexec home would defeat it too.

Strict host-Node resolution now treats only a command that ran and exited as an
answer, so a refused channel (MaxSessions), session limit or timeout stays a
retryable failure instead of a 'no Node' verdict. The launch reuses the Node the
fallback probe found.

Mutable refusals (missing_lib, security_software, Windows noexec) persist again
with their proof time and replay for 24 hours, so a host that still blocks
Orca's runtime is not re-uploaded to on every connect, while a repaired one gets
rung A back. A table-driven test asserts the invariant per host class.

* fix(ssh): every answered rung failure reaches the host-Node default, and D only past it

Two shortcuts skipped the pre-ladder default. An answered but unclassified
install failure (tar ENOSPC, an extract or hash marker, an unverified Windows
promote, a self-test that failed outside every refusal class) aborted the
connect on every attempt; it now steps down as a non-persisted install_failed.
Only unanswered failures (abort, timeout, channel-open, session limit, an
unconfirmed termination, SFTP connection loss, ssh exit 255) stay retryable,
and nothing steps down once a relay launch was issued.

A proved noexec no longer jumps to D: exec denial can be per binary (AppArmor
allowing /usr/bin/node), so it skips B and C, which load from the same tree,
and reaches the host-Node fallback. D now follows only that fallback answering
with a failure, so its outcome is a superset of the default's by construction.

The never-worse test is now the cross-product of every A, B, C and host-Node
answer on Linux and Windows, plus named review cases.

* fix(ssh): system-ssh upload failures and a broken cached runtime step down before launch

System-ssh directory upload and system sftp threw plain Errors that dropped the
host's exit status, so a remote tar ENOSPC or a Windows sftp permission refusal
aborted the connect instead of stepping down. The remote side now throws
SystemSshCommandExitError (ssh exit 255, signals and lost-connection
diagnostics stay retryable), and a local tar failure is still blamed on the
client rather than the remote tar that saw its truncated stream.

The warm runtime check only tested that the verified executable existed, so a
cached runtime that the host's exec policy or a removed library had since broken
was launched and hung on every reconnect. The same command now also runs it and
reports a refusal the way promotion does, so it steps down before any launch,
with no extra round trip.

* fix(ssh): keep the remote answer when local tar only failed writing to it

When the host's tar exits early (ENOSPC, a refusal), BSD tar on macOS exits 1
with 'Write error' and no signal, so the upload rethrew the local error and
dropped the typed remote exit, aborting the connect. The remote answer now wins
whenever local tar finished, was signalled, failed after ssh closed, or reported
a write or pipe error; a local tar that failed on its own input first is still
the client's fault.

* test(ssh): hostile-host cells allow read-only version probes, never installs; probe each Node once

The noexec-home cell failed on 'npm --version': under the never-worse ladder a
proved noexec reaches the strict host-Node fallback, whose probe asks npm its
version before settling D. The cells now judge install and compile calls (npm
install/ci, node-gyp, cc, make) and allow '<tool> --version' / '-v'.

The probe ran twice because the login shell named the Node the path probe had
already rejected. Candidate checks are now memoized per resolution, for the
host-Node fallback and rung C alike.

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>

* chore(i18n): regenerate the runtime-required English catalog after the main merge

* fix(serve): serve on the profile the CLI selected, and refuse any other before the instance lock (#26424)

Co-authored-by: m4air <[email protected]>

* fix(remote-runtime): open terminal tabs reattach after a managed server update re-pairs the host (#26433)

* fix(remote-runtime): a remote pane rebinds after a server update re-pairs its host

A pane captured the host's pairing revision once, when it mounted. A forced
managed-server update re-pairs the host under the same environment id, so every
later request from that pane was refused as stale, and the refusal counted as
fatal: the pane stopped retrying and Reconnect replayed the same stale revision.
Each request now carries the current revision, a pairing refusal re-reads the
catalog before the retry, and the pane treats it like lost contact.

* fix(remote-runtime): close a stream left on the old pairing and ignore a 0x0 grid hold

A stream that reopened before main re-paired stayed open while sendFrame refused
its stale revision, so typed keys vanished. A revision change now closes it as
recoverable so the pane rebinds on the new pairing. A just-restarted server also
published a 0x0 hold that shrank the visible pane to one cell; holds with no grid
are ignored.

* fix(remote-runtime): a pane follows only its own machine's re-pair

A re-pair under the same environment id to a different host key published its
revision before the catalog retired the old tabs, and the pane recovered at
the new revision, so its next call was authenticated as the replacement peer.
The catalog now classifies each re-pair before publishing revisions: a
replaced or removed machine's terminal streams end for good first, and a pane
only advances its pairing along a proven same-host rotation (same registration
and host key). An unresolved identity holds the pane until it is proven.

---------

Co-authored-by: m4air <[email protected]>

* refactor(rpc-permissions): Phase 3.5 elegance pass (#26471)

* refactor(rpc-permissions): drop never-read incarnation and invocation id from bridge credentials

* refactor(rpc-permissions): define runtime device grants once and reuse bridge scope fixtures

* refactor(rpc-permissions): decide terminal host membership in one predicate and share the opt-in hint

* refactor(rpc-permissions): parse bridge selectors once per call

* refactor(rpc-permissions): admit and bind unopted bridge methods from one table

---------

Co-authored-by: m4air <[email protected]>

* refactor(remote-pane-binding): Phase 3.5 elegance pass (#26470)

* refactor(remote-pane-binding): keep the pane's pairing revision in one slot

* refactor(remote-pane-binding): share one hold decision across the input entry points

* refactor(remote-pane-binding): define the persisted-handle adopt once in attachPane

* refactor(remote-pane-binding): build the pushed-snapshot meta once

* refactor(remote-pane-binding): drop the test-only peerReplacedEnvironmentIds wrapper

* test(remote-pane-binding): share the input and subscribe frame readers via stream fixtures

---------

Co-authored-by: m4air <[email protected]>

* refactor(relay-ladder): Phase 3.5 elegance pass (#26474)

* refactor(relay-ladder): put the host-Node fallback in the ladder before D

The Auto ladder now lists legacy as the rung before D, so the step function
is one rule plus the next rung. Deletes nextRelayRuntimeStep, the hostOs
step context and the mutable hostNodeFallback flag (now a constructor-time
laddered field). Windows still ends at legacy: B and C refuse there before
any host I/O.

* refactor(relay-ladder): one rung-D reason and message over reachable states

D is reached only from the host-Node fallback, so its refusal is
host_node_missing or install_failed. Merges the reason and message
functions, drops three message branches that could not run, and folds
noexecRemembered/noexecProved into one noexec field.

* test(relay-ladder): one never-worse cross-product with a remembered axis

Drops the named cases (each matches a cross-product outcome), the transport
case that only checked the model against itself, and the third case the rank
check already implies. Adds rung B's noexec answer and per-rung remembered
flags for A and B, the only rungs that replay a cached refusal.

* refactor(ssh): one answered-miss rethrow for the node resolution probes

Four catch blocks repeated the same session-limit, abort and strict checks.
They now call rethrowUnlessAnsweredMiss and keep their own fallthrough.
Also drops a stale 'Caches nothing' comment.

* refactor(ssh): share the host-answered system-ssh exit rule; flatten the upload throw cascade

isHostAnsweredSystemSshExit owns the 255/null transport rule for both the
upload pipeline and isAnsweredHostFailure. settleUploadPipeline drops a
branch that could not run: a failed tar is judged once, then ssh, then pipe.

---------

Co-authored-by: m4air <[email protected]>

* refactor(serve-daemon-misc): Phase 3.5 elegance pass (#26478)

* refactor(ssh-pty): build obligation transitions behind one closed-delivery guard

* refactor(build-orcad): table-drive the shipped worker smokes

* refactor(daemon): pass scope probe seams as one deps object and share cgroup line parsing

* refactor(repos): route every project removal through removeProjectForHost

* refactor(build-orcad): type the worker smoke table for the type-aware gate

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>

* refactor(terminal-tail): Phase 3.5 elegance pass (#26465)

* refactor(terminal-tail): share mulberry32 and compare whole results in redraw equivalence tests

* refactor(terminal-tail): keep one splice ceiling at the onPtyData entry point

---------

Co-authored-by: m4air <[email protected]>

* fix(terminal): bound the backing a redraw row can pin across chained erases (#26547)

Each erase that keeps at least half the row skipped the copy, so a chain
of them left nested slices pinning the original wide row. Rows now track
an upper bound on the string they slice and copy once the cumulative
shrink passes half.

Co-authored-by: m4air <[email protected]>

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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