Skip to content

The agent that grows with you

fix(update): inventory-less markers settle on a fleet current at the checkout; supervised serve rows never veto gateway discharge

teknium1d6ef05e27575
diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.py
index d1838603137..a38df7074f0 100644
--- a/hermes_cli/update_cmd_fleet.py
+++ b/hermes_cli/update_cmd_fleet.py
@@ -150,10 +150,13 @@ def _receipt_reports_stale_runtime(receipt: dict, expected_sha: str | None = Non
)
+_SUPERVISED_SERVE_BACKENDS = frozenset({"manual-serve", "desktop", "systemd", "launchd", "windows-service", "service"})
+
+
def _receipt_owed_gateways(receipt: dict, pending_manual: list[dict]) -> set[tuple[str, str]] | None:
"""Pure coverage classification after manual retention of this receipt snapshot.
- Empty means this receipt owes no gateways, not that an independent marker owes none. Unknown identities and failed manual transfers make coverage unverified.
+ Empty means this receipt owes no gateways, not that an independent marker owes none. Unknown identities, unclassified serve backends and failed manual transfers make coverage unverified.
"""
plan = receipt.get("plan") or {}
entries: list[tuple[object, str | None]] = [(entry, None) for entry in plan.get("runtimes") or []]
@@ -167,7 +170,13 @@ def _receipt_owed_gateways(receipt: dict, pending_manual: list[dict]) -> set[tup
continue
kind = entry.get("kind", default_kind)
profile = entry.get("profile")
- if kind in ("serve", "dashboard") and entry.get("supervisor") == "manual-serve" and entry not in pending_manual:
+ # A serve/dashboard row is outside the gateway matrix's evidence, not evidence against the
+ # gateways it does cover: a supervised backend (desktop, systemd, launchd) is its
+ # supervisor's to restart, and a manual-serve row outside the retention list is the serve
+ # obligation mechanism's — a host running a dashboard carries such a row in every receipt,
+ # and a blanket veto made the gateway warning permanently undischargeable there (#115090).
+ # Only an unclassified backend or a failed manual transfer still makes coverage unverified.
+ if kind in ("serve", "dashboard") and entry.get("supervisor") in _SUPERVISED_SERVE_BACKENDS and entry not in pending_manual:
continue
if kind != "gateway" or not profile or profile == "unknown":
unverified = True
diff --git a/tests/hermes_cli/test_manual_serve_deferral.py b/tests/hermes_cli/test_manual_serve_deferral.py
index a58199cc4f8..b91eee2b56b 100644
--- a/tests/hermes_cli/test_manual_serve_deferral.py
+++ b/tests/hermes_cli/test_manual_serve_deferral.py
@@ -117,7 +117,7 @@ def test_stamped_manual_only_history_has_no_gateway_obligation(monkeypatch, caps
@pytest.mark.parametrize("manual_first", [True, False])
[email protected]("unsupported", [{"kind": "serve", "supervisor": "desktop"}, {"kind": "gateway", "profile": "unknown"}, None])
[email protected]("unsupported", [{"kind": "serve"}, {"kind": "gateway", "profile": "unknown"}, None])
def test_historical_retention_is_independent_of_plan_order(monkeypatch, capsys, manual_first, unsupported):
manual = asdict(RuntimeRecord(kind="serve", profile="work", pid=900, supervisor="manual-serve", restart_via="respawn-argv", detail={"create_time": 1000.0}))
rows = [manual, unsupported] if manual_first else [unsupported, manual]
diff --git a/tests/hermes_cli/test_update_obligation_identity.py b/tests/hermes_cli/test_update_obligation_identity.py
index 8349261df29..06f2a2f78cd 100644
--- a/tests/hermes_cli/test_update_obligation_identity.py
+++ b/tests/hermes_cli/test_update_obligation_identity.py
@@ -57,8 +57,9 @@ def test_every_owed_identity_requires_current_evidence(monkeypatch, bad):
directory = home / "logs" / "update_receipts"
directory.mkdir(parents=True)
if bad == "marker":
- # Obligation for an SHA the fleet does not serve: no verified discharge.
- (home / "fleet_restart_pending").write_text("expected_sha=future\n")
+ # Recorded obligation for an SHA the fleet does not serve: no verified discharge.
+ inventory = json.dumps({"version": 1, "runtimes": [{"kind": "gateway", "profile": "beta"}]})
+ (home / "fleet_restart_pending").write_text(f"expected_sha=future\ninventory={inventory}\n")
owed = {"kind": "gateway", "profile": "beta", "code_sha": "old"}
if bad == "wrong-kind":
owed["kind"] = "serve"
@@ -85,3 +86,27 @@ def test_every_owed_identity_requires_current_evidence(monkeypatch, bad):
monkeypatch.setattr(update_cmd, "_current_checkout_sha", lambda: "new")
monkeypatch.setattr(update_receipt, "collect_fleet_versions", lambda: rows)
assert update_cmd_fleet._pending_fleet_restart_needed()
+
+
[email protected]("supervisor", ["desktop", "launchd", "systemd"])
+def test_supervised_serve_row_never_vetoes_gateway_discharge(monkeypatch, supervisor):
+ """A host that also runs a supervised ``hermes dashboard``/``serve`` carries that row in every
+ receipt; it must not make gateway coverage unverifiable (#115090). The gateways restarted at
+ the pulled SHA and the fleet has since moved on to a newer checkout: nothing is owed.
+ """
+ home = get_hermes_home()
+ directory = home / "logs" / "update_receipts"
+ directory.mkdir(parents=True)
+ (directory / "latest.json").write_text(json.dumps({
+ "outcome": "failed",
+ "post_update": {"sha": "pulled"},
+ "gateway_restart": {"restarted_services": ["hermes-gateway"], "incomplete": False},
+ "plan": {"runtimes": [
+ {"kind": "gateway", "profile": "default", "code_sha": "old", "supervisor": "manual"},
+ {"kind": "dashboard", "profile": "default", "code_sha": None, "supervisor": supervisor, "restart_via": "respawn-argv"},
+ ]},
+ }))
+ monkeypatch.setattr(update_cmd, "_current_checkout_sha", lambda: "new")
+ monkeypatch.setattr(update_receipt, "collect_fleet_versions", lambda: [{"profile": "default", "state": "current", "code_sha": "new"}])
+ assert not update_cmd_fleet._update_owes_fleet_restart()
+ assert not update_cmd_fleet._pending_fleet_restart_needed()
diff --git a/tests/hermes_cli/test_update_scoped_reconciliation.py b/tests/hermes_cli/test_update_scoped_reconciliation.py
index 3ee2c12b897..87078da6507 100644
--- a/tests/hermes_cli/test_update_scoped_reconciliation.py
+++ b/tests/hermes_cli/test_update_scoped_reconciliation.py
@@ -169,9 +169,25 @@ def test_legacy_marker_discharges_on_live_fleet_evidence_without_receipt(monkeyp
assert target.read_bytes() == receipt_before
[email protected]("live,pending", [([CURRENT], False), ([dict(CURRENT, state="stale", code_sha="old")], True), ([], True)], ids=["fleet-current", "fleet-stale", "fleet-empty"])
+def test_inventory_less_marker_settles_after_out_of_band_pull(monkeypatch, capsys, live, pending):
+ """An inventory-less marker left behind by an old update survives every later out-of-band
+ ``git pull`` (#115638): nothing rewrites it, and its ``expected_sha`` is never HEAD again.
+ It records no owed set, so a fleet that is current on the checkout is the whole of the
+ evidence the warning can be about — a stale or absent fleet still keeps it.
+ """
+ seed(monkeypatch, {}, "old", live)
+ marker = fleet._fleet_restart_pending_marker_path()
+ fleet._warn_pending_fleet_restart_on_startup()
+ assert ("hermes gateway restart" in capsys.readouterr().err) is pending
+ assert fleet._pending_fleet_restart_needed() is pending
+ assert marker.exists() is pending
+
+
# Explicit `inventory=null` records no obligation either, so it settles on live-fleet
-# evidence like a missing line (#115638); the variants below stay fail-closed.
[email protected]("inventory", [{}, [], {"version": 2, "runtimes": [GATEWAY]}, {"version": 1, "runtimes": []}, {"version": 1, "runtimes": [GATEWAY, dict(MANUAL, detail={})]}, {"version": 1, "runtimes": [None]}, {"version": 1, "runtimes": [{"kind": "gateway", "profile": "unknown"}]}, {"version": 1, "runtimes": [{"kind": "gateway", "profile": []}]}])
+# evidence like a missing line (#115638), and an explicit empty inventory owes nothing
+# (#115311); the variants below stay fail-closed.
[email protected]("inventory", [{}, [], {"version": 2, "runtimes": [GATEWAY]}, {"version": 1, "runtimes": [GATEWAY, dict(MANUAL, detail={})]}, {"version": 1, "runtimes": [None]}, {"version": 1, "runtimes": [{"kind": "gateway", "profile": "unknown"}]}, {"version": 1, "runtimes": [{"kind": "gateway", "profile": []}]}])
def test_unverified_marker_inventory_stays_pending(monkeypatch, inventory):
seed(monkeypatch, {"outcome": "success", "plan": {"runtimes": [GATEWAY]}}, "new", [CURRENT])
marker = fleet._fleet_restart_pending_marker_path()