@adamancyzhang/claude-orchestrator 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +179 -186
  2. package/dist/cli/commands.d.ts +6 -17
  3. package/dist/cli/commands.js +106 -172
  4. package/dist/cli/commands.js.map +1 -1
  5. package/dist/config.d.ts +22 -14
  6. package/dist/config.js +47 -20
  7. package/dist/config.js.map +1 -1
  8. package/dist/index.js +110 -246
  9. package/dist/index.js.map +1 -1
  10. package/dist/leader/decision-engine.d.ts +35 -0
  11. package/dist/leader/decision-engine.js +102 -0
  12. package/dist/leader/decision-engine.js.map +1 -0
  13. package/dist/leader/index.js +12 -2
  14. package/dist/leader/index.js.map +1 -1
  15. package/dist/leader/recovery.d.ts +2 -0
  16. package/dist/leader/recovery.js +37 -22
  17. package/dist/leader/recovery.js.map +1 -1
  18. package/dist/leader/state.d.ts +2 -1
  19. package/dist/leader/state.js +39 -2
  20. package/dist/leader/state.js.map +1 -1
  21. package/dist/leader/task-generator.d.ts +34 -0
  22. package/dist/leader/task-generator.js +93 -0
  23. package/dist/leader/task-generator.js.map +1 -0
  24. package/dist/leader/tui.js +8 -5
  25. package/dist/leader/tui.js.map +1 -1
  26. package/dist/leader/watcher.d.ts +3 -1
  27. package/dist/leader/watcher.js +14 -2
  28. package/dist/leader/watcher.js.map +1 -1
  29. package/dist/models/schemas.d.ts +60 -96
  30. package/dist/models/schemas.js +27 -44
  31. package/dist/models/schemas.js.map +1 -1
  32. package/dist/modules/message-router.d.ts +1 -3
  33. package/dist/modules/message-router.js +3 -26
  34. package/dist/modules/message-router.js.map +1 -1
  35. package/dist/modules/registry.js +3 -3
  36. package/dist/modules/registry.js.map +1 -1
  37. package/dist/modules/task-queue.d.ts +1 -1
  38. package/dist/modules/task-queue.js +28 -2
  39. package/dist/modules/task-queue.js.map +1 -1
  40. package/dist/skills/CLAUDE.md +155 -0
  41. package/dist/skills/claude-code-developer/SKILL.md +325 -0
  42. package/dist/skills/claude-orchestrator/SKILL.md +180 -0
  43. package/dist/skills/task-acceptance/SKILL.md +201 -0
  44. package/dist/skills/task-execution/SKILL.md +142 -0
  45. package/dist/skills/task-planning/SKILL.md +188 -0
  46. package/dist/skills/task-review/SKILL.md +220 -0
  47. package/dist/skills/task-traceability/SKILL.md +154 -0
  48. package/dist/skills/task-verification/SKILL.md +194 -0
  49. package/dist/templates/leader-decide.md +59 -0
  50. package/dist/templates/leader-decompose.md +69 -0
  51. package/dist/templates/worker-accept.md +46 -0
  52. package/dist/templates/worker-build.md +45 -0
  53. package/dist/templates/worker-plan.md +43 -0
  54. package/dist/templates/worker-review.md +46 -0
  55. package/dist/templates/worker-verify.md +47 -0
  56. package/dist/utils/exec.d.ts +5 -0
  57. package/dist/utils/exec.js +25 -0
  58. package/dist/utils/exec.js.map +1 -1
  59. package/dist/worker/watcher.d.ts +3 -0
  60. package/dist/worker/watcher.js +72 -2
  61. package/dist/worker/watcher.js.map +1 -1
  62. package/dist/zk/client.d.ts +0 -5
  63. package/dist/zk/client.js +0 -27
  64. package/dist/zk/client.js.map +1 -1
  65. package/dist/zk/paths.d.ts +8 -10
  66. package/dist/zk/paths.js +1 -6
  67. package/dist/zk/paths.js.map +1 -1
  68. package/dist/zk/watcher.d.ts +0 -2
  69. package/dist/zk/watcher.js +0 -3
  70. package/dist/zk/watcher.js.map +1 -1
  71. package/package.json +2 -2
  72. package/dist/modules/context-store.d.ts +0 -10
  73. package/dist/modules/context-store.js +0 -25
  74. package/dist/modules/context-store.js.map +0 -1
  75. package/dist/templates/leader.md +0 -10
  76. package/dist/templates/worker.md +0 -8
@@ -0,0 +1,188 @@
1
+ ---
2
+ name: task-planning
3
+ description: Requirement analysis and task breakdown for the Planner role. Use when the Planner needs to analyze requirements, define task blueprints, break down work into executable tasks with acceptance criteria, establish responsibility chain ordering, and push tasks to the orchestrator queue — all with full traceability from requirements to tasks. Triggers on keywords like "分析需求", "拆解任务", "制定计划", "task planning", "blueprint", "break down", "define tasks", "规划", or when starting a new work cycle that needs tasks created.
4
+ ---
5
+
6
+ # Task Planning
7
+
8
+ > 规划不是猜测,是分析需求 → 定义蓝图 → 拆解可执行任务 → 建立可验证的验收标准。本技能与 [[task-traceability]] 协作,确保每次规划产出清晰、可执行、可追溯——每个任务都可追溯到具体需求。
9
+
10
+ ---
11
+
12
+ ## 何时触发
13
+
14
+ - Leader 分配新的需求/目标给 Planner
15
+ - 用户说"分析一下这个需求"、"拆解任务"、"制定执行计划"
16
+ - 新的工作周期开始,需要产出任务列表
17
+ - 现有蓝图需要修订或补充
18
+
19
+ ---
20
+
21
+ ## 规划六步法
22
+
23
+ 按顺序执行,每一步通过才进入下一步。任一步产出不清晰 → 回退澄清。
24
+
25
+ ### 1. 读取需求上下文
26
+
27
+ 定位并理解需求来源:
28
+
29
+ - 如果是 Leader 通过 orchestrator 分配的需求,通过 `claude-orchestrator get-context --key <需求key>` 获取
30
+ - 如果是本地文档(如 `docs/pm/YYYY-MM-DD/`),读取完整内容
31
+ - 如果是代码库需求(如 Issue、PR 描述),读取相关文档和代码
32
+
33
+ 提取关键信息:
34
+ - 业务目标和背景
35
+ - 约束条件和边界
36
+ - 期望的交付标准和截止时间
37
+
38
+ ### 2. 定义任务蓝图
39
+
40
+ 输出蓝图文档,包含以下要素:
41
+
42
+ ```markdown
43
+ # 任务蓝图:[目标名称]
44
+
45
+ > Planner | YYYY-MM-DD | 版本 v1
46
+
47
+ ## 目标
48
+
49
+ (一句话描述要达成什么)
50
+
51
+ ## 背景
52
+
53
+ (为什么需要做这个,解决什么问题)
54
+
55
+ ## 范围与非范围
56
+
57
+ **范围内:**
58
+ - 具体要做的事项 1
59
+ - 具体要做的事项 2
60
+
61
+ **不在范围内:**
62
+ - 明确不做的事项 1
63
+
64
+ ## 约束条件
65
+
66
+ - 技术约束(如必须兼容 Node.js 18+)
67
+ - 时间约束
68
+ - 依赖约束(如依赖外部服务 X 先就绪)
69
+
70
+ ## 成功定义
71
+
72
+ (可验证的成功标准,不是抽象描述)
73
+ - 标准 1:所有单元测试通过,覆盖率 ≥ X%
74
+ - 标准 2:UI 交互流程可在浏览器中完成
75
+ - ...
76
+ ```
77
+
78
+ ### 3. 拆解可执行任务
79
+
80
+ 将蓝图拆解为独立的任务项。每个任务必须满足:
81
+
82
+ - **可独立执行**:Builder 无需频繁跨任务上下文切换
83
+ - **可验证**:有明确的验收标准(测试命令、UI 检查点、文件路径等)
84
+ - **有产出物**:代码变更、测试报告、截图、文档等
85
+
86
+ ```markdown
87
+ ## 任务清单
88
+
89
+ | # | 任务 | 类型 | 验收标准 | 预估 | 依赖 |
90
+ |---|------|------|---------|------|------|
91
+ | 1 | 实现 XXX 模块 | build | `npm test -- XXX` 全部通过 | 2h | - |
92
+ | 2 | 编写 YYY 集成测试 | build | `npm test -- YYY` 覆盖 3 个场景 | 1h | #1 |
93
+ | 3 | 验证 ZZZ 边界情况 | verify | 运行边界测试套件,0 失败 | 0.5h | #2 |
94
+ | 4 | 审查整体方案一致性 | review | 审查报告无 P0/P1 问题 | 0.5h | #2, #3 |
95
+ | 5 | 验收最终交付物 | accept | 对照验收标准逐项通过 | 0.5h | #4 |
96
+ ```
97
+
98
+ 任务类型对应责任链环节:`plan` / `build` / `verify` / `review` / `accept`。
99
+
100
+ 依赖字段确保责任链顺序:P → B → V → R → A。
101
+
102
+ ### 4. 推入任务队列
103
+
104
+ 通过 orchestrator 将任务推入队列,指定每个任务的责任链环节:
105
+
106
+ ```bash
107
+ # Build 任务
108
+ claude-orchestrator push-task \
109
+ --title "实现 XXX 模块" \
110
+ --link build \
111
+ --priority 0
112
+
113
+ # Verify 任务
114
+ claude-orchestrator push-task \
115
+ --title "验证 ZZZ 边界情况" \
116
+ --link verify \
117
+ --priority 1
118
+
119
+ # Review 任务
120
+ claude-orchestrator push-task \
121
+ --title "审查整体方案一致性" \
122
+ --link review \
123
+ --priority 1
124
+
125
+ # Accept 任务
126
+ claude-orchestrator push-task \
127
+ --title "验收最终交付物" \
128
+ --link accept \
129
+ --priority 1
130
+ ```
131
+
132
+ 优先级建议:`plan` 和下游瓶颈任务用 `0`(HIGH),其余用 `1`(MEDIUM)。
133
+
134
+ ### 5. 建立验收标准可追溯
135
+
136
+ 每个任务的验收标准必须具体到可独立复现。拒绝模糊描述:
137
+
138
+ | 模糊(拒绝) | 具体(通过) |
139
+ |-------------|------------|
140
+ | "功能正常" | `npm test -- auth` 全部通过,覆盖登录/登出/超时 3 个场景 |
141
+ | "UI 没问题" | 截图 `screenshots/login-flow.png` 展示登录→首页完整流程 |
142
+ | "性能合格" | `ab -n 1000 -c 10 /api/users` p95 < 200ms |
143
+ | "代码质量好" | `npx eslint src/auth/` 0 errors, 0 warnings |
144
+
145
+ ### 6. 记录蓝图并通知 Leader
146
+
147
+ 将蓝图文档存入共享上下文,通知 Leader 蓝图就绪:
148
+
149
+ ```bash
150
+ # 存为共享上下文
151
+ claude-orchestrator set-context --key plan-<目标slug> --value "$(cat docs/plans/<目标slug>.md)"
152
+
153
+ # 通知 Leader
154
+ claude-orchestrator send-message --broadcast --content "蓝图 <目标slug> 已就绪,任务已推入队列,共 N 个任务。"
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 蓝图完整性检查清单
160
+
161
+ ```
162
+ □ 目标描述一句话清晰
163
+ □ 范围和边界明确(不做的比要做的更重要)
164
+ □ 每项任务可独立执行
165
+ □ 每项任务有具体验收标准(不是模糊描述)
166
+ □ 依赖链完整(P→B→V→R→A 无断点)
167
+ □ 所有任务已推入 orchestrator 队列
168
+ □ 蓝图文档已存入共享上下文
169
+ □ Leader 已收到蓝图就绪通知
170
+ ```
171
+
172
+ ---
173
+
174
+ ## 与其他技能的协作
175
+
176
+ - **[[task-traceability]]**:基础层。Planner 的每一步都需要可追溯:需求 → 蓝图 → 任务清单 → 验收标准。Plan 是责任链的起点,如果 Plan 的追溯链断裂,Builder 不知道做什么,Verifier 不知道验什么,Reviewer 不知道审什么。
177
+ - **[[task-execution]]**:Builder 依赖 Planner 的蓝图和追溯链来理解执行范围。
178
+ - **[[task-verification]]**:Verifier 以 Planner 蓝图的验收标准为验证基准。
179
+ - **[[task-review]]**:Reviewer 以 Planner 蓝图为审查标准。
180
+
181
+ ---
182
+
183
+ ## 常见错误
184
+
185
+ - **任务拆得太粗**:一个任务包含多个独立模块,Builder 无法一次完成。拆到一个人能在 2-4 小时内完成为宜。
186
+ - **验收标准是废话**:写"功能正常"等于没写。必须写具体的测试命令、文件路径、预期输出。
187
+ - **跳过依赖声明**:没有依赖链,责任链流转就断了。每个非 Plan 任务必须声明它依赖什么产出物。
188
+ - **蓝图没有存共享上下文**:其他 Worker 看不到蓝图就无法理解自己在做什么。蓝图必须是团队可见的。
@@ -0,0 +1,220 @@
1
+ ---
2
+ name: task-review
3
+ description: Quality review of the full Plan→Build→Verify chain for the Reviewer role. Use when the Reviewer needs to assess whether the implementation matches the Planner's design intent — checking code quality, architecture compliance, verification completeness, and producing a review report with a pass/revise decision, with full traceability from every judgment back through the chain. Triggers on keywords like "审查", "review", "code review", "检查代码", "审批", "复核", or when verification is complete and the task enters the Review stage of the responsibility chain.
4
+ ---
5
+
6
+ # Task Review
7
+
8
+ > 审查不是挑刺,是从设计意图的高度判断实现是否"做对了"——不是"代码写得怎么样",而是"该不该通过"。本技能与 [[task-traceability]] 协作,确保每次审查有依据、有深度、有结论、可追溯——每个判定都可追溯到具体的 Plan 意图、Build 产出和 Verify 发现。
9
+
10
+ ---
11
+
12
+ ## 何时触发
13
+
14
+ - Verifier 完成验证,责任链流转到 Review 阶段
15
+ - Worker 通过 `claude-orchestrator claim-task` 认领了 review 类型的任务
16
+ - 用户说"审查一下这个 PR"、"review 一下代码"
17
+ - 蓝图中有 review 类型的任务需要开工
18
+
19
+ ---
20
+
21
+ ## 审查六步法
22
+
23
+ 按顺序执行,每一步通过才进入下一步。
24
+
25
+ ### 1. 认领 Review 任务并收集全链信息
26
+
27
+ ```bash
28
+ # 认领审查任务
29
+ claude-orchestrator claim-task
30
+
31
+ # 获取蓝图
32
+ claude-orchestrator get-context --key plan-<目标slug>
33
+
34
+ # 获取验证报告
35
+ claude-orchestrator get-context --key verify-<目标slug>
36
+ ```
37
+
38
+ 收集审查所需的完整上下文:
39
+ - Planner 的蓝图(设计意图、验收标准、范围边界)
40
+ - Builder 的代码变更(commit diff)
41
+ - Verifier 的验证报告(问题清单、回归结果)
42
+ - Builder 的 task-traceability 记录(commit hash 链)
43
+
44
+ 如果缺少任何一环的产出 → 退回要求补齐。Reviewer 不做信息不完整的审查。
45
+
46
+ ### 2. 审查设计一致性
47
+
48
+ 对照蓝图检查实际实现,回答三个核心问题:
49
+
50
+ **做对了吗?**(功能正确性)
51
+ - 代码变更是否实现了蓝图定义的全部功能?
52
+ - 是否有蓝图定义但未实现的部分?
53
+ - 是否有蓝图未定义但被实现了的部分(越界)?
54
+
55
+ **做合适吗?**(架构合规性)
56
+ - 代码结构是否符合项目现有的架构模式?
57
+ - 是否引入了新的依赖或模式变更?(如有,是否必要且有充分理由?)
58
+ - 命名、目录组织、接口设计与项目现有风格是否一致?
59
+
60
+ **技术债务可控吗?**
61
+ - 是否有明显的性能问题、安全问题、可维护性问题?
62
+ - 是否引入了难以测试的逻辑?
63
+ - 错误处理是否合理?
64
+
65
+ ```bash
66
+ # 查看完整 diff
67
+ git show <commit-hash> --patch
68
+
69
+ # 查看变更的文件列表
70
+ git show <commit-hash> --stat
71
+ ```
72
+
73
+ ### 3. 审查验证报告的完整性
74
+
75
+ 审查 Verifier 的工作质量:
76
+
77
+ - 验证报告是否覆盖了蓝图中所有验收标准?
78
+ - 验证方法是否独立可复现?(不是转述 Builder 的结果)
79
+ - 回归测试是否被执行且通过?
80
+ - Verifier 发现的问题是否被充分描述和分类?
81
+
82
+ 如果验证报告有缺陷(漏检、方法不当)→ 标记为 Review 前置条件不满足,退回 Verifier 补充。
83
+
84
+ ### 4. 判定问题等级
85
+
86
+ 对发现的问题按严重度分级:
87
+
88
+ | 级别 | 定义 | 示例 | 处理 |
89
+ |------|------|------|------|
90
+ | **P0** | 阻断:设计意图未实现,核心功能缺失或不正确 | 蓝图要求的功能完全没做、引入安全漏洞 | 退回 Builder 重做 |
91
+ | **P1** | 严重:实现偏离设计意图,但不影响核心功能 | 错误处理不完整、UI 与设计不一致、性能明显下降 | 退回 Builder 修改 |
92
+ | **P2** | 一般:代码质量、风格、可维护性问题 | 命名不清晰、缺少注释、测试覆盖面不足 | 建议修改,不阻断通过 |
93
+ | **P3** | 建议:优化建议,不影响通过 | 更好的实现方式、可选的性能优化 | 记录,Builder 自行决定 |
94
+
95
+ ### 5. 书写审查报告
96
+
97
+ ```markdown
98
+ # 审查报告
99
+
100
+ > Reviewer | YYYY-MM-DD | 审查范围:<目标名称> (P→B→V 全链)
101
+
102
+ ## 审查结论:Pass / Revise
103
+
104
+ (一句话结论)
105
+
106
+ ---
107
+
108
+ ## 审查范围
109
+
110
+ | 环节 | 负责人 | 产出 | Commit / 文档 |
111
+ |------|--------|------|--------------|
112
+ | Plan | <Planner> | 蓝图 | plan-<slug> |
113
+ | Build | <Builder> | 代码 | `a1b2c3d` |
114
+ | Verify | <Verifier> | 验证报告 | verify-<slug> |
115
+
116
+ ---
117
+
118
+ ## 设计一致性审查
119
+
120
+ | 蓝图要求 | 实现情况 | 判定 |
121
+ |---------|---------|------|
122
+ | 功能 A:XXX | 已实现,见 `src/a.ts:42` | ✅ |
123
+ | 功能 B:YYY | 部分实现,缺少边界处理 | ⚠️ |
124
+ | 功能 C:ZZZ | 未实现 | ❌ |
125
+
126
+ ---
127
+
128
+ ## 代码质量审查
129
+
130
+ | 检查项 | 结果 |
131
+ |--------|------|
132
+ | 架构合规 | ✅ / ⚠️ / ❌ |
133
+ | 命名规范 | ✅ / ⚠️ / ❌ |
134
+ | 错误处理 | ✅ / ⚠️ / ❌ |
135
+ | 性能影响 | ✅ / ⚠️ / ❌ |
136
+ | 安全问题 | ✅ / ⚠️ / ❌ |
137
+
138
+ ---
139
+
140
+ ## 验证报告审查
141
+
142
+ | 检查项 | 结果 |
143
+ |--------|------|
144
+ | 验收标准覆盖 | 3/3 ✅ |
145
+ | 验证方法独立 | ✅ |
146
+ | 回归测试通过 | ✅ (42/42) |
147
+ | Verifier 问题充分描述 | ✅ |
148
+
149
+ ---
150
+
151
+ ## 问题清单
152
+
153
+ | # | 级别 | 描述 | 位置 | 责任人 |
154
+ |---|------|------|------|--------|
155
+ | 1 | P1 | 缺少错误重试逻辑 | `src/auth.ts:L42` | @Builder |
156
+ | 2 | P2 | 变量名 `tmp` 不够清晰 | `src/utils.ts:L18` | @Builder |
157
+
158
+ ---
159
+
160
+ ## 审查建议
161
+
162
+ (对 Builder/Planner/Verifier 的非强制性建议)
163
+
164
+ ---
165
+
166
+ *Reviewer — YYYY-MM-DD*
167
+ ```
168
+
169
+ ### 6. 通知结果并流转
170
+
171
+ ```bash
172
+ # 存入共享上下文
173
+ claude-orchestrator set-context \
174
+ --key review-<目标slug> \
175
+ --value "$(cat docs/review/<目标slug>-YYYY-MM-DD.md)"
176
+
177
+ # Revise → 通知 Builder 和 Planner
178
+ claude-orchestrator send-message \
179
+ --to <builder-id> \
180
+ --content "审查结论 Revise。P1: 缺少错误重试逻辑。详见 review-<slug>"
181
+
182
+ # Pass → 通知 Leader 和 Accepter,流转到 Accept 阶段
183
+ claude-orchestrator send-message \
184
+ --broadcast \
185
+ --content "审查结论 Pass。<目标> 通过 Review,流转至 Accept 阶段。"
186
+ ```
187
+
188
+ ---
189
+
190
+ ## 审查完成检查清单
191
+
192
+ ```
193
+ □ 已收集完整的 P→B→V 链产出
194
+ □ 蓝图验收标准全部检查
195
+ □ 代码 diff 完整审阅
196
+ □ 验证报告质量和完整性已评估
197
+ □ 问题已按 P0/P1/P2/P3 分级
198
+ □ 审查报告已产出并存入共享上下文
199
+ □ 结论(Pass/Revise)已通知相关角色
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 与其他技能的协作
205
+
206
+ - **[[task-traceability]]**:基础层。Reviewer 严格遵循追溯 → 执行 → 映射 → 举证 → 记录的五步法。追溯整条链(Plan 意图 → Build 实现 → Verify 发现),逐项判定(Execute),构建审查判定映射表(Map),为每个判定附理据(Evidence),产出审查报告并签发 Pass/Revise(Record)。如果任何一个上游环节的追溯链断裂,标记为 P1 问题——没有追溯链,审查就没有锚点。
207
+ - **[[task-planning]]**:Reviewer 以 Planner 的蓝图为审查标准。设计意图是唯一的判断基准。
208
+ - **[[task-execution]]**:Reviewer 审查 Builder 的代码实现质量和设计一致性。
209
+ - **[[task-verification]]**:Reviewer 审查 Verifier 的验证报告质量和完整性。验证报告有缺陷的,退回 Verifier。
210
+ - **[[task-acceptance]]**:Accepter 依赖 Reviewer 的 Pass 结论和可追溯判定链来决定是否进入最终验收。
211
+
212
+ ---
213
+
214
+ ## 常见错误
215
+
216
+ - **只审代码不审设计一致性**:陷入代码风格审查,忘记了 Reviewer 的核心职责是判断"是否实现了设计意图"。代码写得再好,与蓝图不一致也是不合格。
217
+ - **跳过对 Verifier 的审查**:假设 Verifier 的报告总是完整正确的。Verifier 也可能遗漏或误判。
218
+ - **不分级的问题清单**:把所有问题列出但不定级,Builder 不知道哪些必须修改、哪些可以忽略。
219
+ - **审查报告不写位置**:问题只描述不定位(缺少文件路径和行号)。Builder 不知道在哪里改。
220
+ - **Pass 但有问题未解决**:P0/P1 问题未解决就签 Pass。零 P0/P1 是 Pass 的前提。
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: task-traceability
3
+ description: Foundational traceability layer for the entire Plan→Build→Verify→Review→Accept responsibility chain. Every role must leave a traceable record: upstream requirements → execution → output mapping → evidence → persisted record. Without traceability at every link, the chain cannot be audited, handoffs break, and sign-off is unreliable. Use this skill whenever any team member executes work in any link of the responsibility chain — planning, building, verifying, reviewing, or accepting. Triggers on any task execution context: task assignment, work plans, code changes, verification, review, or acceptance.
4
+ ---
5
+
6
+ # Task Traceability — Foundational Layer
7
+
8
+ Traceability is not optional. It is the foundation that makes the Plan→Build→Verify→Review→Accept chain auditable, handoffs reliable, and sign-off meaningful. **Every link must produce a traceable record. A single broken link breaks the entire chain.**
9
+
10
+ ## The Universal Five-Step Pattern
11
+
12
+ Every role in the chain follows the same five-step pattern, applied to its specific context:
13
+
14
+ ```
15
+ Step 1: Trace (追溯)
16
+ └── Identify all upstream requirements and artifacts you must reference
17
+
18
+ Step 2: Execute (执行)
19
+ └── Do the work, following the traced requirements
20
+
21
+ Step 3: Map (映射)
22
+ └── Link every output back to a specific upstream requirement
23
+
24
+ Step 4: Evidence (举证)
25
+ └── Provide proof that each mapping is correct and complete
26
+
27
+ Step 5: Record (记录)
28
+ └── Persist the traceability record so downstream roles can pick up the chain
29
+ ```
30
+
31
+ **Why five steps?** Without Trace, you don't know what to do. Without Map, nobody knows why you did it. Without Evidence, your output is unverifiable. Without Record, the next link starts blind.
32
+
33
+ ## Why Every Link Matters
34
+
35
+ ```
36
+ Plan ──→ Build ──→ Verify ──→ Review ──→ Accept
37
+ │ │ │ │ │
38
+ │ │ │ │ └── Break here → sign-off is unverifiable
39
+ │ │ │ └── Break here → audit trail is incomplete
40
+ │ │ └── Break here → verification is untrustworthy
41
+ │ └── Break here → implementation is untraceable
42
+ └── Break here → entire chain starts without a foundation
43
+ ```
44
+
45
+ A chain is only as strong as its weakest link. Traceability must be enforced at **every** link.
46
+
47
+ ## Role-Specific Application
48
+
49
+ ### Plan — Blueprint Traceability
50
+
51
+ Plan is the chain's foundation. If blueprint traceability is broken, every downstream link is working from ambiguity.
52
+
53
+ | Step | Action |
54
+ |------|--------|
55
+ | **Trace** | Read the original requirement. Extract business goals, constraints, scope boundaries, and success criteria. |
56
+ | **Execute** | Design the blueprint: architecture, interfaces, data flow. Break into ordered Build steps, each with completion criteria. |
57
+ | **Map** | Every Build step must trace back to a specific requirement. Every completion criterion must be objectively verifiable. |
58
+ | **Evidence** | Self-check: can a Builder start from this blueprint alone? Are edge cases covered? Are interfaces unambiguous? |
59
+ | **Record** | Write the blueprint document. Push tasks to the orchestrator queue. Store the blueprint in shared context (`set-context`). Notify Leader. |
60
+
61
+ **Plan traceability record**: `requirement → blueprint → task list → shared context key`
62
+
63
+ ### Build — Implementation Traceability
64
+
65
+ Build produces the concrete artifacts. Every code change must be traceable to a specific Plan requirement.
66
+
67
+ | Step | Action |
68
+ |------|--------|
69
+ | **Trace** | Read the Planner's blueprint. Extract every implementable requirement as a checklist. |
70
+ | **Execute** | Implement each requirement. Follow the Plan's architecture and interfaces. Document any deviations. |
71
+ | **Map** | Build a traceability map: `Plan Requirement → Implementation → Status (done/deviated/blocked)`. |
72
+ | **Evidence** | Provide proof: tests passing, manual verification results, key implementation decisions and rationale. |
73
+ | **Record** | Commit code signed with your own name. Record the commit hash next to each completed item in the task document. Commit the document update. |
74
+
75
+ **Build traceability record**: `blueprint requirement → code change → commit hash → document update → document commit`
76
+
77
+ ### Verify — Verification Traceability
78
+
79
+ Verify independently checks Builder output. Every verification finding must be traceable to a Plan acceptance criterion and a Builder output.
80
+
81
+ | Step | Action |
82
+ |------|--------|
83
+ | **Trace** | Read the Plan blueprint (acceptance criteria) and Builder output (commits, artifacts). Build a verification checklist by cross-referencing. |
84
+ | **Execute** | For each checklist item, independently verify. Run tests. Inspect code. Check edge cases and regressions. |
85
+ | **Map** | Build a verification map: `Plan Criterion → Builder Output → Verified Result → Status (pass/gap/fail)`. |
86
+ | **Evidence** | For each finding, record: what was checked, how, actual command output, and references to Plan and Builder artifacts. |
87
+ | **Record** | Write the verification report. Store in shared context. Flag gaps and failures to Builder and Reviewer. |
88
+
89
+ **Verify traceability record**: `acceptance criterion → verification method → actual result → verdict → report path`
90
+
91
+ ### Review — Judgment Traceability
92
+
93
+ Review judges the full chain. Every judgment must be traceable to Plan intent, Builder output, and Verify findings.
94
+
95
+ | Step | Action |
96
+ |------|--------|
97
+ | **Trace** | Read all upstream artifacts: Plan blueprint, Builder traceability map, Verify report. Build a chain-level review checklist. |
98
+ | **Execute** | For each item, make a judgment: ACCEPT / CONCERN / REJECT. Classify issues as P0 (blocking) / P1 (severe) / P2 (minor) / P3 (suggestion). |
99
+ | **Map** | Build a review map: `Plan Intent → Build Result → Verify Finding → Review Judgment`. |
100
+ | **Evidence** | For each CONCERN and REJECT: reference the specific Plan requirement, Builder output, Verify finding, and clear rationale. |
101
+ | **Record** | Write the review report. Store in shared context. Issue Pass/Revise decision. Notify responsible roles. |
102
+
103
+ **Review traceability record**: `plan intent → build result → verify finding → review judgment → report path → decision`
104
+
105
+ ### Accept — Sign-Off Traceability
106
+
107
+ Accept is the final gate. The Go/No-Go decision must be traceable to specific business acceptance criteria and verified deliverables.
108
+
109
+ | Step | Action |
110
+ |------|--------|
111
+ | **Trace** | Read the full chain: Plan blueprint, Builder output, Verify report, Review judgment. Extract business acceptance criteria. |
112
+ | **Execute** | For each acceptance criterion, verify: is there a corresponding deliverable? Does it actually exist? Are upstream issues resolved? |
113
+ | **Map** | Build an acceptance map: `Acceptance Criterion → Deliverable → Verification Result → Review Judgment → Status`. |
114
+ | **Evidence** | For each criterion: verify code exists (grep), verify commits exist (git log), verify tests pass (run them), verify reports are self-consistent. |
115
+ | **Record** | Write the acceptance report. Sign Go/No-Go. Zero issues for Go — no conditional passes. Store in shared context. |
116
+
117
+ **Accept traceability record**: `acceptance criterion → deliverable → verification → review → Go/No-Go → report path`
118
+
119
+ ## The Traceability Record Chain
120
+
121
+ When every link records its traceability, the full chain is auditable from end to end:
122
+
123
+ ```
124
+ Business Requirement
125
+ └── Plan: blueprint → task-001(task-0000000001), task-002(task-0000000002)
126
+ └── Build: task-001 → commit a1b2c3d → doc update commit e4f5g6h
127
+ └── Verify: criterion A → test X passed, criterion B → gap found
128
+ └── Review: gap B → CONCERN P1 → Revise decision
129
+ └── Re-Build: fix gap B → commit i7j8k9l
130
+ └── Re-Verify: criterion B → test Y passed
131
+ └── Re-Review: all clear → Pass
132
+ └── Accept: all criteria met → GO
133
+ ```
134
+
135
+ Anyone can enter the chain at any point and traverse forward or backward. A reviewer can ask "what requirement led to this commit?" and get the answer in one step. An auditor can ask "was this acceptance criterion verified?" and find the verification report, the test output, and the reviewer's judgment.
136
+
137
+ ## Task Completion Checklist (All Roles)
138
+
139
+ ```
140
+ □ Step 1 — Trace: Identified all upstream requirements and artifacts
141
+ □ Step 2 — Execute: Completed work following traced requirements
142
+ □ Step 3 — Map: Every output linked to a specific upstream requirement
143
+ □ Step 4 — Evidence: Proof provided for each mapping
144
+ □ Step 5 — Record: Traceability record persisted (commit, context store, or report)
145
+ ```
146
+
147
+ ## Common Mistakes (All Roles)
148
+
149
+ - **Skipping Trace (Step 1)**: Starting work without reading upstream artifacts. Produces output that may not align with requirements.
150
+ - **Skipping Map (Step 3)**: Producing output without linking it back to requirements. Downstream roles can't tell what was done for what.
151
+ - **Map without Evidence (Step 4)**: Claiming "done" without proof. Unverifiable claims are invisible to auditors.
152
+ - **Skipping Record (Step 5)**: Doing the work but not persisting the traceability record. The next link starts blind — the chain is broken.
153
+ - **Weak evidence**: "Looks good" is not evidence. Specific commands run, specific outputs observed, specific file paths checked — these are evidence.
154
+ - **Signing with someone else's name**: Traceability depends on knowing who did what. Every commit and report must identify its author.