@boyingliu01/xp-gate 0.19.2 → 0.20.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 (223) hide show
  1. package/adapters/gate-4.sh +83 -18
  2. package/adapters/gate-8.sh +49 -5
  3. package/adapters/iac.sh +1 -1
  4. package/adapters/typescript.sh +15 -60
  5. package/bin/xp-gate.js +15 -16
  6. package/gate-10.sh +35 -2
  7. package/gate-4.sh +110 -21
  8. package/gate-8.sh +49 -5
  9. package/hooks/gate-10.sh +35 -2
  10. package/hooks/gate-4.sh +110 -21
  11. package/hooks/gate-8.sh +49 -5
  12. package/hooks/lib/jscpd-run.sh +63 -0
  13. package/hooks/lib/sprint-gate-report.sh +58 -0
  14. package/hooks/lib/test-failure.sh +152 -0
  15. package/hooks/lib/typecheck.sh +141 -0
  16. package/hooks/lib/validate-code-walkthrough.cjs +43 -5
  17. package/hooks/post-merge +100 -0
  18. package/hooks/pre-commit +401 -155
  19. package/hooks/pre-push +75 -19
  20. package/lib/__tests__/bootstrap.test.js +23 -41
  21. package/lib/__tests__/check-version.test.js +8 -1
  22. package/lib/__tests__/detect-deps.test.js +16 -0
  23. package/lib/__tests__/doctor-drift-round2.test.js +212 -0
  24. package/lib/__tests__/doctor-executed-surface.test.js +209 -0
  25. package/lib/__tests__/doctor-hook-drift.test.js +329 -0
  26. package/lib/__tests__/doctor-machine-mutation.test.js +116 -0
  27. package/lib/__tests__/doctor-module-drift.test.js +206 -0
  28. package/lib/__tests__/doctor-module-resolution-parity.test.js +314 -0
  29. package/lib/__tests__/doctor-path-equivalence.test.js +59 -0
  30. package/lib/__tests__/doctor-repair-boundary.test.js +52 -0
  31. package/lib/__tests__/doctor-tui-skill-freshness.test.js +105 -0
  32. package/lib/__tests__/doctor.test.js +155 -0
  33. package/lib/__tests__/gate-runner.test.js +19 -3
  34. package/lib/__tests__/helpers/lib-sandbox.cjs +55 -0
  35. package/lib/__tests__/init.test.js +44 -17
  36. package/lib/__tests__/install-skill-full-dir.test.js +151 -0
  37. package/lib/__tests__/install-skill.test.js +51 -132
  38. package/lib/__tests__/language-tools-detect.test.js +158 -0
  39. package/lib/__tests__/phase-transition.test.js +15 -1
  40. package/lib/__tests__/qoder-delphi-agents.test.js +285 -0
  41. package/lib/__tests__/shared-paths.test.js +20 -0
  42. package/lib/__tests__/shared-utils.test.js +69 -0
  43. package/lib/__tests__/skill-flags.test.js +48 -0
  44. package/lib/__tests__/ui-detector.test.ts +6 -2
  45. package/lib/__tests__/uninstall.test.js +20 -0
  46. package/lib/__tests__/update-hooks.test.js +12 -0
  47. package/lib/__tests__/update-skill.test.js +7 -4
  48. package/lib/detect-deps.js +3 -20
  49. package/lib/doctor-tui.js +22 -5
  50. package/lib/doctor.js +1178 -31
  51. package/lib/init.js +184 -33
  52. package/lib/install-cmd.js +7 -4
  53. package/lib/install-skill.js +38 -95
  54. package/lib/language-tools.js +83 -4
  55. package/lib/mattpocock-license-verdict.json +1 -1
  56. package/lib/shared-paths.js +5 -2
  57. package/lib/shared-utils.js +47 -3
  58. package/lib/uninstall.js +12 -0
  59. package/lib/update-hooks.js +4 -4
  60. package/lib/update-skill.js +6 -7
  61. package/mock-policy/AGENTS.md +4 -4
  62. package/mutation/AGENTS.md +4 -4
  63. package/mutation/__tests__/gate-m.test.ts +66 -14
  64. package/mutation/__tests__/mutmut-runner.test.ts +91 -42
  65. package/mutation/__tests__/test-filter-parity.test.ts +37 -0
  66. package/mutation/gate-m.ts +21 -8
  67. package/package.json +1 -1
  68. package/plugins/claude-code/.claude-plugin/plugin.json +2 -2
  69. package/plugins/claude-code/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  70. package/plugins/claude-code/skills/delphi-review/AGENTS.md +4 -4
  71. package/plugins/claude-code/skills/delphi-review/SKILL.md +98 -14
  72. package/plugins/claude-code/skills/delphi-review/references/code-walkthrough.md +36 -3
  73. package/plugins/claude-code/skills/delphi-review/references/requirements.md +6 -6
  74. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +4 -4
  75. package/plugins/claude-code/skills/sprint-flow/references/phase-2-design.md +3 -3
  76. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +4 -4
  77. package/plugins/dsh/README.md +169 -4
  78. package/plugins/dsh/dsh-overlay.patch.yml +67 -0
  79. package/plugins/dsh/package.json +1 -1
  80. package/plugins/dsh/scripts/prepack.cjs +24 -19
  81. package/plugins/dsh/setup-dsh.ps1 +160 -0
  82. package/plugins/dsh/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  83. package/plugins/dsh/skills/delphi-review/AGENTS.md +4 -4
  84. package/plugins/dsh/skills/delphi-review/SKILL.md +98 -14
  85. package/plugins/dsh/skills/delphi-review/references/code-walkthrough.md +36 -3
  86. package/plugins/dsh/skills/delphi-review/references/requirements.md +6 -6
  87. package/plugins/dsh/skills/sprint-flow/AGENTS.md +4 -4
  88. package/plugins/dsh/skills/sprint-flow/references/phase-2-design.md +3 -3
  89. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +4 -4
  90. package/plugins/dsh/src/command.test.ts +66 -2
  91. package/plugins/dsh/src/command.ts +36 -14
  92. package/plugins/dsh/src/contract.test.ts +31 -1
  93. package/plugins/dsh/src/delphi-config.test.ts +190 -0
  94. package/plugins/dsh/src/delphi-config.ts +223 -0
  95. package/plugins/dsh/src/delphi-run.test.ts +181 -0
  96. package/plugins/dsh/src/delphi-run.ts +129 -0
  97. package/plugins/dsh/src/delphi.test.ts +222 -0
  98. package/plugins/dsh/src/delphi.ts +247 -0
  99. package/plugins/dsh/src/dialect.test.ts +59 -0
  100. package/plugins/dsh/src/dialect.ts +40 -0
  101. package/plugins/dsh/src/index.ts +70 -4
  102. package/plugins/dsh/src/skills.test.ts +26 -19
  103. package/plugins/opencode/package.json +1 -1
  104. package/plugins/opencode/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  105. package/plugins/opencode/skills/delphi-review/AGENTS.md +4 -4
  106. package/plugins/opencode/skills/delphi-review/SKILL.md +98 -14
  107. package/plugins/opencode/skills/delphi-review/references/code-walkthrough.md +36 -3
  108. package/plugins/opencode/skills/delphi-review/references/requirements.md +6 -6
  109. package/plugins/opencode/skills/sprint-flow/AGENTS.md +4 -4
  110. package/plugins/opencode/skills/sprint-flow/references/phase-2-design.md +3 -3
  111. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +4 -4
  112. package/plugins/qoder/agents/delphi-architecture.md +1 -1
  113. package/plugins/qoder/agents/delphi-feasibility.md +1 -1
  114. package/plugins/qoder/agents/delphi-technical.md +1 -1
  115. package/plugins/qoder/plugin.json +2 -2
  116. package/plugins/qoder/skills/admin-template-guidelines/SKILL.md +6 -797
  117. package/plugins/qoder/skills/admin-template-guidelines/references/rule-1.md +91 -0
  118. package/plugins/qoder/skills/admin-template-guidelines/references/rule-2.md +155 -0
  119. package/plugins/qoder/skills/admin-template-guidelines/references/rule-3.md +70 -0
  120. package/plugins/qoder/skills/admin-template-guidelines/references/rule-4.md +154 -0
  121. package/plugins/qoder/skills/admin-template-guidelines/references/rule-5.md +126 -0
  122. package/plugins/qoder/skills/admin-template-guidelines/references/rule-6.md +180 -0
  123. package/plugins/qoder/skills/batch-grill-me/SKILL.md +15 -0
  124. package/plugins/qoder/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  125. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.ps1 +115 -0
  126. package/plugins/qoder/skills/clipboard-vision/describe-clipboard.sh +161 -0
  127. package/plugins/qoder/skills/delphi-review/.delphi-config.json.example +61 -28
  128. package/plugins/qoder/skills/delphi-review/AGENTS.md +4 -4
  129. package/plugins/qoder/skills/delphi-review/INSTALL.md +97 -98
  130. package/plugins/qoder/skills/delphi-review/SKILL.md +170 -63
  131. package/plugins/qoder/skills/delphi-review/hooks.md +19 -0
  132. package/plugins/qoder/skills/delphi-review/opencode.json.delphi.example +6 -10
  133. package/plugins/qoder/skills/delphi-review/references/code-walkthrough.md +36 -3
  134. package/plugins/qoder/skills/delphi-review/references/orchestrator-dispatch.md +64 -0
  135. package/plugins/qoder/skills/delphi-review/references/requirements.md +402 -0
  136. package/plugins/qoder/skills/delphi-review/references/round-templates.md +134 -0
  137. package/plugins/qoder/skills/delphi-review/scripts/verify-consensus.sh +43 -0
  138. package/plugins/qoder/skills/delphi-review/tools.md +29 -0
  139. package/plugins/qoder/skills/domain-modeling/ADR-FORMAT.md +64 -0
  140. package/plugins/qoder/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  141. package/plugins/qoder/skills/domain-modeling/SKILL.md +74 -0
  142. package/plugins/qoder/skills/grill-with-docs/SKILL.md +7 -0
  143. package/plugins/qoder/skills/grilling/SKILL.md +12 -0
  144. package/plugins/qoder/skills/ralph-loop/SKILL.md +87 -428
  145. package/plugins/qoder/skills/ralph-loop/references/components.md +113 -0
  146. package/plugins/qoder/skills/ralph-loop/references/workflow-details.md +99 -0
  147. package/plugins/qoder/skills/sprint-flow/AGENTS.md +5 -5
  148. package/plugins/qoder/skills/sprint-flow/SKILL.md +255 -454
  149. package/plugins/qoder/skills/sprint-flow/__tests__/sprint-flow.test.cjs +457 -0
  150. package/plugins/qoder/skills/sprint-flow/hooks.md +18 -0
  151. package/plugins/qoder/skills/sprint-flow/references/components/memory.md +1 -1
  152. package/plugins/qoder/skills/sprint-flow/references/components/middleware.md +1 -1
  153. package/plugins/qoder/skills/sprint-flow/references/components/skill-invocations.md +21 -20
  154. package/plugins/qoder/skills/sprint-flow/references/components/tool-descriptions.md +22 -23
  155. package/plugins/qoder/skills/sprint-flow/references/force-levels.md +0 -1
  156. package/plugins/qoder/skills/sprint-flow/references/orchestration-rules.md +34 -27
  157. package/plugins/qoder/skills/sprint-flow/references/phase-1-prep.md +1 -1
  158. package/plugins/qoder/skills/sprint-flow/references/phase-2-design.md +160 -123
  159. package/plugins/qoder/skills/sprint-flow/references/phase-3-build.md +203 -2
  160. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +107 -34
  161. package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +194 -12
  162. package/plugins/qoder/skills/sprint-flow/references/phase-6-close.md +139 -7
  163. package/plugins/qoder/skills/sprint-flow/references/phase-overview.md +486 -0
  164. package/plugins/qoder/skills/sprint-flow/scripts/verify-sprint-state.sh +38 -0
  165. package/plugins/qoder/skills/sprint-flow/tools.md +29 -0
  166. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +4 -4
  167. package/plugins/qoder/skills/test-specification-alignment/SKILL.md +104 -601
  168. package/plugins/qoder/skills/to-issues/SKILL.md +1 -1
  169. package/principles/AGENTS.md +9 -8
  170. package/principles/__tests__/adapter-metrics.test.ts +292 -0
  171. package/principles/__tests__/analyzer.test.ts +29 -6
  172. package/principles/__tests__/baseline-prune-timeout.test.ts +71 -0
  173. package/principles/__tests__/baseline-prune.test.ts +338 -0
  174. package/principles/__tests__/boy-scout-init-baseline.test.ts +167 -0
  175. package/principles/__tests__/boy-scout-integration.test.ts +97 -6
  176. package/principles/__tests__/boy-scout.test.ts +253 -7
  177. package/principles/__tests__/config-enforcement.test.ts +469 -0
  178. package/principles/__tests__/config-git-timeout.test.ts +66 -0
  179. package/principles/__tests__/direct-execution.test.ts +187 -0
  180. package/principles/__tests__/index.test.ts +16 -3
  181. package/principles/__tests__/warnings-baseline-budgets.test.ts +74 -0
  182. package/principles/adapters/typescript.ts +613 -13
  183. package/principles/analyzer.ts +22 -0
  184. package/principles/baseline-prune.ts +217 -0
  185. package/principles/boy-scout.ts +481 -51
  186. package/principles/config.ts +362 -54
  187. package/principles/direct-execution.ts +60 -0
  188. package/principles/index.ts +40 -17
  189. package/principles/rules/__tests__/clean-code/many-exports.test.ts +16 -10
  190. package/principles/rules/clean-code/code-duplication.ts +8 -8
  191. package/principles/rules/clean-code/deep-nesting.ts +8 -8
  192. package/principles/rules/clean-code/god-class.ts +8 -8
  193. package/principles/rules/clean-code/large-file.ts +15 -11
  194. package/principles/rules/clean-code/long-function.ts +8 -8
  195. package/principles/rules/clean-code/magic-numbers.ts +10 -7
  196. package/principles/rules/clean-code/many-exports.ts +7 -7
  197. package/principles/rules/clean-code/missing-error-handling.ts +5 -5
  198. package/principles/rules/clean-code/too-many-params.ts +8 -8
  199. package/principles/rules/clean-code/unused-imports.ts +5 -5
  200. package/principles/rules/solid/dip.ts +18 -8
  201. package/principles/rules/solid/isp.ts +9 -8
  202. package/principles/rules/solid/lsp.ts +6 -6
  203. package/principles/rules/solid/ocp.ts +6 -5
  204. package/principles/rules/solid/srp.ts +7 -8
  205. package/principles/types.ts +15 -0
  206. package/scripts/__tests__/sync-package-content.test.js +28 -0
  207. package/scripts/delphi-external-review.cjs +193 -10
  208. package/scripts/sync-package-content.js +7 -4
  209. package/skills/clipboard-vision/__tests__/clipboard-vision-distribution.test.cjs +0 -1
  210. package/skills/delphi-review/AGENTS.md +4 -4
  211. package/skills/delphi-review/SKILL.md +98 -14
  212. package/skills/delphi-review/references/code-walkthrough.md +36 -3
  213. package/skills/delphi-review/references/requirements.md +6 -6
  214. package/skills/sprint-flow/AGENTS.md +4 -4
  215. package/skills/sprint-flow/references/phase-2-design.md +3 -3
  216. package/skills/test-specification-alignment/AGENTS.md +4 -4
  217. package/lib/__tests__/download-skill.test.js +0 -281
  218. package/lib/download-skill.js +0 -96
  219. package/plugins/qoder/skills/ralph-loop/references/components/memory.md +0 -55
  220. package/plugins/qoder/skills/ralph-loop/references/components/middleware.md +0 -54
  221. package/plugins/qoder/skills/ralph-loop/references/components/skill-invocations.md +0 -39
  222. package/plugins/qoder/skills/ralph-loop/references/components/system-prompt.md +0 -24
  223. package/plugins/qoder/skills/ralph-loop/references/components/tool-descriptions.md +0 -32
@@ -0,0 +1,19 @@
1
+ # Hooks — Delphi Review
2
+
3
+ Delphi Review integrates with safety and operational hooks to ensure review integrity
4
+ and context preservation.
5
+
6
+ ## Security Hooks
7
+
8
+ | Hook | Purpose | Activation |
9
+ |------|---------|------------|
10
+ | `/careful` | Safety guardrails for destructive commands | Ensure review is read-only — block any destructive operations |
11
+ | `/freeze` | Restrict edits to review scope | Prevent accidental changes during review |
12
+ | `/guard` | Full safety mode (careful + freeze) | Maximum protection — read-only review with no accidental edits |
13
+
14
+ ## Operational Hooks
15
+
16
+ | Hook | Purpose | Activation |
17
+ |------|---------|------------|
18
+ | `/context-save` | Save review context before pause or handoff | Before pausing review or switching tasks |
19
+ | `/context-restore` | Restore review context on resume | When resuming review from pause or handoff |
@@ -3,23 +3,19 @@
3
3
  "Delphi Review Agent Configuration Template",
4
4
  "===========================================",
5
5
  "Copy the relevant 'agent' block below into your opencode.json.",
6
- "Replace YOUR_PROVIDER/YOUR_MODEL with your actual provider and model names.",
7
- "All 3 agents must use distinct trimmed executable model IDs; providers may be shared."
6
+ "Replace the example model IDs with three callable IDs available through your configured provider.",
7
+ "The three model fields must be different after trimming; providers may be shared."
8
8
  ],
9
9
 
10
10
  "$example_providers": {
11
- "OpenAI": "openai/gpt-4o",
12
- "Anthropic": "anthropic/claude-sonnet-4-20250514",
13
- "Ali_Bailian": "bailian-coding-plan/qwen3.6-plus",
14
- "Google_Gemini": "google/gemini-2.5-pro",
15
- "DeepSeek": "deepseek/deepseek-chat"
11
+ "SharedProviderExample": "bailian-tp/qwen-plus"
16
12
  },
17
13
 
18
14
  "agent": {
19
15
  "delphi-reviewer-architecture": {
20
16
  "description": "Delphi expert reviewer for architecture perspective. Focuses on requirements alignment, system design, and high-level coherence.",
21
17
  "mode": "subagent",
22
- "model": "YOUR_PROVIDER/YOUR_MODEL_A",
18
+ "model": "bailian-tp/qwen-plus",
23
19
  "prompt": "You are a Delphi expert reviewer specializing in architecture and requirements alignment. Review the input for: 1) Alignment with stated goals 2) Architectural coherence 3) System-level implications 4) Trade-offs and alternatives. Output structured review with verdict (APPROVED/REQUEST_CHANGES/REJECTED) and confidence level.",
24
20
  "tools": {
25
21
  "read": true,
@@ -31,7 +27,7 @@
31
27
  "delphi-reviewer-technical": {
32
28
  "description": "Delphi expert reviewer for technical depth. Focuses on implementation details, code correctness, and edge cases. Used in delphi-review.",
33
29
  "mode": "subagent",
34
- "model": "YOUR_PROVIDER/YOUR_MODEL_B",
30
+ "model": "bailian-tp/deepseek-v3",
35
31
  "prompt": "You are a Delphi expert reviewer specializing in technical implementation. Review the input for: 1) Implementation correctness 2) Code quality and patterns 3) Edge cases and error handling 4) Performance implications. Output structured review with verdict (APPROVED/REQUEST_CHANGES/REJECTED) and confidence level.",
36
32
  "tools": {
37
33
  "read": true,
@@ -43,7 +39,7 @@
43
39
  "delphi-reviewer-feasibility": {
44
40
  "description": "Delphi expert reviewer for feasibility analysis. Focuses on practical constraints, risks, and execution viability. Used in delphi-review.",
45
41
  "mode": "subagent",
46
- "model": "YOUR_PROVIDER/YOUR_MODEL_C",
42
+ "model": "bailian-tp/glm-4.5",
47
43
  "prompt": "You are a Delphi expert reviewer specializing in feasibility and risk analysis. Review the input for: 1) Practical constraints (time, resources, dependencies) 2) Risk identification and mitigation 3) Execution complexity 4) Alternative approaches. Output structured review with verdict (APPROVED/REQUEST_CHANGES/REJECTED) and confidence level.",
48
44
  "tools": {
49
45
  "read": true,
@@ -255,9 +255,15 @@ pre-push hook
255
255
  |------|------|------|
256
256
  | 单次走查成本 | ~$0.03 | 正常执行 |
257
257
  | 变更规模 | 无硬性文件数或行数上限 | 大型变更必须完整评审或由用户选择拆分 |
258
+ | 单席位 prompt 体积 | 默认 40000 字节(`max_prompt_bytes` 可按席位覆盖) | runner 发送前拒绝,报错里给出处置办法 |
258
259
 
259
260
  大型变更没有自动跳过或绕过路径。用户可以选择完整评审,或在评审前主动拆分变更;每个变更仍须通过完整的走查和证据验证。
260
261
 
262
+ **prompt 预算是硬约束,不是建议**:实测 `g-glm-5.3-flash` 在 ~40KB 正常应答(225s)、~50KB 直接崩溃
263
+ (305s,`0xC0000409` + libuv `UV_HANDLE_CLOSING`,表现为 "Network error.")——一个席位崩溃就会让整个共识无法完成。
264
+ 构造输入时按重要性排序、给每个席位独立预算、并在报告里显式列出因体积省略的文件;
265
+ 截断到「核心 hunk 看不见」比超限更糟:席位会花整轮报告「无法审计」,而这是评审者的真实缺陷而非代码缺陷。
266
+
261
267
  ---
262
268
 
263
269
  ## Agent 可用性检查 (MANDATORY)
@@ -356,9 +362,9 @@ IF 任何检查失败:
356
362
  "verdict": "APPROVED",
357
363
  "confidence": 9,
358
364
  "experts": [
359
- { "id": "Expert A", "role": "architecture", "verdict": "APPROVED", "confidence": 9, "result_type": "delphi_expert_result", "requested_model": "provider/model-a", "resolved_model": "provider/model-a" },
360
- { "id": "Expert B", "role": "technical", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-b", "resolved_model": null },
361
- { "id": "Expert C", "role": "feasibility", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-c", "resolved_model": "provider/model-c" }
365
+ { "id": "Expert A", "role": "architecture", "verdict": "APPROVED", "confidence": 9, "result_type": "delphi_expert_result", "requested_model": "provider/model-a", "resolved_model": "provider/model-a", "channel": "external" },
366
+ { "id": "Expert B", "role": "technical", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-b", "resolved_model": "provider/model-b", "channel": "external" },
367
+ { "id": "Expert C", "role": "feasibility", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-c", "resolved_model": "provider/model-c", "channel": "external" }
362
368
  ],
363
369
  "issues": [],
364
370
  "consensus_ratio": 1.0,
@@ -399,6 +405,33 @@ Hook 验证以下条件(全部满足才允许 push):
399
405
  5. timestamp 未过期
400
406
  6. expires 必须是 timestamp 之后恰好 1 小时
401
407
 
408
+ ### experts[] 必填字段与 #423 的迁移说明
409
+
410
+ `validate-code-walkthrough.cjs` 对每个 expert 对象强制要求:
411
+
412
+ | 字段 | 约束 |
413
+ |------|------|
414
+ | `result_type` | 必须等于 `"delphi_expert_result"` |
415
+ | `role` | 非空,三个席位 role 互异 |
416
+ | `requested_model` | 非空;比较前只做 trim,**区分大小写**(规范原文是 "distinct trimmed requested model IDs",见 AGENTS.md) |
417
+ | `resolved_model` | 非空;比较前 trim + 转小写,三者互异 |
418
+ | `channel` | 必须严格属于 `["external", "local"]`;`provider: local` 的 fallback 记录不能计为成功执行 |
419
+
420
+ 缺字段或取值不在白名单 → Gate MW **FAIL**(不是 SKIP)。
421
+
422
+ **升级后旧证据怎么处置**:唯一正确做法是在当前 HEAD 重跑一次评审、由 runner 重新生成证据文件。
423
+ 不要手工给老文件补 `channel` —— 那等于伪造执行证据,而 `channel` 存在的目的正是让证据可追溯到一次真实调用。
424
+ 证据本来就与 commit 绑定(`commit` 必须等于 HEAD,有效期 1 小时),跨 commit 复用从来不是受支持的路径。
425
+
426
+ **回滚语义**:validator 与证据生产者(`scripts/delphi-external-review.cjs`)必须成对回滚。
427
+
428
+ - 旧 validator 读新证据:安全,多余字段被忽略。
429
+ - 新 validator 读旧证据:必然 FAIL(缺 `channel`)。这是设计意图——宁可在发布关口停下,
430
+ 也不放行一份无法证明模型来源的证据;把「三个不同模型真的跑过」降级为可选项,等于让门禁只剩形式。
431
+ - 临时降级开关:**没有**。既没有 `XP_GATE_SKIP_MW` 之类的环境变量,也不允许 `--no-verify`
432
+ (见 `githooks/QUALITY-GATES-CODE-OF-CONDUCT.md`)。如果评审确实无法完成,处理方式是缩小
433
+ `--range` 或按席位调整 prompt 预算重跑,而不是放行。
434
+
402
435
  ---
403
436
 
404
437
  ## 与现有系统集成
@@ -0,0 +1,64 @@
1
+ # Orchestrator Dispatch Rules(#218 自动多轮调度)
2
+
3
+ ## 背景
4
+
5
+ Delphi review 在 sprint-flow 中通过 subagent 调用时,Round 1→Round 2→Round 3 的调度**必须在 subagent 内部自动完成**,不能每轮暂停等待 orchestrator 或用户干预。只有在以下情况才需要 orchestrator 暂停:
6
+
7
+ ## 自动调度规则
8
+
9
+ | 场景 | 自动处理 | 需暂停 |
10
+ |------|---------|--------|
11
+ | Round 1 完成,需 Round 2 | ✅ subagent 自动继续 | ❌ |
12
+ | Round 2 完成,需 Round 3 | ✅ subagent 自动继续 | ❌ |
13
+ | Round 3+ 完成,仍需更多轮 | ✅ subagent 自动继续,直到 max_rounds | ❌ |
14
+ | 最终 APPROVED (>=90%) | ✅ subagent 输出结果后退出 | ❌ |
15
+ | 最终 REQUEST_CHANGES(可自动修复) | ✅ subagent 尝试修复措辞、AC 缺失等常见问题后自动重评审 | ❌ |
16
+ | 最终 REQUEST_CHANGES(无法自动修复) | ✅ subagent 输出详细失败报告 | **✅ orchestrator 暂停等用户** |
17
+ | 超过 max_rounds (5) 仍无共识 | ✅ subagent 输出"未达成共识报告" | **✅ orchestrator 暂停等用户决策** |
18
+
19
+ ## Subagent 内部 Round 循环
20
+
21
+ 当 delphi-review 以 subagent 启动时(非交互式),应执行以下自动循环:
22
+
23
+ ```python
24
+ round = 1
25
+ while round <= max_review_rounds:
26
+ results = execute_round(round)
27
+ consensus = check_consensus(results)
28
+
29
+ if consensus.verdict == "APPROVED" and consensus.ratio >= 0.9:
30
+ emit_verdict("APPROVED", consensus)
31
+ break
32
+
33
+ if round == max_review_rounds:
34
+ emit_verdict("NO_CONSENSUS", consensus)
35
+ break
36
+
37
+ round += 1
38
+
39
+ if verdict == "REQUEST_CHANGES":
40
+ auto_fix_result = attempt_auto_fix(issues)
41
+ if auto_fix_result.success:
42
+ round = 2
43
+ continue
44
+ else:
45
+ emit_verdict("REQUEST_CHANGES", auto_fix_result.failed_issues)
46
+ ```
47
+
48
+ ## 终止结果输出
49
+
50
+ 当 subagent 因终态退出时,必须输出清晰的裁决:
51
+
52
+ - **APPROVED**: 共识报告 + specification.yaml
53
+ - **REQUEST_CHANGES(可自动修复)**: 自动修复后再次评审
54
+ - **REQUEST_CHANGES(不可自动修复)**: 失败报告 + 建议修复方向
55
+ - **NO_CONSENSUS**: 分歧详情报告
56
+
57
+ ## 与 orchestrator 的交互约定
58
+
59
+ | 状态 | Subagent 输出 | Orchestrator 动作 |
60
+ |------|--------------|------------------|
61
+ | APPROVED | `{verdict:"APPROVED", consensus_ratio: N, ...}` | 自动进入下一 Phase |
62
+ | REQUEST_CHANGES (auto-fixed) | `{verdict:"APPROVED", auto_fixed: ["..."]}` | 自动进入下一 Phase |
63
+ | REQUEST_CHANGES (unfixable) | `{verdict:"REQUEST_CHANGES", failed_issues: [...]}` | ⚠️ 暂停等用户修复后,通过 task_id 重新 dispatch |
64
+ | NO_CONSENSUS | `{verdict:"NO_CONSENSUS", disagreements: [...]}` | ⚠️ 暂停等用户决策(可继续/中止/强制通过) |
@@ -0,0 +1,402 @@
1
+ # Requirements Mode Reference
2
+
3
+ > Extracted from `SKILL.md`. This file contains ALL content specific to the `requirements` mode of Delphi Review.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ 需求评审模式,用于 grill-with-docs 完成共享理解后、设计文档生成前,对需求完整性进行轻量级多专家 Delphi 评审。
10
+
11
+ **触发命令**: `/delphi-review --mode requirements`
12
+
13
+ **设计背景**: Issue #368 识别出原始意图中"需求评审一次 + 设计评审一次"的第一次评审被完全丢弃。本模式恢复该评审点,在需求探索(grill-with-docs)与设计文档生成之间插入一道轻量质量门禁。
14
+
15
+ **定位**:
16
+ - **固定三专家**: architecture + technical + feasibility,最多 5 轮
17
+ - **需求焦点**: 评审对象是需求陈述 + CONTEXT.md,不是设计文档或代码
18
+ - **程序化阻塞**: 输出 `requirements-reviewed.json`,由 `phase-transition 2 completed` 校验
19
+ - **防陈旧绑定**: `requirements_hash`(SHA-256)绑定需求内容,防止旧证据复用
20
+
21
+ ---
22
+
23
+ ## Five Core Properties
24
+
25
+ 1. **匿名性** — Expert A/B/C 互不知道对方意见(Round 1)
26
+ 2. **迭代共识** — GAPS_FOUND 时回到 grill-with-docs 补充,最多 5 轮循环
27
+ 3. **关键缺口零容忍** — Critical requirement gaps 必须在进入设计前解决
28
+ 4. **防陈旧绑定** — requirements_hash 绑定需求内容 + CONTEXT.md,旧证据不可复用
29
+ 5. **执行可验证** — 三个专家都必须成功返回结构化结果,且 requested_model 三个 distinct
30
+
31
+ ---
32
+
33
+ ## 触发条件
34
+
35
+ - **自动触发**: sprint-flow Phase 2 THINK 链中,grill-with-docs 完成后、设计文档生成前(参见 `skills/sprint-flow/references/phase-2-design.md` Step 2)
36
+ - **手动触发**: `/delphi-review --mode requirements`
37
+
38
+ **⚠️ 重要调用方式说明**:
39
+
40
+ - ✅ **正确**: sprint-flow 编排层在 Phase 2 Step 2 自动调用
41
+ - ✅ **正确**: 在 Agent session 中执行 `/delphi-review --mode requirements`
42
+ - ❌ **错误**: 在设计文档已生成后调用(应在设计前)
43
+ - ❌ **错误**: 用 requirements 模式评审设计文档或代码(那是 design / code-walkthrough 模式的职责)
44
+
45
+ **与 sprint-flow 的集成**:
46
+
47
+ ```
48
+ sprint-flow Phase 2 THINK:
49
+ Step 0: CONTEXT.md 预检
50
+ Step 1: grill-with-docs(需求访谈)
51
+ Step 2: delphi-review --mode requirements ← 本模式
52
+ Step 3: 原生设计文档生成
53
+ Step 4: HARD-GATE(用户审批设计文档)
54
+ ```
55
+
56
+ 所有 Sprint 路径都执行 R1。Force level 只调整上下文深度和后续迭代预算,不跳过需求评审,也不减少三位专家执行。
57
+
58
+ ---
59
+
60
+ ## 流程概览
61
+
62
+ ```
63
+ grill-with-docs (completed)
64
+ │
65
+ ▼
66
+ delphi-review --mode requirements
67
+ │
68
+ ├─→ Context gather: CONTEXT.md + grill session summary + user requirements statement
69
+ │
70
+ ├─→ Expert A (architecture) anonymous review — focus: requirements completeness,
71
+ │ requirement→AC coverage, scenario coverage
72
+ │
73
+ ├─→ Expert B (technical) anonymous review — focus: technical clarity and edge cases
74
+ │
75
+ ├─→ Expert C (feasibility) anonymous review — focus: testability of acceptance criteria,
76
+ │ user persona clarity, scope boundaries
77
+ │
78
+ ├─→ Consensus check
79
+ │ │
80
+ │ ├─→ All three APPROVED → write requirements-reviewed.json verdict=APPROVED
81
+ │ │
82
+ │ └─→ Any GAPS_FOUND → record gaps, set verdict=GAPS_FOUND
83
+ │
84
+ └─→ Return to sprint-flow orchestrator
85
+ │
86
+ ├─→ APPROVED → proceed to design doc generation
87
+ └─→ GAPS_FOUND → loop back to grill-with-docs (up to 5 total rounds)
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 专家角色
93
+
94
+ | 专家 | 视角 | 配置 |
95
+ |------|------|------|
96
+ | Expert A (architecture) | 需求完整性 + 需求→AC 映射 + 场景覆盖 | `.delphi-config.json` → `experts.architecture` |
97
+ | Expert B (technical) | 技术清晰度 + 边界条件 + 实现约束 | `.delphi-config.json` → `experts.technical` |
98
+ | Expert C (feasibility) | AC 可测试性 + 用户画像 + 范围边界 | `.delphi-config.json` → `experts.feasibility` |
99
+
100
+ > 三个角色必须使用三个 distinct trimmed executable model IDs。Provider、vendor、gateway 和模型国籍均不受限制;一个 provider 和 token plan 可以服务全部三个角色。
101
+
102
+ **专家选择理由**:
103
+ - **architecture 专家**: 天然映射范围/覆盖到需求层面——需求完整性、需求→AC 映射、场景覆盖、领域术语一致性
104
+ - **feasibility 专家**: 天然映射可测试性/假设到验收标准——AC 可测试性、用户画像清晰度、范围边界、隐含假设
105
+ - **technical 专家**: 检查需求中的技术清晰度、边界条件和实现约束
106
+
107
+ ---
108
+
109
+ ## 评审焦点(模式切换指令)
110
+
111
+ ### Expert A (architecture) — 需求模式焦点
112
+
113
+ | 维度 | 检查内容 |
114
+ |------|---------|
115
+ | **需求完整性** | 所有用户场景是否已覆盖,是否有遗漏的用例路径 |
116
+ | **需求→AC 映射** | 每个需求是否有对应的验收标准,映射是否完整 |
117
+ | **场景覆盖** | 正常流、异常流、边界场景是否均已识别 |
118
+ | **领域术语一致性** | 需求陈述中的术语是否与 CONTEXT.md 领域模型一致(交叉引用) |
119
+ | **AC 精确度** | 验收标准是否具体、可度量、无歧义 |
120
+
121
+ ### Expert C (feasibility) — 需求模式焦点
122
+
123
+ | 维度 | 检查内容 |
124
+ |------|---------|
125
+ | **AC 可测试性** | 每个验收标准是否可被自动化或手动测试验证 |
126
+ | **用户画像清晰度** | 目标用户/角色是否明确定义,场景是否贴合真实使用 |
127
+ | **范围边界清晰度** | 需求边界(in-scope vs out-of-scope)是否明确划定 |
128
+ | **需求间依赖** | 需求之间是否存在隐含依赖或冲突 |
129
+ | **隐含假设** | 是否存在未明确声明的假设(技术、业务、环境) |
130
+
131
+ ---
132
+
133
+ ## 共识标准
134
+
135
+ | 条件 | 结果 |
136
+ |------|------|
137
+ | 3/3 successful APPROVED + 无 Critical gaps | ✅ verdict=APPROVED,进入设计文档生成 |
138
+ | 3/3 successful APPROVED + 有 Minor gaps | ✅ verdict=APPROVED(记录 gaps 供参考) |
139
+ | 任一专家失败或缺失 | ❌ BLOCK,不能聚合或降级 |
140
+ | 任一专家 GAPS_FOUND | ❌ verdict=GAPS_FOUND,记录 gaps |
141
+ | 有 Critical requirement gaps | ❌ verdict=GAPS_FOUND |
142
+
143
+ **共识要求**: 三个成功结果全部参与聚合,达到 >=90% 且最终 APPROVED。单个专家结果不能代表全局批准。
144
+
145
+ ---
146
+
147
+ ## 循环控制(Loop Semantics)
148
+
149
+ ```
150
+ Round 1: delphi-review --mode requirements
151
+ │
152
+ ├─→ APPROVED → 完成,进入设计文档生成
153
+ │
154
+ └─→ GAPS_FOUND
155
+ │
156
+ ├─→ gaps 记录到 requirements-reviewed.json
157
+ ├─→ 返回 sprint-flow → grill-with-docs 补充访谈
158
+ │
159
+ ▼
160
+ Round 2: delphi-review --mode requirements(带 Round 1 gaps 上下文)
161
+ │
162
+ ├─→ APPROVED → 完成,进入设计文档生成
163
+ │
164
+ └─→ GAPS_FOUND
165
+ │
166
+ └─→ escalation_needed: true
167
+ → sprint-flow Phase 2 处理升级 UX(交用户决策)
168
+ ```
169
+
170
+ **硬性限制**:
171
+ - **最多 5 轮**(Round 1 + 可选后续轮次)
172
+ - **禁止无界循环** — Round 5 后仍 GAPS_FOUND 必须升级
173
+ - **Round 2 上下文**: 专家看到 Round 1 的 gaps 列表,评估是否已修复
174
+ - **升级语义**: `escalation_needed: true` 写入 requirements-reviewed.json,sprint-flow 负责 UX
175
+
176
+ ---
177
+
178
+ ## 输出格式
179
+
180
+ ### 证据文件: `.sprint-state/phase-outputs/requirements-reviewed.json`
181
+
182
+ ```json
183
+ {
184
+ "mode": "requirements",
185
+ "verdict": "APPROVED",
186
+ "timestamp": "2026-07-25T10:30:00Z",
187
+ "consensus_ratio": 1.0,
188
+ "requirements_hash": "7f650ddf715ebe75ca0317efa1e8618ae39d2c0bafea7a6f85aacfdbf3735a5f",
189
+ "head_commit": "abc123def456789...",
190
+ "context_file_used": null,
191
+ "round": 1,
192
+ "expert_verdicts": [
193
+ { "role": "architecture", "verdict": "APPROVED", "confidence": 9, "result_type": "delphi_expert_result", "requested_model": "bailian-tp/qwen-plus", "resolved_model": "qwen-plus", "channel": "external" },
194
+ { "role": "technical", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "bailian-tp/deepseek-v3", "resolved_model": "deepseek-v3", "channel": "external" },
195
+ { "role": "feasibility", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "bailian-tp/glm-4.5", "resolved_model": "glm-4.5", "channel": "external" }
196
+ ],
197
+ "requirements_statement": "实现用户注册流程,支持邮箱验证和密码重置",
198
+ "gaps_found": [],
199
+ "rounds_used": 1,
200
+ "escalation_needed": false
201
+ }
202
+ ```
203
+
204
+ ### GAPS_FOUND 示例
205
+
206
+ ```json
207
+ {
208
+ "mode": "requirements",
209
+ "verdict": "GAPS_FOUND",
210
+ "timestamp": "2026-07-25T10:30:00Z",
211
+ "consensus_ratio": 0.67,
212
+ "requirements_hash": "7f650ddf715ebe75ca0317efa1e8618ae39d2c0bafea7a6f85aacfdbf3735a5f",
213
+ "head_commit": "abc123def456789...",
214
+ "context_file_used": null,
215
+ "round": 1,
216
+ "expert_verdicts": [
217
+ { "role": "architecture", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-a", "resolved_model": "provider/model-a", "channel": "external" },
218
+ { "role": "technical", "verdict": "GAPS_FOUND", "confidence": 7, "result_type": "delphi_expert_result", "requested_model": "provider/model-b", "resolved_model": "provider/model-b", "channel": "external" },
219
+ { "role": "feasibility", "verdict": "APPROVED", "confidence": 8, "result_type": "delphi_expert_result", "requested_model": "provider/model-c", "resolved_model": "provider/model-c", "channel": "external" }
220
+ ],
221
+ "requirements_statement": "实现用户注册流程,支持邮箱验证和密码重置",
222
+ "gaps_found": [
223
+ "密码重置的过期时间未定义",
224
+ "邮箱验证失败的重试策略缺失",
225
+ "AC-003 不可测试:'系统应快速响应' 无量化指标"
226
+ ],
227
+ "rounds_used": 1,
228
+ "escalation_needed": false
229
+ }
230
+ ```
231
+
232
+ ### 字段说明
233
+
234
+ | 字段 | 类型 | 说明 |
235
+ |------|------|------|
236
+ | `mode` | string | 固定值 `"requirements"` |
237
+ | `verdict` | string | `APPROVED` 或 `GAPS_FOUND` |
238
+ | `timestamp` | string | 评审完成时间 (ISO 8601 UTC) |
239
+ | `consensus_ratio` | number | 三位专家的共识比例;APPROVED 必须为 `0.90` 至 `1.0` |
240
+ | `requirements_hash` | string | SHA-256 hex digest(防陈旧绑定,见下文) |
241
+ | `head_commit` | string | 当前 `git rev-parse HEAD` |
242
+ | `context_file_used` | string \| null | 项目根目录内引用的 context 文件相对路径;未使用时为 `null` 或空字符串 |
243
+ | `round` | number | 当前轮次(1 至 5) |
244
+ | `expert_verdicts` | array | 三位专家的成功结构化结果,包含 `result_type` 和 `requested_model` |
245
+ | `requirements_statement` | string | 被评审需求的简短摘要 |
246
+ | `gaps_found` | array | GAPS_FOUND 时的缺口列表(APPROVED 时为空数组) |
247
+ | `rounds_used` | number | 实际使用的轮次数 |
248
+ | `escalation_needed` | boolean | Round 5 后仍 GAPS_FOUND 时为 `true` |
249
+
250
+ ### 状态文件: `.sprint-state/delphi-reviewed.json`
251
+
252
+ APPROVED 时同步写入状态文件(与 design / code-walkthrough 模式一致):
253
+
254
+ ```json
255
+ {
256
+ "mode": "requirements",
257
+ "timestamp": "2026-07-25T10:30:00Z",
258
+ "verdict": "APPROVED",
259
+ "consensus_ratio": 1.0
260
+ }
261
+ ```
262
+
263
+ > 此文件供 `verify-consensus.sh` 校验。GAPS_FOUND 时**不写入**此文件(评审未完成)。
264
+
265
+ ---
266
+
267
+ ## Hash 绑定(防陈旧绑定 — §8.4)
268
+
269
+ `requirements_hash` = SHA-256 of:
270
+
271
+ ```
272
+ requirements_statement + CONTEXT.md content + ISO timestamp prefix (YYYY-MM-DD)
273
+ ```
274
+
275
+ **计算规则**:
276
+ 1. 从 evidence `timestamp` 解析严格有效的 ISO 8601 UTC 时间,并取其 `YYYY-MM-DD` 前缀
277
+ 2. 若 `context_file_used` 非空,只允许项目根目录内的相对路径;拒绝绝对路径、`..` 穿越、缺失/非普通文件,以及 realpath 逃出项目根目录的符号链接
278
+ 3. 按 UTF-8 原样读取 context 文件,不添加分隔符或换行;拼接精确字符串 `requirements_statement + context content + YYYY-MM-DD`
279
+ 4. 对拼接结果计算 SHA-256;生成值使用 64 位小写 hex,校验时大小写不敏感
280
+ 5. 未使用 context 时,精确拼接 `requirements_statement + YYYY-MM-DD`
281
+
282
+ **目的**: 防止旧证据复用。`phase-transition 2 completed` 校验时:
283
+ - 文件必须存在
284
+ - `verdict` 必须为 `APPROVED`
285
+ - `requirements_hash` 必须为 64 位 hex,并与运行时重新计算值匹配
286
+ - 若 hash 与当前需求内容不匹配 → BLOCK(防陈旧绑定)
287
+
288
+ **与 phase-transition.js 的集成**:
289
+
290
+ ```javascript
291
+ // EVIDENCE_FILES[2] — 已存在于 phase-transition.js
292
+ {
293
+ path: '.sprint-state/phase-outputs/requirements-reviewed.json',
294
+ requiredFields: [
295
+ 'verdict', 'requirements_statement', 'timestamp', 'consensus_ratio',
296
+ 'expert_verdicts', 'head_commit', 'requirements_hash'
297
+ ],
298
+ blockingCheck: (data) => data.verdict === 'APPROVED',
299
+ blockingMessage: 'Requirements review verdict is not APPROVED',
300
+ }
301
+ ```
302
+
303
+ ---
304
+
305
+ ## 证据文件路径
306
+
307
+ | 文件 | 路径 | 校验时机 | 校验方 |
308
+ |------|------|----------|--------|
309
+ | requirements-reviewed.json | `.sprint-state/phase-outputs/` | `phase-transition 2 completed` | phase-transition.js Layer 2 |
310
+ | delphi-reviewed.json | `.sprint-state/` | verify-consensus.sh | verify-consensus.sh |
311
+
312
+ ---
313
+
314
+ ## Anti-Patterns
315
+
316
+ **只在 `--mode requirements` 时适用:**
317
+
318
+ | ❌ Don't | ✅ Do | Why |
319
+ |----------|------|-----|
320
+ | 使用少于 3 个专家 | 必须使用 architecture + technical + feasibility | 三个角色共同构成全局证据 |
321
+ | 无界循环评审 | 最多 5 轮,之后升级 | 防止无限循环 |
322
+ | 跳过 CONTEXT.md 交叉引用 | 始终交叉引用领域术语 | 需求应使用 CONTEXT.md 中的规范术语 |
323
+ | 输出泛化批准 | 输出 hash 绑定的需求陈述 | 防陈旧绑定(§8.4,Round 1 设计反馈 #14) |
324
+ | 接受单个专家批准 | 要求三份成功结果参与聚合,并达到 >=90% 共识 | 单个结果不能代表全局批准 |
325
+ | Round 2 中复用 Round 1 gaps 作为新发现 | Round 2 专家获得 Round 1 gaps 上下文 | 迭代改进,避免重复劳动 |
326
+ | 评审设计文档或代码 | 仅评审需求陈述 + CONTEXT.md | 设计/代码评审是 design / code-walkthrough 模式的职责 |
327
+ | GAPS_FOUND 时写入 delphi-reviewed.json | 仅 APPROVED 时写入状态文件 | GAPS_FOUND 表示评审未完成 |
328
+ | 在 lightweight sprint 中减少或跳过 R1 | 所有路径都执行三专家 R1,仅缩短上下文 | Force level 不改变专家数或批准证据 |
329
+
330
+ ---
331
+
332
+ ## Security Notes
333
+
334
+ - **只读评审**: requirements 模式不修改任何源文件,仅写入证据文件到 `.sprint-state/`
335
+ - **Hash 完整性**: `requirements_hash` 使用 SHA-256,防止需求内容被篡改后复用旧证据
336
+ - **Commit 绑定**: `head_commit` 记录评审时的 git HEAD,提供时间线追溯
337
+ - **调用边界**: 评审内容只传递给用户配置的 callable provider;provider、vendor、gateway 和模型国籍不作额外限制
338
+ - **证据不可伪造**: phase-transition.js 程序化校验证据文件,LLM 无法绕过
339
+
340
+ ---
341
+
342
+ ## Triggers / Negative Triggers
343
+
344
+ **触发(requirements 模式特有)**:
345
+ - `/delphi-review --mode requirements`
346
+ - "review the requirements"
347
+ - "评审需求"
348
+ - "requirements review"
349
+ - "/requirements-review"
350
+
351
+ **不触发**:
352
+ - "review my requirements document"(教育性讨论,非执行评审)
353
+ - "requirements template"(询问模板格式)
354
+ - "how to write requirements"(教育性)
355
+ - "check my requirements"(模糊,可能是 Casual 检查)
356
+
357
+ ---
358
+
359
+ ## Terminal State Checklist (requirements mode)
360
+
361
+ **Pre-requisites (MANDATORY - BLOCK if missing):**
362
+ - [ ] grill-with-docs 已完成(或 CONTEXT.md 快速路径)
363
+ - [ ] 需求陈述可用(非空)
364
+ - [ ] Expert A (architecture)、Expert B (technical)、Expert C (feasibility) 均成功执行
365
+ - [ ] 三个 `requested_model` trimmed 后 distinct
366
+ - [ ] 三份结果均为 `result_type=delphi_expert_result`
367
+
368
+ **CRITICAL - 共识验证 (requirements):**
369
+ - [ ] 聚合共识 >=90%,且所有 Critical gaps 已处理
370
+ - [ ] 无 Critical requirement gaps 未解决
371
+ - [ ] requirements_hash 已计算并写入
372
+
373
+ **Final Requirements (requirements):**
374
+ - [ ] `.sprint-state/phase-outputs/requirements-reviewed.json` 已写入
375
+ - [ ] JSON 格式有效,包含所有必需字段
376
+ - [ ] verdict 为 APPROVED 或 GAPS_FOUND
377
+ - [ ] IF APPROVED: `.sprint-state/delphi-reviewed.json` 已写入(mode=requirements)
378
+ - [ ] IF GAPS_FOUND: gaps_found 数组非空,escalation_needed 正确设置
379
+ - [ ] IF Round 5 后仍 GAPS_FOUND: escalation_needed = true
380
+
381
+ **IF 任何 Pre-requisite 缺失:**
382
+ - **CANNOT 完成评审**
383
+ - **MUST BLOCK 并通知用户**
384
+
385
+ **IF GAPS_FOUND (Round 1):**
386
+ - 返回 sprint-flow → grill-with-docs 补充
387
+ - 重新执行 requirements 评审(Round 2)
388
+
389
+ **IF GAPS_FOUND (Round 5):**
390
+ - **escalation_needed = true**
391
+ - **MUST 升级给用户决策**
392
+ - **CANNOT 自动继续**
393
+
394
+ **⭐ APPROVED 后必做 (requirements mode):写入证据文件**
395
+
396
+ IF mode == `requirements` AND 最终裁决是 APPROVED,评审完成后必须:
397
+
398
+ 1. 写入 `.sprint-state/phase-outputs/requirements-reviewed.json`
399
+ 2. 写入 `.sprint-state/delphi-reviewed.json`(状态文件)
400
+ 3. 验证 JSON 格式有效
401
+ 4. 验证 requirements_hash 为 64 位 hex 且运行时重新计算匹配
402
+ 5. 验证 head_commit 匹配当前 HEAD