Repository navigation
fix(ssh): keep the enrolled pairing across a managed server's update, rollback and recovery - #31684
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/ssh/orcad-runtime-maintenance.test.ts: 1
95-101: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert the pinned key and local endpoint in the maintenance tests.
The shared helper does not assert
publicKeyB64or the persisted endpoint. The fixture also gives the startup offer the same public key as the enrolled offer. A regression that selects a different startup host key would therefore pass all three maintenance tests.Suggested fix
import { createManagedLifecycleHarness, MANAGED_PREVIOUS_VERSION, MANAGED_VERSION, + MANAGED_LOCAL_PORT, managedReadiness } from '../managed-server/lifecycle/orcad-managed-lifecycle-test-fixture' function expectEnrolledPairing(): void { const [environment] = listEnvironments(harness.userDataPath) expect(environment?.endpoints[0]?.deviceToken).toBe('device-token') + expect(environment?.endpoints[0]?.publicKeyB64).toBe('public-key') + expect(environment?.endpoints[0]?.endpoint).toBe( + `ws://127.0.0.1:${MANAGED_LOCAL_PORT}/` + ) expect(environment?.pairingRevision).toBe(harness.environment.pairingRevision) expect(environment?.orcadDeployment).toEqual(harness.environment.orcadDeployment) }-export function managedReadiness(deviceToken = 'device-token'): ServeReadiness { +export function managedReadiness( + deviceToken = 'device-token', + publicKeyB64 = 'public-key' +): ServeReadiness { ... - publicKeyB64: 'public-key' + publicKeyB64Pass a distinct public key, such as
managedReadiness('startup-offer-token', 'startup-public-key'), in the update, rollback, and recovery cases.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
96ba517b-a0e1-46e3-a7a8-9e2d0dd7fd11
📥 Commits
Reviewing files that changed from the base of the PR and between d22fb0d and 31ea86c3e1f2366b70e546fcdc7b2e3a823e73f5.
📒 Files selected for processing: 4
src/main/runtime/device-registry-startup-offer.test.tssrc/main/ssh/orcad-runtime-maintenance.test.tssrc/main/ssh/orcad-runtime-maintenance.tssrc/shared/runtime-environment-managed-orcad-store.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
60a8d49 to
a022c4e
Compare
360ec1d to
e8f8f49
Compare
… rollback and recovery orcad's startup offer names a pending device, which it re-mints once a client has paired with it. Update, rollback and recovery re-paired the desktop from that offer, so the desktop became a new device to its host after each one. They now keep the enrolled grant, as WSL does since #29042.
…and warn on a changed host key The WSL incumbent's terminal count authenticated with the startup offer, which marked that pending device used, so every orcad start enrolled another device. It now uses this desktop's enrolled pairing. After an SSH update, rollback or recovery, a server that names a host key other than the pinned one is reported with a warning instead of a plain success.
…key warning to a follow-up The census can repair a refused pairing before the update re-pairs, so the enrolled grant is re-read from the store rather than taken from the copy read first. The host-key warning goes back out: only the CLI would show it, and surfacing it in the desktop lifecycle UI is a separate change.
…onto main refreshPairing reads the enrolled offer in one statement, and the WSL connection error classes move into their own file.
e8f8f49 to
5109a40
Compare
ELI5
When Orca updates, rolls back or recovers a managed server on an SSH host, it used to re-pair this desktop using the server's "new client" invitation, not the pairing the desktop already had. To the host, the desktop then looked like a brand-new device after each of those actions. It now keeps its existing pairing, as WSL hosts already do.
What Changed
Before: after Update, Rollback or Recover on a managed SSH server, the desktop's saved credential was replaced by the token from the server's startup invitation. That invitation is only reused while nobody has accepted it. Once this desktop has paired, every restart issues a new device. So the desktop's identity to its host changed each time. Anything tied to that identity (which caller started a worker, which phone it relays, chat ownership) then pointed at an old device, and the old device was left registered.
After: those three actions keep the enrolled credential and pinned host key, and refresh only the local tunnel address. This is the same rule WSL hosts follow since fix(wsl): keep the desktop pairing across host restarts #29042.
Same class on WSL: before an update, the WSL host's terminal count authenticated with the startup offer. That marked the pending device as used, so every orcad start enrolled yet another device on the distro. The count now uses this desktop's enrolled pairing.
Mechanism:
refreshPairinginsrc/main/ssh/orcad-runtime-maintenance.tsnow passes the saved offer totunneledOrcadPairingCode. It reads that offer from the store at that moment, because the terminal count may have repaired a refused pairing in between. WSL's incumbent count (wsl-orcad-incumbent.ts) gets the enrolled offer through a newpairedOfferdeploy option. The store comment that implied the startup offer is stable across versions now says what is actually stable: the device registry.Why
The store's comment suggested this was harmless, because "orcad keeps its pairing state across versions". The registry does persist, but the startup offer is a pending device that the registry re-mints once a client has used it. A new test pins exactly that against the real
DeviceRegistry.I chose keeping the enrolled grant over re-pairing because it is what the SSH connect and WSL already do. A credential the host no longer knows (for example after a rollback restored older server state) is still caught by the existing automatic pairing repair, which re-pairs from the startup offer only when the host refuses the token and the pinned host key matches.
Linked Issue
None; found by the SSH cleanup pass (maintainer work).
Visual Proof
N/A: no UI change; this changes which credential is saved after server maintenance.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New tests for update, rollback and recover each fail on main (the token became the startup offer's) and pass here.
A registry test shows the startup offer repeats while unused and names a new device once a client pairs.
A WSL test with a real device registry shows three restarts grew it from 2 to 4 devices on main; with this change it stays at 2.
A pairing the terminal count repaired is kept, not overwritten by the copy read before it.
Ran the managed-server suites,
pnpm tc:nodeand the full static job. The Docker managed-orcad lane runs in CI.Verified live: nothing beyond CI.
Mixed versions: an old orcad on the host keeps its device registry the same way, so the enrolled grant stays valid. No wire change.
Review
Codex review and an independent review.
Agent skill upstream boundary
Notes
SSH and WSL. Folder workspaces are unaffected. Follow-ups, not in this PR:
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)