feat: consult only the pillars a change affects directly (iteration 5 step 3)

A graded question per pillar (not at all, only indirectly, directly) picks
the pillar advisors to consult again on a Revision or a Change request; the
design advisor is told which, and keeps its earlier advice for the rest. As
a yes or no the answer was yes for nearly every pillar of every change.

A completed Execution now writes working.json with each pillar's advice
and checklist review, and a Change request starts from its Baseline's, so
only the pillars a change touches are consulted afresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 15:22:57 +01:00
parent a7bc5310f3
commit 844987587c
10 changed files with 290 additions and 4 deletions

View File

@@ -631,3 +631,85 @@ async def test_a_change_request_writes_changes_json_and_a_full_set_of_files(tmp_
assert set(manifest["deliverables"]) == {kind.value for kind in DEPENDENCY_GRAPH}
assert (case / "v2" / "solution-architecture-guide.md").is_file()
assert not (case / "v1" / "changes.json").exists()
# --- only the pillars a change touches are consulted again ------------------------------
async def test_a_change_request_starts_from_the_baselines_pillar_advice(tmp_path):
"""The design advisor is told which pillars the change affects, and has the
Baseline's advice for the rest."""
from app.adk.fake_runtime import FakeDecider
from app.adk.runtime import Answer
from app.tools.pillars import ADVICE_KEY
await delivered(tmp_path)
# A Baseline whose design advisor consulted two pillars.
folder = tmp_path / "deliverables" / "cases" / CASE / "executions" / "v1"
advice = {"security": "Use a dedicated identity.", "reliability": "Two zones."}
(folder / "working.json").write_text(
json.dumps({"design_recommendations": {ADVICE_KEY: advice}})
)
seen: dict = {}
def advisor(task):
seen["pillars_to_consult"] = task.context["pillars_to_consult"]
return [sample_submission(K.DESIGN_RECOMMENDATIONS)]
decider = FakeDecider(
{"security": Answer(0.3, 0.8), "reliability": Answer(1.9, 0.9)}
)
runtime = FakeAgentRuntime(changed(**{"design-advisor": [advisor]}))
engine = ExecutionEngine(
runtime=runtime,
roles=ROLES,
recorder=InMemoryRecorder(),
checkpointer=InMemorySaver(),
output_root=tmp_path,
orchestrator=Router(NoDecider(), None, Thresholds()),
decider=decider,
)
result = await engine.start(
"Availability goes up.",
customer_case=CASE,
pre_approved=True,
execution_id="v2",
baseline="v1",
)
assert seen["pillars_to_consult"] == ["reliability"]
state, _, _ = decider.asked[0]
assert "Requirement NFR-1 changed: 99.99% availability." in state
# The advice is carried into the new Execution, and written for the next change.
assert result.state["working"]["design_recommendations"][ADVICE_KEY] == advice
assert json.loads((folder.parent / "v2" / "working.json").read_text()) == {
"design_recommendations": {ADVICE_KEY: advice}
}
async def test_a_first_consultation_is_given_no_hint(tmp_path):
seen: dict = {}
def advisor(task):
seen["pillars_to_consult"] = task.context["pillars_to_consult"]
return [sample_submission(K.DESIGN_RECOMMENDATIONS)]
from app.adk.fake_runtime import FakeDecider
decider = FakeDecider({})
turns = once()
turns["design-advisor"] = [advisor]
engine = ExecutionEngine(
runtime=FakeAgentRuntime(turns),
roles=ROLES,
recorder=InMemoryRecorder(),
checkpointer=InMemorySaver(),
output_root=tmp_path,
orchestrator=Router(NoDecider(), None, Thresholds()),
decider=decider,
)
await engine.start("Ingest webhooks", pre_approved=True)
assert seen["pillars_to_consult"] is None and decider.asked == []

View File

@@ -408,3 +408,59 @@ async def test_with_no_review_nothing_is_added():
result = await submit.handler(**sample_submission(kind).args)
assert REVIEW_HEADING not in result.outcome.content
# --- only the pillars a change touches are consulted again -------------------------------
async def test_a_change_names_the_pillars_it_affects_directly():
from app.adk.fake_runtime import FakeDecider
from app.adk.runtime import Answer
from app.tools.pillars import pillars_touched
decider = FakeDecider(
{
"security": Answer(1.9, 0.9),
"reliability": Answer(1.0, 0.6),
"sustainability": Answer(0.2, 0.8),
}
)
chosen = await pillars_touched(
decider, list(PILLARS), "Use customer-managed keys.", scope="e1"
)
state, questions, scope = decider.asked[0]
assert chosen == ["security"]
assert scope == "e1" and state.endswith("Use customer-managed keys.")
assert questions["security"].kind == "score"
assert questions["security"].options == (
"not at all",
"only indirectly",
"directly",
)
async def test_a_change_that_touches_no_pillar_is_an_answer_and_no_decision_is_not():
from app.adk.fake_runtime import FakeDecider
from app.adk.runtime import Answer, NoDecider
from app.tools.pillars import pillars_touched
nothing = FakeDecider(dict.fromkeys(PILLARS, Answer(0.0, 0.99)))
assert await pillars_touched(nothing, list(PILLARS), "Rename a page.") == []
assert await pillars_touched(NoDecider(), list(PILLARS), "Rename a page.") is None
assert await pillars_touched(nothing, list(PILLARS), " ") is None
async def test_an_empty_list_of_pillars_consults_none_and_returns_what_was_said():
memory: dict = {}
runtime = FakeAgentRuntime({PILLAR_ADVISOR: [turn_for_pillar] * 3})
tool = pillar_consultation_tool(runtime, ADVISOR, PILLARS, memory=memory)
await consult(tool, brief="b")
again = await consult(tool, brief="b", pillars=[])
assert len(runtime.runs) == 3 # nobody was consulted a second time
for pillar in PILLARS:
assert f"## {pillar} (from your earlier consultation)" in again.message