The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(windows): web-ui-build mock seam, AF_UNIX gating, browser-profile tests
ethernetc81c93e7717c
diff --git a/tests/hermes_cli/test_update_wedged_gateway.py b/tests/hermes_cli/test_update_wedged_gateway.pyindex 71349e3e7a1..7f7c0a6d2cb 100644--- a/tests/hermes_cli/test_update_wedged_gateway.py+++ b/tests/hermes_cli/test_update_wedged_gateway.py@@ -473,9 +473,13 @@ class TestLaunchdRestartWedgedIntegration:assert ("drain", 4242, 195.0) in events[email protected]_onlyclass TestLoopTickWitness:"""Two-witness liveness (#90502 review).+ Windows CPython builds don't expose AF_UNIX, so this POSIX-socket+ transport class gates to Linux.+The heartbeat write moved off-loop, so a stale file no longer proves awedged loop and a fresh file no longer proves an alive one. The loopanswers a UNIX socket instead; the probe only escalates when BOTHdiff --git a/tests/hermes_cli/test_web_ui_build.py b/tests/hermes_cli/test_web_ui_build.pyindex c6bc6ad869d..9b1b905c8b6 100644--- a/tests/hermes_cli/test_web_ui_build.py+++ b/tests/hermes_cli/test_web_ui_build.py@@ -145,7 +145,7 @@ class TestBuildWebUISkipsWhenFresh:install_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")build_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main.subprocess.run", return_value=install_cp) as mock_run, \patch("hermes_cli.main._run_with_idle_timeout", return_value=build_cp) as mock_build:result = _build_web_ui(web_dir)@@ -178,7 +178,7 @@ class TestBuildWebUISkipsWhenFresh:install_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")build_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main.subprocess.run", return_value=install_cp) as mock_run, \patch("hermes_cli.main._run_with_idle_timeout", return_value=build_cp):result = _build_web_ui(web_dir)@@ -201,7 +201,7 @@ class TestBuildWebUISkipsWhenFresh:install_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")build_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main.subprocess.run", return_value=install_cp) as mock_run, \patch("hermes_cli.main._run_with_idle_timeout", return_value=build_cp):result = _build_web_ui(web_dir)@@ -223,7 +223,7 @@ class TestBuildWebUISkipsWhenFresh:install_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")build_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main.subprocess.run", return_value=install_cp), \patch("hermes_cli.main._run_with_idle_timeout", return_value=build_cp) as mock_idle:result = _build_web_ui(web_dir)@@ -247,7 +247,7 @@ class TestBuildWebUIRetryAndStaleFallback:# build attempt 1: fail; build attempt 2: success.build_fail = Subprocess.CompletedProcess([], 1, stdout="EPERM", stderr="")build_ok = Subprocess.CompletedProcess([], 0, stdout="", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main._time.sleep") as mock_sleep, \patch("hermes_cli.main.subprocess.run", return_value=install_ok), \patch("hermes_cli.main._run_with_idle_timeout",@@ -267,7 +267,7 @@ class TestBuildWebUIRetryAndStaleFallback:Subprocess = __import__("subprocess")install_ok = Subprocess.CompletedProcess([], 0, stdout="", stderr="")build_fail = Subprocess.CompletedProcess([], 1, stdout="vite ENOMEM", stderr="")- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main._time.sleep"), \patch("hermes_cli.main.subprocess.run", return_value=install_ok), \patch("hermes_cli.main._run_with_idle_timeout",@@ -318,7 +318,7 @@ class TestBuildWebUIFlock:t = threading.Timer(0.2, release_after_building)t.start()try:- with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \+ with patch("hermes_cli.main._resolve_node_runtime_npm", return_value="/usr/bin/npm"), \patch("hermes_cli.main.subprocess.run") as mock_run:result = build(web_dir)finally:diff --git a/tests/tools/test_browser_real_profile.py b/tests/tools/test_browser_real_profile.pyindex a1814691971..df0c865c215 100644--- a/tests/tools/test_browser_real_profile.py+++ b/tests/tools/test_browser_real_profile.py@@ -89,8 +89,14 @@ class TestSnapshotRealProfile:(root / "Default" / "Cache" / "Cache_Data" / "big").write_text("x" * 1000)(root / "Code Cache" / "js" / "blob").write_text("y" * 1000)(root / "Crashpad" / "dump").write_text("z")- # Live-instance leftovers that must never reach the copy- os.symlink("dead-target-1", root / "SingletonLock")+ # Live-instance leftovers that must never reach the copy. On Windows+ # without the SeCreateSymbolicLink privilege os.symlink raises+ # WinError 1314 — a regular dangling-ish placeholder exercises the+ # same exclusion contract there.+ try:+ os.symlink("dead-target-1", root / "SingletonLock")+ except OSError:+ (root / "SingletonLock").write_text("dead-target-1")return rootdef test_fresh_snapshot_copies_auth_and_skips_caches(self, tmp_path, monkeypatch):@@ -139,6 +145,7 @@ class TestSnapshotRealProfile:assert dst is Noneassert err and "was not found" in err+ @pytest.mark.linux_onlydef test_snapshot_files_are_owner_only(self, tmp_path, monkeypatch):"""Every copied file must be 0600 and every dir 0700 (#96729).@@ -170,6 +177,7 @@ class TestSnapshotRealProfile:offenders.append((os.path.join(root, f), oct(mode)))assert not offenders, f"group/world-accessible snapshot entries: {offenders}"+ @pytest.mark.linux_onlydef test_existing_lax_snapshot_heals_on_refresh(self, tmp_path, monkeypatch):"""A snapshot left 0644 by an older build tightens on the next pass."""import stat@@ -964,16 +972,27 @@ class TestReviewRound3:import tools.browser_tool as btbt._real_profile_cdp_cache.clear()proc = Mock(returncode=0, stdout="", stderr="")++ class FakeChrome:+ def poll(self):+ return None++ def fake_popen(argv, **kw):+ (tmp_path / "DevToolsActivePort").write_text("9251\n/devtools/browser/x\n")+ return FakeChrome()+with patch.object(bt, "_use_real_profile", return_value=True), \patch.object(bt, "_using_lightpanda_engine", return_value=False), \patch("hermes_cli.browser_connect.detect_default_chromium", return_value="chrome"), \patch("hermes_cli.browser_connect.real_profile_copy_dir", return_value=str(tmp_path)), \+ patch("hermes_cli.browser_connect.chromium_executable", return_value="/usr/bin/chrome"), \patch("hermes_cli.browser_connect.snapshot_real_profile",return_value=(str(tmp_path), None)) as snap, \patch.object(bt, "_agent_browser_get_cdp",side_effect=[None, "http://127.0.0.1:9251"]), \patch.object(bt, "_find_agent_browser", return_value="/usr/bin/agent-browser"), \patch.object(bt.subprocess, "run", return_value=proc), \+ patch.object(bt.subprocess, "Popen", side_effect=fake_popen), \patch.object(bt, "_is_headed_mode", return_value=False):cdp, err = bt._real_profile_cdp()assert err is None