The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(serve): pin the owner-watchdog wiring through start_server and serve
kshitijk4poor05b1690ca13d
diff --git a/tests/hermes_cli/test_resource_limits.py b/tests/hermes_cli/test_resource_limits.pyindex 2b080b57c50..9236b4340b8 100644--- a/tests/hermes_cli/test_resource_limits.py+++ b/tests/hermes_cli/test_resource_limits.py@@ -227,18 +227,22 @@ def test_serve_startup_applies_limit_before_web_server(monkeypatch):monkeypatch.setattr(main_web_build, "_build_web_ui", lambda *args, **kwargs: True)monkeypatch.setattr(cli_main, "_maybe_setup_dashboard_auth_interactively", lambda args: None)monkeypatch.setattr(hermes_cli.plugins, "discover_plugins", lambda: None)+ served: dict = {}monkeypatch.setattr(hermes_cli.web_server,"start_server",- lambda **kwargs: calls.append("server"),+ lambda **kwargs: (calls.append("server"), served.update(kwargs)),)+ # Desktop SSH serve: the owner watchdog's lock sits next to the validated token (#132034).+ token_dir = Path("/home/u/.hermes/desktop-ssh") / ("f" * 32)+ monkeypatch.setattr(cli_main, "_read_ssh_session_token_file", lambda path: "s" * 64)args = SimpleNamespace(status=False,stop=False,headless_backend=True,- ssh_owner_nonce=None,- ssh_session_token_file=None,+ ssh_owner_nonce="0123456789abcdef",+ ssh_session_token_file=str(token_dir / "0123456789abcdef.token"),host="127.0.0.1",port=0,no_open=True,@@ -251,6 +255,7 @@ def test_serve_startup_applies_limit_before_web_server(monkeypatch):cli_main.cmd_dashboard(args)assert calls == ["limit", "server"]+ assert served["ssh_lock_path"] == token_dir / "backend.lock.json"@pytest.mark.platforms("linux")diff --git a/tests/hermes_cli/test_web_server_ws_ping.py b/tests/hermes_cli/test_web_server_ws_ping.pyindex b1eccde3628..9192972c67d 100644--- a/tests/hermes_cli/test_web_server_ws_ping.py+++ b/tests/hermes_cli/test_web_server_ws_ping.py@@ -71,20 +71,32 @@ def _stub_uvicorn(monkeypatch):return captured-def test_start_server_applies_process_local_ssh_bootstrap_state(monkeypatch):+def test_start_server_applies_process_local_ssh_bootstrap_state(monkeypatch, tmp_path):captured = _stub_uvicorn(monkeypatch)+ owner_watchdogs: list[dict] = []+ monkeypatch.setattr("hermes_cli.web_server_owner_exit.start_owner_watchdog",+ lambda server, **kw: owner_watchdogs.append(kw))+ lock_path = tmp_path / "backend.lock.json"++ def serve(**extra):+ web_server.start_server(+ host="127.0.0.1",+ port=0,+ open_browser=False,+ ssh_session_token="s" * 64,+ ssh_owner_nonce="0123456789abcdef",+ **extra,+ )- web_server.start_server(- host="127.0.0.1",- port=0,- open_browser=False,- ssh_session_token="s" * 64,- ssh_owner_nonce="0123456789abcdef",- )+ serve(ssh_lock_path=lock_path)assert web_server._SESSION_TOKEN == "s" * 64assert web_server._SSH_OWNER_NONCE == "0123456789abcdef"assert captured["port"] == 0+ # The Desktop's ownership lock arms supersession retirement (#132034); no lock path, no watchdog.+ assert owner_watchdogs == [{"lock_path": lock_path, "nonce": "0123456789abcdef"}]+ serve()+ assert len(owner_watchdogs) == 1def test_start_server_disables_ws_ping_on_loopback(monkeypatch):