feat: serve Executions over A2A with a pre-approved /generate
Increment 7 of .scratch/solution-architect-agent/spec.md. - app/assembly.py: composition root building the engine from settings and the provider bundle (roles, ADK runtime, MCP catalog, Terraform tools, checkpointer, recorder). - app/a2a: a2a-sdk 1.1 JSON-RPC server (v0.3 compatible) mapping tasks to Executions; questions, Approvals and permissions pause as input-required; Approvals accepted only as structured data; completed tasks return the guide and code as artifacts; agent card derived from the dependency graph. - POST /generate runs a pre-approved Execution with the legacy keys. - Specialist exceptions are relayed to the user; Orchestrator exceptions fail the task. Engine accepts a caller-chosen execution id. - Dockerfile installs checksum-verified Terraform and ships agents, providers and skills; add mcp and a2a-sdk requirements. - 17 new tests; full suite 206 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
76
tests/execution/test_presentation.py
Normal file
76
tests/execution/test_presentation.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""Prompt text for plain clients and the /generate response mapping."""
|
||||
|
||||
import json
|
||||
|
||||
from app.execution.engine import Interaction
|
||||
from app.execution.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", "architecture_diagram"],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
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"]
|
||||
Reference in New Issue
Block a user