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:
@@ -387,3 +387,66 @@ def test_a_pre_approved_task_is_not_read_as_a_question(tmp_path):
|
||||
assert task["status"]["state"] == "TASK_STATE_COMPLETED"
|
||||
assert decider.asked == []
|
||||
assert runtime.runs
|
||||
|
||||
|
||||
def delivered_case(tmp_path: Path, case: str = "acme") -> None:
|
||||
folder = tmp_path / "deliverables" / "cases" / case / "intent"
|
||||
folder.mkdir(parents=True)
|
||||
(folder / "history.json").write_text(
|
||||
'{"customer_case": "acme", "intents": [{"version": 1, "workflow_request": '
|
||||
'"Design ingestion.", "execution_id": "v1", "status": "completed"}]}'
|
||||
)
|
||||
|
||||
|
||||
def test_a_change_to_delivered_work_names_the_baseline_and_starts_nothing(tmp_path):
|
||||
delivered_case(tmp_path)
|
||||
decider = FakeDecider({"intake": Answer("change_request", 0.98)})
|
||||
client, runtime = client_for(tmp_path, {}, decider)
|
||||
with client:
|
||||
task = send(
|
||||
client,
|
||||
[{"text": "Availability must now be 99.99%."}],
|
||||
metadata={"customer_case": "acme"},
|
||||
)
|
||||
|
||||
text, data = status_parts(task)
|
||||
assert task["status"]["state"] == "TASK_STATE_COMPLETED"
|
||||
assert 'send this again with "baseline" set to "v1"' in text
|
||||
assert data == {"status": "answered", "intake": "change_request", "baseline": "v1"}
|
||||
assert runtime.runs == []
|
||||
|
||||
|
||||
def test_a_caller_who_says_it_is_new_work_is_not_second_guessed(tmp_path):
|
||||
delivered_case(tmp_path)
|
||||
decider = FakeDecider({"intake": Answer("change_request", 0.98)})
|
||||
turns = {"orchestrator": [[Call("ask_user", {"questions": ["Which region?"]})]]}
|
||||
client, runtime = client_for(tmp_path, turns, decider)
|
||||
with client:
|
||||
task = send(
|
||||
client,
|
||||
[{"text": "Availability must now be 99.99%."}],
|
||||
metadata={"customer_case": "acme", "new_request": True},
|
||||
)
|
||||
|
||||
assert task["status"]["state"] == "TASK_STATE_INPUT_REQUIRED"
|
||||
assert decider.asked == [] and len(runtime.runs) == 1
|
||||
|
||||
|
||||
def test_a_baseline_that_cannot_be_one_fails_the_task_and_generate(tmp_path):
|
||||
client, runtime = client_for(tmp_path, {})
|
||||
with client:
|
||||
task = send(
|
||||
client,
|
||||
[{"text": "A change."}],
|
||||
metadata={"customer_case": "acme", "baseline": "nope"},
|
||||
)
|
||||
response = client.post(
|
||||
"/generate",
|
||||
json={"request": "A change.", "customer_case": "acme", "baseline": "nope"},
|
||||
)
|
||||
|
||||
assert task["status"]["state"] == "TASK_STATE_FAILED"
|
||||
assert "is not an Execution of Customer case acme" in status_parts(task)[0]
|
||||
assert response.status_code == 400
|
||||
assert "is not an Execution of Customer case acme" in response.json()["error"]
|
||||
assert runtime.runs == []
|
||||
|
||||
Reference in New Issue
Block a user