Skip to content

The agent that grows with you

fix: preserve loop liveness witnesses for long gateway homes

Tekniumae92d198b7cc
diff --git a/gateway/shutdown_watchdog.py b/gateway/shutdown_watchdog.py
index 528c8e8a01e..21b883e1f21 100644
--- a/gateway/shutdown_watchdog.py
+++ b/gateway/shutdown_watchdog.py
@@ -333,14 +333,15 @@ async def loop_heartbeat_forever(
loop-scheduling witness (``_tick_socket_handler``, flagged as ``loop_tick_socket``); probes must
require the witness to agree before classifying WEDGED."""
interval = _coerce_float(interval_s, DEFAULT_HEARTBEAT_INTERVAL_S, floor=1.0)
- # Arm the witness, best-effort: a failed bind only disables it and the payload flag makes
- # probes classify UNKNOWN, never WEDGED (drain backstop stays). asyncio AF_UNIX is POSIX-only
- # (ungated it raised AttributeError on native Windows), so non-POSIX binds TCP loopback and
- # publishes ``loop_tick_tcp_port``.
+ # The witness exposes only a scheduling ping, not control/auth operations. Reuse its
+ # loopback transport when AF_UNIX is unavailable or the encoded address will not fit;
+ # consumers already discover this port in the heartbeat, independent of their TMPDIR.
+ from gateway.control_socket import _fits_sun_path
+ unix_path = get_loop_tick_socket_path(home) if os.name == "posix" else None
tick_server = tick_socket_path = tick_tcp_port = None
try:
- if os.name == "posix":
- tick_socket_path = get_loop_tick_socket_path(home)
+ if unix_path is not None and _fits_sun_path(unix_path):
+ tick_socket_path = unix_path
tick_socket_path.parent.mkdir(parents=True, exist_ok=True)
_sweep_stale_tick_sockets(tick_socket_path)
tick_server = await asyncio.start_unix_server(_tick_socket_handler,