fix(auto_approve+solver): P1 kubectl gate + P2 Nemo path kubectl 強制
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 9m56s

P1 安全漏洞 (auto_approve.py):
- 新增條件 1d:action 必須含 kubectl 關鍵字才可自動執行
- Solver 經 OpenClaw Nemo 路徑輸出自然語言 → 條件 1c 通過但無法執行
- 修復:自然語言 action → 降級人工審核(NO_PLAYBOOK reason)

P2 執行障礙 (solver_agent.py):
- Nemo 格式路徑:action_title 不含 kubectl → return [] → 觸發 _degraded_plan
- _default_action_for_category:舊自然語言 → 真實 kubectl 調查指令
- 降級路徑現在輸出 kubectl get/top/exec 等唯讀指令,可被 auto_approve 1d 正確評估

ADR-082: Phase 2 多 Agent 協作
2026-04-17 ogt + Claude Sonnet 4.6(亞太): P1+P2 hotfix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-17 14:49:53 +08:00
parent f421e652d3
commit 93205ceab0
2 changed files with 39 additions and 10 deletions

View File

@@ -290,6 +290,22 @@ class AutoApprovePolicy:
confidence=confidence,
)
# 條件 1d: 自然語言描述不可自動執行2026-04-17 ogt + Claude Sonnet 4.6
# 根因Solver 經 OpenClaw Nemo 路徑輸出「重啟 Crash Looping Pod」等自然語言
# action 非空 → 條件 1c 通過 → auto_approved=True
# 但 kubectl_command 為空 → 實際無法執行 → incident 卡在 investigating
# 修復action 必須含 kubectl 關鍵字才可自動執行,否則降級人工審核
_kubectl_cmd = proposal_data.get("kubectl_command", "") or ""
_has_kubectl = "kubectl" in action.lower() or "kubectl" in _kubectl_cmd.lower()
if not _has_kubectl:
return self._reject(
reason=AutoApproveReason.NO_PLAYBOOK,
detail=f"Action '{action[:60]}' is natural language — no kubectl command, requires human review",
risk_level=risk_level,
trust_score=trust_score,
confidence=confidence,
)
# 條件 2: 風險等級必須在允許列表中
if risk_level not in self.config.allowed_risk_levels:
return self._reject(