Install
openclaw skills install @thcjp/auto-healing-manager五阶段故障自愈闭环管理器v1.0,检测→诊断→修复→验证→回归完整闭环,30天无人值守期间故障自愈率80%。触发:故障自愈/自动修复/自愈管理/auto-healing/fault-healing/混沌工程/故障预案
openclaw skills install @thcjp/auto-healing-manager核心功能: 本技能提供器v1等能力。
检测→诊断→修复→验证→回归完整闭环,30天无人值守期间故障自愈率从0%提升至80%。
五阶段闭环: 检测(阶段1,接收fault_event)→诊断(阶段2,根因分析)→修复(阶段3,执行预案)→验证(阶段4,健康检查)→回归(阶段5,业务验证)。任一阶段失败则停止后续阶段并记录,避免级联错误。
故障预案库: config/fault_playbook.yaml定义11个常见故障预案(PG连接池耗尽/Docker容器停止/Cookie过期/LLM 429/磁盘满/Gateway无响应/MCP超时/Redis失败/网络分区/CPU高/内存泄漏),每个预案包含检测条件/诊断规则/修复步骤/验证方法/回滚方案。
冷却机制: 同一fault_type在300秒内不重复触发(可通过force=true强制覆盖),防止修复风暴。
并发控制: 最大3个并发自愈(asyncio.Semaphore),防止资源争用。
PG持久化: auto_healing_events表(event_id/fault_type/diagnosis/repair_action/verification_result/created_at),ThreadedConnectionPool(minconn=1,maxconn=5),PG不可用时降级到文件持久化。
| 异常 | 错误码 | 处理 |
|---|---|---|
| fault_type为空 | INVALID_ARG | 返回错误,提示必填 |
| fault_context非合法JSON | INVALID_JSON | 返回错误,提示格式 |
| 冷却中 | COOLDOWN_ACTIVE | 返回剩余秒数,提示用force=true强制 |
| 预案未找到 | PLAYBOOK_NOT_FOUND | 返回可用fault_type列表 |
| 阶段2诊断失败 | STAGE2_FAILED | 记录并停止,不执行修复 |
| 阶段3修复失败 | STAGE3_FAILED | 记录并停止,不执行验证 |
| 阶段4验证失败 | STAGE4_FAILED | 记录并停止,不执行回归 |
| 阶段5回归失败 | STAGE5_FAILED | 记录,EP链路可能受影响 |
| PG不可用 | (降级) | 自动降级到文件持久化,不报错 |
| MCP不可用 | TRIGGER_ERROR | 返回异常信息,记录日志 |
{
"action": "trigger|diagnose|repair|verify|regression|history|healthcheck",
"fault_type": "docker_container_stopped",
"fault_context": "{\"container_name\":\"redis\"}",
"force": false,
"dry_run": false,
"full": false,
"limit": 50,
"status": "completed"
}
字段说明:
action: 操作类型(trigger触发/diagnose诊断/repair修复/verify验证/regression回归/history历史/healthcheck健康检查)fault_type: 故障类型标识(除history/healthcheck外必填)fault_context: 故障上下文JSON字符串(用于{placeholder}替换)force: 是否强制触发忽略冷却(仅trigger)dry_run: 干跑模式(仅repair)full: 全量验证(仅regression)limit: 历史条数(仅history,默认50)status: 按状态过滤(仅history,如completed/failed){
"success": true,
"data": {
"event_id": "a1b2c3d4-...",
"fault_type": "docker_container_stopped",
"stages": {
"stage1_detection": {"status": "detected", "passed": true},
"stage2_diagnosis": {"status": "diagnosed", "passed": true, "diagnosis": {...}},
"stage3_repair": {"status": "repaired", "passed": true, "repair": {...}},
"stage4_verification": {"status": "verified", "passed": true, "verification": {...}},
"stage5_regression": {"status": "regressed", "passed": true, "regression": {...}}
},
"status": "completed",
"ep_chain_ok": true
},
"error": null,
"code": null
}
字段说明:
event_id: 自愈事件唯一ID(UUID)stages: 五阶段执行结果(stage1~stage5)status: 事件最终状态(completed/failed)ep_chain_ok: EP-01~EP-05链路是否完整(阶段5结果)docker start redis,等待healthy{success:true, data:{status:"completed", ep_chain_ok:true}}{success:false, data:{cooldown_remaining_sec:180}, error:"冷却中", code:"COOLDOWN_ACTIVE"}{success:true, data:{steps_executed:2, steps_succeeded:2, details:[{action:"switch_provider", dry_run:true}]}}{success:true, data:{events:[...], count:3}}| 验证项 | 标准 |
|---|---|
| 五阶段闭环 | trigger_healing单次调用完整执行5阶段 |
| 阶段失败停止 | 任一阶段失败不执行后续阶段 |
| 预案库覆盖 | ≥10个常见故障预案(当前11个) |
| 冷却机制 | 同fault_type 300秒内不重复触发 |
| 并发控制 | 最大3个并发自愈 |
| PG持久化 | auto_healing_events表,ThreadedConnectionPool(1,5) |
| 文件降级 | PG不可用时降级到data/auto_healing/state.json |
| EP链路回归 | 阶段5验证PG+Docker+Gateway+磁盘4项核心 |
| 变量替换 | {placeholder}替换为context值 |
| 修复重试 | 单步最多2次重试 |
| 历史查询 | 支持按fault_type与status过滤 |
| 健康检查 | 返回预案数/PG状态/自愈统计 |
| 版本 | 日期 | 变更内容 |
|---|---|---|
| v1.0 | 2026-07-07 | ARCH-8初始版本:五阶段闭环+11预案+PG持久化 |