Skip to content

fix(ssh): declare a wedged relay link lost, and stop reading silence as a verdict - #17817

Merged
nwparker merged 9 commits into
mainfrom
fix/ssh-link-wedge-and-probe-verdict
Sep 2, 2026
Merged

nwparker merged 9 commits into
mainfrom
fix/ssh-link-wedge-and-probe-verdict

Conversation

@nwparker

@nwparker nwparker commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​429 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​420
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​113

What

Three fixes for one class of bug: treating "no answer" as evidence. Per docs/reference/ssh-execution-boundary.md, loss of contact is never evidence of process death — and the same mistake was being made in both directions, on both ends of the link.

1. A saturated writer suppressed dead-link detection, with no upper bound

SshChannelMultiplexer's health check was gated on writerSaturated. On a half-open link (sleep/resume, dropped NAT mapping) the transport reports backpressure and never drains, so:

  • nothing ever leaves the writer;
  • the writer's single-outstanding liveness guard (ssh-multiplexer-transport-writer.ts:82) silences every keepalive after the first, because that flag only clears on a settlement that never comes;
  • and the one check that could notice is suppressed indefinitely.

The mux never disposes, so onRelayLost (ssh-relay-session.ts) never fires and the bounded-backoff reconnect never runs. Every RPC times out at 30s, forever.

Saturation no longer suppresses the check. The relay sends its own keepalive every 5s (src/relay/dispatcher-client-lifecycle.ts), so a slow-but-alive peer still refreshes lastReceivedAt and is never falsely killed; only a link delivering nothing inbound for 20s is declared lost, which reconnects.

2. The relay had no inbound-liveness signal at all

Symmetric to the above, on the host side. RelayClient had no lastReceivedAt; the 5s timer is send-only; frame.ack is never read; there is no socket.setTimeout; and the writer's drain arm has no timer. So a half-open client parked forever holding its owner lease, with every PTY it held paused, until the OS eventually failed the socket — or never.

ssh-owner-recovery-retry.ts:14-17 documents the assumption this violated: "the relay frees it when its keepalive notices." It never noticed, which is why the client-side budget for that case is only 1000ms.

Clients are now reaped after 20s of silence, with a sleep/wake rebase so a paused host process does not reap everyone on its first tick back. The close cause stays the cautious 'local' default: silence is not evidence the peer died, and the PTYs stay live for the replacement client to reclaim.

Three carve-outs, each with its own test: the primary sink (closing it tears down the relay's own stdin/stdout and nothing in production revives it), a client that does not speak the keepalive protocol (the remote orca CLI sends one orca.cli request and then waits for a result budgeted in minutes), and a client that has not spoken yet (a relay is launched before its client finishes handshaking).

That last carve-out was unbounded, which review flagged twice: a client that clears the endpoint handshake and then never frames anything has no lastReceivedAt to go stale, so its socket, writer and client entry were held for the life of the relay. It now has its own much wider deadline — 6 silence windows, rebased across a host suspend like the other clock — so a real client that is merely slow is never touched and a dead one is still collected.

3. Keeping the verdict honest where fix 1 changes it

Fix 1 has a user-visible consequence that has to be paid for here rather than discovered later. Pre-change, a saturated-writer wedge left the mux alive and requests failed at 30s with SSH_MUX_REQUEST_TIMEOUT. Post-change the mux disposes at 20s and dispose('connection_lost') rejects the pending requests with CONNECTION_LOST.

Three sites branched on isSshMuxRequestTimeoutError to choose their wording:

  • source-control-remote-generation.ts:28
  • commit-message-model-discovery.ts:209
  • ai-vault/ssh-session-list.ts:87

The timeout branch says "…may still be running on the remote host."; the fallthrough says "could not be reached on the {location}." So fix 1 on its own would have deleted the unverifiable wording from three user-facing surfaces and replaced it with a claim of absence — exactly the substitution the boundary doc forbids, and the sentence mosh treats as essential (stmclient.cc:229-232: "the mosh-server process may still be running on the server").

Both codes mean the same thing — the frame reached the wire and the answer did not come back — so the three sites now branch on isSshRequestOutcomeUnverifiable, which covers both. Each site has a regression test that fails if the wording is dropped again, plus a unit test on the predicate itself.

Also here: two small probe fixes

  • The Windows native-deps probe now checks $LASTEXITCODE, so a real load failure prints MISSING and exits 0 like its POSIX twin, instead of throwing and being read as "the host never answered".
  • execCommand's timeout error carries a typed SSH_EXEC_TIMEOUT_CODE, and ssh-remote-platform-detection.ts now reads that code instead of matching /timed out after \d+s$/u against the message. Previously any error whose message happened to end that way could claim the transport-shaped branch and turn an unsupported-platform answer into a thrown probe failure.

Fix evidence

Each fix has a test verified failing before and passing after.

  • ssh-channel-multiplexer-saturation-wedge.test.ts against pre-change code: mux never disposes after 200s, and exactly 1 keepalive is ever written.
  • dispatcher-silent-client-reaper.test.ts: reaps the silent client, keeps the quiet-but-answering one, keeps the primary, keeps a non-keepalive CLI client, does not reap everyone after a simulated host sleep, and still bounds a client that never speaks.
  • The three verdict call sites: dropping CONNECTION_LOST from isSshRequestOutcomeUnverifiable fails one test per site plus the predicate's own.
  • ssh-remote-platform-detection.test.ts: restoring the message-text match fails does not read a look-alike timeout message as a timed-out channel.

Mutation-checked rather than assumed. Deleting the client === this.primaryClient guard from reapSilentClients used to leave all 7 reaper tests passing — the primary was never fed, so the never-spoken and no-keepalive guards skipped it regardless. The test now feeds it (dispatcher.feed(encodeKeepAliveFrame(1, 0))), which is what a real primary does, and deleting the guard fails it:

FAIL  src/relay/dispatcher-silent-client-reaper.test.ts > RelayDispatcher silent-client reaper
      > never reaps the primary client, whose sink cannot be revived
AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times
$ pnpm tc                                                        # clean
$ pnpm test src/main/ssh src/relay src/main/text-generation src/main/ai-vault src/main/providers
 Test Files  471 passed | 3 skipped (474)
      Tests  5026 passed | 23 skipped (5049)
$ pnpm run check:code-quality:changed                            # 0 new findings

Relationship to #17748

This supersedes it. #17748's own description names the defect fixed here as a given — "the dead-link check … is deliberately suppressed in exactly that state" — and works around it by extending budgets. With the suppression gone, a wedged writer disposes in ~20s and reconnects, rather than a spawn burning 30s in a queue on a link that is already dead. #17748 would instead raise SSH_PTY_CONNECT_WORST_CASE_MS to 160s, lengthening the dead-pane window ~6x on exactly the path users complained about. Its orphan-PTY hazard also dissolves here: dispose() clears the writer queue, so a parked frame can never later reach the wire.

Worth salvaging from it separately: its two test files, and dequeue-on-timeout in the writer.

Note on scope

An earlier revision of this branch also carried the three-state native-deps probe (available / missing / unverifiable) for #14830. That landed independently on main via #17979 and #18011, so only the Windows $LASTEXITCODE fix and its regression test remain here. #14830 is closed by those PRs, not this one.

#17928 is stacked on this branch and must land with it. Fix 1 widens the window in which a pty.spawn reaches an already-disposed mux, and that path tombstones the operation id for 24 hours even though the request was never framed. Merging this alone makes that bug easier to hit.


ELI5

Orca could get stuck talking to a remote machine and never notice. If the network died in a way that leaves the connection technically 'open' (laptop sleep, Wi-Fi change), Orca would wait forever instead of reconnecting. Same bug on the server side: an abandoned Orca window kept holding your terminals hostage. And when Orca gives up on a remote request, it now still tells you the truth — "it may still be running over there" — instead of claiming the machine could not be reached.

User-facing regression risk

  • You may now see a brief 'reconnecting' state where the terminal previously just froze. That is the fix working, but it is a visible change.
  • A link that genuinely delivers nothing for 20s is now dropped and rebuilt. On a very bad network you could see more reconnects than before, where previously you saw a hang.
  • On the relay side, a client that has gone silent for 20s loses its socket. Its PTYs stay live and the reconnecting client reclaims them; the close cause is 'local', so nothing downstream reads it as the peer having died.

@greptile-apps

greptile-apps Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR adds bounded inbound-liveness checks on both sides of the SSH relay and introduces a three-state native-dependency probe so unanswered probes do not trigger destructive repair work.

  • Declares saturated, silent application-side relay links lost while retaining wake and inbound-traffic safeguards.
  • Reaps silent keepalive-capable relay clients without treating transport loss as proof of process death.
  • Adds typed SSH execution timeout errors and distinguishes available, missing, and unverifiable native dependencies.
  • Adds focused regression coverage for wedged transports, relay-client reaping, and native-dependency repair behavior.

Confidence Score: 4/5

The PR is not yet safe to merge because confirmed SSH probe failures can still be swallowed as an unverifiable dependency result.

The native-dependency probe catches every execution rejection and continues through the non-missing launch path, even though confirmed exec refusals are distinguishable from timeout or unconfirmed channel termination.

Files Needing Attention: src/main/ssh/ssh-relay-deploy.ts

Important Files Changed

Filename Overview
src/main/ssh/ssh-channel-multiplexer.ts Removes saturation as a dead-link-check exemption while preserving read-pause and wake protections.
src/relay/dispatcher-client-lifecycle.ts Adds keepalive-aware client silence tracking, wake rebasing, and transport-only cleanup.
src/relay/dispatcher-frame-codec.ts Records inbound activity and marks clients that participate in the keepalive protocol.
src/main/ssh/ssh-relay-deploy.ts Introduces three-state dependency probing and restricts repairs to explicit missing verdicts.
src/main/ssh/ssh-relay-exec-command.ts Adds a stable typed code and classifier for SSH execution timeouts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Application multiplexer] <-->|Framed SSH traffic| B[Relay dispatcher]
  A --> C{Inbound traffic within timeout?}
  C -->|No| D[Dispose transport and reconnect]
  C -->|Yes| A
  B --> E{Keepalive-capable client answering?}
  E -->|No| F[Detach silent socket client]
  E -->|Yes| B
  G[Native dependency probe] --> H{Probe verdict}
  H -->|Available| I[Launch relay]
  H -->|Missing| J[Repair node_modules]
  H -->|Unverifiable| I
Loading

Reviews (5): Last reviewed commit: "fix(relay): exempt the primary sink from..." | Re-trigger Greptile

Comment thread src/main/ssh/ssh-relay-deploy.ts Outdated
Comment on lines +772 to +784
} catch (error) {
signal?.throwIfAborted()
return { available: false, missing: [...RELAY_NATIVE_DEP_NAMES] }
// Why: the probe shell always exits 0 and prints MISSING for a real load failure, so a throw
// only ever means the host never answered — a timed-out `require()` on a wedged dlopen, or a
// torn exec channel. Reading that as "every native dep is missing" sent a healthy install
// through an eight-minute npm install + rebuild that could not help, then round-tripped until
// the 15-minute deploy budget expired (#14830).
console.warn(
`[ssh-relay] Native-deps probe did not answer at ${remoteDir}: ${
error instanceof Error ? error.message : String(error)
}`
)
return { verdict: 'unverifiable', 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 Confirmed probe failures become silence

When the probe command returns a definitive failure such as a permission-related cd error, SSH exec refusal, or session-limit error, this catch classifies it as unverifiable. repairInstalledNativeDeps then follows the same branch as an available probe and continues toward launch, obscuring the actionable error and bypassing applicable retry handling; restrict this conversion to timeout or otherwise unconfirmed termination errors.

Knowledge Base Used: Relay protocol and transport

@coderabbitai

coderabbitai Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 1ac9ba0d-65f9-4ece-83c3-e2d5c8214603

📥 Commits

Reviewing files that changed from the base of the PR and between 7873f73 and 23d0539.

📒 Files selected for processing (10)
  • src/main/ssh/ssh-channel-multiplexer-saturation-wedge.test.ts
  • src/main/ssh/ssh-channel-multiplexer.test.ts
  • src/main/ssh/ssh-channel-multiplexer.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-exec-command.ts
  • src/main/ssh/ssh-relay-native-deps-install.test.ts
  • src/relay/dispatcher-client-lifecycle.ts
  • src/relay/dispatcher-contract.ts
  • src/relay/dispatcher-frame-codec.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/main/ssh/ssh-relay-deploy.ts
  • src/relay/dispatcher-frame-codec.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts
  • src/main/ssh/ssh-channel-multiplexer.test.ts
  • src/main/ssh/ssh-channel-multiplexer-saturation-wedge.test.ts
  • src/relay/dispatcher-contract.ts
  • src/main/ssh/ssh-channel-multiplexer.ts
  • src/main/ssh/ssh-relay-native-deps-install.test.ts
  • src/relay/dispatcher-client-lifecycle.ts
  • src/main/ssh/ssh-relay-exec-command.ts

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


📝 Walkthrough

Walkthrough

The SSH multiplexer now detects dead links during writer saturation and preserves links that receive inbound keepalives. Native dependency probes classify non-zero node exits and execution timeouts without triggering repair for unanswered hosts. The relay dispatcher tracks inbound frames, handles paused timer intervals, and closes eligible silent clients. New tests cover these liveness and probe scenarios.

Merge Risk: 🟡 Moderate · up to 23d05

This PR changes SSH liveness handling and native-dependency repair decisions, but the current code can still treat an unanswered dependency probe as permission to rewrite native dependencies and can allow a silent client to retain relay resources indefinitely; these issues may cause wasted repair cycles or leaked sessions, so merge should wait for correction or explicit owner acceptance.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The native-dependency probe changes are in scope for #14830. The SSH multiplexer saturation handling, relay-side silent-client reaping, keepalive tracking, PTY preservation, and their tests address se… Remove the unrelated SSH multiplexer and silent-client reaping changes, or link issues that explicitly require those relay-liveness fixes and explain their inclusion in the PR scope.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The native-dependency changes address #14830 by preserving the existing bounded execution timeout, adding typed timeout detection, and preventing install or rebuild actions when the probe never answer…
Title check ✅ Passed The title clearly identifies the primary SSH fix: detecting wedged relay links and avoiding incorrect silence-based conclusions.
Description check ✅ Passed The description is detailed and on-topic. It explains the problem, changes, rationale, linked issues, regression risks, testing evidence, and scope. It does not reproduce every template heading, but i…
Full details: Linked Issues check

Explanation

The native-dependency changes address #14830 by preserving the existing bounded execution timeout, adding typed timeout detection, and preventing install or rebuild actions when the probe never answered. The regression test covers the unanswered-probe behavior.

Full details: Out of Scope Changes check

Explanation

The native-dependency probe changes are in scope for #14830. The SSH multiplexer saturation handling, relay-side silent-client reaping, keepalive tracking, PTY preservation, and their tests address separate relay-liveness problems that are not required by the linked issue.

Full details: Description check

Explanation

The description is detailed and on-topic. It explains the problem, changes, rationale, linked issues, regression risks, testing evidence, and scope. It does not reproduce every template heading, but it provides the required substantive information.

✨ 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.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 4fa8ea97-6925-4675-96bf-873453ba02b5

📥 Commits

Reviewing files that changed from the base of the PR and between 9bc564c and 5b4609d.

📒 Files selected for processing (10)
  • src/main/ssh/ssh-channel-multiplexer-saturation-wedge.test.ts
  • src/main/ssh/ssh-channel-multiplexer.test.ts
  • src/main/ssh/ssh-channel-multiplexer.ts
  • src/main/ssh/ssh-relay-deploy.ts
  • src/main/ssh/ssh-relay-exec-command.ts
  • src/main/ssh/ssh-relay-native-deps-install.test.ts
  • src/relay/dispatcher-client-lifecycle.ts
  • src/relay/dispatcher-contract.ts
  • src/relay/dispatcher-frame-codec.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts

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

Comment thread src/main/ssh/ssh-relay-deploy.ts Outdated
} catch {
return probe.includes('ORCA-NATIVE-DEPS-OK')
? { verdict: 'available', missing: [] }
: { verdict: 'missing', missing: missingNativeDepsFromProbe(probe) }

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 | 🟠 Major | ⚡ Quick win

Require the explicit missing marker before repair.

A bare MISSING response has no ORCA-NATIVE-DEPS-MISSING: marker. The POSIX and Windows probe commands emit this response when Node cannot start. missingNativeDepsFromProbe() converts unmarked output into both dependencies, so Line 771 routes an installed relay into repair without confirmation that either dependency is missing. Return unverifiable when output has neither the success token nor the missing marker. Add a test for bare MISSING.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 3c543f56-9b3f-4e50-be89-d3466a6ecb48

📥 Commits

Reviewing files that changed from the base of the PR and between 5b4609d and bbf11f0.

📒 Files selected for processing (4)
  • src/main/ssh/ssh-relay-deploy.ts
  • src/relay/dispatcher-client-lifecycle.ts
  • src/relay/dispatcher-contract.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts

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

@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.

Important

The new reaper's sleep/wake rebase shares its TIMEOUT_MS boundary with the reap itself, so a ~16–20s host pause can falsely disconnect every client — the same "silence as a verdict" class this PR removes elsewhere. See the inline comment for the fix; the rest of the change is solid.

Reviewed changes

  • SshChannelMultiplexer dead-link check unblocked — removed the writerSaturated suppression so a wedged uplink disposes in ~20s instead of parking forever, while a live peer's own keepalives still refresh the clock.
  • Relay inbound-liveness reaper — RelayClient.lastReceivedAt is stamped per decoded frame and a 5s keepalive tick closes clients silent for 20s, freeing owner leases and paused PTYs.
  • Three-state native-deps probe — available / missing / unverifiable so an unanswered probe never authorizes npm install + rebuild.
  • Typed exec timeout code — SSH_EXEC_TIMEOUT_CODE replaces message-text matching on the timeout path.

ℹ️ Nitpicks

  • isSshExecTimeout / SSH_EXEC_TIMEOUT_CODE (ssh-relay-exec-command.ts) are exported but never consumed; the one existing message-text discriminator, EXEC_TIMEOUT_MESSAGE in ssh-remote-platform-detection.ts:17, is left matching timed out after \d+s$ instead of migrating to the new code.

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

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/relay/dispatcher-client-lifecycle.ts (1)

178-178: 🩺 Stability & Availability | 🟠 Major

Use a wake-gap margin below TIMEOUT_MS.

A timer gap can be shorter than TIMEOUT_MS while lastReceivedAt is already one KEEPALIVE_SEND_MS interval old. The next tick can then satisfy now - client.lastReceivedAt > TIMEOUT_MS and close a healthy client after a short host pause.

Trigger the rebase with a margin below TIMEOUT_MS, and add a boundary regression test for this interval.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 4ef10e9a-134d-489e-8999-23aa449653bc

📥 Commits

Reviewing files that changed from the base of the PR and between bbf11f0 and 06b0eea.

📒 Files selected for processing (4)
  • src/relay/dispatcher-client-lifecycle.ts
  • src/relay/dispatcher-contract.ts
  • src/relay/dispatcher-frame-codec.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts

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

@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 behavioral issues in these three follow-up commits — they correctly close the CLI-client and slow-handshake false-reap gaps, and fix the Windows repair-path probe. Two test-hygiene items below.

Reviewed changes

  • Reaper skips clients that have never spoken — lastReceivedAt starts null and silence only counts after the first inbound frame, so a relay launched before its client finishes handshaking isn't killed mid-connect.
  • Reaper skips clients that don't speak keepalives — keepaliveObserved is set only on inbound keepalive frames, so the one-shot orca CLI (which waits minutes on orca.cli) is never judged by 20s of silence.
  • Windows deps probe exits 0 on a real load failure — the repair-path probe gained the $LASTEXITCODE guard so a non-zero node exit prints MISSING and exits 0, matching the POSIX twin and the sibling install-path probe.

ℹ️ Sleep/wake rebase lost its only test coverage

The "does not reap every client on the first tick after the host slept" test used to exercise the resumedAfterPause rebase, but now that lastReceivedAt is nullable it passes through the lastReceivedAt === null guard instead, because the test client never speaks. The rebase is still load-bearing — a spoken client would be reaped after a >20s host pause without it — yet no test covers a spoken client surviving a pause.

Technical details
# Rebase coverage gap

## Affected sites
- src/relay/dispatcher-silent-client-reaper.test.ts:51 — "does not reap every client on the first tick after the host slept" attaches a client and feeds it nothing, so `lastReceivedAt` stays `null` and the null guard (not the rebase) skips the reap.
- src/relay/dispatcher-client-lifecycle.ts:184 — `if (resumedAfterPause && client.lastReceivedAt !== null)` rebase path is no longer reached by any test.

## Required outcome
- A test where a client that has already sent a keepalive survives a host pause > `TIMEOUT_MS` via the rebase (and is not reaped).

## Suggested approach
- In the sleep test, feed one keepalive frame before `vi.setSystemTime(...)` so `keepaliveObserved` is true and `lastReceivedAt` is non-null, then assert the client is not detached. Optionally add a boundary case around the pause length.

ℹ️ Nitpicks

  • src/relay/dispatcher-silent-client-reaper.test.ts:46 — the comment says the unattached primary sink "is expected to be reaped"; with keepaliveObserved it never speaks and is now skipped, so the comment is stale.

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

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: c60ca9b6-c69e-4748-837b-3bdf4de6e341

📥 Commits

Reviewing files that changed from the base of the PR and between 06b0eea and 8cc42cd.

📒 Files selected for processing (2)
  • src/relay/dispatcher-client-lifecycle.ts
  • src/relay/dispatcher-silent-client-reaper.test.ts

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

@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.

ℹ️ One test-quality item: the new primary-exemption test doesn't actually pin the exemption it names. The dead-band fix itself is correct.

Reviewed changes

  • Rebase threshold moved below TIMEOUT_MS — resumedAfterPause now arms at TIMEOUT_MS - KEEPALIVE_SEND_MS, so a healthy client whose lastReceivedAt is ~5s stale can never be reaped on a pause, closing the dead band the prior review flagged.
  • Primary sink exempt from reaping — the reaper skips primaryClient, whose close would tear down the relay's stdin/stdout with no production revival path.
  • Tests — a dead-band regression test for the stall scenario (meaningful — it fails at the old TIMEOUT_MS threshold), and a primary-exemption test (see inline).

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

This was referenced Sep 1, 2026
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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.

ℹ️ The merge reconciliation is clean and adds no new behavioral issues, but the PR is not approvable: the "never reaps the primary client" test still doesn't pin the exemption it names (flagged inline at dispatcher-silent-client-reaper.test.ts:120). The primary never speaks in that test, so lastReceivedAt stays null and the reaper already skips it on the null guard — removing the client === this.primaryClient exemption would not fail the test.

Reviewed changes

The only commit since the last review is a merge origin/main, which reconciles this branch's native-deps probe with the version main already landed in #18000:

  • Aligned the probe verdict vocabulary — probeRequiredNativeDeps now returns status: 'ok' | 'blocked' | 'unverifiable' (main's naming) instead of the branch's verdict: 'available' | 'missing' | 'unverifiable'; the repairInstalledNativeDeps gate and re-probe were updated to match. Semantics are preserved: an unanswered probe is still unverifiable, and only an answered blocked authorizes repairing node_modules.
  • Adopted main's locked re-probe fallback — a locked re-probe returning unverifiable now falls back to the initial probe's answered missing list rather than dropping repair evidence.
  • Dropped the now-redundant wording — removed the "Native-deps probe did not answer" console warning and replaced the test's warn-text assertion with a behavioral rm -rf node_modules/node-pty check that pins "no answer ⇒ no rewrite".

The merge result is coherent — no stale verdict/available references remain — and the fix's intent (silence is not evidence) survives the reconciliation intact.

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

@nwparker

nwparker commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Review finding: the primary-exemption test is vacuous — proven by mutation.

Deleting the client === this.primaryClient guard from reapSilentClients leaves the suite fully green:

Test Files  1 passed (1)
     Tests  7 passed (7)

That includes 'never reaps the primary client, whose sink cannot be revived'. The test never feeds the primary, so lastReceivedAt === null and keepaliveObserved === false cause it to be skipped regardless of the guard.

The exemption is load-bearing in production — a real client answers keepalives, so only the exemption saves it. The code is right; the test cannot detect its removal. Both pullfrog (3901312184) and CodeRabbit (3901309642) flagged this with the same one-line fix (dispatcher.feed(encodeKeepAliveFrame(1, 0))), and it is still unaddressed.


Second, unmentioned issue: an untested regression at three call sites.

Pre-change, a saturated-writer wedge left the mux alive and requests failed at 30s with SSH_MUX_REQUEST_TIMEOUT. Post-change the mux disposes at 20s, and dispose('connection_lost') rejects pending requests with CONNECTION_LOST. Three sites branch on isSshMuxRequestTimeoutError:

  • src/main/text-generation/source-control-remote-generation.ts:28 — the timeout branch says "…may still be running on the remote host."; the fallthrough says "could not be reached on the {location}."
  • src/main/text-generation/commit-message-model-discovery.ts:209
  • src/main/ai-vault/ssh-session-list.ts:87

So this deletes the unverifiable wording from three user-facing surfaces, with no test and no mention in the body. The discrimination point is deliberate — ssh-channel-multiplexer.ts:66-68 documents "callers branch on 'the request timed out'…".

For reference, mosh treats this exact sentence as essential, printing it even as it gives up (src/frontend/stmclient.cc:229-232): "the mosh-server process may still be running on the server."


Body accuracy: the "three-state native-deps probe" headline already landed on main via #18000 — probeRequiredNativeDeps returns 'ok' | 'blocked' | 'unverifiable' there today. And "execCommand gained a typed SSH_EXEC_TIMEOUT_CODE so callers discriminate on a code rather than message text" — no caller reads it; EXEC_TIMEOUT_MESSAGE = /timed out after \d+s$/u in ssh-remote-platform-detection.ts:17 still matches on text.

The core fix is sound and well-supported — removing writerSaturated suppression and gating on inbound silence is strictly better evidence than VS Code's equivalent load-estimator proxy, and it lands on OSS precedent.

To unhold: feed the primary a keepalive in that test; preserve or restore the three-call-site wording; correct the body. Note this must land with or immediately before #17928, which fixes a pre-dispatch tombstone bug that this PR widens.

@nwparker
nwparker force-pushed the fix/ssh-link-wedge-and-probe-verdict branch from 23d0539 to c54be7e Compare September 2, 2026 20:48

@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.

Reviewed changes

Since the prior review (23d0539), this PR added the following:

  • Widened the request-outcome verdict to cover CONNECTION_LOST — introduced isSshRequestOutcomeUnverifiable (matching SSH_MUX_REQUEST_TIMEOUT_CODE and the CONNECTION_LOST disposition) and switched the three user-facing call sites onto it, so a wedged link's connection_lost dispose keeps the "may still be running on the remote host" wording instead of regressing to "could not be reached".
  • Consumed the typed exec-timeout code — ssh-remote-platform-detection.ts now branches on isSshExecTimeout rather than the /timed out after \d+s$/u message regex, retiring the previously-unused export and closing the look-alike-message hole.
  • Bounded the never-spoken client — reapSilentClients now reaps a client that cleared the handshake but never framed anything after six silence windows, rebased across a host suspend, so its socket and client entry can no longer be held for the relay's lifetime.
  • Fixed the primary-exemption test — the "never reaps the primary" test now feeds the primary a keepalive first, so the exemption (not the null/keepalive guards) is what keeps it alive.

Each of the three verdict sites gained a regression test asserting the unverifiable wording survives CONNECTION_LOST, the predicate itself has a unit test, and the two isSshExecTimeout branches gained look-alike-message coverage.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the fix/ssh-link-wedge-and-probe-verdict branch from c54be7e to c58e8bb Compare September 2, 2026 21:04
@nwparker
nwparker force-pushed the fix/ssh-link-wedge-and-probe-verdict branch from c58e8bb to 0632910 Compare September 2, 2026 21:13

@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.

Reviewed changes

Since the prior review (c54be7e), this PR landed a single substantive commit on top of two pure rebases onto main:

  • Restored the activityOptions i18n key — src/renderer/src/i18n/locales/en.json regained the activityOptions entry (plus the missing trailing comma on showChildAgents) that a rebase had dropped. The key is consumed by activity-thread-options-menu.tsx:104, so without it the Activity-options tooltip label would silently fall back to the inline default instead of rendering the locale string.

The restore is correct: the entry nests under auto.components.activity.ActivityPrototypePage as referenced, and its value matches the existing fallback.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@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.

Reviewed changes

Since the prior review (152fc64), this PR landed one commit:

  • Unioned en.json with main — restored the dashboard.sidebar keys openActivity ("View activity") and closeActivity ("Turn off activity view") and the trailing comma on dashboardLabel, which the latest rebase had dropped. Both keys are consumed at SidebarHeader.tsx:40-43 via translate(key, inlineDefault), and those inline defaults already carry the identical strings, so the drop was invisible — but keeping the locale file complete against main stops the same keys being dropped again on the next rebase.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 7458c39 into main Sep 2, 2026
25 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…as a verdict (stablyai#17817)

* fix(ssh): declare a wedged relay link lost instead of suppressing the dead-link check

* fix(ssh): make the Windows deps probe exit 0 on a real load failure, like its POSIX twin

* fix(relay): reap a client that has stopped answering instead of holding its leases forever

* test(relay): feed the primary before asserting the reaper exemption holds

* fix(ssh): keep a lost link's verdict unverifiable instead of reporting absence

* refactor(ssh): read the exec timeout from its typed code, not the message text

* fix(relay): bound a client that clears the handshake and then never frames anything

* 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