fix(decision): inline YAML NO_ACTION 補查 — 修復 Phase 2 路徑盲點
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 4m0s

根因:Phase 2 (agent debate → auto_approve 拒絕 → 直接推 TG) 不經過
      auto_execute() 的 YAML check,Coordinator 不設 blocked_reason。
      PostgreSQL disk / host resource 等 NO_ACTION 規則告警在 Phase 2
      路徑仍顯示「ACTION REQUIRED」卡片(TYPE-3),而非 TYPE-1 資訊卡。

修復:_push_decision_to_telegram() 在 blocked_reason 為空時,補做一次
      alertname inline YAML 查詢,任何路徑(Phase 2 / Expert / Webhook)
      都能正確偵測 NO_ACTION → TYPE-1 / critical NO_ACTION → TYPE-4。

生產驗證觸發:INC-20260416-C365D0 PostgreSQL disk alert 顯示 ACTION REQUIRED
             而非 TYPE-1,確認全景 Code Review 遺漏此執行路徑。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-17 10:15:21 +08:00
parent f9d08de3a2
commit c05bcdbbd4

View File

@@ -268,6 +268,31 @@ async def _push_decision_to_telegram(
# ② NO_ACTION + critical → TYPE-4critical 事件不能靜默,即便 AI 無法自動修復
# ③ NO_ACTION + non-critical → TYPE-1一般資訊告警純資訊卡即可
_blocked_reason = proposal_data.get("blocked_reason", "")
# 2026-04-17 ogt + Claude Sonnet 4.6: Inline YAML NO_ACTION 補查
# 根因Phase 2 路徑agent debate → auto_approve 拒絕 → 直接推 TG不經過
# auto_execute() 的 YAML checklines 1427-1439Coordinator 不設 blocked_reason。
# 修復:在 _push_decision_to_telegram 內做一次 alertname 查詢,任何路徑都能偵測 NO_ACTION。
if not _blocked_reason and incident.signals:
try:
from src.services.alert_rule_engine import match_rule as _notif_match
_notif_alertname = incident.signals[0].labels.get("alertname", "")
if _notif_alertname:
_notif_rule = _notif_match({
"labels": incident.signals[0].labels,
"alert_type": _notif_alertname,
"message": "",
"target_resource": target,
"namespace": "awoooi-prod",
})
if _notif_rule:
if _notif_rule.get("blocked_reason", "").startswith("INVALID_TARGET"):
_blocked_reason = _notif_rule["blocked_reason"]
elif _notif_rule.get("suggested_action") == "NO_ACTION":
_blocked_reason = f"YAML: NO_ACTION for {_notif_alertname}"
except Exception:
pass # 查詢失敗不影響主流程
if "INVALID_TARGET" in _blocked_reason:
_notif_type = NotificationType.TYPE_4
elif "NO_ACTION" in _blocked_reason: