Skip to content

fix(ssh): stop an unanswered native-deps probe from wiping a healthy relay - #17979

Merged
nwparker merged 1 commit into
mainfrom
fix/native-deps-probe-unverifiable
Sep 1, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/native-deps-probe-unverifiable

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​226 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​226
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18

Closes the destructive half of #17891's root cause. Land this before #17920 — see sequencing below.

ELI5

The relay's repair-path probe mapped any thrown error to "all native deps are missing":

} catch {
  signal?.throwIfAborted()
  return { available: false, missing: [...RELAY_NATIVE_DEP_NAMES] }
}

available: false does two things, and the second is the worse one:

  1. it feeds resetDeps → rm -rf 'node_modules/node-pty' → full recompile (a node-gyp source build on Linux, which has no prebuild);
  2. it is what triggers the repair at all.

So an unanswered probe against a perfectly healthy relay caused an unnecessary full reinstall plus source compile. That is a direct contributor to the report behind this sweep — "SSH relays … taking several minutes to connect." Loss of contact was being treated as proof of breakage, which docs/reference/ssh-execution-boundary.md forbids.

The asymmetry that is the whole bug

The sibling probe already does this correctly. probeInstalledNativeDeps (:1275) has no try/catch — the error bubbles, the deploy fails, the lock releases, a later reconnect retries. Two tests deliberately pin that policy, one named "lets a probe SSH-channel failure bubble up rather than silently mapping to MISSING."

The discipline existed on the install path and was never applied to the repair path. That is the tenth instance in this sweep of a hazard guarded in one place and not its twin.

The fix

Return type goes from { available: boolean } to { status: 'ok' | 'blocked' | 'unverifiable'; missing }, reusing the vocabulary and rationale already written out in src/main/orcad/node-pty-precondition.ts:45-56: "a probe that times out or cannot spawn says nothing about node-pty, and refusing to boot on it would brick working hosts for a reason that was never established."

  1. The catch returns { status: 'unverifiable', missing: [] } — an unanswered probe can no longer name a single dep for reset.
  2. Only blocked repairs. Unverifiable takes the existing no-repair exit.
  3. Locked re-probe: resetDeps = probe.status === 'unverifiable' ? initialProbe.missing : probe.missing.

Point 3 is scope beyond the named catch, and it is load-bearing. Without it, an initial probe answering "only @parcel/watcher is broken" followed by an unverifiable re-probe still widened the reset to node-pty — the same defect, one call site over. It preserves repair for genuine breakage (the answered initial probe's evidence stands) while never letting an unanswered probe author a reset list.

One deliberate deviation from the brief. I suggested routing unverifiable to the lockResult === 'busy' | 'error' degraded exit. The implementation used the healthy-probe exit instead: for busy/error the two are byte-identical, but the healthy exit also handles acquired correctly. Taking the busy/error exit under an acquired lock would return ownsInstallLock: false with an undefined gcClaimToken, leaking the repair lock until stale recovery. The deviation is correct and my brief was wrong.

Scope fences held

  • missingNativeDepsFromProbe (no marker line → all deps) is untouched. That path runs only when the probe answered and || echo MISSING fired, which genuinely means broken — resetting is correct there.
  • The all-missing-on-catch was not protecting "relay dir vanished": under an acquired lock the recheck calls isRelayAlreadyInstalled and throws RelayDirectoryGcConflictError; under busy/error the pre-existing acquireRelayLaunchGcFence throws the same. Verified, not assumed.

User-facing regressions

None expected. Negative controls: a probe answering bare MISSING still resets both deps and runs finalizeInstall; a probe answering OK still skips npm install; the two pinned tests at ssh-relay-native-deps-install.test.ts:395 and :428 pass unchanged (that file is not in the diff — only 2 files changed).

Behavior delta: an unanswered probe against a healthy relay used to cost a full npm install plus a node-gyp build. It now costs one extra exec (the launch-namespace marker) and launches. If the deps really were broken, the next reconnect re-probes and repairs — no state is lost, only the destructive guess.

Testing

New spec ssh-relay-native-deps-probe-verdict.test.ts. Before → after:

 ❯ ssh-relay-native-deps-probe-verdict.test.ts (4 tests | 2 failed)
   × launches an intact relay when the health probe never answers
   × keeps the answered reset scope when the locked re-probe cannot answer
 Test Files  1 passed (1)
      Tests  4 passed (4)

The test was restructured mid-implementation: it first failed only on fixture slot-drift (Relay failed to start within 10s) — a true failure for the wrong reason. Asserting the repair-avoidance facts before the launch outcome makes the pre-fix failure name the actual defect, and the second test prints the offending command:

Received: "... && rm -rf 'node_modules/node-pty'; rm -rf 'node_modules/@parcel/watcher'; ... npm install ..."

pnpm test src/main/ssh → 1798 passed / 16 skipped. tc:node clean. check:code-quality:changed 0 new findings. check:max-lines-ratchet OK. The 3 heaviest src/main/ipc/ssh* consumers also run (37 passed) since the return shape changed.

Sequencing

This should land before #17920. It touches no artifact, manifest, or content hash, so no host moves to a fresh install dir — it costs zero reinstalls. #17920 forces exactly one reinstall per host and adds a third 240s command to a budget that is already 720s inside a 900s bound. Landing the free fix first is strictly dominant, and it removes the runaway that #17920 would otherwise lengthen.

probeRequiredNativeDeps mapped any thrown error to available:false, which
both triggered the repair and fed resetDeps — so one dropped exec channel
rm -rf'd node_modules/node-pty on a healthy relay and forced a node-gyp
source build. Verdicts are now ok / blocked / unverifiable; only an
answered probe may repair, and only an answered probe may name reset deps.

@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 critical issues — one minor suggestion inline.

Reviewed changes

  • Probe verdict tri-state — probeRequiredNativeDeps now returns { status: 'ok' | 'blocked' | 'unverifiable'; missing } instead of { available: boolean; missing }. A probe that throws (torn channel, timed-out require()) maps to unverifiable with an empty missing, rather than available: false with every dep named — which is what used to trigger rm -rf node_modules/node-pty on a healthy relay.
  • Repair gating — only blocked performs repair; unverifiable takes the existing no-repair (healthy) exit, and a locked re-probe that can't answer falls back to the initial probe's answered missing set instead of widening the reset to all deps.
  • Regression spec — a new ssh-relay-native-deps-probe-verdict.test.ts pins four probe-verdict behaviors, including two (an unanswered health probe, and an unverifiable re-probe) that fail against the old code.

The fix is correct and minimal: the only behavioral delta is unverifiable moving from the repair branch to the healthy branch, and the acquired/busy/error lock-ownership handling is preserved by reusing the existing status !== 'blocked' exit (verified — an unverifiable probe with an acquired lock holds it exactly like the ok case, no leak). The missing: [] on unverifiable is never read, so no empty-reset path exists.

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

return { available: false, missing: [...RELAY_NATIVE_DEP_NAMES] }
// Why: an unanswered probe says nothing about the deps; reporting MISSING here reset and
// recompiled healthy relays, turning one dropped exec channel into a multi-minute reconnect.
return { status: 'unverifiable', missing: [] }

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.

An unanswered probe is now swallowed with no log, so a dropped exec channel during the health probe leaves zero trace and the relay simply launches — previously it surfaced loudly via the Repairing missing native deps warning plus a visible build. The install-path sibling surfaces the same failure (a throw that its callers log as [NATIVE-DEPS-REBUILD-FAIL] / [NPTY-MISSING]); a console.warn here would keep a real transport failure from being invisible.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 6e5f577d-fb89-4713-b420-d2f5006558de

📥 Commits

Reviewing files that changed from the base of the PR and between 5aa02ea and a8801bb.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-native-deps-probe-verdict.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

SSH relay native-dependency probing now returns ok, blocked, or unverifiable. Unverifiable initial probes skip repair and allow relay launch. Blocked probes trigger scoped repair. During locked re-probing, unverifiable results preserve the dependency list from the initial answered probe. New Vitest coverage verifies each probe verdict and reset-scope behavior.

Merge Risk: ⚪ Minimal · up to a8801

The change prevents unanswered SSH dependency probes from triggering destructive reinstalls while preserving repair for confirmed dependency failures. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. 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 and concisely identifies the SSH native-dependency probe fix and its primary effect: preventing an unanswered probe from damaging a healthy relay.
Description check ✅ Passed The description is detailed, relevant, and covers the problem, rationale, implementation, scope boundaries, issue reference, sequencing, and testing results. It does not use every template heading and…
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: Description check

Explanation

The description is detailed, relevant, and covers the problem, rationale, implementation, scope boundaries, issue reference, sequencing, and testing results. It does not use every template heading and does not explicitly provide the required Visual Proof N/A statement or checklist confirmations, but the substantive information is mostly complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 02ffd40 into main Sep 1, 2026
33 checks passed
@nwparker
nwparker deleted the fix/native-deps-probe-unverifiable branch September 1, 2026 19:23
nwparker added a commit that referenced this pull request Sep 1, 2026
Resolves the probe-verdict conflict toward main's landed #17979 vocabulary
(status: ok|blocked|unverifiable), which is strictly better: it repairs on
any non-ok status and carries the initial probe's answered evidence forward
when a locked re-probe cannot answer.

Keeps this branch's unique PowerShell $LASTEXITCODE guard on the probe: a
native non-zero exit does not throw in PowerShell, so the catch never fires
and the probe would otherwise return empty, markerless stdout.
Jinwoo-H pushed a commit that referenced this pull request Sep 1, 2026
#17979)

probeRequiredNativeDeps mapped any thrown error to available:false, which
both triggered the repair and fed resetDeps — so one dropped exec channel
rm -rf'd node_modules/node-pty on a healthy relay and forced a node-gyp
source build. Verdicts are now ok / blocked / unverifiable; only an
answered probe may repair, and only an answered probe may name reset deps.

(cherry picked from commit 02ffd40)
nwparker added a commit that referenced this pull request Sep 2, 2026
…#18011)

The repair path read "the probe answered, but nothing in the answer names a
dep" as "both deps are missing". The POSIX probe is fenced with
`|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe
catch added by #17979 never ran. A node that cannot start (invalid
NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and
every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher
and burned a 240s npm install that failed the same way. `.install-complete`
from the original install survives, so the relay kept launching with no PTY
and no file watcher, permanently, per host.

Only a marker line that actually names deps is evidence about them; anything
else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the
POSIX probe and carry stderr into the warning via a new execCommand `onStderr`
hook, so the reason node failed survives. stderr stays its own stream — folded
into stdout it would match the probe's own token strings.

The Windows branch shared the same parser and is fixed with it.
nwparker added a commit that referenced this pull request Sep 2, 2026
…lently

The wrongful rebuild used to be the only visible symptom of a dropped exec
channel; #17979 removed it, so a real transport failure now leaves no trace.
Matches the install-path sibling, whose callers log the same class of failure.
nwparker added a commit that referenced this pull request Sep 2, 2026
…lently (#18000)

* fix(ssh): log an unanswered native-deps probe instead of launching silently

The wrongful rebuild used to be the only visible symptom of a dropped exec
channel; #17979 removed it, so a real transport failure now leaves no trace.
Matches the install-path sibling, whose callers log the same class of failure.

* fix(i18n): restore the activity-options key the rebase dropped

* fix(i18n): union en.json with main so the rebase cannot drop keys
GhostFlying pushed a commit to GhostFlying/orca that referenced this pull request Sep 3, 2026
stablyai#17979)

probeRequiredNativeDeps mapped any thrown error to available:false, which
both triggered the repair and fed resetDeps — so one dropped exec channel
rm -rf'd node_modules/node-pty on a healthy relay and forced a node-gyp
source build. Verdicts are now ok / blocked / unverifiable; only an
answered probe may repair, and only an answered probe may name reset deps.
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
stablyai#17979)

probeRequiredNativeDeps mapped any thrown error to available:false, which
both triggered the repair and fed resetDeps — so one dropped exec channel
rm -rf'd node_modules/node-pty on a healthy relay and forced a node-gyp
source build. Verdicts are now ok / blocked / unverifiable; only an
answered probe may repair, and only an answered probe may name reset deps.

Mirror-Of: 02ffd40
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Sep 3, 2026
…stablyai#18011)

The repair path read "the probe answered, but nothing in the answer names a
dep" as "both deps are missing". The POSIX probe is fenced with
`|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe
catch added by stablyai#17979 never ran. A node that cannot start (invalid
NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and
every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher
and burned a 240s npm install that failed the same way. `.install-complete`
from the original install survives, so the relay kept launching with no PTY
and no file watcher, permanently, per host.

Only a marker line that actually names deps is evidence about them; anything
else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the
POSIX probe and carry stderr into the warning via a new execCommand `onStderr`
hook, so the reason node failed survives. stderr stays its own stream — folded
into stdout it would match the probe's own token strings.

The Windows branch shared the same parser and is fixed with it.

Mirror-Of: 4f4872c
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
stablyai#17979)

probeRequiredNativeDeps mapped any thrown error to available:false, which
both triggered the repair and fed resetDeps — so one dropped exec channel
rm -rf'd node_modules/node-pty on a healthy relay and forced a node-gyp
source build. Verdicts are now ok / blocked / unverifiable; only an
answered probe may repair, and only an answered probe may name reset deps.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…stablyai#18011)

The repair path read "the probe answered, but nothing in the answer names a
dep" as "both deps are missing". The POSIX probe is fenced with
`|| echo MISSING`, so the subshell always exits 0 and the unanswered-probe
catch added by stablyai#17979 never ran. A node that cannot start (invalid
NODE_OPTIONS, OOM kill, exit 127) therefore produced a bare `MISSING`, and
every reconnect rm -rf'd node_modules/node-pty and node_modules/@parcel/watcher
and burned a 240s npm install that failed the same way. `.install-complete`
from the original install survives, so the relay kept launching with no PTY
and no file watcher, permanently, per host.

Only a marker line that actually names deps is evidence about them; anything
else is `unverifiable` and launches as-is. Also drop `2>/dev/null` from the
POSIX probe and carry stderr into the warning via a new execCommand `onStderr`
hook, so the reason node failed survives. stderr stays its own stream — folded
into stdout it would match the probe's own token strings.

The Windows branch shared the same parser and is fixed with it.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…lently (stablyai#18000)

* fix(ssh): log an unanswered native-deps probe instead of launching silently

The wrongful rebuild used to be the only visible symptom of a dropped exec
channel; stablyai#17979 removed it, so a real transport failure now leaves no trace.
Matches the install-path sibling, whose callers log the same class of failure.

* fix(i18n): restore the activity-options key the rebase dropped

* fix(i18n): union en.json with main so the rebase cannot drop keys
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