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>
This commit is contained in:
@@ -28,8 +28,17 @@ from app.workflows.deliverables import (
|
||||
check_submission,
|
||||
deliverables_in,
|
||||
)
|
||||
from app.workflows.target_architecture import (
|
||||
DIAGRAM_ATTACHMENT,
|
||||
GRAPH_ATTACHMENT,
|
||||
GraphError,
|
||||
TargetArchitecture,
|
||||
parse_graph,
|
||||
render_mermaid,
|
||||
)
|
||||
|
||||
ORCHESTRATOR = "orchestrator"
|
||||
_TARGET = DeliverableKind.TARGET_ARCHITECTURE
|
||||
CLOUD_READ = "cloud_read"
|
||||
|
||||
_NO_ARGS: Mapping[str, Any] = {"type": "object", "properties": {}}
|
||||
@@ -186,10 +195,23 @@ class OrchestratorToolbox:
|
||||
"summary": summary,
|
||||
"deliverables": [kind.value for kind in deliverables_in(phase_id)],
|
||||
}
|
||||
graph = self._target_architecture()
|
||||
if graph and phase_id is DEPENDENCY_GRAPH[_TARGET].phase:
|
||||
# What the user is approving before any code is written.
|
||||
self.approval["target_architecture"] = graph.summary()
|
||||
return ToolResult(
|
||||
f"Asked the user to approve {phase_id}.", TurnEnded("request_approval")
|
||||
)
|
||||
|
||||
def _target_architecture(self) -> TargetArchitecture | None:
|
||||
deliverable = self._deliverables.get(_TARGET.value)
|
||||
if not deliverable:
|
||||
return None
|
||||
try:
|
||||
return parse_graph(deliverable.get("attachments", {})[GRAPH_ATTACHMENT])
|
||||
except (KeyError, GraphError):
|
||||
return None
|
||||
|
||||
async def reopen(self, kind: str, reason: str) -> ToolResult:
|
||||
try:
|
||||
result = self.ledger.reopen(
|
||||
@@ -231,8 +253,13 @@ def specialist_tools(
|
||||
kind: DeliverableKind,
|
||||
extra: Sequence[ToolSpec],
|
||||
allow_cloud_read: bool | None,
|
||||
upstream: Mapping[str, Mapping[str, Any]] | None = None,
|
||||
) -> list[ToolSpec]:
|
||||
"""A Specialist's tools: submit, ask, and its role's tools with the cloud-read gate."""
|
||||
"""A Specialist's tools: submit, ask, and its role's tools with the cloud-read gate.
|
||||
|
||||
`upstream` is the Deliverables this one builds on; with it, a submission's links
|
||||
along the Requirements chain are checked.
|
||||
"""
|
||||
|
||||
async def submit_deliverable(content: str, attachments: Any = None) -> ToolResult:
|
||||
try:
|
||||
@@ -245,18 +272,34 @@ def specialist_tools(
|
||||
"attachment names must be relative paths without '..': "
|
||||
+ ", ".join(unsafe)
|
||||
)
|
||||
missing = check_submission(kind, content, attachments)
|
||||
missing = check_submission(kind, content, attachments, upstream)
|
||||
if missing:
|
||||
return ToolResult(
|
||||
"Not submitted. The Deliverable is missing: " + "; ".join(missing)
|
||||
)
|
||||
if kind is DeliverableKind.TARGET_ARCHITECTURE:
|
||||
# The diagram is a view of the graph, so the engine draws it.
|
||||
attachments[DIAGRAM_ATTACHMENT] = render_mermaid(
|
||||
parse_graph(attachments[GRAPH_ATTACHMENT])
|
||||
)
|
||||
return ToolResult(f"Submitted {kind}.", Submitted(content, attachments))
|
||||
|
||||
async def needs_input(questions: Sequence[str]) -> ToolResult:
|
||||
async def needs_input(
|
||||
questions: Sequence[str], draft: str | None = None, attachments: Any = None
|
||||
) -> ToolResult:
|
||||
questions = tuple(q for q in questions if q)
|
||||
if not questions:
|
||||
return _refused("ask at least one question")
|
||||
return ToolResult("Questions sent to the user.", NeedsInput(questions))
|
||||
try:
|
||||
draft_attachments = files_from_argument(attachments)
|
||||
except TypeError as exc:
|
||||
return _refused(f"attachments: {exc}")
|
||||
return ToolResult(
|
||||
"Questions sent to the user.",
|
||||
NeedsInput(
|
||||
questions, draft=draft or None, draft_attachments=draft_attachments
|
||||
),
|
||||
)
|
||||
|
||||
return [
|
||||
ToolSpec(
|
||||
@@ -274,9 +317,15 @@ def specialist_tools(
|
||||
),
|
||||
ToolSpec(
|
||||
"needs_input",
|
||||
"Ask the user questions you can't proceed without. Ends your turn.",
|
||||
"Ask the user questions you can't proceed without. Ends your turn. When "
|
||||
"you are asking them to confirm a draft, pass it as `draft` (with its "
|
||||
"`attachments`): it is returned to you with their answers.",
|
||||
_schema(
|
||||
{"questions": {"type": "array", "items": {"type": "string"}}},
|
||||
{
|
||||
"questions": {"type": "array", "items": {"type": "string"}},
|
||||
"draft": {"type": "string"},
|
||||
"attachments": FILES_SCHEMA,
|
||||
},
|
||||
["questions"],
|
||||
),
|
||||
needs_input,
|
||||
|
||||
Reference in New Issue
Block a user