The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): an unmapped stopped gateway's restart debt needs its own successor (C13)
Teknium72260bd05897
diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.pyindex 3d5cd4d1dc8..5ca7fd6768d 100644--- a/hermes_cli/update_cmd_fleet.py+++ b/hermes_cli/update_cmd_fleet.py@@ -457,8 +457,11 @@ def _marker_only_restart_obsolete() -> bool:return False # stale / down / unknown-identity row still owes the restartif owed is not None and not owed - {_UNMAPPED_GATEWAY} <= covered:return False # A gateway this marker owns is absent (down) or unidentifiable.- if owed and _UNMAPPED_GATEWAY in owed and all(row_is_external(row) for row in fleet):- return False # another checkout's gateway is no successor for the one the update stopped+ if owed and _UNMAPPED_GATEWAY in owed and not (_fleet_covered_gateways(+ [row for row in fleet if not row_is_external(row)]) or set()) - owed:+ # An unmapped stopped gateway has no identity to match, so only a local gateway that no+ # mapped owed one explains can be its successor; another checkout's gateway never is.+ return False_clear_fleet_restart_pending_marker()logger.debug("Fleet-restart-pending marker discharged: %d gateway(s) already serve %s",diff --git a/tests/hermes_cli/test_update_fleet_check_fail_closed.py b/tests/hermes_cli/test_update_fleet_check_fail_closed.pyindex 8b10342837f..c6de5605ef1 100644--- a/tests/hermes_cli/test_update_fleet_check_fail_closed.py+++ b/tests/hermes_cli/test_update_fleet_check_fail_closed.py@@ -173,3 +173,26 @@ def test_unmapped_stop_debt_survives_startup_until_a_current_gateway_runs(monkeyfleet_rows.append({"profile": "default", "state": "current", "code_sha": "head"}) # `hermes gateway run`assert fleet._update_owes_fleet_restart(receipt={}, pending_manual=[]) is Falseassert not fleet._fleet_restart_obligation_armed()+++def test_unmapped_stop_debt_is_not_settled_by_the_mapped_gateways_restart(monkeypatch, tmp_path):+ # The inventory owes `default` AND an unmapped gateway: `default` coming back current is the+ # successor of `default`, not of the unmapped one, so the debt stays until a further local+ # gateway (the unmapped one's successor, whatever profile it names) runs the checkout.+ from hermes_cli import update_cmd_fleet as fleet, update_host_obligation as host, update_receipt++ monkeypatch.setattr(host, "host_obligation_path", lambda: tmp_path / "host-update-restart.json")+ monkeypatch.setattr(fleet, "_current_checkout_sha", lambda: "head")+ fleet._write_fleet_restart_pending_marker(expected_sha="head", runtimes=[+ {"kind": "gateway", "profile": "default", "pid": 7},+ {"kind": "gateway", "profile": None, "pid": 101, "stopped_unmapped": True},+ ])+ fleet_rows = [{"profile": "default", "state": "current", "code_sha": "head", "pid": 8}]+ monkeypatch.setattr(update_receipt, "collect_fleet_versions", lambda **kw: list(fleet_rows))++ assert fleet._update_owes_fleet_restart(receipt={}, pending_manual=[]) is True+ assert fleet._fleet_restart_obligation_armed()++ fleet_rows.append({"profile": "work", "state": "current", "code_sha": "head", "pid": 9})+ assert fleet._update_owes_fleet_restart(receipt={}, pending_manual=[]) is False+ assert not fleet._fleet_restart_obligation_armed()