Files
hermes-agent/hermes_cli
Kyzcreig aa0289f307 fix(gateway): cap signal-driven stop drain to launchd's live ExitTimeOut
launchd's per-user (gui) domain clamps ExitTimeOut at 60s regardless of the
plist value (measured on macOS 26.6.1: 215->60, 90->60, 60->60, 30->30). A
gateway configured with restart_drain_timeout above that drains past the
budget and is SIGKILLed mid-teardown (adapters still connected, SQLite
checkpoint/close never runs). That unclean exit is one half of the
recurring state.db "structural corruption" class.

- gateway/restart.py: parse_launchd_exit_timeout / read_launchd_exit_timeout_s
  (launchctl print gui/<uid>/<label>, bounded, fail-open None when not
  launchd-owned or launchctl fails), resolve_launchd_capped_drain
  (min(drain, exit_timeout - 10s cleanup reserve); never extends a drain),
  effective_stop_drain_timeout (duck-typed for shutdown-path test doubles).
- gateway/run.py: read the live budget once at boot and WARN when the
  configured drain exceeds it; the SIGTERM/SIGINT handler marks the stop as
  signal-driven.
- gateway/run_shutdown.py: _stop_impl caps the drain, the watchdog leash and
  the cron drain ceiling to the launchd budget for those stops only. In-band
  SIGUSR1 restarts and --replace takeovers are not launchd-timed and keep the
  configured drain. systemd/s6/foreground: unchanged (no budget -> no cap).
- hermes_cli/gateway.py: plist template ExitTimeOut 25 -> 60 so LaunchAgents
  ask for the full clamp instead of a quarter of it.
2026-09-20 18:49:23 +05:30
..
…
…
…
…
…
…
…
…
…
…
…
…