Python · 2326 bytes Raw Blame History
1 """Tests for durable workflow-ledger semantics."""
2
3 from __future__ import annotations
4
5 from loader.runtime.workflow import ArtifactEvidence, ArtifactFreshness, ClarifyBrief
6 from loader.runtime.workflow_ledger import (
7 WorkflowLedger,
8 apply_freshness_to_workflow_ledger,
9 seed_workflow_ledger_from_acceptance_criteria,
10 seed_workflow_ledger_from_brief,
11 workflow_ledger_highlights,
12 )
13
14
15 def test_workflow_ledger_seeds_from_brief_and_tracks_drift() -> None:
16 brief = ClarifyBrief(
17 task_statement="Keep the runtime artifact aligned with the actual work.",
18 assumptions=["notes.txt stays out of scope unless clarified otherwise."],
19 acceptance_criteria=["planned.txt exists in the workspace root."],
20 decision_boundaries=["Escalate before broad UX changes."],
21 )
22 brief.fill_defaults()
23
24 ledger = seed_workflow_ledger_from_brief(WorkflowLedger(), brief)
25 ledger = seed_workflow_ledger_from_acceptance_criteria(
26 ledger,
27 ["planned.txt exists in the workspace root."],
28 phase="plan",
29 )
30 freshness = ArtifactFreshness(
31 evidence=[
32 ArtifactEvidence(
33 kind="contradicted_assumption",
34 summary="Clarify scope assumed `notes.txt` stayed out of scope.",
35 ),
36 ArtifactEvidence(
37 kind="verification_contradiction",
38 summary=(
39 "Failed verification exposed missing brief coverage for "
40 "`notes.txt exists in the workspace root.`."
41 ),
42 ),
43 ArtifactEvidence(
44 kind="task_boundary_change",
45 summary="The active task framing outgrew the persisted clarify brief.",
46 ),
47 ]
48 )
49
50 updated = apply_freshness_to_workflow_ledger(ledger, freshness)
51
52 assert any(
53 item.text == "notes.txt stays out of scope unless clarified otherwise."
54 and item.status == "contradicted"
55 for item in updated.assumptions
56 )
57 assert any(
58 "notes.txt exists in the workspace root." in item.text
59 and item.status == "changed"
60 for item in updated.acceptance_anchors
61 )
62 assert any(item.status == "reopened" for item in updated.decision_boundaries)
63 assert workflow_ledger_highlights(updated)