Skip to content

The agent that grows with you

fix(updater): require evidence before deferring desktop serve

KoNit-K81bee00ba5b2
diff --git a/hermes_cli/update_inventory.py b/hermes_cli/update_inventory.py
index 17270cf2541..42a53be703c 100644
--- a/hermes_cli/update_inventory.py
+++ b/hermes_cli/update_inventory.py
@@ -324,10 +324,11 @@ def match_runtime_outcomes(
Serve/dashboard runtimes are reconciled in their OWN vocabulary and never borrow the gateway's
outcome: with ``stale_serve_pids`` a pre-update serve whose incarnation is gone counts as
``restarted``, one still alive is ``unaccounted``; without the probe an untouched serve stays
- ``unaccounted``. A Desktop-supervised serve still alive is ``deferred`` instead: the restart phase
- is forbidden to restart it out from under the app (it hosts the live Desktop chats), so it is
- handed back to its supervisor and surfaced — never counted as a missed restart the updater could
- have discharged. See #111494.
+ ``unaccounted``. A Desktop-supervised serve is ``deferred`` only when that probe confirmed its
+ pre-update incarnation is still alive: the restart phase is forbidden to restart it out from under
+ the app (it hosts the live Desktop chats), so it is handed back to its supervisor and surfaced.
+ Without that evidence it remains ``unaccounted``, rather than claiming the app owns an unknown
+ incarnation. See #111494.
See #91277.
They never borrow the gateway's outcome: ``relaunched_profiles`` and ``hermes-gateway*`` name a
@@ -353,9 +354,11 @@ def match_runtime_outcomes(
# dashboard cleanup respawn / the Desktop app).
return "restarted"
if r.supervisor == "desktop":
- # Still alive on pre-update code, but the Desktop app owns it and the restart phase
- # must not kill it (_DESKTOP_SERVE_SKIP_REASON); only the app can pick up the new code.
- return "deferred"
+ if stale_serves is not None:
+ # Still alive on pre-update code, but the Desktop app owns it and the restart phase
+ # must not kill it (_DESKTOP_SERVE_SKIP_REASON); only the app can pick up the new code.
+ return "deferred"
+ return "unaccounted"
if stale_serves is not None:
return "unaccounted"
return "restarted" if any(_serve_unit_matches_profile(r.profile, s) for s in restarted_set) else "unaccounted"
diff --git a/tests/hermes_cli/test_restart_plan_reconciliation.py b/tests/hermes_cli/test_restart_plan_reconciliation.py
index 4066d57c575..12f3d180e7e 100644
--- a/tests/hermes_cli/test_restart_plan_reconciliation.py
+++ b/tests/hermes_cli/test_restart_plan_reconciliation.py
@@ -295,6 +295,34 @@ def test_serve_outcome_follows_incarnation_probe_when_provided():
assert by_pid == {900: "unaccounted", 901: "stopped"}
+def test_desktop_serve_deferral_requires_a_verified_alive_incarnation():
+ """Desktop may defer only a serve the survivor probe confirmed alive."""
+ desktop_serve = _serve("default", 900)
+ desktop_serve.supervisor = "desktop"
+ desktop_serve.restart_via = _restart_mechanism("desktop", "default")
+
+ unknown = match_runtime_outcomes(
+ _plan(desktop_serve), restarted_services=["hermes-serve.service"],
+ relaunched_profiles=[], externally_supervised_profiles=[], killed_pids=set(),
+ failed_units=[], stale_serve_pids=None,
+ )
+ assert unknown[0]["outcome"] == "unaccounted"
+
+ alive = match_runtime_outcomes(
+ _plan(desktop_serve), restarted_services=[], relaunched_profiles=[],
+ externally_supervised_profiles=[], killed_pids=set(), failed_units=[],
+ stale_serve_pids={900},
+ )
+ assert alive[0]["outcome"] == "deferred"
+
+ gone = match_runtime_outcomes(
+ _plan(desktop_serve), restarted_services=[], relaunched_profiles=[],
+ externally_supervised_profiles=[], killed_pids=set(), failed_units=[],
+ stale_serve_pids=set(),
+ )
+ assert gone[0]["outcome"] == "restarted"
+
+
def test_unaccounted_serve_report_names_serve_remedy_not_gateway_restart(capsys):
outcomes = match_runtime_outcomes(
_plan(_serve("default", 900)),