Files
gcp_solution_architecture_a…/tests/test_assembly.py
Jonathan Boniface 4e7a16cedd chore: raise the validator's budget and record the runs of cases 02, 03 and 04
- Validator budget 15 to 30: recording verdicts in pieces for 100 Checks
  used all 15 calls in one attempt.
- Plans record three runs on 2026-10-08:
  case 02 completed at 100% with no Revision in 24 minutes;
  case 03 completed at 100% with two Revisions of the design in 40 minutes;
  case 04 (interactive) ended with warnings at 75%, on two router faults:
  a reply that echoes the question is read as a change request, and the
  router loops at the Revision limit. Neither is fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 13:16:36 +01:00

95 lines
3.2 KiB
Python

"""Building the engine from settings and the provider bundle."""
from typing import Any
from app.adk.fake_runtime import Call, FakeAgentRuntime
from app.agent import open_assembly
from app.config import Settings
from app.recorder import InMemoryRecorder
def settings(tmp_path, **overrides) -> Settings:
values: dict[str, Any] = {
"CHECKPOINTER": "memory",
"MCP_ENABLED": False,
"ORCHESTRATOR": "model",
"ORCHESTRATOR_BUDGET": 9,
"SPECIALIST_BUDGET": 4,
}
values.update(overrides)
return Settings(**values)
async def test_assembly_wires_roles_budgets_and_tools_from_settings(tmp_path):
runtime = FakeAgentRuntime(
{"orchestrator": [[Call("ask_user", {"questions": ["Which region?"]})]]}
)
async with open_assembly(
settings(tmp_path),
runtime=runtime,
recorder=InMemoryRecorder(),
output_root=tmp_path,
) as assembly:
interaction = await assembly.engine.start("Design ingestion")
assert interaction.prompt["questions"][0]["question"] == "Which region?"
assert assembly.bundle.name == "gcp"
assert assembly.roles["orchestrator"].budget == 9
# A role with no budget of its own takes the setting; the validator has one.
assert assembly.roles["decomposer"].budget == 4
assert assembly.roles["validator"].budget == 30
assert assembly.mcp_gaps == {}
async def test_preview_mcp_servers_follow_the_setting(tmp_path):
async with open_assembly(
settings(tmp_path, MCP_ENABLE_PREVIEW=False),
runtime=FakeAgentRuntime({}),
recorder=InMemoryRecorder(),
output_root=tmp_path,
) as assembly:
servers = assembly.roles["requirements-analyst"].mcp_servers
assert "asset_inventory" not in servers
assert "compute" in servers
async def test_the_assembly_routes_by_default_and_runs_without_a_jev_key(tmp_path):
"""With no Jev key the router follows its playbook on rules alone."""
from app.adk.fake_runtime import sample_submission
from app.adk.runtime import NoDecider
from app.workflows.deliverables import DeliverableKind
runtime = FakeAgentRuntime(
{"requirements-analyst": [[sample_submission(DeliverableKind.REQUIREMENTS)]]}
)
async with open_assembly(
settings(tmp_path, ORCHESTRATOR="router", TYPESAFE_API_KEY=None),
runtime=runtime,
recorder=InMemoryRecorder(),
output_root=tmp_path,
) as assembly:
interaction = await assembly.engine.start("Design ingestion")
assert isinstance(assembly.decider, NoDecider)
# The router delegated requirements with no Orchestrator model, then the
# decomposer (unscripted here) stopped and its question reached the user.
assert [run.role for run in runtime.runs] == ["requirements-analyst"]
assert interaction.status == "awaiting_user"
assert "reply-writer" in assembly.roles
async def test_an_unknown_orchestrator_setting_is_refused(tmp_path):
import pytest
with pytest.raises(ValueError, match="ORCHESTRATOR must be router or model"):
async with open_assembly(
settings(tmp_path, ORCHESTRATOR="llm"),
runtime=FakeAgentRuntime({}),
recorder=InMemoryRecorder(),
output_root=tmp_path,
):
pass