The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge remote-tracking branch 'origin/main' into ethie/pm-clean
ethernetd2daa9685e69
diff --cc tests-js/install-known-failures.test.tsindex acc081e54cd,acc081e54cd..faa5527001e--- a/tests-js/install-known-failures.test.ts+++ b/tests-js/install-known-failures.test.ts@@@ -11,8 -11,8 +11,7 @@@ const classifier = path.resolve(import.const lockedLog = ['error: failed to remove file `C:/install/venv/Lib/site-packages/../../Scripts/hermes.exe`: Access is denied. (os error 5)',-- 'File "C:/install/venv/Scripts/hermes.exe/__main__.py", line 10, in <module>',-- "subprocess.CalledProcessError: Command '['uv', 'pip', 'install', '-e', '.', '--quiet']' returned non-zero exit status 2.",++ "⚠ Git update failed: Command '['uv', 'pip', 'install', '-e', '.', '--quiet']' returned non-zero exit status 2.",].join('\n')const base = {diff --cc tests/hermes_cli/test_pending_supervisor_recovery.pyindex 78b5ac9d7d3,bdc0c2485d8..50b9ceeb510--- a/tests/hermes_cli/test_pending_supervisor_recovery.py+++ b/tests/hermes_cli/test_pending_supervisor_recovery.py@@@ -7,9 -7,66 +7,6 @@@ import pytesfrom hermes_cli import gateway, main, update_cmd_fleet as fleet, update_receipt[email protected](autouse=True)-def _units_belong_to_this_update(monkeypatch):- """The fake ``hermes-gateway-one/two`` units carry no home; ownership (#93349,- ``test_update_fleet_home_scope.py``) is pinned so this file keeps testing the catch-up contract."""- monkeypatch.setattr(fleet, "_systemd_unit_owned_by_update", lambda scope_cmd, svc_name: True)--[email protected]_only[email protected]("failure", ["listing", "timeout", "missing", "restart", "inactive", "running", "missing-owned", None])-def test_pending_marker_requires_complete_systemd_recovery(monkeypatch, tmp_path, failure):- stopped = []- monkeypatch.setattr(gateway, "find_gateway_pids", lambda **kw: [123] if failure == "running" and not stopped else [])- monkeypatch.setattr(gateway, "kill_gateway_processes", lambda **kw: stopped.append(True))- monkeypatch.setattr(gateway, "_wait_for_gateway_exit", lambda **kw: None)- monkeypatch.setattr(gateway, "supports_systemd_services", lambda: True)- monkeypatch.setattr(fleet, "_SYSTEMD_SCOPES", (("user", ["systemctl", "--user"]),))- monkeypatch.setattr(fleet._time, "sleep", lambda _: None)- ticks = iter(range(1000))- monkeypatch.setattr(fleet._time, "monotonic", lambda: next(ticks))- recovered = []-- def systemctl(cmd, **kw):- if "list-units" in cmd:- if stopped:- return SimpleNamespace(returncode=0, stdout="", stderr="")- if failure == "timeout":- raise subprocess.TimeoutExpired(cmd, 10)- if failure == "missing":- raise FileNotFoundError("systemctl")- return SimpleNamespace(returncode=int(failure == "listing"), stdout=(- "hermes-gateway-one.service loaded active running\n"- + ("" if failure == "missing-owned" else "hermes-gateway-two.service loaded failed failed\n")), stderr="")- bad = cmd[-1] == "hermes-gateway-two"- if "restart" in cmd:- recovered.append(cmd[-1])- return SimpleNamespace(returncode=int(bad and failure == "restart"), stdout="")- if "is-active" in cmd:- active = not (bad and failure == "inactive")- return SimpleNamespace(returncode=0 if active else 3, stdout="active" if active else "inactive")- return SimpleNamespace(returncode=0, stdout="0s")--- monkeypatch.setattr(fleet, "_systemctl", systemctl)- monkeypatch.setattr(fleet, "_current_checkout_sha", lambda: "pending")- monkeypatch.setattr(update_receipt, "collect_fleet_versions", lambda **kw: [- {"profile": name.removeprefix("hermes-gateway-"), "state": "current", "code_sha": "pending"}- for name in recovered- ])- fleet._write_fleet_restart_pending_marker(expected_sha="pending", runtimes=[- {"kind": "gateway", "profile": profile} for profile in ("one", "two")- ])- if failure not in (None, "running"):- with pytest.raises(SystemExit, match="1"):- fleet._apply_pending_fleet_restart_catchup()- assert fleet._fleet_restart_obligation_armed()- else:- fleet._apply_pending_fleet_restart_catchup()- assert not fleet._fleet_restart_obligation_armed()- assert set(recovered) == {"hermes-gateway-one", "hermes-gateway-two"}----@pytest.mark.parametrize("failure", ["listing", "restart", "inactive", "unloaded", None])def test_pending_launchd_requires_complete_supervision(monkeypatch, tmp_path, failure):# Host-independent subprocess-boundary fixture, not native launchd validation.diff --cc tests/hermes_cli/test_profiles.pyindex 1e993ba6b8a,93ab79825e6..61c33295eee--- a/tests/hermes_cli/test_profiles.py+++ b/tests/hermes_cli/test_profiles.py@@@ -211,12 -212,50 +212,50 @@@ class TestCreateProfileprofile_dir = create_profile("coder", clone_config=True, no_alias=True)- cloned_config = yaml.safe_load((profile_dir / "config.yaml").read_text())+ cloned_config = yaml.safe_load((profile_dir / "config.yaml").read_text(encoding="utf-8-sig"))assert cloned_config["_config_version"] == DEFAULT_CONFIG["_config_version"]assert cloned_config["model"] == "test"- assert (profile_dir / ".env").read_text().strip() == "KEY=val"- assert (profile_dir / "SOUL.md").read_text() == "Be helpful."+ assert (profile_dir / ".env").read_text(encoding="utf-8-sig").strip() == "KEY=val"+ assert (profile_dir / "SOUL.md").read_text(encoding="utf-8-sig") == "Be helpful."+ def test_clone_config_copies_only_the_active_memory_providers_config(self, profile_env):+ """#120115: --clone carried ``memory.provider: hindsight`` but not hindsight's own config,+ so the clone booted with memory silently unavailable. Only the ACTIVE provider's+ ``<provider>/`` dir / ``<provider>.json`` travels; another provider's leftovers stay behind."""+ tmp_path = profile_env+ default_home = tmp_path / ".hermes"+ (default_home / "config.yaml").write_text("memory:\n provider: hindsight\n")+ (default_home / "hindsight").mkdir()+ payload = '{"mode": "local_embedded", "bank_id": "hermes", "apiKey": "hs-secret"}'+ (default_home / "hindsight" / "config.json").write_text(payload)+ (default_home / "mem0.json").write_text('{"agent_id": "hermes"}')++ profile_dir = create_profile("coder", clone_config=True, no_alias=True)++ cloned = profile_dir / "hindsight" / "config.json"+ assert cloned.read_text() == payload+ if os.name != "nt":+ assert stat.S_IMODE(cloned.stat().st_mode) == 0o600+ assert not (profile_dir / "mem0.json").exists()++ @pytest.mark.parametrize("provider", ["../outside", "a/b", "..", "hind sight"])+ def test_clone_config_ignores_unsafe_memory_provider_names(self, profile_env, provider):+ """A hand-edited ``memory.provider`` must never aim the copy outside the source profile."""+ tmp_path = profile_env+ default_home = tmp_path / ".hermes"+ (default_home / "config.yaml").write_text(f"memory:\n provider: {provider!r}\n")+ (tmp_path / "outside").mkdir()+ (tmp_path / "outside" / "config.json").write_text("{}")+ (default_home / "a").mkdir()+ (default_home / "a" / "b").mkdir()+ (default_home / "a" / "b" / "config.json").write_text("{}")++ profile_dir = create_profile("coder", clone_config=True, no_alias=True)++ assert not (profile_dir / "a").exists()+ assert not (profile_dir.parent / "outside").exists()+ assert not (profile_dir / "hind sight").exists()+def test_clone_sync_imports_carries_manifest_but_never_links_profiles(self, profile_env):"""--sync-imports copies import-sync.json (a pointer at EXTERNAL agent trees) and nothingelse changes: the clone still gets its own config/skills copies, never a live link."""diff --cc tests/hermes_cli/test_update_host_obligation.pyindex 1c554c83f49,f3adad4056f..bffe0ac8e90--- a/tests/hermes_cli/test_update_host_obligation.py+++ b/tests/hermes_cli/test_update_host_obligation.py@@@ -69,30 -77,30 +77,6 @@@ def test_obligation_armed_by_one_profilassert fleet._pending_fleet_restart_needed() is False--def test_host_gateway_restarts_once_when_two_profiles_run_the_catch_up(-- two_profiles, no_live_fleet, monkeypatch, capsys--):-- """``hermes -p coder update`` then ``hermes -p writer update`` stops the host gateway ONCE."""-- monkeypatch.setattr("hermes_cli.gateway.find_gateway_pids", lambda **k: [4242])-- monkeypatch.setattr("hermes_cli.gateway.supports_systemd_services", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway.is_macos", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway.is_windows", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway._wait_for_gateway_exit", lambda **k: True)-- monkeypatch.setattr(fleet, "_restart_macos_launchd_gateways", lambda *a, **k: None)-- kills: list = []-- monkeypatch.setattr("hermes_cli.gateway.kill_gateway_processes", lambda **k: kills.append(k))---- _enter(monkeypatch, two_profiles["coder"])-- _arm("coder")-- assert update_cmd._run_pending_fleet_restart() is True---- _enter(monkeypatch, two_profiles["writer"])-- _arm("writer")-- assert update_cmd._run_pending_fleet_restart() is True---- assert len(kills) == 1, "the one host gateway must be stopped once per update, not once per profile"----def test_legacy_per_home_marker_is_still_read_and_cleared(two_profiles, no_live_fleet, monkeypatch):"""An obligation armed by the pre-host-scope code must still be discharged after the upgrade."""_enter(monkeypatch, two_profiles["coder"])@@@ -235,32 -243,32 +219,6 @@@ def test_unreadable_host_record_is_neveassert fleet._pending_fleet_restart_needed() is True--def test_restart_runs_once_per_host_on_a_non_git_install(two_profiles, monkeypatch, capsys):-- """zip/pip/Docker installs resolve no checkout SHA; the restart-once guard must still hold.---- ``mark_host_restart_completed("")`` can never match, so every profile's ``hermes update``-- re-killed the one shared multiplexer on exactly the installs this record exists for.-- """-- monkeypatch.setattr(fleet, "_current_checkout_sha", lambda: None)-- monkeypatch.setattr("hermes_cli.update_receipt.collect_fleet_versions", lambda: [])-- monkeypatch.setattr("hermes_cli.gateway.find_gateway_pids", lambda **k: [4242])-- monkeypatch.setattr("hermes_cli.gateway.supports_systemd_services", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway.is_macos", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway.is_windows", lambda: False)-- monkeypatch.setattr("hermes_cli.gateway._wait_for_gateway_exit", lambda **k: True)-- kills: list = []-- monkeypatch.setattr("hermes_cli.gateway.kill_gateway_processes", lambda **k: kills.append(k))---- _enter(monkeypatch, two_profiles["coder"])-- _arm("coder")-- assert update_cmd._run_pending_fleet_restart() is True---- _enter(monkeypatch, two_profiles["writer"])-- assert update_cmd._run_pending_fleet_restart() is True---- assert len(kills) == 1, "the host gateway must be stopped once per update, not once per profile"----def test_a_failing_main_pid_probe_keeps_its_own_restart():"""Any probe error is unproven identity (its own restart), never an aborted restart pass."""def boom(unit):diff --cc tests/hermes_cli/test_update_unit_client_budget.pyindex 0f56b4864a4,9963575b253..2f8529fc056--- a/tests/hermes_cli/test_update_unit_client_budget.py+++ b/tests/hermes_cli/test_update_unit_client_budget.py@@@ -6,10 -6,18 +6,17 @@@ import pytesfrom hermes_cli import update_cmd_fleet as fleet+ @pytest.fixture(autouse=True)+ def _units_belong_to_this_update(monkeypatch):+ """Fake units on an invented MainPID (42) have no readable home; ownership (#93349,+ ``test_update_fleet_home_scope.py``) is pinned so these tests keep proving budgets and health."""+ monkeypatch.setattr(fleet, "_systemd_unit_owned_by_update", lambda scope_cmd, svc_name: True)++[email protected]("graceful,retry", [(False, False), (False, True), (True, False), ("catchup", False)])[email protected]("graceful,retry", [(False, False), (False, True), (True, False)])def test_unit_transaction_budget_preserves_scope_and_health(monkeypatch, graceful, retry):- catchup = graceful == "catchup"- scope = ["systemctl", "--user"] if catchup else ["systemctl", "--no-ask-password"]- manage = scope if catchup else ["sudo", "-n", *scope]+ scope = ["systemctl", "--no-ask-password"]+ manage = ["sudo", "-n", *scope]calls = []def systemctl(cmd, *, timeout):diff --cc tests/install/e2e-assets/known-failures.jsonindex eaf226778a1,eaf226778a1..263b6dc5c56--- a/tests/install/e2e-assets/known-failures.json+++ b/tests/install/e2e-assets/known-failures.json@@@ -6,7 -6,7 +6,7 @@@"cases": [["installer-script", "hermes-update"]],"errors": ["^E2E ASSERTION FAILED: hermes update exited [1-9][0-9]* \\(expected 0\\)$"],"log": "update",-- "signatures": ["failed to remove file[^\\r\\n]*Scripts[/\\\\]hermes\\.exe[^\\r\\n]*Access is denied\\. \\(os error 5\\)", "hermes\\.exe[/\\\\]__main__\\.py", "CalledProcessError[^\\r\\n]*pip[^\\r\\n]*install[^\\r\\n]*returned non-zero exit status 2"],++ "signatures": ["failed to remove file[^\\r\\n]*Scripts[/\\\\]hermes\\.exe[^\\r\\n]*Access is denied\\. \\(os error 5\\)", "(?:CalledProcessError|Git update failed: Command)[^\\r\\n]*pip[^\\r\\n]*install[^\\r\\n]*returned non-zero exit status 2"],"explanation": "The March/April Windows updater is already running from hermes.exe when uv tries to replace it. Windows refuses the locked launcher. The update target cannot change that loaded code; re-running the installer is a separate recovery route.","evidence": "https://github.com/ethernet8023/hermes-agent/actions/runs/34055462305/job/101546487700"},