Repository navigation
fix(ssh): stop fabricating an exit when a reattach fails (STA-3077 E-0) - #13323
Merged
nwparker merged 1 commit intoAug 13, 2026
Conversation
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
merged commit Aug 13, 2026
c19f1b3
into
nwparker/sta-3077-reattach-pane-cardinality
40 of 45 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Design step E-0. Goalpost S3. First of a 4-PR stack.
The defect
handlePtyReattachFailuretreated a not-found from the relay as proof the shell exited. It is not.The relay answers
PTY "pty-7" not foundfor 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.isSshPtyNotFoundErroris a message regex, so both arrive identically. On that basis the client sent the pane a syntheticpty: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 🐋