fix(approval): clamp approvals.timeout at the config-read chokepoint (#83220)
Widen the salvaged gate-site clamp to the bug class. The gate min() from the contributor PR capped the gate bound at 360s, which would break the #79719 contract (gate must extend while a legitimate >360s approval prompt is answerable) and left the sibling overflow sites live: the CLI prompt thread.join, the gateway poll deadline, and human_wait_ceiling all consume the same config value. Clamp once in _get_approval_timeout() via agent.deadline.MAX_SAFE_TIMEOUT_S (1 year - semantically unbounded, platform-safe). The gate keeps its approvals.timeout-tracking behavior above 360s; 7 regression tests pin lock-acquire/thread-join safety and the gate-extension contract. Bilateral E2E: with approvals.timeout=1e20 in a real config.yaml, main crashes every consumer with OverflowError; this branch survives all 5 probes.
This commit is contained in:
@@ -154,12 +154,13 @@ def _authorization_gate_lock_timeout() -> float:
|
||||
try:
|
||||
from tools.approval import human_wait_ceiling
|
||||
|
||||
# Clamp to _AUTHORIZATION_GATE_LOCK_TIMEOUT_S: the gate serializes
|
||||
# parallel dispatch — it should never wait longer than a wedged-holder
|
||||
# timeout even when approvals.timeout is set very large (or infinite).
|
||||
# On macOS, unbounded values overflow threading.Lock.acquire's timespec
|
||||
# and raise OverflowError (#83220).
|
||||
return min(human_wait_ceiling(), _AUTHORIZATION_GATE_LOCK_TIMEOUT_S)
|
||||
# human_wait_ceiling is platform-safety-capped (agent/deadline.py
|
||||
# MAX_SAFE_TIMEOUT_S): a huge approvals.timeout can no longer overflow
|
||||
# Lock.acquire's time_t on macOS (#83220). Deliberately NOT min()'d
|
||||
# with _AUTHORIZATION_GATE_LOCK_TIMEOUT_S — the gate must never give
|
||||
# up while a legitimate approval prompt is still answerable (#79719),
|
||||
# so a configured approvals.timeout above 360s must extend the gate.
|
||||
return human_wait_ceiling()
|
||||
except Exception:
|
||||
return _AUTHORIZATION_GATE_LOCK_TIMEOUT_S
|
||||
|
||||
|
||||
Reference in New Issue
Block a user