feat: scoping is the first Phase, completed in conversation (iteration 9 step 2)
Some checks failed
validation / verify (push) Failing after 10s

Every Execution now begins by agreeing the scope, before requirements.

- A new Phase and Deliverable, produced by a scope analyst with two tools:
  scope_read shows what is settled and what is not; scope_set records fields
  with where each value came from (the request, the customer's answer, or an
  assumption with its reason). Code checks each value against the catalogue.
- With someone present the analyst asks for what is missing; with nobody
  present it assumes it, visibly. With no spec it drafts one from the request.
  A value the customer stated in the file is changed only by their own answer.
- A submission cannot leave an essential field unknown. Code writes the
  completed spec, the data every later Specialist reads, and the information
  register, from what was recorded.
- The spec's status follows the Execution: under review, approved, then
  locked as a Baseline. A Change request starts from the delivered scope.
- The requirements analyst derives from the agreed scope and no longer asks
  for what it settles.

About 80 tests assumed requirements came first; tests/scoped.py runs scoping
ahead of a test's own script, and tests about order and counts are updated.
Not run with real models.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 18:17:32 +01:00
parent afe78640f8
commit 545097530b
38 changed files with 1054 additions and 123 deletions

View File

@@ -25,6 +25,9 @@ from app.nodes.router import (
)
from app.recorder import InMemoryRecorder
from app.workflows.deliverables import DEPENDENCY_GRAPH, DeliverableKind
from tests.scoped import ScopedEngine as ExecutionEngine # noqa: F811
from tests.scoped import ScopedRuntime as FakeAgentRuntime # noqa: F811
from tests.scoped import scoped_ledger
K = DeliverableKind
@@ -122,6 +125,8 @@ async def test_an_execution_completes_with_no_model_choosing_an_action(tmp_path)
assert result.status == "completed"
assert "orchestrator" not in {run.role for run in runtime.runs}
assert actions(result) == [
"delegate", # the scope
"request_approval",
"delegate", # requirements
"delegate", # technical decomposition
"request_approval",
@@ -198,14 +203,18 @@ async def test_the_approval_summary_is_assembled_from_the_data(tmp_path):
async def test_a_model_writes_the_summary_but_decides_nothing(tmp_path):
turns = {
**once(),
REPLY_WRITER: [[Call("write_reply", {"text": "Two requirements, ready."})]],
REPLY_WRITER: [
[Call("write_reply", {"text": "The scope, ready."})],
[Call("write_reply", {"text": "Two requirements, ready."})],
],
}
engine, runtime = engine_for(tmp_path, turns, writer=True)
first = await engine.start("Ingest webhooks")
assert first.prompt["approval"]["summary"] == "Two requirements, ready."
writer_run = next(run for run in runtime.runs if run.role == REPLY_WRITER)
# The writer ran once for the scope and once for the requirements.
writer_run = [run for run in runtime.runs if run.role == REPLY_WRITER][-1]
assert writer_run.tools == ("write_reply",)
assert writer_run.task.context["facts"]["deliverables"] == [
"requirements",
@@ -478,6 +487,7 @@ async def test_a_requested_change_is_routed_to_the_deliverable_it_affects(tmp_pa
[(state, questions, _)] = decider.asked
assert "The user's message: Use customer-managed keys on the topic." in state
assert questions["change_target"].options == (
"scope",
"requirements",
"technical_decomposition",
"product_selection",
@@ -689,9 +699,8 @@ def test_a_quoted_question_is_removed_from_what_the_user_said():
async def test_the_questions_asked_are_given_to_the_decider_as_background(tmp_path):
from app.nodes.router import TurnView
from app.states.ledger import Ledger
ledger = Ledger()
ledger = scoped_ledger()
ledger.start([K.REQUIREMENTS], actor="orchestrator")
ledger.submit(K.REQUIREMENTS, 1, actor="requirements-analyst")
decider = FakeDecider(
@@ -765,9 +774,8 @@ async def test_a_reply_that_restates_what_is_agreed_is_an_answer_not_a_change(
):
"""Evaluation case 04: a requirement said again in reply to a later question."""
from app.nodes.router import Readings, TurnView
from app.states.ledger import Ledger
ledger = Ledger()
ledger = scoped_ledger()
ledger.start([K.REQUIREMENTS], actor="orchestrator")
ledger.submit(K.REQUIREMENTS, 1, actor="requirements-analyst")
view = TurnView(