fix(scaffold): quality-gate law — transition-to-closed refuses without contract_quality evidence + post-hoc quality for the two lapsed closes (hook_engine, adaptive_router)

This commit is contained in:
Nick committed 2026-10-14 01:09:01 +01:00
1 parent 49bd788442
commit 2597b58b88
1 file changed
+15
+15
View File
@@ -486,6 +486,21 @@ class Scaffold:
raise IllegalPhaseTransition(
f"illegal transition: {current} → {phase} (legal: {sorted(LEGAL_TRANSITIONS.get(current, set()))})"
)
# QUALITY-GATE LAW (2026-10-13): entering `closed` via raw transition
# bypassed the predicted-vs-observed computation entirely — two wave
# landings (hook_engine, adaptive_router 2026-10-13) closed with a
# 'closed' phase and NO contract_quality, silently. The designed
# entry is close() (computes quality + material-change). Raw
# transition to closed now requires the quality to ALREADY be
# recorded (e.g. close_contract ran in this process); otherwise it
# refuses — the quality gate is mechanical, not advisory.
if phase == "closed":
if not e.get("ext", {}).get("contract_quality"):
raise IllegalPhaseTransition(
f"transition to 'closed' requires contract_quality evidence — "
f"close the contract via close() (predicted-vs-observed), "
f"not a raw transition ({contract_id})"
)
e["phase"] = phase
if phase == "closed":
e["status"] = "closed"