Skip to content

The agent that grows with you

fix(desktop): ship the SSH relaunch marker gate on stdin, not in the ssh command

xxxigm0630e548ebcf
diff --git a/apps/desktop/electron/remote-lifecycle.ts b/apps/desktop/electron/remote-lifecycle.ts
index a043888c95e..b9fdae38823 100644
--- a/apps/desktop/electron/remote-lifecycle.ts
+++ b/apps/desktop/electron/remote-lifecycle.ts
@@ -331,6 +331,17 @@ async function probeRemoteHermesHome(ssh) {
* located, adds its checkout to the probed ones. Every parse, read, lock, or
* transport uncertainty fails closed so a Desktop relaunch cannot start
* `serve` beside an updater that survived the old app process.
+ *
+ * The program travels on stdin (`python3 -`), not in argv. `ssh.exec` rides the
+ * POSIX ControlMaster mux socket, where ssh writes the session request and only
+ * then hands our stdio descriptors over with sendmsg(SCM_RIGHTS): a request
+ * still sitting in the socket buffer leaves no room for that descriptor message
+ * and the pass fails with EMSGSIZE ("mm_send_fd: sendmsg(0): Message too long",
+ * exit 255). macOS sizes a unix-stream buffer at 8 KB and the gate program is
+ * ~7.5 KB, so an inlined `python3 -c` landed a connect inside that window and
+ * every reconnect read a transport error as "could not prove it is clear".
+ * Python compiles the whole program before running it and the gate never reads
+ * stdin, so argv stays a few dozen bytes however the judge grows.
*/
async function assertRemoteInstallUpdateClear(ssh, hermesHome, hermesPath = '') {
const marker = expandRemotePath(`${remoteInstallRoot(hermesHome)}/.hermes-update-in-progress`)
@@ -339,7 +350,7 @@ async function assertRemoteInstallUpdateClear(ssh, hermesHome, hermesPath = '')
try {
observation =
- String(await ssh.exec(`python3 -c ${shq(REMOTE_MARKER_GATE_PY)} ${marker}${hermes}`))
+ String(await ssh.exec(`python3 - ${marker}${hermes}`, { stdinData: REMOTE_MARKER_GATE_PY }))
.trim()
.split(/\r?\n/)
.pop() || ''
diff --git a/apps/desktop/electron/remote-update-marker-programs.ts b/apps/desktop/electron/remote-update-marker-programs.ts
index fcd2760e5c4..154904b7be2 100644
--- a/apps/desktop/electron/remote-update-marker-programs.ts
+++ b/apps/desktop/electron/remote-update-marker-programs.ts
@@ -108,8 +108,10 @@ def marker_verdict(raw):
`
/**
- * POSIX gate: `python3 -c GATE <marker> [payload] [hermes...]` (an empty payload
- * is the probe). Holds the updaters' kernel lock `<marker>.lock` (A7 rule 1:
+ * POSIX gate: `python3 -c GATE <marker> [payload] [hermes...]`, or the same
+ * arguments after `python3 -` with the program on stdin (an empty payload is the
+ * probe, which the relaunch gate ships on stdin to keep its ssh argv small).
+ * Holds the updaters' kernel lock `<marker>.lock` (A7 rule 1:
* Python update_lock flock, marker.sh flock) for a bounded 10 s, judges the
* marker, and unlinks a dead claim inside that hold only while the install's
* CHECKOUT lock is free (update_lock._reclaim_dead): a killed updater's