feat: Change requests against a Baseline (ADR-0006)

A caller restates a request to say how requirements have changed, naming a
completed Execution of the same Customer case as the Baseline.

- app/baseline.py reads a Baseline from its files and refuses one that
  does not exist, did not complete or belongs to another case, before
  anything runs or is recorded. A Baseline is never modified.
- Requirements carry a change (unchanged, added, changed, removed) and a
  reason. Submission is refused when a Baseline requirement disappears, an
  id is reused, or an unchanged requirement's text differs. A removed
  requirement stays on record and asks nothing downstream.
- Each Specialist starts from its delivered version; the graph and the code
  are its working copy, and the description is carried over when the
  design's shape is the same.
- app/workflows/changes.py compares versions by id and traces what each
  changed requirement reaches; anything else that changed is listed as
  unrequested. Approvals show the change for their Phase, and changes.json
  is written with the full Deliverables.
- Intake no longer starts a message read as a change: it names the
  Execution to give as the Baseline.
- A fifth evaluation case runs a request and then a change to it, with
  four checks that the change is recorded, reaches Checks, stays contained
  and costs less than its Baseline.

Tested with scripted agents only; no Change request has run with real
models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 11:38:15 +01:00
parent db28d02f56
commit 5ef434d00e
32 changed files with 1824 additions and 40 deletions

View File

@@ -36,6 +36,7 @@ from app.tools.workspace import (
working_verdicts,
)
from app.workflows.chain import VERDICTS_FILE, read_graph
from app.workflows.changes import change_summary, changes_for
from app.workflows.deliverables import (
DEPENDENCY_GRAPH,
DeliverableKind,
@@ -82,10 +83,13 @@ class OrchestratorToolbox:
ledger: Ledger,
deliverables: Mapping[str, Mapping[str, Any]],
pending_questions: Sequence[Mapping[str, Any]],
baseline: Mapping[str, Any] | None = None,
) -> None:
self.ledger = ledger
self._deliverables = deliverables
self._pending_questions = pending_questions
# A Change request's Baseline: with it, an Approval shows what changed.
self._baseline = baseline
self.started: dict[DeliverableKind, int] = {}
self.questions: list[dict[str, str]] = []
self.approval: dict[str, Any] | None = None
@@ -213,6 +217,14 @@ class OrchestratorToolbox:
"summary": summary,
"deliverables": [kind.value for kind in deliverables_in(phase_id)],
}
if self._baseline:
# Worked out from the ids, not written by an agent: what this Phase's
# Deliverables add, change and remove against the Baseline.
self.approval["baseline"] = self._baseline.get("execution_id")
self.approval["changes"] = changes_for(
change_summary(self._baseline.get("deliverables"), self._deliverables),
self.approval["deliverables"],
)
graph = self._target_architecture()
if graph and phase_id is DEPENDENCY_GRAPH[_TARGET].phase:
# What the user is approving before any code is written.
@@ -271,6 +283,7 @@ def specialist_tools(
library: Mapping[str, Mapping[str, Any]] | None = None,
review: Callable[[Mapping[str, str]], Awaitable[Sequence[str]]] | None = None,
confirm_first: bool = False,
baseline: Mapping[str, Any] | None = None,
) -> list[ToolSpec]:
"""A Specialist's tools: submit, ask, its working copy, and its role's tools with
the cloud-read gate.
@@ -284,6 +297,7 @@ def specialist_tools(
`confirm_first` is set while a user is present and has not yet been asked about
this Deliverable: a submission is then refused until the Specialist has put its
draft to them. A rule, because an instruction alone was not always followed.
`baseline` is the Baseline's version of this Deliverable in a Change request.
"""
working = {} if working is None else working
is_graph = kind is DeliverableKind.TARGET_ARCHITECTURE
@@ -319,7 +333,9 @@ def specialist_tools(
"attachment names must be relative paths without '..': "
+ ", ".join(unsafe)
)
missing = check_submission(kind, content, attachments, upstream)
missing = check_submission(
kind, content, attachments, upstream, baseline=baseline
)
if missing:
return ToolResult(
"Not submitted. The Deliverable is missing: " + "; ".join(missing)