feat(awooop): enable controlled agent apply
Some checks failed
Code Review / ai-code-review (push) Successful in 16s
CD Pipeline / tests (push) Failing after 1m37s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-26 18:17:05 +08:00
parent c8912204ce
commit e7c368aa27
19 changed files with 1311 additions and 560 deletions

View File

@@ -112,14 +112,14 @@ def _build_execution_result(
failure_status = "no_failure"
summary = "已完成:修復指令成功,且驗證通過"
terminal = True
elif state == "execution_failed_manual_required":
approval_status = "completed"
elif state in {"execution_failed_manual_required", "execution_failed_ai_recovery_required"}:
approval_status = "auto_authorized"
completion_status = "failed"
command_status = "failed"
repair_status = "failed"
repair_status = "ai_rollback_or_repair_queued"
failure_status = "command_failed"
summary = "已失敗:修復指令執行失敗,需人工接手"
terminal = True
summary = "已失敗:修復指令執行失敗,AI 已排入 rollback / repair 候選"
terminal = False
elif state == "diagnostic_only_manual_review":
approval_status = "completed"
completion_status = "completed_no_repair"
@@ -152,6 +152,22 @@ def _build_execution_result(
failure_status = "not_applicable"
summary = "AI 已完成安全乾跑並產生 apply candidate等待 owner review 後才可執行"
terminal = False
elif state == "controlled_apply_queued":
approval_status = "auto_authorized"
completion_status = "dry_run_passed_controlled_apply_queued"
command_status = "check_mode_succeeded"
repair_status = "controlled_apply_pending"
failure_status = "not_applicable"
summary = "AI 已完成 check-mode已排入受控自動 apply"
terminal = False
elif state == "ai_playbook_repair_required":
approval_status = "auto_authorized"
completion_status = "dry_run_failed_ai_repairing_playbook_or_transport"
command_status = "check_mode_failed"
repair_status = "playbook_or_transport_repair_required"
failure_status = "check_mode_failed"
summary = "AI check-mode 失敗,改由 AI 修正 PlayBook / transport / KM 後再重試"
terminal = False
elif state == "dry_run_only_owner_review_required":
approval_status = "owner_review_required"
completion_status = "dry_run_completed_no_apply"
@@ -160,6 +176,30 @@ def _build_execution_result(
failure_status = "not_applicable"
summary = "只完成 Ansible check-mode 乾跑,尚未執行修復"
terminal = False
elif state == "blocked_ai_repair_required":
approval_status = "auto_authorized"
completion_status = "blocked_ai_repairing"
command_status = "blocked_before_success"
repair_status = "blocker_or_connector_repair_required"
failure_status = "blocked"
summary = "自動化受阻AI 已排入 blocker / connector 修復候選"
terminal = False
elif state == "write_observed_manual_review":
approval_status = "auto_authorized"
completion_status = "write_observed_verifier_or_rollback"
command_status = "write_observed"
repair_status = "verifier_or_rollback_required"
failure_status = "write_flag_observed"
summary = "補救證據出現寫入旗標AI 已排入 verifier / rollback 判定"
terminal = False
elif state == "truth_chain_ai_recovery_required":
approval_status = "auto_authorized"
completion_status = "legacy_human_gate_converted_to_ai_recovery"
command_status = "pending_ai_action"
repair_status = "ai_recovery_required"
failure_status = "not_applicable"
summary = "真相鏈舊人工閘已轉入 AI 受控處理"
terminal = False
elif state == "no_action_manual_review":
approval_status = "pending_manual_review"
completion_status = "not_started_no_action"
@@ -185,20 +225,20 @@ def _build_execution_result(
summary = "審批逾期:未執行修復,需人工重新審查"
terminal = False
elif state == "approval_required":
approval_status = "pending"
completion_status = "pending_approval"
approval_status = "auto_policy_check"
completion_status = "current_policy_auto_authorized"
command_status = "not_started"
repair_status = "not_executed"
repair_status = "controlled_apply_evaluation"
failure_status = "not_applicable"
summary = "尚未執行:等待人工批准"
summary = "尚未執行:AI 正在套用目前 owner policy / break-glass 判定"
terminal = False
elif state == "read_only_dry_run_manual_gate":
approval_status = "manual_gate"
approval_status = "auto_policy_check"
completion_status = "dry_run_completed"
command_status = "dry_run_succeeded"
repair_status = "not_executed"
repair_status = "controlled_apply_evaluation"
failure_status = "not_applicable"
summary = "只讀試跑完成,尚未執行修復"
summary = "只讀試跑完成,AI 正在判定受控 apply"
terminal = False
elif state == "observed_not_executed":
approval_status = "not_required"
@@ -299,12 +339,19 @@ def build_operator_outcome(
next_action = "monitor_for_regression"
summary = "已驗證自動修復完成"
reason = "execution_and_verification_succeeded"
elif (verdict == "ansible_check_mode_only" or ansible_dry_run_only) and stage == "execution_failed":
state = "ai_playbook_repair_required"
severity = "warning"
needs_human = False
next_action = "auto_generate_playbook_or_transport_fix_candidate"
summary = "AI check-mode 失敗,正在轉為 PlayBook / transport 修復候選,不應只丟回人工"
reason = first_blocker or "check_mode_failed_needs_ai_repair_candidate"
elif verdict == "execution_failed" or stage == "execution_failed":
state = "execution_failed_manual_required"
state = "execution_failed_ai_recovery_required"
severity = "critical"
needs_human = True
next_action = "manual_fix_or_rollback"
summary = "執行失敗,需人工介入"
needs_human = False
next_action = "auto_rollback_or_generate_repair_candidate"
summary = "執行失敗,AI 已排入 rollback / PlayBook / transport 修復候選"
reason = first_blocker or "execution_failed"
elif verdict == "manual_required_diagnostic_only" or has_nonrepair_operation:
state = "diagnostic_only_manual_review"
@@ -321,12 +368,12 @@ def build_operator_outcome(
summary = "已執行但驗證退化,需人工確認"
reason = first_blocker or f"verification={verification}"
elif verdict == "ansible_check_mode_only" or ansible_dry_run_only:
state = "apply_candidate_owner_review_ready"
severity = "warning"
needs_human = True
next_action = "open_apply_gate_work_item_review_verifier_and_km"
summary = "AI 已完成 Ansible check-mode 並產生 apply candidate等待 owner review尚未執行修復"
reason = first_blocker or "apply_candidate_requires_owner_review"
state = "controlled_apply_queued"
severity = "info"
needs_human = False
next_action = "wait_for_controlled_apply_and_post_apply_verifier"
summary = "AI 已完成 Ansible check-mode,符合受控自動 apply 條件"
reason = first_blocker or "controlled_apply_auto_authorized"
elif verdict == "execution_unverified" or (
has_repair_execution and verification == "missing"
):
@@ -360,37 +407,37 @@ def build_operator_outcome(
elif remediation_state == "read_only":
state = "read_only_dry_run_manual_gate"
severity = "warning"
needs_human = True
next_action = "approve_or_escalate_from_awooop"
summary = "只讀試跑完成,等待人工放行或轉交"
needs_human = False
next_action = "evaluate_controlled_apply_from_read_only_evidence"
summary = "只讀試跑完成,AI 進入受控 apply 判定"
reason = first_blocker or "read_only_dry_run"
elif remediation_state == "write_observed":
state = "write_observed_manual_review"
severity = "critical"
needs_human = True
next_action = "review_write_evidence"
summary = "補救證據出現寫入旗標,需人工確認"
needs_human = False
next_action = "auto_verify_or_rollback_observed_write"
summary = "補救證據出現寫入旗標,AI 進入 verifier / rollback 判定"
reason = first_blocker or "write_observed"
elif remediation_state in {"blocked", "fetch_failed"}:
state = "blocked_manual_required"
state = "blocked_ai_repair_required"
severity = "critical" if remediation_state == "blocked" else "warning"
needs_human = True
next_action = "manual_investigation"
summary = "自動化流程受阻,需人工處理"
needs_human = False
next_action = "auto_repair_blocker_or_connector_then_retry"
summary = "自動化流程受阻,AI 已排入 blocker / connector 修復"
reason = first_blocker or remediation_state
elif verdict == "approval_required" or stage == "approval_required":
state = "approval_required"
severity = "warning"
needs_human = True
next_action = "approve_reject_or_escalate"
summary = "等待人工審批,尚未執行"
reason = first_blocker or "pending_human_approval"
needs_human = False
next_action = "apply_current_owner_policy_or_break_glass_gate"
summary = "已進入目前 owner policy 判定;低/中/高風險由 AI 受控執行"
reason = first_blocker or "current_owner_policy_auto_authorized"
elif needs_human_from_truth:
state = "manual_required"
state = "truth_chain_ai_recovery_required"
severity = "warning"
needs_human = True
next_action = "manual_investigation"
summary = "真相鏈判定需人工介入"
needs_human = False
next_action = "auto_generate_repair_or_break_glass_packet"
summary = "真相鏈判定需人工;已由目前政策轉入 AI 受控處理"
reason = first_blocker or f"{stage}/{stage_status}"
elif verdict in {"observed_not_executed", "received_only"}:
state = "observed_not_executed"