@chenguangyao/devflow-kit 0.1.43

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 (198) hide show
  1. package/CHANGELOG.md +232 -0
  2. package/LICENSE +21 -0
  3. package/README.md +539 -0
  4. package/bin/devflow.js +9 -0
  5. package/docs/RFC-001-devflow-kit.md +617 -0
  6. package/docs/RFC-002-workflow-kernel.md +134 -0
  7. package/docs/enterprise-integration-supplement.md +274 -0
  8. package/docs/internal-gitlab-setup.md +426 -0
  9. package/docs/marketplace-skills.md +231 -0
  10. package/docs/migration-from-arb.md +232 -0
  11. package/docs/tooling-overview.md +774 -0
  12. package/docs/workflow-orchestration.md +695 -0
  13. package/docs/workflow-ui-prototype.html +271 -0
  14. package/package.json +52 -0
  15. package/schemas/config.schema.json +51 -0
  16. package/schemas/delta.schema.json +22 -0
  17. package/schemas/state.schema.json +130 -0
  18. package/schemas/status-surface.schema.json +197 -0
  19. package/schemas/workflow-confirmation-surface.schema.json +70 -0
  20. package/schemas/workflow-picker.schema.json +94 -0
  21. package/scripts/postinstall.js +101 -0
  22. package/scripts/render-workflow-ui-prototype.js +271 -0
  23. package/skills/apply/SKILL.md +313 -0
  24. package/skills/apply/references/discipline-checklist.md +145 -0
  25. package/skills/apply/references/subagent-implementer-prompt.md +113 -0
  26. package/skills/apply/references/subagent-orchestration.md +150 -0
  27. package/skills/apply/references/subagent-reviewer-prompt.md +180 -0
  28. package/skills/apply/references/tdd-loop.md +287 -0
  29. package/skills/apply/references/when-plan-is-wrong.md +279 -0
  30. package/skills/apply/references/worktree-swarm.md +292 -0
  31. package/skills/archive/SKILL.md +229 -0
  32. package/skills/archive/references/conflict-resolution.md +336 -0
  33. package/skills/archive/references/knowledge-deposit.md +381 -0
  34. package/skills/archive/references/spec-merge.md +365 -0
  35. package/skills/brainstorm/SKILL.md +123 -0
  36. package/skills/brainstorm/references/proposal-template.md +244 -0
  37. package/skills/brainstorm/references/question-catalog.md +168 -0
  38. package/skills/brainstorm/references/session-template.md +184 -0
  39. package/skills/ci-fix/SKILL.md +63 -0
  40. package/skills/ci-fix/references/loop.md +25 -0
  41. package/skills/code-review/SKILL.md +279 -0
  42. package/skills/code-review/references/escalation-playbook.md +192 -0
  43. package/skills/code-review/references/language-cheatsheets/go.md +175 -0
  44. package/skills/code-review/references/language-cheatsheets/java-spring-mybatis.md +246 -0
  45. package/skills/code-review/references/language-cheatsheets/python.md +170 -0
  46. package/skills/code-review/references/language-cheatsheets/vue.md +199 -0
  47. package/skills/code-review/references/output-template.md +275 -0
  48. package/skills/code-review/references/review-checklist.md +251 -0
  49. package/skills/complexity-grading/SKILL.md +259 -0
  50. package/skills/deliver/SKILL.md +271 -0
  51. package/skills/deliver/references/delivery-modes.md +299 -0
  52. package/skills/deliver/references/notify.md +359 -0
  53. package/skills/deliver/references/pr-description.md +319 -0
  54. package/skills/dependency-upgrade/SKILL.md +57 -0
  55. package/skills/dependency-upgrade/references/risk-matrix.md +38 -0
  56. package/skills/df-orchestrator/SKILL.md +407 -0
  57. package/skills/df-orchestrator/references/complexity-grading.md +177 -0
  58. package/skills/df-orchestrator/references/escalation-matrix.md +191 -0
  59. package/skills/df-orchestrator/references/routing-rules.md +290 -0
  60. package/skills/df-orchestrator/references/workflow-state-machine.md +208 -0
  61. package/skills/frontend-quality/SKILL.md +61 -0
  62. package/skills/frontend-quality/references/checklist.md +35 -0
  63. package/skills/handoff-resume/SKILL.md +59 -0
  64. package/skills/handoff-resume/references/handoff-template.md +54 -0
  65. package/skills/plan/SKILL.md +166 -0
  66. package/skills/plan/references/task-breakdown.md +207 -0
  67. package/skills/plan/references/task-sequencing.md +143 -0
  68. package/skills/plan/references/task-template.md +248 -0
  69. package/skills/requirement-analysis/SKILL.md +499 -0
  70. package/skills/requirement-analysis/references/acceptance-criteria.md +183 -0
  71. package/skills/requirement-analysis/references/code-recon.md +151 -0
  72. package/skills/requirement-analysis/references/edge-case-catalog.md +164 -0
  73. package/skills/requirement-analysis/references/requirement-template.md +339 -0
  74. package/skills/requirement-analysis/references/scope-negotiation.md +162 -0
  75. package/skills/security-hardening/SKILL.md +60 -0
  76. package/skills/security-hardening/references/checklist.md +42 -0
  77. package/skills/tech-spec/SKILL.md +388 -0
  78. package/skills/tech-spec/references/api-contract-design.md +172 -0
  79. package/skills/tech-spec/references/decision-records.md +110 -0
  80. package/skills/tech-spec/references/design-template.md +301 -0
  81. package/skills/tech-spec/references/rollout-and-rollback.md +203 -0
  82. package/skills/tech-spec/references/spec-delta-conventions.md +250 -0
  83. package/skills/tech-spec/references/transaction-patterns.md +212 -0
  84. package/skills/test-spec/SKILL.md +219 -0
  85. package/skills/test-spec/references/coverage-strategy.md +218 -0
  86. package/skills/test-spec/references/edge-case-to-test.md +143 -0
  87. package/skills/test-spec/references/test-case-template.md +276 -0
  88. package/skills/verify/SKILL.md +232 -0
  89. package/skills/verify/references/nfr-verification.md +292 -0
  90. package/skills/verify/references/report-templates.md +510 -0
  91. package/skills/verify/references/self-test-guide.md +240 -0
  92. package/skills/verify/references/verify-rollback-map.md +247 -0
  93. package/src/cli/commands/_helpers.js +108 -0
  94. package/src/cli/commands/_submit.js +718 -0
  95. package/src/cli/commands/apply.js +198 -0
  96. package/src/cli/commands/archive.js +180 -0
  97. package/src/cli/commands/checkpoint.js +113 -0
  98. package/src/cli/commands/deliver.js +377 -0
  99. package/src/cli/commands/deploy.js +504 -0
  100. package/src/cli/commands/design.js +158 -0
  101. package/src/cli/commands/disable.js +21 -0
  102. package/src/cli/commands/doctor.js +178 -0
  103. package/src/cli/commands/enable.js +21 -0
  104. package/src/cli/commands/flow.js +645 -0
  105. package/src/cli/commands/help.js +93 -0
  106. package/src/cli/commands/ingest.js +602 -0
  107. package/src/cli/commands/init.js +341 -0
  108. package/src/cli/commands/knowledge.js +523 -0
  109. package/src/cli/commands/logs.js +43 -0
  110. package/src/cli/commands/new.js +202 -0
  111. package/src/cli/commands/plan.js +49 -0
  112. package/src/cli/commands/propose.js +27 -0
  113. package/src/cli/commands/provider.js +698 -0
  114. package/src/cli/commands/report.js +143 -0
  115. package/src/cli/commands/requirement.js +227 -0
  116. package/src/cli/commands/review.js +301 -0
  117. package/src/cli/commands/skills.js +457 -0
  118. package/src/cli/commands/status.js +925 -0
  119. package/src/cli/commands/switch.js +27 -0
  120. package/src/cli/commands/sync.js +47 -0
  121. package/src/cli/commands/test.js +366 -0
  122. package/src/cli/commands/uninstall.js +32 -0
  123. package/src/cli/commands/update.js +74 -0
  124. package/src/cli/commands/verify.js +354 -0
  125. package/src/cli/commands/worktree.js +78 -0
  126. package/src/cli/index.js +72 -0
  127. package/src/cli/parse-args.js +102 -0
  128. package/src/core/autodetect.js +271 -0
  129. package/src/core/change.js +208 -0
  130. package/src/core/checkpoint.js +217 -0
  131. package/src/core/config.js +60 -0
  132. package/src/core/delta.js +290 -0
  133. package/src/core/markers.js +59 -0
  134. package/src/core/paths.js +173 -0
  135. package/src/core/plan-tasks.js +36 -0
  136. package/src/core/project-routing.js +285 -0
  137. package/src/core/projects.js +200 -0
  138. package/src/core/state.js +200 -0
  139. package/src/core/workflow-check.js +177 -0
  140. package/src/core/workflow-init.js +34 -0
  141. package/src/core/workflow-picker.js +154 -0
  142. package/src/core/workflow-policy.js +119 -0
  143. package/src/core/workflow-suggest.js +181 -0
  144. package/src/core/workflow-verify.js +88 -0
  145. package/src/core/workflow.js +433 -0
  146. package/src/core/worktree.js +241 -0
  147. package/src/knowledge/categories.js +107 -0
  148. package/src/knowledge/classify.js +125 -0
  149. package/src/knowledge/deposit.js +414 -0
  150. package/src/knowledge/migrate.js +149 -0
  151. package/src/knowledge/mr.js +219 -0
  152. package/src/knowledge/query.js +131 -0
  153. package/src/knowledge/registry.js +151 -0
  154. package/src/knowledge/sync.js +179 -0
  155. package/src/providers/base.js +74 -0
  156. package/src/providers/drivers/api-yapi.js +78 -0
  157. package/src/providers/drivers/ci-jenkins.js +109 -0
  158. package/src/providers/drivers/intake-confluence.js +544 -0
  159. package/src/providers/drivers/kb-git.js +549 -0
  160. package/src/providers/drivers/kb-weknora.js +472 -0
  161. package/src/providers/drivers/notify-smtp.js +515 -0
  162. package/src/providers/drivers/observability-oss.js +43 -0
  163. package/src/providers/drivers/observability-sls.js +50 -0
  164. package/src/providers/lifecycle.js +135 -0
  165. package/src/providers/loader.js +132 -0
  166. package/src/providers/local.js +190 -0
  167. package/src/providers/userconfig.js +283 -0
  168. package/src/reports/aggregate.js +185 -0
  169. package/src/reports/coverage.js +163 -0
  170. package/src/reports/detect.js +143 -0
  171. package/src/reports/parse.js +236 -0
  172. package/src/templates/files/ci/github.yml +38 -0
  173. package/src/templates/files/ci/gitlab.yml +27 -0
  174. package/src/templates/files/design.md +63 -0
  175. package/src/templates/files/ide/devflow-workflow.md +58 -0
  176. package/src/templates/files/ide/project-overview-reference.md +1 -0
  177. package/src/templates/files/ide/project-overview.md +27 -0
  178. package/src/templates/files/knowledge-index.json +17 -0
  179. package/src/templates/files/knowledge.md +28 -0
  180. package/src/templates/files/meta.json +8 -0
  181. package/src/templates/files/plan.md +38 -0
  182. package/src/templates/files/proposal.md +33 -0
  183. package/src/templates/files/reports/contract-test.md +40 -0
  184. package/src/templates/files/reports/e2e-test.md +30 -0
  185. package/src/templates/files/reports/integration-test.md +36 -0
  186. package/src/templates/files/reports/joint-test.md +58 -0
  187. package/src/templates/files/reports/perf.md +24 -0
  188. package/src/templates/files/reports/regression.md +20 -0
  189. package/src/templates/files/reports/remote-test.md +55 -0
  190. package/src/templates/files/reports/self-test.md +43 -0
  191. package/src/templates/files/reports/smoke-test.md +22 -0
  192. package/src/templates/files/reports/unit-test.md +36 -0
  193. package/src/templates/files/requirement.md +51 -0
  194. package/src/templates/files/review.md +38 -0
  195. package/src/templates/files/tests.md +36 -0
  196. package/src/templates/files/verify.md +32 -0
  197. package/src/templates/index.js +21 -0
  198. package/src/utils/log.js +37 -0
@@ -0,0 +1,276 @@
1
+ # test-spec / test-case-template
2
+
3
+ `tests.md` 完整模板、用例详表字段语义、正反例、L2 完整示例。
4
+
5
+ ---
6
+
7
+ ## 模板
8
+
9
+ ```markdown
10
+ ---
11
+ slug: <slug>
12
+ createdAt: <ISO>
13
+ level: L1 | L2 | L3
14
+ refs:
15
+ - requirement.md
16
+ - design.md
17
+ ---
18
+
19
+ # Tests: <one-line title>
20
+
21
+ ## 1. 测试策略
22
+ - 金字塔分布:unit 75% / integration 20% / e2e 5%
23
+ - 工具:<按项目语言;见 coverage-strategy.md>
24
+ - 覆盖率目标:line ≥ 80%,branch ≥ 70%(业务核心类)
25
+
26
+ ## 2. 数据准备(Fixtures)
27
+ - `fixtures/users/batch_1k.json`:1000 合法用户
28
+ - `fixtures/users/with_risk.json`:50 命中风控 + 950 正常
29
+ - `fixtures/coupon/templates.sql`:3 个有效模板 + 1 个过期 + 1 个不足库存
30
+ - Factory:`UserFactory.make(count, riskRate=0.1)` 批量生成
31
+
32
+ ## 3. 环境依赖 & Mock 策略
33
+ | 依赖 | 策略 | 说明 |
34
+ | --- | --- | --- |
35
+ | DB | 真(内嵌 H2 / test container MySQL) | 用 fixture 种子 |
36
+ | RiskService | mock | 覆盖 pass / hit / timeout 三分支 |
37
+ | FeatureFlag | stub | 默认 enabled=true,按用例切 |
38
+ | 监控上报 | spy | 断言指标是否上报 |
39
+
40
+ ## 4. 测试用例索引
41
+ | TC | 类型 | F-ID | 优先级 | 一句话 |
42
+ | --- | --- | --- | --- | --- |
43
+ | TC-001 | unit | F-01 | P0 | 正向:1000 人全成功 |
44
+ | TC-002 | unit | F-01 | P0 | 边界:空 userIds 400 |
45
+ | TC-003 | unit | F-01 | P0 | 边界:1001 人 400 |
46
+ | TC-004 | unit | F-02 | P0 | 部分失败:10 人风控 → failedUsers |
47
+ | TC-005 | integration | F-01 | P0 | E2E with DB:批次落库正确 |
48
+ | TC-006 | integration | F-02 | P1 | RiskService timeout 降级 |
49
+ | TC-007 | unit | F-01 | P1 | 幂等:同 batchId 重复调用 |
50
+ | TC-008 | integration | F-03 | P1 | 运营后台 CSV 上传 → 调 F-01 |
51
+ | TC-009 | integration | F-01 | P1 | 权限:无 coupon:batch_grant → 403 |
52
+ | NFR-PERF-001 | perf | F-01 | P1 | 1000 人 P99 ≤ 3s |
53
+
54
+ ## 5. 逐用例详表
55
+
56
+ ### TC-001:正向 - 1000 人全成功
57
+ - **type**: unit
58
+ - **linkedF**: F-01
59
+ - **priority**: P0
60
+ - **preconditions**:
61
+ - couponTemplate `ct_ok` 存在、库存 1200
62
+ - userIds = 1000 个合法 userId(fixture users/batch_1k.json)
63
+ - RiskService mock 全 pass
64
+ - **steps**:
65
+ 1. 调 `BatchGrantController.grant({userIds, couponTemplateId: 'ct_ok'})`
66
+ - **expected**:
67
+ - 响应 status = 200
68
+ - body.grantedCount === 1000
69
+ - body.failedCount === 0
70
+ - body.failedUsers === []
71
+ - DB: coupon_grant 表新增 1000 行,每行 batch_id 非空且一致
72
+ - 指标 `coupon.batch.latency` 上报 1 条 histogram
73
+ - **dataSource**: fixtures/users/batch_1k.json
74
+ - **notes**: -
75
+
76
+ ### TC-002:边界 - 空 userIds → 400
77
+ - **type**: unit
78
+ - **linkedF**: F-01
79
+ - **priority**: P0
80
+ - **preconditions**: userIds = []
81
+ - **steps**:
82
+ 1. 调接口
83
+ - **expected**:
84
+ - 响应 status = 400
85
+ - body.code === "EMPTY_BATCH"
86
+ - DB 无变更
87
+ - **dataSource**: -
88
+
89
+ ### TC-003:边界 - 1001 人 → 400 BATCH_TOO_LARGE
90
+ - **type**: unit
91
+ - **linkedF**: F-01
92
+ - **priority**: P0
93
+ - **preconditions**: userIds 长度 1001
94
+ - **steps**:
95
+ 1. 调接口
96
+ - **expected**:
97
+ - 响应 status = 400
98
+ - body.code === "BATCH_TOO_LARGE"
99
+ - body.details.limit === 1000
100
+ - body.details.actual === 1001
101
+
102
+ ### TC-004:部分失败 - 10 人风控 hit
103
+ - **type**: unit
104
+ - **linkedF**: F-02
105
+ - **priority**: P0
106
+ - **preconditions**:
107
+ - userIds = 1000(fixture users/with_risk.json:前 50 人 mock 命中风控)
108
+ - RiskService mock: 前 10 人返回 hit(hitCode = "R001"),其余 pass
109
+ - **steps**:
110
+ 1. 调接口
111
+ - **expected**:
112
+ - 响应 status = 200
113
+ - body.grantedCount === 990
114
+ - body.failedCount === 10
115
+ - body.failedUsers 含 10 个 {userId, reason: "RISK_HIT", hitCode: "R001"}
116
+ - DB: coupon_grant 新增 990 行(被拦的 10 人无记录)
117
+
118
+ ### TC-005:integration - 批次落库
119
+ - **type**: integration
120
+ - **linkedF**: F-01
121
+ - **priority**: P0
122
+ - **preconditions**:
123
+ - test container MySQL 已起
124
+ - fixture users/batch_1k.json
125
+ - **steps**:
126
+ 1. HTTP POST 真实调用
127
+ 2. SELECT * FROM coupon_grant WHERE batch_id = <返回的 batchId>
128
+ - **expected**:
129
+ - 查询得 1000 行
130
+ - 每行 status = 'granted',batch_id 一致,user_id 与输入列表一一对应
131
+
132
+ ### TC-006:RiskService timeout 降级
133
+ - **type**: integration
134
+ - **linkedF**: F-02
135
+ - **priority**: P1
136
+ - **preconditions**:
137
+ - RiskService stub: 对前 20 个 userId 返回 timeout(sleep 5s)
138
+ - config:riskTimeoutMs = 3000
139
+ - **steps**:
140
+ 1. 调接口(1000 人)
141
+ - **expected**:
142
+ - 响应 status = 200
143
+ - 前 20 个在 failedUsers(reason: "RISK_TIMEOUT")
144
+ - 指标 `risk.timeout.count` 上报 20 次
145
+
146
+ ### TC-007:幂等 - 同 batchId
147
+ - **type**: unit
148
+ - **linkedF**: F-01
149
+ - **priority**: P1
150
+ - **preconditions**:
151
+ - batchId = "b_test_01"
152
+ - 第一次调用成功发 1000 人
153
+ - **steps**:
154
+ 1. 用同 batchId 再调一次
155
+ - **expected**:
156
+ - 响应 status = 200
157
+ - 内容与第一次相同(幂等)
158
+ - DB 不新增行(唯一键拦截)
159
+
160
+ ### TC-009:权限 - 无 coupon:batch_grant
161
+ - **type**: integration
162
+ - **linkedF**: F-01
163
+ - **priority**: P1
164
+ - **preconditions**:
165
+ - 使用普通运营 token(角色: coupon:view)
166
+ - **steps**:
167
+ 1. 调接口
168
+ - **expected**:
169
+ - 响应 status = 403
170
+ - body.code === "FORBIDDEN"
171
+
172
+ ### NFR-PERF-001:1000 人性能基线
173
+ - **type**: perf
174
+ - **linkedF**: F-01 + NFR-PERF
175
+ - **priority**: P1
176
+ - **preconditions**: 单实例 4c8g;DB 有 1k 模板 + 10k 用户 fixture
177
+ - **steps**:
178
+ 1. 用 k6 / JMeter 调接口 20 并发 × 5 分钟,每次 1000 人
179
+ - **expected**:
180
+ - P99 ≤ 3s
181
+ - Error rate < 0.1%
182
+ - GC 无 Full GC > 200ms
183
+
184
+ ## 6. 非功能测试
185
+ - 性能:NFR-PERF-001(见上)
186
+ - 安全:TC-009 已覆盖鉴权;敏感数据脱敏在 unit test 里检查 log message
187
+ - 可观测性:TC-001 / TC-006 断言指标上报
188
+
189
+ ## 7. 回归清单
190
+ | 已有 TC | 影响 | 重跑原因 |
191
+ | --- | --- | --- |
192
+ | CouponGrantControllerTest.testSingleGrant | 单发不应受影响 | 确认不回归 |
193
+ | RiskServiceTest.testCheck_hit | 风控判定不变 | 确认签名兼容 |
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 字段语义补充
199
+
200
+ ### TC 编号
201
+
202
+ - `TC-<NNN>`(三位数字)全局唯一
203
+ - 不重用已删除的编号
204
+ - 非功能前缀 `NFR-<domain>-<NNN>`
205
+
206
+ ### priority(优先级)
207
+
208
+ | | 含义 |
209
+ | --- | --- |
210
+ | P0 | 必过;一个挂就阻塞 deliver |
211
+ | P1 | 应过;挂了但 MUST 修不上,需要用户 accept 风险 |
212
+ | P2 | 最好过;挂了可以进 `todo.md` 下期跟进 |
213
+
214
+ ### type(类型)
215
+
216
+ - **unit**:单类 / 纯函数;mock 所有外部依赖;毫秒级
217
+ - **integration**:真实 DB + mock 第三方;秒级
218
+ - **e2e**:端到端全链路(可能含前端);分钟级
219
+ - **perf**:性能 / 容量;独立阶段跑
220
+ - **security**:鉴权 / 敏感数据 / 越权;通常归 integration 但单独标识
221
+
222
+ ### linkedF
223
+
224
+ - 必引用 ≥ 1 个 F-ID(如 `F-01` 或 `F-01, F-02`)
225
+ - 非功能引用 `NFR-<domain>`(PERF / SEC / OBS / AVAIL)
226
+
227
+ ### preconditions
228
+
229
+ **要**:具体、可复现(fixture 文件名 / 数据库状态 / mock 返回)
230
+
231
+ **不要**:"系统正常" / "普通场景"这种模糊表达
232
+
233
+ ### steps
234
+
235
+ - 编号列表,每一步动作是 agent 可执行的
236
+ - 不要塞断言(断言在 expected);只写"做什么"
237
+
238
+ ### expected
239
+
240
+ - 每条断言独立一行
241
+ - 覆盖:响应、body 字段、DB 状态、副作用(指标、日志、事件)
242
+ - **数字精确**("grantedCount === 990",不是"大约 990")
243
+
244
+ ### dataSource
245
+
246
+ - 指向 fixture 文件或 factory 规则
247
+ - 不要用"根据业务逻辑生成"这种模糊表达
248
+
249
+ ### notes
250
+
251
+ - flaky 原因、skip 原因、为什么不用某种测法
252
+ - 空可以省略
253
+
254
+ ---
255
+
256
+ ## 反例
257
+
258
+ ```
259
+ TC-XXX: 测试批量发放
260
+ type: unit
261
+ steps: 调用接口,检查结果
262
+ expected: 正常
263
+ ```
264
+
265
+ 问题:
266
+
267
+ - 没 linkedF
268
+ - preconditions 缺
269
+ - steps 不可执行
270
+ - expected 零信息(什么叫"正常")
271
+
272
+ ---
273
+
274
+ ## 本文与 SKILL.md 的关系
275
+
276
+ SKILL.md 给了 tests.md 的 section 骨架和字段清单。本文是完整模板 + 完整示例,agent 写 tests.md 时复制本文模板开始。
@@ -0,0 +1,232 @@
1
+ ---
2
+ name: devflow-verify
3
+ description: |
4
+ devflow-kit verify 阶段按 change 级别跑齐所有必需测试 + 报告(unit / integration / contract / e2e / joint / remote / smoke / self-test /
5
+ perf / regression),用**带 YAML frontmatter 的 markdown** 作为 first-class 报告物,
6
+ 最后 `devflow verify finalize` 汇总到 verify.md。触发:`devflow verify`、`devflow test <kind>`、
7
+ `devflow report self-test`、`devflow verify finalize`、`/df:verify`。
8
+ when_to_use: |
9
+ code-review 全部轮次通过后。跑测试 → 写 / 生成报告 → finalize。不通过则回退 apply(修)
10
+ 或 tech-spec(重新设计)。verify 拦的是"事实",不是"主观判断"。
11
+ ---
12
+
13
+ # verify
14
+
15
+ **事实层**:只关心"测试真的跑了没、结果是什么"。不下主观判断(那是 review 的事),但可以发现 review 看不出来的行为问题(如性能不达标)。
16
+
17
+ ## 前置检查
18
+
19
+ | 输入 | 必需 | 缺失处理 |
20
+ | --- | --- | --- |
21
+ | code-review status = completed(所有轮次通过) | 是 | 回退 review |
22
+ | 所有 plan 的 task 状态 done | 是 | 回退 apply |
23
+ | `design.md` 里有 NFR(L2/L3) | L2/L3 必须 | 回退 tech-spec |
24
+ | 测试契约 | 是 | 优先读 `tests.md`;缺失时读 `plan.md` 的 Test 字段和 requirement.md 的 AC |
25
+ | 有可用的测试执行环境 | 是 | `devflow doctor` |
26
+
27
+ **硬闸**:`devflow verify` 启动时检查 `state.review.status === "completed"`;缺失拒绝启动,除非 `--skip-review-gate --reason="..."`(审计)。如果 review 刚通过并生成了 `verify_start` 检查点,必须先由用户确认 `devflow checkpoint resolve --id=<checkpoint-id> --decision=start-verify`,不得自动开始 verify;紧急场景可用 `devflow verify --slug=<slug> --force --reason="..."` 审计绕过。
28
+
29
+ ## 按级别的必需报告
30
+
31
+ | level | 必需报告 | 可选 |
32
+ | --- | --- | --- |
33
+ | L0 | `test-report.md#unit` | 若部署后才可见,补 `#smoke` |
34
+ | L1 | `test-report.md#unit`, `#smoke` | — |
35
+ | L2 | `test-report.md#unit`, `#integration`, `#smoke`, `#self-test` | 有调用方/回调/跳转链路时补 `#contract`;按风险补 regression |
36
+ | L3 | `test-report.md#unit`, `#integration`, `#e2e`, `#smoke`, `#self-test` | 跨服务链路默认补 `#contract`;按风险补 `#perf`, `#regression` |
37
+
38
+ 报告按需聚合写在 `devflow/changes/<slug>/reports/test-report.md`。不要为凑 level 生成空 section;没执行对应测试就不要写对应 section。只有兼容旧工具时才显式加 `--split-report` 额外生成零散 markdown。
39
+
40
+ 每种报告的具体结构、必填字段、数据来源:见 [`references/report-templates.md`](references/report-templates.md)。
41
+
42
+ ## 每种报告的产出方式
43
+
44
+ | kind | 生成方式 | 工具 |
45
+ | --- | --- | --- |
46
+ | unit-test | 自动 | `devflow test unit --cmd "<test command>"` |
47
+ | integration-test | 自动 | `devflow test integration --cmd "<test command>"` |
48
+ | contract-test | 自动/半自动 | `devflow test contract --cmd "<contract/check command>"`;可结合 `devflow sync yapi` 和 `devflow logs query` |
49
+ | e2e-test | 半自动 | `devflow test e2e --cmd "..."` + 手动补充截图 / 视频链接 |
50
+ | joint-test | 半自动 | `devflow test joint --cmd "..." --backend-url=... --frontend-url=...` + 浏览器操作 / 截图 |
51
+ | remote-test | 自动/半自动 | `devflow test remote --preflight --api-base-url=... --cmd "..."` |
52
+ | smoke-test | 手工 | 按模板手写(实际用户路径走一遍) |
53
+ | self-test | 半自动 | `devflow report self-test` 脚手架 → 按 F-ID / AC 逐项手填证据 |
54
+ | perf-test | 自动或半自动 | `devflow test perf --cmd "<jmh / wrk / k6 command>"` |
55
+ | regression-test | 自动 | `devflow test regression --cmd "<回归 suite>"` |
56
+
57
+ 框架自动解析 9 种框架(Jest / Vitest / Mocha / Tap / node:test / Go / Pytest / unittest / JUnit)和 5 种 coverage 格式(JSON summary / LCOV / Cobertura / Go cover profile / JaCoCo XML),都能写进 frontmatter。
58
+
59
+ 报告的解析规则、自定义扩展、frontmatter 最小 / 推荐字段:见 [`references/report-templates.md`](references/report-templates.md)。
60
+
61
+ ## YAML frontmatter 契约
62
+
63
+ 每份报告**必须**包含:
64
+
65
+ ```yaml
66
+ ---
67
+ slug: <change-slug>
68
+ kind: unit | integration | contract | e2e | joint | remote | smoke | self-test | regression | perf
69
+ status: pass | fail | partial | blocked
70
+ failureType: code_error | env_error | -
71
+ ts: <ISO datetime>
72
+ ---
73
+ ```
74
+
75
+ 推荐补充(生成器会自动填;手写时可选):
76
+
77
+ ```yaml
78
+ total: 245
79
+ passed: 243
80
+ failed: 2
81
+ skipped: 0
82
+ duration_ms: 142300
83
+ coverage:
84
+ lines: 86.4
85
+ branches: 78.1
86
+ coveragePath: coverage/coverage-summary.json
87
+ command: "mvn -pl coupon-service test"
88
+ ```
89
+
90
+ `devflow verify finalize`、`devflow deliver` 里生成 PR 评论 都会读这些字段。缺失时会回退到简化展示。
91
+
92
+ ## Self-test 的严格性
93
+
94
+ L2/L3 的 `test-report.md#self-test` 不是 "跑了下单元测试" 就算。它必须**逐个 F-ID / AC 留证据**:
95
+
96
+ ```markdown
97
+ ### F-01 | AC1: 批量提交 1000 条成功 → 返回 grantedCount=1000
98
+
99
+ - **执行方式**:postman / curl 批量提交,query DB
100
+ - **执行时间**:2026-04-24 14:00
101
+ - **输入**:`users-1k.json`(附件)
102
+ - **期望**:response.grantedCount = 1000
103
+ - **实际**:response.grantedCount = 1000 ✅
104
+ - **证据**:`reports/evidence/F-01-AC1-response.json`、`reports/screenshots/F-01-AC1-db.png`
105
+ ```
106
+
107
+ self-test 书写规则 + AC 证据模板 + 反模式:见 [`references/self-test-guide.md`](references/self-test-guide.md)。
108
+
109
+ ## NFR 验证(L2/L3)
110
+
111
+ design.md 里的 NFR(性能、并发、SLA)在 verify 阶段**必须**有对应报告数据支撑:
112
+
113
+ | NFR 类型 | 验证手段 |
114
+ | --- | --- |
115
+ | P99 响应时间 | `test-report.md#perf`,基于负载测试工具输出 |
116
+ | QPS / 吞吐 | `test-report.md#perf` |
117
+ | 并发数 | `test-report.md#perf`(压测工具并发参数) |
118
+ | 可用性(SLA) | 不在 verify 跑,但要写进 rollout plan |
119
+ | 数据一致性 | `test-report.md#integration` 或 `#self-test` |
120
+ | 调用链 / API 契约一致性 | `test-report.md#contract`;必要时附 YAPI 同步记录和 SLS/OSS 日志检索 |
121
+ | 资源使用(CPU / mem) | `test-report.md#perf`(附 profiling 截图) |
122
+
123
+ 缺失 NFR 报告 → finalize 拒绝通过,除非用 `--accept-missing-nfr` 审计跳过(带 justification)。
124
+
125
+ NFR 验证的具体方法、工具选型、基线对比:见 [`references/nfr-verification.md`](references/nfr-verification.md)。
126
+
127
+ ## Finalize
128
+
129
+ ```bash
130
+ devflow verify finalize
131
+ ```
132
+
133
+ 执行内容:
134
+
135
+ 1. 扫描 `reports/` 下所有必需报告(根据 level)
136
+ 2. 读每份报告的 frontmatter(尤其 status)
137
+ 3. **全部 status=pass** → verify.status=completed,产出 `verify.md` 汇总
138
+ 4. 任一 fail / partial → finalize 拒绝;顾问给出回退建议(apply / tech-spec / requirement-analysis)
139
+ 5. 任一缺失 → 拒绝,提示补跑
140
+
141
+ verify.md 本身 = 一份 dashboard(报告链接 + 结论),不重复内容。
142
+
143
+ ## 测试失败时的 Systematic Debug(必须先找根因)
144
+
145
+ > 借鉴 **systematic-debugging** 原则:禁止"随手改一下试试",每次修复前必须完成根因调查。
146
+
147
+ ```
148
+ Iron Law: NO FIXES WITHOUT ROOT CAUSE FIRST
149
+
150
+ 测试失败 → 4 阶段必须顺序执行,不可跳跃:
151
+
152
+ Phase 1 — 根因调查(先于任何改动)
153
+ 1. 完整读错误信息(不要只看最后一行)
154
+ 2. 确认:能稳定复现吗?每次都失败?
155
+ 3. 查最近变更:git diff 里哪个改动最可能引入这个 fail?
156
+ 4. 多组件系统:在每个边界加诊断输出,先跑一次看在哪层断
157
+
158
+ Phase 2 — 模式分析
159
+ 1. 找 codebase 里同类功能的正常写法
160
+ 2. 对比"正常的"和"失败的",列出所有差异
161
+ 3. 确认依赖 / 环境 / 配置是否完整
162
+
163
+ Phase 3 — 假设 + 最小验证
164
+ 1. 写下一句话假设:"我认为根因是 X,因为 Y"
165
+ 2. 最小改动验证(只改一处)
166
+ 3. 若验证失败 → 新假设,不要叠加修改
167
+
168
+ Phase 4 — 修复
169
+ 1. 先写回归测试(红 → 绿 验证)
170
+ 2. 改根因,不改症状
171
+ 3. 确认 exit 0 + 全量测试绿
172
+
173
+ ⛔ 红线(出现以下想法立刻停):
174
+ - "先改几个地方看看哪个有效"
175
+ - "大概是 X 问题,改了再说"
176
+ - 尝试 3 次都没解决 → 停!可能是架构问题,回 tech-spec
177
+ ```
178
+
179
+ ## 失败后的回退路径
180
+
181
+ | 失败情况 | 回退到 |
182
+ | --- | --- |
183
+ | unit / integration fail,代码 bug | apply |
184
+ | e2e fail,集成问题 | apply(可能 tech-spec) |
185
+ | self-test 发现 AC 没满足 | apply(回去实现;严重时 tech-spec 重新设计) |
186
+ | perf-test 不达 NFR | tech-spec(重新设计)或申请修改 NFR(回到 requirement-analysis) |
187
+ | smoke-test 发现 UX / 核心路径不通 | apply |
188
+ | 回归测试挂(无关本次改动) | 记 ISSUE + 审计跳过(不阻塞本 slug) |
189
+
190
+ 每次回退都在 `state.iterations[]` 记一条("triggeredAt: verify")。
191
+
192
+ verify 失败的完整回退决策树、审计格式、与 orchestrator 的交互:见 [`references/verify-rollback-map.md`](references/verify-rollback-map.md)。
193
+
194
+ ## 完成状态协议
195
+
196
+ ```
197
+ ---STATUS---
198
+ result: DONE | BLOCKED | NEEDS_INPUT
199
+ verifyStatus: pass | fail | partial | blocked
200
+ outputs:
201
+ - devflow/changes/<slug>/verify.md
202
+ - devflow/changes/<slug>/reports/test-report.md
203
+ reports:
204
+ unit: pass (243/245, cov 86.4%)
205
+ integration: pass (52/52)
206
+ e2e: pass (18/18)
207
+ smoke: pass
208
+ self-test: pass (12/12 F-ID, all AC met)
209
+ perf: pass (P99=180ms, NFR=200ms)
210
+ failedReports: []
211
+ nextAction: devflow deliver
212
+ ---END_STATUS---
213
+ ```
214
+
215
+ ## 反模式
216
+
217
+ - **pass 前没有重跑最新代码**:上次 fix 后没重跑,结果 report 是旧的(frontmatter `ts` 字段会暴露:早于最后一次 commit)
218
+ - **self-test 一笔带过**("按规格做了测试,通过了" 没 AC 证据)→ L2/L3 finalize 会拒绝
219
+ - **截图超 1MB 嵌 markdown**:用 `reports/screenshots/` 相对链接
220
+ - **跳过 perf-test 说"线下环境不准"**:至少跑一次拿基线,不达标则 stub + 真实环境补跑
221
+ - **把 skipped 测试归为 pass**:frontmatter 的 skipped 字段要如实;大量 skip 需 explain
222
+ - **finalize 前没清 flaky**:3 次跑 2 次过的测试要先 quarantine(+ 记 issue),不能"多跑几次过就算"
223
+ - **把 verify.md 写得比 review.md 长**:verify.md 是 dashboard,不重复内容
224
+ - **verify 不过就在 apply 偷偷改**:必须回退到 apply(更新 state、开新 iteration)
225
+ - **把测试框架警告当错误**(or 反过来):status=pass/fail 的判定要看 frontmatter,不要看"视觉印象"
226
+
227
+ ## 参考
228
+
229
+ - [`references/report-templates.md`](references/report-templates.md) — 每种 kind 的模板、frontmatter 字段语义、9 种测试框架 / 5 种 coverage 格式的识别规则
230
+ - [`references/self-test-guide.md`](references/self-test-guide.md) — self-test 的 AC 证据书写规则、L1 / L2 / L3 深度要求、反模式
231
+ - [`references/nfr-verification.md`](references/nfr-verification.md) — 性能 / 吞吐 / 可用性 / 资源的验证方法与工具选型
232
+ - [`references/verify-rollback-map.md`](references/verify-rollback-map.md) — 失败 → 回退决策树 + 审计格式 + 与 orchestrator 的接口