agent: launcher probes harnessd liveness with a real request

A stale socket file survived a container idle window while the daemon
died; the [ -S ] check skipped the restart and the nested agent's MCP
server crashed at connect. The agent refused cleanly (no ledger row, no
fabrication). Liveness now means answering read_playbook, not existing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
This commit is contained in:
Claude
2026-07-10 12:11:42 +00:00
parent db6d2dc948
commit 632e861f7f
+14 -2
View File
@@ -55,11 +55,23 @@ fi
( cd "$ROOT" && cargo build -q -p harnessd -p verdict )
mkdir -p "$SOCK_DIR"
if [ ! -S "$SOCK" ]; then
# A stale socket file survives a dead daemon (e.g. after a container
# suspend), so liveness means answering a real request — not existing.
sock_alive() {
[ -S "$SOCK" ] && timeout 5 python3 -c "
import socket
s = socket.socket(socket.AF_UNIX); s.connect('$SOCK')
f = s.makefile('rw')
f.write('{\"op\":\"read_playbook\",\"class\":1}\n'); f.flush()
assert f.readline()
" 2>/dev/null
}
if ! sock_alive; then
rm -f "$SOCK"
( cd "$ROOT" && setsid ./target/debug/harnessd --socket "$SOCK" \
>>/var/log/hotpath-harnessd.log 2>&1 & )
for _ in $(seq 1 50); do [ -S "$SOCK" ] && break; sleep 0.1; done
[ -S "$SOCK" ] || { echo "harnessd socket never appeared" >&2; exit 1; }
sock_alive || { echo "harnessd did not come up on $SOCK" >&2; exit 1; }
fi
run_loop="python3 -m hotpath_agent.loop $TARGET --run-id $RUN_ID --max-turns $MAX_TURNS --repo-root $ROOT"