The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: native-Windows portability for branch daemon/probe fixtures
Teknium99c8897c4fab
diff --git a/tests/gateway/fixtures/session_policy_peer.py b/tests/gateway/fixtures/session_policy_peer.pyindex e9bbbf07152..9ae9daa6368 100644--- a/tests/gateway/fixtures/session_policy_peer.py+++ b/tests/gateway/fixtures/session_policy_peer.py@@ -111,8 +111,10 @@ async def probe(peer):assert agent is not None, (source, list(runner._agent_cache), peer.requests, await rpc(ws, 'session.resume', session_id=sid))assert agent.platform == {'cli': 'cli', 'tui': 'tui', 'gui': 'desktop'}[source], vars(agent).get('platform')cwd = Path(os.environ['HERMES_HOME'], source)- assert (cwd / 'policy-proof.txt').read_text() == 'owned'requests = [r for r in peer.requests if r.get('model') == 'policy-' + source]+ tool_results = [m for r in requests for m in r['messages'] if m['role'] == 'tool']+ assert (cwd / 'policy-proof.txt').is_file(), (source, str(cwd), tool_results)+ assert (cwd / 'policy-proof.txt').read_text() == 'owned'assert len(requests) >= 2, peer.requestsassert any(str(cwd) in json.dumps(m) for r in requests for m in r['messages'] if m['role'] == 'tool')names = {t['function']['name'] for t in requests[0]['tools']}diff --git a/tests/gateway/test_api_crash_recovery.py b/tests/gateway/test_api_crash_recovery.pyindex 5a518300ba9..ccab9f057a2 100644--- a/tests/gateway/test_api_crash_recovery.py+++ b/tests/gateway/test_api_crash_recovery.py@@ -10,7 +10,7 @@ import threadingimport aiohttp-from tests.gateway.fixtures.local_recovery_probe import daemon, Model+from tests.gateway.fixtures.local_recovery_probe import child_env, daemon, Modeldef test_api_crash_queue_and_identified_result_retry(tmp_path):@@ -28,7 +28,7 @@ def test_api_crash_queue_and_identified_result_retry(tmp_path):'gateway': {'platforms': {'api_server': {'enabled': True, 'port': port, 'host': '127.0.0.1'}}, 'multiplex_profiles': False},'auxiliary': {'title_generation': {'enabled': False}}, 'terminal': {'cwd': str(home)}}(home / 'config.yaml').write_text(json.dumps(cfg))- env = {k: os.environ[k] for k in ('PATH', 'LANG', 'TZ', 'TIRITH_ENABLED') if k in os.environ}+ env = {**child_env(), **{k: os.environ[k] for k in ('TIRITH_ENABLED',) if k in os.environ}}env.update(HOME=str(user), USERPROFILE=str(user), HERMES_HOME=str(home), PYTHONPATH=str(root),OPENAI_API_KEY='loopback-only', OPENAI_BASE_URL=base, API_SERVER_KEY='ordinary-daemon-owned-secret',API_SERVER_ENABLED='true', API_SERVER_PORT=str(port), PYTHONUNBUFFERED='1')diff --git a/tests/gateway/test_api_pending_daemon.py b/tests/gateway/test_api_pending_daemon.pyindex 698c91eecf4..9163fe4fbcf 100644--- a/tests/gateway/test_api_pending_daemon.py+++ b/tests/gateway/test_api_pending_daemon.py@@ -63,7 +63,8 @@ def test_api_and_ws_pending_controls_share_identity(tmp_path):'auxiliary': {'title_generation': {'enabled': False}}, 'terminal': {'cwd': str(home)},'platform_toolsets': {'api_server': ['terminal', 'clarify']}, 'approvals': {'mode': 'manual'}}(home / 'config.yaml').write_text(json.dumps(cfg))- env = {k: os.environ[k] for k in ('PATH', 'LANG', 'TZ', 'TIRITH_ENABLED') if k in os.environ}+ from tests.gateway.fixtures.local_recovery_probe import child_env+ env = {**child_env(), **{k: os.environ[k] for k in ('TIRITH_ENABLED',) if k in os.environ}}env.update(HOME=str(user), USERPROFILE=str(user), HERMES_HOME=str(home), PYTHONPATH=str(root),OPENAI_API_KEY='loopback-only', OPENAI_BASE_URL=base, API_SERVER_KEY='ordinary-daemon-owned-secret',API_SERVER_ENABLED='true', API_SERVER_PORT=str(port), PYTHONUNBUFFERED='1')diff --git a/tests/gateway/test_managed_worker_bypass.py b/tests/gateway/test_managed_worker_bypass.pyindex 67bbaff8890..78fe15b4475 100644--- a/tests/gateway/test_managed_worker_bypass.py+++ b/tests/gateway/test_managed_worker_bypass.py@@ -86,8 +86,9 @@ print(json.dumps({{'max_turns': cfg['agent']['max_turns'], 'raw_model': raw['mod'opened': opened, 'plugins': sorted(get_plugin_manager()._plugins),'executed': os.path.exists(os.path.join(home, 'plugin-executed'))}}))''', encoding='utf-8')- env = {k: os.environ[k] for k in ('PATH', 'LANG', 'TZ', 'TIRITH_ENABLED') if k in os.environ}- env.update(HOME=str(tmp_path), HERMES_HOME=str(home), PYTHONPATH=str(root))+ from tests.gateway.fixtures.local_recovery_probe import child_env+ env = {**child_env(), **{k: os.environ[k] for k in ('TIRITH_ENABLED',) if k in os.environ}}+ env.update(HOME=str(tmp_path), USERPROFILE=str(tmp_path), HERMES_HOME=str(home), PYTHONPATH=str(root))result = subprocess.run([sys.executable, str(script)], cwd=root, env=env, stdin=subprocess.DEVNULL,capture_output=True, text=True, timeout=90)assert result.returncode == 0, result.stdout + result.stderrdiff --git a/tests/gateway/test_session_kanban.py b/tests/gateway/test_session_kanban.pyindex 8bc728ade45..061d226418b 100644--- a/tests/gateway/test_session_kanban.py+++ b/tests/gateway/test_session_kanban.py@@ -57,8 +57,9 @@ def test_real_dispatcher_lifecycle(tmp_path, mode):import subprocessimport sysrepo = Path(__file__).resolve().parents[2]- env = {k: os.environ[k] for k in ('PATH', 'LANG', 'TZ', 'SYSTEMROOT') if k in os.environ}- env.update(HOME=str(tmp_path / 'home'), HERMES_HOME=str(tmp_path / 'state'), PYTHONPATH=str(repo), KANBAN_PROBE_MODE=mode)+ from tests.gateway.fixtures.local_recovery_probe import child_env+ env = child_env()+ env.update(HOME=str(tmp_path / 'home'), USERPROFILE=str(tmp_path / 'home'), HERMES_HOME=str(tmp_path / 'state'), PYTHONPATH=str(repo), KANBAN_PROBE_MODE=mode)result = subprocess.run([sys.executable, str(Path(__file__).parent / 'fixtures' / 'kanban_owner_probe.py')],env=env, cwd=repo, stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=150)assert result.returncode == 0, result.stdout + result.stderrdiff --git a/tests/gateway/test_session_policy.py b/tests/gateway/test_session_policy.pyindex 29661acb77f..23e57096c49 100644--- a/tests/gateway/test_session_policy.py+++ b/tests/gateway/test_session_policy.py@@ -46,7 +46,8 @@ def test_launch_policy_reaches_real_turn_runner(tmp_path):home, state = tmp_path / 'home', tmp_path / 'state'home.mkdir()state.mkdir()- env = {k: os.environ[k] for k in ('PATH', 'SYSTEMROOT', 'LANG', 'TZ') if k in os.environ}+ from tests.gateway.fixtures.local_recovery_probe import child_env+ env = child_env()env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(state), PYTHONPATH=str(repo))result = subprocess.run([sys.executable, str(Path(__file__).parent / 'fixtures' / 'session_policy_peer.py')],cwd=repo, env=env, stdin=subprocess.DEVNULL, capture_output=True, text=True, encoding='utf-8', errors='replace', timeout=130)diff --git a/tests/hermes_cli/test_corelane_frozen_worker_skill_env.py b/tests/hermes_cli/test_corelane_frozen_worker_skill_env.pyindex 036fd50be5f..6aa12711e38 100644--- a/tests/hermes_cli/test_corelane_frozen_worker_skill_env.py+++ b/tests/hermes_cli/test_corelane_frozen_worker_skill_env.py@@ -37,8 +37,9 @@ def _run(tmp_path, mode):result = json.loads(skill_view("probe"))print(json.dumps({"opened": opened, "missing": result.get("missing_required_environment_variables")}))"""), encoding="utf-8")- env = {k: os.environ[k] for k in ("PATH", "LANG", "TZ") if k in os.environ}- env.update(HOME=str(home), HERMES_HOME=str(home), PROBE_MODE=mode, HERMES_DISABLE_LAZY_INSTALLS="1")+ from tests.gateway.fixtures.local_recovery_probe import child_env+ env = child_env()+ env.update(HOME=str(home), USERPROFILE=str(home), HERMES_HOME=str(home), PROBE_MODE=mode, HERMES_DISABLE_LAZY_INSTALLS="1")proc = subprocess.run([sys.executable, str(script)], cwd=ROOT, env=env, stdin=subprocess.DEVNULL,capture_output=True, text=True, timeout=90)assert proc.returncode == 0, proc.stdout + proc.stderrdiff --git a/tests/hermes_cli/test_safe_mode.py b/tests/hermes_cli/test_safe_mode.pyindex d204adb0f6b..ae7be6e47d0 100644--- a/tests/hermes_cli/test_safe_mode.py+++ b/tests/hermes_cli/test_safe_mode.py@@ -11,7 +11,6 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServerimport jsonimport osfrom pathlib import Path-import ptyimport reimport selectimport sqlite3@@ -56,6 +55,7 @@ class Model(BaseHTTPRequestHandler):def _pty_cli(argv, cwd, env, timeout=90):"""Real PTY launch: stdin/stdout/stderr are a terminal, like a user's shell."""+ import pty # POSIX-only; the module must still collect on Windowsmaster, slave = pty.openpty()proc = subprocess.Popen(argv, cwd=cwd, env=env, stdin=slave, stdout=slave, stderr=slave, close_fds=True)os.close(slave)diff --git a/tests/hermes_state/test_target_advance_fence.py b/tests/hermes_state/test_target_advance_fence.pyindex f706204b395..ac44c20360e 100644--- a/tests/hermes_state/test_target_advance_fence.py+++ b/tests/hermes_state/test_target_advance_fence.py@@ -12,7 +12,7 @@ from hermes_state import SessionDBimport hermes_state_runtime as rt-def _local_session(db, epoch):+def _local_session(db, epoch, cwd):from hermes_state_local import commit_local_sessionfrom gateway.config import Platformfrom gateway.session import SessionEntry, SessionSource@@ -23,7 +23,7 @@ def _local_session(db, epoch):source = SessionSource(platform=Platform.LOCAL, chat_id=sid, user_id='human', chat_type='dm')now = _now()entry = SessionEntry('local:' + sid, sid, now, now, origin=source, platform=Platform.LOCAL)- policy = build_policy({'source': 'cli', 'cwd': '/', 'model': 'm', 'toolsets': []},+ policy = build_policy({'source': 'cli', 'cwd': str(cwd), 'model': 'm', 'toolsets': []},{'platform_toolsets': {'cli': []}}, private_secrets={})commit_local_session(db, epoch=epoch, receipt={'profile_id': 'profile', 'principal_id': 'human', 'request_id': 'r', 'session_id': sid,@@ -44,7 +44,7 @@ def test_target_advance_allows_queued_follower_and_refuses_started_head(tmp_pathprepare = {'_prepare_only': True} if operation == 'compress' else {}with closing(SessionDB(tmp_path / 'state.db')) as db:epoch = rt.begin_runtime_epoch(db, instance_id='owner')- sid = _local_session(db, epoch)+ sid = _local_session(db, epoch, tmp_path)rt.admit_session_input(db, epoch=epoch, principal_id='human', session_id=sid,request_id='head', payload={'text': 'head'})rt.admit_session_input(db, epoch=epoch, principal_id='human', session_id=sid,