From 184b6fc6a66078c76fd6b08fda4d92e14c1d0781 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sat, 29 Aug 2026 13:57:12 -0400 Subject: [PATCH] Correct the claim that reattach is local only Written down as "an ssh session's child dies with its connection, so it takes the ordinary --resume path". The code never had that branch: `start` records a pid whatever the transport, and for a remote session the process the backend owns is the ssh client. Adopting it is right -- the fifo feeds it, its logs capture the far end, and ssh lives exactly as long as the remote command, so its liveness is the session's. The docs claimed less than the code does, which is the safe direction to be wrong in but still wrong, and it was about to mislead someone: a remote `claude` has an sshd pipe on stdin under every version of this server, because the fifo is on the backend's side of the connection. Reading a remote session's stdin therefore says nothing about which backend started it, and we were an inch from concluding otherwise. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01VETa8afmpWaYezLCqJhDB8 --- AGENTS.md | 9 +++++++-- PLAN.md | 14 +++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 292a4d4..58f6167 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -281,8 +281,13 @@ day: - **`--resume` only ever runs when nothing is running.** That check is the fix for the incident below, and the reason there is one entry point (`ClaudeDriver::launch`) rather than a spawn and an attach. -- Local only: an ssh session's child dies with its connection, so it takes - the ordinary `--resume` path. +- Remote sessions are adopted too. The pid recorded for one is the **`ssh` + client's**, on this machine — that is the process the backend owns, and it + lives as long as the remote command does. (This said "local only" until + 2026-08-29; the code never had that branch.) Note the far `claude` always + has an sshd pipe on stdin whichever version started it, since the fifo is + on the backend's side — so you cannot tell a backend's version by looking + at a remote session's stdin. The import list reports each session's **size as well as its line count**, because the two disagree in the way that matters: these transcripts embed diff --git a/PLAN.md b/PLAN.md index b600277..3b23e95 100644 --- a/PLAN.md +++ b/PLAN.md @@ -266,9 +266,17 @@ Two consequences worth stating: rule as the import refusal below, and for the same reason: two CLIs on one session file duplicate the conversation into it and bill the second for re-reading all of it. -- **Local only.** An ssh session's child sits behind a connection that dies - with the server, so there is nothing to adopt; nothing is recorded for one - and it takes the ordinary `--resume` path. +- **Remote sessions are adopted too, and the recorded pid is the `ssh` + client's.** This was written down as "local only" and that was wrong about + the code: `start` records a pid whatever the transport, and for a remote + session the process the backend owns *is* the ssh client. Adopting it is + coherent — the fifo still feeds it, its logs still capture the far end's + output, and `ssh` lives exactly as long as the remote command does, so its + liveness is the session's liveness. + The consequence worth knowing: **the remote `claude` always has an sshd + pipe on stdin, under old code and new alike**, because the fifo is on the + backend's side of the connection. So the far process's stdin says nothing + about which version of this server started it. `Driver` therefore has two ways out rather than one: `detach` (the server is going away and means to come back) and `stop` (the session is being deleted,