@specdest/devkit 0.4.11 → 0.4.12

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.
@@ -127,6 +127,12 @@ export function createCanonicalCommandHandlers(projectRoot = process.cwd(), opti
127
127
  return 2;
128
128
  }
129
129
  const result = await canonicalCheck(projectRoot, source, parsed);
130
+ if (result.versionProblems?.length && !parsed.json) {
131
+ for (const problem of result.versionProblems) {
132
+ io.stderr.write(`FAIL stale rule ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash mismatch)' : ''}.\n`);
133
+ }
134
+ io.stderr.write('No validators executed. Run `pnpm exec specdest sync`, commit `.spd/installed.json`, then retry.\n');
135
+ }
130
136
  if (parsed.json) {
131
137
  io.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
132
138
  return result.exitCode;
@@ -1,5 +1,15 @@
1
1
  export declare function runWithConcurrency<T, R>(items: T[], limit: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
2
2
  export declare function canonicalCheck(projectRoot: string, source: any, options?: any): Promise<{
3
+ exitCode: number;
4
+ results: any;
5
+ executions: never[];
6
+ versionProblems: {
7
+ id: any;
8
+ installedVersion: any;
9
+ requiredVersion: any;
10
+ contentMismatch: boolean;
11
+ }[];
12
+ } | {
3
13
  exitCode: number;
4
14
  results: {
5
15
  [k: string]: any;
@@ -11,4 +21,5 @@ export declare function canonicalCheck(projectRoot: string, source: any, options
11
21
  stdout: any;
12
22
  stderr: any;
13
23
  }[];
24
+ versionProblems?: undefined;
14
25
  }>;
@@ -36,8 +36,37 @@ export async function runWithConcurrency(items, limit, worker) {
36
36
  export async function canonicalCheck(projectRoot, source, options = {}) {
37
37
  await assertPredefinedPackageState(projectRoot);
38
38
  const current = await readInstalledState(projectRoot);
39
- const { applicable, canonicalCheckRoot, checkerRuntimeRoot } = await loadCanonicalProjectContext(projectRoot, source, { offline: false, withCheckers: true, refresh: options.refresh ?? false });
39
+ const { applicable, canonicalCheckRoot, checkerRuntimeRoot } = await loadCanonicalProjectContext(projectRoot, source, { offline: false, withCheckers: true, refresh: true });
40
40
  const byId = new Map(applicable.map((entry) => [entry.id, entry]));
41
+ // Fail closed before invoking any checker if its installed contract is stale.
42
+ // A cached validator may otherwise report PASS against obsolete requirements.
43
+ const versionProblems = applicable.flatMap((entry) => {
44
+ if ((entry.enforcement ?? 'guidance') === 'guidance')
45
+ return [];
46
+ const installed = current.installed[entry.id];
47
+ if (!installed || installed.kind !== 'rule')
48
+ return [];
49
+ if (installed.version === entry.version && installed.contentHash === entry.contentHash)
50
+ return [];
51
+ return [
52
+ {
53
+ id: entry.id,
54
+ installedVersion: installed.version ?? 'unknown',
55
+ requiredVersion: entry.version,
56
+ contentMismatch: installed.version === entry.version,
57
+ },
58
+ ];
59
+ });
60
+ if (versionProblems.length) {
61
+ const results = Object.fromEntries(versionProblems.map((problem) => {
62
+ const message = `STALE RULE ${problem.id}: installed ${problem.installedVersion}, canonical ${problem.requiredVersion}${problem.contentMismatch ? ' (content hash differs)' : ''}. Run \`pnpm exec specdest sync\` and commit .spd/installed.json.`;
63
+ return [
64
+ problem.id,
65
+ { status: 'fail', exitCode: 1, stderr: message, diagnostics: [{ message }] },
66
+ ];
67
+ }));
68
+ return { exitCode: 1, results, executions: [], versionProblems };
69
+ }
41
70
  const results = {};
42
71
  const groups = new Map();
43
72
  const executor = options.executor ?? execute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@specdest/devkit",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "specdest": "dist/npm/cli.js"