The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): refuse an unserve ack that carries an error before the restore
kshitijk4poor1c4b47a02049
diff --git a/hermes_cli/cli_snapshot.py b/hermes_cli/cli_snapshot.pyindex 3e069fc8643..72102c7078c 100644--- a/hermes_cli/cli_snapshot.py+++ b/hermes_cli/cli_snapshot.py@@ -58,9 +58,11 @@ def restore_snapshot_command(cli, parts):def _pause_owner(home, control_home, identity):from gateway.control_socket import pause_gateway_for_update, request_unserve_profile+ from hermes_cli.gateway_profile_lifecycle import _confirmedif control_home != home:ack = request_unserve_profile(control_home, home.name)- accepted = ack is not None and (ack.get("unserved") == home.name or ack.get("pending"))+ accepted = _confirmed(ack, "unserved", home.name) or (+ isinstance(ack, dict) and ack.get("pending") and not ack.get("error"))else:ack = pause_gateway_for_update(control_home, timeout=8)accepted = (ack is not None and (ack.get("pausing") or ack.get("already_stopping"))diff --git a/tests/hermes_cli/test_gateway_snapshot_restore_guards.py b/tests/hermes_cli/test_gateway_snapshot_restore_guards.pyindex 0770c7f4a65..093753e3d15 100644--- a/tests/hermes_cli/test_gateway_snapshot_restore_guards.py+++ b/tests/hermes_cli/test_gateway_snapshot_restore_guards.py@@ -37,6 +37,7 @@ def _restore_error(sid):("satellite-not-reserved", lambda sid: True, "manual", "is not served again yet: host operation is still pending"),("invalid-id", lambda sid: False, "manual", "Snapshot not found: ../outside"),("other-pid-paused", None, "manual", "Gateway refused the snapshot maintenance handoff"),+ ("satellite-unserve-error", None, "manual", "Gateway refused the snapshot maintenance handoff"),])def test_restore_reply_follows_the_restore_not_the_rejoin(tmp_path, monkeypatch, capsys,case, restore, supervisor, expected):@@ -50,7 +51,7 @@ def test_restore_reply_follows_the_restore_not_the_rejoin(tmp_path, monkeypatch,store = GatewaySessionStore(old)cli = SimpleNamespace(_session_db=store, _gateway_session_open=True, session_id="kept",agent=object(), conversation_history=[])- satellite = case == "satellite-not-reserved"+ satellite = case.startswith("satellite-")control_home = str(tmp_path) if satellite else str(home)endpoint = GatewayEndpoint(str(home), "owner", 5, 1, "http://127.0.0.1:1", "none",frozenset({"session-authority-v1"}), control_home)@@ -64,7 +65,8 @@ def test_restore_reply_follows_the_restore_not_the_rejoin(tmp_path, monkeypatch,lambda *a, **kw: paused.append(a) or {"pausing": True,"pid": 99 if case == "other-pid-paused" else 4321})monkeypatch.setattr("gateway.control_socket.request_unserve_profile",- lambda *a: {"unserved": home.name})+ lambda *a: {"unserved": home.name, "error": "teardown failed"}+ if case == "satellite-unserve-error" else {"unserved": home.name})monkeypatch.setattr("gateway.control_socket.request_serve_profile_hot", lambda *a: {"pending": True})monkeypatch.setattr("hermes_cli.profiles_remove.wait_profile_unowned", lambda home: True)monkeypatch.setattr("hermes_cli.backup.restore_quick_snapshot",