The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: observe relay completion and cron guard at owner seams
Teknium625bb379b7eb
diff --git a/tests/gateway/test_relay_authority.py b/tests/gateway/test_relay_authority.pyindex cd94f417bae..8fc446edc5f 100644--- a/tests/gateway/test_relay_authority.py+++ b/tests/gateway/test_relay_authority.py@@ -13,7 +13,7 @@ import timedef test_authenticated_relay_uses_canonical_admission(tmp_path):- env = dict(os.environ, HERMES_HOME=str(tmp_path), PYTHONUNBUFFERED='1')+ env = dict(os.environ, HOME=str(tmp_path), HERMES_HOME=str(tmp_path), PYTHONUNBUFFERED='1')result = subprocess.run([sys.executable, __file__, 'peer'], env=env,capture_output=True, text=True, timeout=100)assert result.returncode == 0, result.stdout + result.stderr@@ -140,9 +140,15 @@ async def probe(peer):second = deepcopy(raw)second.update(message_id='relay-2', text='WS_SHARED')rows = await send(second)+ # Settlement and an RPC reply do not drain the fanout writer.+ # Observe this admission's terminal event before taking a snapshot.+ admission_id = next(r['admission_id'] for r in rows if r['request_id'] == 'relay-2')+ async with asyncio.timeout(10):+ while not any(f.get('params', {}).get('type') == 'message.complete'+ and f['params'].get('admission_id') == admission_id for f in frames):+ frames.append(json.loads(await ws.recv()))snapshot = await rpc('session.resume', session_id=sid)assert 'LOCAL_ACK_WS_SHARED' in json.dumps(snapshot), snapshot- assert any(f.get('params', {}).get('type') == 'message.complete' for f in frames), framesassert [r['request_id'] for r in rows] == ['relay-1', 'relay-2'], rowsassert len(peer.requests) == 2, peer.requestsassert authority.agent(SessionRef('default', sid)) is warm_agentdiff --git a/tests/hermes_cli/test_config_guard_surfaces.py b/tests/hermes_cli/test_config_guard_surfaces.pyindex 8721f01a827..4c438b501bb 100644--- a/tests/hermes_cli/test_config_guard_surfaces.py+++ b/tests/hermes_cli/test_config_guard_surfaces.py@@ -62,12 +62,36 @@ class TestCronRunJobGuard:job.update(overrides)return job- def test_run_job_fails_closed_on_corrupt_config(self, tmp_path):- from cron.scheduler import run_job+ @pytest.mark.asyncio+ async def test_run_job_fails_closed_on_corrupt_config(self, tmp_path):+ import json+ from types import SimpleNamespace- _write_corrupt_config(tmp_path)+ from gateway.session_contract import SessionRef+ from gateway.session_cron import current_execution, execute+ from hermes_state_registry import acquire, release- success, output_doc, final_response, error = run_job(self._job())+ _write_corrupt_config(tmp_path)+ # Agent-backed run_job is now a client. Exercise the scheduler's guard+ # through its owner entry, without launching a daemon or bypassing it.+ db = acquire(tmp_path / "state.db")+ ref = SessionRef("default", "cron-guard")+ db.create_session(ref.session_id, source="cron")+ owner = SimpleNamespace(db=db, pending_results={}, sessions={+ ref.session_id: SimpleNamespace(source=SimpleNamespace(user_id="cron-owner"))})+ admission = {"admission_id": "guard-fire", "request_id": "guard-fire",+ "principal_id": "cron-owner", "payload": {"text": ""}}+ policy = SimpleNamespace(request_json=json.dumps({+ "cron_job": self._job(), "extra_prompt": None, "request_id": "guard-fire"}))+ previous = current_execution()+ try:+ with pytest.raises(RuntimeError, match="Refusing non-interactive startup"):+ await execute(owner, ref, admission, policy)+ success, output_doc, final_response, error = owner.pending_results["guard-fire"]["result"]["cron_result"]+ assert current_execution() is previous+ assert not owner._cron_cancellations+ finally:+ release(db)assert success is Falseassert error is not None