Skip to content

fix(ssh): a live run's journal reads busy, a wake releases only its own fence, a cancelled re-check never reports connected - #25470

Merged
OrcaWin merged 2 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-delta-ssh
Oct 5, 2026
Merged

OrcaWin merged 2 commits into
OrcaWin/node-rt-phase3from
OrcaWin/node-rt-p3-delta-ssh

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​185 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​178
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​87 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62

ELI5

This fixes three small correctness problems in the last round of SSH fixes:

  • Busy reported as broken: a host that was simply busy could still be reported as needing recovery.
  • Wrong fence released: a lock left by one wake could be released after another run had taken it.
  • Cancelled connect shown as connected: a connect cancelled at the wrong moment could still show "connected".

What Changed

A live run's journal is busy, not "recovery required".

  • Before: any journal behind a held fence meant "recovery required". A healthy update or stop from another client keeps a journal under the fence for minutes, so a second client was told to Recover, and auto-update recorded a failure. Recover also cannot take a fresh fence, so the user couldn't act on that message.
  • After: a held fence reads orcad_activation_fence_busy, which is retried, unless the lock is past its stale age or a journal exists with no fence over it. Deploy's pre-upload shortcut uses the same classifier, so a fresh fence returns busy.

A wake releases only the fence it left.

  • Before: after a wake lost its connection, the client remembered the host and later released whatever fence it found with no journal. That included one another run had taken after the original was cleared some other way.
  • After: a wake writes an owner token into the fence's lock directory, and later releases only a fence that carries that token. Seeing the fence gone also forgets it.

A cancelled connect never reports connected after the relay-terminal re-check. doConnect checks session ownership after refineRelayTerminalDecision, the same way it does after every other await. Inside the re-check, an attempt that is no longer current neither records a relay decision nor retires leases.

A caller that joined a cancelled tunnel run builds its own. This is the ssh-orcad-idle-exit race.

  • What happened: after a relaunch, the launch-time restore starts a tunnel run that connects over SSH. The test's disconnect cancels that connect. The explicit connect that followed had joined the run, so it failed with "SSH connection attempt was cancelled".
  • Fix: a joiner now builds once anew after any end of the joined run, except an auth failure, which it shares rather than prompting again.
  • Tests: two cases cover this, and they fail without the fix.

Why

  • Busy vs. recovery: a fence that a live run will release soon should be retried. Only a stale lock or an unguarded journal is evidence of an interrupted run.
  • Owner token: an in-memory flag can't tell its own fence from a later one, so the token makes the release exact.

Linked Issue

N/A (Phase 3 delta review)

Visual Proof

N/A. There is no UI change.

Testing

  • pnpm tc:node passes.

  • pnpm test src/main/ssh src/main/ipc passes: 800 files, 8897 tests.

  • The changed-code gate passes.

  • New tests:

    • the fence classifier (live journal is busy; stale lock or unguarded journal is recovery);
    • a wake never releases a fence another run took after its own was cleared;
    • the re-check reports and retires nothing when cancelled;
    • a connect cancelled during the re-check rejects instead of resolving connected (this one fails without the fix).
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH execution boundary: respected; no unknown reads as exited.
  • Wire: no wire change. The owner token file lives inside the lock directory, so older clients that release the fence remove it too.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…wn fence, a cancelled re-check never reports connected

- A held fence asks for Recover only when its lock is stale or a journal has no fence over it;
  a journal under a fresh fence is a run still working and reads orcad_activation_fence_busy.
- A wake writes an owner token into the fence it takes and later releases only a fence carrying
  that token; observing the fence gone forgets it.
- The connect re-checks ownership after the relay-terminal re-check, and the re-check itself
  neither records a decision nor retires leases for a cancelled attempt.
…ilds its own

The launch-time restore's tunnel run connects over SSH; a disconnect then cancels that connect.
An explicit connect that had joined the run inherited its SshConnectAttemptCancelledError and
failed (seen as the idle-exit e2e's 'connect threw: ... cancelled'). A joiner now builds once
anew after any end of the joined run except an auth failure, which it shares rather than prompt again.

@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 — full PR reviewed in this run (no prior Pullfrog review to delta against); the head commit adds the tunnel-joiner retry on top of the three fixes in 8c6ece1.

  • Classified a held activation fence as busy unless the install lock is stale or a journal is left with no fence over it, so a healthy update or stop from another client no longer reads as recovery-required.
  • Gave each wake an owner token inside the fence's lock directory and release only the fence carrying that exact token, so a fence a later run took after the original was cleared is never dropped.
  • Threaded isCurrent through the relay-terminal re-check so a cancelled connect neither records a live relay decision nor retires leases, and re-checked session ownership in doConnect after the re-check returns.
  • Made a tunnel caller that joined a run a disconnect cancelled build its own once, while sharing an auth failure instead of prompting again.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 1917049 into OrcaWin/node-rt-phase3 Oct 5, 2026
86 of 88 checks passed
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