The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): trim s6 status salvage and fold its tests into test_gateway.py (#125390, salvage #125397)
teknium11b1b93a65cbf
diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.pyindex fe45320439b..2079f9bc45b 100644--- a/hermes_cli/gateway.py+++ b/hermes_cli/gateway.py@@ -5638,10 +5638,8 @@ def _cmd_status(args):print()_print_lines(*_STATUS_RUNNING_HINTS[_status_host_kind()])elif snapshot.service_running:- # Supervised-but-unscannable gateway (s6 container): the service is up, yet the- # process-table scan finds no PID — the `python -c` launcher argv is deliberately- # unmatched (#123881) and containers carry no gateway.pid file. Trust the service- # state instead of reporting a false outage (#125390).+ # s6 container: the service is up but the scan finds no PID (the `python -c` launcher+ # argv is deliberately unmatched, #123881, and there is no gateway.pid) — #125390.print(f"✓ Gateway is running (supervised by {snapshot.manager})")_print_runtime_health()_print_multiplex_standalone_reason()diff --git a/tests/hermes_cli/test_gateway.py b/tests/hermes_cli/test_gateway.pyindex b1c84b1463d..9075b874adc 100644--- a/tests/hermes_cli/test_gateway.py+++ b/tests/hermes_cli/test_gateway.py@@ -252,6 +252,40 @@ def test_s6_runtime_snapshot_reports_supervised_service(monkeypatch, tmp_path):assert snapshot.gateway_pids == (123,)+def _run_status_with_snapshot(monkeypatch, snapshot) -> str:+ """``_cmd_status`` for a host with no installed systemd/launchd/Windows service."""+ import io+ from contextlib import redirect_stdout++ monkeypatch.setattr("hermes_cli.gateway_profile_lifecycle.print_parked_status", lambda: False)+ monkeypatch.setattr(gateway, "get_gateway_runtime_snapshot", lambda system=False: snapshot)+ monkeypatch.setattr(gateway, "_installed_service_kind_for", lambda probe: None)+ monkeypatch.setattr(gateway, "named_profile_served_by_running_multiplexer", lambda: False)+ for name in ("_print_runtime_health", "_print_multiplex_standalone_reason", "_print_served_ingress_urls",+ "_print_duplicate_credential_warnings", "_print_other_profiles_gateway_status",+ "_print_standalone_by_config"):+ monkeypatch.setattr(gateway, name, lambda *a, **k: None)+ buf = io.StringIO()+ with redirect_stdout(buf):+ gateway._cmd_status(SimpleNamespace(deep=False, full=False, system=False))+ return buf.getvalue()+++def test_s6_supervised_gateway_without_scannable_pid_reports_running(monkeypatch):+ """#125390: s6 service up, process scan empty (`python -c` launcher argv is unmatched per+ #123881 and containers have no gateway.pid) — the default profile must not report an outage."""+ snapshot = gateway.GatewayRuntimeSnapshot(+ manager="s6 (container supervisor)", service_installed=True, service_running=True, gateway_pids=())+ out = _run_status_with_snapshot(monkeypatch, snapshot)+ assert out.startswith("✓ Gateway is running (supervised by s6 (container supervisor))")+ assert "not running" not in out+++def test_manual_gateway_without_pids_still_reports_stopped(monkeypatch):+ out = _run_status_with_snapshot(monkeypatch, gateway.GatewayRuntimeSnapshot(manager="manual process"))+ assert out.startswith("✗ Gateway is not running")++diff --git a/tests/hermes_cli/test_gateway_status_s6.py b/tests/hermes_cli/test_gateway_status_s6.pydeleted file mode 100644index c3f8c143a4b..00000000000--- a/tests/hermes_cli/test_gateway_status_s6.py+++ /dev/null@@ -1,62 +0,0 @@-"""#125390: a default-profile gateway supervised by s6 (container) reports as running.--``_cmd_status``'s final ``else`` branch decided liveness from ``snapshot.gateway_pids``-alone. In the s6-overlay container the gateway runs as a ``python -c`` wrapper argv the-process scan deliberately refuses to match (#123881) and there is no ``gateway.pid``-file, so a healthy ``gateway-default`` service printed a false-"✗ Gateway is not running". The branch now honors ``snapshot.service_running``.-"""--from __future__ import annotations--import io-from contextlib import redirect_stdout-from types import SimpleNamespace---def _run_status(monkeypatch, snapshot) -> str:- import hermes_cli.gateway_profile_lifecycle as lifecycle-- monkeypatch.setattr(lifecycle, "print_parked_status", lambda: False)- from hermes_cli import gateway as gw- monkeypatch.setattr(gw, "get_gateway_runtime_snapshot", lambda system=False: snapshot)- monkeypatch.setattr(gw, "_installed_service_kind_for", lambda probe: None)- monkeypatch.setattr(gw, "named_profile_served_by_running_multiplexer", lambda: False)- for name in (- "_print_runtime_health",- "_print_multiplex_standalone_reason",- "_print_served_ingress_urls",- "_print_duplicate_credential_warnings",- "_print_other_profiles_gateway_status",- "_print_standalone_by_config",- ):- monkeypatch.setattr(gw, name, lambda *a, **k: None)-- buf = io.StringIO()- with redirect_stdout(buf):- gw._cmd_status(SimpleNamespace(deep=False, full=False, system=False))- return buf.getvalue()---def test_s6_supervised_gateway_without_scannable_pid_reports_running(monkeypatch):- """Service up, process scan empty (s6 container): must not report a false outage."""- from hermes_cli.gateway import GatewayRuntimeSnapshot-- snapshot = GatewayRuntimeSnapshot(- manager="s6 (container supervisor)",- service_installed=True,- service_running=True,- gateway_pids=(), # `python -c` launcher argv unmatched (#123881), no gateway.pid- )- out = _run_status(monkeypatch, snapshot)- assert out.startswith("✓ Gateway is running (supervised by s6 (container supervisor))")- assert "not running" not in out---def test_manual_gateway_without_pids_still_reports_stopped(monkeypatch):- """No service, no PIDs (plain manual host): the stopped message and hints stay."""- from hermes_cli.gateway import GatewayRuntimeSnapshot-- snapshot = GatewayRuntimeSnapshot(manager="manual process")- out = _run_status(monkeypatch, snapshot)- assert out.startswith("✗ Gateway is not running")