feat: run role files on the ADK runtime with scoped Skills
Increment 5 of .scratch/solution-architect-agent/spec.md, test-first. - agents/*.md: provider-neutral role files for the Orchestrator, nine Specialists and the pillar advisor, with a shared Specialist protocol. - app/agents/roles.py: load and validate role files; Skills, MCP servers and models come from the provider bundle. - app/agents/adk_runtime.py: AgentRuntime on google-adk 2.9 with a per-run LlmAgent, role-scoped SkillToolset (no run_skill_script), step budgets, early stop on turn-ending tools, LiteLLM models. - app/execution/pillars.py + toolkit.py: design advisor fans out to one advisor per WAF pillar in parallel. - Specialists receive every earlier-Phase Deliverable as input. - Bundle gains role_skills, pillar_skills and -latest Gemini aliases; pin google-adk[extensions]==2.9.0. - 37 new tests; full suite 158 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
110
tests/execution/test_pillars.py
Normal file
110
tests/execution/test_pillars.py
Normal file
@@ -0,0 +1,110 @@
|
||||
"""The design advisor's fan-out to one advisor per architecture-framework pillar."""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.agents.fake_runtime import Call, FakeAgentRuntime
|
||||
from app.agents.roles import PILLAR_ADVISOR
|
||||
from app.agents.runtime import RoleSpec, ToolSpec
|
||||
from app.execution.pillars import CONSULT_TOOL, pillar_consultation_tool
|
||||
from app.execution.toolkit import make_tool_factory
|
||||
|
||||
pytestmark = pytest.mark.asyncio
|
||||
|
||||
PILLARS = {
|
||||
"security": "waf-security",
|
||||
"reliability": "waf-reliability",
|
||||
"sustainability": "waf-sustainability",
|
||||
}
|
||||
ADVISOR = RoleSpec(PILLAR_ADVISOR, "Advise on one pillar.", budget=5)
|
||||
|
||||
|
||||
def advice(pillar: str) -> list[Call]:
|
||||
return [Call("submit_advice", {"content": f"Use strong defaults for {pillar}."})]
|
||||
|
||||
|
||||
def turn_for_pillar(task):
|
||||
return advice(task.context["pillar"])
|
||||
|
||||
|
||||
async def consult(tool: ToolSpec, **args):
|
||||
return await tool.handler(**args)
|
||||
|
||||
|
||||
async def test_consults_every_pillar_with_only_its_skill():
|
||||
runtime = FakeAgentRuntime({PILLAR_ADVISOR: [turn_for_pillar] * 3})
|
||||
tool = pillar_consultation_tool(runtime, ADVISOR, PILLARS)
|
||||
|
||||
result = await consult(tool, brief="Event ingestion on serverless compute.")
|
||||
|
||||
assert result.outcome is None
|
||||
for pillar in PILLARS:
|
||||
assert f"## {pillar}" in result.message
|
||||
assert f"Use strong defaults for {pillar}." in result.message
|
||||
runs = {run.task.context["pillar"]: run for run in runtime.runs}
|
||||
assert set(runs) == set(PILLARS)
|
||||
assert (
|
||||
runs["security"].task.context["brief"]
|
||||
== "Event ingestion on serverless compute."
|
||||
)
|
||||
assert runtime.runs[0].tools == ("submit_advice",)
|
||||
|
||||
|
||||
async def test_advisors_are_scoped_to_their_pillar_skill():
|
||||
seen: dict[str, tuple[str, ...]] = {}
|
||||
|
||||
class RecordingRuntime(FakeAgentRuntime):
|
||||
async def run(self, role, task, tools):
|
||||
seen[task.context["pillar"]] = role.skills
|
||||
return await super().run(role, task, tools)
|
||||
|
||||
runtime = RecordingRuntime({PILLAR_ADVISOR: [turn_for_pillar] * 3})
|
||||
|
||||
await consult(pillar_consultation_tool(runtime, ADVISOR, PILLARS), brief="b")
|
||||
|
||||
assert seen == {pillar: (skill,) for pillar, skill in PILLARS.items()}
|
||||
|
||||
|
||||
async def test_a_subset_of_pillars_can_be_consulted():
|
||||
runtime = FakeAgentRuntime({PILLAR_ADVISOR: [turn_for_pillar]})
|
||||
tool = pillar_consultation_tool(runtime, ADVISOR, PILLARS)
|
||||
|
||||
result = await consult(tool, brief="b", pillars=["reliability"])
|
||||
|
||||
assert "## reliability" in result.message
|
||||
assert "## security" not in result.message
|
||||
|
||||
|
||||
async def test_unknown_pillars_are_refused():
|
||||
tool = pillar_consultation_tool(FakeAgentRuntime({}), ADVISOR, PILLARS)
|
||||
|
||||
result = await consult(tool, brief="b", pillars=["speed"])
|
||||
|
||||
assert result.message.startswith("Refused")
|
||||
assert "security" in result.message
|
||||
|
||||
|
||||
async def test_an_advisor_that_fails_is_reported_without_losing_the_others():
|
||||
def maybe_fail(task):
|
||||
if task.context["pillar"] == "reliability":
|
||||
return [Call("submit_advice", {"content": ""})]
|
||||
return advice(task.context["pillar"])
|
||||
|
||||
runtime = FakeAgentRuntime({PILLAR_ADVISOR: [maybe_fail] * 3})
|
||||
|
||||
result = await consult(
|
||||
pillar_consultation_tool(runtime, ADVISOR, PILLARS), brief="b"
|
||||
)
|
||||
|
||||
assert "Use strong defaults for security." in result.message
|
||||
assert "## reliability\n\nNo guidance:" in result.message
|
||||
|
||||
|
||||
async def test_tool_factory_gives_the_consultation_only_to_the_design_advisor():
|
||||
roles = {PILLAR_ADVISOR: ADVISOR}
|
||||
factory = make_tool_factory(FakeAgentRuntime({}), roles, PILLARS)
|
||||
|
||||
design = factory(RoleSpec("design-advisor", "", budget=5), "design_recommendations")
|
||||
other = factory(RoleSpec("decomposer", "", budget=5), "technical_decomposition")
|
||||
|
||||
assert [tool.name for tool in design] == [CONSULT_TOOL]
|
||||
assert list(other) == []
|
||||
Reference in New Issue
Block a user