fix(api): expose runtime switch completion readback
All checks were successful
CD Pipeline / workflow-shape (push) Successful in 1s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 22s
CD Pipeline / build-and-deploy (push) Successful in 8m40s
CD Pipeline / post-deploy-checks (push) Successful in 58s

This commit is contained in:
Your Name
2026-06-30 01:33:35 +08:00
parent 599b6a7632
commit 7d7d0028df
9 changed files with 158 additions and 65 deletions

View File

@@ -22,8 +22,11 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
receipt_rollups = _dict(receipt.get("rollups"))
receipt_boundaries = _dict(receipt.get("operation_boundaries"))
receipt_readback = _dict(receipt.get("readback"))
switch_value = str(receipt_rollups.get("runtime_execution_switch_value") or "0")
switch_enabled = switch_value == "1"
switch_value = str(
receipt_rollups.get("runtime_execution_switch_value")
or ("1" if receipt_rollups.get("runtime_execution_enabled") is True else "0")
)
runtime_enabled = switch_value == "1"
receipt_ready = (
receipt.get("status") == _RECEIPT_READY_STATUS
and receipt.get("active_blockers") == []
@@ -46,11 +49,11 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
"priority": "P0-004",
"scope": "gitea_onboarding_warning_step_runtime_enablement",
"status": (
"controlled_warning_step_runtime_enabled"
if switch_enabled and not active_blockers
"blocked_warning_step_runtime_enablement_gate"
if active_blockers
else "controlled_warning_step_runtime_enabled"
if runtime_enabled
else "controlled_warning_step_runtime_enablement_gate_ready"
if not active_blockers
else "blocked_warning_step_runtime_enablement_gate"
),
"readback": {
"workplan_id": "P0-004-WARNING-STEP-RUNTIME-ENABLEMENT",
@@ -68,19 +71,24 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
"workflow_content_sha256_12"
),
"runtime_enablement_switch": "AWOOOI_ONBOARDING_WARNING_STEP_EXECUTION_ENABLED",
"previous_switch_value_before_controlled_apply": "0",
"current_switch_default": switch_value,
"desired_switch_value_after_controlled_apply": "1",
"safe_next_step": (
"runtime_enablement_switch_enabled_wait_for_manual_dispatch_evidence"
if switch_enabled
"verify_production_runtime_switch_readback_then_open_controlled_dispatch_gate_after_pressure_guard"
if runtime_enabled
else "prepare_controlled_switch_flip_with_pressure_guard_then_verify_no_auto_branch_trigger"
),
},
"controlled_apply": {
"mode": "controlled_apply_prepared",
"controlled_apply_allowed": not active_blockers and not switch_enabled,
"workflow_runtime_enablement_authorized": not active_blockers
and not switch_enabled,
"mode": (
"controlled_apply_completed"
if runtime_enabled
else "controlled_apply_prepared"
),
"controlled_apply_allowed": not active_blockers,
"controlled_apply_completed": runtime_enabled and not active_blockers,
"workflow_runtime_enablement_authorized": not active_blockers,
"workflow_dispatch_authorized": False,
"auto_push_or_pull_request_trigger_authorized": False,
"generic_runner_label_authorized": False,
@@ -95,17 +103,18 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
"selector_type": "workflow_runtime_enablement_switch",
"workflow_path": _WORKFLOW_PATH,
"env_key": "AWOOOI_ONBOARDING_WARNING_STEP_EXECUTION_ENABLED",
"previous_expected_value_before_controlled_apply": "0",
"expected_current_value": switch_value,
"desired_value_after_controlled_apply": "1",
"allowed_runner_label": "awoooi-non110-host",
},
"source_of_truth_diff": {
"current_state": (
"warning_step_runtime_job_enabled_for_manual_dispatch_only"
if switch_enabled
"warning_step_runtime_job_enabled_for_controlled_dispatch_only"
if runtime_enabled
else "warning_step_runtime_job_fail_closed_disabled"
),
"desired_state": "warning_step_runtime_job_enabled_for_manual_dispatch_only",
"desired_state": "warning_step_runtime_job_enabled_for_controlled_dispatch_only",
"delta_kind": "env_switch_value_change",
"auto_branch_event_delta_allowed": False,
"generic_runner_label_delta_allowed": False,
@@ -120,7 +129,11 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
"run_runner_pressure_guard",
"verify_no_push_pull_request_triggers",
"verify_no_generic_runner_labels",
"verify_switch_currently_fail_closed",
(
"verify_switch_enabled_for_controlled_dispatch_only"
if runtime_enabled
else "verify_switch_currently_fail_closed"
),
"verify_git_diff_contains_only_switch_change",
],
},
@@ -164,12 +177,16 @@ def load_latest_awoooi_gitea_onboarding_warning_step_runtime_enablement_gate() -
receipt_rollups.get("runtime_execution_switch_controlled") is True
),
"runtime_execution_switch_value": switch_value,
"runtime_execution_switch_enabled": switch_enabled,
"runtime_execution_switch_enabled": runtime_enabled,
"runtime_enablement_switch_present": (
receipt_rollups.get("runtime_enablement_switch_present") is True
),
"runtime_execution_enabled": runtime_enabled,
"runner_pressure_guard_required": True,
"controlled_runtime_enablement_ready": not active_blockers,
"active_blocker_count": len(active_blockers),
"workflow_trigger_performed": False,
"runtime_switch_changed": switch_enabled,
"runtime_switch_changed": runtime_enabled,
},
"active_blockers": active_blockers,
"operation_boundaries": {

View File

@@ -1,4 +1,4 @@
"""AWOOOI warning-step template copy receipt readback."""
"""AWOOOI warning-step template copy and runtime-switch receipt readback."""
from __future__ import annotations
@@ -17,7 +17,7 @@ _SCHEMA_VERSION = "awoooi_gitea_onboarding_warning_step_template_copy_receipt_v1
_RECEIPT_SCHEMA_VERSION = (
"awoooi_gitea_onboarding_warning_step_template_copy_receipt_snapshot_v1"
)
_EXPECTED_WORKFLOW_SHA256_12 = "23b59f29cb77"
_EXPECTED_WORKFLOW_SHA256_12 = "980ff5452f59"
_TEMPLATE_RELATIVE_PATH = (
"docs/operations/templates/awoooi-gitea-onboarding-warning-step.workflow.yaml"
)
@@ -36,7 +36,7 @@ _GENERIC_LABEL_PATTERNS = (
def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_receipt(
repo_root: Path | None = None,
) -> dict[str, Any]:
"""Return the warning-step workflow copy receipt."""
"""Return the warning-step workflow copy receipt across controlled stages."""
root = repo_root or resolve_repo_root(Path(__file__))
template_path = root / _TEMPLATE_RELATIVE_PATH
workflow_path = root / _WORKFLOW_RELATIVE_PATH
@@ -55,7 +55,8 @@ def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_receipt(
_short_content_sha(effective_workflow_text) if effective_workflow_text else ""
)
runtime_switch_value = _runtime_execution_switch_value(
receipt, effective_workflow_text
receipt,
effective_workflow_text,
)
template_copy_recorded = _template_copy_recorded(
receipt=receipt,
@@ -140,7 +141,7 @@ def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_receipt(
"workflow_matches_source_template_or_receipt_hash_matches",
"workflow_has_no_auto_branch_event",
"workflow_has_no_generic_runner_label",
"workflow_runtime_execution_switch_controlled",
"workflow_runtime_execution_switch_declared",
"runner_pressure_guard_required",
"git_diff_check_required",
],
@@ -186,11 +187,20 @@ def load_latest_awoooi_gitea_onboarding_warning_step_template_copy_receipt(
)
or receipt.get("fail_closed_execution_switch_present") is True,
"runtime_execution_switch_controlled": _runtime_execution_switch_controlled(
receipt, effective_workflow_text
receipt,
effective_workflow_text,
),
"runtime_execution_switch_value": runtime_switch_value,
"runtime_execution_switch_enabled": runtime_switch_value == "1",
"runtime_enablement_switch_changed": runtime_switch_value == "1",
"runtime_enablement_switch_present": _runtime_enablement_switch_present(
effective_workflow_text
)
or receipt.get("runtime_enablement_switch_present") is True,
"runtime_execution_enabled": _runtime_execution_enabled(
effective_workflow_text
)
or receipt.get("runtime_execution_enabled") is True,
"apply_gate_ready": _gate_ready(gate_readback),
"active_blocker_count": len(active_blockers),
"active_workflow_file_created": template_copy_recorded,
@@ -384,5 +394,16 @@ def _runtime_execution_switch_controlled(
) or receipt.get("runtime_execution_switch_controlled") is True
def _runtime_enablement_switch_present(template_text: str) -> bool:
return (
"AWOOOI_ONBOARDING_WARNING_STEP_EXECUTION_ENABLED:" in template_text
and "AWOOOI_ONBOARDING_WARNING_STEP_EXECUTION_ENABLED == '1'" in template_text
)
def _runtime_execution_enabled(template_text: str) -> bool:
return 'AWOOOI_ONBOARDING_WARNING_STEP_EXECUTION_ENABLED: "1"' in template_text
def _dict(value: Any) -> dict[str, Any]:
return value if isinstance(value, dict) else {}

View File

@@ -901,6 +901,7 @@ def build_delivery_closure_workbench(
in {
"controlled_warning_step_runtime_enablement_gate_ready",
"controlled_warning_step_runtime_enabled",
"controlled_warning_step_runtime_enabled_receipt_ready",
}
),
"runtime_enablement_gate_active_blocker_count": _int(
@@ -912,6 +913,19 @@ def build_delivery_closure_workbench(
)
is True
),
"runtime_enablement_controlled_apply_completed": (
cicd_runtime_enablement_controlled_apply.get(
"controlled_apply_completed"
)
is True
),
"runtime_enablement_runtime_execution_enabled": (
cicd_runtime_enablement_rollups.get("runtime_execution_enabled")
is True
),
"runtime_enablement_switch_changed": (
cicd_runtime_enablement_rollups.get("runtime_switch_changed") is True
),
"runtime_enablement_workflow_dispatch_authorized": (
cicd_runtime_enablement_controlled_apply.get(
"workflow_dispatch_authorized"
@@ -1443,6 +1457,7 @@ def build_delivery_closure_workbench(
in {
"controlled_warning_step_runtime_enablement_gate_ready",
"controlled_warning_step_runtime_enabled",
"controlled_warning_step_runtime_enabled_receipt_ready",
}
),
"p0_cicd_warning_step_runtime_enablement_active_blocker_count": _int(
@@ -1454,6 +1469,18 @@ def build_delivery_closure_workbench(
)
is True
),
"p0_cicd_warning_step_runtime_enablement_controlled_apply_completed": (
cicd_runtime_enablement_controlled_apply.get(
"controlled_apply_completed"
)
is True
),
"p0_cicd_warning_step_runtime_enablement_runtime_execution_enabled": (
cicd_runtime_enablement_rollups.get("runtime_execution_enabled") is True
),
"p0_cicd_warning_step_runtime_enablement_switch_changed": (
cicd_runtime_enablement_rollups.get("runtime_switch_changed") is True
),
"p0_cicd_warning_step_runtime_enablement_workflow_dispatch_authorized": (
cicd_runtime_enablement_controlled_apply.get(
"workflow_dispatch_authorized"