Files
gcp_solution_architecture_a…/tests/execution/test_deliverables.py
Jonathan Boniface f040493583 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>
2026-09-16 09:51:02 +01:00

176 lines
5.7 KiB
Python

"""The dependency graph and Deliverable contracts."""
import pytest
from app.execution.deliverables import (
DEPENDENCY_GRAPH,
PHASE_ORDER,
DeliverableKind,
PhaseId,
check_submission,
deliverables_in,
inputs_of,
)
def test_every_kind_is_declared_once_with_known_dependencies():
assert set(DEPENDENCY_GRAPH) == set(DeliverableKind)
for kind, spec in DEPENDENCY_GRAPH.items():
assert spec.kind is kind
assert set(spec.depends_on) <= set(DeliverableKind), kind
def test_dependencies_never_point_to_a_later_phase_and_form_no_cycle():
position = {phase: index for index, phase in enumerate(PHASE_ORDER)}
for spec in DEPENDENCY_GRAPH.values():
for dependency in spec.depends_on:
assert position[DEPENDENCY_GRAPH[dependency].phase] <= position[spec.phase]
visiting: set[DeliverableKind] = set()
done: set[DeliverableKind] = set()
def visit(kind: DeliverableKind) -> None:
assert kind not in visiting, f"cycle through {kind}"
if kind in done:
return
visiting.add(kind)
for dependency in DEPENDENCY_GRAPH[kind].depends_on:
visit(dependency)
visiting.discard(kind)
done.add(kind)
for kind in DeliverableKind:
visit(kind)
def test_every_phase_groups_at_least_one_deliverable_with_a_distinct_specialist():
assert PHASE_ORDER == (
PhaseId.REQUIREMENTS_DISCOVERY,
PhaseId.SOLUTION_ARCHITECTURE,
PhaseId.SOLUTION_VALIDATION,
PhaseId.PACKAGING,
)
for phase in PHASE_ORDER:
assert deliverables_in(phase), phase
specialists = [spec.specialist for spec in DEPENDENCY_GRAPH.values()]
assert len(specialists) == len(set(specialists))
def test_graph_matches_the_upstream_skill_dependencies():
depends = {kind: set(spec.depends_on) for kind, spec in DEPENDENCY_GRAPH.items()}
K = DeliverableKind
assert depends[K.REQUIREMENTS] == set()
assert depends[K.TECHNICAL_DECOMPOSITION] == {K.REQUIREMENTS}
assert depends[K.PRODUCT_SELECTION] == {K.TECHNICAL_DECOMPOSITION}
assert depends[K.ARCHITECTURE_DIAGRAM] == {K.PRODUCT_SELECTION}
assert depends[K.ARCHITECTURE_DESCRIPTION] == {
K.ARCHITECTURE_DIAGRAM,
K.PRODUCT_SELECTION,
}
assert depends[K.DESIGN_RECOMMENDATIONS] == {K.PRODUCT_SELECTION, K.REQUIREMENTS}
assert depends[K.DEPLOYMENT_GUIDANCE] == {
K.PRODUCT_SELECTION,
K.DESIGN_RECOMMENDATIONS,
}
assert depends[K.VALIDATION_RESULTS] == {K.DEPLOYMENT_GUIDANCE}
assert depends[K.SOLUTION_GUIDE] == set(
deliverables_in(PhaseId.SOLUTION_VALIDATION)
)
def test_inputs_are_earlier_phases_plus_indirect_dependencies_in_graph_order():
assert inputs_of(DeliverableKind.REQUIREMENTS) == ()
assert inputs_of(DeliverableKind.DEPLOYMENT_GUIDANCE) == (
DeliverableKind.REQUIREMENTS,
DeliverableKind.TECHNICAL_DECOMPOSITION,
DeliverableKind.PRODUCT_SELECTION,
DeliverableKind.DESIGN_RECOMMENDATIONS,
)
assert inputs_of(DeliverableKind.ARCHITECTURE_DESCRIPTION) == (
DeliverableKind.REQUIREMENTS,
DeliverableKind.TECHNICAL_DECOMPOSITION,
DeliverableKind.PRODUCT_SELECTION,
DeliverableKind.ARCHITECTURE_DIAGRAM,
)
assert set(inputs_of(DeliverableKind.SOLUTION_GUIDE)) == set(DeliverableKind) - {
DeliverableKind.SOLUTION_GUIDE
}
def test_submission_meeting_the_contract_has_nothing_missing():
content = (
"# Deployment guidance\n"
"## 6.1. Deployment prerequisites\nEnable APIs.\n"
"## 6.2. Step-by-step deployment instructions\nRun terraform.\n"
)
attachments = {"terraform/main.tf": "resource {}", "terraform/variables.tf": ""}
assert (
check_submission(DeliverableKind.DEPLOYMENT_GUIDANCE, content, attachments)
== ()
)
def test_submission_reports_missing_sections_and_attachments():
missing = check_submission(
DeliverableKind.DEPLOYMENT_GUIDANCE,
"## Deployment prerequisites\n",
{"terraform/main.tf": "resource {}"},
)
assert missing == (
"section: Step-by-step deployment instructions",
"attachment: terraform/variables.tf",
)
@pytest.mark.parametrize(
"heading",
[
"### 5.1. Security, privacy, and compliance",
"## security, privacy, and compliance",
"# 5.1 Security, Privacy, and Compliance:",
],
)
def test_section_matching_ignores_numbering_case_and_trailing_punctuation(heading):
content = (
f"{heading}\n"
"## Reliability\n"
"## Operational excellence\n"
"## Cost optimization\n"
"## Performance efficiency\n"
"## Sustainability\n"
)
assert check_submission(DeliverableKind.DESIGN_RECOMMENDATIONS, content, {}) == ()
def test_section_matches_a_provider_prefixed_heading_but_not_a_longer_word():
content = (
"### 4.1. Google Cloud products and features mapping\n"
"## Non-functional requirements\n"
)
assert check_submission(DeliverableKind.PRODUCT_SELECTION, content, {}) == ()
assert "section: Functional requirements" in check_submission(
DeliverableKind.REQUIREMENTS, content, {}
)
def test_section_names_in_body_text_do_not_count_as_headings():
missing = check_submission(
DeliverableKind.REQUIREMENTS,
"Functional requirements, non-functional requirements, current state and "
"dependencies are all covered below.\n",
{},
)
assert "section: Functional requirements" in missing
def test_empty_content_is_refused():
assert check_submission(DeliverableKind.TECHNICAL_DECOMPOSITION, " \n", {}) == (
"content: must not be empty",
)