Files
orchestration_engine/tests/execution/test_presentation.py

101 lines
3.3 KiB
Python

"""Prompt text for plain clients and the /generate response mapping."""
import json
from execution_engine.agent import Interaction
from tests.reference_workflow.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