The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(serve): idle-proof live probe waits for the verdict to settle between cron ticks
teknium1fa0aade11bae
diff --git a/tests/hermes_cli/test_web_server_idle_proof.py b/tests/hermes_cli/test_web_server_idle_proof.pyindex 30c6aa1e21f..92acdc5c1ad 100644--- a/tests/hermes_cli/test_web_server_idle_proof.py+++ b/tests/hermes_cli/test_web_server_idle_proof.py@@ -12,6 +12,7 @@ import socketimport subprocessimport sysimport threading+import timeimport urllib.errorimport urllib.requestimport json@@ -158,6 +159,20 @@ def _read_until(proc: subprocess.Popen, token: str, timeout: float = 120.0):return hit.is_set(), lines+def _probe_settled(port: int, settled, timeout: float = 20.0) -> tuple[int, dict]:+ """The probe is stable BETWEEN ticks, not at every instant: the in-process cron ticker holds+ retirement admission for its whole scan (#98745), so a single sample can say+ ``retirement_admission`` for an idle resident, or name the admission instead of the cron ledger+ for a busy child. Poll until *settled(body)* or the window closes; the last verdict is returned+ either way, so a genuinely wrong state still fails the assertion."""+ deadline = time.monotonic() + timeout+ while True:+ verdict = _probe(port)+ if settled(verdict[1]) or time.monotonic() >= deadline:+ return verdict+ time.sleep(0.25)++def _probe(port: int, token: str | None = TOKEN) -> tuple[int, dict]:req = urllib.request.Request(f"http://127.0.0.1:{port}/api/health/idle",headers={"X-Hermes-Session-Token": token} if token else {})@@ -186,7 +201,9 @@ def test_live_pooled_children_prove_idle_or_busy_over_the_desktop_probe(tmp_pathready_line = next(l for l in lines if "HERMES_BACKEND_READY" in l)ports[name] = int(ready_line.strip().rsplit("port=", 1)[1])- verdicts = {name: _probe(port) for name, port in ports.items()}+ verdicts = {name: _probe_settled(port, lambda b: b.get("idle") is True)+ for name, port in ports.items() if name != "cron-busy"}+ verdicts["cron-busy"] = _probe_settled(ports["cron-busy"], lambda b: str(b.get("detail", "")).startswith("cron:"))assert verdicts["resident-a"] == (200, {"ok": True, "idle": True, "reason": None}), verdictsassert verdicts["resident-b"] == (200, {"ok": True, "idle": True, "reason": None}), verdictsassert verdicts["cron-busy"] == (200, {