Files
gcp_solution_architecture_a…/tests/execution/test_intake.py
Jonathan Boniface 5ef434d00e 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>
2026-10-09 11:38:15 +01:00

65 lines
2.5 KiB
Python

"""Intake: what a message that starts something is asking for."""
import json
from app.adk.fake_runtime import FakeDecider
from app.adk.runtime import Answer, NoDecider
from app.nodes.intake import CHANGE_REQUEST, NEW_REQUEST, QUESTION, Intake
def delivered(tmp_path, case: str, statuses: list[str]) -> None:
folder = tmp_path / "deliverables" / "cases" / case / "intent"
folder.mkdir(parents=True)
intents = [
{
"version": n,
"workflow_request": f"Design thing {n}.",
"status": status,
"execution_id": f"v{n}",
}
for n, status in enumerate(statuses, start=1)
]
(folder / "history.json").write_text(
json.dumps({"customer_case": case, "intents": intents})
)
async def test_without_a_decision_every_message_is_a_new_request(tmp_path):
reading = await Intake(NoDecider(), tmp_path).read("What can you do?")
assert reading.kind == NEW_REQUEST and not reading.judged
async def test_a_confident_question_is_read_as_one(tmp_path):
decider = FakeDecider({"intake": Answer(QUESTION, 0.98)})
reading = await Intake(decider, tmp_path).read("How long does it take?", scope="t1")
state, questions, scope = decider.asked[0]
assert reading.kind == QUESTION and reading.judged
assert scope == "t1"
assert questions["intake"].options == (NEW_REQUEST, CHANGE_REQUEST, QUESTION)
assert state.endswith("The user's message: How long does it take?")
async def test_a_reading_that_is_not_sure_enough_starts_new_work(tmp_path):
decider = FakeDecider({"intake": Answer(QUESTION, 0.6)})
assert (await Intake(decider, tmp_path, act=0.75).read("hello")).kind == NEW_REQUEST
async def test_a_change_needs_something_delivered_to_change(tmp_path):
decider = FakeDecider({"intake": Answer(CHANGE_REQUEST, 0.99)})
delivered(tmp_path, "acme", ["completed", "in_progress"])
intake = Intake(decider, tmp_path)
with_history = await intake.read("Raise availability to 99.99%.", "acme")
without = await intake.read("Raise availability to 99.99%.", "new-client")
no_case = await intake.read("Raise availability to 99.99%.")
assert with_history.kind == CHANGE_REQUEST and with_history.earlier == 1
assert with_history.latest == "v1" # what the change would change
assert "- Design thing 1." in decider.asked[0][0]
assert "Design thing 2." not in decider.asked[0][0] # still in progress
assert without.kind == NEW_REQUEST and no_case.kind == NEW_REQUEST