feat: 自动开发管道 Phase A — 状态机编排 + 流式卡片 + 记忆系统#10
Conversation
新增 /dev 命令触发多步自动开发管道: - Pipeline 状态机 (plan → plan_review → implement → code_review → push) - 各阶段独立 system prompt,review 步骤支持 APPROVED/REJECTED 解析 - 失败自动重试(最多 2 轮),review 反馈注入下一轮 prompt - 流式卡片更新(3s/500字符节流),管道阶段进度卡片 - 跨会话记忆系统(session_summaries 独立表,30 天自动清理) - executor.execute() 重构为 options 对象模式,支持 systemPromptOverride Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- orchestrator: 完整流程、plan/code review 拒绝重试、失败边界、 verdict 解析(APPROVED/REJECTED/unparseable)、成本累计、摘要生成 - message-builder: buildStreamingCard、buildPipelineCard 各阶段展示 - database: session_summaries CRUD、limit、chat/user 隔离、 cleanup 不影响 summaries、旧摘要清理 - 修复 ORDER BY 在同时间戳下的不确定顺序 (加 id DESC) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- 提取 acquireSession() 修复并发保护 TOCTOU 竞态,检查通过后立即锁定 - /dev 命令增加 containsDangerousCommand 安全检查 - review agent 失败策略从 fail-open 改为 fail-closed - 新增 MAX_ITERATIONS=20 循环保护,防止状态机死循环 - onPhaseChange 回调加 try-catch,回调异常不中断管道 - 新增 failedAtPhase 字段精确定位失败阶段 - PHASE_META 单一数据源重构,消除 message-builder 中的重复定义 - 流式更新改用 buildPipelineCard 保留阶段进度信息 - 测试: 新增 7 个用例 (failedAtPhase、MAX_ITERATIONS、回调异常容错) 更新 fail-closed 断言,修复 mockReset 防止 mock 泄漏 (115→122) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 54s —— View job Code Review: Auto Development Pipeline (Phase A)
|
| # | Severity | File | Confidence | Description |
|---|---|---|---|---|
| 1 | 🟡 warning | src/feishu/event-handler.ts:396-408 |
85 | acquireSession TOCTOU is still racy — check + set are two separate DB calls with no atomic CAS. Two concurrent requests can both read idle before either writes busy. |
| 2 | 🟡 warning | src/pipeline/orchestrator.ts:136 |
80 | Mixed mutation pattern — state.totalCostUsd is mutated in-place, then the same state is spread into a new object. Works today but fragile for future changes. |
| 3 | 🟡 warning | src/feishu/event-handler.ts:537-544 |
78 | /dev pipeline bypasses the per-chat task queue (taskQueue), while regular messages go through it. This creates an inconsistency in ordering guarantees. |
| 4 | 🟡 warning | src/pipeline/orchestrator.ts:365-385 |
82 | parseVerdict full-text fallback uses includes('APPROVED') which could match substrings (e.g., "NOT APPROVED"). The fail-closed default mitigates risk, but a word-boundary regex would be more precise. |
Overall Assessment
This is a well-structured addition. The state machine design is clean, the separation of system prompts per role is good, and the test coverage (600+ lines of orchestrator tests) is thorough with good edge-case coverage for retries, failures, and callback resilience.
Strengths:
- Fail-closed review strategy (unparseable verdict → REJECTED) is the right security posture
- MAX_ITERATIONS loop guard prevents runaway pipelines
- Callback error resilience (try/catch around
onPhaseChange) prevents card update failures from killing the pipeline - Session summaries surviving session cleanup is well-designed and tested
- The executor refactor to options-object pattern is a clean improvement
The issues above are all warnings, not blockers. The most impactful one to address would be #1 (the acquireSession atomicity), since the PR explicitly calls out TOCTOU as a goal. A single UPDATE ... WHERE status != 'busy' with a changes check would make it truly atomic.
- acquireSession 改用原子 SQL `UPDATE WHERE status != 'busy'` + changes 检查,
彻底消除 TOCTOU 竞态(新增 database.tryAcquire + sessionManager.tryAcquire)
- orchestrator 各阶段从 `state.totalCostUsd += ...` 原地 mutation 改为
`const totalCostUsd = state.totalCostUsd + ...` 后在 spread 中赋值,模式一致
- parseVerdict 全文搜索从 includes('APPROVED') 改为 /\bAPPROVED\b/i
词边界正则,避免匹配 "NOT APPROVED" 等子串
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 50s —— View job Re-review: Auto Development Pipeline (Phase A)
Previous Issues Status
3 of 4 previous issues resolved. New Commits ReviewReviewed the fix commit ✅ ApprovedThe fix commit cleanly addresses the three actionable review findings. The atomic CAS pattern for The remaining task-queue bypass (issue #3) is a deliberate design choice with adequate concurrency protection and doesn't warrant blocking the PR. |
解决冲突: - executor.ts: 保留 options 对象模式 (ExecuteInput),合入 main 的 restart 信号跟踪 + disableWorkspaceTool + maxTurns/maxBudgetUsd - event-handler.ts: 合入 main 的 restart 逻辑 + sendResultCard + /project 路径安全校验 + processQueue,保留我们的 pipeline + acquireSession + /dev 命令 - executor.test.ts: 更新测试从位置参数改为 ExecuteInput 对象模式 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 47s —— View job Re-review: Auto Development Pipeline (Phase A)
Previous Issues Status
All 4 previous review threads resolved. New IssuesNo new issues found at confidence ≥ 75. ✅ ApprovedAll three actionable findings from the previous review have been cleanly fixed in commit Code quality summary:
|
* feat: 自动开发管道 Phase A — 状态机编排 + 流式卡片 + 记忆系统
新增 /dev 命令触发多步自动开发管道:
- Pipeline 状态机 (plan → plan_review → implement → code_review → push)
- 各阶段独立 system prompt,review 步骤支持 APPROVED/REJECTED 解析
- 失败自动重试(最多 2 轮),review 反馈注入下一轮 prompt
- 流式卡片更新(3s/500字符节流),管道阶段进度卡片
- 跨会话记忆系统(session_summaries 独立表,30 天自动清理)
- executor.execute() 重构为 options 对象模式,支持 systemPromptOverride
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: 添加 pipeline orchestrator、streaming card、database summary 测试 (43 个)
- orchestrator: 完整流程、plan/code review 拒绝重试、失败边界、
verdict 解析(APPROVED/REJECTED/unparseable)、成本累计、摘要生成
- message-builder: buildStreamingCard、buildPipelineCard 各阶段展示
- database: session_summaries CRUD、limit、chat/user 隔离、
cleanup 不影响 summaries、旧摘要清理
- 修复 ORDER BY 在同时间戳下的不确定顺序 (加 id DESC)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: 管道健壮性加固 — TOCTOU 修复、fail-closed 审查、循环保护
- 提取 acquireSession() 修复并发保护 TOCTOU 竞态,检查通过后立即锁定
- /dev 命令增加 containsDangerousCommand 安全检查
- review agent 失败策略从 fail-open 改为 fail-closed
- 新增 MAX_ITERATIONS=20 循环保护,防止状态机死循环
- onPhaseChange 回调加 try-catch,回调异常不中断管道
- 新增 failedAtPhase 字段精确定位失败阶段
- PHASE_META 单一数据源重构,消除 message-builder 中的重复定义
- 流式更新改用 buildPipelineCard 保留阶段进度信息
- 测试: 新增 7 个用例 (failedAtPhase、MAX_ITERATIONS、回调异常容错)
更新 fail-closed 断言,修复 mockReset 防止 mock 泄漏 (115→122)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: 修复 PR review 反馈 — 原子 CAS 并发锁、消除 state mutation、verdict 词边界
- acquireSession 改用原子 SQL `UPDATE WHERE status != 'busy'` + changes 检查,
彻底消除 TOCTOU 竞态(新增 database.tryAcquire + sessionManager.tryAcquire)
- orchestrator 各阶段从 `state.totalCostUsd += ...` 原地 mutation 改为
`const totalCostUsd = state.totalCostUsd + ...` 后在 spread 中赋值,模式一致
- parseVerdict 全文搜索从 includes('APPROVED') 改为 /\bAPPROVED\b/i
词边界正则,避免匹配 "NOT APPROVED" 等子串
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
/dev <task>命令触发多步自动开发管道(plan → plan_review → implement → code_review → push)Changes
src/pipeline/— 新增 orchestrator 状态机、types、promptssrc/feishu/event-handler.ts—/dev命令处理 +acquireSession并发保护src/feishu/message-builder.ts—buildPipelineCard管道进度卡片src/claude/executor.ts— 重构为 options 对象模式,支持systemPromptOverridesrc/session/— 新增 session_summaries 表,30 天自动清理Test plan
/dev <task>触发完整管道流程/dev命令,第二条应被拒绝🤖 Generated with Claude Code