fix(ssh): degrade Windows relay node-pty patch on source drift instead of bricking deploy
Summary
Audit follow-up to PR #9638 (shipped in v1.4.150). The Windows SSH relay patches node-pty's conpty_console_list_agent.js (config/relay-assets/node-pty-1.1.0-console-list-agent-patch.cjs) to wrap getConsoleProcessList in an AttachConsole-failure try/catch fallback.
That patch was strictly fail-CLOSED on source drift:
patchNodePtyConsoleListAgent()threw"Refusing to patch unexpected node-pty console-list agent source"during install if the freshly npm-installed source SHA matched neither the pinned original nor patched hash → the remote install command exited non-zero → the fresh Windows relay deploy hard-failed.- The deploy probe (
assertPatchedNodePtyConsoleListAgent) mapped any non-patched source to "node-pty missing".
Blast radius: if node-pty ever shipped a byte-different 1.1.0 build (registry mirror, alternate registry, republish), every Windows SSH relay deploy would hard-fail with no fallback. Zero user impact today (the pinned SHA matches); low-probability, total-outage.
What changed
On an unexpected source/version, the deploy now degrades instead of bricking: it skips the patch, runs node-pty unpatched, and emits telemetry so the drift is visible.
patchNodePtyConsoleListAgent()/ newclassifyNodePtyConsoleListAgent()return a typed outcome (patched/already-patched/unpatched-original/skipped-unexpected-source/skipped-unexpected-version) rather than throwing on drift.- The remote probe one-liner runs on the relay host and has no telemetry sink, so it prints an
ORCA-NODE-PTY-PATCH-SKIPPED:<outcome>:<sha12>:<version>token (mirroringNATIVE_DEPS_MISSING_PREFIX). The local Orca side parses it where the probe result is interpreted and emits the newrelay_node_pty_patch_skippedevent. - New telemetry event
relay_node_pty_patch_skippedinsrc/shared/telemetry-events.ts(validated by the existingsrc/main/telemetry/validator.ts):{ reason, node_pty_version, source_sha_prefix (12-char), relay_platform }. SHA prefix only — never full source.
⚠️ Security tradeoff (please scrutinize)
Degrading to unpatched node-pty is a FUNCTIONALITY loss, not a security bypass. The patch only adds a Windows ConPTY AttachConsole-failure try/catch fallback; running without it just loses that fallback.
The SHA verification is not weakened:
- The SHA gate stays intact — we still refuse to mutate source we don't recognize. No blind string-replace, and an unknown/foreign source is never marked "patched". Degradation is "skip + run unpatched + report", never "apply the patch anyway".
- The known-original happy path is unchanged: atomic temp-file+rename write + post-write
PATCHED_SHAre-assert. - The probe still fails the deploy on genuinely broken native deps (node-pty won't load at all). Patch classification runs on a branch separate from the node-pty load; a recognized-but-unpatched original still re-marks node-pty missing so the repair path re-applies the patch (unchanged behavior). Only the "patch legitimately skipped due to source drift" case becomes non-fatal.
Design decision (version mismatch)
A node-pty version mismatch (npm installed a version != pinned 1.1.0) also degrades, with a distinct telemetry reason (unexpected_version vs unexpected_source). External registry drift keeps version=1.1.0 and hits the source path; version != 1.1.0 only happens from an internal pin edit that forgot to bump the patch's EXPECTED_NODE_PTY_VERSION. Degrading keeps a single fail-open posture while the distinct telemetry reason keeps that internal pin-drift visible without bricking user deploys. Happy to switch version back to fail-closed if review prefers.
Cross-platform / SSH
All new behavior is Windows-relay-only and stays behind the existing isWindowsRemoteHost / process.platform === "win32" runtime checks. The skip token only prints on win32, and the telemetry enum guards the relay_platform value.
Tests
config/scripts/node-pty-console-list-agent-patch.test.mjs: (a) known original → patched (happy path unchanged), (b) already-patched → no-op, (c) unexpected source and unexpected version → skip with no throw and source left byte-for-byte unchanged, tamper → still reports "not installed".src/main/ssh/ssh-relay-deploy-native-deps-probe.test.ts(new): probe classifies the patch on a separate branch; (c) unexpected source/version → node-pty stays available + skip signal parsed +relay_node_pty_patch_skippedemitted with the right props; (d) node-pty missing entirely → still flagged missing (deploy stays fatal) and no drift telemetry; healthy output emits nothing.
pnpm run tc passes; touched vitest + node test files green (126 tests); oxlint clean.
📝 Walkthrough
Walkthrough
The node-pty ConPTY patcher now classifies installed versions and source hashes, skips unexpected states without failing deployment, and verifies successful rewrites. Native-dependency probes detect skipped patches and report structured Windows telemetry for source or version drift. Telemetry schemas and derived event registries include the new event. Tests cover classification, idempotency, unchanged drifted files, probe parsing, missing dependencies, healthy output, and telemetry behavior.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title is concise and accurately summarizes the main Windows SSH relay node-pty drift behavior change. |
| Description check | ✅ Passed | The description is detailed and covers summary, testing, security, and platform notes, with only minor template omissions. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| 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. |
✨ Finishing Touches
📝 Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
SSH still works: Orca connects to the host over SSH and routes workspace operations through the managed remote Orca server (orcad). These merges remove the legacy SSH relay, not SSH support.
Closing as obsolete after the merged SSH relay retirement in #27214 and #27215. This PR concerns SSH relay runtime deployment and its native dependency bootstrap. #27214 removed the desktop relay connection/fallback path; #27215 deleted the SSH relay server, deployment assets, and relay-only tests. SSH hosts now use the managed Orca server (orcad), and unsupported hosts fail explicitly, so this relay-specific work is no longer planned. This closes the proposed relay implementation; it does not claim that any independent local, WSL, or managed-server behavior was fixed.