Files
gcp_solution_architecture_a…/tests/execution/test_presentation.py
Jonathan Boniface e9246828b3 feat: establish the Target architecture as a graph before code
Design is now approved before any infrastructure code is written (ADR-0005).
A new target-architect Specialist produces one graph of Elements,
Relationships and Checks; the diagram is rendered from it, deployment
guidance must account for every Check, and validation gives a verdict per
Check. Requirements, components, products and recommendations carry ids in
data files, and a submission with a gap in the Requirements chain is refused.

Also in this commit:
- Customer cases group Executions, with an intent history per case
- lesson candidates are captured when an Execution ends
- evaluation gains chain, verdict, judged and interactive checks, and
  per-case thresholds
- Terraform providers are cached between checks
- the requirements analyst proposes defaults instead of asking
- the legacy-baseline case and the checks that only read it are removed
- ADR-0006 (Change requests) accepted; ADR-0004 and ADR-0007 proposed
- plans for iterations 4 to 7 under .agents/plans/

Unproven with a real model: no evaluation run has completed on this design.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 13:59:09 +01:00

101 lines
3.3 KiB
Python

"""Prompt text for plain clients and the /generate response mapping."""
import json
from app.agent import Interaction
from app.presentation import describe_prompt, to_generate_response
def test_approval_prompt_explains_the_structured_reply():
text = describe_prompt(
{
"approval": {
"phase": "solution_architecture",
"summary": "Cloud Run and Pub/Sub",
"deliverables": ["product_selection", "target_architecture"],
}
}
)
reply = {"approval": {"phase": "solution_architecture", "decision": "approve"}}
assert json.dumps(reply) in text
assert "never approves" in text
def test_questions_are_numbered_with_their_source():
text = describe_prompt(
{
"questions": [
{"from": "requirements", "question": "RTO?"},
{"from": "orchestrator", "question": "Region?"},
]
}
)
assert text.startswith("1. (requirements) RTO?\n2. (orchestrator) Region?")
def test_generate_response_maps_deliverables_onto_legacy_artifacts():
requirements = (
"# Requirements\n## 2.3. Current state\nThree VMs.\n### Detail\nNginx.\n"
"## Dependencies\nNone.\n"
)
interaction = Interaction(
"exec-1",
"completed_with_warnings",
None,
{
"session_id": "s-1",
"warnings": ["revision limit"],
"deliverables": {
"requirements": {"content": requirements, "attachments": {}},
"deployment_guidance": {
"content": "# Guide",
"attachments": {"terraform/main.tf": "resource {}"},
},
},
"ledger": {
"deliverables": {"requirements": {"revisions": 2}},
"phases": {
"requirements_discovery": "approved",
"solution_architecture": "open",
},
},
},
)
body = to_generate_response(interaction, {})
assert body["status"] == "completed_with_warnings"
assert body["validation_passed"] is False
assert body["total_loop_iterations"] == 3
assert body["current_phase"] == "solution_architecture"
assert body["artifacts"]["source_discovery_doc"] == "Three VMs.\n### Detail\nNginx."
assert body["artifacts"]["terraform_code"] == "resource {}"
assert body["artifacts"]["solution_guide"] is None
assert body["warnings"] == ["revision limit"]
def test_the_design_approval_says_what_the_user_is_committing_to():
text = describe_prompt(
{
"approval": {
"phase": "solution_architecture",
"summary": "Cloud Run and Pub/Sub",
"deliverables": ["target_architecture"],
"target_architecture": {
"elements": 9,
"relationships": 11,
"checks": 23,
"not_applicable": [
{"recommendation": "DR-9", "reason": "Single region."}
],
},
}
}
)
assert "9 Elements, 11 Relationships and 23 Checks" in text
assert "No infrastructure code is written until you approve it" in text
assert "Recommendation DR-9 is treated as not applicable: Single region." in text