@boyingliu01/xp-gate 0.38.5 → 0.38.7

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 (52) hide show
  1. package/adapters/gate-7.sh +7 -2
  2. package/build-integrity/gate-10.ts +45 -27
  3. package/gate-7.sh +7 -2
  4. package/hooks/gate-7.sh +7 -2
  5. package/hooks/gate-entries/gate-0-entry.sh +249 -28
  6. package/hooks/gate-entries/gate-1-entry.sh +81 -3
  7. package/hooks/gate-entries/gate-10-entry.sh +7 -0
  8. package/hooks/gate-entries/gate-11-entry.sh +7 -0
  9. package/hooks/gate-entries/gate-12-entry.sh +7 -0
  10. package/hooks/gate-entries/gate-12b-entry.sh +7 -0
  11. package/hooks/gate-entries/gate-12c-entry.sh +7 -0
  12. package/hooks/gate-entries/gate-13-entry.sh +7 -0
  13. package/hooks/gate-entries/gate-5-entry.sh +48 -2
  14. package/hooks/gate-entries/gate-6-entry.sh +93 -2
  15. package/hooks/gate-entries/gate-7-entry.sh +7 -0
  16. package/hooks/gate-entries/gate-8-entry.sh +7 -0
  17. package/hooks/gate-entries/gate-9-entry.sh +7 -0
  18. package/lib/mattpocock-license-verdict.json +1 -1
  19. package/mock-policy/AGENTS.md +1 -1
  20. package/mutation/AGENTS.md +1 -1
  21. package/package.json +1 -1
  22. package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
  23. package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
  24. package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
  25. package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
  26. package/plugins/dsh/package.json +1 -1
  27. package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
  28. package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
  29. package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
  30. package/plugins/opencode/package.json +1 -1
  31. package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
  32. package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
  33. package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
  34. package/plugins/qoder/plugin.json +1 -1
  35. package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
  36. package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
  37. package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
  38. package/principles/AGENTS.md +1 -1
  39. package/principles/analyzer.ts +12 -1
  40. package/principles/config.ts +179 -0
  41. package/scripts/generate-mirrors.cjs +85 -28
  42. package/scripts/sync-package-content.js +5 -0
  43. package/skills/delphi-review/AGENTS.md +1 -1
  44. package/skills/sprint-flow/AGENTS.md +1 -1
  45. package/skills/test-specification-alignment/AGENTS.md +1 -1
  46. package/build-integrity/__tests__/ccn-refactor-gate10.test.ts +0 -133
  47. package/build-integrity/__tests__/gate-10.test.ts +0 -340
  48. package/build-integrity/__tests__/import-resolver.test.ts +0 -747
  49. package/build-integrity/__tests__/orchestrator.test.ts +0 -302
  50. package/build-integrity/__tests__/quote-masker.test.ts +0 -177
  51. package/skills/sprint-flow/__tests__/sprint-flow.test.cjs +0 -457
  52. package/skills/sprint-flow/__tests__/verify-sprint-state.test.bats +0 -70
@@ -10,6 +10,28 @@ export interface RuleConfig {
10
10
  methodThreshold?: number;
11
11
  }
12
12
 
13
+ /**
14
+ * A path-scoped severity relaxation (#806).
15
+ *
16
+ * `severity` in `rules` is one global value per rule, so a project could not both
17
+ * block a rule in production and keep it advisory in tests. Measured here with
18
+ * four rules promoted to `error`: 220 of 271 findings were in test files, so
19
+ * enabling production blocking would have blocked nearly every test edit -- and
20
+ * demoting the rule globally re-opened the defect the promotion existed to fix.
21
+ *
22
+ * These entries may only RELAX a rule (error -> warning/info). They never
23
+ * promote and never suppress: the violation is still reported, only its severity
24
+ * changes for matching paths. See `resolveSeverityForFile`.
25
+ */
26
+ export interface SeverityOverride {
27
+ // POSIX-style globs matched against the file path, e.g. any `__tests__`
28
+ // directory at any depth. Written as a line comment on purpose: a block
29
+ // comment cannot carry a globstar path, because the `/` after `**` closes it.
30
+ paths: string[];
31
+ /** `"<group>.<rule>"` -> target severity. */
32
+ rules: Record<string, string>;
33
+ }
34
+
13
35
  interface PrinciplesConfig {
14
36
  rules: {
15
37
  'clean-code': {
@@ -54,6 +76,8 @@ interface PrinciplesConfig {
54
76
  mode?: string;
55
77
  mediumProjectDefinition?: string;
56
78
  };
79
+ /** Path-scoped severity relaxations, applied in order (#806). */
80
+ overrides?: SeverityOverride[];
57
81
  }
58
82
 
59
83
  /** Config keys that carry a numeric threshold, per group. */
@@ -267,6 +291,10 @@ function mergeConfig(
267
291
  // just outside `rules`; found by the Delphi walkthrough.
268
292
  output: mergeSection(defaults.output, user.output),
269
293
  performance: mergeSection(defaults.performance, user.performance),
294
+ // Explicit: `...user` would carry the RAW block through unvalidated, so a
295
+ // malformed override would reach the resolver and fail there instead of
296
+ // being reported once, at load, with a message naming the bad entry.
297
+ overrides: parseOverrides(user.overrides, '.principlesrc'),
270
298
  rules: {
271
299
  'clean-code': mergeGroup(
272
300
  defaults.rules['clean-code'],
@@ -479,4 +507,155 @@ export function setActiveConfig(config: PrinciplesConfig): void {
479
507
  export function resetActiveConfig(): void {
480
508
  activeConfig = getDefaultConfig();
481
509
  activeConfigInstalled = false;
510
+ }
511
+
512
+ // ---------------------------------------------------------------------------
513
+ // Path-scoped severity overrides (#806)
514
+ // ---------------------------------------------------------------------------
515
+
516
+ /** Severity order, most to least severe. Used to forbid upward overrides. */
517
+ const SEVERITY_RANK: Record<string, number> = { error: 3, warning: 2, info: 1 };
518
+
519
+ /**
520
+ * Translate a POSIX-style glob to a RegExp.
521
+ *
522
+ * Deliberately small: this supports the two shapes the feature needs (`**` across
523
+ * directories, `*` within one segment) plus `?`. Anything richer belongs in a
524
+ * glob library, and pulling a dependency into `src/npm-package` is forbidden.
525
+ *
526
+ * `**` becomes `.*` (so `**​/__tests__/**` matches a nested test dir AND an
527
+ * absolute native path), `*` becomes `[^/]*`, and regex metacharacters are
528
+ * escaped so a literal `.` in `*.test.ts` does not match `a_test.ts`.
529
+ */
530
+ function globToRegExp(glob: string): RegExp {
531
+ let out = '';
532
+ for (let i = 0; i < glob.length; i++) {
533
+ const ch = glob[i];
534
+ if (ch === '*') {
535
+ if (glob[i + 1] === '*') {
536
+ out += '.*';
537
+ i++;
538
+ // `**/` may match zero segments (`src/__tests__/a.ts` for `/src/**`).
539
+ if (glob[i + 1] === '/') i++;
540
+ } else {
541
+ out += '[^/]*';
542
+ }
543
+ } else if (ch === '?') {
544
+ out += '[^/]';
545
+ } else if ('\\^$.|+()[]{}'.includes(ch)) {
546
+ out += `\\${ch}`;
547
+ } else {
548
+ out += ch;
549
+ }
550
+ }
551
+ return new RegExp(`^${out}$`);
552
+ }
553
+
554
+ /** Normalise a path for matching: native separators -> POSIX. */
555
+ function normaliseForMatch(filePath: string): string {
556
+ return filePath.replace(/\\/g, '/');
557
+ }
558
+
559
+ /**
560
+ * Whether `filePath` matches `glob`.
561
+ *
562
+ * Tries the whole path first, then every trailing segment run, so a repo-relative
563
+ * glob also matches a file handed to the checker as an absolute native path. Gate
564
+ * 4 passes repo-relative paths, but `--files` accepts absolute ones and the
565
+ * override must not silently stop applying because the caller changed shape.
566
+ */
567
+ function matchesGlob(filePath: string, glob: string): boolean {
568
+ const target = normaliseForMatch(filePath);
569
+ const re = globToRegExp(normaliseForMatch(glob));
570
+ if (re.test(target)) return true;
571
+ const segments = target.split('/');
572
+ for (let i = 1; i < segments.length; i++) {
573
+ if (re.test(segments.slice(i).join('/'))) return true;
574
+ }
575
+ return false;
576
+ }
577
+
578
+ /**
579
+ * The severity to report for one rule on one file.
580
+ *
581
+ * Starts from the declared severity (the caller passes what the rule would emit)
582
+ * and lets a matching override RELAX it. Relaxing only is enforced by rank, not
583
+ * by convention: a stray override must never turn an advisory rule into a
584
+ * blocker, because that would make the gate's reach depend on path globs nobody
585
+ * reviewed.
586
+ *
587
+ * Never suppresses the violation -- the finding is still reported. Only its
588
+ * severity changes, so the "passed with warnings" case stays distinguishable
589
+ * from "nothing found".
590
+ */
591
+ export function resolveSeverityForFile(
592
+ ruleId: string,
593
+ filePath: string,
594
+ declaredSeverity: string
595
+ ): string {
596
+ const overrides = activeConfig.overrides;
597
+ if (!Array.isArray(overrides) || overrides.length === 0) return declaredSeverity;
598
+
599
+ let effective = declaredSeverity;
600
+ const declaredRank = SEVERITY_RANK[declaredSeverity] ?? 0;
601
+ for (const entry of overrides) {
602
+ const target = entry?.rules?.[ruleId];
603
+ if (!target) continue;
604
+ const targetRank = SEVERITY_RANK[target];
605
+ // Unknown severity or an upward move: ignore rather than guess.
606
+ if (targetRank === undefined || targetRank >= declaredRank) continue;
607
+ if (!entry.paths.some(p => matchesGlob(filePath, p))) continue;
608
+ // A later override may relax further, never tighten back up.
609
+ if (targetRank < (SEVERITY_RANK[effective] ?? 0)) effective = target;
610
+ }
611
+ return effective;
612
+ }
613
+
614
+ /**
615
+ * Validate the `overrides` block, dropping malformed entries with a warning.
616
+ *
617
+ * A config typo must not take Gate 4 down, and it must not silently do nothing
618
+ * either -- both would be the silent-defaults defect this module removes. The
619
+ * same reasoning as `mergeRule`, applied to a nested structure.
620
+ */
621
+ function parseOverrides(raw: unknown, source: string): SeverityOverride[] {
622
+ if (raw === undefined) return [];
623
+ if (!Array.isArray(raw)) {
624
+ warn(`"overrides" in ${source} must be an array — ignored`);
625
+ return [];
626
+ }
627
+ const out: SeverityOverride[] = [];
628
+ for (const [index, entry] of raw.entries()) {
629
+ if (!isPlainObject(entry)) {
630
+ warn(`overrides[${index}] in ${source} must be an object — ignored`);
631
+ continue;
632
+ }
633
+ const paths = entry.paths;
634
+ if (!Array.isArray(paths) || paths.length === 0 || paths.some(p => typeof p !== 'string')) {
635
+ warn(`overrides[${index}].paths in ${source} must be a non-empty string array — ignored`);
636
+ continue;
637
+ }
638
+ const rules = entry.rules;
639
+ if (!isPlainObject(rules) || Object.keys(rules).length === 0) {
640
+ warn(`overrides[${index}].rules in ${source} must be a non-empty object — ignored`);
641
+ continue;
642
+ }
643
+ const cleanRules: Record<string, string> = {};
644
+ for (const [ruleId, severity] of Object.entries(rules)) {
645
+ if (typeof severity !== 'string' || !(SEVERITIES as readonly string[]).includes(severity)) {
646
+ warn(
647
+ `overrides[${index}].rules["${ruleId}"] in ${source} must be one of ${SEVERITIES.join('|')} — ignored`
648
+ );
649
+ continue;
650
+ }
651
+ if (!ruleId.includes('.')) {
652
+ warn(`overrides[${index}].rules["${ruleId}"] in ${source} must be "<group>.<rule>" — ignored`);
653
+ continue;
654
+ }
655
+ cleanRules[ruleId] = severity;
656
+ }
657
+ if (Object.keys(cleanRules).length === 0) continue;
658
+ out.push({ paths: paths as string[], rules: cleanRules });
659
+ }
660
+ return out;
482
661
  }
@@ -13,6 +13,16 @@
13
13
  * mirror-only fix that the next publish rolled back, and #717 sent a C#
14
14
  * SAST fix into a file no hook sourced.
15
15
  *
16
+ * P1-E step 2 adds the three trees that were still committed twice and are
17
+ * already byte-identical mirrors: `hooks/lib/` (21), `build-integrity/`
18
+ * (9) and `skills/` (67). Same argument, same contract, 97 more files that
19
+ * stop having an editorial second copy.
20
+ *
21
+ * `src/principles/` is NOT here yet, and the omission is deliberate: it is
22
+ * still being edited in place by another workstream, and two producers
23
+ * writing one tree means the content depends on which process ran last.
24
+ * It joins once that work lands.
25
+ *
16
26
  * P1-E step 1 moves the largest tree (`adapters/`, 199 files) out of
17
27
  * version control. Once it is generated, "edit the wrong copy" stops being
18
28
  * detectable-but-possible and becomes physically impossible: there is no
@@ -48,7 +58,10 @@ const REPO_ROOT = path.resolve(PKG_ROOT, '..', '..');
48
58
 
49
59
  /** Mirrors generated here, each with the canonical tree it comes from. */
50
60
  const GENERATED_TREES = Object.freeze([
51
- { mirror: 'adapters', canonical: path.join(REPO_ROOT, 'githooks', 'adapters') },
61
+ { mirror: 'adapters', canonical: path.join(REPO_ROOT, 'githooks', 'adapters'), sync: 'adapters' },
62
+ { mirror: 'hooks/lib', canonical: path.join(REPO_ROOT, 'githooks', 'lib'), sync: 'hooks' },
63
+ { mirror: 'build-integrity', canonical: path.join(REPO_ROOT, 'src', 'build-integrity'), sync: 'module' },
64
+ { mirror: 'skills', canonical: path.join(REPO_ROOT, 'skills'), sync: 'skills' },
52
65
  ]);
53
66
 
54
67
  function quiet(argv) {
@@ -75,46 +88,90 @@ function main(argv = process.argv.slice(2)) {
75
88
  if (!silent) process.stderr.write(`${message}\n`);
76
89
  };
77
90
 
78
- // 1. The tree this step owns. Absence of the canonical source is a defect in the
79
- // checkout, not a normal state, so it fails rather than skipping.
80
- const [{ mirror, canonical }] = GENERATED_TREES;
81
- if (!fs.existsSync(canonical)) {
82
- process.stderr.write(
83
- `[generate-mirrors] CANNOT GENERATE: canonical tree missing: ${canonical}\n`
84
- + ' The package would build without its adapters. Refusing to continue '
85
- + 'silently -- a package missing the files it ships is the failure this\n'
86
- + ' generator exists to prevent.\n',
87
- );
88
- return 1;
89
- }
91
+ // The canonical source of `adapters` is the tree this module was built for, so
92
+ // its absence is a defect in the checkout and fails. The other three are
93
+ // best-effort: `prepare` runs on every `npm install`, including from a sdist-less
94
+ // checkout where a sibling tree may legitimately be absent, and an install must
95
+ // not fail because of that. It must not SILENTLY SKIP either -- a package that
96
+ // ships without the files it promises is worse than a loud warning.
97
+ const REQUIRED = 'adapters';
98
+ const failures = [];
99
+ let syncSkillsHook;
100
+ let syncAdaptersHook;
101
+ let syncModulesHook;
102
+ let syncHooksHook;
90
103
 
91
- let sync;
92
104
  try {
93
105
  // Required lazily: sync-package-content.js runs its own main at require-time
94
106
  // when invoked directly, and the eager import would make every caller pay for
95
107
  // the skills/plugin discovery even when only the adapters mirror is wanted.
96
- // No eslint-disable needed: this file is CommonJS and `global-require` does
97
- // not fire here (the directive that used to sit on this line was itself the
98
- // reported problem -- an unused disable is a warning, and Gate 1 allows zero).
99
- ({ syncAdapters: sync } = require('./sync-package-content.js'));
108
+ const mod = require('./sync-package-content.js');
109
+ syncAdaptersHook = mod.syncAdapters;
110
+ syncModulesHook = mod.syncModules;
111
+ syncSkillsHook = mod.syncSkills;
112
+ syncHooksHook = mod.syncHooks;
100
113
  } catch (error) {
101
114
  process.stderr.write(`[generate-mirrors] cannot load sync-package-content.js: ${error.message}\n`);
102
115
  return 1;
103
116
  }
104
117
 
105
- if (typeof sync !== 'function') {
106
- process.stderr.write('[generate-mirrors] sync-package-content.js does not export syncAdapters\n');
107
- return 1;
108
- }
118
+ for (const tree of GENERATED_TREES) {
119
+ if (!fs.existsSync(tree.canonical)) {
120
+ if (tree.mirror === REQUIRED) {
121
+ process.stderr.write(
122
+ `[generate-mirrors] CANNOT GENERATE: canonical tree missing: ${tree.canonical}\n`
123
+ + ' The package would build without its adapters. Refusing to continue '
124
+ + 'silently -- a package missing the files it ships is the failure this\n'
125
+ + ' generator exists to prevent.\n',
126
+ );
127
+ return 1;
128
+ }
129
+ process.stderr.write(
130
+ `[generate-mirrors] WARNING: canonical tree missing, skipping ${tree.mirror}/: ${tree.canonical}\n`
131
+ + ' The published package would be missing these files. This is tolerated '
132
+ + 'only because `prepare` runs on installs from partial checkouts.\n',
133
+ );
134
+ failures.push(tree.mirror);
135
+ continue;
136
+ }
109
137
 
110
- const entries = sync();
111
- const files = countFiles(path.join(PKG_ROOT, mirror));
112
- if (files === 0) {
113
- process.stderr.write(`[generate-mirrors] ERROR: ${mirror}/ generated 0 files from ${canonical}\n`);
114
- return 1;
138
+ let produced = 0;
139
+ try {
140
+ if (tree.sync === 'adapters') {
141
+ syncAdaptersHook();
142
+ produced = 1;
143
+ } else if (tree.sync === 'hooks') {
144
+ // syncHooks copies githooks/* plus the whole githooks/lib/ subtree.
145
+ syncHooksHook();
146
+ produced = 1;
147
+ } else if (tree.sync === 'module') {
148
+ produced = syncModulesHook(tree.mirror);
149
+ } else if (tree.sync === 'skills') {
150
+ syncSkillsHook();
151
+ produced = 1;
152
+ }
153
+ } catch (error) {
154
+ process.stderr.write(`[generate-mirrors] ERROR generating ${tree.mirror}/: ${error.message}\n`);
155
+ return 1;
156
+ }
157
+
158
+ if (!produced) {
159
+ process.stderr.write(`[generate-mirrors] ERROR: sync for ${tree.mirror}/ reported nothing copied\n`);
160
+ return 1;
161
+ }
162
+
163
+ const mirrorDir = tree.mirror === 'hooks/lib'
164
+ ? path.join(PKG_ROOT, 'hooks', 'lib')
165
+ : path.join(PKG_ROOT, tree.mirror);
166
+ const files = countFiles(mirrorDir);
167
+ if (files === 0) {
168
+ process.stderr.write(`[generate-mirrors] ERROR: ${tree.mirror}/ generated 0 files from ${tree.canonical}\n`);
169
+ return 1;
170
+ }
171
+ say(`[generate-mirrors] ${tree.mirror}/ (${files} files)`);
115
172
  }
116
- say(`[generate-mirrors] ${mirror}/ (${entries} entries, ${files} files)`);
117
173
 
174
+ if (failures.length > 0) say(`[generate-mirrors] best-effort trees skipped: ${failures.join(', ')}`);
118
175
  return 0;
119
176
  }
120
177
 
@@ -609,5 +609,10 @@ if (require.main === module) {
609
609
  checkPreCommitDrift,
610
610
  syncHooks,
611
611
  syncAdapters,
612
+ // P1-E step 2: generate-mirrors.cjs produces these trees too, so the mirror
613
+ // stops being a second committed copy. Exported for that caller only; the
614
+ // require-time guards above stay untouched.
615
+ syncSkills,
616
+ syncModules,
612
617
  };
613
618
  }
@@ -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.5.0
6
+ **Version:** 0.38.7.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.5.0
6
+ **Version:** 0.38.7.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.5.0
6
+ **Version:** 0.38.7.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,133 +0,0 @@
1
- /**
2
- * @test CCN refactoring for Gate 10 (runGate10, main)
3
- * @intent Verify refactored functions maintain same behavior
4
- * @covers runGate10, main, parseGate10Args, printGate10Result
5
- */
6
-
7
- import { describe, it, expect, vi } from 'vitest';
8
-
9
- import { runGate10, parseGate10Args } from '../gate-10';
10
-
11
- vi.setConfig({ testTimeout: 30000 });
12
-
13
- describe('parseGate10Args', () => {
14
- it('parses --changed-files with comma-separated values', () => {
15
- const result = parseGate10Args([
16
- '--changed-files', 'src/a.ts,src/b.ts',
17
- ]);
18
- expect(result.changedFiles).toEqual(['src/a.ts', 'src/b.ts']);
19
- expect(result.projectRoot).toBe(process.cwd());
20
- expect(result.timeoutMs).toBe(60000);
21
- });
22
-
23
- it('parses --project-root', () => {
24
- const result = parseGate10Args([
25
- '--project-root', '/tmp/test',
26
- ]);
27
- expect(result.projectRoot).toBe('/tmp/test');
28
- });
29
-
30
- it('parses --timeout', () => {
31
- const result = parseGate10Args([
32
- '--timeout', '30000',
33
- ]);
34
- expect(result.timeoutMs).toBe(30000);
35
- });
36
-
37
- it('returns help=true when --help is passed', () => {
38
- const result = parseGate10Args(['--help']);
39
- expect(result.help).toBe(true);
40
- });
41
-
42
- it('trims and filters empty changed files', () => {
43
- const result = parseGate10Args([
44
- '--changed-files', 'a.ts,,,b.ts',
45
- ]);
46
- expect(result.changedFiles).toEqual(['a.ts', 'b.ts']);
47
- });
48
-
49
- it('returns empty array when no --changed-files', () => {
50
- const result = parseGate10Args([]);
51
- expect(result.changedFiles).toEqual([]);
52
- });
53
- });
54
-
55
- describe('runGate10 (status logic tests)', () => {
56
- it('blocks when tsc fails, pack passes, import passes', async () => {
57
- const result = await runGate10({
58
- changedFiles: [],
59
- projectRoot: '/nonexistent',
60
- timeoutMs: 30000,
61
- });
62
-
63
- // No tsconfig → tsc skip, no package.json → pack skip, no files → imports pass
64
- expect(result.exitCode).toBe(0);
65
- expect(result.checks.tsc.status).toBe('skip');
66
- expect(result.checks.pack.status).toBe('skip');
67
- expect(result.checks.imports.status).toBe('pass');
68
- });
69
-
70
- it('status is skip when ALL checks skip', () => {
71
- // Test via static analysis — status = skip when all are skip
72
- const result = {
73
- status: 'skip' as const,
74
- exitCode: 0,
75
- checks: {
76
- tsc: { status: 'skip' as const, message: '', durationMs: 0 },
77
- pack: { status: 'skip' as const, message: '', durationMs: 0 },
78
- imports: { status: 'skip' as const, message: '', durationMs: 0, violations: [] },
79
- },
80
- warnings: [],
81
- errors: [],
82
- };
83
- expect(result.status).toBe('skip');
84
- expect(result.exitCode).toBe(0);
85
- });
86
-
87
- it('status is pass when any check passes and none fail', () => {
88
- const result = {
89
- status: 'pass' as const,
90
- exitCode: 0,
91
- checks: {
92
- tsc: { status: 'pass' as const, message: '', durationMs: 0 },
93
- pack: { status: 'skip' as const, message: '', durationMs: 0 },
94
- imports: { status: 'skip' as const, message: '', durationMs: 0, violations: [] },
95
- },
96
- warnings: [],
97
- errors: [],
98
- };
99
- expect(result.status).toBe('pass');
100
- });
101
- });
102
-
103
- describe('collectErrors', () => {
104
- it('collects errors from failed checks', async () => {
105
- // Import the internal functions via the module
106
- const result = await runGate10({
107
- changedFiles: [],
108
- projectRoot: '/nonexistent',
109
- timeoutMs: 30000,
110
- });
111
- // In this path: no tsconfig (skip), no package.json (skip), no files (pass)
112
- expect(result.errors).toEqual([]);
113
- expect(result.warnings).toEqual([]);
114
- });
115
- });
116
-
117
- describe('resolveGate10Status', () => {
118
- it('returns block when any check fails', () => {
119
- const result = {
120
- status: 'block' as const,
121
- exitCode: 1,
122
- checks: {
123
- tsc: { status: 'fail' as const, message: 'error', durationMs: 0 },
124
- pack: { status: 'pass' as const, message: '', durationMs: 0 },
125
- imports: { status: 'pass' as const, message: '', durationMs: 0, violations: [] },
126
- },
127
- warnings: [],
128
- errors: ['tsc: error'],
129
- };
130
- expect(result.exitCode).toBe(1);
131
- expect(result.status).toBe('block');
132
- });
133
- });