fix(api): distinguish ansible dry run from repair
Some checks failed
Code Review / ai-code-review (push) Successful in 14s
CD Pipeline / tests (push) Successful in 1m35s
CD Pipeline / build-and-deploy (push) Successful in 5m0s
CD Pipeline / post-deploy-checks (push) Successful in 1m33s
Ansible / Reboot Recovery Contract / validate (push) Has been cancelled

This commit is contained in:
Your Name
2026-06-25 20:52:22 +08:00
parent 8080606112
commit d7b3997b4a
9 changed files with 362 additions and 23 deletions

View File

@@ -106,6 +106,14 @@ def _build_execution_result(
failure_status = "no_command_failed"
summary = "已執行成功,但缺少修復驗證結果"
terminal = False
elif state == "dry_run_only_owner_review_required":
approval_status = "owner_review_required"
completion_status = "dry_run_completed_no_apply"
command_status = "check_mode_succeeded"
repair_status = "not_executed"
failure_status = "not_applicable"
summary = "只完成 Ansible check-mode 乾跑,尚未執行修復"
terminal = False
elif state == "no_action_manual_review":
approval_status = "pending_manual_review"
completion_status = "not_started_no_action"
@@ -218,6 +226,11 @@ def build_operator_outcome(
has_repair_execution = _safe_int(facts.get("effective_execution_records")) > 0 or _safe_int(
facts.get("auto_repair_execution_records")
) > 0
ansible_dry_run_only = (
_safe_int(facts.get("ansible_check_mode_total")) > 0
and _safe_int(facts.get("ansible_apply_total")) == 0
and _safe_int(facts.get("auto_repair_execution_records")) == 0
)
has_nonrepair_operation = (
_safe_int(facts.get("automation_operation_records")) > 0
and not has_repair_execution
@@ -260,6 +273,13 @@ def build_operator_outcome(
next_action = "manual_verify_or_repair"
summary = "已執行但驗證退化,需人工確認"
reason = first_blocker or f"verification={verification}"
elif verdict == "ansible_check_mode_only" or ansible_dry_run_only:
state = "dry_run_only_owner_review_required"
severity = "warning"
needs_human = True
next_action = "owner_review_apply_gate_or_create_verifier_plan"
summary = "只完成 Ansible check-mode 乾跑,尚未執行修復"
reason = first_blocker or "ansible_check_mode_without_apply"
elif verdict == "execution_unverified" or (
has_repair_execution and verification == "missing"
):