Skip to content

fix(ssh): stop fabricating an exit when a reattach fails (STA-3077 E-0) - #13323

Merged
nwparker merged 1 commit into
nwparker/sta-3077-reattach-pane-cardinalityfrom
nwparker/sta-3077-a-no-fabricated-exit
Aug 13, 2026
Merged

nwparker merged 1 commit into
nwparker/sta-3077-reattach-pane-cardinalityfrom
nwparker/sta-3077-a-no-fabricated-exit

Conversation

@nwparker

@nwparker nwparker commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Design step E-0. Goalpost S3. First of a 4-PR stack.

Base is nwparker/sta-3077-reattach-pane-cardinality (PR #13111), not main. That PR stays held; nothing here merges it.

The defect

handlePtyReattachFailure treated a not-found from the relay as proof the shell exited. It is not.

The relay answers PTY "pty-7" not found for a pane-identity mismatch too — where it found the pty, and comparing is how it noticed — and for any id it merely cannot hand back. isSshPtyNotFoundError is a message regex, so both arrive identically. On that basis the client sent the pane a synthetic pty:exit { code: -1 }, cleared provider state, deleted ownership and expired the lease.

Four destructive claims about a process we know nothing about, on a shell that is usually still running.

The change

Collapse every failure into the non-destructive branch that already existed a few lines above (restoreRequired = 'reattachAttemptsExhausted' + wakeRecovery). A branch collapse, not a new mechanism.

−21 production lines.

Evidence

Oracle src/main/ssh/ssh-relay-reattach-exit-proof.test.ts — 8 clauses green.

Mutation proof: restoring the destructive block reddens 6 of 8; the 2 producer pins stay green, so the mutation is clause-selective rather than blunt.

Tests inverted, not patched

  • retires the lease without a kill when the relay proves the PTY is gone → leaves the shell running when the relay only reports the PTY as not found. Its comment asserted that attach verifies liveness before answering not-found. It does not.
  • invalidates and broadcasts remote PTYs that cannot reattach → leaves an unreattachable remote PTY alone while its sibling reattaches.

Compatibility

Client-side only. No relay redeploy — which matters, because the reported failure is happening on hosts people have already deployed. No wire change. Nothing concludes anything from a relay restart, which is the Windows-divergent question the design refuses to depend on.

Made with Orca 🐋

A failed attach never proves the shell exited. The relay answers not-found for
a pane-identity mismatch and for any id it merely cannot hand back, so treating
it as death sent the pane a synthetic `pty:exit { code: -1 }`, cleared provider
state, deleted ownership and expired the lease — four claims about a process we
know nothing about, on a shell that is usually still running.

Collapse every failure into the non-destructive branch that already existed a
few lines above (`restoreRequired = 'reattachAttemptsExhausted'` + wakeRecovery).
A branch collapse, not a new mechanism: goalpost S3.

Two tests pinned the deleted premise and are INVERTED rather than patched, so
the new intent stays covered:
- ssh-relay-orphan-abandon-paths: "retires the lease without a kill when the
  relay proves the PTY is gone" -> "leaves the shell running when the relay only
  reports the PTY as not found". Its comment claimed attach verifies liveness
  before answering not-found; it does not.
- ssh-relay-session: "invalidates and broadcasts remote PTYs that cannot
  reattach" -> "leaves an unreattachable remote PTY alone while its sibling
  reattaches".

Also repairs two clauses left red by c51be80 (step A), which dropped the
expected-identity parameter and the expectedIdentityByPtyId map.

Mutation proof: restoring the destructive block reddens 6 of the 8 oracle
clauses in ssh-relay-reattach-exit-proof.test.ts; the 2 producer pins stay
green. Verified the mutation landed before believing the result.

Net production: -21 lines.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker merged commit c19f1b3 into nwparker/sta-3077-reattach-pane-cardinality Aug 13, 2026
40 of 45 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