Skip to content

The agent that grows with you

test(desktop): pin the boot orphan reap's startup grace (#122533)

Halldrix5dd34697baef
diff --git a/tests/hermes_cli/test_dashboard_admin_endpoints.py b/tests/hermes_cli/test_dashboard_admin_endpoints.py
index d5177709cb9..1c81c8601cf 100644
--- a/tests/hermes_cli/test_dashboard_admin_endpoints.py
+++ b/tests/hermes_cli/test_dashboard_admin_endpoints.py
@@ -1146,3 +1146,33 @@ def test_desktop_lifespan_terminates_managed_gateway_restart(monkeypatch):
pass
assert calls == ["terminate"]
+
+
+def test_desktop_lifespan_reaps_orphans_with_a_startup_grace(monkeypatch):
+ """The boot sweep must pass the startup grace, not reap a just-launching gateway (#122533).
+
+ Asserting only "the reaper ran" would not catch a revert to the bare
+ ``_reap_unsupervised_gateway_orphans()`` call, which is exactly the regression.
+ """
+ import hermes_cli.web_server as ws
+ from hermes_cli.dashboard_procs import _REAP_MIN_AGE_SECONDS
+
+ seen = {}
+
+ def _fake_reap(extra_exclude=None, *, min_age_s=0.0):
+ seen["extra_exclude"] = extra_exclude
+ seen["min_age_s"] = min_age_s
+ return False
+
+ monkeypatch.setenv("HERMES_DESKTOP", "1")
+ monkeypatch.setenv("HERMES_DASHBOARD_SESSION_TOKEN", "desktop-spawn-token")
+ monkeypatch.setattr(ws, "_warm_gateway_module", lambda: None)
+ monkeypatch.setattr(ws, "_start_desktop_cron_ticker", lambda *_args: None)
+ monkeypatch.setattr("hermes_cli.gateway._reap_unsupervised_gateway_orphans", _fake_reap)
+
+ client, _header = _client()
+ with client:
+ pass
+
+ assert seen["min_age_s"] == _REAP_MIN_AGE_SECONDS
+ assert _REAP_MIN_AGE_SECONDS > 0