@boyingliu01/xp-gate 0.35.17 → 0.35.18

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 (67) hide show
  1. package/gate-12-file-hygiene.sh +26 -4
  2. package/gate-13-compiler-strictness.sh +12 -0
  3. package/gates/gate-3.ts +77 -21
  4. package/gates/gate-8.ts +39 -26
  5. package/gates/gate-9.ts +4 -4
  6. package/hooks/gate-12-file-hygiene.sh +26 -4
  7. package/hooks/gate-13-compiler-strictness.sh +12 -0
  8. package/hooks/pre-commit +75 -11
  9. package/hooks/pre-push +11 -2
  10. package/lib/__tests__/doctor.test.js +9 -0
  11. package/lib/__tests__/gate-numbering.test.js +52 -0
  12. package/lib/__tests__/gate-runner.test.js +59 -14
  13. package/lib/__tests__/shared-utils.test.js +47 -0
  14. package/lib/gate-runner.js +98 -18
  15. package/lib/mattpocock-license-verdict.json +1 -1
  16. package/lib/shared-utils.js +27 -1
  17. package/mock-policy/AGENTS.md +2 -2
  18. package/mutation/AGENTS.md +2 -2
  19. package/package.json +1 -1
  20. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  21. package/plugins/claude-code/skills/delphi-review/AGENTS.md +2 -2
  22. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +2 -2
  23. package/plugins/claude-code/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  24. package/plugins/claude-code/skills/sprint-flow/references/definition-of-done.md +47 -0
  25. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +16 -0
  26. package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +14 -0
  27. package/plugins/claude-code/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  28. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +2 -2
  29. package/plugins/dsh/package.json +1 -1
  30. package/plugins/dsh/skills/delphi-review/AGENTS.md +2 -2
  31. package/plugins/dsh/skills/sprint-flow/AGENTS.md +2 -2
  32. package/plugins/dsh/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  33. package/plugins/dsh/skills/sprint-flow/references/definition-of-done.md +47 -0
  34. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +16 -0
  35. package/plugins/dsh/skills/sprint-flow/references/phase-5-ship.md +14 -0
  36. package/plugins/dsh/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  37. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +2 -2
  38. package/plugins/dsh/src/delphi-findings.test.ts +32 -6
  39. package/plugins/dsh/src/exit-code.test.ts +6 -0
  40. package/plugins/opencode/package.json +1 -1
  41. package/plugins/opencode/skills/delphi-review/AGENTS.md +2 -2
  42. package/plugins/opencode/skills/sprint-flow/AGENTS.md +2 -2
  43. package/plugins/opencode/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  44. package/plugins/opencode/skills/sprint-flow/references/definition-of-done.md +47 -0
  45. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +16 -0
  46. package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +14 -0
  47. package/plugins/opencode/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  48. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +2 -2
  49. package/plugins/qoder/plugin.json +1 -1
  50. package/plugins/qoder/skills/delphi-review/AGENTS.md +2 -2
  51. package/plugins/qoder/skills/sprint-flow/AGENTS.md +2 -2
  52. package/plugins/qoder/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  53. package/plugins/qoder/skills/sprint-flow/references/definition-of-done.md +47 -0
  54. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +16 -0
  55. package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +14 -0
  56. package/plugins/qoder/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  57. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +2 -2
  58. package/principles/AGENTS.md +2 -2
  59. package/scripts/__tests__/sync-package-content.test.js +114 -46
  60. package/skills/delphi-review/AGENTS.md +2 -2
  61. package/skills/sprint-flow/AGENTS.md +2 -2
  62. package/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  63. package/skills/sprint-flow/references/definition-of-done.md +47 -0
  64. package/skills/sprint-flow/references/phase-4-verify.md +16 -0
  65. package/skills/sprint-flow/references/phase-5-ship.md +14 -0
  66. package/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  67. package/skills/test-specification-alignment/AGENTS.md +2 -2
@@ -99,6 +99,20 @@ Sprint 分支已准备就绪。请选择操作:
99
99
 
100
100
  ### Step 2: 原生 Ship 步骤序列(选择 Option 2 时执行)
101
101
 
102
+ #### Step 2.0: 完成定义后半段(DoD 第 7–10 项,MANDATORY)
103
+
104
+ 推送前逐项过 [`definition-of-done.md`](./definition-of-done.md):
105
+
106
+ | # | 条目 | 在这里怎么查 |
107
+ |---|------|--------------|
108
+ | 7 | 不做未经要求的相邻改动 | `git diff` 逐行对照 REQ;顺手发现的无关问题只提及,不删改 |
109
+ | 8 | **已知限制已写明** | 没做的部分与原因写进提交说明或 issue,而不是留空 |
110
+ | 9 | 文档与实现一致 | 门禁数量/CLI 表/阈值等出现在多处的事实同步更新(`AGENTS.md` "Known Drift") |
111
+ | 10 | 可回滚 | 提交粒度单一,能单独 revert 而不牵连其他改动 |
112
+
113
+ 第 8 项最容易被跳过,也最容易造成误导:**一个没写下来的限制,下一个人会按"已完成"来依赖它。**
114
+
115
+
102
116
  ```
103
117
  1. 运行测试:
104
118
  npm test # 或项目特定测试命令
@@ -3,6 +3,12 @@
3
3
  # Checks that sprint-state.json is valid JSON and all expected keys exist.
4
4
  #
5
5
  # Usage: bash verify-sprint-state.sh [sprint-state-dir]
6
+ #
7
+ # The expected keys are the ones `xp-gate sprint-init` actually writes (#679).
8
+ # They were previously ['sprint_id','status','current_phase','phases'] -- a schema
9
+ # this project has never written, so the check failed on every sprint the CLI
10
+ # itself had just created. A verifier that rejects its own producer's output is
11
+ # worse than no verifier: it trains people to ignore it.
6
12
 
7
13
  set -euo pipefail
8
14
 
@@ -24,12 +30,19 @@ node -e "
24
30
  const fs = require('fs');
25
31
  try {
26
32
  const data = JSON.parse(fs.readFileSync('$STATE_FILE', 'utf8'));
27
- const requiredKeys = ['sprint_id', 'status', 'current_phase', 'phases'];
33
+ // These are the keys src/npm-package/lib/sprint-init.js writes.
34
+ const requiredKeys = ['id', 'task_description', 'phase', 'status'];
28
35
  const missing = requiredKeys.filter(k => !(k in data));
29
36
  if (missing.length > 0) {
30
37
  console.error('ERROR: Missing required keys in sprint-state.json:', missing.join(', '));
31
38
  process.exit(1);
32
39
  }
40
+ // phase_history is an array by construction; a non-array here means the file
41
+ // was hand-edited or written by a different tool, which is worth failing on.
42
+ if (!Array.isArray(data.phase_history)) {
43
+ console.error('ERROR: phase_history must be an array in sprint-state.json');
44
+ process.exit(1);
45
+ }
33
46
  console.log('OK: sprint-state.json is valid with all required keys');
34
47
  } catch (e) {
35
48
  console.error('ERROR: sprint-state.json is not valid JSON:', e.message);
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/dsh-plugin-xp-gate",
3
- "version": "0.35.17",
3
+ "version": "0.35.18",
4
4
  "description": "XP-Gate deterministic quality gates + AI workflow skills as a DeepSeek Harness (DSH) native plugin: gate-check / gate-principles / gate-arch tools + 12 SKILL.md skills",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bats
2
+ # @test REQ-688
3
+ # @intent 验证 sprint-flow 的校验脚本能接受 `xp-gate sprint-init` 自己写出的状态文件
4
+ # ——脚本曾要求 sprint_id/current_phase/phases 这套从未被写入过的键,
5
+ # 对 CLI 刚创建的 sprint 恒判失败(#679)
6
+ # @covers AC-688-01, AC-688-02
7
+ #
8
+ # 为什么用真 sprint-init 而不是手写一个 fixture:缺陷的本质是「校验方与生产方对
9
+ # schema 的认知不一致」。手写 fixture 会把「我认为 CLI 写什么」固化下来,双方一起
10
+ # 错就一起绿。只有让生产方真的产出、校验方真的读,才能发现这类偏差。
11
+
12
+ setup() {
13
+ REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../.." && pwd)"
14
+ VERIFY="$REPO_ROOT/skills/sprint-flow/scripts/verify-sprint-state.sh"
15
+ CLI="$REPO_ROOT/src/npm-package/bin/xp-gate.js"
16
+ WORK="$(mktemp -d)"
17
+ }
18
+
19
+ teardown() {
20
+ rm -rf "$WORK"
21
+ }
22
+
23
+ @test "AC-688-01: accepts state written by xp-gate sprint-init" {
24
+ cd "$WORK"
25
+ git init -q .
26
+ echo '{}' > package.json
27
+ git add -A
28
+ git -c user.email=t@t -c user.name=t commit -q -m init
29
+
30
+ run node "$CLI" sprint-init "probe task"
31
+ [ -f ".sprint-state/sprint-state.json" ]
32
+
33
+ run bash "$VERIFY"
34
+ [ "$status" -eq 0 ]
35
+ [[ "$output" == *"OK:"* ]]
36
+ }
37
+
38
+ @test "AC-688-02: still rejects a state file missing real keys" {
39
+ # The fix must not become "accept anything": a file that lost its task or its
40
+ # phase is genuinely broken and the verifier should say so.
41
+ mkdir -p "$WORK/.sprint-state"
42
+ printf '{"id":"s-1","phase":"BUILD"}\n' > "$WORK/.sprint-state/sprint-state.json"
43
+
44
+ cd "$WORK"
45
+ run bash "$VERIFY"
46
+ [ "$status" -eq 1 ]
47
+ [[ "$output" == *"task_description"* ]]
48
+ }
@@ -0,0 +1,47 @@
1
+ # Definition of Done(统一完成定义)
2
+
3
+ 一个 REQ 只有在**全部 10 项**都可指向证据时才算完成。这份清单是 #607 的落地,
4
+ 对应指南 §12;它存在的理由是本仓库历史上反复出现「以为完成了,其实没有」:
5
+
6
+ - **#561** 覆盖率阈值形状写错(`Path` 而非 `Partial<Record>`),声明 80% 但整个门禁是空转
7
+ - **#570** 覆盖率检查 fail-open,跑不起来时报告通过
8
+ - **#585** Gate 5c 静默通过
9
+ - **.xp-gate/modules 陈旧副本**(2026-10-19)劫持 Gate 6 数周,hook 报的警告数和独立扫描永远对不上
10
+
11
+ 共同点全部是:**某一步从未真正执行,而没有任何东西把这件事说出来。**
12
+ 所以这份清单里每一项的判据都是「证据在哪儿」,不是「做没做」。
13
+
14
+ ---
15
+
16
+ ## 10 项完成定义
17
+
18
+ | # | 条目 | 判据(必须能指出位置) |
19
+ |---|------|------------------------|
20
+ | 1 | **需求可追溯** | `specification.yaml` 有 REQ + AC;测试文件带 `@covers AC-xxx`;`scripts/__tests__/ac-reference-guard.test.cjs` 通过 |
21
+ | 2 | **测试先行** | 实现前存在失败的测试;或说明为何不适用(纯文档/配置) |
22
+ | 3 | **测试真的能失败** | 至少一个变异体/破坏被测试抓住。「测试通过」在从未运行时和「功能正确」无法区分 |
23
+ | 4 | **验证命令已运行** | 记录实际命令与输出,不是「应该是绿的」。CI 命令与本地命令一致 |
24
+ | 5 | **门禁未降级** | 无 `--no-verify`;无新增基线额度来吸收本次改动自身的告警 |
25
+ | 6 | **镜像已同步** | 改了 `githooks/`/`skills/`/`plugins/` → `bash scripts/check-hook-mirror.sh` 输出 PASS |
26
+ | 7 | **不做未经要求的相邻改动** | 每行改动可追溯到本 REQ;顺手发现的无关死代码只提及不删除 |
27
+ | 8 | **已知限制已写明** | 没做的部分、以及为什么没做,写进 issue/提交,而不是留空 |
28
+ | 9 | **文档与实现一致** | 门禁数量、CLI 表、阈值等出现在多处的事实同步更新(见 `AGENTS.md` "Known Drift") |
29
+ | 10 | **可回滚** | 提交粒度单一;出问题时能单独 revert 而不牵连其他改动 |
30
+
31
+ ---
32
+
33
+ ## 相位落点
34
+
35
+ - **Phase 4 VERIFY**:逐项过 1/2/3/4/5/6,任何一项拿不出证据 → 不得进入 SHIP。
36
+ - **Phase 5 SHIP**:逐项过 7/8/9/10,然后才推送。
37
+ - **Phase 6 CLOSE**:把第 8 项「已知限制」回填到 issue 并关闭。
38
+
39
+ ## 常见误判
40
+
41
+ | 看起来完成了 | 实际没有 |
42
+ |---|---|
43
+ | 「测试通过」 | 没跑过会失败的版本,不知道它能不能失败 |
44
+ | 「门禁有配置」 | 配置形状错/键名不对时被静默丢弃,等于没有(#561) |
45
+ | 「工具缺失时跳过」 | 跳过被当成通过;只有 Gate 8 是 fail-closed |
46
+ | 「CI 绿了」 | CI 可能没跑到那一步(`if:` 条件不满足),或跑的是旧副本(#451) |
47
+ | 「注释写了这么做」 | 注释与代码漂移;只有测试能固定行为 |
@@ -142,6 +142,22 @@ ELSE:
142
142
  - Web 前端附加: ui-review report + OPTIONAL QA/design-review/benchmark reports
143
143
  - 验证通过的 MVP
144
144
 
145
+ ### 完成定义(DoD 第 1–6 项)
146
+
147
+ 离开 VERIFY 前逐项过一遍 [`definition-of-done.md`](./definition-of-done.md)。**任何一项拿不出证据 → 不得进入 SHIP。**
148
+
149
+ | # | 条目 | 在 VERIFY 的检查方式 |
150
+ |---|------|----------------------|
151
+ | 1 | 需求可追溯 | `npx vitest run scripts/__tests__/ac-reference-guard.test.cjs` 通过(测试引用的 AC 都在 spec 里) |
152
+ | 2 | 测试先行 | 有 RED 证据(提交历史或记录),或说明为何不适用 |
153
+ | 3 | **测试真的能失败** | 至少证明过一个变异体会被抓住——「测试通过」在从未运行时与「功能正确」无法区分 |
154
+ | 4 | 验证命令已运行 | 记录实际命令 + 输出,不是「应该是绿的」 |
155
+ | 5 | 门禁未降级 | 无 `--no-verify`;无为了本次改动新增的基线额度 |
156
+ | 6 | 镜像已同步 | `bash scripts/check-hook-mirror.sh` → PASS |
157
+
158
+ 第 5 项值得单独说明:**加基线额度来吸收自己刚产生的告警,等于把门禁关掉一次。**
159
+ `.warnings-baseline.json` 只应记录「改动之前就存在」的告警。
160
+
145
161
  ---
146
162
 
147
163
  ## Part B: FEEDBACK CAPTURE(反馈获取)
@@ -99,6 +99,20 @@ Sprint 分支已准备就绪。请选择操作:
99
99
 
100
100
  ### Step 2: 原生 Ship 步骤序列(选择 Option 2 时执行)
101
101
 
102
+ #### Step 2.0: 完成定义后半段(DoD 第 7–10 项,MANDATORY)
103
+
104
+ 推送前逐项过 [`definition-of-done.md`](./definition-of-done.md):
105
+
106
+ | # | 条目 | 在这里怎么查 |
107
+ |---|------|--------------|
108
+ | 7 | 不做未经要求的相邻改动 | `git diff` 逐行对照 REQ;顺手发现的无关问题只提及,不删改 |
109
+ | 8 | **已知限制已写明** | 没做的部分与原因写进提交说明或 issue,而不是留空 |
110
+ | 9 | 文档与实现一致 | 门禁数量/CLI 表/阈值等出现在多处的事实同步更新(`AGENTS.md` "Known Drift") |
111
+ | 10 | 可回滚 | 提交粒度单一,能单独 revert 而不牵连其他改动 |
112
+
113
+ 第 8 项最容易被跳过,也最容易造成误导:**一个没写下来的限制,下一个人会按"已完成"来依赖它。**
114
+
115
+
102
116
  ```
103
117
  1. 运行测试:
104
118
  npm test # 或项目特定测试命令
@@ -3,6 +3,12 @@
3
3
  # Checks that sprint-state.json is valid JSON and all expected keys exist.
4
4
  #
5
5
  # Usage: bash verify-sprint-state.sh [sprint-state-dir]
6
+ #
7
+ # The expected keys are the ones `xp-gate sprint-init` actually writes (#679).
8
+ # They were previously ['sprint_id','status','current_phase','phases'] -- a schema
9
+ # this project has never written, so the check failed on every sprint the CLI
10
+ # itself had just created. A verifier that rejects its own producer's output is
11
+ # worse than no verifier: it trains people to ignore it.
6
12
 
7
13
  set -euo pipefail
8
14
 
@@ -24,12 +30,19 @@ node -e "
24
30
  const fs = require('fs');
25
31
  try {
26
32
  const data = JSON.parse(fs.readFileSync('$STATE_FILE', 'utf8'));
27
- const requiredKeys = ['sprint_id', 'status', 'current_phase', 'phases'];
33
+ // These are the keys src/npm-package/lib/sprint-init.js writes.
34
+ const requiredKeys = ['id', 'task_description', 'phase', 'status'];
28
35
  const missing = requiredKeys.filter(k => !(k in data));
29
36
  if (missing.length > 0) {
30
37
  console.error('ERROR: Missing required keys in sprint-state.json:', missing.join(', '));
31
38
  process.exit(1);
32
39
  }
40
+ // phase_history is an array by construction; a non-array here means the file
41
+ // was hand-edited or written by a different tool, which is worth failing on.
42
+ if (!Array.isArray(data.phase_history)) {
43
+ console.error('ERROR: phase_history must be an array in sprint-state.json');
44
+ process.exit(1);
45
+ }
33
46
  console.log('OK: sprint-state.json is valid with all required keys');
34
47
  } catch (e) {
35
48
  console.error('ERROR: sprint-state.json is not valid JSON:', e.message);
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -39,13 +39,39 @@ function verdict(id: string, role: string, report: string, verdictValue: string,
39
39
  }
40
40
  }
41
41
 
42
+ /**
43
+ * Build a ReviewOutcome from per-round verdicts.
44
+ *
45
+ * `consensusRatio` / `reachedConsensus` are computed the same way `runRound`
46
+ * does rather than stubbed: `RoundResult` declares them as required, and a
47
+ * fixture that hard-codes 0/false would be asserting against values the real
48
+ * code can never produce for these inputs. `formatOutcome` does not read them
49
+ * today (it takes consensus from the top-level fields), but a fixture that
50
+ * disagrees with the producer is exactly how a later change gets "verified"
51
+ * against something impossible.
52
+ *
53
+ * Delphi's seat/threshold constants are module-private in delphi.ts; they are
54
+ * restated here on purpose so this fixture does not force the producer to widen
55
+ * its public API just to be testable.
56
+ */
57
+ const DELPHI_EXPERTS = 3
58
+ const DELPHI_THRESHOLD_PERCENT = 90
59
+
42
60
  function outcomeOf(rounds: Array<{ round: number; verdicts: ReturnType<typeof verdict>[] }>): ReviewOutcome {
43
- const mapped = rounds.map((r) => ({
44
- round: r.round,
45
- approvals: r.verdicts.filter((v) => v.verdict === "APPROVED").length,
46
- validCount: r.verdicts.length,
47
- verdicts: r.verdicts,
48
- }))
61
+ const mapped = rounds.map((r) => {
62
+ const counted = r.verdicts.filter((v) => v.counted)
63
+ const approvals = counted.filter((v) => v.verdict === "APPROVED").length
64
+ // Mirrors runRound: consensus is measured over VALID responses only.
65
+ const consensusRatio = counted.length === 0 ? 0 : approvals / counted.length
66
+ return {
67
+ round: r.round,
68
+ approvals,
69
+ validCount: counted.length,
70
+ verdicts: r.verdicts,
71
+ consensusRatio,
72
+ reachedConsensus: counted.length === DELPHI_EXPERTS && consensusRatio * 100 >= DELPHI_THRESHOLD_PERCENT,
73
+ }
74
+ })
49
75
  return {
50
76
  rounds: mapped,
51
77
  consensus: false,
@@ -19,6 +19,7 @@
19
19
  * @covers AC-669-01, AC-669-02, AC-669-03, AC-669-04
20
20
  */
21
21
  import { execFileSync } from "node:child_process"
22
+ import { describe, expect, it } from "vitest"
22
23
  import { buildCommand, detectDialectForShell } from "./command.js"
23
24
  import { classifyGateRun } from "./gate-runner.js"
24
25
 
@@ -68,6 +69,11 @@ describe("#669 命令串的退出码必须真实传递", () => {
68
69
  // 两者不一致时不能静默采信其中之一。
69
70
  const base = {
70
71
  timedOut: false,
72
+ // ShellRunResult requires both liveness fields. These fixtures represent a
73
+ // run that ended by itself, so "no signal" and "not aborted" are the honest
74
+ // values — omitting them only typechecked because this file never ran.
75
+ signal: null,
76
+ aborted: false,
71
77
  timeoutMs: 1000,
72
78
  stdout: { text: "some output\n[XP-Gate] exit:7\n", truncated: false },
73
79
  stderr: { text: "", truncated: false },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.35.17",
3
+ "version": "0.35.18",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bats
2
+ # @test REQ-688
3
+ # @intent 验证 sprint-flow 的校验脚本能接受 `xp-gate sprint-init` 自己写出的状态文件
4
+ # ——脚本曾要求 sprint_id/current_phase/phases 这套从未被写入过的键,
5
+ # 对 CLI 刚创建的 sprint 恒判失败(#679)
6
+ # @covers AC-688-01, AC-688-02
7
+ #
8
+ # 为什么用真 sprint-init 而不是手写一个 fixture:缺陷的本质是「校验方与生产方对
9
+ # schema 的认知不一致」。手写 fixture 会把「我认为 CLI 写什么」固化下来,双方一起
10
+ # 错就一起绿。只有让生产方真的产出、校验方真的读,才能发现这类偏差。
11
+
12
+ setup() {
13
+ REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../.." && pwd)"
14
+ VERIFY="$REPO_ROOT/skills/sprint-flow/scripts/verify-sprint-state.sh"
15
+ CLI="$REPO_ROOT/src/npm-package/bin/xp-gate.js"
16
+ WORK="$(mktemp -d)"
17
+ }
18
+
19
+ teardown() {
20
+ rm -rf "$WORK"
21
+ }
22
+
23
+ @test "AC-688-01: accepts state written by xp-gate sprint-init" {
24
+ cd "$WORK"
25
+ git init -q .
26
+ echo '{}' > package.json
27
+ git add -A
28
+ git -c user.email=t@t -c user.name=t commit -q -m init
29
+
30
+ run node "$CLI" sprint-init "probe task"
31
+ [ -f ".sprint-state/sprint-state.json" ]
32
+
33
+ run bash "$VERIFY"
34
+ [ "$status" -eq 0 ]
35
+ [[ "$output" == *"OK:"* ]]
36
+ }
37
+
38
+ @test "AC-688-02: still rejects a state file missing real keys" {
39
+ # The fix must not become "accept anything": a file that lost its task or its
40
+ # phase is genuinely broken and the verifier should say so.
41
+ mkdir -p "$WORK/.sprint-state"
42
+ printf '{"id":"s-1","phase":"BUILD"}\n' > "$WORK/.sprint-state/sprint-state.json"
43
+
44
+ cd "$WORK"
45
+ run bash "$VERIFY"
46
+ [ "$status" -eq 1 ]
47
+ [[ "$output" == *"task_description"* ]]
48
+ }
@@ -0,0 +1,47 @@
1
+ # Definition of Done(统一完成定义)
2
+
3
+ 一个 REQ 只有在**全部 10 项**都可指向证据时才算完成。这份清单是 #607 的落地,
4
+ 对应指南 §12;它存在的理由是本仓库历史上反复出现「以为完成了,其实没有」:
5
+
6
+ - **#561** 覆盖率阈值形状写错(`Path` 而非 `Partial<Record>`),声明 80% 但整个门禁是空转
7
+ - **#570** 覆盖率检查 fail-open,跑不起来时报告通过
8
+ - **#585** Gate 5c 静默通过
9
+ - **.xp-gate/modules 陈旧副本**(2026-10-19)劫持 Gate 6 数周,hook 报的警告数和独立扫描永远对不上
10
+
11
+ 共同点全部是:**某一步从未真正执行,而没有任何东西把这件事说出来。**
12
+ 所以这份清单里每一项的判据都是「证据在哪儿」,不是「做没做」。
13
+
14
+ ---
15
+
16
+ ## 10 项完成定义
17
+
18
+ | # | 条目 | 判据(必须能指出位置) |
19
+ |---|------|------------------------|
20
+ | 1 | **需求可追溯** | `specification.yaml` 有 REQ + AC;测试文件带 `@covers AC-xxx`;`scripts/__tests__/ac-reference-guard.test.cjs` 通过 |
21
+ | 2 | **测试先行** | 实现前存在失败的测试;或说明为何不适用(纯文档/配置) |
22
+ | 3 | **测试真的能失败** | 至少一个变异体/破坏被测试抓住。「测试通过」在从未运行时和「功能正确」无法区分 |
23
+ | 4 | **验证命令已运行** | 记录实际命令与输出,不是「应该是绿的」。CI 命令与本地命令一致 |
24
+ | 5 | **门禁未降级** | 无 `--no-verify`;无新增基线额度来吸收本次改动自身的告警 |
25
+ | 6 | **镜像已同步** | 改了 `githooks/`/`skills/`/`plugins/` → `bash scripts/check-hook-mirror.sh` 输出 PASS |
26
+ | 7 | **不做未经要求的相邻改动** | 每行改动可追溯到本 REQ;顺手发现的无关死代码只提及不删除 |
27
+ | 8 | **已知限制已写明** | 没做的部分、以及为什么没做,写进 issue/提交,而不是留空 |
28
+ | 9 | **文档与实现一致** | 门禁数量、CLI 表、阈值等出现在多处的事实同步更新(见 `AGENTS.md` "Known Drift") |
29
+ | 10 | **可回滚** | 提交粒度单一;出问题时能单独 revert 而不牵连其他改动 |
30
+
31
+ ---
32
+
33
+ ## 相位落点
34
+
35
+ - **Phase 4 VERIFY**:逐项过 1/2/3/4/5/6,任何一项拿不出证据 → 不得进入 SHIP。
36
+ - **Phase 5 SHIP**:逐项过 7/8/9/10,然后才推送。
37
+ - **Phase 6 CLOSE**:把第 8 项「已知限制」回填到 issue 并关闭。
38
+
39
+ ## 常见误判
40
+
41
+ | 看起来完成了 | 实际没有 |
42
+ |---|---|
43
+ | 「测试通过」 | 没跑过会失败的版本,不知道它能不能失败 |
44
+ | 「门禁有配置」 | 配置形状错/键名不对时被静默丢弃,等于没有(#561) |
45
+ | 「工具缺失时跳过」 | 跳过被当成通过;只有 Gate 8 是 fail-closed |
46
+ | 「CI 绿了」 | CI 可能没跑到那一步(`if:` 条件不满足),或跑的是旧副本(#451) |
47
+ | 「注释写了这么做」 | 注释与代码漂移;只有测试能固定行为 |
@@ -142,6 +142,22 @@ ELSE:
142
142
  - Web 前端附加: ui-review report + OPTIONAL QA/design-review/benchmark reports
143
143
  - 验证通过的 MVP
144
144
 
145
+ ### 完成定义(DoD 第 1–6 项)
146
+
147
+ 离开 VERIFY 前逐项过一遍 [`definition-of-done.md`](./definition-of-done.md)。**任何一项拿不出证据 → 不得进入 SHIP。**
148
+
149
+ | # | 条目 | 在 VERIFY 的检查方式 |
150
+ |---|------|----------------------|
151
+ | 1 | 需求可追溯 | `npx vitest run scripts/__tests__/ac-reference-guard.test.cjs` 通过(测试引用的 AC 都在 spec 里) |
152
+ | 2 | 测试先行 | 有 RED 证据(提交历史或记录),或说明为何不适用 |
153
+ | 3 | **测试真的能失败** | 至少证明过一个变异体会被抓住——「测试通过」在从未运行时与「功能正确」无法区分 |
154
+ | 4 | 验证命令已运行 | 记录实际命令 + 输出,不是「应该是绿的」 |
155
+ | 5 | 门禁未降级 | 无 `--no-verify`;无为了本次改动新增的基线额度 |
156
+ | 6 | 镜像已同步 | `bash scripts/check-hook-mirror.sh` → PASS |
157
+
158
+ 第 5 项值得单独说明:**加基线额度来吸收自己刚产生的告警,等于把门禁关掉一次。**
159
+ `.warnings-baseline.json` 只应记录「改动之前就存在」的告警。
160
+
145
161
  ---
146
162
 
147
163
  ## Part B: FEEDBACK CAPTURE(反馈获取)
@@ -99,6 +99,20 @@ Sprint 分支已准备就绪。请选择操作:
99
99
 
100
100
  ### Step 2: 原生 Ship 步骤序列(选择 Option 2 时执行)
101
101
 
102
+ #### Step 2.0: 完成定义后半段(DoD 第 7–10 项,MANDATORY)
103
+
104
+ 推送前逐项过 [`definition-of-done.md`](./definition-of-done.md):
105
+
106
+ | # | 条目 | 在这里怎么查 |
107
+ |---|------|--------------|
108
+ | 7 | 不做未经要求的相邻改动 | `git diff` 逐行对照 REQ;顺手发现的无关问题只提及,不删改 |
109
+ | 8 | **已知限制已写明** | 没做的部分与原因写进提交说明或 issue,而不是留空 |
110
+ | 9 | 文档与实现一致 | 门禁数量/CLI 表/阈值等出现在多处的事实同步更新(`AGENTS.md` "Known Drift") |
111
+ | 10 | 可回滚 | 提交粒度单一,能单独 revert 而不牵连其他改动 |
112
+
113
+ 第 8 项最容易被跳过,也最容易造成误导:**一个没写下来的限制,下一个人会按"已完成"来依赖它。**
114
+
115
+
102
116
  ```
103
117
  1. 运行测试:
104
118
  npm test # 或项目特定测试命令
@@ -3,6 +3,12 @@
3
3
  # Checks that sprint-state.json is valid JSON and all expected keys exist.
4
4
  #
5
5
  # Usage: bash verify-sprint-state.sh [sprint-state-dir]
6
+ #
7
+ # The expected keys are the ones `xp-gate sprint-init` actually writes (#679).
8
+ # They were previously ['sprint_id','status','current_phase','phases'] -- a schema
9
+ # this project has never written, so the check failed on every sprint the CLI
10
+ # itself had just created. A verifier that rejects its own producer's output is
11
+ # worse than no verifier: it trains people to ignore it.
6
12
 
7
13
  set -euo pipefail
8
14
 
@@ -24,12 +30,19 @@ node -e "
24
30
  const fs = require('fs');
25
31
  try {
26
32
  const data = JSON.parse(fs.readFileSync('$STATE_FILE', 'utf8'));
27
- const requiredKeys = ['sprint_id', 'status', 'current_phase', 'phases'];
33
+ // These are the keys src/npm-package/lib/sprint-init.js writes.
34
+ const requiredKeys = ['id', 'task_description', 'phase', 'status'];
28
35
  const missing = requiredKeys.filter(k => !(k in data));
29
36
  if (missing.length > 0) {
30
37
  console.error('ERROR: Missing required keys in sprint-state.json:', missing.join(', '));
31
38
  process.exit(1);
32
39
  }
40
+ // phase_history is an array by construction; a non-array here means the file
41
+ // was hand-edited or written by a different tool, which is worth failing on.
42
+ if (!Array.isArray(data.phase_history)) {
43
+ console.error('ERROR: phase_history must be an array in sprint-state.json');
44
+ process.exit(1);
45
+ }
33
46
  console.log('OK: sprint-state.json is valid with all required keys');
34
47
  } catch (e) {
35
48
  console.error('ERROR: sprint-state.json is not valid JSON:', e.message);
@@ -1,9 +1,9 @@
1
1
  # SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.35.17",
3
+ "version": "0.35.18",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Qoder. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -1,9 +1,9 @@
1
1
  # SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -1,9 +1,9 @@
1
1
  # SKILLS/SPRINT-FLOW KNOWLEDGE BASE
2
2
 
3
3
  **Generated:** 2026-10-31
4
- **Commit:** 26a741de
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.17.0
6
+ **Version:** 0.35.18.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.