From 4fcd9ede33be540144c4578154882fcd5ebc786d Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Thu, 3 Sep 2026 15:15:53 -0700 Subject: [PATCH] simplify(compat): repoint the last stragglers (run_agent computer_use import, 8 test files patching old facade paths) --- run_agent.py | 2 +- tests/cron/test_cron_run_stale_claim_reap_86721.py | 2 +- tests/hermes_cli/test_update_fleet_restart_pending.py | 5 ++--- tests/hermes_cli/test_update_handoff_exit.py | 3 ++- tests/hermes_cli/test_update_head_moved_gate.py | 5 +++-- tests/hermes_cli/test_update_parked_branch_guard.py | 4 ++-- tests/hermes_cli/test_update_receipt.py | 3 ++- tests/test_resource_limits.py | 6 ++++-- tests/tui_gateway/test_subprocess_encoding.py | 4 ++-- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/run_agent.py b/run_agent.py index f6d31bc8e2..d64048251d 100644 --- a/run_agent.py +++ b/run_agent.py @@ -931,7 +931,7 @@ class AIAgent( process_registry.kill_all(task_id=task_id) def release_computer_use() -> None: - from tools.computer_use import release_computer_use_session + from tools.computer_use.tool import release_computer_use_session release_computer_use_session(task_id) for step in (kill_processes, lambda: cleanup_vm(task_id), lambda: cleanup_browser(task_id), release_computer_use): diff --git a/tests/cron/test_cron_run_stale_claim_reap_86721.py b/tests/cron/test_cron_run_stale_claim_reap_86721.py index 8cb2780d2e..97baf79830 100644 --- a/tests/cron/test_cron_run_stale_claim_reap_86721.py +++ b/tests/cron/test_cron_run_stale_claim_reap_86721.py @@ -127,7 +127,7 @@ def test_try_dispatch_background_run_calls_recovery_before_claiming(monkeypatch) "gateway.session_context.async_delivery_supported", lambda: True ) monkeypatch.setattr( - "tools.approval.get_current_session_key", lambda default="": "" + "tools.approval_context.get_current_session_key", lambda default="": "" ) job = {"id": "unit-test-job", "name": "unit test job", "deliver": "local"} diff --git a/tests/hermes_cli/test_update_fleet_restart_pending.py b/tests/hermes_cli/test_update_fleet_restart_pending.py index d5da6456e9..2a57f70788 100644 --- a/tests/hermes_cli/test_update_fleet_restart_pending.py +++ b/tests/hermes_cli/test_update_fleet_restart_pending.py @@ -82,7 +82,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect): "_get_origin_url", lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git", ) - monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False) + monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False) monkeypatch.setattr( hermes_main, "_stash_local_changes_if_needed", lambda *a, **k: None ) @@ -99,8 +99,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect): ) monkeypatch.setattr(hermes_main, "_write_update_incomplete_marker", lambda: None) monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None) - monkeypatch.setattr( - hermes_main, "_finish_dashboard_update_cleanup", lambda *a, **k: None + monkeypatch.setattr(update_cmd, "_finish_dashboard_update_cleanup", lambda *a, **k: None ) monkeypatch.setattr( update_cmd, "_finish_dashboard_update_cleanup", lambda *a, **k: None diff --git a/tests/hermes_cli/test_update_handoff_exit.py b/tests/hermes_cli/test_update_handoff_exit.py index f392cba019..4b963c1ba8 100644 --- a/tests/hermes_cli/test_update_handoff_exit.py +++ b/tests/hermes_cli/test_update_handoff_exit.py @@ -21,6 +21,7 @@ from types import SimpleNamespace import pytest import hermes_cli.main as main_mod +from hermes_cli import update_cmd from hermes_cli.main import cmd_update @@ -62,7 +63,7 @@ def _run_cmd_update(monkeypatch, impl, *, reexec: bool): monkeypatch.setattr("hermes_cli.config.is_managed", lambda: False) monkeypatch.setattr("hermes_cli.config.detect_install_method", lambda root: "git") monkeypatch.setattr("hermes_cli.update_lock.UpdateLock", lambda: _FakeLock(events["order"])) - monkeypatch.setattr(main_mod, "_cmd_update_impl", fake_impl) + monkeypatch.setattr(update_cmd, "_cmd_update_impl", fake_impl) monkeypatch.setattr(main_mod, "_install_hangup_protection", lambda gateway_mode=False: None) monkeypatch.setattr(main_mod, "_finalize_update_output", fake_finalize_io) monkeypatch.setattr("hermes_cli.update_receipt.finalize_pending_update_receipt", fake_receipt) diff --git a/tests/hermes_cli/test_update_head_moved_gate.py b/tests/hermes_cli/test_update_head_moved_gate.py index f363dac411..34d83a3845 100644 --- a/tests/hermes_cli/test_update_head_moved_gate.py +++ b/tests/hermes_cli/test_update_head_moved_gate.py @@ -14,6 +14,7 @@ from types import SimpleNamespace import pytest from hermes_cli import main as hermes_main +from hermes_cli import update_cmd def _make_head_moved_side_effect(pre_sha="abc123", post_sha="def456"): @@ -83,7 +84,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect): hermes_main, "_get_origin_url", lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git", ) - monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False) + monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False) monkeypatch.setattr( hermes_main, "_stash_local_changes_if_needed", lambda *a, **k: None ) @@ -104,7 +105,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect): monkeypatch.setattr(hermes_main, "_write_update_incomplete_marker", lambda: None) monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None) # Gateway restart path (called after a successful update). - monkeypatch.setattr(hermes_main, "_finish_dashboard_update_cleanup", lambda *a: None) + monkeypatch.setattr(update_cmd, "_finish_dashboard_update_cleanup", lambda *a: None) # Keep the (now surfaced — #78574) gateway auto-restart phase away from # this machine's real gateways: discovery returns nothing, systemd is # unsupported, so the phase is a clean no-op for both snapshots. diff --git a/tests/hermes_cli/test_update_parked_branch_guard.py b/tests/hermes_cli/test_update_parked_branch_guard.py index 2508606b3a..3d293c28fe 100644 --- a/tests/hermes_cli/test_update_parked_branch_guard.py +++ b/tests/hermes_cli/test_update_parked_branch_guard.py @@ -255,8 +255,8 @@ def _patch_update_flow(monkeypatch, repo, run_real_git=True): hermes_main, "_get_origin_url", lambda *a, **k: "https://github.com/NousResearch/hermes-agent.git", ) - monkeypatch.setattr(hermes_main, "_is_fork", lambda *a, **k: False) - monkeypatch.setattr(hermes_main, "_discard_lockfile_churn", lambda *a, **k: None) + monkeypatch.setattr(update_cmd, "_is_fork", lambda *a, **k: False) + monkeypatch.setattr(update_cmd, "_discard_lockfile_churn", lambda *a, **k: None) monkeypatch.setattr(update_cmd, "_discard_lockfile_churn", lambda *a, **k: None) monkeypatch.setattr(update_cmd, "_normalize_managed_eol", lambda *a, **k: None) monkeypatch.setattr(hermes_main, "_clear_bytecode_cache", lambda *a, **k: 0) diff --git a/tests/hermes_cli/test_update_receipt.py b/tests/hermes_cli/test_update_receipt.py index 01b38914b6..e7d1b2e778 100644 --- a/tests/hermes_cli/test_update_receipt.py +++ b/tests/hermes_cli/test_update_receipt.py @@ -17,6 +17,7 @@ from pathlib import Path import pytest import hermes_cli.update_receipt as ur +from hermes_cli import update_cmd @pytest.fixture() @@ -217,7 +218,7 @@ class TestCommandBoundaryFinalization: ur.record_step("windows_preflight", False, "hermes.exe holds venv") sys.exit(2) - monkeypatch.setattr(hermes_main, "_cmd_update_impl", _fake_impl) + monkeypatch.setattr(update_cmd, "_cmd_update_impl", _fake_impl) monkeypatch.setattr( hermes_main, "detect_install_method", lambda *a, **k: "git", raising=False ) diff --git a/tests/test_resource_limits.py b/tests/test_resource_limits.py index 6f24ce0e51..51a9e8c553 100644 --- a/tests/test_resource_limits.py +++ b/tests/test_resource_limits.py @@ -11,6 +11,8 @@ from types import SimpleNamespace import pytest from hermes_cli import resource_limits +from hermes_cli import dashboard_procs +from hermes_cli import main_dashboard class _FakeResource: @@ -270,7 +272,7 @@ def test_named_profile_reroute_defers_limit_to_final_process(monkeypatch, tmp_pa "get_active_profile_name", lambda: "worker", ) - monkeypatch.setattr(cli_main, "_dashboard_listening", lambda *args: False) + monkeypatch.setattr(main_dashboard, "_dashboard_listening", lambda *args: False) monkeypatch.setattr( local_environment, "build_subprocess_env", @@ -325,7 +327,7 @@ def test_dashboard_lifecycle_flags_skip_limit_adjustment(monkeypatch, lifecycle_ "apply_nofile_soft_limit", lambda: calls.append("limit"), ) - monkeypatch.setattr(cli_main, "_scan_dashboard_processes", lambda: []) + monkeypatch.setattr(dashboard_procs, "_scan_dashboard_processes", lambda: []) monkeypatch.setattr(cli_main, "_find_stale_dashboard_pids", lambda: []) args = SimpleNamespace( diff --git a/tests/tui_gateway/test_subprocess_encoding.py b/tests/tui_gateway/test_subprocess_encoding.py index 91cabb187d..a1dd0bbc1a 100644 --- a/tests/tui_gateway/test_subprocess_encoding.py +++ b/tests/tui_gateway/test_subprocess_encoding.py @@ -95,8 +95,8 @@ def test_shell_exec_uses_utf8_replace(): handler = server._methods["shell.exec"] with patch("subprocess.run", return_value=_make_completed_process()) as mock_run: # A harmless, non-dangerous command that passes the approval gate. - with patch("tools.approval.detect_hardline_command", return_value=(False, "")), \ - patch("tools.approval.detect_dangerous_command", return_value=(False, None, "")): + with patch("tools.approval_detection.detect_hardline_command", return_value=(False, "")), \ + patch("tools.approval_detection.detect_dangerous_command", return_value=(False, None, "")): resp = handler(1, {"command": "echo hello"}) assert mock_run.called, "subprocess.run was not invoked" kwargs = mock_run.call_args[1]