Skip to content

fix(orcad): reopen a managed tunnel to a host another desktop restarted - #25800

Merged
OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-tunnel-identity-restart
Oct 6, 2026
Merged

OrcaWin merged 1 commit into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-tunnel-identity-restart

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​127
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 0

ELI5

A managed SSH server gets a new internal ID every time it restarts. Desktop A's tunnel check insisted on the ID it last saw. So if another desktop restarted or updated the server while A was away, A could never reconnect, and it couldn't learn the new ID either, because learning it needs the tunnel. Now the tunnel check trusts what actually proves the server, its encryption key and our login token, and the new ID is recorded from the first status reply.

What Changed

Before (Astra review pass 6, P1):

  • verifyManagedOrcadTunnelIdentity compared the server's status reply against the saved runtimeId.
  • orcad mints that ID per process (randomUUID() in orca-runtime-runtime-id.ts).
  • So if the host was updated or woken by another desktop, or restarted while this desktop was offline, every reconnect failed with orcad_identity_mismatch.
  • Nothing could refresh the saved ID, because the status refresh needs the tunnel first.

After:

  • The tunnel opens. The first authenticated status reply records the new ID; that recording path (markEnvironmentUsed) already existed.
  • A server with a different encryption key, or one that rejects our token, is still refused.

Why the real-host Windows scenario (d) worked anyway: orcad was killed and the same desktop reconnected with a new pid. The SSH forward stayed up the whole time, so the identity check never ran again. The desktop's existing transport reconnected over the open forward, and its first status reply recorded the new ID. The check runs only when a tunnel is reopened, which is the case that fails.

Why

  • What proves the server. The pairing handshake encrypts with the host's pinned E2EE public key. Only a host holding the matching secret key can complete it, and only one that knows our device token accepts us. The host keeps that key in its own profile (~/.orca) across updates and restarts.
  • Why the runtime ID can't serve as identity. It is per-process liveness information, so pinning it rejects the right host after any restart it didn't see.
  • Why not record the ID during verification. The tunnel setup's ownership check compares saved runtime IDs mid-setup. Recording the ID there would abort the setup it is verifying, so the existing first-status recording path is used instead.

Linked Issue

Phase 3 review, Astra pass 6 (P1): verifyManagedOrcadTunnelIdentity compares the reply against the per-process runtime ID.

Visual Proof

N/A. This changes connection behavior, and the tests below cover it.

Testing

  • orcad-managed-tunnel-identity-restart.test.ts runs real runtime RPC servers with real E2EE:

    • an orcad process on a host profile pairs, and its runtime ID is recorded;
    • the process stops and a new one starts on the same profile, so it has the same key and devices but a new runtime ID;
    • the tunnel identity check now verifies it, and the status reply carries the new ID, which is recorded on the desktop's environment record;
    • a host with a different profile (a different key) answering on the tunnel is still refused as foreign.
  • The restart case fails on the current phase3 code with The endpoint does not match this paired runtime identity.

  • orcad-managed-tunnel-identity.test.ts is updated: the check no longer pins the runtime ID.

  • I manually tested these changes locally

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

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

  • Only the managed orcad tunnel check changes. Independent SSH access and fresh deploys keep their existing checks.
  • No wire change, so older hosts and mixed versions are unaffected.

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)

The tunnel's identity check pinned the saved runtime id, which orcad mints per process. A host
updated or woken by another desktop, or restarted while this one was away, failed every reconnect
with orcad_identity_mismatch, and nothing could refresh the id because that needs the tunnel. The
E2EE handshake with the pinned host key and our accepted token now prove the server; the first
authenticated status reply records the new id. A different host is still refused.

Co-Authored-By: Claude <[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