Skip to content

feat(ssh): relay runtime fallback ladder, telemetry and host runtime setting - #24133

Merged
OrcaWin merged 5 commits into
mainfrom
OrcaWin/node-rt-p2-ladder
Oct 1, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
OrcaWin/node-rt-p2-ladder

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​749 $\color{#cf222e}{\Huge{\mathbf{−}}}$​24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​725
Prod 28 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1296 $\color{#cf222e}{\Huge{\mathbf{−}}}$​143 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1153

ELI5

When Orca's pinned Node can't run on an SSH host, Orca now tries the next option instead of failing. First Orca's pinned Node, then (later) an old-glibc build, then the host's own Node with Orca's prebuilt addons, then today's npm path. If nothing works, the connection fails with a clear reason. A new per-host setting chooses the runtime.

What Changed

  • Ladder (ssh-relay-runtime-ladder.ts), used when the runtime is "Orca-managed Node":

    • A: Orca's pinned Node.
    • B: a slot for an old-glibc build (none ship yet).
    • C: the host's own Node (18 or newer, N-API 8 or newer) with Orca's prebuilt addons. It uses an addon-only probe that never needs npm.
    • Legacy: today's npm path.
    • D: a RemoteRuntimeUnavailableError whose message and TerminalUnavailableCause state the reason.

    It steps down only on a classified refusal. Anything unverifiable fails the connect, and the next connect retries the same rung.

  • Persisted decision: SshTarget.remoteRuntimeResolution records the result. A rung A refusal is reused only while the glibc version, runtime hash and Orca major version still match. It resets when the host, port or runtime setting changes.

  • Telemetry: ssh_remote_runtime_resolved, enum fields only, behind the existing consent gate. It's sent once per host per session, and the host key is never sent. telemetry.mdx lists what it collects.

  • Settings: SSH host → Advanced → Runtime, with Auto, Orca-managed Node and Host Node. Auto keeps today's default.

Why

This is design D6: nobody who connects today should be locked out, and a noexec home or policy refusal should produce a stated reason instead of a silent failure.

Linked Issue

Part of the Node runtime plan (Phase 2). Stacked on #24129.

Visual Proof

Captured from the e2e build in the background (ORCA_BACKGROUND_LAUNCH=1, headless, isolated profile). A seeded SSH host is open at Settings → SSH Hosts → Edit target → Advanced.

Before (base branch): Advanced has no Runtime setting.

Light Dark

After: Advanced shows a Runtime select with help text. It defaults to Auto.

Light Dark

After, select open: Auto, Orca-managed Node, Host Node.

Light Dark

Testing

  • Tests: 14,285 tests pass across src/main/ssh, settings, shared and prebuild. They cover each rung, the noexec → D path, descent from A through B and C to legacy, the persisted refusal and key mismatch, and telemetry sent once.

  • Fixed in review: a remembered noexec is now cleared once rung C passes, and rung B can match musl hosts.

  • Not done:

    • Rung D gives a reason only. Plain SSH terminals and SFTP browsing without the relay need a new PTY and filesystem provider.
    • Remote AI Vault isn't gated for host Node below 22.16.
    • Windows hosts still use the legacy path.
  • I manually tested these changes locally

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

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.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 1/5

[High risk] Refactors SSH relay runtime selection and adds telemetry.

The PR does not appear safe to merge because a classified permission refusal can block a usable SSH host, and previously identified cache-invalidation failures remain.

Findings

  1. P1 Permission Refusal Skips Fallbacks ▶
  2. P1 Config imports retain stale decisions ▶
  3. P1 Endpoint edits retain memory refusals ▶
  4. P2 Default Runtime Goes Unreported ▶
  5. P2 Rejected events consume the quota ▶

Summary

The PR adds an SSH relay runtime fallback ladder, persists per-host runtime decisions, records runtime telemetry, and exposes a per-host runtime setting.

  • The ladder includes pinned Node, a future compatibility slot, host Node with prebuilt addons, and the existing npm path.
  • A fresh runtime-specific permission refusal can prematurely block an otherwise usable host; default-runtime connections are omitted from the new telemetry.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Pinned Node"] -->|classified refusal| B["Compat slot"]
  B -->|unavailable| C["Host Node + prebuilt addons"]
  C -->|classified refusal| L["Host Node + npm"]
  L -->|unavailable| D["Connection failure"]
  A -->|fresh noexec classification| D
Loading

Reviews (4) · Last reviewed commit: "test(ssh): import node:fs once in the ho..."

Comment on lines +92 to +96
const resetsRuntime =
changed('remoteRuntime') || changed('host') || changed('port') || changed('configHost')
const updated = this.store.updateSshTarget(
id,
resetsRuntime ? { ...updates, remoteRuntimeResolution: undefined } : updates

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Config imports retain stale decisions

When a config-managed SSH host changes its HostName or port during import, the import updates the underlying store directly and bypasses this cache reset. If the new endpoint has the same glibc version, Orca can replay a refusal from the old host and skip its pinned Node on the new one. Config imports need the same decision invalidation as manual endpoint edits.

Comment on lines +94 to +96
const updated = this.store.updateSshTarget(
id,
resetsRuntime ? { ...updates, remoteRuntimeResolution: undefined } : updates

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Endpoint edits retain memory refusals

This clears the stored decision but leaves the in-memory pinned-Node refusal, which is keyed by target ID and runtime hash rather than endpoint. If a target is edited to point to another host in the same app session, Orca checks that old refusal first and can skip rung A even when the new host supports it. Clear the in-memory refusal when the endpoint changes.

Comment on lines +100 to +106
if (reportedHosts.has(hostKey)) {
return
}
reportedHosts.add(hostKey)
try {
// track() applies the existing consent gate and validates against the strict schema.
track('ssh_remote_runtime_resolved', sshRemoteRuntimeResolvedProps(input))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Rejected events consume the quota

The host is marked as reported before track() says whether it accepted the event. If a user connects while telemetry consent is disabled and enables it later in the same app session, the later connect is deduplicated, so no runtime event is sent for that host. Mark it reported only after track() succeeds.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Warm installs skip runtime validation src/main/ssh/ssh-relay-deploy.ts:603 ▶

    Rung C selects the host Node again on each connection, but an installed addon directory is reused without testing it against that Node. If the host Node or its library environment has changed, the version and N-API probe can pass while the relay fails to launch. That failure becomes a startup error instead of a classified refusal that could reach the legacy npm path. Revalidate the installed runtime when its host Node changes, or make the installation identity reflect that Node.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions only — one inline note and one design tradeoff worth confirming.

Reviewed changes

  • Ladder core — relayRuntimeLadder and nextRelayRuntimeStep express the A/B/C/legacy/D descent as data; fresh noexec and C + host_node_missing short-circuit to D, a remembered noexec only skips its own rung.
  • Per-host decision + telemetry — RelayRuntimeLadderRun persists the rung under a glibc/runtime-hash/Orca-major key that a passing rung C can disprove, and emits ssh_remote_runtime_resolved once per target per session (strict enum-only schema, host key never sent).
  • Rung C — planHostNodeAddonRelay runs Orca's prebuilt N-API addons on the host's own Node (>= 18, N-API >= 8) with no npm, via the addon-only toolchain probe and resolveRemoteHostNodeForAddons; unanswered probes throw rather than reading as "no Node".
  • Deploy loop — deployAndLaunchRelayInner walks the ladder, caches the detected platform on the run, and raises RemoteRuntimeUnavailableError at D; deployAndLaunchRelayOnRuntime skips ensurePinnedRelayRuntime for host-node-addons.
  • Settings + persistence — a Runtime select (Auto / Orca-managed Node / Host Node), save/draft plumbing, remoteRuntimeResolution normalization, and a clear-on-endpoint/runtime change in updateTarget.
  • Docs — telemetry.mdx documents the new event.

ℹ️ A persisted noexec re-runs rung C (plan + full upload + failing self-test) on every reconnect

On the first connect to a noexec home, a fresh rung A refusal short-circuits straight to D. Once that refusal is persisted, later connects treat it as remembered and step to B and then C, so each reconnect plans C, uploads the relay, and self-tests it only to fail the same way; a refused C install is abandoned without the completion sentinel, so nothing is reused next time. That is the deliberate "re-prove, the mount may have changed" rule, but on a permanently noexec host it is a per-connect cost — worth confirming it is the intended trade.

Technical details
# Remembered noexec pays a full rung C attempt per connect

## Affected sites
- src/main/ssh/ssh-relay-runtime-ladder.ts:63 — `!remembered` is what sends a fresh noexec to D while a remembered one advances to B
- src/main/ssh/ssh-relay-runtime-resolution.ts:105 — only a passing rung C clears the remembered noexec (and only with a self-test, not a warm launch)
- src/main/ssh/ssh-relay-deploy.ts:499 — rung C plans the host-node-addons relay, then `deployAndLaunchRelayOnRuntime` uploads + verifies it
- src/main/ssh/ssh-relay-versioned-install.ts:179 — a refused C install is abandoned without the completion sentinel, so the next connect re-uploads

## Required outcome
Decide whether a persistently noexec host should retry C on every connect (current behaviour) or whether the remembered refusal should settle to D after one failed re-proof, and make the choice explicit.

## Open questions for the human
Is one rung C upload + self-test per reconnect acceptable on a host whose home is permanently noexec?

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

// Why: a new runtime choice or endpoint must re-run the ladder, not replay the old rung.
const changed = (key: 'remoteRuntime' | 'host' | 'port' | 'configHost'): boolean =>
key in updates && existing?.[key] !== updates[key]
const resetsRuntime =

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.

This reset only runs through SshConnectionStore.updateTarget, but passive ~/.ssh/config sync (importFromSshConfig) rewrites host/port straight through store.updateSshTarget, so a repointed config alias keeps its cached remoteRuntimeResolution. Because the cache key is glibc + pinned-runtime hash + Orca major and not the endpoint, a host that moved to a machine which would qualify for rung A keeps skipping it.

Technical details
# Config-sync endpoint change does not clear the cached ladder decision

## Affected sites
- src/main/ssh/ssh-connection-store.ts:92 — `resetsRuntime` only guards `updateTarget`
- src/main/ssh/ssh-connection-store.ts:224 — `importFromSshConfig` calls `store.updateSshTarget(existing.id, { ...nextFields, source: 'ssh-config' })` directly, bypassing the reset

## Required outcome
An endpoint change to a config-sourced target must clear `remoteRuntimeResolution` the same way a renderer edit does, so the ladder re-runs against the new endpoint.

## Suggested approach
Route the sync write through `updateTarget` (note it also reclaims the alias), or clear the field inside `importFromSshConfig` when `host`/`port` differ.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found in the incremental delta.

Reviewed changes

  • Test-only cleanup (1b7e39a) — readdirSync is folded into the existing node:fs import in ssh-relay-host-node-addons.test.ts and its duplicate import removed. No production or behavioral change.

The two prior notes from the initial review (the config-sync cached-decision gap inline, and the per-reconnect rung C cost at D) are unaffected by this commit and remain open.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

m4air added 5 commits October 1, 2026 01:42
…t, C, D)

Rung C runs the relay on the host's Node >= 18 with Orca's prebuilt N-API
addons and no npm (addon-only probe mode). Rung B is a data-driven slot chosen
only when a compat runtime is listed. Rung D fails the connect with a
classified reason carried as a TerminalUnavailableCause. The ladder steps
down only on classified refusals; unanswered probes throw. The rung decision
is persisted per host keyed by (glibc, runtime hash, Orca major), and
ssh_remote_runtime_resolved reports it once per host per session.
…ibc-less compat runtimes

A remembered rung A noexec was re-persisted even after rung C self-tested addons from the same
~/.orca-remote tree, so rung A stayed skipped until the key changed. Rung B's evaluator also could
never match a musl compat runtime.
@OrcaWin
OrcaWin force-pushed the OrcaWin/node-rt-p2-ladder branch from 1b7e39a to f6ff3df Compare October 1, 2026 08:43
@OrcaWin
OrcaWin changed the base branch from OrcaWin/node-rt-p2-relay to main October 1, 2026 08:52
@OrcaWin OrcaWin closed this Oct 1, 2026
@OrcaWin OrcaWin reopened this Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered
📝 Walkthrough

Walkthrough

The SSH settings now support Auto, pinned Node, and legacy runtime choices. Relay deployment uses a runtime ladder that can plan with pinned Node or host Node, persist decisions, and report unavailable-runtime outcomes. Host-Node planning checks Node and N-API requirements and stages addons. The changes also add transfer and self-test tracking, strict SSH runtime telemetry, and persistence validation for runtime choices and resolution data.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to f6ff3

Resolve stale runtime decisions after SSH config changes before merging. Also preserve the structured unavailable-runtime outcome when the final fallback fails. Runtime telemetry can be lost after a rejected capture, although its intended retry behavior remains unclear.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to f6ff3

Runtime verification and bounded, consent-gated telemetry provide useful controls. However, SSH configuration imports can carry a saved runtime refusal to a different endpoint, causing future connections to skip the managed runtime without checking it on that host.

Retained concerns

  • Medium · security · observed: SSH configuration synchronization preserves remoteRuntimeResolution when an existing target changes host or port. If the replacement endpoint has matching glibc and build facts, its first managed-runtime attempt can be skipped using the previous endpoint's refusal. This makes runtime provenance depend on observations from another host and extends the pre-existing session-cache problem across application sessions.
Security review details

Security Blast Radius

  • inferred — The demonstrated cache-ownership exposure follows a reused SSH target registration and affects runtime selection on its replacement endpoint. Matching build and glibc facts constrain reuse. Broader tenant, account, credential, or local privilege exposure was not established.

Security Findings and Attack Paths

  • inferred — A saved refusal from one endpoint can survive configuration synchronization to another endpoint and suppress its managed-runtime attempt. Exploiting this deliberately would require influence over the relevant remote observations and endpoint configuration; an unauthenticated attack path or privilege gain was not demonstrated.

Trust Boundaries and Controls

  • observed — Telemetry capture retains live-consent and schema-validation gates. Renderer IPC rejects the main-owned runtime-resolution event, and SSH settlement invokes its tracker directly from the main process.

Resilience and Maintainability Implications

  • observed — The connection manager rejects overlapping ordinary connects for one target, providing counterevidence against unrestricted concurrent settlement. However, runtime-resolution persistence writes by target identifier without an expected endpoint or configuration revision, so this protection does not establish stale-write rejection after target edits.

Hardening Proposals

  • proposed — Bind cached decisions and settlement writes to an endpoint and runtime-configuration revision, and apply invalidation through every target mutation path, including configuration imports. This would also provide an explicit stale-settlement rejection rule.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 85 functions across 41 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: the SSH relay runtime fallback ladder, telemetry, and host runtime setting.
Description check ✅ Passed The description is detailed and covers the required ELI5, changes, rationale, linked issue reference, visual proof, testing, and upstream-boundary sections. It omits the AI Disclosure, Review, Notes, …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 85 functions across 41 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a582048d-8d68-416f-be0c-0dcc0448e365

📥 Commits

Reviewing files that changed from the base of the PR and between a560137 and f6ff3df.

📒 Files selected for processing (43)
  • config/scripts/orcad-prebuild-slot-contents.test.mjs
  • docs/site/content/docs/telemetry.mdx
  • src/main/ipc/ssh-target-crud-handlers.ts
  • src/main/ipc/telemetry.ts
  • src/main/persistence-ssh-targets-and-pane-keys.test.ts
  • src/main/persistence/leasing-ssh-ptys/ssh-normalization.ts
  • src/main/ssh/orcad-remote-node-runtime.ts
  • src/main/ssh/ssh-connection-store.test.ts
  • src/main/ssh/ssh-connection-store.ts
  • src/main/ssh/ssh-relay-deploy-pinned-node.test.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-host-node-addons.test.ts
  • src/main/ssh/ssh-relay-host-node-addons.ts
  • src/main/ssh/ssh-relay-opencode-pinned-node.test.ts
  • src/main/ssh/ssh-relay-opencode-pinned-node.ts
  • src/main/ssh/ssh-relay-pinned-node-install.test.ts
  • src/main/ssh/ssh-relay-pinned-node-install.ts
  • src/main/ssh/ssh-relay-pinned-node.test.ts
  • src/main/ssh/ssh-relay-pinned-node.ts
  • src/main/ssh/ssh-relay-runtime-ladder.test.ts
  • src/main/ssh/ssh-relay-runtime-ladder.ts
  • src/main/ssh/ssh-relay-runtime-resolution.test.ts
  • src/main/ssh/ssh-relay-runtime-resolution.ts
  • src/main/ssh/ssh-relay-runtime-self-test.ts
  • src/main/ssh/ssh-relay-runtime-step-plan.ts
  • src/main/ssh/ssh-remote-node-addon-resolution.test.ts
  • src/main/ssh/ssh-remote-node-addon-resolution.ts
  • src/main/ssh/ssh-remote-node-resolution.ts
  • src/main/ssh/ssh-remote-node-toolchain-probe.test.ts
  • src/main/ssh/ssh-remote-node-toolchain-probe.ts
  • src/main/ssh/ssh-remote-runtime-telemetry.test.ts
  • src/main/ssh/ssh-remote-runtime-telemetry.ts
  • src/renderer/src/components/settings/SshHostAdvancedFields.tsx
  • src/renderer/src/components/settings/ssh-target-draft.test.ts
  • src/renderer/src/components/settings/ssh-target-draft.ts
  • src/renderer/src/components/settings/ssh-target-save-payload.test.ts
  • src/renderer/src/components/settings/ssh-target-save-payload.ts
  • src/renderer/src/components/sidebar/add-remote-host-ssh-actions.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/orcad-artifacts.ts
  • src/shared/ssh-types.ts
  • src/shared/telemetry-event-registry.ts
  • src/shared/telemetry-ssh-runtime-event-schemas.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Comment on lines +438 to +452
{ step, run }
)
// Why only a laddered pass: a plain host-npm connect has no rung decision to record.
if (ladder.length > 1) {
run.settle(step)
}
return result
} catch (err) {
if (err instanceof PinnedRelayFallbackError) {
logPinnedRelayFallback(err.reason, err.detail)
runtime = 'legacy'
if (err instanceof PinnedRelayFallbackError && step !== 'legacy' && step !== 'D') {
console.warn(
`[ssh-relay] Relay runtime rung ${step} unavailable (${err.reason}): ${err.detail}`
)
run.refused(step, err.reason)
step = nextRelayRuntimeStep(ladder, step, err.reason, err.remembered)
run.enter(step)

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:

sed -n '410,462p' src/main/ssh/ssh-relay-deploy.ts
sed -n '540,620p' src/main/ssh/ssh-relay-deploy.ts
rg -n 'resolveRelayBootstrapState|host_node_missing|RemoteRuntimeUnavailableError' src/main/ssh

Repository: stablyai/orca

Length of output: 6958


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- changed files/stat ---'
git diff --stat a5601375d44cc245e5bc5c3bbdb1d1c48f28e5c6 f6ff3df6590e693ca3ebafdc883756df9f058535
printf '%s\n' '--- runtime ladder ---'
cat -n src/main/ssh/ssh-relay-runtime-ladder.ts
printf '%s\n' '--- bootstrap resolver ---'
sed -n '280,395p' src/main/ssh/ssh-relay-deploy.ts | cat -n
printf '%s\n' '--- host-node addon resolver ---'
cat -n src/main/ssh/ssh-relay-host-node-addons.ts
printf '%s\n' '--- runtime resolution errors ---'
sed -n '120,205p' src/main/ssh/ssh-relay-runtime-resolution.ts | cat -n
printf '%s\n' '--- pinned-node deploy tests around unavailable runtime ---'
sed -n '350,430p' src/main/ssh/ssh-relay-deploy-pinned-node.test.ts | cat -n
printf '%s\n' '--- relevant catch/error usages ---'
rg -n -C 4 'RemoteRuntimeUnavailableError|PinnedRelayFallbackError|resolveRelayBootstrapState|host_node_missing|no_runtime|deployAndLaunchRelay' src/main/ssh --glob '*.{ts,d.ts}'

Repository: stablyai/orca

Length of output: 45665


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/architecture /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 47850


🏁 Script executed:

#!/bin/bash
set -e
git diff --stat a5601375d44cc245e5bc5c3bbdb1d1c48f28e5c6 f6ff3df6590e693ca3ebafdc883756df9f058535
cat -n src/main/ssh/ssh-relay-runtime-ladder.ts
sed -n '280,395p' src/main/ssh/ssh-relay-deploy.ts | cat -n
cat -n src/main/ssh/ssh-relay-host-node-addons.ts
sed -n '120,205p' src/main/ssh/ssh-relay-runtime-resolution.ts | cat -n
sed -n '350,430p' src/main/ssh/ssh-relay-deploy-pinned-node.test.ts | cat -n
rg -n -C 4 'RemoteRuntimeUnavailableError|PinnedRelayFallbackError|resolveRelayBootstrapState|host_node_missing|no_runtime|deployAndLaunchRelay' src/main/ssh --glob '*.{ts,d.ts}'

Repository: stablyai/orca

Length of output: 45665


🏁 Script executed:

git diff --stat a5601375d44cc245e5bc5c3bbdb1d1c48f28e5c6 f6ff3df6590e693ca3ebafdc883756df9f058535
cat -n src/main/ssh/ssh-relay-runtime-ladder.ts
sed -n '280,395p' src/main/ssh/ssh-relay-deploy.ts | cat -n
cat -n src/main/ssh/ssh-relay-host-node-addons.ts
sed -n '120,205p' src/main/ssh/ssh-relay-runtime-resolution.ts | cat -n
sed -n '350,430p' src/main/ssh/ssh-relay-deploy-pinned-node.test.ts | cat -n
rg -n -C 4 'RemoteRuntimeUnavailableError|PinnedRelayFallbackError|resolveRelayBootstrapState|host_node_missing|no_runtime|deployAndLaunchRelay' src/main/ssh --glob '*.{ts,d.ts}'

Repository: stablyai/orca

Length of output: 45665


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- remote node resolution ---'
cat -n src/main/ssh/ssh-remote-node-resolution.ts
printf '%s\n' '--- pinned runtime error declarations ---'
rg -n -C 8 'class PinnedRelayFallbackError|type RelayRuntimeFallbackReason|host_node_missing|resolveRemoteNodePath' src/main/ssh/ssh-relay-pinned-node.ts src/main/ssh/ssh-remote-node-resolution.ts src/main/ssh/ssh-remote-node-addon-resolution.ts
printf '%s\n' '--- deploy imports/entrypoints/planning ---'
sed -n '1,150p' src/main/ssh/ssh-relay-deploy.ts | cat -n
sed -n '150,285p' src/main/ssh/ssh-relay-deploy.ts | cat -n
printf '%s\n' '--- relay runtime resolution beginning and ladder state ---'
sed -n '1,140p' src/main/ssh/ssh-relay-runtime-resolution.ts | cat -n
printf '%s\n' '--- focused deploy tests 236-470 ---'
sed -n '236,470p' src/main/ssh/ssh-relay-deploy-pinned-node.test.ts | cat -n
printf '%s\n' '--- session handling of deployment errors ---'
rg -n -C 6 'deployAndLaunchRelay\\(|RemoteRuntimeUnavailableError|terminalUnavailableCauseFromError|TerminalUnavailableCause|status: .blocked' src/main/ssh src/main/ipc src/shared --glob '*.{ts,d.ts}' --glob '!*.test.ts'

Repository: stablyai/orca

Length of output: 41868


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- remote node resolution ---'
cat -n src/main/ssh/ssh-remote-node-resolution.ts
printf '%s\n' '--- pinned runtime error declarations ---'
rg -n -C 8 'class PinnedRelayFallbackError|type RelayRuntimeFallbackReason|host_node_missing|resolveRemoteNodePath' src/main/ssh/ssh-relay-pinned-node.ts src/main/ssh/ssh-remote-node-resolution.ts src/main/ssh/ssh-remote-node-addon-resolution.ts
printf '%s\n' '--- deploy imports/entrypoints/planning ---'
sed -n '1,150p' src/main/ssh/ssh-relay-deploy.ts | cat -n
sed -n '150,285p' src/main/ssh/ssh-relay-deploy.ts | cat -n
printf '%s\n' '--- relay runtime resolution beginning and ladder state ---'
sed -n '1,140p' src/main/ssh/ssh-relay-runtime-resolution.ts | cat -n
printf '%s\n' '--- focused deploy tests 236-470 ---'
sed -n '236,470p' src/main/ssh/ssh-relay-deploy-pinned-node.test.ts | cat -n
printf '%s\n' '--- session handling of deployment errors ---'
rg -n -C 6 'deployAndLaunchRelay\(|RemoteRuntimeUnavailableError|terminalUnavailableCauseFromError|TerminalUnavailableCause|status: .blocked' src/main/ssh src/main/ipc src/shared --glob '*.{ts,d.ts}' --glob '!*.test.ts'

Repository: stablyai/orca

Length of output: 42680


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- runtime step planner ---'
cat -n src/main/ssh/ssh-relay-runtime-step-plan.ts
printf '%s\n' '--- deploy inner ladder and attempt call ---'
sed -n '420,470p' src/main/ssh/ssh-relay-deploy.ts | cat -n
sed -n '500,590p' src/main/ssh/ssh-relay-deploy.ts | cat -n
printf '%s\n' '--- session establish/reconnect error boundaries ---'
sed -n '500,590p' src/main/ssh/ssh-relay-session.ts | cat -n
sed -n '680,750p' src/main/ssh/ssh-relay-session.ts | cat -n
sed -n '1010,1105p' src/main/ssh/ssh-relay-session.ts | cat -n
printf '%s\n' '--- cause use and relay deployment catch references ---'
rg -n -F -C 5 'terminalUnavailableCauseFromError' src/main/ssh src/main/ipc src/shared --glob '*.{ts,d.ts}' --glob '!*.test.ts'
rg -n -F -C 5 'deployAndLaunchRelay(conn' src/main/ssh/ssh-relay-session.ts

Repository: stablyai/orca

Length of output: 23437


Classify a conclusive legacy no-runtime result as rung D.

When rung C refuses for a classified reason such as libc_floor, the loop enters legacy. The legacy plan has no prebuilt runtime, so resolveRemoteBootstrapState calls resolveRemoteNodePath. If no usable Node/npm exists, that resolver throws a plain Error. The ladder catch rethrows it because it handles only PinnedRelayFallbackError. The loop therefore never reaches D.

This exposes a generic installation error instead of RemoteRuntimeUnavailableError with a structured blocked cause. Classify only the resolver's conclusive no-runtime error. Preserve unanswered SSH probe errors on the current abort path.

Suggested fix
diff --git a/src/main/ssh/ssh-remote-node-resolution.ts b/src/main/ssh/ssh-remote-node-resolution.ts
@@
 const LOGIN_SHELL_PROBE_TIMEOUT_MS = 8_000
 
+export class RemoteNodeNotFoundError extends Error {
+  constructor(message: string) {
+    super(message)
+    this.name = 'RemoteNodeNotFoundError'
+  }
+}
+
@@
-  throw new Error(guidance)
+  throw new RemoteNodeNotFoundError(guidance)
@@
-  throw new Error(
+  throw new RemoteNodeNotFoundError(
     [
       'Node.js not found on remote host. Orca relay requires Node.js 18+ and npm.',
diff --git a/src/main/ssh/ssh-relay-deploy.ts b/src/main/ssh/ssh-relay-deploy.ts
@@
-import { resolveRemoteNodePath } from './ssh-remote-node-resolution'
+import {
+  RemoteNodeNotFoundError,
+  resolveRemoteNodePath
+} from './ssh-remote-node-resolution'
@@
     } catch (err) {
+      if (ladder.length > 1 && step === 'legacy' && err instanceof RemoteNodeNotFoundError) {
+        run.refused(step, 'host_node_missing')
+        step = 'D'
+        run.enter(step)
+        continue
+      }
       if (err instanceof PinnedRelayFallbackError && step !== 'legacy' && step !== 'D') {

Comment on lines +100 to +103
if (reportedHosts.has(hostKey)) {
return
}
reportedHosts.add(hostKey)

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

Dedupe marks the host as reported before track can succeed.

The host key is added to reportedHosts before track() runs. track() returns false when the user has not yet consented, the client is not initialized, or the burst cap is hit. In those cases the host is never reported again in this session. If consent is granted later, the event is lost for that host.

Consider adding the key only when track() returns true. This keeps the once-per-session guarantee for emitted events and avoids losing events to transient gates. If you prefer to drop events that occur before consent, document that choice.

Proposed fix
   if (reportedHosts.has(hostKey)) {
     return
   }
-  reportedHosts.add(hostKey)
   try {
     // track() applies the existing consent gate and validates against the strict schema.
-    track('ssh_remote_runtime_resolved', sshRemoteRuntimeResolvedProps(input))
+    if (track('ssh_remote_runtime_resolved', sshRemoteRuntimeResolvedProps(input))) {
+      reportedHosts.add(hostKey)
+    }
   } catch {

The test at ssh-remote-runtime-telemetry.test.ts mocks track with vi.fn(), which returns undefined. Make the mock return true so the dedupe test still passes.

reason: RelayRuntimeStepReason,
remembered = false
): RelayRuntimeStep {
if ((reason === 'noexec' && !remembered) || (current === 'C' && reason === 'host_node_missing')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Permission refusal skips fallbacks

If only the pinned executable is blocked, its exit 126 or “Permission denied” response is still classified as noexec. This branch then jumps straight to D without trying Host Node or npm. A host with a usable runtime can lose its SSH connection and receive an incorrect home-directory noexec diagnosis.

Comment on lines +440 to +443
// Why only a laddered pass: a plain host-npm connect has no rung decision to record.
if (ladder.length > 1) {
run.settle(step)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Default runtime goes unreported

The default Host Node runtime has a one-step ladder, so this condition never calls settle() for those connections. As a result, they emit no ssh_remote_runtime_resolved event, leaving the documented once-per-host telemetry incomplete and undercounting hosts using the legacy runtime.

@OrcaWin
OrcaWin merged commit 53fd2de into main Oct 1, 2026
49 of 51 checks passed
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