feat(wave6-8): P2.1 fusion + P2.2 governance + P2.4 consensus + Wave 7/8 BLOCKER 修復

承接 Wave 6/7/8 多 engineer 在 agent 限額前完成的代碼,補 commit 解 production
HEAD 隱性 import error(decision_fusion 已被 decision_manager 引用但檔案 untracked)。

新增(後端核心):
- decision_fusion.py (562 行) — P2.1 方法 III(OpenClaw + Hermes + Elephant 三 LLM 融合)
- aiops_timeline.py + aiops_timeline_service.py — critic B4 修復
  /api/v1/aiops/timeline endpoint,DB 存取抽到 service 層遵守 leWOOOgo 積木化
- migrations/p2_decision_fusion_columns.sql + rollback — approval_records fusion 欄位

修改(後端整合):
- decision_manager.py — fusion 三斷鏈修補(critic B1+B2+B3):
  · B1: 寫 _evidence_snapshot_ref 到 token.proposal_data
  · B2: fusion 前計算 complexity_score 並寫 token
  · B3: fusion composite 寫 token.proposal_data["decision_fusion"]
- auto_approve.py — fusion + consensus 認識(critic B3+B5):
  · composite > 0.7 → auto_execute_eligible bypass min_confidence
  · source=consensus_engine + score>=0.6 → 規則可信路徑
- consensus_engine.py — db-fix _save_consensus 重用 agent_sessions
- governance_agent.py — db-fix _alert PG 寫入 ai_governance_events
- approval_db.py — fusion 3 欄位 + 2 partial index + CheckConstraint
- db/models.py — schema 對齊 migration
- core/config.py — vuln #1 修復:OLLAMA_URL/_FALLBACK_URL field_validator
  拒絕公網 IP + 外部域名,僅允許私網/loopback/K8s SVC 白名單
- core/feature_flags.py — P2 fusion + consensus flags
- main.py — governance_agent lifespan 啟動
- failover_alerter.py — Wave8-X2: in-memory dedup fallback(Redis 拒絕後不 fail-open)
- ollama_*.py — metrics 整合 + recovery 改善
- auto_repair_service.py — verifier 接線

新增(測試 2438 行):
- test_decision_fusion.py / test_governance_agent.py / test_consensus_integration.py
- test_p2_db_fixes.py / test_wave8_fusion_fixes.py
- test_config_url_validation.py(vuln #1 12 tests)
- test_failover_alerter.py +Wave8-X2 in-memory dedup 補測

驗收: 116 tests pass (decision_fusion + wave8_fusion + config_url + consensus +
                      governance + p2_db_fixes + failover_alerter)

Conflict resolution:
- 3 檔(config.py + auto_approve.py + decision_manager.py)git stash pop 衝突
  保留 stashed (engineer 最終版),補回 ValueError 「公網 IP」字樣對齊 test

Note: 此 commit 解 production HEAD 隱性 import error
仍未修: vuln #4 prompt injection / debugger B14 quota fail-closed
       / B25-B26 drain_pending_tasks / B8 governance fail alert

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Multiple Engineers (Wave 6/7/8) <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-04-27 08:10:28 +08:00
parent b0bf3783e4
commit cc547736ab
34 changed files with 4205 additions and 25 deletions

View File

@@ -1221,5 +1221,119 @@
"actionGoSettings": "Go to Settings",
"actionGoTerminal": "Go to Terminal",
"actionGoApprovals": "Go to Authorizations"
},
"aiopsTimeline": {
"title": "AIOps Full Timeline",
"subtitle": "Alert → Investigation → Decision → Execution → Verification → Learning",
"mockBadge": "MOCK MODE",
"stages": {
"alert": "Alert Triggered",
"diagnose": "Investigation",
"decide": "AI Decision",
"execute": "Auto Execute",
"verify": "Verification",
"learn": "Learning Update"
},
"status": {
"success": "Success",
"running": "Running",
"failed": "Failed",
"skipped": "Skipped",
"pending": "Pending"
},
"filters": {
"incident_id": "Incident ID",
"incident_id_placeholder": "Search incident ID...",
"time_range": "Time Range",
"status_filter": "Status Filter",
"incident_count": "{count} incidents",
"timeRange": {
"1h": "1H",
"6h": "6H",
"24h": "24H",
"7d": "7D"
},
"statusFilter": {
"all": "All",
"success": "Success",
"failed": "Failed",
"running": "Running"
}
},
"incident": {
"started_at": "Started At",
"resolved_at": "Resolved At",
"duration": "Duration",
"in_progress": "In Progress",
"severity": "Severity",
"stages_summary": "{success} success / {total} stages",
"expand_all": "Expand All",
"collapse_all": "Collapse All"
},
"stage": {
"toggle_details": "Toggle {stage} details"
},
"evidence": {
"dimensions": "8D Dimensions",
"anomalyCount": "{count}/{total} anomaly dimensions",
"noData": "N/A"
},
"stageDetails": {
"alert": {
"name": "Alert Name",
"rule": "Rule",
"value": "Current Value",
"labels": "Labels"
},
"diagnose": {
"investigator": "Investigator",
"tools_used": "MCP Tools",
"hypothesis": "Root Cause Hypothesis",
"evidence": "8D Evidence"
},
"decide": {
"engine": "Decision Engine",
"fusion": "Fusion Method",
"confidence": "Confidence",
"confidenceThreshold": "Threshold {value}%",
"auto_execute": "Auto Execute",
"auto_yes": "Yes",
"auto_no": "No (requires approval)",
"playbook": "Playbook",
"decision": "Decision Command",
"reasoning": "Reasoning",
"alternates": "Alternate Decisions"
},
"execute": {
"command": "Command",
"target": "Target",
"executor": "Executor",
"duration": "Duration",
"stdout": "Output",
"exit_code": "Exit Code"
},
"verify": {
"verifier": "Verifier",
"outcome": "Outcome",
"checks": "Checks",
"trust_delta": "Trust Delta",
"notes": "Notes"
},
"learn": {
"playbook": "Playbook",
"trust_update": "Trust Update",
"km_entry": "Knowledge Base Entry",
"summary": "Learning Summary"
}
},
"loading": "Loading timeline data...",
"empty": {
"title": "No incidents found",
"subtitle": "No AIOps incidents match the current filters"
},
"error": {
"title": "Failed to load data",
"retry": "Retry"
}
}
}

View File

@@ -1222,5 +1222,119 @@
"actionGoSettings": "前往設定",
"actionGoTerminal": "前往終端頁面",
"actionGoApprovals": "前往授權中心"
},
"aiopsTimeline": {
"title": "AIOps 全景時序",
"subtitle": "告警→感官調查→AI決策→自動執行→驗證→學習 完整鏈路",
"mockBadge": "MOCK 模式",
"stages": {
"alert": "告警觸發",
"diagnose": "感官調查",
"decide": "AI 決策",
"execute": "自動執行",
"verify": "結果驗證",
"learn": "學習更新"
},
"status": {
"success": "成功",
"running": "執行中",
"failed": "失敗",
"skipped": "跳過",
"pending": "待執行"
},
"filters": {
"incident_id": "事件編號",
"incident_id_placeholder": "搜尋事件 ID...",
"time_range": "時間範圍",
"status_filter": "狀態篩選",
"incident_count": "{count} 筆事件",
"timeRange": {
"1h": "1H",
"6h": "6H",
"24h": "24H",
"7d": "7D"
},
"statusFilter": {
"all": "全部",
"success": "成功",
"failed": "失敗",
"running": "進行中"
}
},
"incident": {
"started_at": "開始時間",
"resolved_at": "結束時間",
"duration": "持續時長",
"in_progress": "處理中",
"severity": "嚴重度",
"stages_summary": "{success} 成功 / {total} 階段",
"expand_all": "展開全部",
"collapse_all": "收合全部"
},
"stage": {
"toggle_details": "展開 {stage} 詳情"
},
"evidence": {
"dimensions": "8D 維度",
"anomalyCount": "{count}/{total} 異常維度",
"noData": "N/A"
},
"stageDetails": {
"alert": {
"name": "告警名稱",
"rule": "規則",
"value": "當前值",
"labels": "標籤"
},
"diagnose": {
"investigator": "調查器",
"tools_used": "MCP 工具",
"hypothesis": "根因假設",
"evidence": "8D 證據"
},
"decide": {
"engine": "決策引擎",
"fusion": "融合方法",
"confidence": "信心度",
"confidenceThreshold": "門檻 {value}%",
"auto_execute": "自動執行",
"auto_yes": "是",
"auto_no": "否(需授權)",
"playbook": "Playbook",
"decision": "決策指令",
"reasoning": "推理依據",
"alternates": "備選方案"
},
"execute": {
"command": "執行指令",
"target": "執行目標",
"executor": "執行器",
"duration": "耗時",
"stdout": "輸出",
"exit_code": "退出碼"
},
"verify": {
"verifier": "驗證器",
"outcome": "結果",
"checks": "檢查項",
"trust_delta": "信任度變化",
"notes": "備註"
},
"learn": {
"playbook": "Playbook",
"trust_update": "信任度更新",
"km_entry": "知識庫記錄",
"summary": "學習摘要"
}
},
"loading": "載入時序資料中...",
"empty": {
"title": "無事件記錄",
"subtitle": "目前沒有符合條件的 AIOps 事件"
},
"error": {
"title": "資料載入失敗",
"retry": "重試"
}
}
}

File diff suppressed because one or more lines are too long