feat: start an Execution from a scope spec (ADR-0008, iteration 9 step 1)
Some checks failed
validation / verify (push) Failing after 10s
Some checks failed
validation / verify (push) Failing after 10s
A scope spec is a YAML file of what the customer wants and the facts a design depends on, complete or partly filled. It sits beside the Intent, which stays in the customer's words. - skills/scoping holds a provider-neutral catalogue of 63 fields; the Cloud provider's bundle supplies the values it allows for the fields left to it. - app/scope.py reads a spec against the catalogue with no model: it refuses an unknown field or a value of the wrong type, and yields what is stated, what is left to the agent, what is unknown and how pressing each gap is. A field may say ask, decide or not_applicable. - ExecutionEngine.start(scope=...), /generate, A2A metadata and evaluation cases accept one. Its statement is the request, its engagement reference names the Customer case, and its run options apply. A pre-approved start is refused when an essential field is not settled. - The spec as supplied is kept unaltered beside a completed copy with assumptions, gaps, provenance, readiness and a status. - Every Specialist is shown the spec and given the Skill: a stated choice binds, exclusions are out of scope. - Covers workloads and platform foundations; case-08-landing-zone starts from a benchmark spec. Plans for scoping (iteration 9) and the work breakdown structure (iteration 10, nothing built), and the design spec they come from. Not run with real models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
76
app/agent.py
76
app/agent.py
@@ -46,6 +46,7 @@ from app.nodes.router import (
|
||||
)
|
||||
from app.providers import ProviderBundle, load_provider
|
||||
from app.recorder import DatabaseRecorder, ExecutionRecorder
|
||||
from app.scope import ESSENTIAL, Catalogue, Scope, read_scope, slug
|
||||
from app.skills.agent_skills import discover_skills, skill_version
|
||||
from app.states.execution_state import check_customer_case
|
||||
from app.states.ledger import Ledger
|
||||
@@ -106,6 +107,9 @@ class ExecutionEngine:
|
||||
assess_at_end: bool = False,
|
||||
modules_available: bool = False,
|
||||
default_modules: bool = False,
|
||||
scope_catalogue: Catalogue | None = None,
|
||||
scope_values: Mapping[str, Sequence[str]] | None = None,
|
||||
scope_skill: str | None = None,
|
||||
) -> None:
|
||||
required = {
|
||||
ORCHESTRATOR,
|
||||
@@ -115,6 +119,11 @@ class ExecutionEngine:
|
||||
if missing:
|
||||
raise ValueError(f"Missing roles: {', '.join(missing)}")
|
||||
self._max_revisions = max_revisions
|
||||
# The catalogue a scope spec is read against (ADR-0008); None when this
|
||||
# deployment's Cloud provider has none.
|
||||
self._scope_catalogue = scope_catalogue
|
||||
self._scope_values = dict(scope_values or {})
|
||||
self._scope_skill = scope_skill
|
||||
# Whether the Cloud provider approves any module sources, and whether an
|
||||
# Execution uses them when its caller does not say.
|
||||
self._modules_available = modules_available
|
||||
@@ -154,13 +163,14 @@ class ExecutionEngine:
|
||||
*,
|
||||
session_id: str | None = None,
|
||||
customer_case: str | None = None,
|
||||
pre_approved: bool = False,
|
||||
pre_approved: bool | None = None,
|
||||
allow_cloud_read: bool | None = None,
|
||||
execution_id: str | None = None,
|
||||
scripted_answers: Sequence[Sequence[str]] = (),
|
||||
baseline: str | None = None,
|
||||
overlay_skills: Sequence[str] = (),
|
||||
terraform_modules: bool | None = None,
|
||||
scope: str | Mapping[str, Any] | None = None,
|
||||
) -> Interaction:
|
||||
"""Start an Execution. `scripted_answers` are (regex, answer[, asker]) entries a
|
||||
pre-approved Execution uses to answer questions, for evaluation runs.
|
||||
@@ -180,7 +190,50 @@ class ExecutionEngine:
|
||||
does as its Baseline did and any other Execution takes the deployment's
|
||||
default, which is plain resources. Opting in is refused when the provider
|
||||
approves no sources.
|
||||
|
||||
`scope` is a scope spec (ADR-0008), as YAML text or already parsed. It may
|
||||
be complete or partly filled. The start is refused when it names a field
|
||||
the catalogue does not have or holds a value of the wrong type, and, for a
|
||||
pre-approved Execution, when an essential field is not settled: nobody is
|
||||
there to ask. What the spec states under `run` applies where the caller
|
||||
gave no value of their own. Its statement of intent is the request when
|
||||
none is given.
|
||||
"""
|
||||
read = self._read_scope(scope) if scope is not None else None
|
||||
if read is not None:
|
||||
run = read.values
|
||||
if pre_approved is None:
|
||||
pre_approved = bool(run.get("run.pre_approved", False))
|
||||
if allow_cloud_read is None and "run.allow_cloud_read" in run:
|
||||
allow_cloud_read = bool(run["run.allow_cloud_read"])
|
||||
if terraform_modules is None and "run.terraform_modules" in run:
|
||||
terraform_modules = bool(run["run.terraform_modules"])
|
||||
overlay_skills = [*overlay_skills, *run.get("run.overlay_skills", [])]
|
||||
if (
|
||||
customer_case
|
||||
and read.customer_case
|
||||
and slug(customer_case) != (read.customer_case)
|
||||
):
|
||||
raise ValueError(
|
||||
f"The scope spec is for {read.customer_case}, and this was "
|
||||
f"started for {customer_case}."
|
||||
)
|
||||
customer_case = customer_case or read.customer_case
|
||||
# The spec's statement is the customer's; it is what gets recorded.
|
||||
workflow_request = read.statement or workflow_request
|
||||
missing = read.gaps(ESSENTIAL)
|
||||
if pre_approved and missing:
|
||||
raise ValueError(
|
||||
"The scope spec leaves essential fields unsettled, and a "
|
||||
"pre-approved Execution has nobody to ask: "
|
||||
+ ", ".join(gap["field"] for gap in missing)
|
||||
+ ". Give each a value, or `decide` to leave it to the agent."
|
||||
)
|
||||
pre_approved = bool(pre_approved)
|
||||
if not workflow_request.strip():
|
||||
raise ValueError(
|
||||
"A request is needed: text, or a scope spec with a statement."
|
||||
)
|
||||
customer_case = check_customer_case(customer_case)
|
||||
execution_id = execution_id or str(uuid.uuid4())
|
||||
if await self._exists(execution_id):
|
||||
@@ -224,6 +277,8 @@ class ExecutionEngine:
|
||||
session_id=session_id,
|
||||
workflow_request=workflow_request,
|
||||
baseline=baseline or None,
|
||||
scope_supplied=scope if isinstance(scope, str) else None,
|
||||
scope_completed=read.completed(read.status(pre_approved)) if read else None,
|
||||
)
|
||||
initial: dict[str, Any] = {
|
||||
"execution_id": execution_id,
|
||||
@@ -236,6 +291,15 @@ class ExecutionEngine:
|
||||
# Overlay Skills this Execution loads, each with the version it had.
|
||||
"overlay_skills": {name: self._overlays[name] for name in chosen},
|
||||
"terraform_modules": terraform_modules,
|
||||
# What the customer's scope spec settles and leaves open; None without one.
|
||||
"scope": {
|
||||
"skill": self._scope_skill,
|
||||
"status": read.status(pre_approved),
|
||||
"readiness": read.readiness(),
|
||||
"context": read.for_context(),
|
||||
}
|
||||
if read
|
||||
else None,
|
||||
"risks": [],
|
||||
"pre_approved": pre_approved,
|
||||
"allow_cloud_read": allow_cloud_read,
|
||||
@@ -274,6 +338,13 @@ class ExecutionEngine:
|
||||
await self._graph.ainvoke(initial, self._config(execution_id))
|
||||
return await self.interaction(execution_id)
|
||||
|
||||
def _read_scope(self, supplied: str | Mapping[str, Any]) -> Scope:
|
||||
if self._scope_catalogue is None:
|
||||
raise ValueError("This deployment has no scope spec catalogue.")
|
||||
return read_scope(
|
||||
supplied, self._scope_catalogue, provider_values=self._scope_values
|
||||
)
|
||||
|
||||
async def resume(self, execution_id: str, reply: Mapping[str, Any]) -> Interaction:
|
||||
"""Answer the Execution's current prompt: {"reply"} | {"approval"} | {"permission"}."""
|
||||
current = await self.interaction(execution_id)
|
||||
@@ -517,6 +588,9 @@ async def open_assembly(
|
||||
else None,
|
||||
skill_threshold=settings.JEV_SKILL_THRESHOLD,
|
||||
assess_at_end=settings.JEV_ASSESS_EXECUTIONS,
|
||||
scope_catalogue=bundle.scope_catalogue() if bundle.scope_skill else None,
|
||||
scope_values=bundle.scope_values,
|
||||
scope_skill=bundle.scope_skill,
|
||||
modules_available=bool(bundle.terraform_module_namespaces),
|
||||
default_modules=settings.TERRAFORM_MODULES,
|
||||
overlays={
|
||||
|
||||
Reference in New Issue
Block a user