From 19b00a1ca05f5c59c9e81d19ba0deeb697e50d24 Mon Sep 17 00:00:00 2001 From: OG T Date: Sun, 29 Mar 2026 15:57:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E7=A7=BB=E9=99=A4=20Consensus=20En?= =?UTF-8?q?gine=20=E5=81=87=E4=BF=A1=E5=BF=83=E5=88=86=E6=95=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔴 違反鐵律: feedback_confidence_truthfulness.md Expert System 必須 confidence = 0.0,禁止假裝 AI 仲裁 修正: - SREAgent: 0.85/0.80/0.75/0.60 → 0.0 - SecurityAgent: 0.70/0.85 → 0.0 - CostAgent: 0.75 → 0.0 - PerformanceAgent: 0.80/0.70 → 0.0 所有規則匹配現在正確顯示為「⚙️ 規則匹配」而非「🤖 AI 仲裁」 Co-Authored-By: Claude Opus 4.5 --- apps/api/src/services/consensus_engine.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/api/src/services/consensus_engine.py b/apps/api/src/services/consensus_engine.py index 5626acf4..164fee1e 100644 --- a/apps/api/src/services/consensus_engine.py +++ b/apps/api/src/services/consensus_engine.py @@ -196,22 +196,22 @@ class SREAgent(ExpertAgent): if any(kw in alert_names for kw in ["crash", "restart", "oom", "killed"]): action = "重新啟動服務以恢復穩定性" kubectl = f"kubectl rollout restart deployment/{target} -n awoooi-prod" - confidence = 0.85 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "medium" elif any(kw in alert_names for kw in ["latency", "slow", "timeout"]): action = "擴展副本數以分散負載" kubectl = f"kubectl scale deployment/{target} --replicas=3 -n awoooi-prod" - confidence = 0.80 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "low" elif any(kw in alert_names for kw in ["cpu", "memory", "resource"]): action = "調整資源限制或擴展副本" kubectl = f"kubectl scale deployment/{target} --replicas=2 -n awoooi-prod" - confidence = 0.75 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "medium" else: action = "進行安全重啟以排除未知問題" kubectl = f"kubectl rollout restart deployment/{target} -n awoooi-prod" - confidence = 0.60 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "medium" return AgentOpinion( @@ -250,11 +250,11 @@ class SecurityAgent(ExpertAgent): if security_concerns: action = "建議先隔離受影響服務,啟用 NetworkPolicy 限制" - confidence = 0.70 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "critical" else: action = "無明顯資安風險,建議 SRE 處理" - confidence = 0.85 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 risk = "low" return AgentOpinion( @@ -289,7 +289,7 @@ class CostAgent(ExpertAgent): agent_type=self.agent_type, action=action, reasoning="FinOps 分析: 使用 HPA 可在負載降低後自動縮減,相比固定擴容可節省約 40% 成本", - confidence=0.75, + confidence=0.0, # 🔴 規則匹配,非 AI 分析 risk_assessment="成本風險: low,使用 HPA 可自動調節", kubectl_command=kubectl, priority=4, @@ -313,11 +313,11 @@ class PerformanceAgent(ExpertAgent): if any(kw in alert_names for kw in ["latency", "p99", "slow"]): action = "建議增加資源限制並啟用 PodDisruptionBudget" kubectl = f"kubectl patch deployment/{target} -n awoooi-prod -p '{{\"spec\":{{\"template\":{{\"spec\":{{\"containers\":[{{\"name\":\"{target}\",\"resources\":{{\"limits\":{{\"cpu\":\"2\",\"memory\":\"2Gi\"}}}}}}]}}}}}}}}'" - confidence = 0.80 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 else: action = "當前效能指標正常,建議觀察" kubectl = None - confidence = 0.70 + confidence = 0.0 # 🔴 規則匹配,非 AI 分析 return AgentOpinion( agent_type=self.agent_type,