@boyingliu01/xp-gate 0.35.16 → 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 (75) 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 +82 -12
  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/mutation/runners/mutmut-runner.ts +165 -70
  20. package/package.json +1 -1
  21. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  22. package/plugins/claude-code/skills/delphi-review/AGENTS.md +2 -2
  23. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +2 -2
  24. package/plugins/claude-code/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  25. package/plugins/claude-code/skills/sprint-flow/references/definition-of-done.md +47 -0
  26. package/plugins/claude-code/skills/sprint-flow/references/phase-4-verify.md +16 -0
  27. package/plugins/claude-code/skills/sprint-flow/references/phase-5-ship.md +14 -0
  28. package/plugins/claude-code/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  29. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +2 -2
  30. package/plugins/dsh/package.json +1 -1
  31. package/plugins/dsh/skills/delphi-review/AGENTS.md +2 -2
  32. package/plugins/dsh/skills/sprint-flow/AGENTS.md +2 -2
  33. package/plugins/dsh/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  34. package/plugins/dsh/skills/sprint-flow/references/definition-of-done.md +47 -0
  35. package/plugins/dsh/skills/sprint-flow/references/phase-4-verify.md +16 -0
  36. package/plugins/dsh/skills/sprint-flow/references/phase-5-ship.md +14 -0
  37. package/plugins/dsh/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  38. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +2 -2
  39. package/plugins/dsh/src/delphi-findings.test.ts +32 -6
  40. package/plugins/dsh/src/exit-code.test.ts +6 -0
  41. package/plugins/opencode/package.json +1 -1
  42. package/plugins/opencode/skills/delphi-review/AGENTS.md +2 -2
  43. package/plugins/opencode/skills/sprint-flow/AGENTS.md +2 -2
  44. package/plugins/opencode/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  45. package/plugins/opencode/skills/sprint-flow/references/definition-of-done.md +47 -0
  46. package/plugins/opencode/skills/sprint-flow/references/phase-4-verify.md +16 -0
  47. package/plugins/opencode/skills/sprint-flow/references/phase-5-ship.md +14 -0
  48. package/plugins/opencode/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  49. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +2 -2
  50. package/plugins/qoder/plugin.json +1 -1
  51. package/plugins/qoder/skills/delphi-review/AGENTS.md +2 -2
  52. package/plugins/qoder/skills/sprint-flow/AGENTS.md +2 -2
  53. package/plugins/qoder/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  54. package/plugins/qoder/skills/sprint-flow/references/definition-of-done.md +47 -0
  55. package/plugins/qoder/skills/sprint-flow/references/phase-4-verify.md +16 -0
  56. package/plugins/qoder/skills/sprint-flow/references/phase-5-ship.md +14 -0
  57. package/plugins/qoder/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  58. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +2 -2
  59. package/principles/AGENTS.md +2 -2
  60. package/principles/adapters/import-clause.ts +57 -0
  61. package/principles/adapters/member-scan.ts +73 -0
  62. package/principles/adapters/position-analysis.ts +43 -0
  63. package/principles/adapters/quote-state.ts +80 -0
  64. package/principles/adapters/typescript.ts +57 -116
  65. package/principles/rules/clean-code/god-class.ts +37 -14
  66. package/principles/rules/solid/dip.ts +15 -2
  67. package/scripts/__tests__/sync-package-content.test.js +114 -46
  68. package/skills/delphi-review/AGENTS.md +2 -2
  69. package/skills/sprint-flow/AGENTS.md +2 -2
  70. package/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +48 -0
  71. package/skills/sprint-flow/references/definition-of-done.md +47 -0
  72. package/skills/sprint-flow/references/phase-4-verify.md +16 -0
  73. package/skills/sprint-flow/references/phase-5-ship.md +14 -0
  74. package/skills/sprint-flow/scripts/verify-sprint-state.sh +14 -1
  75. package/skills/test-specification-alignment/AGENTS.md +2 -2
@@ -1,5 +1,5 @@
1
1
  // @no-test-required: mutmut wrapper — tested via gate-m integration + pre-push Gate M
2
- import { spawn, execSync } from 'child_process';
2
+ import { spawn, execSync, type ChildProcess } from 'child_process';
3
3
  import { writeFileSync, unlinkSync, readFileSync, existsSync } from 'fs';
4
4
  import { join, dirname } from 'path';
5
5
  import type {
@@ -24,6 +24,87 @@ type MutmutRoute = 'native' | 'wsl' | 'unavailable' | 'unresolved';
24
24
  * - Results stored in SQLite; `mutmut results` outputs per-mutant status lines
25
25
  * - `mutmut run` stdout shows emoji progress: 🎉 N 🫥 N ⏰ N 🤔 N 🙁 N
26
26
  */
27
+ /**
28
+ * Wire a child process's stdout/stderr into one accumulating callback.
29
+ *
30
+ * Extracted from `runMutmut`: the two listeners were six lines of pure
31
+ * accumulation inside an already-long Promise body, and their nesting was part
32
+ * of what made that method exceed both the length and the nesting budget.
33
+ */
34
+ function collectOutput(
35
+ child: ChildProcess,
36
+ onChunk: (chunk: string, isStderr: boolean) => void,
37
+ ): void {
38
+ child.stdout?.on('data', (data: Buffer) => onChunk(data.toString(), false));
39
+ child.stderr?.on('data', (data: Buffer) => onChunk(data.toString(), true));
40
+ }
41
+
42
+ /** How long a SIGTERMed mutmut gets before it is killed outright. */
43
+ const ESCALATION_DELAY_MS = 5000;
44
+
45
+ /** Where the pre-run copy of pyproject.toml lives. */
46
+ function pyprojectBackupPath(pyprojectPath: string): string {
47
+ return `${pyprojectPath}.xp-gate-backup`;
48
+ }
49
+
50
+ /**
51
+ * Put pyproject.toml back the way it was, or remove the one we generated.
52
+ *
53
+ * Cleanup is best-effort by design: the mutation run's own result is what the
54
+ * caller acts on, and failing here would replace a usable outcome with an
55
+ * exception raised from a `finally`. Extracted from `run` because the nested
56
+ * try/if/if/else was what pushed that method to 5 nesting levels.
57
+ */
58
+ function restorePyproject(pyprojectPath: string, hadExisting: boolean): void {
59
+ const backupPath = pyprojectBackupPath(pyprojectPath);
60
+ try {
61
+ if (hadExisting && existsSync(backupPath)) {
62
+ writeFileSync(pyprojectPath, readFileSync(backupPath, 'utf-8'), { encoding: 'utf-8' });
63
+ unlinkSync(backupPath);
64
+ } else if (!hadExisting && existsSync(pyprojectPath)) {
65
+ unlinkSync(pyprojectPath);
66
+ }
67
+ } catch {
68
+ // Best effort cleanup
69
+ }
70
+ }
71
+
72
+ /** The tracker shape `settleTracker` returns; only the timeout path uses these. */
73
+ interface SettleTracker {
74
+ didTimeOut: () => boolean;
75
+ markTimedOut: () => void;
76
+ settle: (outcome: MutationRunOutcome) => void;
77
+ isSettled: () => boolean;
78
+ }
79
+
80
+ /**
81
+ * Arm the run timeout, escalating SIGTERM to SIGKILL once.
82
+ *
83
+ * Extracted from `runMutmut` for the same reason as `collectOutput`: the
84
+ * two-step kill sequence is twelve lines of policy that pushed the method past
85
+ * both budgets. The escalation timer id is handed back through `setEscalation`
86
+ * so the caller's `cancelTimers` closure can still reach it.
87
+ *
88
+ * @returns the primary timer id, to be cleared by the caller.
89
+ */
90
+ function armTimeout(
91
+ child: ChildProcess,
92
+ timeoutMs: number,
93
+ tracker: SettleTracker,
94
+ setEscalation: (id: NodeJS.Timeout) => void,
95
+ ): NodeJS.Timeout {
96
+ const escalationMs = ESCALATION_DELAY_MS;
97
+ return setTimeout(() => {
98
+ tracker.markTimedOut();
99
+ child.kill('SIGTERM');
100
+ if (tracker.isSettled()) return;
101
+ // SIGTERM may be ignored; escalate once.
102
+ setEscalation(setTimeout(() => {
103
+ if (!tracker.isSettled()) child.kill('SIGKILL');
104
+ }, escalationMs));
105
+ }, timeoutMs);
106
+ }
107
+
27
108
  export class MutmutRunner implements MutationRunner {
28
109
  readonly name = 'mutmut';
29
110
  readonly extensions = ['py'];
@@ -72,33 +153,35 @@ export class MutmutRunner implements MutationRunner {
72
153
  const sourceDirs = this.extractUniqueDirs(options.files);
73
154
 
74
155
  const pyprojectPath = join(options.cwd, 'pyproject.toml');
75
- const backupPath = join(options.cwd, 'pyproject.toml.xp-gate-backup');
76
- let hadExisting = false;
156
+ const hadExisting = this.backupPyproject(pyprojectPath);
77
157
 
78
158
  try {
79
- if (existsSync(pyprojectPath)) {
80
- hadExisting = true;
81
- const existing = readFileSync(pyprojectPath, 'utf-8');
82
- writeFileSync(backupPath, existing, { encoding: 'utf-8' });
83
- }
84
159
  this.writeMutmutConfig(pyprojectPath, sourceDirs);
85
-
86
160
  return await this.runMutmut(options);
87
161
  } finally {
88
- try {
89
- if (hadExisting && existsSync(backupPath)) {
90
- const backup = readFileSync(backupPath, 'utf-8');
91
- writeFileSync(pyprojectPath, backup, { encoding: 'utf-8' });
92
- unlinkSync(backupPath);
93
- } else if (!hadExisting && existsSync(pyprojectPath)) {
94
- unlinkSync(pyprojectPath);
95
- }
96
- } catch {
97
- // Best effort cleanup
98
- }
162
+ restorePyproject(pyprojectPath, hadExisting);
99
163
  }
100
164
  }
101
165
 
166
+ /**
167
+ * Copy an existing pyproject.toml aside so `run` can put it back.
168
+ * @returns whether a file was there to back up.
169
+ */
170
+ private backupPyproject(pyprojectPath: string): boolean {
171
+ if (!existsSync(pyprojectPath)) return false;
172
+ const backupPath = pyprojectBackupPath(pyprojectPath);
173
+ try {
174
+ writeFileSync(backupPath, readFileSync(pyprojectPath, 'utf-8'), { encoding: 'utf-8' });
175
+ } catch (err) {
176
+ // Failing here must be loud: without a backup, `restorePyproject` would
177
+ // silently leave this repo's pyproject.toml overwritten by a generated one.
178
+ throw new Error(
179
+ `Could not back up ${pyprojectPath} before writing a mutmut config: ${(err as Error).message}`,
180
+ );
181
+ }
182
+ return true;
183
+ }
184
+
102
185
  /**
103
186
  * Build the terminal-outcome handler for one `mutmut run`.
104
187
  *
@@ -173,39 +256,17 @@ export class MutmutRunner implements MutationRunner {
173
256
 
174
257
  const tracker = this.settleTracker(resolve, cancelTimers);
175
258
 
176
- const timeoutId = setTimeout(() => {
177
- tracker.markTimedOut();
178
- child.kill('SIGTERM');
179
- if (tracker.isSettled()) return;
180
- // SIGTERM may be ignored; escalate once, and let the retry live in a
181
- // variable so `cancelTimers` can reach it.
182
- escalationId = setTimeout(() => {
183
- if (!tracker.isSettled()) child.kill('SIGKILL');
184
- }, 5000);
185
- }, options.timeoutMs);
186
-
187
- child.stdout?.on('data', (data: Buffer) => {
188
- stdout += data.toString();
259
+ const timeoutId = armTimeout(child, options.timeoutMs, tracker, (id) => {
260
+ escalationId = id;
189
261
  });
190
262
 
191
- child.stderr?.on('data', (data: Buffer) => {
192
- stderr += data.toString();
263
+ collectOutput(child, (chunk, isErr) => {
264
+ if (isErr) stderr += chunk;
265
+ else stdout += chunk;
193
266
  });
194
267
 
195
268
  child.on('close', (code) => {
196
- // A null exit code means the process was killed ("timed out" when we did
197
- // it, "unknown" otherwise); there is no report to parse either way.
198
- if (code === null) {
199
- tracker.settle({ report: null, timedOut: tracker.didTimeOut() });
200
- return;
201
- }
202
-
203
- tracker.settle({
204
- // Parse results from mutmut run stdout (v3.x emoji progress)
205
- report: this.parseEmojiProgress(stdout),
206
- timedOut: tracker.didTimeOut(),
207
- error: code !== 0 ? stderr || stdout : undefined,
208
- });
269
+ tracker.settle(this.outcomeFor(code, stdout, stderr, tracker));
209
270
  });
210
271
 
211
272
  child.on('error', (err) => {
@@ -214,6 +275,29 @@ export class MutmutRunner implements MutationRunner {
214
275
  });
215
276
  }
216
277
 
278
+ /**
279
+ * Turn one `mutmut run` exit into the outcome the caller expects.
280
+ *
281
+ * Extracted from `runMutmut`'s close handler to bring that method back under
282
+ * the length and nesting budgets. A null exit code means the process was
283
+ * killed -- "timed out" when we did it, "unknown" otherwise -- and there is no
284
+ * report to parse either way.
285
+ */
286
+ private outcomeFor(
287
+ code: number | null,
288
+ stdout: string,
289
+ stderr: string,
290
+ tracker: SettleTracker,
291
+ ): MutationRunOutcome {
292
+ if (code === null) return { report: null, timedOut: tracker.didTimeOut() };
293
+ return {
294
+ // Parse results from mutmut run stdout (v3.x emoji progress)
295
+ report: this.parseEmojiProgress(stdout),
296
+ timedOut: tracker.didTimeOut(),
297
+ error: code !== 0 ? stderr || stdout : undefined,
298
+ };
299
+ }
300
+
217
301
  private toWslPath(path: string): string | null {
218
302
  const match = path.match(/^([A-Za-z]):[\\/](.*)$/);
219
303
  if (!match) return null;
@@ -300,28 +384,39 @@ export class MutmutRunner implements MutationRunner {
300
384
  }
301
385
 
302
386
  private writeMutmutConfig(pyprojectPath: string, sourceDirs: string[]): void {
303
- const sourcePaths = sourceDirs.map((d) => `"${d}"`).join(', ');
304
- const sourcePathsLine = `source_paths = [${sourcePaths}]`;
305
-
306
- let content = '';
307
- if (existsSync(pyprojectPath)) {
308
- content = readFileSync(pyprojectPath, 'utf-8');
309
- if (content.includes('[tool.mutmut]')) {
310
- const sourcePathsRegex = /source_paths\s*=\s*\[.*?\]/;
311
- if (sourcePathsRegex.test(content)) {
312
- content = content.replace(sourcePathsRegex, sourcePathsLine);
313
- } else {
314
- content = content.replace(
315
- '[tool.mutmut]',
316
- `[tool.mutmut]\n${sourcePathsLine}`,
317
- );
318
- }
319
- } else {
320
- content = content.trimEnd() + `\n\n[tool.mutmut]\n${sourcePathsLine}\n`;
321
- }
322
- } else {
323
- content = `[tool.mutmut]\n${sourcePathsLine}\n`;
387
+ const sourcePathsLine = `source_paths = [${sourceDirs.map((d) => `"${d}"`).join(', ')}]`;
388
+ try {
389
+ // Read here so the content builder stays pure: it then has no I/O to
390
+ // fail on, and the one place that can fail is the one that explains why.
391
+ const existing = existsSync(pyprojectPath) ? readFileSync(pyprojectPath, 'utf-8') : null;
392
+ writeFileSync(pyprojectPath, mutmutConfigContent(existing, sourcePathsLine), {
393
+ encoding: 'utf-8',
394
+ });
395
+ } catch (err) {
396
+ // A missing or half-written pyproject.toml would make mutmut scan the wrong
397
+ // tree, so surface the path instead of letting a bare fs error escape.
398
+ throw new Error(`Could not write mutmut config to ${pyprojectPath}: ${(err as Error).message}`);
324
399
  }
325
- writeFileSync(pyprojectPath, content, { encoding: 'utf-8' });
326
400
  }
327
401
  }
402
+
403
+ /**
404
+ * pyproject.toml content with `[tool.mutmut] source_paths` set as requested.
405
+ *
406
+ * Pure by design: the caller reads the existing file and passes it in, so this
407
+ * function has no I/O that could fail partway through. Three shapes have to be
408
+ * preserved -- an existing `source_paths` is rewritten in place, a bare
409
+ * `[tool.mutmut]` table gets the key added, and a file without the table gets
410
+ * one appended (a fresh file passes `null`).
411
+ *
412
+ * @param existing current file content, or null when the file does not exist.
413
+ */
414
+ function mutmutConfigContent(existing: string | null, sourcePathsLine: string): string {
415
+ if (existing === null) return `[tool.mutmut]\n${sourcePathsLine}\n`;
416
+ if (!existing.includes('[tool.mutmut]')) {
417
+ return existing.trimEnd() + `\n\n[tool.mutmut]\n${sourcePathsLine}\n`;
418
+ }
419
+ const sourcePathsRegex = /source_paths\s*=\s*\[.*?\]/;
420
+ if (sourcePathsRegex.test(existing)) return existing.replace(sourcePathsRegex, sourcePathsLine);
421
+ return existing.replace('[tool.mutmut]', `[tool.mutmut]\n${sourcePathsLine}`);
422
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.35.16",
3
+ "version": "0.35.18",
4
4
  "description": "AI-driven development workflow: 6 quality gates + Delphi review + Sprint Flow",
5
5
  "bin": {
6
6
  "xp-gate": "bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.35.16",
3
+ "version": "0.35.18",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. 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:** 3aa988e7
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.16.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:** 3aa988e7
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.16.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:** 3aa988e7
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.16.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.16",
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:** 3aa988e7
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.16.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:** 3aa988e7
4
+ **Commit:** 97e3c2ec
5
5
  **Branch:** main
6
- **Version:** 0.35.16.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
+ | 「注释写了这么做」 | 注释与代码漂移;只有测试能固定行为 |