86 lines
2.8 KiB
Python
86 lines
2.8 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "active-runtime/app"))
|
|
|
|
from aios_online_agent_execution import ( # noqa: E402
|
|
GovernedExecutionBinding,
|
|
project_execution_envelope,
|
|
)
|
|
import aios_online_agent_worker as worker # noqa: F401,E402
|
|
from aios_online_agent_worker import WorkerSupervisor # noqa: E402
|
|
|
|
|
|
BASE = "a" * 40
|
|
|
|
|
|
def test_agent_runtime_replays_the_durable_envelope_to_bridge(monkeypatch) -> None:
|
|
monkeypatch.setattr(
|
|
worker,
|
|
"WORKER_CAPABILITIES",
|
|
tuple(sorted((*worker.WORKER_CAPABILITIES, "agent.runtime.hermes"))),
|
|
)
|
|
binding = GovernedExecutionBinding.from_mapping(
|
|
{
|
|
"task_id": "r42-agent-runtime-replay-test-20260818",
|
|
"job_id": "job-agent-runtime-replay-test",
|
|
"repository": "aios/aios",
|
|
"base_oid": BASE,
|
|
"expected_branch_oid": BASE,
|
|
"target_branch": "agent/agent-runtime-replay-test",
|
|
"branch_mode": "CREATE_NEW",
|
|
"generation": 1,
|
|
"idempotency_key": "agent-runtime-replay-test-v1",
|
|
}
|
|
)
|
|
execution = project_execution_envelope(
|
|
binding,
|
|
{
|
|
"action": "agent_runtime",
|
|
"adapter": "hermes",
|
|
"capability_scope": ["agent.runtime.hermes"],
|
|
"change_set": [],
|
|
"runtime_input": {
|
|
"goal": "replay the exact durable runtime envelope",
|
|
"instructions": "return the bounded sentinel",
|
|
"success_criteria": [
|
|
{
|
|
"id": "sentinel",
|
|
"description": "return the bounded sentinel",
|
|
}
|
|
],
|
|
"constraints": {
|
|
"provider_boundary": "provider-credential-only",
|
|
"change_set": [],
|
|
"writer_lease": False,
|
|
},
|
|
},
|
|
},
|
|
)
|
|
task = {
|
|
**binding.public(),
|
|
"required_capabilities": ["agent.runtime.hermes"],
|
|
"metadata": {"execution": execution},
|
|
}
|
|
|
|
class Bridge:
|
|
def __init__(self) -> None:
|
|
self.calls: list[object] = []
|
|
|
|
def project_execution(self, _task: object, projection_input: object = None):
|
|
self.calls.append(projection_input)
|
|
return 200, dict(projection_input or {})
|
|
|
|
supervisor = object.__new__(WorkerSupervisor)
|
|
supervisor.bridge = Bridge()
|
|
resolved, source = supervisor.resolve_envelope(task)
|
|
|
|
assert source == "persisted_verified"
|
|
assert resolved.action == "agent_runtime"
|
|
assert resolved.adapter == "hermes"
|
|
assert resolved.digest == execution["execution_digest"]
|
|
assert supervisor.bridge.calls == [execution]
|