diff --git a/docs/design/architecture-v2.6.md b/docs/design/architecture-v2.6.md index f603772..aa4e6b0 100644 --- a/docs/design/architecture-v2.6.md +++ b/docs/design/architecture-v2.6.md @@ -16,19 +16,25 @@ | v2.6.1 | 2026-05-15 | 司马懿评审反馈 + Mail 退役决策 + 质量门控 + 决策记录 + 工程修正 | | v2.6.2 | 2026-05-15 | 课题1设计决策:三层执行模型、续杯机制、AI驱动retry、Guardrail体系、must_haves三件套、分级审查矩阵 | | v2.6.2.1 | 2026-05-15 | 司马懿评审反馈:L2/L3区分标准、timeout修正、outputs关联attempt、Scope Guard异步、risk_level自动 | +| v2.6.3 | 2026-05-15 | 课题2设计决策:双层事件架构(EventBus+Signal File+Tick)、L1/L2/L3上下文传递、黑板是索引不是仓库、依赖驱动并行/串行、Phase规划更新 | -### 课题 1 遗留 TODO(需后续课题解决) +### 课题 1-2 遗留 TODO(需后续课题解决) | # | 待解决事项 | 归属课题 | 说明 | |---|----------|---------|------| -| T1-1 | spawn sub 是否阻塞?需要调查 | 课题 2 | 决定 L2 层能否真正实现"轻量异步" | -| T1-2 | 事件驱动取代 polling tick | 课题 2 | Retry、Agent 协商等依赖即时响应 | -| T1-3 | 依赖推进(done→自动解锁下游) | 课题 2 | 需要事件驱动的 complete→auto-unlock | -| T1-4 | Agent 间自主协商机制 | 课题 2+3 | 课题 2 事件驱动 + 课题 3 挑战体系共同支撑 | +| ~~T1-1~~ | ~~spawn sub 是否阻塞?需要调查~~ | ~~课题 2~~ | ✅ 课题 2 解决:不阻塞,signal file 异步 | +| ~~T1-2~~ | ~~事件驱动取代 polling tick~~ | ~~课题 2~~ | ✅ 课题 2 解决:双层事件架构 | +| ~~T1-3~~ | ~~依赖推进(done→自动解锁下游)~~ | ~~课题 2~~ | ✅ 课题 2 解决:task_completed 事件即时解锁 | +| ~~T2-1~~ | ~~files_modified 冲突检测~~ | ~~课题 2~~ | ✅ D2-4 决策:不做,Agent 评论自然协调 | +| ~~T2-2~~ | ~~Auto-compact~~ | ~~课题 2~~ | ✅ D2-6 决策:不做,隔离 session 天然无 context rot | +| T1-4 | Agent 间自主协商机制 | 课题 3 | 事件驱动 + 挑战体系共同支撑 | | T1-5 | Scope Guard 的 Skill 定义 | 课题 4 | scope_declaration 格式、检查 prompt 模板 | -| T1-6 | truths 验证的具体实现 | 课题 4 | AI 级别验证,怎么让 AI 判断 truths 达成 | +| T1-6 | truths 验证的具体实现 | 课题 4 | AI 级别验证,怎么让 AI 判断 truths 达成 | | T1-7 | outputs attempt_number 过滤规则 | 课题 4 | 重试时 Agent 看到之前 attempt output 的规则 | -| T1-8 | 状态机细化(review 轮次、sub_status) | 课题 3 | 挑战体系引入 review 内部状态 | +| T1-8 | 状态机细化(review 轮次、sub_status) | 课题 3 | 挑战体系引入 review 内部状态 | +| T2-3 | blackboard.py 写操作自动写 signal file | Phase 1 实现 | CLI 层自动完成 | +| T2-4 | EventBus + Signal File Watcher 实现 | Phase 1 实现 | Daemon 核心改造 | +| T2-5 | L2/L3 分层读取 API | Phase 2 实现 | blackboard.py read --level L2/L3 | --- @@ -912,20 +918,20 @@ python3 ~/.sanguo_projects/sanguo_moziplus/cli/blackboard.py create --title "分 ## 6. 关键场景流程 -### 6.1 庞统规划 + Agent 领任务(事件驱动版) +### 6.1 庞统规划 + Agent 领任务(事件驱动版) ``` -用户 → 庞统(主session):“设计一个动量因子策略” +用户 → 庞统(主session):"设计一个动量因子策略" ↓ 庞统在黑板上写: - 创建 task-001(数据准备,pending,无依赖) - 创建 task-002(因子计算,pending,depends_on: [task-001]) - 创建 task-003(回测验证,pending,depends_on: [task-002]) - - 评论:“建议赵云领 001,张飞领 002 和 003” + - 评论:"建议赵云领 001,张飞领 002 和 003" ↓ 庞统写 signal file: task_created ↓ -Daemon EventBus 收到 task_created(低优先级) +Daemon EventBus 收到 task_created(低优先级) → Tick 批量处理: spawn 赵云通知 task-001 ↓ 赵云读黑板 → claim task-001 → 执行 → 写产出 → 更新 status→done @@ -936,26 +942,26 @@ Daemon EventBus 即时收到 task_completed → task-002 的依赖全部满足 → 触发 task_ready → spawn 张飞执行 task-002 ↓ -(同理 task-002 done → 即时触发 task-003) +(同理 task-002 done → 即时触发 task-003) ``` -**对比 polling 版**:task-001 done 到 task-002 spawn 的延迟从 ≤60s 降到 ~0ms。 +**对比 polling 版**:task-001 done 到 task-002 spawn 的延迟从 ≤60s 降到 ~0ms。 -### 6.2 Agent 间协作讨论(事件驱动版) +### 6.2 Agent 间协作讨论(事件驱动版) ``` 张飞执行 task-002 时发现需要分钟线数据 ↓ -张飞写评论:“@赵云 task-002 需要分钟线数据,能帮忙下载吗?” +张飞写评论:"@赵云 task-002 需要分钟线数据,能帮忙下载吗?" 张飞更新任务状态 → blocked → 写 signal file: comment_added ↓ Daemon EventBus 即时收到 comment_added → 解析 @mention → 赵云 - → spawn 赵云(L1 消息含评论摘要) + → spawn 赵云(L1 消息含评论摘要) ↓ 赵云读黑板 → 看到评论 → 下载数据 → 写产出 -赵云写评论:“@张飞 数据就绪,可以继续” +赵云写评论:"@张飞 数据就绪,可以继续" → 写 signal file: comment_added ↓ Daemon EventBus 即时收到 → @mention → spawn 张飞 @@ -963,7 +969,7 @@ Daemon EventBus 即时收到 → @mention → spawn 张飞 张飞读黑板 → 看到数据就绪 → 继续 task-002 ``` -**对比 polling 版**:@mention 响应从 ≤60s 降到 ≤1s。 +**对比 polling 版**:@mention 响应从 ≤60s 降到 ≤1s。 ### 6.3 Agent 发现风险 @@ -1178,22 +1184,22 @@ Agent 写产出时,`content_path` 指向此目录。Daemon 存档 session jsonl ### Phase 1: 黑板基础设施 1. SQLite blackboard.db(5 表 + WAL) 2. blackboard.py CLI(读写操作 + signal file 写入) -3. Daemon 核心循环(EventBus + Signal File Watcher + Tick 兜底) +3. Daemon 核心循环(EventBus + Signal File Watcher + Tick 兜底) 4. Session 管理(spawn + 存档 + 清理) 5. L1 spawn message 模板 ### Phase 2: 事件驱动 + Agent 交互 6. Agent 黑板操作 Skill -7. EventBus 即时处理(task_completed → 解锁下游、@mention → spawn) -8. 任务依赖自动推进(complete→auto-unlock) -9. 评论 + @mention 通知链路(即时版) +7. EventBus 即时处理(task_completed → 解锁下游、@mention → spawn) +8. 任务依赖自动推进(complete→auto-unlock) +9. 评论 + @mention 通知链路(即时版) 10. 健康检查(stale reclaim + zombie 检测) -11. L2/L3 分层读取 API(blackboard.py read --level) +11. L2/L3 分层读取 API(blackboard.py read --level) ### Phase 3: 智能化 12. 庞统 AI 规划(读需求 → 创建任务 + 分配建议 + must_haves) 13. Agent 自主领活(读黑板 → 匹配职责 → claim + scope_declaration) -14. 产出验证门禁(Output Guard + Scope Guard) +14. 产出验证门禁(Output Guard + Scope Guard) 15. AI 驱动 Retry + Circuit breaker 16. 经验沉淀(observation → knowledge base) @@ -1205,7 +1211,7 @@ Agent 写产出时,`content_path` 指向此目录。Daemon 存档 session jsonl |------|---------|-----------|------| | 共享状态 | Hermes SQLite + Network-AI flock | SQLite WAL + 事务 CAS | 原子性 + 无外部依赖 | | 讨论 | Hermes kanban_comment | comments 表 + @mention | 简单追加写入,所有人可见 | -| 事件驱动 | open-multi-agent EventEmitter | asyncio.Queue EventBus + Signal File | 零基础设施,进程内 ~0ms,跨进程 ~500ms | +| 事件驱动 | open-multi-agent EventEmitter | asyncio.Queue EventBus + Signal File | 零基础设施,进程内 ~0ms,跨进程 ~500ms | | 调度 | Hermes Dispatcher 60s tick | EventBus 即时 + Signal File + 30s Tick 兜底 | 即时响应 + 健康检查 | | 上下文传递 | GSD Wave Execution + Claude Code file ref | L1 必传 + L2/L3 按需读取 | 信号噪声比优化 | | 通知 | Claude Code idle notification | Daemon spawn + L1 message | OpenClaw 原生能力 |