Coverage for src/governed_harness/friction/plans.py: 100%
6 statements
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-12 16:06 +0000
« prev ^ index » next coverage.py v7.17.2, created at 2026-11-12 16:06 +0000
1"""The digest a plan approval is bound to (#8 through #58).
3A PLANNING attempt rebuilds its plan with fresh step identifiers, so the digest covers what
4the plan says, not its identifiers: the task revision, each step's description, capabilities
5and expected evidence, the validators and the risks. The same task and configuration give the
6same digest on every attempt; any change to them gives another one, and an approval of the
7earlier plan no longer applies."""
9from __future__ import annotations
11from governed_harness.domain.models import Plan
12from governed_harness.evidence.hashing import sha256_json
15def plan_digest(plan: Plan, task_digest: str) -> str:
16 return sha256_json(
17 {
18 "taskDigest": task_digest,
19 "steps": [
20 {
21 "description": step.description,
22 "capabilities": list(step.capabilities),
23 "expectedEvidence": list(step.expected_evidence),
24 }
25 for step in plan.steps
26 ],
27 "validators": list(plan.validator_ids),
28 "risks": list(plan.risks),
29 }
30 )
33__all__ = ["plan_digest"]