Skip to content

The agent that grows with you

docs+test(gateway): pin Windows witness-absent behavior and the probe-budget math

kshitijk4poor5abe2e18806b
diff --git a/gateway/shutdown_watchdog.py b/gateway/shutdown_watchdog.py
index a7dc5b1c4de..c7fb676ded5 100644
--- a/gateway/shutdown_watchdog.py
+++ b/gateway/shutdown_watchdog.py
@@ -525,6 +525,14 @@ async def loop_heartbeat_forever(
# path length) must not abort the gateway or the file heartbeat — it only
# disables the witness, and the payload flag tells probes that staleness is
# no longer sufficient authority to escalate.
+ #
+ # Windows: asyncio.start_unix_server raises (no AF_UNIX event-loop
+ # support), so the witness is PERMANENTLY absent there — the payload
+ # records loop_tick_socket=False and every stale-file probe classifies
+ # UNKNOWN, never WEDGED. That is deliberate fail-safe: a wedged native
+ # Windows gateway keeps the graceful-drain backstop instead of an
+ # escalation verdict built on a witness that cannot exist. (WSL2 — the
+ # #90502 incident environment — is Linux and arms the socket normally.)
tick_server = None
tick_socket_path = None
try:
diff --git a/tests/hermes_cli/test_update_wedged_gateway.py b/tests/hermes_cli/test_update_wedged_gateway.py
index 858ec4c828a..2e12c233dd9 100644
--- a/tests/hermes_cli/test_update_wedged_gateway.py
+++ b/tests/hermes_cli/test_update_wedged_gateway.py
@@ -927,3 +927,28 @@ class TestLoopTickWitness:
finally:
state["thread"].join(timeout=5.0)
assert not errors, errors
+
+
+def test_default_probe_budget_stays_inside_query_tier():
+ """The module doc pins the worst-case wedge-suspected probe at ~3.4s,
+ 'far inside the 10s query tier'. Assert the strike-count math so
+ retuning tick_timeout / tick_strikes / tick_gap_s can't silently blow
+ past that tier (reviewer ask on #92315).
+
+ Worst case: the first probe misses (tick_timeout), then the sustained
+ window runs (tick_strikes - 1) more probes, each up to tick_timeout,
+ with tick_gap_s sleeps between attempts.
+ """
+ import inspect
+
+ sig = inspect.signature(gateway_cli.probe_gateway_loop_liveness)
+ tick_timeout = sig.parameters["tick_timeout"].default
+ tick_strikes = sig.parameters["tick_strikes"].default
+ tick_gap_s = sig.parameters["tick_gap_s"].default
+
+ worst_case = tick_strikes * tick_timeout + (tick_strikes - 1) * tick_gap_s
+ assert worst_case <= 5.0, (
+ f"default probe budget {worst_case:.1f}s exceeds half the 10s query "
+ "tier — retune tick_timeout/tick_strikes/tick_gap_s or update the "
+ "subprocess-timeout doc reference in hermes_cli/gateway.py"
+ )