118 lines
3.4 KiB
Python
118 lines
3.4 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 (
|
|
GovernedExecutionBinding,
|
|
project_execution_envelope,
|
|
)
|
|
import aios_online_agent_worker as worker
|
|
from aios_online_agent_worker import WorkerSupervisor
|
|
|
|
|
|
BASE = "a" * 40
|
|
|
|
|
|
def _binding() -> GovernedExecutionBinding:
|
|
return GovernedExecutionBinding.from_mapping(
|
|
{
|
|
"task_id": "r42-source-capture-replay-test-20260818",
|
|
"job_id": "job-source-capture-replay-test",
|
|
"repository": "aios/aios",
|
|
"base_oid": BASE,
|
|
"expected_branch_oid": BASE,
|
|
"target_branch": "agent/source-capture-replay-test",
|
|
"branch_mode": "CREATE_NEW",
|
|
"generation": 1,
|
|
"idempotency_key": "source-capture-replay-test-v1",
|
|
}
|
|
)
|
|
|
|
|
|
def test_source_capture_replays_the_durable_envelope_to_bridge():
|
|
binding = _binding()
|
|
execution = project_execution_envelope(
|
|
binding,
|
|
{
|
|
"action": "source_capture",
|
|
"adapter": "compact_interface_map",
|
|
"capability_scope": ["git.read", "git.test"],
|
|
"source_signals": ["model provider registry version pinning"],
|
|
},
|
|
)
|
|
task = {
|
|
**binding.public(),
|
|
"required_capabilities": ["git.read", "git.test"],
|
|
"metadata": {"execution": execution},
|
|
}
|
|
|
|
class Bridge:
|
|
def __init__(self):
|
|
self.calls = []
|
|
|
|
def project_execution(self, _task, projection_input=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.digest == execution["execution_digest"]
|
|
assert supervisor.bridge.calls == [execution]
|
|
|
|
|
|
def test_deterministic_tasks_still_use_plan_registry_without_payload_replay():
|
|
binding = _binding()
|
|
execution = project_execution_envelope(
|
|
binding,
|
|
{
|
|
"action": "deterministic",
|
|
"adapter": "deterministic",
|
|
"capability_scope": [
|
|
"git.read",
|
|
"git.test",
|
|
"governed.write.branch",
|
|
"governed.write.file",
|
|
],
|
|
"change_set": [
|
|
{
|
|
"path": "active-runtime/app/example.py",
|
|
"operation": "write_file",
|
|
"content": "x",
|
|
}
|
|
],
|
|
},
|
|
)
|
|
task = {
|
|
**binding.public(),
|
|
"required_capabilities": [
|
|
"git.read",
|
|
"git.test",
|
|
"governed.write.branch",
|
|
"governed.write.file",
|
|
],
|
|
"metadata": {"execution": execution},
|
|
}
|
|
|
|
class Bridge:
|
|
def __init__(self):
|
|
self.calls = []
|
|
|
|
def project_execution(self, _task, projection_input=None):
|
|
self.calls.append(projection_input)
|
|
return 200, dict(execution)
|
|
|
|
supervisor = object.__new__(WorkerSupervisor)
|
|
supervisor.bridge = Bridge()
|
|
resolved, source = supervisor.resolve_envelope(task)
|
|
|
|
assert source == "persisted_verified"
|
|
assert resolved.digest == execution["execution_digest"]
|
|
assert supervisor.bridge.calls == [None]
|