"""The agent assembled from its own folder on the Execution engine: its role files, its Skills and its provider bundle, with a scripted runtime in place of models.""" from __future__ import annotations from pathlib import Path from typing import Any from execution_engine.adk.fake_runtime import FakeAgentRuntime from execution_engine.agent import open_assembly from execution_engine.config import Settings from execution_engine.recorder import InMemoryRecorder from app.main import ROOT from app.solution_architecture.assembly import workflow_for from app.solution_architecture.workflow import DEPENDENCY_GRAPH, WORKFLOW from tests.support import SPEC, whole_execution CASE = "bench" # What the operating model agent digests of a completed architecture Execution. DIGESTED = { "components.json", "products.json", "recommendations.json", "requirements.json", "scope.json", "target-architecture.json", "verdicts.json", "work-breakdown.json", } def settings(**overrides: Any) -> Settings: values: dict[str, Any] = { "CLOUD_PROVIDER": "gcp", "CHECKPOINTER": "memory", "MCP_ENABLED": False, "LESSONS_ENABLED": False, } values.update(overrides) return Settings(_env_file=None, **values) # type: ignore[call-arg] def assembled(tmp_path: Path, runtime: FakeAgentRuntime, **overrides: Any) -> Any: return open_assembly( settings(**overrides), workflow_for, root=ROOT, runtime=runtime, recorder=InMemoryRecorder(), output_root=tmp_path, ) async def test_every_role_the_workflow_names_has_its_file(tmp_path): async with assembled(tmp_path, FakeAgentRuntime({})) as assembly: roles = set(assembly.roles) assert {spec.specialist for spec in DEPENDENCY_GRAPH.values()} <= roles assert {"orchestrator", "reply-writer"} <= roles assert assembly.bundle.name == "gcp" # The pillar advisors come from the provider bundle's pillar Skills. assert assembly.engine.workflow.role_tools is not None async def test_a_pre_approved_execution_delivers_what_the_operating_model_reads( tmp_path, ): async with assembled(tmp_path, FakeAgentRuntime(whole_execution())) as assembly: result = await assembly.engine.start( "Accept webhooks and keep them for replay.", pre_approved=True, customer_case=CASE, scope=SPEC, ) assert result.status == "completed", result.state.get("warnings") out = tmp_path / "deliverables" / "cases" / CASE / "executions" folder = next(out.iterdir()) written = {path.name for path in folder.rglob("*.json")} assert DIGESTED <= written assert (folder / "execution.json").is_file() assert (folder / WORKFLOW.final_file).is_file()