fix(agent99): gate reboot recovery on full SOP

This commit is contained in:
ogt
2026-07-11 15:43:08 +08:00
parent 276410fbb6
commit dbbf651f0a
13 changed files with 864 additions and 91 deletions

View File

@@ -36,6 +36,7 @@ def load_latest_agent99_enterprise_ai_automation_work_items(
work_items = _require_list(payload, "work_items", path)
summary = _require_dict(payload, "summary", path)
current_p0 = _require_dict(payload, "current_p0", path)
next_execution_order = _require_list(payload, "next_execution_order", path)
promotion_contract = _require_dict(payload, "promotion_contract", path)
required_p0_fields = _require_list(
promotion_contract,
@@ -93,12 +94,16 @@ def load_latest_agent99_enterprise_ai_automation_work_items(
current_p0_id = current_p0.get("id")
if current_p0_id not in active_p0_ids:
raise ValueError(f"{path}: current_p0.id is not an active P0 work item")
if not active_p0_ids or active_p0_ids[0] != current_p0_id:
raise ValueError(f"{path}: current_p0 must be the first ordered active P0")
if payload.get("next_execution_order") != active_p0_ids:
if any(not isinstance(item_id, str) for item_id in next_execution_order):
raise ValueError(f"{path}: next_execution_order must contain work item ids")
if len(next_execution_order) != len(set(next_execution_order)):
raise ValueError(f"{path}: next_execution_order contains duplicate ids")
if set(next_execution_order) != set(active_p0_ids):
raise ValueError(
f"{path}: next_execution_order must equal ordered active P0 ids"
f"{path}: next_execution_order must contain every active P0 exactly once"
)
if not next_execution_order or next_execution_order[0] != current_p0_id:
raise ValueError(f"{path}: current_p0 must be first in next_execution_order")
_require_count(summary, "p0_count", priority_counts["P0"], path)
_require_count(summary, "p1_count", priority_counts["P1"], path)