Repository navigation
fix(runtime): hold parking and transport reads through an unverifiable probe - #20096
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Transport verdict fall-through —
runtimeHostConnectionStateForEntrynow feeds the snapshot's own transport intotransportStatus(ready → connected,connecting/unknown → checking) instead of letting it default todisconnected, so a host still establishing contact readscheckingrather than the destructivedisconnectedverdict. I re-ran the fall-through againstruntimeHostConnectionStateand the enumerated table is accurate, including theremoteControl: closedandretired/blockedshort-circuits. - Parking capability reads — both paired-parking readers now go through
lastVerifiedRuntimeStatus, so an unverifiable probe no longer unpacks a parked terminal or cold-restores a fresh session viadeferred-session-reattach-choice.ts:96. - Single nulling rule —
refreshRuntimeEnvironmentStatustakes an explicitapplySnapshotcallback, deleting the deadverification === 'verified'duplicate that its only caller already discarded. Behavior-identical, and the dead-code claim checks out againstruntime-host-status-owner.ts(disposesetsretiredalongsideverification: 'blocked'). - Tests — the enumerated verdict table and the unverifiable-probe parking cases bind to the fixes and fail against the pre-fix sources (the two
connecting/unknown+unavailablerows and bothstatus: null+snapshotcapability reads).
One non-blocking note for awareness, not a change request: the parking reads don't exclude retired the way the transport verdict does, so a disposed host's retained snapshot.status still reads as "capable" via lastVerifiedRuntimeStatus. That's harmless in practice — retired environment ids are deleted from runtimeStatusByEnvironmentId on the next catalog update — and consistent with "a capability is a fact about the host's build", but it's the one asymmetry between the two reads worth having consciously accepted.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
1292d5b to
ae5e9f7
Compare
323fa13 to
5b1df3f
Compare
There was a problem hiding this comment.
Important
The narrowed transport hint re-exposes a case the previous commit had fixed: a host that has already answered a status probe can keep transport: 'unknown' for the whole session and, after one failed probe, now reads disconnected, dropping the session mirror and blanking its SSH rows. Evidence and a proposed discrimination are inline.
Reviewed changes
Since the prior pullfrog review (323fa135), commit 5b1df3f:
- Added
isRuntimeHostContactRevokedtoruntime-host-status.tsand gated both paired-parking reads and the connection-state derivation on it, resolving theretired/blockedasymmetry the prior review flagged. - Narrowed the transport fall-through to
connecting → 'checking', deliberately leavingunknownat the default'disconnected', with an affordance test asserting a never-contacted host staysConnect-able. - Extended
paired-parking-unverifiable-host.test.tswithblocked/retiredrefusal cases for both parking reads.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // Why only 'connecting': a transport mid-handshake fell through to the default and | ||
| // reported a host still establishing contact as down. 'unknown' keeps that default on | ||
| // purpose — it means no transport was ever attempted, which for an unreachable paired | ||
| // host is the permanent state, and 'checking' there withdraws its Connect action and | ||
| // pins the status bar to "connecting" forever. | ||
| ...(snapshot?.transport === 'connecting' ? { transportStatus: 'checking' as const } : {}), |
There was a problem hiding this comment.
transport: 'unknown' is not exclusive to a host that was never contacted: the desktop status owner leaves it at 'unknown' whenever shared control is absent (runtime-environment-status-owner.ts calls transport.pause() for a capability-absent host, a no-op with no connection) or the read is passive, and complete() retains snapshot.status across a later failed probe. That entry — status: null, snapshot: { status: <verified>, verification: 'unavailable', transport: 'unknown' } — reads disconnected here, so getReachableRuntimeSessionMirrorTargets drops a target whose retained runtimeId is non-null and runtime-environment-ssh-selectors.ts blanks its rows: loss of contact read as exit. The never-contacted host this is fixing has snapshot.status === null; discriminating on that keeps the Connect affordance and holds a previously-answered host as unverifiable.
Technical details
# `unknown` transport with a retained verified status must not read `disconnected`
## Affected sites
- `src/renderer/src/runtime/runtime-host-connection-state.ts:147` — the hint is passed only for `'connecting'`; with `'unknown'` the fall-through defaults `transportStatus` to `'disconnected'`.
- `src/renderer/src/runtime/runtime-host-connection-state.test.ts:281` — the new row asserts `disconnected`; the comment at :279-280 encodes the premise ("no transport was ever attempted") the code below refutes.
- `src/renderer/src/lib/runtime-session-mirror-targets.ts:55` — `isDisconnectedRuntimeHostState(...)` short-circuits before the retained `runtimeId` at :58 is read.
- `src/renderer/src/store/slices/runtime-environment-ssh-selectors.ts:22-24` — `isConnectedRuntimeHostState` false, so mirrored SSH rows/errors are withheld.
## Why `unknown` is reachable for a host that already answered
- The owner initializes `transport: 'unknown'` (`src/shared/runtime-host-status-owner.ts:44-52`) and only `connectionChanged` writes it (`:133-159`); no production caller passes `'unknown'`.
- The desktop owner calls `transport.establish()` only when the host advertises `REMOTE_RUNTIME_SHARED_CONTROL_CAPABILITY` (`src/main/ipc/runtime-environment-status-owner.ts:56-72`); otherwise `transport.pause()`, a no-op when no connection exists (`src/main/ipc/runtime-environment-request-connections.ts:182-184`). A reachable `capabilities: []` host therefore keeps `'unknown'` indefinitely (`runtime-environment-status-recovery.test.ts:47-70` verifies one successfully).
- `complete()` retains `snapshot.status` on a failed probe (`runtime-host-status-owner.ts:223-229`), and the store nulls only `entry.status` (`src/renderer/src/store/slices/runtime-status-snapshot.ts:27`).
- `runtimeHostConnectionStateForEntry` passes `entry.status` (not `snapshot.status`) into `runtimeHostConnectionState` (`:141`), so the retained verified status is invisible to the transport branch.
## Required outcome
- A host with a retained verified status must read as unverifiable (`checking`), not `disconnected`, when its transport is `'unknown'` and its latest probe failed. The never-contacted case (`snapshot.status === null`) may keep returning `disconnected` so the row keeps its Connect action.
## Suggested approach (optional)
- Discriminate on the retained status at `:147`, e.g. treat `transport === 'connecting' || (transport === 'unknown' && snapshot.status != null)` as `'checking'`, or derive the hint from `lastVerifiedRuntimeStatus(entry)`.
- Add a row for `unknown` + `unavailable` with a non-null `snapshot.status`; the new `snapshotWith` helper only builds `status: null`, so this case is uncovered.
## Open questions for the human (optional)
- Is a capability-absent (or passive-only) host expected to keep its session mirror / SSH rows? If not, this destructive read may be intended; if yes, the retained-status case needs the hold.ae5e9f7 to
e17ac8e
Compare
5b1df3f to
9b44476
Compare
…e probe Three remaining sites where a non-verified status probe was read as evidence the host is gone, per docs/reference/ssh-execution-boundary.md. - runtime-status-refresh published its own copy of the "null the status unless verified" rule, then handed the snapshot to applyRuntimeHostStatusSnapshot, which re-derived it. The copy was dead but free to drift; the snapshot branch now calls applyRuntimeHostStatusSnapshot directly, leaving one implementation. - The paired-parking capability reads treated a nulled status as "host cannot park", so a transient probe failure unparked live paired terminals and dropped a parked session's reattach in favour of a fresh cold restore. Both now read lastVerifiedRuntimeStatus; a capability is a fact about the host's build. - runtimeHostConnectionStateForEntry handled transport 'disconnected' and 'ready' and let 'connecting'/'unknown' fall through to the default 'disconnected' — reporting a host mid-handshake as down, a worse verdict than an actually disconnected transport gets. It now passes the snapshot's transport through.
Holding a capability through an unverifiable probe is right; holding it through the host's own refusal is not. `blocked` (auth rejected, protocol mismatch) stops every retry for good, and parking trades the client's only copy of the scrollback for a host-side restore that can then never happen -- the destructive direction. `isRuntimeHostContactRevoked` names that one terminal verdict once, and the connection-state derivation now reads it too so there is a single definition. Also narrows the transport hint to 'connecting'. 'unknown' means no transport was ever attempted, which is the permanent state of an unreachable paired host: as 'checking' its row lost its Connect action and the status bar read "connecting" for the whole session.
9b44476 to
6caf692
Compare
…e probe (stablyai#20096) * fix(runtime): hold parking and transport reads through an unverifiable probe Three remaining sites where a non-verified status probe was read as evidence the host is gone, per docs/reference/ssh-execution-boundary.md. - runtime-status-refresh published its own copy of the "null the status unless verified" rule, then handed the snapshot to applyRuntimeHostStatusSnapshot, which re-derived it. The copy was dead but free to drift; the snapshot branch now calls applyRuntimeHostStatusSnapshot directly, leaving one implementation. - The paired-parking capability reads treated a nulled status as "host cannot park", so a transient probe failure unparked live paired terminals and dropped a parked session's reattach in favour of a fresh cold restore. Both now read lastVerifiedRuntimeStatus; a capability is a fact about the host's build. - runtimeHostConnectionStateForEntry handled transport 'disconnected' and 'ready' and let 'connecting'/'unknown' fall through to the default 'disconnected' — reporting a host mid-handshake as down, a worse verdict than an actually disconnected transport gets. It now passes the snapshot's transport through. * fix(runtime): keep a revoked host out of the parking promise Holding a capability through an unverifiable probe is right; holding it through the host's own refusal is not. `blocked` (auth rejected, protocol mismatch) stops every retry for good, and parking trades the client's only copy of the scrollback for a host-side restore that can then never happen -- the destructive direction. `isRuntimeHostContactRevoked` names that one terminal verdict once, and the connection-state derivation now reads it too so there is a single definition. Also narrows the transport hint to 'connecting'. 'unknown' means no transport was ever attempted, which is the permanent state of an unreachable paired host: as 'checking' its row lost its Connect action and the status bar read "connecting" for the whole session. * test(runtime): pin the parking gate against over-firing on a flap

Stacked on #20095. Closes the last three sites in the status-verdict family where a non-
verifiedprobe was read as evidence the host is gone.Governing rule:
docs/reference/ssh-execution-boundary.md— verdicts arelive/unverifiable/exited, no synonyms, and loss of contact is never evidence of process death. ReuseslastVerifiedRuntimeStatus()from #20085; no new predicates.1. Writer divergence — real as duplication, unreachable as a behaviour split
runtime-status-refresh.ts:25andruntime-status-snapshot.ts:27both implemented the "null the status unless verified" rule, and only the latter guarded on!snapshot.retired/ mergedremoteControl. The reported consequence — a retired host publishing a non-nullentry.statusthrough the manual-refresh path — does not reproduce, for two independent reasons:retired: trueimpliesverification: 'blocked', permanently.retiredis set in exactly one place,RuntimeHostStatusOwner.dispose()(src/shared/runtime-host-status-owner.ts:182), together withverification: 'blocked'.dispose()setsthis.disposed, and every mutator (activate,acceptVerified,refresh,connectionChanged,authenticationRejected,startRequest,verify) early-returns ondisposed, so no laterupdate()can reach the snapshot.verification === 'verified' && !retiredis therefore equivalent toverification === 'verified'. The owner is the only producer — bothgetStatusSnapshotspaths (runtime-environment-connectivity-handlers.ts:64,web-runtime-session.ts:46) just read owner snapshots.statuswas never used. Its caller (runtime-status.ts:297) branchedif (entry.snapshot) { applyRuntimeHostStatusSnapshot(entry.snapshot); return }— discarding the entry and re-deriving through the other rule. The duplicate was dead code.So there is no user-visible split today. The duplication is still the defect this area keeps producing, so the dead copy is removed rather than left to drift:
refreshRuntimeEnvironmentStatusnow takes an explicitapplySnapshotcallback and hands the snapshot straight toapplyRuntimeHostStatusSnapshot, leaving one implementation of the nulling rule.Mutation table: none. Behaviour-identical by construction — the removed expression's value was already discarded by the only caller.
2. Paired-parking capability reads — real, and one is destructive
Both sites read
entry.status?.capabilities, so a nulled status reads as "this host cannot park".paired-parked-terminal-restore.ts→deferred-session-reattach-choice.ts:96— destructive. Path proven: reaching line 96 requiresisRemoteRuntimePtyId(candidateReattachSessionId). WhencanRestorePairedParkedTerminalreturns false,pairedParkedReattachSessionIdis null;runtimeHostPtyWakeHint(line 66) and the third disjunct (line 103) both require!isRemoteRuntimePtyId(candidate), so both are false too —deferredReattachSessionIdis null. WithhasSleepingAgentSessiontrue,detachedLivePtyIdanddetachedRemoteLeafPtyIdare both null (lines 48, 56) andeagerLivePtyIdrequires a non-remote id, so control reaches the finalelseand callsstartFreshColdRestoreAgentResume.A parked paired terminal that should have reattached instead cold-restores a fresh session, because its host failed one status probe. This is reachable exactly when it matters: panes remount on reconnect while the status probe is still in flight.
paired-runtime-parking-capabilities.ts→canWatcherCoverParkedTerminalTab— real but conservative. A false negative propagates throughisParkRestorableTerminalPtytoparkedTabIds.delete(...)(terminal-cold-park-withheld-tabs.ts:47) andimmediateTabIds.add(...)(terminal-cold-activation.ts:127): a tab that should have parked stays mounted. No output is lost — the gate only ever fails toward mounting, and the pane owns the bytes. The cost is churn: every paired terminal tab in the workspace unparks and remounts on each transient probe failure, then re-parks on recovery.Both now read
lastVerifiedRuntimeStatus. A capability is a fact about the host's build, not about current reachability.entry.statussnapshot.statusnullnullnullnull3. Transport fall-through — real, and inverted
runtimeHostConnectionStateForEntry's snapshot branch handledtransport: 'disconnected'and'ready';'connecting'and'unknown'fell through toruntimeHostConnectionState, which was called withouttransportStatusand so defaulted it to'disconnected'.Reachable, and the verdict is inverted: a host whose transport is disconnected returns
'reconnecting', while a host actively connecting returned'disconnected'— the destructive verdict, the only oneisDisconnectedRuntimeHostStateaccepts and the one that earns the red glyph.The producing sequence is ordinary reconnect.
connectionChanged('connecting')with a previous transport of'ready'setsverification: 'unavailable'(runtime-host-status-owner.ts:145-151). On the desktop path the caller passesdiagnostics, whoseremoteControl.statesteers the result before the default applies.web-runtime-client.ts:58passes no diagnostics, soremoteControlstays undefined and the default lands — the web client painted a reconnecting host as disconnected.Fixed by passing the snapshot's own transport instead of letting it default.
'disconnected'already returned above, so'ready'is the only connected transport remaining.UI effect:
runtimeStatusForOverallmaps'checking'toconnectingand'disconnected'todisconnected, andisDisconnectedRuntimeHostStateis true only for'disconnected'. The status bar and Settings > Available Hosts move that host from the red disconnected glyph to the connecting state for the duration of the handshake. That is the correct reading: the transport is being established, which is unverifiable, not exited.Mutation table (
entry.statusnull, noremoteControl—transportStatusonly feeds the!statusbranch, so every case with a non-null status is unchanged):snapshot.transportverificationdisconnectedreconnectingreconnectingreadyunavailableruntime-unavailableruntime-unavailablereadycheckingcheckingcheckingconnectingcheckingcheckingcheckingunknowncheckingcheckingcheckingconnectingunavailabledisconnectedcheckingunknownunavailabledisconnecteddisconnected(corrected in the follow-up below)blockeddisconnecteddisconnectedretireddisconnecteddisconnectedconnectingunavailable,remoteControl: closeddisconnecteddisconnectedVerification
Each gate was proven able to fail before its pass was believed.
connecting/unavailableandunknown/unavailablereturning'disconnected'instead of'checking', plus both capability reads. 26 other tests in those files still passed, so the suites are not merely tautological.tsc -p config/tsconfig.tc.web.json,config/tsconfig.node.json,config/tsconfig.tc.cli.json— all empty logs. Proven failable: a deliberate type error inruntime-host-connection-state.tsreportedTS2322at the right line.vitest run --config config/vitest.config.tsoversrc/renderer/src/runtime/,src/renderer/src/lib/,src/renderer/src/store/slices/, the parking suites andpty-connection/— 733 + 329 + 6 + 8 files, 0 failures. Logs grepped forFAILrather than trusting the exit code.oxlintover the four touched directories, exit 0. Proven failable: an unused variable reportedno-unused-vars.The
'ready'+'checking'row was wrong in my first draft of the verdict table — I had expectedruntime-unavailable, but theverification === 'checking' && !statusguard answers first. The enumerated table caught it; the code was right and the expectation was wrong.Follow-up commit:
fix(runtime): keep a revoked host out of the parking promiseTwo defects found by adversarial review after the sections above were written. Both are fixed in the second commit on this branch.
A. The capability reads had no trust gate, and one direction is destructive
Section 2 above is right that a capability is a fact about the host's build. It is not right that the fact survives every verdict.
blockedandretiredstop all retries permanently (runtime-host-status-owner.ts:93, 187, 237), andsnapshot.statusis never cleared (:221is its only writer), so both sites kept advertisingTERMINAL_PAIRED_PARKING_RUNTIME_CAPABILITYfor a host that can never honour a restore.That inverts the safe direction for the parking site.
selectPairedRuntimeParkingEnvironmentIds→isParkRestorableTerminalPty→selectColdParkedTerminalTabscold-unmounts the pane, and remote-runtime bytes never transit main, so the client's xterm buffer is its only copy of the scrollback. Trading it for a host-side restore that cannot happen is the lossy direction, not the conservative one. Onmainthose tabs stayed mounted.Fix:
isRuntimeHostContactRevokedinsrc/shared/runtime-host-status.tsnames the one terminal verdict — retired, or refused — once. Both parking sites gate on it before readinglastVerifiedRuntimeStatus, andruntimeHostConnectionStateForEntrynow reads the same predicate instead of its own inline copy, so there is a single definition rather than two derivations free to drift.Known limit, stated plainly:
verification: 'blocked'is broader than "the host refused us".isRuntimeHostStatusBlockedalso coversinvalid_argument,invalid_runtime_response,method_not_foundandunsupported_method, and the owner maps any client-sideTypeError/SyntaxErrortoinvalid_runtime_response. So a host whose status method is merely broken is treated as revoked here too. That is the same breadthruntimeHostConnectionStateForEntryhas always had, and it is strictly narrower thanmain, which drops the capability on every non-verified verification. Splitting "refused" from "status method broken" belongs at the owner, in its own PR.B.
transport: 'unknown'is not a handshake in progressThe mutation table above claimed
unknown+unavailableshould readchecking. That was wrong, and the row is corrected.transport: 'unknown'is the owner's constructor default (runtime-host-status-owner.ts:51), andconnectionChangedis only ever called from a shared-control connection's diagnostics handler (runtime-environment-request-connections.ts:229). That connection is created only after a verified probe (runtime-environment-status-owner.ts:69). So for a host that never answers — a paired laptop that is switched off —unknownis not a transient handshake state; it is where the transport stays.Reading it as
checkingwithdrew the user's only affordance:runtimeActionLabel('checking')returnsnull, so the row offered neither Connect nor Disconnect, andruntimeStatusForOverall('checking')held the whole status-bar segment in a connecting state. The hint now applies only totransport: 'connecting', which really is a handshake in flight;unknownkeeps the previous default and the row stays actionable.Verification of the follow-up
Six new assertions, each mutation-checked: reverting the specific fix produced
6 failed | 29 passed (35), restoring it35 passed (35). No survivors. Broader runs on the rebased branch:src/renderer/src/components/terminal-pane453 passed (453)/4360 passed (4360);src/renderer/src/runtime+src/renderer/src/store/slices522 passed (522)/4772 passed (4772); status-bar, sidebar host options andRepositoryHostSetupsSection56 passed (56)/397 passed (397).pnpm tcexit 0 with zeroerror TS;check:code-quality:changedagainst this PR's base exit 0.