20260706:新增一些文章

This commit is contained in:
2026-07-06 10:14:02 +08:00
parent 6021dea160
commit 24b006225b
194 changed files with 8512 additions and 91 deletions

View File

@@ -0,0 +1,39 @@
---
title: "Circuit Breaker Pattern熔断器模式"
created: 2026-06-29
updated: 2026-06-29
type: concept
tags: [safety, loop-engineering, reliability, pattern]
sources: [[prompt-to-loop-engineering-2026]]
confidence: high
---
# Circuit Breaker Pattern
> 在 [[loop-engineering|Loop Engineering]] 中,熔断器是 [[loop-contract|Loop Contract]] 的 BUDGET 维度固化为硬约束的安全机制——连续失败 N 次即跳闸。
## 核心参数
- **max_consecutive_failures**:连续失败次数上限。一旦连续报错 N 次,系统立即跳闸并回退代码,将当前运行栈日志打包成工单转交人工
- **max_runtime_min**:墙上时间上限。超时无条件熔断,不等待当前操作完成
## 设计原理
熔断器来自分布式系统设计模式,在自主 Agent 循环中承担 **安全预算执行者** 角色:
1. **失败计数**:跟踪连续失败次数
2. **阈值触发**:达到 max_consecutive_failures → OPEN 状态(拒绝所有操作)
3. **优雅降级**:回退代码 → 打包日志 → 转交人工,而非静默丢失
## 与看门狗的分工
| 机制 | 监控对象 | 触发条件 | 响应 |
|------|---------|---------|------|
| [[circuit-breaker-pattern|熔断器]] | 任务级失败 | 连续失败 N 次 | 跳闸 + 回退 |
| [[watchdog-pattern|看门狗]] | 进程级异常 | CPU 满载 + 无 I/O | SIGKILL |
## 相关概念
- [[loop-contract|Loop Contract]]
- [[watchdog-pattern|看门狗]]
- [[loop-engineering|Loop Engineering]]