@boyingliu01/xp-gate 0.41.57 → 0.41.58

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.
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-12-01T15:27:48.648Z",
5
+ "checked_at": "2026-12-01T15:31:05.560Z",
6
6
  "source": "network"
7
7
  }
@@ -37,6 +37,7 @@ function formatDuration(seconds) {
37
37
  }
38
38
  const fs = require('fs');
39
39
  const crypto = require('crypto');
40
+ const { checkSpecHash } = require('./spec-binding.js');
40
41
  const { execFileSync, execSync } = require('child_process');
41
42
  const { SprintStateManager } = require('./sprint-state-manager');
42
43
 
@@ -171,31 +172,12 @@ function validateRequirementsExpertEvidence(data) {
171
172
  }
172
173
 
173
174
  /**
174
- * Compute SHA-256 hash of a file's contents.
175
- * @param {string} filePath
176
- * @returns {string} hex digest
177
- */
178
- /**
179
- * SHA-256 of a file's contents.
180
- *
181
- * A read failure must not look like a hash mismatch: "the spec changed" and "I
182
- * could not read the spec" send the operator to different places. Callers compare
183
- * this against a recorded hash, so an exception here surfaces as a crash rather
184
- * than as a silent "changed" verdict -- which is the right direction.
175
+ * Parse an evidence timestamp, rejecting anything that is not a UTC ISO-8601
176
+ * instant on the stated date.
185
177
  *
186
- * @param {string} filePath
187
- * @returns {string}
178
+ * @param {string} timestamp
179
+ * @returns {Date|null}
188
180
  */
189
- function computeFileHash(filePath) {
190
- let content;
191
- try {
192
- content = fs.readFileSync(filePath, 'utf8');
193
- } catch (err) {
194
- throw new Error(`cannot hash ${filePath}: ${err.message}`);
195
- }
196
- return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
197
- }
198
-
199
181
  function parseEvidenceDate(timestamp) {
200
182
  if (typeof timestamp !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(timestamp)) {
201
183
  return null;
@@ -437,15 +419,16 @@ function checkPhaseSpecificEvidence(phase, fileName, data, projectDir, errors, w
437
419
  }
438
420
 
439
421
  if (phase === PHASE_VERIFY) {
440
- // spec_hash check (only if specification.yaml exists)
441
- const specPath = path.join(projectDir, 'specification.yaml');
442
- if (fs.existsSync(specPath)) {
443
- const expectedHash = computeFileHash(specPath);
444
- if (data.spec_hash !== expectedHash) {
445
- const msg = `${fileName}: spec_hash mismatch — specification.yaml has changed since report was generated`;
446
- recordProblem(msg, errors, warnings, isLegacySprint);
447
- }
448
- }
422
+ // #834: the binding question lives in spec-binding.js -- see that module for
423
+ // why a scoped spec has to be expressible and why "no spec" is neither a
424
+ // silent skip nor a block.
425
+ checkSpecHash(
426
+ data,
427
+ fileName,
428
+ projectDir,
429
+ (msg) => recordProblem(msg, errors, warnings, isLegacySprint),
430
+ (msg) => warnings.push(msg),
431
+ );
449
432
  }
450
433
 
451
434
  if (phase === PHASE_DESIGN) {
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @module spec-binding — which specification a phase-4 report is bound to (#834)
3
+ *
4
+ * WHY THIS IS ITS OWN MODULE
5
+ * The evidence gate used to hash `<repo>/specification.yaml` and nothing else.
6
+ * Two sprints running in parallel, each owning its own REQ slice, could never
7
+ * satisfy that binding: a sprint that legitimately scored against its own slice
8
+ * had a real PASS rejected for a BINDING mismatch and had to spend the
9
+ * `--skip-evidence` quota -- a quota meant for missing evidence -- to get past it.
10
+ *
11
+ * It lives here rather than inline because the fix pushed `phase-transition.js`
12
+ * past the file-size limit the same repository enforces. Splitting is the
13
+ * correct response to that limit, not a baseline entry: this is one question
14
+ * ("which file, and did it change?") with its own tests, and it does not need
15
+ * the rest of the transition machinery to answer.
16
+ *
17
+ * THREE STATES, and collapsing them is the defect this module exists to avoid:
18
+ *
19
+ * bound the report names a spec and carries a hash → verify exactly
20
+ * unbound no spec_path and no hash → WARNED with a reason, never silently
21
+ * passed, never blocked (a project without a spec is legitimate)
22
+ * unreadable a spec was named but the file is gone → ERROR. The old
23
+ * `if (fs.existsSync(specPath))` skipped this whole case and printed
24
+ * nothing, so a renamed spec disabled the check silently.
25
+ *
26
+ * The strength of the invariant does not change with the scope: a different file
27
+ * is still hashed whole and compared exactly. Binding to a slice is not the same
28
+ * as not binding.
29
+ */
30
+
31
+ 'use strict';
32
+
33
+ const fs = require('fs');
34
+ const path = require('path');
35
+ const crypto = require('crypto');
36
+
37
+ /** The file the binding falls back to when a report names none. */
38
+ const DEFAULT_SPEC_PATH = 'specification.yaml';
39
+
40
+ /**
41
+ * Hash a file's contents exactly as it sits on disk.
42
+ *
43
+ * A read failure is thrown rather than returned: "the spec changed" and "I could
44
+ * not read the spec" send the operator to different places, and a caller that
45
+ * confuses them reports a mismatch where there is an unreadable file.
46
+ *
47
+ * @param {string} filePath
48
+ * @returns {string} hex sha256
49
+ */
50
+ function computeFileHash(filePath) {
51
+ let content;
52
+ try {
53
+ content = fs.readFileSync(filePath, 'utf8');
54
+ } catch (err) {
55
+ throw new Error(`cannot hash ${filePath}: ${err.message}`);
56
+ }
57
+ return crypto.createHash('sha256').update(content, 'utf8').digest('hex');
58
+ }
59
+
60
+ /**
61
+ * Resolve the specification file a report is bound to.
62
+ *
63
+ * `spec_path` comes from the evidence report, which is data and therefore
64
+ * attacker-controlled. Without the escape check the hash could be pointed at any
65
+ * file on the machine, which turns a binding check into a bypass.
66
+ *
67
+ * @param {string} projectDir repository root
68
+ * @param {string|undefined} specPath reported path, relative to the root
69
+ * @returns {{rel: string, abs: string, escaped: boolean}}
70
+ */
71
+ function resolveSpecTarget(projectDir, specPath) {
72
+ const rel = typeof specPath === 'string' && specPath.trim() ? specPath.trim() : DEFAULT_SPEC_PATH;
73
+ const abs = path.resolve(projectDir, rel);
74
+ const root = path.resolve(projectDir);
75
+ const escaped = abs !== root && !abs.startsWith(root + path.sep);
76
+ return { rel, abs, escaped };
77
+ }
78
+
79
+ /**
80
+ * Verify a report's spec_hash against the file it names.
81
+ *
82
+ * `recordProblem` is injected so this module does not have to own the
83
+ * errors-vs-warnings policy (legacy sprints warn where current ones error); that
84
+ * policy belongs to the evidence gate, not to the binding question.
85
+ *
86
+ * @param {object} data parsed report
87
+ * @param {string} fileName
88
+ * @param {string} projectDir
89
+ * @param {(msg: string) => void} fail record a problem under the caller's policy
90
+ * @param {(msg: string) => void} warn record a non-blocking reason
91
+ */
92
+ function checkSpecHash(data, fileName, projectDir, fail, warn) {
93
+ const declared = typeof data.spec_path === 'string' && data.spec_path.trim() !== '';
94
+ const hasHash = typeof data.spec_hash === 'string' && data.spec_hash.trim() !== '';
95
+ if (!declared && !hasHash) {
96
+ warn(`${fileName}: no spec_path or spec_hash — the specification binding was NOT verified`);
97
+ return;
98
+ }
99
+ const target = resolveSpecTarget(projectDir, data.spec_path);
100
+ if (target.escaped) {
101
+ fail(`${fileName}: spec_path '${target.rel}' resolves outside the repository`);
102
+ return;
103
+ }
104
+ if (!fs.existsSync(target.abs)) {
105
+ fail(`${fileName}: spec_path '${target.rel}' does not exist — the spec binding was NOT verified`);
106
+ return;
107
+ }
108
+ if (data.spec_hash !== computeFileHash(target.abs)) {
109
+ fail(`${fileName}: spec_hash mismatch — ${target.rel} has changed since report was generated`);
110
+ }
111
+ }
112
+
113
+ module.exports = { checkSpecHash, resolveSpecTarget, computeFileHash, DEFAULT_SPEC_PATH };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.41.57",
3
+ "version": "0.41.58",
4
4
  "description": "Deterministic quality gates for AI-generated code: 15 gates, Delphi review, sprint flow. Works with Claude Code, OpenCode, Qoder.",
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.41.57",
3
+ "version": "0.41.58",
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": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.41.57",
3
+ "version": "0.41.58",
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",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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/opencode-plugin",
3
- "version": "0.41.57",
3
+ "version": "0.41.58",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.41.57",
3
+ "version": "0.41.58",
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": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.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; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.57.0
6
+ **Version:** 0.41.58.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.