@boyingliu01/xp-gate 0.18.4 → 0.19.0

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 (248) hide show
  1. package/adapter-common.sh +27 -0
  2. package/adapters/powershell.sh +85 -33
  3. package/adapters/typescript.sh +8 -8
  4. package/build-integrity/__tests__/import-resolver.test.ts +22 -0
  5. package/build-integrity/__tests__/orchestrator.test.ts +1 -2
  6. package/build-integrity/gate-10.ts +7 -0
  7. package/gate-12-file-hygiene.sh +230 -0
  8. package/hooks/adapter-common.sh +27 -0
  9. package/hooks/gate-10.sh +105 -0
  10. package/hooks/lib/validate-code-walkthrough.cjs +125 -0
  11. package/hooks/pre-commit +130 -33
  12. package/hooks/pre-push +15 -91
  13. package/lib/__tests__/check-version.test.js +67 -46
  14. package/lib/__tests__/doctor.test.js +7 -6
  15. package/lib/__tests__/gate-runner.test.js +267 -0
  16. package/lib/__tests__/init.test.js +32 -0
  17. package/lib/__tests__/npm-package.test.js +13 -0
  18. package/lib/__tests__/phase-transition.test.js +604 -12
  19. package/lib/__tests__/sprint-discovery.test.ts +0 -1
  20. package/lib/__tests__/sprint-status-rework.test.js +100 -1
  21. package/lib/__tests__/update-hooks.test.js +143 -10
  22. package/lib/__tests__/upgrade-exec.test.js +73 -45
  23. package/lib/__tests__/upgrade-skill-sync.test.js +1 -1
  24. package/lib/__tests__/upgrade.test.js +12 -11
  25. package/lib/doctor.js +2 -1
  26. package/lib/gate-runner.js +68 -23
  27. package/lib/init.js +34 -5
  28. package/lib/install-skill.js +1 -0
  29. package/lib/mattpocock-license-verdict.json +1 -1
  30. package/lib/phase-transition.js +203 -23
  31. package/lib/shared-paths.js +2 -0
  32. package/lib/sprint-status.js +15 -4
  33. package/lib/test-alignment.ts +3 -13
  34. package/lib/update-hooks.js +129 -15
  35. package/mock-policy/AGENTS.md +5 -5
  36. package/mock-policy/__tests__/gate-m3.test.ts +0 -5
  37. package/mock-policy/__tests__/scope-scanner.test.ts +8 -2
  38. package/mutation/AGENTS.md +4 -4
  39. package/mutation/__tests__/mutmut-runner.test.ts +443 -2
  40. package/mutation/__tests__/update-baseline.test.ts +0 -2
  41. package/mutation/runners/mutmut-runner.ts +67 -17
  42. package/package.json +9 -3
  43. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  44. package/plugins/claude-code/skills/clipboard-vision/SKILL.md +47 -0
  45. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  46. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  47. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  48. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  49. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  50. package/plugins/claude-code/skills/clipboard-vision/describe-clipboard.sh +161 -0
  51. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  52. package/plugins/claude-code/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  53. package/plugins/claude-code/skills/delphi-review/.delphi-config.json.example +24 -27
  54. package/plugins/claude-code/skills/delphi-review/AGENTS.md +13 -12
  55. package/plugins/claude-code/skills/delphi-review/INSTALL.md +15 -17
  56. package/plugins/claude-code/skills/delphi-review/SKILL.md +30 -29
  57. package/plugins/claude-code/skills/delphi-review/opencode.json.delphi.example +6 -10
  58. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +33 -49
  59. package/plugins/claude-code/skills/delphi-review/references/requirements.md +66 -54
  60. package/plugins/claude-code/skills/delphi-review/references/round-templates.md +7 -7
  61. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +5 -5
  62. package/plugins/claude-code/skills/sprint-flow/SKILL.md +4 -4
  63. package/plugins/claude-code/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  64. package/plugins/claude-code/skills/sprint-flow/references/force-levels.md +37 -35
  65. package/plugins/claude-code/skills/sprint-flow/references/orchestration-rules.md +1 -1
  66. package/plugins/claude-code/skills/sprint-flow/references/phase-1-prep.md +1 -1
  67. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +24 -14
  68. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +6 -6
  69. package/plugins/claude-code/skills/sprint-flow/references/phase-overview.md +2 -2
  70. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
  71. package/plugins/dsh/README.md +25 -0
  72. package/plugins/dsh/cordis.patch.yml +7 -0
  73. package/plugins/dsh/package.json +70 -0
  74. package/plugins/dsh/scripts/prepack.cjs +82 -0
  75. package/plugins/dsh/skills/admin-template-guidelines/SKILL.md +113 -0
  76. package/plugins/dsh/skills/admin-template-guidelines/references/rule-1.md +91 -0
  77. package/plugins/dsh/skills/admin-template-guidelines/references/rule-2.md +155 -0
  78. package/plugins/dsh/skills/admin-template-guidelines/references/rule-3.md +70 -0
  79. package/plugins/dsh/skills/admin-template-guidelines/references/rule-4.md +154 -0
  80. package/plugins/dsh/skills/admin-template-guidelines/references/rule-5.md +126 -0
  81. package/plugins/dsh/skills/admin-template-guidelines/references/rule-6.md +180 -0
  82. package/plugins/dsh/skills/batch-grill-me/SKILL.md +15 -0
  83. package/plugins/dsh/skills/clipboard-vision/SKILL.md +47 -0
  84. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  85. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  86. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  87. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  88. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  89. package/plugins/dsh/skills/clipboard-vision/describe-clipboard.sh +161 -0
  90. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  91. package/plugins/dsh/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  92. package/plugins/dsh/skills/delphi-review/.delphi-config.json.example +70 -0
  93. package/plugins/dsh/skills/delphi-review/AGENTS.md +67 -0
  94. package/plugins/dsh/skills/delphi-review/INSTALL.md +150 -0
  95. package/plugins/dsh/skills/delphi-review/SKILL.md +559 -0
  96. package/plugins/dsh/skills/delphi-review/hooks.md +19 -0
  97. package/plugins/dsh/skills/delphi-review/opencode.json.delphi.example +52 -0
  98. package/plugins/dsh/skills/delphi-review/references/code-walkthrough.md +470 -0
  99. package/plugins/dsh/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  100. package/plugins/dsh/skills/delphi-review/references/requirements.md +402 -0
  101. package/plugins/dsh/skills/delphi-review/references/round-templates.md +134 -0
  102. package/plugins/dsh/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  103. package/plugins/dsh/skills/delphi-review/tools.md +29 -0
  104. package/plugins/dsh/skills/domain-modeling/ADR-FORMAT.md +64 -0
  105. package/plugins/dsh/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  106. package/plugins/dsh/skills/domain-modeling/SKILL.md +74 -0
  107. package/plugins/dsh/skills/grill-with-docs/SKILL.md +7 -0
  108. package/plugins/dsh/skills/grilling/SKILL.md +12 -0
  109. package/plugins/dsh/skills/improve-codebase-architecture/SKILL.md +156 -0
  110. package/plugins/dsh/skills/ralph-loop/SKILL.md +198 -0
  111. package/plugins/dsh/skills/ralph-loop/references/components.md +113 -0
  112. package/plugins/dsh/skills/ralph-loop/references/phase-2-build-ralph.md +89 -0
  113. package/plugins/dsh/skills/ralph-loop/references/workflow-details.md +99 -0
  114. package/plugins/dsh/skills/ralph-loop/templates/progress-log.md +36 -0
  115. package/plugins/dsh/skills/sprint-flow/AGENTS.md +103 -0
  116. package/plugins/dsh/skills/sprint-flow/SKILL.md +411 -0
  117. package/plugins/dsh/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  118. package/plugins/dsh/skills/sprint-flow/hooks.md +18 -0
  119. package/plugins/dsh/skills/sprint-flow/references/components/memory.md +87 -0
  120. package/plugins/dsh/skills/sprint-flow/references/components/middleware.md +75 -0
  121. package/plugins/dsh/skills/sprint-flow/references/components/skill-invocations.md +105 -0
  122. package/plugins/dsh/skills/sprint-flow/references/components/system-prompt.md +27 -0
  123. package/plugins/dsh/skills/sprint-flow/references/components/tool-descriptions.md +95 -0
  124. package/plugins/dsh/skills/sprint-flow/references/force-levels.md +204 -0
  125. package/plugins/dsh/skills/sprint-flow/references/orchestration-rules.md +236 -0
  126. package/plugins/dsh/skills/sprint-flow/references/phase-1-prep.md +294 -0
  127. package/plugins/dsh/skills/sprint-flow/references/phase-2-design.md +273 -0
  128. package/plugins/dsh/skills/sprint-flow/references/phase-3-build.md +348 -0
  129. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +225 -0
  130. package/plugins/dsh/skills/sprint-flow/references/phase-5-ship.md +222 -0
  131. package/plugins/dsh/skills/sprint-flow/references/phase-6-close.md +266 -0
  132. package/plugins/dsh/skills/sprint-flow/references/phase-overview.md +486 -0
  133. package/plugins/dsh/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  134. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-learning-log.md +136 -0
  135. package/plugins/dsh/skills/sprint-flow/templates/auto-estimate-output-template.md +110 -0
  136. package/plugins/dsh/skills/sprint-flow/templates/emergent-issues-template.md +120 -0
  137. package/plugins/dsh/skills/sprint-flow/templates/pain-document-template.md +115 -0
  138. package/plugins/dsh/skills/sprint-flow/templates/sprint-progress-template.md +140 -0
  139. package/plugins/dsh/skills/sprint-flow/templates/sprint-summary-template.md +121 -0
  140. package/plugins/dsh/skills/sprint-flow/tools.md +29 -0
  141. package/plugins/dsh/skills/test-driven-development/SKILL.md +371 -0
  142. package/plugins/dsh/skills/test-driven-development/testing-anti-patterns.md +299 -0
  143. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +56 -0
  144. package/plugins/dsh/skills/test-specification-alignment/SKILL.md +205 -0
  145. package/plugins/dsh/skills/test-specification-alignment/references/alignment-verification-algorithm.md +493 -0
  146. package/plugins/dsh/skills/test-specification-alignment/references/phase2-constraint-enforcement.md +431 -0
  147. package/plugins/dsh/skills/test-specification-alignment/references/specification-format.md +348 -0
  148. package/plugins/dsh/skills/to-issues/SKILL.md +277 -0
  149. package/plugins/dsh/src/command.test.ts +102 -0
  150. package/plugins/dsh/src/command.ts +75 -0
  151. package/plugins/dsh/src/contract.test.ts +62 -0
  152. package/plugins/dsh/src/gate-runner.test.ts +100 -0
  153. package/plugins/dsh/src/gate-runner.ts +58 -0
  154. package/plugins/dsh/src/index.test.ts +97 -0
  155. package/plugins/dsh/src/index.ts +94 -0
  156. package/plugins/dsh/src/skills.test.ts +58 -0
  157. package/plugins/dsh/tsconfig.build.json +13 -0
  158. package/plugins/dsh/tsconfig.json +19 -0
  159. package/plugins/dsh/vitest.config.ts +8 -0
  160. package/plugins/opencode/package.json +1 -1
  161. package/plugins/opencode/scripts/prepack.cjs +1 -0
  162. package/plugins/opencode/skills/clipboard-vision/SKILL.md +47 -0
  163. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  164. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  165. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  166. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  167. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  168. package/plugins/opencode/skills/clipboard-vision/describe-clipboard.sh +161 -0
  169. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  170. package/plugins/opencode/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  171. package/plugins/opencode/skills/delphi-review/.delphi-config.json.example +24 -27
  172. package/plugins/opencode/skills/delphi-review/AGENTS.md +13 -12
  173. package/plugins/opencode/skills/delphi-review/INSTALL.md +15 -17
  174. package/plugins/opencode/skills/delphi-review/SKILL.md +30 -29
  175. package/plugins/opencode/skills/delphi-review/opencode.json.delphi.example +6 -10
  176. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +33 -49
  177. package/plugins/opencode/skills/delphi-review/references/requirements.md +66 -54
  178. package/plugins/opencode/skills/delphi-review/references/round-templates.md +7 -7
  179. package/plugins/opencode/skills/sprint-flow/AGENTS.md +5 -5
  180. package/plugins/opencode/skills/sprint-flow/SKILL.md +4 -4
  181. package/plugins/opencode/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  182. package/plugins/opencode/skills/sprint-flow/references/force-levels.md +37 -35
  183. package/plugins/opencode/skills/sprint-flow/references/orchestration-rules.md +1 -1
  184. package/plugins/opencode/skills/sprint-flow/references/phase-1-prep.md +1 -1
  185. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +24 -14
  186. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +6 -6
  187. package/plugins/opencode/skills/sprint-flow/references/phase-overview.md +2 -2
  188. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
  189. package/plugins/qoder/plugin.json +1 -1
  190. package/plugins/qoder/skills/clipboard-vision/SKILL.md +47 -0
  191. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  192. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  193. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  194. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  195. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/SKILL.md +47 -0
  196. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  197. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  198. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  199. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  200. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  201. package/plugins/qoder/skills/clipboard-vision/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  202. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  203. package/plugins/qoder/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  204. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +3 -11
  205. package/plugins/qoder/skills/delphi-review/AGENTS.md +15 -17
  206. package/plugins/qoder/skills/delphi-review/INSTALL.md +12 -12
  207. package/plugins/qoder/skills/delphi-review/SKILL.md +58 -25
  208. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +1 -1
  209. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +33 -49
  210. package/plugins/qoder/skills/sprint-flow/AGENTS.md +5 -5
  211. package/plugins/qoder/skills/sprint-flow/SKILL.md +2 -2
  212. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +38 -35
  213. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  214. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +48 -6
  215. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +5 -6
  216. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
  217. package/principles/AGENTS.md +4 -4
  218. package/scripts/__tests__/sync-package-content.test.js +30 -0
  219. package/scripts/delphi-external-review.cjs +194 -63
  220. package/scripts/sync-package-content.js +9 -2
  221. package/skills/clipboard-vision/SKILL.md +47 -0
  222. package/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +65 -0
  223. package/skills/clipboard-vision/__tests__/clipboard-vision-security.test.cjs +185 -0
  224. package/skills/clipboard-vision/__tests__/clipboard-vision.Tests.ps1 +138 -0
  225. package/skills/clipboard-vision/__tests__/clipboard-vision.test.cjs +273 -0
  226. package/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  227. package/skills/clipboard-vision/describe-clipboard.sh +161 -0
  228. package/skills/clipboard-vision/scripts/clipboard-vision.ps1 +86 -0
  229. package/skills/clipboard-vision/scripts/clipboard-vision.sh +137 -0
  230. package/skills/delphi-review/.delphi-config.json.example +24 -27
  231. package/skills/delphi-review/AGENTS.md +13 -12
  232. package/skills/delphi-review/INSTALL.md +15 -17
  233. package/skills/delphi-review/SKILL.md +30 -29
  234. package/skills/delphi-review/opencode.json.delphi.example +6 -10
  235. package/skills/delphi-review/references/code-walkthrough.md +33 -49
  236. package/skills/delphi-review/references/requirements.md +66 -54
  237. package/skills/delphi-review/references/round-templates.md +7 -7
  238. package/skills/sprint-flow/AGENTS.md +5 -5
  239. package/skills/sprint-flow/SKILL.md +4 -4
  240. package/skills/sprint-flow/references/components/skill-invocations.md +2 -2
  241. package/skills/sprint-flow/references/force-levels.md +37 -35
  242. package/skills/sprint-flow/references/orchestration-rules.md +1 -1
  243. package/skills/sprint-flow/references/phase-1-prep.md +1 -1
  244. package/skills/sprint-flow/references/phase-2-design.md +24 -14
  245. package/skills/sprint-flow/references/phase-4-verify.md +6 -6
  246. package/skills/sprint-flow/references/phase-overview.md +2 -2
  247. package/skills/test-specification-alignment/AGENTS.md +4 -4
  248. package/sprint-gate.sh +291 -0
@@ -0,0 +1,348 @@
1
+ # Phase 3/6: BUILD(TDD + 并行执行 + 盲评 + 验证)
2
+
3
+ **完整指令**: @see SKILL.md `## Phase 3/6: BUILD` section.
4
+
5
+ **对应旧模型**: Phase 2 BUILD(功能不变)
6
+
7
+ **摘要**: TDD 执行, 多 Agent 并行加速, 盲评验证, Gate 1 验证通过。
8
+
9
+ **关键链路**: BUILD-ENTRY-CONTRACT → DELPHI-GATE → parallel-dispatch/ralph-loop → TDD → blind-review (read-only subagent) → verification → cost monitor
10
+
11
+ **输出**: MVP v1
12
+
13
+ ---
14
+
15
+ ## Gate 参考表(Phase 3/6 相关)
16
+
17
+ | Gate | 名称 | 行为 |
18
+ |------|------|------|
19
+ | Gate 5 | 单元测试 + 覆盖率 | 全部通过 + ≥80% 覆盖率 |
20
+ | Gate 5a-BLOCK | 新增 .ts/.tsx 文件测试强制 | 新增 .ts/.tsx 文件无对应测试文件 → BLOCK;修改文件 → WARNING |
21
+ | Gate M2 | Mock 密度检查 | 30% WARNING (Phase 1); 可配置 via `.mockpolicyrc` |
22
+
23
+ ---
24
+
25
+ ## BUILD Entry Contract Check (MANDATORY — v0.18.0+, 程序化)
26
+
27
+ **Purpose**: Validate `slices-manifest.json` schema and slice↔REQ cross-artifact consistency before entering BUILD.
28
+
29
+ **Execution**: `phase-transition 3 in_progress` 时程序化校验:
30
+
31
+ ```
32
+ 1. slices-manifest.json 存在且 schema 合法
33
+ 2. manifest 每个 slice 引用的 REQ 必须存在于 specification.yaml
34
+ 3. 不合法 → BLOCK
35
+ ```
36
+
37
+ **GATE CHECK**:
38
+ ```
39
+ [BUILD-ENTRY] slices-manifest.json exists ✓
40
+ [BUILD-ENTRY] manifest schema valid ✓
41
+ [BUILD-ENTRY] slice↔REQ consistency ✓ # 每个 slice 的 REQ 引用在 specification.yaml 中存在
42
+ ```
43
+
44
+ **IF GATE FAILS**: BLOCK — 返回 Phase 2/6 修复 manifest 或 specification.yaml。
45
+
46
+ ---
47
+
48
+ ## Uncommitted Changes Gate
49
+
50
+ **Purpose**: Prevent entering BUILD with uncommitted changes that could mix with sprint work.
51
+
52
+ **Execution**: Before entering Phase 3/6 BUILD, the orchestrator MUST check for uncommitted changes in the worktree.
53
+
54
+ ### Gate Logic
55
+
56
+ ```bash
57
+ # Check for uncommitted changes
58
+ UNCOMMITTED=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
59
+
60
+ if [ "$SKIP_UNCOMMITTED_GATE" = "1" ]; then
61
+ echo "[UNCOMMITTED-GATE] Skipped (SKIP_UNCOMMITTED_GATE=1)"
62
+ echo "{\"skipped\":true,\"reason\":\"SKIP_UNCOMMITTED_GATE=1\",\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .sprint-state/uncommitted-gate-log.json
63
+ elif [ "$UNCOMMITTED" -gt 0 ]; then
64
+ echo "⚠️ [UNCOMMITTED-GATE] Found ${UNCOMMITTED} uncommitted files in worktree:"
65
+ git status --short 2>/dev/null | head -20
66
+ echo ""
67
+ echo "Uncommitted changes may conflict with sprint work. Recommended actions:"
68
+ echo " 1. Commit changes: git add -A && git commit -m 'pre-sprint: save work before BUILD'"
69
+ echo " 2. Stash changes: git stash push -m 'pre-sprint stash'"
70
+ echo " 3. Skip gate: export SKIP_UNCOMMITTED_GATE=1 (not recommended)"
71
+ echo ""
72
+ echo "Logging to .sprint-state/uncommitted-gate-log.json"
73
+ echo "{\"blocked\":true,\"uncommitted_files\":${UNCOMMITTED},\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .sprint-state/uncommitted-gate-log.json
74
+ echo "[BLOCK] Uncommitted changes detected. Please commit, stash, or set SKIP_UNCOMMITTED_GATE=1 to continue."
75
+ exit 1
76
+ else
77
+ echo "✅ [UNCOMMITTED-GATE] Worktree clean. Proceeding to BUILD."
78
+ echo "{\"clean\":true,\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > .sprint-state/uncommitted-gate-log.json
79
+ fi
80
+ ```
81
+
82
+ ### Escape Valve
83
+
84
+ ```bash
85
+ # Skip the uncommitted changes gate (use with caution)
86
+ SKIP_UNCOMMITTED_GATE=1
87
+ ```
88
+
89
+ ### Log Format (`.sprint-state/uncommitted-gate-log.json`)
90
+
91
+ ```json
92
+ {
93
+ "clean": true,
94
+ "blocked": false,
95
+ "skipped": false,
96
+ "uncommitted_files": 0,
97
+ "timestamp": "2026-07-08T10:00:00Z"
98
+ }
99
+ ```
100
+
101
+ **Log location**: `.sprint-state/uncommitted-gate-log.json` — written on every gate execution for audit trail.
102
+
103
+ ---
104
+
105
+ ## TDD-GATE: Pre-Implementation TDD Check (MANDATORY — v0.14.0+)
106
+
107
+ **Purpose**: Enforce RED → GREEN → REFACTOR discipline at BUILD entry before any delegation.
108
+
109
+ **Execution**: Before dispatching to ralph-loop or parallel agents, the orchestrator MUST verify for each REQ:
110
+
111
+ ### Gate Logic
112
+
113
+ ```
114
+ FOR each REQ in slices-manifest.json:
115
+ IF test file exists for this REQ:
116
+ IF test passes (GREEN state) AND no implementation exists:
117
+ → BLOCK: TDD bypass detected. Test is passing before implementation.
118
+ ELSE IF test fails (RED state):
119
+ → ALLOW: Proceed to implementation (GREEN phase).
120
+ ELSE (no test file exists):
121
+ → ALLOW: Mark REQ as [TDD-RED]. ralph-loop creates the test as step 0.
122
+ ```
123
+
124
+ ### Todo Prefix Convention
125
+
126
+ Each todo item MUST carry a TDD phase prefix in the content field:
127
+ - `[TDD-RED]`: Write failing test first. No implementation yet.
128
+ - `[TDD-GREEN]`: Write minimal implementation to make test pass.
129
+ - `[TDD-REFACTOR]`: Refactor while keeping tests green.
130
+
131
+ The priority field (high/medium/low) is separate and unchanged.
132
+
133
+ Example:
134
+ ```
135
+ "[TDD-RED] src/lib/auth.ts: Add validateToken() test for expired tokens - expect test to fail"
136
+ "[TDD-GREEN] src/lib/auth.ts: Implement validateToken() to pass test - expect test passes"
137
+ "[TDD-REFACTOR] src/lib/auth.ts: Extract token parsing into parseToken() helper - expect tests stay green"
138
+ ```
139
+
140
+ ### Deadlock Prevention
141
+
142
+ The TDD-GATE is a PRE-RALPH-LOOP check, NOT a replacement for ralph-loop's internal TDD:
143
+ - If no test exists → ralph-loop IS allowed to proceed (creates test as step 0)
144
+ - If test exists and is GREEN without implementation → BLOCK (TDD bypass)
145
+ - The gate verifies TDD DISCIPLINE was followed, not that TDD was skipped
146
+
147
+ ### Limitation
148
+
149
+ This enforcement is instructional (LLM follows SKILL.md instructions), not programmatic. For stronger enforcement, consider a future automated pre-commit hook that checks git staging order (test file must be staged before source file).
150
+
151
+ ### Log Format (`.sprint-state/tdd-gate-log.json`)
152
+
153
+ ```json
154
+ {
155
+ "checked": true,
156
+ "blocked": false,
157
+ "skipped": false,
158
+ "reqs_checked": 4,
159
+ "reqs_blocked": 0,
160
+ "timestamp": "2026-07-09T00:00:00Z"
161
+ }
162
+ ```
163
+
164
+ **Log location**: `.sprint-state/tdd-gate-log.json` — written on every gate execution for audit trail.
165
+
166
+ ---
167
+
168
+ ## In-Session Verification (MANDATORY — v0.14.31+)
169
+
170
+ **Purpose**: Ensure every implementation change is immediately verified and recorded, enabling Better Loop Harness (and other observability tools) to capture normalized change→validation event pairs.
171
+
172
+ **Problem it solves**: Without explicit in-session verification, Agents may edit files and move on without running tests or linters. This creates unverified changes that are invisible to post-hoc review tools, breaking the traceability chain between "what changed" and "was it validated".
173
+
174
+ ### Mandatory Verification Protocol
175
+
176
+ After **every** implementation change (file edit, refactor, new feature, bug fix), the Agent MUST execute the following sequence BEFORE claiming the change is complete:
177
+
178
+ 1. **Run tests**: `npm test` or `npx vitest run` (or project-specific test command)
179
+ 2. **Run linter**: `npm run lint` or `npx eslint .` (or project-specific lint command)
180
+ 3. **Type-check** (TypeScript projects): `npx tsc --noEmit`
181
+ 4. **Record the result**: Append a structured verification event (see format below)
182
+
183
+ ### Verification Event Format
184
+
185
+ Each verification event MUST be recorded as a structured JSON object. Agents should output this to stdout or append to `.sprint-state/phase-outputs/verification-events.jsonl`:
186
+
187
+ ```json
188
+ {
189
+ "timestamp": "2026-07-22T10:30:00Z",
190
+ "change": {
191
+ "type": "edit|refactor|feature|bugfix",
192
+ "files": ["src/lib/auth.ts", "src/lib/auth.test.ts"],
193
+ "description": "Implement validateToken() for expired token handling"
194
+ },
195
+ "verification": {
196
+ "tests": { "command": "npx vitest run src/lib/auth.test.ts", "status": "pass|fail", "summary": "4 passed, 0 failed" },
197
+ "lint": { "command": "npm run lint", "status": "pass|fail|warn", "summary": "0 errors, 2 warnings" },
198
+ "typecheck": { "command": "npx tsc --noEmit", "status": "pass|fail|skip", "summary": "No type errors" }
199
+ },
200
+ "outcome": "verified|failed|partial",
201
+ "req": "REQ-003"
202
+ }
203
+ ```
204
+
205
+ ### Integration with ralph-loop
206
+
207
+ When using ralph-loop mode (default BUILD strategy), each REQ iteration MUST include verification as the final step before marking the REQ complete:
208
+
209
+ ```
210
+ ralph-loop iteration:
211
+ 1. [TDD-RED] Write failing test
212
+ 2. [TDD-GREEN] Implement minimal code to pass
213
+ 3. [TDD-REFACTOR] Clean up while keeping tests green
214
+ 4. [VERIFY] Run tests + lint + typecheck ← MANDATORY
215
+ 5. [RECORD] Append verification event ← MANDATORY
216
+ 6. Mark REQ complete and continue to next
217
+ ```
218
+
219
+ ### Anti-Patterns
220
+
221
+ | ❌ Error | ✅ Correct |
222
+ |----------|----------|
223
+ | Edit file → claim done → move to next task | Edit file → run tests + lint → record result → claim done |
224
+ | "Tests should pass" (assertion without evidence) | "Tests passed: 4 passed, 0 failed (npx vitest run)" |
225
+ | Run tests only at end of entire BUILD phase | Run tests after every individual change/REQ |
226
+ | Skip type-check because "I didn't touch types" | Always run `tsc --noEmit` on TypeScript projects |
227
+
228
+ ### Harness Integration
229
+
230
+ Better Loop Harness captures change and verification events by inspecting session history. The structured verification events above serve as the canonical signal that:
231
+ - A change occurred (the `change` field)
232
+ - The change was validated (the `verification` field)
233
+ - The outcome is attributable (the `outcome` field ties result to specific change)
234
+
235
+ Without these events, the Harness can only infer changes from file diffs and has no verification signal, resulting in lower "改动验证" (Change Verification) dimension scores.
236
+
237
+ ---
238
+
239
+ ## Blind Review — Read-Only Subagent Convention (v0.18.0+, 证据型标准步骤)
240
+
241
+ **Purpose**: Code review by an isolated subagent with read-only tool access. Replaces the former `freeze/unfreeze` mechanism.
242
+
243
+ **Convention**: The blind-review reviewer runs as a Task subagent with restricted tools:
244
+
245
+ ```
246
+ tools: [Read, Grep, Glob] # 只读 — 禁止 Write/Edit/Bash 写操作
247
+ ```
248
+
249
+ **Execution**:
250
+ 1. Orchestrator dispatches a Task subagent with `tools: [Read, Grep, Glob]`
251
+ 2. Subagent reviews all changed files (from `git diff` or slices-manifest scope)
252
+ 3. Subagent outputs review findings (issues, suggestions, risks)
253
+ 4. Orchestrator records findings to `.sprint-state/phase-outputs/blind-review-report.md`
254
+
255
+ **Classification**: 证据型标准步骤(非 HARD-GATE)— 执行并留存评审记录,不设程序化阻断。Worktree 本身已是隔离边界。
256
+
257
+ **Anti-Pattern**: Reviewer subagent MUST NOT have Write, Edit, or Bash permissions. This ensures the review is truly read-only and cannot accidentally modify code under review.
258
+
259
+ ---
260
+
261
+ ## Learnings Capture (v0.18.0+, 原生)
262
+
263
+ **Purpose**: Record patterns and lessons learned during BUILD for future sprints.
264
+
265
+ **Execution**: ralph-loop 迭代中或 BUILD 完成后,将有价值的模式/教训写入:
266
+
267
+ ```
268
+ .sprint-history/learnings.md
269
+ ```
270
+
271
+ **Format**:
272
+ ```markdown
273
+ ## [YYYY-MM-DD] Sprint <id> — BUILD Learnings
274
+
275
+ ### Pattern: <title>
276
+ - **Context**: <when this applies>
277
+ - **Insight**: <what was learned>
278
+ - **Action**: <how to apply in future>
279
+ ```
280
+
281
+ **Note**: 替代原 `gstack/learn` 调用,纯原生文件写入,零外部依赖。
282
+
283
+ ---
284
+
285
+ ## TDD 强制执行
286
+
287
+ ### Gate 5a-BLOCK: 新增文件测试强制
288
+
289
+ - **新增 `.ts/.tsx` 文件**必须有对应的测试文件(`*.test.ts`、`*.spec.ts`、`__tests__/` 目录),否则 **BLOCK** 提交
290
+ - **修改已有文件**仅触发 WARNING(不阻断)
291
+ - **Escape valve**: 非 main/master 分支可设置 `SKIP_GATE_5A_BLOCK=1` 跳过阻断(仅 WARNING)
292
+
293
+ ### Gate M2: Mock 密度阈值调整
294
+
295
+ - Mock 密度阈值从 50% 降低至 **30%**
296
+ - **Phase 1**: WARNING 模式(仅告警,不阻断)
297
+ - **Phase 2**: 将在基线分析后启用 BLOCK 模式
298
+ - 可通过 `.mockpolicyrc` 配置阈值和行为
299
+
300
+ ### Escape Valve
301
+
302
+ ```bash
303
+ # 非 main/master 分支临时跳过 Gate 5a-BLOCK
304
+ SKIP_GATE_5A_BLOCK=1 git commit -m "message"
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Timing & Stability
310
+
311
+ ### Expected Execution Times
312
+
313
+ | Step | Description | Expected Time | Timeout | On Timeout |
314
+ |------|-------------|--------------|---------|------------|
315
+ | DELPHI-GATE | Verify delphi-reviewed.json exists | 1-2s | 10s | BLOCK (critical gate) |
316
+ | ralph-loop (per REQ) | TDD + verification per requirement | 5-15 min | 30 min/REQ | Mark REQ as `timeout`, continue next REQ |
317
+ | parallel dispatch | Multi-agent parallel build | 10-30 min | 45 min | Collect partial results, continue |
318
+ | TDD cycle (per unit) | RED → GREEN → REFACTOR | 2-5 min | 10 min | Skip unit, log failure |
319
+ | blind-review (read-only subagent) | Code review via read-only subagent | 5-10 min | 20 min | WARNING, continue |
320
+ | verification | Test suite + coverage check | 2-5 min | 15 min | Retry once, then BLOCK |
321
+ | cost monitor | Token cost accounting | <1s | 5s | Skip, log warning |
322
+ | Phase 3/6 total (lightweight) | ≤3 REQs | 15-30 min | 45 min | — |
323
+ | Phase 3/6 total (standard) | 4-10 REQs | 30-120 min | 150 min | — |
324
+ | Phase 3/6 total (complex) | >10 REQs | 60-240 min | 300 min | — |
325
+
326
+ ### Stability Guidelines
327
+
328
+ 1. **Timeout handling**: All sub-steps MUST have explicit timeouts. If a step times out, log the failure to `.sprint-state/phase-outputs/phase-3-errors.json` and continue to the next step (except DELPHI-GATE which is a hard BLOCK).
329
+
330
+ 2. **Retry strategy**: For recoverable failures (verification, TDD cycle):
331
+ - First failure: log warning, retry once
332
+ - Second failure: log error, BLOCK and prompt user decision
333
+ - Do NOT retry more than twice for any single sub-step
334
+
335
+ 3. **Parallel dispatch stability**: When using `--mode parallel`, if any agent fails:
336
+ - Collect partial results from successful agents
337
+ - Rerun failed agent(s) individually with `--mode ralph-loop`
338
+ - Do NOT rerun the entire parallel batch
339
+
340
+ 4. **Cost monitor thresholds**:
341
+ - Token cost per REQ > 50,000 → WARNING (review REQ scope)
342
+ - Token cost per REQ > 100,000 → BLOCK (REQ too large, split into smaller units)
343
+
344
+ 5. **StdDev reduction**: To reduce execution timing variability:
345
+ - Cache dependency installation results between REQs
346
+ - Reuse TDD scaffolding across similar REQ types
347
+ - Pre-compute code structure analysis once at Phase start
348
+ - Batch lint/format operations at the end, not per REQ
@@ -0,0 +1,225 @@
1
+ # Phase 4/6: VERIFY(验证 — 代码走查 + 测试对齐 + 反馈获取)
2
+
3
+ **执行时机**: Phase 3/6 BUILD 完成后、Phase 5/6 SHIP 之前。
4
+ **对应旧模型**: Phase 3 REVIEW + Phase 4 FEEDBACK
5
+
6
+ ## 目标
7
+
8
+ 多专家代码走查、测试对齐(#367 程序化 HARD-GATE)、浏览器验证(Layer 4 可选链)、反馈捕获。确保 MVP 符合 specification 并记录经验教训。
9
+
10
+ **执行者**: orchestrator 直接执行 Part A(非 subagent dispatch — Issue #249)。
11
+
12
+ Web 前端项目额外增加:原生 UI 审查 + 可选增强。
13
+
14
+ ---
15
+
16
+ ## Part A: REVIEW + TEST(代码走查 + 测试对齐)
17
+
18
+ ### 调用 Skills
19
+
20
+ **所有项目(原生 HARD-GATE 链)**:
21
+ - `delphi-review --mode code-walkthrough` — 三位专家匿名代码走查,验证三个 distinct requested_model 并聚合 ≥90% consensus
22
+ - `test-specification-alignment` — 测试与 Spec 对齐验证(#367 程序化 HARD-GATE)
23
+ - `xp-gate check --all` — 全量质量门禁(Gate 0–9,含安全审计)
24
+
25
+ **浏览器验证 — Layer 4 可选链**:
26
+ ```
27
+ OPTIONAL: 若检测到 gstack browse 已安装 → 使用 gstack browse 进行浏览器自动化测试
28
+ ELSE IF 平台支持 browser-use MCP → 使用 browser-use MCP
29
+ ELSE → SKIP 并记录 "[sprint-flow] 浏览器验证 SKIP(无可用浏览器工具)"
30
+ ```
31
+
32
+ **Web 前端项目额外注入** (`--type web-nextjs` / `web-react` / `web-vue`):
33
+ - `xp-gate ui-review`(原生)— UI 视觉审查(间距、层级、一致性)
34
+ - OPTIONAL: 若检测到 gstack `qa` 已安装 → 三层 QA 系统化测试;未安装则 SKIP
35
+ - OPTIONAL: 若检测到 gstack `design-review` 已安装 → 视觉审计增强;未安装则 SKIP
36
+ - OPTIONAL: 若检测到 gstack `benchmark` 已安装 → Core Web Vitals 基线;未安装则 SKIP
37
+
38
+ **Mobile 项目额外注入** (`--type mobile-flutter` / `mobile-react-native`):
39
+ - `flutter-test` — Flutter 单元测试 + widget 测试 (Flutter only)
40
+ - Detox E2E — React Native 端到端测试 (RN only)
41
+
42
+ **Backend 项目额外注入** (`--type backend-go` / `backend-springboot` / `backend-django`):
43
+ - API Testing — 后端 API 自动化测试
44
+
45
+ ### 执行步骤
46
+
47
+ #### Step 1: 调用 delphi-review --mode code-walkthrough
48
+
49
+ ```
50
+ skill(name="delphi-review", user_message="--mode code-walkthrough")
51
+ ```
52
+
53
+ - architecture、technical、feasibility 三位专家匿名独立评审,模型 ID 必须 distinct
54
+ - Round 1: 三位专家独立执行,输出 `result_type=delphi_expert_result`
55
+ - 验证三份成功结果和三个 distinct requested_model 后再聚合
56
+ - 后续轮次最多到 Round 5,≥90% 共识 + APPROVED 才通过
57
+ - 任一失败或模型重复都阻断,不降级为少数专家
58
+
59
+ **如果 REQUEST_CHANGES**: 暂停等待用户处理 → 修复后重新评审。**如果 APPROVED**: 写入 `.code-walkthrough-result.json`(1 小时有效期)→ 进入 Step 2。
60
+
61
+ #### Step 2: 调用 test-specification-alignment(#367 程序化 HARD-GATE)
62
+
63
+ ```
64
+ skill(name="test-specification-alignment", user_message="--spec specification.yaml --tests mvp-v1/tests")
65
+ ```
66
+
67
+ Phase 1: 验证对齐(可修改测试) → Phase 2: 执行测试(禁止修改测试)
68
+
69
+ **#367 修复 — 程序化 HARD-GATE**:
70
+
71
+ test-specification-alignment 执行后**必须**输出 `.sprint-state/phase-outputs/test-alignment-report.json`:
72
+
73
+ ```json
74
+ {
75
+ "alignment_status": "PASS | FAIL",
76
+ "head_commit": "<git rev-parse HEAD>",
77
+ "spec_hash": "<SHA-256 of specification.yaml>",
78
+ "req_test_mapping": {},
79
+ "ac_assertion_mapping": {},
80
+ "timestamp": "<ISO 8601>"
81
+ }
82
+ ```
83
+
84
+ **`phase-transition 4 completed` 程序化校验**:
85
+ - 文件缺失 → BLOCK
86
+ - `alignment_status` 非 PASS → BLOCK
87
+ - `head_commit` 与当前 HEAD 不符 → BLOCK(防陈旧绑定)
88
+ - `spec_hash` 与当前 specification.yaml 不符 → BLOCK(防陈旧绑定)
89
+
90
+ **--skip-evidence 逃生口护栏**:
91
+ - `--skip-evidence` 必须同时提供 `--reason "<text>"`
92
+ - 每次使用写入 audit.jsonl(`event: evidence_skipped, reason, phase`)
93
+ - `xp-gate retro` 报告设曝光区块
94
+ - 单 sprint 使用 >2 次 → 告警
95
+
96
+ #### Step 2.5: 质量门禁全量验证
97
+
98
+ ```
99
+ npx xp-gate check --all
100
+ ```
101
+
102
+ 运行所有可用的质量门禁(Gate 0–9,含安全审计 Gate 7/8/9)并输出汇总报告。任何 BLOCK 状态 → 回退 Phase 3/6 修复。
103
+
104
+ > 此步骤自动调用各独立门禁(lint、复杂度、principles、架构、安全扫描等),无需手动逐个执行。替代原 `cso` 外部 skill 调用。
105
+
106
+ #### Step 2.5-2.10: 项目类型特定验证(Web/Mobile/Backend)
107
+
108
+ - **Web**: `xp-gate ui-review`(原生)→ OPTIONAL gstack qa/design-review/benchmark(如已安装)
109
+ - **Mobile**: flutter-test / detox E2E
110
+ - **Backend**: API automation tests
111
+
112
+ #### Step 3: 浏览器验证(Layer 4 可选链)
113
+
114
+ ```
115
+ OPTIONAL: 若检测到 gstack browse 已安装:
116
+ skill(name="browse", user_message="--url [URL] --test-ui")
117
+ ELSE IF 平台支持 browser-use MCP:
118
+ 使用 browser-use MCP 进行浏览器验证
119
+ ELSE:
120
+ SKIP 并记录 "[sprint-flow] 浏览器验证 SKIP(无可用浏览器工具)"
121
+ ```
122
+
123
+ 默认 URL: `localhost:3000`。发现问题 → 回退 Phase 3/6 修复。
124
+
125
+ #### Step 4: 保存 Review Report
126
+
127
+ 保存到 `<project-root>/.sprint-state/phase-outputs/review-report.md`
128
+
129
+ ### 暂停点
130
+
131
+ | 暂停点 | 触发条件 | 用户操作 |
132
+ |--------|---------|---------|
133
+ | delphi code-walkthrough REQUEST_CHANGES | Critical Issues 未修复 | 用户修复 → 重新评审 |
134
+ | test-alignment 失败 | 自动回退 Phase 3/6(不暂停) | 自动迭代 |
135
+ | 浏览器验证发现问题 | 自动回退 Phase 3/6(不暂停) | 自动迭代 |
136
+
137
+ ### 输出
138
+
139
+ - `.code-walkthrough-result.json`(pre-push hook 验证)
140
+ - `.sprint-state/phase-outputs/test-alignment-report.json`(#367 程序化 HARD-GATE 证据)
141
+ - Review Report (`review-report.md`)
142
+ - Web 前端附加: ui-review report + OPTIONAL QA/design-review/benchmark reports
143
+ - 验证通过的 MVP
144
+
145
+ ---
146
+
147
+ ## Part B: FEEDBACK CAPTURE(反馈获取)
148
+
149
+ ### 调用 Skills
150
+
151
+ **原生**:
152
+ - `learnings.md` 写入 — 模式记录(替代原 gstack `learn`)
153
+ - `xp-gate retro` — 工程回顾:提交历史、工作模式、代码质量趋势、返工率区块
154
+
155
+ **可选(Layer 4)**:
156
+ - OPTIONAL: 若检测到 `systematic-debugging` skill 已安装 → 根因调试(保留"无根因不修复"纪律);未安装则使用"根因分析后方可修复"文本纪律
157
+
158
+ ### 执行步骤
159
+
160
+ #### Step 1: Learnings 写入(原生)
161
+
162
+ 将 Sprint 中发现的模式/教训写入 `.sprint-history/learnings.md`:
163
+
164
+ ```markdown
165
+ ## [YYYY-MM-DD] Sprint <id> — VERIFY Learnings
166
+
167
+ ### Pattern: <title>
168
+ - **Context**: <when this applies>
169
+ - **Insight**: <what was learned>
170
+ - **Action**: <how to apply in future>
171
+ ```
172
+
173
+ #### Step 2: 工程回顾 — xp-gate retro(原生)
174
+
175
+ ```
176
+ npx xp-gate retro
177
+ ```
178
+
179
+ - 提交历史分析、代码质量趋势、改进建议
180
+ - 含 #369 返工率趋势区块
181
+ - 含 --skip-evidence 使用曝光区块
182
+
183
+ #### Step 3: 根因调试(可选 — Layer 4)
184
+
185
+ **IF Phase 6/6 CLOSE 发现 bug 或 Part A 验证失败**:
186
+
187
+ ```
188
+ OPTIONAL: 若检测到 systematic-debugging skill 已安装:
189
+ skill(name="systematic-debugging", user_message="[具体 bug 描述]")
190
+ ELSE:
191
+ 遵循"无根因不修复"文本纪律 — 先分析根因,确认后再修复
192
+ ```
193
+
194
+ Iron Law: 无调查 → 不修复
195
+
196
+ #### Step 4: 转化 Emergent Issues 为 Sprint 2 Pain Document
197
+
198
+ ```markdown
199
+ # Sprint 2 Pain Document
200
+
201
+ ## 来源:基于 Sprint 1 的 Emergent Issues
202
+
203
+ ## Critical Issues (自动进入 Sprint 2)
204
+ ## Major Issues (询问用户是否纳入)
205
+ ## Minor Issues (可选纳入)
206
+ ```
207
+
208
+ #### Step 5: 保存 Feedback Log
209
+
210
+ 保存到:
211
+ - `<project-root>/.sprint-state/phase-outputs/feedback-log.md`
212
+ - `<project-root>/.sprint-state/phase-outputs/sprint2-pain.md` (如有 emergent issues)
213
+
214
+ ### 暂停点
215
+
216
+ **无** — Part B 完成后自动进入 Phase 5/6 SHIP
217
+
218
+ **HARD-GATE**: feedback-log.md must exist before Phase 5/6 SHIP
219
+
220
+ ### 输出
221
+
222
+ - Feedback Log (`feedback-log.md`)
223
+ - Retro Report(`xp-gate retro` 输出)
224
+ - Sprint 2 Pain Document (`sprint2-pain.md`) — 如果有 emergent issues
225
+ - 进入 Phase 5/6 SHIP 自动执行