feat(governance): normalize AI治理告警輸出與元告警解析度
This commit is contained in:
@@ -142,6 +142,13 @@ class GovernanceAgent:
|
||||
],
|
||||
"sample_playbook_ids": kept_ids[:10],
|
||||
},
|
||||
"drifted_count": len(drifted),
|
||||
"auto_deprecated_count": len(auto_deprecated_ids),
|
||||
"auto_deprecated_ids": auto_deprecated_ids[:10],
|
||||
"playbook_ids": kept_ids[:10],
|
||||
"total_playbooks": total,
|
||||
"threshold": TRUST_DRIFT_THRESHOLD,
|
||||
"auto_deprecate_after_days": TRUST_DRIFT_AUTO_DEPRECATE_AFTER_DAYS,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -215,6 +222,11 @@ class GovernanceAgent:
|
||||
"安排至少 2 位 owner 對 stale條目做快速人工審核",
|
||||
],
|
||||
},
|
||||
"stale_count": stale,
|
||||
"total_count": total,
|
||||
"stale_ratio": round(ratio, 3),
|
||||
"threshold": KM_STALE_RATIO,
|
||||
"stale_days": KM_STALE_DAYS,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -260,6 +272,27 @@ class GovernanceAgent:
|
||||
await self._alert(
|
||||
"llm_hallucination",
|
||||
{
|
||||
"status": "warning",
|
||||
"impact": {
|
||||
"failed_count": failed,
|
||||
"total_checked": total,
|
||||
"hallucination_rate": round(rate, 3),
|
||||
"threshold": HALLUCINATION_RATE_THRESHOLD,
|
||||
},
|
||||
"remediation": {
|
||||
"items": [
|
||||
"檢核 AI 建議來源與 evidence snapshot 一致性",
|
||||
"檢視最近 incident 的 verifier 輸入欄位是否缺失關鍵上下文",
|
||||
],
|
||||
"next_action": "run_knowledge_gap_audit",
|
||||
"hint": "高失敗率通常表示 evidence 收斂流程退化或資料欄位解讀偏差",
|
||||
},
|
||||
"actionable": {
|
||||
"items": [
|
||||
"啟動 `playbook_evidence` 對齊補償流程",
|
||||
"調整 verify timeout 與降級策略,避免過度信任低品質證據",
|
||||
],
|
||||
},
|
||||
"failed_count": failed,
|
||||
"total_checked": total,
|
||||
"hallucination_rate": round(rate, 3),
|
||||
@@ -304,6 +337,27 @@ class GovernanceAgent:
|
||||
await self._alert(
|
||||
"execution_blast_radius",
|
||||
{
|
||||
"status": "warning",
|
||||
"impact": {
|
||||
"failed_count": failed,
|
||||
"total_executions": total,
|
||||
"failure_rate": round(rate, 3),
|
||||
"threshold": EXECUTION_FAIL_RATE_THRESHOLD,
|
||||
},
|
||||
"remediation": {
|
||||
"items": [
|
||||
"鎖定失敗 playbook 清單,關閉高風險自動執行",
|
||||
"比對 incident evidence 與 post_execution_verification 失敗原因",
|
||||
],
|
||||
"next_action": "pause_auto_repair_for_top_failing_playbooks",
|
||||
"hint": "可能是 auto_repair_playbook 與 runtime 版本/環境脫節",
|
||||
},
|
||||
"actionable": {
|
||||
"items": [
|
||||
"跑 `run_self_check` 快照與失敗 playbook 熱點報表",
|
||||
"必要時啟用 emergency fallback 路由進人工審核",
|
||||
],
|
||||
},
|
||||
"failed_count": failed,
|
||||
"total_executions": total,
|
||||
"failure_rate": round(rate, 3),
|
||||
@@ -548,9 +602,25 @@ class GovernanceAgent:
|
||||
await self._alert(
|
||||
"governance_self_failure",
|
||||
{
|
||||
"failed_checks": failed_checks,
|
||||
"total_checks": 5, # 2026-04-27 P3.4 by Claude — 加入 slo_compliance 後共 5 項
|
||||
"errors": {k: results[k].get("error") for k in failed_checks},
|
||||
"status": "critical",
|
||||
"impact": {
|
||||
"failed_checks": failed_checks,
|
||||
"total_checks": 5, # 2026-04-27 P3.4 by Claude — 加入 slo_compliance 後共 5 項
|
||||
"errors": {k: results[k].get("error") for k in failed_checks},
|
||||
},
|
||||
"remediation": {
|
||||
"items": [
|
||||
"暫停非關鍵治理自動化接收鏈路",
|
||||
"聚焦治理執行路徑錯誤並補齊 fallback",
|
||||
],
|
||||
"next_action": "investigate_governance_pipeline_health",
|
||||
},
|
||||
"actionable": {
|
||||
"items": [
|
||||
"檢查 GovernanceAgent run loop 是否完整執行 5 個項目",
|
||||
"確認 DB 寫入與 Prometheus fetch 未被上游干擾",
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user