feat: scoping is the first Phase, completed in conversation (iteration 9 step 2)
Some checks failed
validation / verify (push) Failing after 10s
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:
48
app/scope.py
48
app/scope.py
@@ -33,6 +33,10 @@ import yaml
|
||||
ASK, DECIDE, NOT_APPLICABLE = "ask", "decide", "not_applicable"
|
||||
MARKERS = (ASK, DECIDE, NOT_APPLICABLE)
|
||||
SUPPLIED, ASSUMED, UNKNOWN = "supplied", "assumed", "unknown"
|
||||
# Where a settled value came from: the spec file, the customer's request in prose,
|
||||
# an answer they gave in conversation, or the agent's own choice.
|
||||
REQUEST, ANSWERED = "request", "answered"
|
||||
SOURCES = (SUPPLIED, REQUEST, ANSWERED, ASSUMED)
|
||||
ESSENTIAL, IMPORTANT, OPTIONAL = "essential", "important", "optional"
|
||||
_SEVERITY = {ESSENTIAL: "HIGH", IMPORTANT: "MEDIUM", OPTIONAL: "LOW"}
|
||||
DRAFT, UNDER_REVIEW, APPROVED, LOCKED = (
|
||||
@@ -131,6 +135,13 @@ class Scope:
|
||||
values: dict[str, Any] = field(default_factory=dict) # field -> stated value
|
||||
states: dict[str, str] = field(default_factory=dict) # field -> marker
|
||||
supplied_text: str = ""
|
||||
# Where each value came from, when it was not the spec file; and what was said
|
||||
# about it: the reason for an assumption, the question an answer was given to.
|
||||
sources: dict[str, str] = field(default_factory=dict)
|
||||
notes: dict[str, str] = field(default_factory=dict)
|
||||
|
||||
def source(self, path: str) -> str:
|
||||
return self.sources.get(path, SUPPLIED)
|
||||
|
||||
@property
|
||||
def customer_case(self) -> str | None:
|
||||
@@ -163,16 +174,25 @@ class Scope:
|
||||
"""What the customer left to the agent, each with the default to take and
|
||||
what a wrong choice would change."""
|
||||
found: list[dict[str, str]] = []
|
||||
for path, state in self.states.items():
|
||||
if state != DECIDE:
|
||||
for path in self.catalogue.fields:
|
||||
chosen = path in self.values and self.source(path) == ASSUMED
|
||||
if not chosen and self.states.get(path) != DECIDE:
|
||||
continue
|
||||
spec = self.catalogue.fields[path]
|
||||
if chosen:
|
||||
statement = f"Assumed {path} is {self.values[path]}."
|
||||
if self.notes.get(path):
|
||||
statement += f" {self.notes[path]}"
|
||||
else:
|
||||
default = spec.default if spec.default is not None else "its choice"
|
||||
statement = (
|
||||
f"The customer left {path} to the agent. Default: {default}."
|
||||
)
|
||||
found.append(
|
||||
{
|
||||
"id": f"ASSUMP-{len(found) + 1:02d}",
|
||||
"field": path,
|
||||
"statement": f"The customer left {path} to the agent. "
|
||||
f"Default: {spec.default if spec.default is not None else 'the agent chooses'}.",
|
||||
"statement": statement,
|
||||
"impact_if_invalid": f"Changes {spec.affects}."
|
||||
if spec.affects
|
||||
else "Local to this field.",
|
||||
@@ -182,9 +202,11 @@ class Scope:
|
||||
|
||||
def readiness(self) -> dict[str, int]:
|
||||
states = list(self.states.values())
|
||||
came = [self.source(path) for path in self.values]
|
||||
return {
|
||||
SUPPLIED: len(self.values),
|
||||
ASSUMED: states.count(DECIDE),
|
||||
SUPPLIED: came.count(SUPPLIED) + came.count(REQUEST),
|
||||
ANSWERED: came.count(ANSWERED),
|
||||
ASSUMED: came.count(ASSUMED) + states.count(DECIDE),
|
||||
UNKNOWN: states.count(ASK),
|
||||
NOT_APPLICABLE: states.count(NOT_APPLICABLE),
|
||||
}
|
||||
@@ -204,7 +226,7 @@ class Scope:
|
||||
value = self.values.get(path, self.states.get(path, ASK))
|
||||
_put(document, path, value)
|
||||
_put(document, "metadata.status", status)
|
||||
provenance = {path: SUPPLIED for path in self.values}
|
||||
provenance = {path: self.source(path) for path in self.values}
|
||||
provenance |= {
|
||||
path: {DECIDE: ASSUMED, ASK: UNKNOWN, NOT_APPLICABLE: NOT_APPLICABLE}[state]
|
||||
for path, state in self.states.items()
|
||||
@@ -220,11 +242,19 @@ class Scope:
|
||||
choose, and what is unknown."""
|
||||
stated: dict[str, Any] = {}
|
||||
for path, value in self.values.items():
|
||||
if not path.startswith(("run.", "metadata.")):
|
||||
_put(stated, path, value)
|
||||
if path.startswith(("run.", "metadata.")) or self.source(path) == ASSUMED:
|
||||
continue
|
||||
_put(stated, path, value)
|
||||
return {
|
||||
"kind": self.kind,
|
||||
"stated": stated,
|
||||
# What the agent chose where the customer did not say. Not the
|
||||
# customer's decision: it may be revisited when they answer.
|
||||
"assumed": [
|
||||
{"field": path, "value": value, "why": self.notes.get(path, "")}
|
||||
for path, value in self.values.items()
|
||||
if self.source(path) == ASSUMED and not path.startswith("run.")
|
||||
],
|
||||
"to_decide": [
|
||||
{
|
||||
"field": path,
|
||||
|
||||
Reference in New Issue
Block a user