This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from app.execution.deliverables import (
|
||||
from app.workflows.deliverables import (
|
||||
DEPENDENCY_GRAPH,
|
||||
PHASE_ORDER,
|
||||
DeliverableKind,
|
||||
|
||||
@@ -9,11 +9,11 @@ import pytest
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
|
||||
|
||||
from app.agents.fake_runtime import Call, FakeAgentRuntime
|
||||
from app.agents.runtime import RoleSpec, ToolResult, ToolSpec
|
||||
from app.execution.deliverables import DEPENDENCY_GRAPH, DeliverableKind, PhaseId
|
||||
from app.execution.engine import ExecutionEngine
|
||||
from app.execution.recorder import InMemoryRecorder
|
||||
from app.adk.fake_runtime import Call, FakeAgentRuntime
|
||||
from app.adk.runtime import RoleSpec, ToolResult, ToolSpec
|
||||
from app.agent import ExecutionEngine
|
||||
from app.recorder import InMemoryRecorder
|
||||
from app.workflows.deliverables import DEPENDENCY_GRAPH, DeliverableKind, PhaseId
|
||||
|
||||
K = DeliverableKind
|
||||
P = PhaseId
|
||||
@@ -661,3 +661,28 @@ async def test_a_failing_specialist_is_relayed_to_the_user_as_a_question(tmp_pat
|
||||
assert question["from"] == "requirements"
|
||||
assert "model API unavailable" in question["question"]
|
||||
assert result.state["ledger"]["deliverables"]["requirements"]["status"] == "pending"
|
||||
|
||||
|
||||
async def test_pre_approved_questions_use_matching_scripted_answers(tmp_path):
|
||||
runtime = FakeAgentRuntime(
|
||||
{
|
||||
"orchestrator": [
|
||||
[ask_user("What is the RTO?", "Which region?")],
|
||||
[ask_user("Anything else?")],
|
||||
]
|
||||
}
|
||||
)
|
||||
engine = make_engine(tmp_path, runtime, max_orchestrator_turns=2)
|
||||
|
||||
result = await engine.start(
|
||||
"Ingestion",
|
||||
pre_approved=True,
|
||||
scripted_answers=[(r"\bRTO\b", "One hour."), ("region", "europe-west2")],
|
||||
)
|
||||
|
||||
first_reply = result.state["conversation"][2]["text"]
|
||||
assert "Q: What is the RTO?\nA: One hour." in first_reply
|
||||
assert "Q: Which region?\nA: europe-west2" in first_reply
|
||||
assert "No user is available" not in first_reply
|
||||
second_reply = result.state["conversation"][4]["text"]
|
||||
assert second_reply.startswith("No user is available")
|
||||
|
||||
72
tests/execution/test_file_arguments.py
Normal file
72
tests/execution/test_file_arguments.py
Normal file
@@ -0,0 +1,72 @@
|
||||
"""Files cross tool calls as a list of {path, content}: models rewrite object keys."""
|
||||
|
||||
import pytest
|
||||
|
||||
from app.adk.runtime import FILES_SCHEMA, Submitted, files_from_argument
|
||||
from app.tools.execution import specialist_tools
|
||||
from app.tools.local import TerraformRunner, local_tools
|
||||
from app.workflows.deliverables import DeliverableKind
|
||||
|
||||
GUIDANCE = (
|
||||
"# Deployment prerequisites\n\nx\n\n# Step-by-step deployment instructions\n\ny\n"
|
||||
)
|
||||
|
||||
|
||||
def test_files_are_offered_as_a_list_of_path_and_content():
|
||||
assert FILES_SCHEMA["type"] == "array"
|
||||
assert FILES_SCHEMA["items"]["required"] == ["path", "content"]
|
||||
|
||||
|
||||
def test_file_arguments_accept_lists_and_maps():
|
||||
as_list = [{"path": "terraform/main.tf", "content": "a"}]
|
||||
|
||||
assert files_from_argument(as_list) == {"terraform/main.tf": "a"}
|
||||
assert files_from_argument({"terraform/main.tf": "a"}) == {"terraform/main.tf": "a"}
|
||||
assert files_from_argument(None) == {}
|
||||
with pytest.raises(TypeError):
|
||||
files_from_argument(["terraform/main.tf"])
|
||||
|
||||
|
||||
async def test_submission_takes_attachments_as_a_list():
|
||||
submit = specialist_tools(
|
||||
DeliverableKind.DEPLOYMENT_GUIDANCE, extra=[], allow_cloud_read=False
|
||||
)[0]
|
||||
|
||||
result = await submit.handler(
|
||||
content=GUIDANCE,
|
||||
attachments=[
|
||||
{"path": "terraform/main.tf", "content": "resource {}"},
|
||||
{"path": "terraform/variables.tf", "content": ""},
|
||||
],
|
||||
)
|
||||
|
||||
assert result.outcome == Submitted(
|
||||
GUIDANCE, {"terraform/main.tf": "resource {}", "terraform/variables.tf": ""}
|
||||
)
|
||||
|
||||
|
||||
async def test_malformed_attachments_are_refused_to_the_agent():
|
||||
submit = specialist_tools(
|
||||
DeliverableKind.DEPLOYMENT_GUIDANCE, extra=[], allow_cloud_read=False
|
||||
)[0]
|
||||
|
||||
result = await submit.handler(content=GUIDANCE, attachments=["terraform/main.tf"])
|
||||
|
||||
assert result.outcome is None
|
||||
assert result.message.startswith("Refused: attachments")
|
||||
|
||||
|
||||
async def test_terraform_tools_take_files_as_a_list():
|
||||
received = {}
|
||||
|
||||
class Runner(TerraformRunner):
|
||||
async def validate(self, files):
|
||||
received.update(files)
|
||||
return await super().validate({})
|
||||
|
||||
(validate,) = local_tools(["terraform_validate"], Runner())
|
||||
|
||||
await validate.handler(files=[{"path": "terraform/main.tf", "content": "x"}])
|
||||
|
||||
assert validate.parameters["properties"]["files"]["type"] == "array"
|
||||
assert received == {"terraform/main.tf": "x"}
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from app.execution.deliverables import DeliverableKind as K
|
||||
from app.execution.deliverables import PhaseId as P
|
||||
from app.execution.ledger import (
|
||||
from app.states.ledger import (
|
||||
DeliverableStatus,
|
||||
Ledger,
|
||||
LedgerRefusal,
|
||||
PhaseStatus,
|
||||
)
|
||||
from app.workflows.deliverables import DeliverableKind as K
|
||||
from app.workflows.deliverables import PhaseId as P
|
||||
|
||||
|
||||
def produce(ledger: Ledger, *kinds: K) -> None:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""The design advisor's fan-out to one advisor per architecture-framework pillar."""
|
||||
|
||||
from app.agents.fake_runtime import Call, FakeAgentRuntime
|
||||
from app.agents.roles import PILLAR_ADVISOR
|
||||
from app.agents.runtime import RoleSpec, ToolResult, ToolSpec
|
||||
from app.execution.pillars import CONSULT_TOOL, pillar_consultation_tool
|
||||
from app.execution.toolkit import make_tool_factory
|
||||
from app.adk.fake_runtime import Call, FakeAgentRuntime
|
||||
from app.adk.roles import PILLAR_ADVISOR
|
||||
from app.adk.runtime import RoleSpec, ToolResult, ToolSpec
|
||||
from app.tools.pillars import CONSULT_TOOL, pillar_consultation_tool
|
||||
from app.tools.toolkit import make_tool_factory
|
||||
|
||||
PILLARS = {
|
||||
"security": "waf-security",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import json
|
||||
|
||||
from app.execution.engine import Interaction
|
||||
from app.execution.presentation import describe_prompt, to_generate_response
|
||||
from app.agent import Interaction
|
||||
from app.presentation import describe_prompt, to_generate_response
|
||||
|
||||
|
||||
def test_approval_prompt_explains_the_structured_reply():
|
||||
|
||||
@@ -6,11 +6,11 @@ import pytest
|
||||
from langgraph.checkpoint.memory import InMemorySaver
|
||||
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
|
||||
|
||||
from app.checkpointing import open_checkpointer
|
||||
from app.config import get_settings
|
||||
from app.database import DatabaseManager
|
||||
from app.execution.checkpointing import open_checkpointer
|
||||
from app.execution.ledger import LedgerEvent
|
||||
from app.execution.recorder import DatabaseRecorder
|
||||
from app.recorder import DatabaseRecorder
|
||||
from app.states.ledger import LedgerEvent
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user