The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Merge origin/main (#38: 70 commits to c57331677d7) into feat/unified-gateway-runtime
Tekniumb1ccce898b5f
diff --cc tests/hermes_cli/test_finite_chat_delegation.pyindex abc0498b91e,f9e65b94a4f..0c02afbf279--- a/tests/hermes_cli/test_finite_chat_delegation.py+++ b/tests/hermes_cli/test_finite_chat_delegation.py@@@ -126,51 -121,16 +126,51 @@@ def test_finite_chat_joins_parallel_chiHERMES_MANAGED_DIR=str(tmp_path / "managed"), TERMINAL_CWD=str(tmp_path),OPENAI_BASE_URL=url, OPENAI_API_KEY="local-test-only", PYTHONPATH=str(REPO_ROOT),PYTHONDONTWRITEBYTECODE="1", LANG="C.UTF-8")- mode_flags = {"quiet": ["-Q"], "oneshot": ["--oneshot"], "redirected": []}+ mode_flags = {"quiet": ["-Q"], "oneshot": ["--oneshot"], "redirected": [],+ "resumed": ["-Q"]}command = [sys.executable, "-c", "from hermes_cli.main import main; main()", "chat",- *mode_flags[mode], "--provider", "custom", "--model", "test-model",+ *mode_flags[mode], "--provider", "custom", "--model", "test-model", "--base-url", url,"--toolsets", "delegation", "--ignore-rules", "--query-file", str(query),- "--reasoning", "high", "--max-turns", "10", "--run-budget", "60",+ "--reasoning", "high", "--max-turns", "10",]+ from tests.gateway.fixtures.local_recovery_probe import daemon, rpc, websocket++ async def create_resume_target(desc):+ async with websocket(home, desc) as ws:+ created = await rpc(ws, "session.create", request_id="interactive-origin", source="cli",+ model="test-model", provider="custom", base_url=url,+ toolsets=["delegation"], cwd=str(tmp_path), ignore_rules=True)+ return created["result"]["stored_session_id"]++ async def check_receipt(desc, row):+ sid, request_id, payload = row+ payload = json.loads(payload)+ assert payload["finite"] is True+ async with websocket(home, desc) as ws:+ assert "result" in await rpc(ws, "session.resume", session_id=sid)+ retry = dict(session_id=sid, input_id=request_id, **payload)+ assert (await rpc(ws, "prompt.submit", **retry))["result"]["status"] == "terminal"+ conflict = await rpc(ws, "prompt.submit", **{**retry, "finite": False})+ assert conflict["error"]["message"] == "admission_conflict"+ invalid = await rpc(ws, "prompt.submit", **{**retry, "finite": "true"})+ assert invalid["error"]["message"] == "invalid_params"try:- result = subprocess.run(command, cwd=tmp_path, env=env, stdin=subprocess.DEVNULL,- capture_output=True, text=True, encoding="utf-8", timeout=75, check=False)+ # Own the ordinary authority explicitly: a finite viewer must not own its lifetime.+ with daemon(REPO_ROOT, home, env, barrier=False) as (owner, desc):+ if mode == "resumed":+ sid = asyncio.run(create_resume_target(desc))+ command = command[:5] + ["-Q", "--resume", sid, "--query-file", str(query)]+ result = subprocess.run(command, cwd=tmp_path, env=env, stdin=subprocess.DEVNULL,- capture_output=True, text=True, encoding="utf-8", timeout=75)++ capture_output=True, text=True, encoding="utf-8", timeout=75, check=False)+ assert owner.poll() is None+ with closing(sqlite3.connect(f"file:{home / 'state.db'}?mode=ro", uri=True)) as db:+ admissions = db.execute("SELECT status FROM session_admissions").fetchall()+ saved = db.execute("SELECT target_session_id,request_id,payload_json FROM session_admissions").fetchone()+ # Inline children never leave a detached-result receipt for a later viewer.+ assert db.execute("SELECT count(*) FROM async_delegations").fetchone() == (0,)+ assert admissions == [("terminal",)], admissions+ asyncio.run(check_receipt(desc, saved))finally:server.shutdown()server.server_close()diff --cc tests/test_live_system_guard_self_test.pyindex b64e1912b72,4ea03e988bb..1c235df6b2e--- a/tests/test_live_system_guard_self_test.py+++ b/tests/test_live_system_guard_self_test.py@@@ -153,20 -153,9 +153,20 @@@ def test_subprocess_run_bash_c_systemctdef test_subprocess_run_setsid_systemctl_blocked():with pytest.raises(RuntimeError, match="live-system guard"):- subprocess.run(["setsid", "systemctl", "kill", "hermes-gateway"])+ subprocess.run(["setsid", "systemctl", "kill", "hermes-gateway"], check=False)+def test_host_gateway_start_blocked_but_container_exec_allowed():+ """A host-side ``hermes gateway start`` spawns a real runtime; the same words addressed to+ a container via ``docker exec`` stay inside it and are the Docker harness's business."""+ with pytest.raises(RuntimeError, match="REAL hermes gateway runtime"):+ subprocess.run(["hermes", "-p", "p", "gateway", "start"])+ argv = ["docker", "exec", "-u", "hermes", "hermes-test-x", "sh", "-c", "hermes -p p gateway start"]+ # Past the guard the call reaches the real subprocess.run; a missing binary is fine here.+ with pytest.raises(FileNotFoundError):+ subprocess.run(argv, env={"PATH": "/nonexistent"})++def test_subprocess_run_string_shell_true_blocked():with pytest.raises(RuntimeError, match="live-system guard"):subprocess.run(diff --cc tests/tools/test_completed_process_results.pyindex 49f77f1afb6,e649b9c1dc7..400d3a863a3--- a/tests/tools/test_completed_process_results.py+++ b/tests/tools/test_completed_process_results.py@@@ -175,13 -151,7 +175,13 @@@ def test_headless_terminal_result_survi"oneshot=True, provider='custom', model='test-model', api_key='local-test-only', "f"base_url={url!r}, toolsets='terminal', max_turns=3, ignore_rules=True)",], cwd=tmp_path, env=env, stdin=subprocess.DEVNULL,- capture_output=True, text=True, encoding="utf-8", timeout=60)+ capture_output=True, text=True, encoding="utf-8", timeout=60, check=False)+ # The canonical CLI is a finite client: it exits on its turn's terminal event while+ # the daemon that owns the child keeps its watcher. The owned completion is admitted+ # there as a follow-up turn, so the model must stay reachable until it arrives.+ deadline = time.monotonic() + 30+ while not follow_ups and time.monotonic() < deadline:+ time.sleep(0.1)finally:release.touch()server.shutdown()