acpmux: wait for live daemon peers

Merged
TE
2d ago
+291-264

Summary

Local acpmux CLI calls now wait while the daemon peer is alive and fail promptly when the peer is gone. Default acpmux send/new prompt collection waits for the live peer; explicit --stall and --timeout remain caller choices. Daemon handover, lock, socket and startup paths use peer liveness, with only cleanup and a documented hung-child readiness fallback bounded.

Leo's words (2026-11-04): “shouldn't be this short. no reason for this. i imagine there's other nonsensical gates like this to remove in the broader app/acpmux”.

Gates audited

LocationOld gateWhat it guardedVerdict
cmux-tui/crates/acpmux/src/cli/command.rs:249--stall default 30sdefault prompt collectionRemoved default wall-clock failure; live peer waits; explicit flag preserved
cmux-tui/crates/acpmux/src/cli/command_new.rs:71--stall default 30snew-session prompt collectionRemoved default wall-clock failure; explicit flag preserved
cmux-tui/crates/acpmux/src/daemon.rs:1255lock handover 60sdaemon takeoverRemoved; kernel lock release is liveness
cmux-tui/crates/acpmux/src/daemon.rs:1270,1275,1294connect/status/shutdown 5s/5s/10stakeover peer callsRemoved; closed sockets fail through transport, live peers may answer later
cmux-tui/crates/acpmux/src/daemon.rs:1393,1621handover 20sstart/stop handoverRemoved; lock/socket liveness controls retry
cmux-tui/crates/acpmux/src/daemon/running.rs:42HANDOVER_BUDGETacpmux lsRemoved; live lock holder is retried and a released lock fails promptly
cmux-tui/crates/acpmux/src/daemon/handover.rs:19HANDOVER_BUDGETready-fd start raceRemoved; retries until lock ownership or live winner answers
cmux-tui/crates/acpmux/src/daemon.rs:1432,1452systemd probe 1sservice probingProbe timeout falls through to the real launch path
cmux-tui/crates/acpmux/src/daemon.rs:1321detached readiness 8schild that never reaches readinessKept as a real hung-child hazard bound, documented beside the constant
cmux-tui/crates/acpmux/src/daemon.rs:1797, daemon/windows.rs:276no winner bound after losing starthung lock winnerRestored START_BUDGET; process/lock liveness still controls ordinary handover
cmux-tui/crates/acpmux/src/daemon/snapshot_clear.rs:12connect could hang foreveraccepted socket that never initializesKept 2s initialization grace so lock-protected offline cleanup can decide safely
cmux-tui/crates/acpmux/src/daemon.rs:1325shutdown exit gracecleanup after stop/deathKept; cleanup bound, not a live-peer answer deadline

Regression coverage

  • daemon::running::tests::a_slow_but_alive_daemon_is_not_cut_off_by_the_old_budget waits through 120 failed probes before success.
  • daemon::running::tests::a_closed_socket_fails_fast_even_when_the_connect_future_is_slow covers closed/refused peer failure.
  • daemon::running::tests::no_daemon_is_an_error_at_once_and_nothing_is_started covers no live peer.
  • Fleet green at the final exact head: fast-checks run 41829007548, tested 6c626322732c64e03f9e5502b4ef577efaec387d; 5 passed.
  • Earlier fleet red runs exposed and were fixed: 41815398549 (duplicate lock helper/readiness type), 41828393439 (readiness error conversion).

Changelog

Fixed: local acpmux CLI and daemon handover calls wait for live peers instead of failing on arbitrary default wall-clock limits.

🤖 Generated with Codex

Agent session: agent session