CUST-WP-0055 T06: workplan-first curate decision scope
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 10s

Dual-write workplan_id and legacy workstream_id on State Hub decisions;
add --workplan-id CLI flag. Archive grandfather notes (T07).
This commit is contained in:
tegwick 2026-07-08 20:26:24 +02:00
parent a338d8debe
commit a08d988157
3 changed files with 32 additions and 13 deletions

View file

@ -28,15 +28,16 @@ def _now() -> str:
def build_decision(candidate: dict, action: str, rationale: str,
*, workstream_id: Optional[str] = None,
*, workplan_id: Optional[str] = None,
workstream_id: Optional[str] = None,
decided_by: str = "curator") -> dict:
"""Shape a curate decision as a State Hub ``record_decision`` payload."""
key = candidate["key"]
verb = "Promote" if action == "approve" else "Reject"
return {
scope_id = workplan_id or workstream_id
payload = {
"title": f"{verb} pattern candidate {key}",
"decision_type": "made",
"workstream_id": workstream_id,
"rationale": rationale,
"decided_by": decided_by,
"description": json.dumps({
@ -46,6 +47,10 @@ def build_decision(candidate: dict, action: str, rationale: str,
}, sort_keys=True),
"recorded_at": _now(),
}
if scope_id:
payload["workplan_id"] = scope_id
payload["workstream_id"] = scope_id
return payload
@dataclass
@ -54,14 +59,21 @@ class DecisionRecorder:
queue_path: str
sink: Optional[Sink] = None
workplan_id: Optional[str] = None
workstream_id: Optional[str] = None
decided_by: str = "curator"
_queued: int = field(default=0, init=False)
def record(self, candidate: dict, action: str, rationale: str) -> bool:
"""Record one decision. Returns True if the sink accepted it, else queued."""
payload = build_decision(candidate, action, rationale,
workstream_id=self.workstream_id, decided_by=self.decided_by)
payload = build_decision(
candidate,
action,
rationale,
workplan_id=self.workplan_id,
workstream_id=self.workstream_id,
decided_by=self.decided_by,
)
if self.sink is not None:
try:
self.sink(payload)