From c5d37bb95cf7a932d644eb2811f57a7f00b9f670 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 29 Jul 2026 10:57:16 -0700 Subject: [PATCH] test(tui): pin approval-mode fixtures to env HERMES_HOME for canonical resolver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _load_approval_mode now delegates to tools.approval._get_approval_mode, which reads config via hermes_cli.config.load_config — that path resolves HERMES_HOME from the environment, not the server module's _hermes_home attribute. The four approval-mode tests only monkeypatched the module attribute, so the resolver silently read the developer/CI real config (default 'smart') instead of the temp fixture. Behavior assertions are unchanged (invalid → manual fail-safe, YAML off-bool → 'off', three-way persist + live emit); the fixtures now also set HERMES_HOME so the canonical read path sees the same temp config. --- tests/test_tui_gateway_server.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_tui_gateway_server.py b/tests/test_tui_gateway_server.py index dfc44447ccb..7456f116bcd 100644 --- a/tests/test_tui_gateway_server.py +++ b/tests/test_tui_gateway_server.py @@ -5313,6 +5313,10 @@ def test_config_get_approval_mode_uses_smart_default_when_key_is_missing( import yaml monkeypatch.setattr(server, "_hermes_home", tmp_path) + # Point the canonical resolver (load_config → env HERMES_HOME) at the + # temp home too, so the smart default is asserted against THIS config + # rather than whatever the developer's real ~/.hermes happens to hold. + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) (tmp_path / "config.yaml").write_text( yaml.safe_dump({"approvals": {"timeout": 15}}) ) @@ -5329,6 +5333,11 @@ def test_config_get_approval_mode_fails_safe_to_manual_for_invalid_explicit_valu import yaml monkeypatch.setattr(server, "_hermes_home", tmp_path) + # _load_approval_mode delegates to the canonical resolver in + # tools.approval, which reads via hermes_cli.config.load_config — + # that path resolves HERMES_HOME from the environment, not + # server._hermes_home. + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) (tmp_path / "config.yaml").write_text( yaml.safe_dump({"approvals": {"mode": "sometimes"}}) ) @@ -5343,6 +5352,9 @@ def test_config_get_approval_mode_normalizes_yaml_off(tmp_path, monkeypatch): import yaml monkeypatch.setattr(server, "_hermes_home", tmp_path) + # See fail-safe test above: the canonical resolver reads via + # load_config, which resolves HERMES_HOME from the environment. + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) (tmp_path / "config.yaml").write_text( yaml.safe_dump({"approvals": {"mode": False}}) ) @@ -5359,6 +5371,10 @@ def test_config_set_approval_mode_persists_three_way_value_and_emits_live_status import yaml monkeypatch.setattr(server, "_hermes_home", tmp_path) + # config.set writes via server._hermes_home, but the post-write + # session.info emit resolves the effective mode through the canonical + # tools.approval resolver (load_config → env HERMES_HOME). + monkeypatch.setenv("HERMES_HOME", str(tmp_path)) emitted = [] monkeypatch.setattr(server, "_emit", lambda *args: emitted.append(args)) server._sessions["sid"] = {"agent": object(), "session_key": "profile-session"}