@boyingliu01/xp-gate 0.38.0 → 0.38.1

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.
@@ -8,6 +8,7 @@
8
8
  * @covers AC-SASTD-01, AC-SASTD-02, AC-SASTD-03, AC-SASTD-04
9
9
  */
10
10
  const path = require('node:path');
11
+ const { execFileSync } = require('node:child_process');
11
12
 
12
13
  const {
13
14
  resolveDaemonPolicy,
@@ -26,6 +27,28 @@ const CAPTURED_TOTAL_TIME = 1.98;
26
27
  const SHORT_TIMEOUT_MS = 5000;
27
28
  const LONG_TIMEOUT_MS = 120000;
28
29
 
30
+ /**
31
+ * True when this interpreter can `import semgrep`.
32
+ *
33
+ * Some tests here drive the REAL `semgrep.run_scan.run_scan_and_return_json`,
34
+ * because the property they pin is "the daemon behaves like the CLI it replaces"
35
+ * -- a stub would prove nothing. Those tests therefore need semgrep installed,
36
+ * and CI does not install it (only the local machine does). Detect it ONCE and
37
+ * skip loudly rather than failing: a red build for a missing optional tool
38
+ * trains people to ignore red, which is worse than a named skip.
39
+ */
40
+ let semgrepImportable;
41
+ function hasSemgrep() {
42
+ if (semgrepImportable !== undefined) return semgrepImportable;
43
+ try {
44
+ execFileSync('python', ['-c', 'import semgrep'], { stdio: 'ignore', timeout: LONG_TIMEOUT_MS });
45
+ semgrepImportable = true;
46
+ } catch {
47
+ semgrepImportable = false;
48
+ }
49
+ return semgrepImportable;
50
+ }
51
+
29
52
  describe('resolveDaemonPolicy — AC-SASTD-01', () => {
30
53
  it('enables the daemon only for values that ask for it', () => {
31
54
  for (const v of ['on', '1', 'true', 'auto', 'ON', ' On ']) {
@@ -50,6 +73,39 @@ describe('normaliseResultPaths — AC-SASTD-02', () => {
50
73
  expect(out[0].path).toBe('t.js');
51
74
  });
52
75
 
76
+ // AC-SASTD-02, cross-platform half. `path.isAbsolute`/`path.basename` answer
77
+ // for the HOST only, so the original implementation passed on Windows and
78
+ // failed on Linux CI: 'C:/repo/sub/t.js' is not absolute to a POSIX host, so
79
+ // the path was left absolute and the report showed a different-looking
80
+ // finding. A scan's paths arrive from whichever machine ran semgrep, so BOTH
81
+ // conventions must reduce to the same basename no matter which host runs this.
82
+ const BACKSLASH = String.fromCharCode(92);
83
+ // A UNC path is EXACTLY two leading backslashes. Building the prefix with
84
+ // `[BACKSLASH + BACKSLASH, 'server', ...].join(BACKSLASH)` yields THREE, and
85
+ // a three-backslash string starts with '/' in POSIX eyes (isAbsolute=true) but
86
+ // not in the implementation's UNC branch -- so it passed on Windows and failed
87
+ // on Linux CI. The separator before 'server' must not be joined in.
88
+ const UNC_PREFIX = BACKSLASH + BACKSLASH;
89
+ const ABSOLUTE_FORMS = [
90
+ ['posix', ['/', 'repo', 'sub', 't.js'].join('/')],
91
+ ['windows forward-slash', ['C:', 'repo', 'sub', 't.js'].join('/')],
92
+ ['windows backslash', ['C:', 'repo', 'sub', 't.js'].join(BACKSLASH)],
93
+ ['windows UNC', UNC_PREFIX + ['server', 'share', 't.js'].join(BACKSLASH)],
94
+ ];
95
+
96
+ for (const [label, p] of ABSOLUTE_FORMS) {
97
+ it(`rewrites an absolute ${label} path to its basename on every host`, () => {
98
+ const out = normaliseResultPaths([{ path: p }]);
99
+ expect(out[0].path).toBe('t.js');
100
+ });
101
+ }
102
+
103
+ it('never basenames a relative path, in either separator style', () => {
104
+ for (const p of ['sub/t.js', 'sub' + BACKSLASH + 't.js', './t.js']) {
105
+ expect(normaliseResultPaths([{ path: p }])[0].path).toBe(p);
106
+ }
107
+ });
108
+
53
109
  it('leaves an already-relative path untouched', () => {
54
110
  // Rewriting this would silently drop the "sub/" prefix and make two distinct
55
111
  // findings look like the same file.
@@ -168,13 +224,7 @@ describe('resident process — AC-SASTD-05: the daemon must outlive one call', (
168
224
  });
169
225
 
170
226
  it('the second call reuses the same daemon process', async () => {
171
- let semgrepAvailable = true;
172
- try {
173
- execFileSync('python', ['-c', 'import semgrep'], { stdio: 'ignore', timeout: 120000 });
174
- } catch {
175
- semgrepAvailable = false;
176
- }
177
- if (!semgrepAvailable) {
227
+ if (!hasSemgrep()) {
178
228
  // Skipping loudly beats a green test that proved nothing.
179
229
  console.warn('[sastd] semgrep not importable in this environment; residence test skipped');
180
230
  return;
@@ -268,6 +318,10 @@ describe('process exit — AC-SASTD-06: a one-shot caller must not hang', () =>
268
318
  });
269
319
 
270
320
  it('exits on its own after a single scan (no explicit process.exit)', () => {
321
+ if (!hasSemgrep()) {
322
+ console.warn('[sastd] semgrep not importable; one-shot-exit test skipped');
323
+ return;
324
+ }
271
325
  const script = `
272
326
  const { requestScan } = require(${JSON.stringify(
273
327
  path.join(__dirname, '..', 'sastd-client.js'),
@@ -363,6 +417,10 @@ describe('never greener — AC-SASTD-07: a thinner scan must not read as a clean
363
417
  // the helper directly, so deleting the helper's call site left it green: it
364
418
  // proved the function worked, not that anything used it. Reverting the call in
365
419
  // _handle now turns this red (verified).
420
+ if (!hasSemgrep()) {
421
+ console.warn('[sastd] semgrep not importable; coverage-guard handler test skipped');
422
+ return;
423
+ }
366
424
  const out = runPython(
367
425
  [
368
426
  'import semgrep.run_scan as rs',
@@ -382,6 +440,10 @@ describe('never greener — AC-SASTD-07: a thinner scan must not read as a clean
382
440
  it('the scan HANDLER leaves a fully-covering scan untouched', () => {
383
441
  // The negative half: a guard that fires on every scan would push every run onto
384
442
  // the direct path and make the daemon permanently useless while looking "safe".
443
+ if (!hasSemgrep()) {
444
+ console.warn('[sastd] semgrep not importable; full-coverage handler test skipped');
445
+ return;
446
+ }
385
447
  const out = runPython(
386
448
  [
387
449
  'import semgrep.run_scan as rs',
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-11-12T04:25:30.026Z",
5
+ "checked_at": "2026-11-12T06:13:24.150Z",
6
6
  "source": "network"
7
7
  }
@@ -37,6 +37,44 @@ function resolveDaemonPolicy(env = process.env) {
37
37
  return { enabled: false, reason: 'not_requested' };
38
38
  }
39
39
 
40
+ /**
41
+ * True when <p> is absolute in EITHER POSIX or Windows form.
42
+ *
43
+ * `path.isAbsolute` answers for the HOST platform only, which is the wrong
44
+ * question here: a scan's paths come from whichever machine semgrep ran on, and
45
+ * they cross a process boundary (the daemon) and sometimes a platform boundary
46
+ * (a reported path can be pasted between OSes). On Linux, `C:/repo/t.js` is not
47
+ * absolute, so the old check left it as-is and the report kept a full path --
48
+ * the exact "suddenly absolute path looks like a different finding" problem
49
+ * this function exists to prevent (#SASTD-02).
50
+ *
51
+ * @param {string} p
52
+ * @returns {boolean}
53
+ */
54
+ function isAnyAbsolute(p) {
55
+ if (path.isAbsolute(p)) return true;
56
+ // Windows drive-absolute: "C:\x" or "C:/x".
57
+ if (/^[A-Za-z]:[\\/]/.test(p)) return true;
58
+ // Windows UNC: "\\server\share" or the forward-slash form of it.
59
+ return /^[\\/]{2}[^\\/]/.test(p);
60
+ }
61
+
62
+ /**
63
+ * Basename of <p> under either path convention.
64
+ *
65
+ * `path.basename` is host-dependent too: on POSIX, `path.basename('C:/a/b.js')`
66
+ * returns `'b.js'` only by luck (the last separator happens to be '/'), while
67
+ * `path.basename('C:\\a\\b.js')` returns the whole string. Splitting on both
68
+ * separators is what makes the result the same whichever host runs it.
69
+ *
70
+ * @param {string} p
71
+ * @returns {string}
72
+ */
73
+ function anyBasename(p) {
74
+ const parts = p.split(/[\\/]+/).filter((s) => s.length > 0);
75
+ return parts.length > 0 ? parts[parts.length - 1] : p;
76
+ }
77
+
40
78
  /**
41
79
  * Normalise one semgrep result so the daemon's output matches the CLI's.
42
80
  *
@@ -51,9 +89,9 @@ function resolveDaemonPolicy(env = process.env) {
51
89
  * report prints the path, and a suddenly-absolute path would look like a
52
90
  * different finding to anyone reading it or diffing two runs.
53
91
  *
54
- * `path.basename` is used rather than a repo-relative computation: gate-10
55
- * already passes one directory per staged file and the CLI's own "relative"
56
- * path is the basename for those targets, confirmed equal on the same fixture.
92
+ * Basename is used rather than a repo-relative computation: gate-10 already
93
+ * passes one directory per staged file and the CLI's own "relative" path is the
94
+ * basename for those targets, confirmed equal on the same fixture.
57
95
  *
58
96
  * @param {Array<Record<string, unknown>>} results
59
97
  * @returns {Array<Record<string, unknown>>}
@@ -64,8 +102,8 @@ function normaliseResultPaths(results) {
64
102
  if (!r || typeof r.path !== 'string') return r;
65
103
  // Only rewrite absolute paths. A relative path is already what we want, and
66
104
  // basename-ing it would silently destroy a subdirectory prefix.
67
- if (!path.isAbsolute(r.path)) return r;
68
- return { ...r, path: path.basename(r.path) };
105
+ if (!isAnyAbsolute(r.path)) return r;
106
+ return { ...r, path: anyBasename(r.path) };
69
107
  });
70
108
  }
71
109
 
@@ -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.38.0.0
6
+ **Version:** 0.38.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Mock layering policy enforcement — Gate M3 of pre-push hook. Ensures integration tests use real implementations for internal dependencies, mock external dependencies, and annotate pending mocks with removal plans. Combines project scope scanning, mock decision engine, and per-file validation into a single pipeline.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **Gate M** (incremental mutation testing) + **Gate M2** helpers (test-layer detection used by `src/mock-policy/`). Pre-push quality gate. TypeScript-only; uses Stryker.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
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.38.0",
3
+ "version": "0.38.1",
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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.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.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.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.38.0",
3
+ "version": "0.38.1",
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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.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.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.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.38.0",
3
+ "version": "0.38.1",
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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.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.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.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.38.0",
3
+ "version": "0.38.1",
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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.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.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Clean Code & SOLID principles checker — **Gate 4** of pre-commit. 14 rules × 9 language adapters, SARIF 2.1.0 output. Houses the **Boy Scout Rule** enforcement engine (Gate 6) and warning-baseline storage.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.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.38.0.0
6
+ **Version:** 0.38.1.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.
@@ -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.38.0.0
6
+ **Version:** 0.38.1.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.