feat(api): ADR-030 Phase 2 診斷資料收集強化
實作智能自動修復系統的資料收集層: 1. k8s_diagnostics.py - K8s 診斷服務 - Pod Events/Logs/ResourceUsage 收集 - CrashLoopBackOff/OOM/ImagePull 偵測 - 非同步並行收集 + 錯誤容忍 2. diagnosis_aggregator.py - 診斷聚合器 - 整合 K8s + SignOz + Expert Rules - DiagnosisContext 提供結構化 LLM Prompt - DiagnosisSignal 信號分析 3. decision_manager.py - 決策引擎整合 - Step 2.5 加入診斷收集 - 傳遞 diagnosis_context 給 LLM 4. openclaw.py - LLM Prompt 增強 - 整合 K8s/SignOz 深度診斷上下文 - 支援 diagnosis_signals 摘要 ADR-030 架構: 診斷先行,根因分析,非盲目重啟 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1119,10 +1119,22 @@ Trace URL: {signoz_trace_url}
|
||||
"""
|
||||
|
||||
# 2026-03-27: 整合 Expert System 診斷上下文
|
||||
# 2026-03-26: ADR-030 Phase 2 - 加入 K8s/SignOz 診斷上下文
|
||||
expert_diagnosis_context = ""
|
||||
if expert_context:
|
||||
diagnosis_cmds = expert_context.get("suggested_diagnosis_commands", [])
|
||||
diagnosis_cmds_str = "\n".join([f" - `{cmd}`" for cmd in diagnosis_cmds]) if diagnosis_cmds else " - (無)"
|
||||
|
||||
# ADR-030: 加入完整診斷上下文 (如果有)
|
||||
full_diagnosis = expert_context.get("diagnosis_context", "")
|
||||
diagnosis_signals = expert_context.get("diagnosis_signals", [])
|
||||
signals_summary = ""
|
||||
if diagnosis_signals:
|
||||
signals_summary = "\n".join([
|
||||
f" - [{s.get('severity', 'info').upper()}] {s.get('source', 'unknown')}: {s.get('message', 'N/A')[:100]}"
|
||||
for s in diagnosis_signals[:5]
|
||||
])
|
||||
|
||||
expert_diagnosis_context = f"""
|
||||
## 🔍 Expert System Initial Diagnosis
|
||||
- **Matched Rule**: {expert_context.get('initial_diagnosis', 'unknown')}
|
||||
@@ -1132,8 +1144,15 @@ Trace URL: {signoz_trace_url}
|
||||
- **Suggested Diagnosis Commands**:
|
||||
{diagnosis_cmds_str}
|
||||
|
||||
**IMPORTANT**: The Expert System has provided an initial diagnosis.
|
||||
Consider this context but apply your own analysis. If Expert says "human review required",
|
||||
{f'''## 🩺 K8s/SignOz Deep Diagnosis (ADR-030)
|
||||
{full_diagnosis}
|
||||
|
||||
### Diagnosis Signals
|
||||
{signals_summary if signals_summary else " - (No signals detected)"}
|
||||
''' if full_diagnosis else ''}
|
||||
|
||||
**IMPORTANT**: The Expert System and Diagnostic Aggregator have provided context.
|
||||
Consider this data but apply your own analysis. If Expert says "human review required",
|
||||
provide diagnostic guidance rather than automated fixes.
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user