The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: re-pin refusal exit codes and gate patch points to the shared contract
Teknium847af7301a71
diff --git a/tests/hermes_cli/test_cmd_update_apt.py b/tests/hermes_cli/test_cmd_update_apt.pyindex fa4ba8a0d6d..d9e8a3ea588 100644--- a/tests/hermes_cli/test_cmd_update_apt.py+++ b/tests/hermes_cli/test_cmd_update_apt.py@@ -27,7 +27,8 @@ def test_cmd_update_apt_prints_pkg_guidance_without_git(with pytest.raises(SystemExit) as excinfo:cmd_update(SimpleNamespace(check=False))- assert excinfo.value.code == 1+ # exit 2 = refused-by-contract (#91277 Phase 3), distinct from exit-1 errors+ assert excinfo.value.code == 2assert "pkg upgrade hermes-agent" in capsys.readouterr().outassert mock_run.call_args_list == []@@ -40,6 +41,7 @@ def test_cmd_update_check_apt_prints_pkg_guidance_without_git(with pytest.raises(SystemExit) as excinfo:_cmd_update_check()- assert excinfo.value.code == 1+ # exit 2 = refused-by-contract (#91277 Phase 3)+ assert excinfo.value.code == 2assert "pkg upgrade hermes-agent" in capsys.readouterr().outassert mock_run.call_args_list == []diff --git a/tests/hermes_cli/test_cmd_update_docker.py b/tests/hermes_cli/test_cmd_update_docker.pyindex 9fd45045643..a4c52ab2c53 100644--- a/tests/hermes_cli/test_cmd_update_docker.py+++ b/tests/hermes_cli/test_cmd_update_docker.py@@ -33,11 +33,14 @@ from hermes_cli.main import _cmd_update_check, cmd_updatedef test_cmd_update_in_docker_prints_guidance_and_exits(mock_run, _mock_method, _mock_managed, capsys):- """``hermes update`` inside Docker → friendly message + exit 1, no git calls."""+ """``hermes update`` inside Docker → friendly message + exit 2, no git calls.++ Exit 2 = refused-by-contract (#91277 Phase 3), distinct from exit-1 errors.+ """with pytest.raises(SystemExit) as excinfo:cmd_update(SimpleNamespace(check=False))- assert excinfo.value.code == 1+ assert excinfo.value.code == 2out = capsys.readouterr().out# Spot-check the key guidance — exhaustive wording is locked in by the# config-module test below to keep these CLI tests resilient to copy edits.diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.pyindex 3e7eb907896..2002fa16150 100644--- a/tests/hermes_cli/test_web_server.py+++ b/tests/hermes_cli/test_web_server.py@@ -1173,6 +1173,11 @@ class TestWebServerEndpoints:# Bypass the managed-externally gate so we reach the docker install check.monkeypatch.setattr(web_server, "_dashboard_local_update_managed_externally", lambda: False)+ # The shared admission gate (#91277 Phase 3) resolves the install+ # method through hermes_cli.config directly.+ monkeypatch.setattr(+ "hermes_cli.config.detect_install_method", lambda *_a, **_k: "docker"+ )monkeypatch.setattr(web_server, "detect_install_method", lambda _root: "docker")monkeypatch.setattr(web_server, "_spawn_hermes_action", fail_spawn)web_server._ACTION_PROCS.pop("hermes-update", None)@@ -1208,6 +1213,12 @@ class TestWebServerEndpoints:raise AssertionError("APT-managed update guard should not spawn hermes update")monkeypatch.setattr(web_server, "_dashboard_local_update_managed_externally", lambda: False)+ # The shared admission gate (#91277 Phase 3) resolves the install+ # method through hermes_cli.config directly, so patch it there (the+ # web_server module alias only feeds the /update/check endpoint).+ monkeypatch.setattr(+ "hermes_cli.config.detect_install_method", lambda *_a, **_k: "apt"+ )monkeypatch.setattr(web_server, "detect_install_method", lambda _root: "apt")monkeypatch.setattr(web_server, "_spawn_hermes_action", fail_spawn)web_server._ACTION_PROCS.pop("hermes-update", None)