The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): `restart --all` owes the same "Gateway online" notice
Leegenuxbc8e9107b600
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex cbd3e49f799..a70ec4126bf 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -5388,7 +5388,7 @@ def _stop_host_multiplexer(owner) -> int:def _restart_all(system: bool, detach: bool = False) -> None:- from hermes_cli.gateway_profile_lifecycle import host_scope_for_all_verb+ from hermes_cli.gateway_profile_lifecycle import restart_all_verb_scopeowner = _host_multiplexer_for_all_verb()if owner is not None and not _host_multiplexer_is_ours(owner):# `--all` means "restart the ONE host multiplexer" — and this profile does not own it.@@ -5402,7 +5402,7 @@ def _restart_all(system: bool, detach: bool = False) -> None:sys.exit(GATEWAY_FATAL_CONFIG_EXIT_CODE)# No live owner: stop/kill/start as the host root, not as the invoking profile (whose own# gateway the run-side guard would refuse — the host stayed down after a Desktop update).- with host_scope_for_all_verb(owner):+ with restart_all_verb_scope(owner):_restart_all_as_host(owner, system, detach)diff --git a/hermes_cli/gateway_profile_lifecycle.py b/hermes_cli/gateway_profile_lifecycle.pyindex 140f4332d0a..d4405ddb158 100644--- a/hermes_cli/gateway_profile_lifecycle.py+++ b/hermes_cli/gateway_profile_lifecycle.py@@ -2,6 +2,7 @@from __future__ import annotationsimport logging+from contextlib import contextmanagerfrom hermes_constants import get_hermes_home, get_default_hermes_rootfrom hermes_cli.profiles import parked_marker_path, profile_is_parked, profile_is_standalone, profiles_to_serve@@ -44,6 +45,20 @@ def host_scope_for_all_verb(owner):return _home_env(owner.home if owner is not None else get_default_hermes_root())+@contextmanager+def restart_all_verb_scope(owner):+ """``host_scope_for_all_verb`` plus the owed online notice: ``restart --all`` restarts the host.++ The verb stops the host with a service call or a SIGTERM, so the old process never runs the+ in-band restart path that stamps the planned-restart marker; without it the next boot reads a+ plain stop and every home channel stays silent — #142515's gap, on every OS.+ """+ from gateway.restart_notice import write_planned_restart_marker+ with host_scope_for_all_verb(owner):+ write_planned_restart_marker()+ yield++def profile_lifecycle(command: str, args) -> bool:"""True when a named-profile command was handled (including an unconfirmed request)."""from hermes_cli import gateway as gwdiff --git a/tests/hermes_cli/test_gateway_restart_all_marker.py b/tests/hermes_cli/test_gateway_restart_all_marker.pynew file mode 100644index 00000000000..586653ee2b3--- /dev/null+++ b/tests/hermes_cli/test_gateway_restart_all_marker.py@@ -0,0 +1,51 @@+"""``gateway restart --all`` owes the same "Gateway online" notice as ``gateway restart``.++The verb stops the host multiplexer through a service call or a SIGTERM, then starts it again, so+the old process never runs the in-band restart path that stamps ``.restart_pending.json``. Without a+marker the next boot reads a plain stop and every home channel stays silent — the same gap #142515+describes for the Windows CLI restart, on every OS.+"""++from __future__ import annotations++from types import SimpleNamespace++import pytest++from gateway import run as gateway_run+++def hermes_home(tmp_path, monkeypatch):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ monkeypatch.setattr(gateway_run, "_hermes_home", tmp_path)+ return tmp_path+++def test_restart_all_stamps_the_marker_before_the_host_is_stopped(hermes_home, monkeypatch):+ from hermes_cli import gateway as gw++ marker = hermes_home / ".restart_pending.json"+ seen: dict[str, bool] = {}+ monkeypatch.setattr(+ gw, "_stop_installed_service", lambda system: seen.setdefault("marker_at_stop", marker.exists()) or False+ )+ monkeypatch.setattr(gw, "_stop_host_multiplexer", lambda owner: 1)+ monkeypatch.setattr(gw, "_print_unfolded_gateway_note", lambda owner: None)+ monkeypatch.setattr(gw, "_wait_for_gateway_exit", lambda **kw: None)+ monkeypatch.setattr(gw, "_wait_for_api_server_port_free", lambda: None)+ monkeypatch.setattr(gw, "_discard_dead_host_record", lambda: None)+ monkeypatch.setattr(gw, "_forget_host_gateway_probe", lambda: None)+ monkeypatch.setattr(gw, "_installed_service_kind_for", lambda windows: "systemd")+ monkeypatch.setattr(gw, "_service_call", lambda kind, verb, system: None)+ monkeypatch.setattr(gw, "is_windows", False)++ owner = SimpleNamespace(pid=4242, profiles=["default"], home=hermes_home, describe=lambda: "host")+ monkeypatch.setattr(gw, "_host_multiplexer_for_all_verb", lambda: owner)+ monkeypatch.setattr(gw, "_host_multiplexer_is_ours", lambda o: True)++ # The verb itself, exactly as the CLI dispatches it.+ gw._restart_all(system=False)++ assert seen["marker_at_stop"] is True, "the host must be stopped with the notice already owed"+ assert marker.exists(), "the restarted host's boot pass reads this marker"