@planu/cli 5.7.12 → 5.7.13
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.
- package/CHANGELOG.md +16 -0
- package/dist/.planu-build.json +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -1
- package/dist/cli/commands/doctor.js +51 -1
- package/dist/cli/commands/install.js +14 -0
- package/dist/config/registries/strict-audit-scripts.json +4 -0
- package/dist/engine/doctor/npm-cache-check.d.ts +10 -0
- package/dist/engine/doctor/npm-cache-check.js +109 -0
- package/dist/engine/ears-gate.d.ts +1 -0
- package/dist/engine/ears-gate.js +64 -2
- package/dist/engine/framework-detector.d.ts +1 -0
- package/dist/engine/framework-detector.js +1 -1
- package/dist/engine/handoff-artifacts/schemas.d.ts +2 -0
- package/dist/engine/handoff-artifacts/schemas.js +1 -1
- package/dist/engine/spec-grounding/contract.js +3 -1
- package/dist/engine/spec-grounding/grounding-entry-parser.js +1 -0
- package/dist/engine/validator/blast-radius-gate.js +95 -9
- package/dist/engine/validator/spec-compliance-runner.d.ts +1 -0
- package/dist/engine/validator/spec-compliance-runner.js +75 -25
- package/dist/engine/validator/strict-audits-gate.d.ts +3 -0
- package/dist/engine/validator/strict-audits-gate.js +74 -0
- package/dist/engine/validator/validation-report-writer.js +4 -2
- package/dist/tools/challenge-spec/scenarios-data.js +4 -3
- package/dist/tools/challenge-spec/scenarios-utils.d.ts +1 -2
- package/dist/tools/challenge-spec/scenarios-utils.js +13 -2
- package/dist/tools/register-spec-tools/core-spec-tools.js +5 -0
- package/dist/tools/update-status/batch.js +1 -0
- package/dist/tools/update-status/file-sync.d.ts +1 -1
- package/dist/tools/update-status/file-sync.js +4 -2
- package/dist/tools/update-status/index.js +4 -1
- package/dist/tools/update-status/transition-guard.d.ts +0 -1
- package/dist/tools/update-status/transition-guard.js +9 -5
- package/dist/tools/validate.js +67 -2
- package/dist/types/handoff-artifacts.d.ts +1 -1
- package/dist/types/installation.d.ts +10 -0
- package/dist/types/spec-format.d.ts +1 -0
- package/dist/types/spec-grounding.d.ts +1 -1
- package/dist/types/validation-evidence.d.ts +30 -1
- package/package.json +1 -1
- package/planu-plugin.json +1 -1
- package/src/i18n/messages/en.json +1 -1
- package/src/i18n/messages/es.json +1 -1
- package/src/i18n/messages/pt.json +1 -1
|
@@ -210,6 +210,11 @@ export function parseFrontmatterScenarios(raw) {
|
|
|
210
210
|
}
|
|
211
211
|
return scenarios;
|
|
212
212
|
}
|
|
213
|
+
function isAdapterFailure(adapter) {
|
|
214
|
+
return (adapter?.statuses.size === 0 &&
|
|
215
|
+
(adapter.detail.startsWith('runner failed') ||
|
|
216
|
+
adapter.detail.startsWith('unparseable runner output')));
|
|
217
|
+
}
|
|
213
218
|
function validRelativePath(candidate) {
|
|
214
219
|
if (candidate.trim() !== candidate ||
|
|
215
220
|
candidate.length === 0 ||
|
|
@@ -254,17 +259,20 @@ async function matchPlaywrightLink(reportedPath, links, projectPath) {
|
|
|
254
259
|
const candidates = links.filter((link) => link.path === reportedPath || link.path.endsWith(`/${reportedPath}`));
|
|
255
260
|
return candidates.length === 1 ? (candidates[0] ?? null) : null;
|
|
256
261
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
262
|
+
const VITEST_REPORT_ANCHOR = '{"numTotalTestSuites';
|
|
263
|
+
export function parseJsonOutput(stdout) {
|
|
264
|
+
for (const start of [stdout.lastIndexOf(VITEST_REPORT_ANCHOR), stdout.indexOf('{')]) {
|
|
265
|
+
if (start === -1) {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
return JSON.parse(stdout.slice(start));
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
267
274
|
}
|
|
275
|
+
return null;
|
|
268
276
|
}
|
|
269
277
|
function vitestFilePath(result) {
|
|
270
278
|
for (const candidate of [result.testFilePath, result.name, result.filepath, result.filePath]) {
|
|
@@ -290,9 +298,14 @@ function throwForTerminalProcessFailure(result) {
|
|
|
290
298
|
throw new ComplianceCommandTerminalError('COMPLIANCE_COMMAND_TIMED_OUT');
|
|
291
299
|
}
|
|
292
300
|
}
|
|
301
|
+
function isVitestReport(report) {
|
|
302
|
+
return (typeof report === 'object' &&
|
|
303
|
+
report !== null &&
|
|
304
|
+
Array.isArray(report.testResults));
|
|
305
|
+
}
|
|
293
306
|
async function runVitestAdapter(links, projectPath, signal) {
|
|
294
307
|
const statuses = new Map();
|
|
295
|
-
const
|
|
308
|
+
const runVitestOnce = () => runAbortableProcess('pnpm', [
|
|
296
309
|
'exec',
|
|
297
310
|
technologyValue('technology-vitest-a9127f'),
|
|
298
311
|
'--reporter=json',
|
|
@@ -304,15 +317,26 @@ async function runVitestAdapter(links, projectPath, signal) {
|
|
|
304
317
|
maxBufferBytes: 64 * 1024 * 1024,
|
|
305
318
|
signal,
|
|
306
319
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
320
|
+
const first = await runVitestOnce();
|
|
321
|
+
throwForTerminalProcessFailure(first);
|
|
322
|
+
const firstReport = first.error ? null : parseJsonOutput(first.stdout);
|
|
323
|
+
const attempt = isVitestReport(firstReport)
|
|
324
|
+
? { result: first, report: firstReport }
|
|
325
|
+
: await (async () => {
|
|
326
|
+
const second = await runVitestOnce();
|
|
327
|
+
throwForTerminalProcessFailure(second);
|
|
328
|
+
const secondReport = second.error ? null : parseJsonOutput(second.stdout);
|
|
329
|
+
return { result: second, report: isVitestReport(secondReport) ? secondReport : null };
|
|
330
|
+
})();
|
|
331
|
+
if (attempt.report === null) {
|
|
332
|
+
return {
|
|
333
|
+
statuses,
|
|
334
|
+
detail: attempt.result.error
|
|
335
|
+
? 'runner failed (retried once)'
|
|
336
|
+
: 'unparseable runner output (retried once)',
|
|
337
|
+
};
|
|
314
338
|
}
|
|
315
|
-
for (const testResult of report.testResults) {
|
|
339
|
+
for (const testResult of attempt.report.testResults) {
|
|
316
340
|
const reportedPath = vitestFilePath(testResult);
|
|
317
341
|
if (!reportedPath || !Array.isArray(testResult.assertionResults)) {
|
|
318
342
|
continue;
|
|
@@ -588,12 +612,13 @@ export async function runSpecCompliance(spec, projectPath, signal, canonicalProj
|
|
|
588
612
|
}
|
|
589
613
|
return `${technologyValue('technology-vitest-a9127f')} --reporter=json --run ${links.map((link) => link.path).join(' ')}`;
|
|
590
614
|
});
|
|
591
|
-
const
|
|
615
|
+
const scenarioResults = scenarios.map((scenario) => {
|
|
592
616
|
if (!scenario.tests?.length) {
|
|
593
617
|
return {
|
|
594
618
|
title: scenario.title,
|
|
595
619
|
verdict: 'missing',
|
|
596
620
|
evidence: ['No test links — scenario has no tests array'],
|
|
621
|
+
linkVerdicts: [],
|
|
597
622
|
};
|
|
598
623
|
}
|
|
599
624
|
const evidence = [];
|
|
@@ -614,34 +639,59 @@ export async function runSpecCompliance(spec, projectPath, signal, canonicalProj
|
|
|
614
639
|
evidence.push(`${source.path || '(missing path)'}: ${link?.error ?? 'malformed test link'}`);
|
|
615
640
|
return { verdict: 'missing', unverifiable: true };
|
|
616
641
|
}
|
|
642
|
+
const groupResult = statusByGroup.get(groupKey(link));
|
|
643
|
+
if (isAdapterFailure(groupResult)) {
|
|
644
|
+
evidence.push(`${link.path}: runner reported ${groupResult.detail}`);
|
|
645
|
+
return { verdict: 'indeterminate', unverifiable: true };
|
|
646
|
+
}
|
|
617
647
|
const adapter = statusByGroup.get(groupKey(link));
|
|
618
648
|
const verdict = adapter?.statuses.get(link.path) ?? 'missing';
|
|
619
649
|
evidence.push(`${link.path}: ${verdict === 'pass' ? 'passed' : verdict === 'fail' ? 'failed' : `not found in ${adapter?.detail ?? 'runner output'}`}`);
|
|
620
650
|
return { verdict, unverifiable: false };
|
|
621
651
|
});
|
|
622
652
|
const verdicts = linkResults.map((entry) => entry.verdict);
|
|
623
|
-
const
|
|
653
|
+
const hasFail = verdicts.some((item) => item === 'fail');
|
|
654
|
+
const hasMissing = verdicts.some((item) => item === 'missing');
|
|
624
655
|
const verdict = verdicts.every((item) => item === 'pass')
|
|
625
656
|
? 'pass'
|
|
626
|
-
:
|
|
627
|
-
? '
|
|
628
|
-
:
|
|
657
|
+
: !hasFail && !hasMissing
|
|
658
|
+
? 'indeterminate'
|
|
659
|
+
: hasMissing
|
|
660
|
+
? 'missing'
|
|
661
|
+
: 'fail';
|
|
662
|
+
const unverifiable = verdict === 'indeterminate' ||
|
|
663
|
+
linkResults.some((entry) => entry.verdict === 'missing' && entry.unverifiable);
|
|
629
664
|
return {
|
|
630
665
|
title: scenario.title,
|
|
631
666
|
verdict,
|
|
632
667
|
evidence,
|
|
668
|
+
linkVerdicts: verdicts,
|
|
633
669
|
...(unverifiable ? { unverifiable: true } : {}),
|
|
634
670
|
};
|
|
635
671
|
});
|
|
672
|
+
const perScenario = scenarioResults.map(({ linkVerdicts: _linkVerdicts, ...scenario }) => scenario);
|
|
636
673
|
const passCount = perScenario.filter((scenario) => scenario.verdict === 'pass').length;
|
|
674
|
+
const indeterminateCount = perScenario.filter((scenario) => scenario.verdict === 'indeterminate').length;
|
|
675
|
+
const scoredCount = scenarios.length - indeterminateCount;
|
|
676
|
+
const failedAdapters = [...statusByGroup.values()].filter(isAdapterFailure);
|
|
677
|
+
const affectedScenarios = scenarioResults.filter((scenario) => scenario.linkVerdicts.some((verdict) => verdict === 'indeterminate')).length;
|
|
637
678
|
return {
|
|
638
|
-
dimensionScore: Math.round((passCount /
|
|
679
|
+
dimensionScore: scoredCount > 0 ? Math.round((passCount / scoredCount) * 100) : 0,
|
|
639
680
|
perScenario,
|
|
640
681
|
command: commands.join(' && ') ||
|
|
641
682
|
`${technologyValue('technology-vitest-a9127f')} --reporter=json --run (no test files linked)`,
|
|
642
683
|
evidenceSource: executableEvidence.source,
|
|
643
684
|
ignoredCriteriaTitles: executableEvidence.ignoredCriteriaTitles,
|
|
644
685
|
doneDriftFindings,
|
|
686
|
+
...(failedAdapters.length > 0
|
|
687
|
+
? {
|
|
688
|
+
runnerFailure: {
|
|
689
|
+
kind: 'runner-output-unparseable',
|
|
690
|
+
detail: failedAdapters[0]?.detail ?? 'unparseable runner output',
|
|
691
|
+
indeterminateScenarios: affectedScenarios,
|
|
692
|
+
},
|
|
693
|
+
}
|
|
694
|
+
: {}),
|
|
645
695
|
};
|
|
646
696
|
}
|
|
647
697
|
export function findScenariosWithoutTests(raw) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RunStrictAuditsGateOptions, StrictAuditsGateResult } from '../../types/validation-evidence.js';
|
|
2
|
+
export declare function runStrictAuditsGate(projectPath: string, options: RunStrictAuditsGateOptions): Promise<StrictAuditsGateResult>;
|
|
3
|
+
//# sourceMappingURL=strict-audits-gate.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { runAbortableProcess } from '../abortable-process-runner.js';
|
|
4
|
+
import { pmRunner } from '../framework-detector.js';
|
|
5
|
+
import { resolveProjectCommandPlan } from '../project-command-runtime.js';
|
|
6
|
+
import { remainingExecutionMs } from '../execution/context.js';
|
|
7
|
+
import strictAuditScripts from '../../config/registries/strict-audit-scripts.json' with { type: 'json' };
|
|
8
|
+
const REGISTRY = strictAuditScripts;
|
|
9
|
+
const MAX_FINDING_LINES = 20;
|
|
10
|
+
function fallbackFindingLine(script, result) {
|
|
11
|
+
const signal = result.signal !== null ? ` (signal ${result.signal})` : '';
|
|
12
|
+
const error = result.error !== undefined ? `: ${result.error.message}` : '';
|
|
13
|
+
return `${script} exited with status ${String(result.status)}${signal}${error}`;
|
|
14
|
+
}
|
|
15
|
+
function findingsForFailure(script, result) {
|
|
16
|
+
const lines = `${result.stdout}\n${result.stderr}`
|
|
17
|
+
.split('\n')
|
|
18
|
+
.map((line) => line.trim())
|
|
19
|
+
.filter((line) => line.length > 0)
|
|
20
|
+
.slice(0, MAX_FINDING_LINES);
|
|
21
|
+
if (lines.length === 0) {
|
|
22
|
+
return [{ script, line: fallbackFindingLine(script, result) }];
|
|
23
|
+
}
|
|
24
|
+
return lines.map((line) => ({ script, line }));
|
|
25
|
+
}
|
|
26
|
+
function noStrictScriptsResult() {
|
|
27
|
+
return { skipped: 'no-strict-scripts', executedScripts: [], passed: true, findings: [] };
|
|
28
|
+
}
|
|
29
|
+
function deadlineExceededResult(executedScripts, findings) {
|
|
30
|
+
return { skipped: 'deadline-exceeded', executedScripts, passed: false, findings };
|
|
31
|
+
}
|
|
32
|
+
export async function runStrictAuditsGate(projectPath, options) {
|
|
33
|
+
let pkg;
|
|
34
|
+
try {
|
|
35
|
+
const raw = readFileSync(join(projectPath, 'package.json'), 'utf-8');
|
|
36
|
+
pkg = JSON.parse(raw);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return noStrictScriptsResult();
|
|
40
|
+
}
|
|
41
|
+
const scripts = pkg.scripts ?? {};
|
|
42
|
+
const declared = REGISTRY.scripts.filter((script) => typeof scripts[script] === 'string');
|
|
43
|
+
if (declared.length === 0) {
|
|
44
|
+
return noStrictScriptsResult();
|
|
45
|
+
}
|
|
46
|
+
const packageManagerName = typeof pkg.packageManager === 'string' ? (pkg.packageManager.split('@')[0] ?? null) : null;
|
|
47
|
+
const runner = pmRunner(packageManagerName);
|
|
48
|
+
const runProcess = options.runProcess ?? runAbortableProcess;
|
|
49
|
+
const deadlineAt = Date.now() + options.timeoutMs;
|
|
50
|
+
const executedScripts = [];
|
|
51
|
+
const findings = [];
|
|
52
|
+
for (const script of declared) {
|
|
53
|
+
const budgetMs = Math.min(deadlineAt - Date.now(), remainingExecutionMs());
|
|
54
|
+
if (budgetMs <= 0) {
|
|
55
|
+
return deadlineExceededResult(executedScripts, findings);
|
|
56
|
+
}
|
|
57
|
+
const plan = resolveProjectCommandPlan(projectPath, `${runner} run ${script}`);
|
|
58
|
+
const result = await runProcess(plan.executable, plan.args, {
|
|
59
|
+
cwd: projectPath,
|
|
60
|
+
timeoutMs: budgetMs,
|
|
61
|
+
maxBufferBytes: 8 * 1024 * 1024,
|
|
62
|
+
signal: options.signal,
|
|
63
|
+
});
|
|
64
|
+
executedScripts.push(script);
|
|
65
|
+
if (result.timedOut || result.aborted) {
|
|
66
|
+
return deadlineExceededResult(executedScripts, findings);
|
|
67
|
+
}
|
|
68
|
+
if (result.error !== undefined || result.status !== 0) {
|
|
69
|
+
findings.push(...findingsForFailure(script, result));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { skipped: null, executedScripts, passed: findings.length === 0, findings };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=strict-audits-gate.js.map
|
|
@@ -182,13 +182,15 @@ function buildSpecComplianceGate(result) {
|
|
|
182
182
|
reason: `No executable scenarios declared (evidence source: ${result.evidenceSource ?? 'none'}) — add BDD criteria TEST: markers or frontmatter scenarios before done.${ignoredNote}`,
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
-
const passed = result.dimensionScore === 100;
|
|
185
|
+
const passed = result.dimensionScore === 100 && result.runnerFailure === undefined;
|
|
186
186
|
return {
|
|
187
187
|
name: 'spec-compliance',
|
|
188
188
|
passed,
|
|
189
189
|
reason: passed
|
|
190
190
|
? ignoredNote.trim() || undefined
|
|
191
|
-
:
|
|
191
|
+
: result.runnerFailure
|
|
192
|
+
? `Test runner output was unusable (${result.runnerFailure.detail}); ${String(result.runnerFailure.indeterminateScenarios)} scenario(s) are indeterminate — re-run validate.${ignoredNote}`
|
|
193
|
+
: `Expected all executable scenarios to pass, got ${String(result.dimensionScore)}.${ignoredNote}`,
|
|
192
194
|
};
|
|
193
195
|
}
|
|
194
196
|
function toValidationReportCompliance(result) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// tools/challenge-spec/scenarios-data.ts — Data consistency and partial write scenarios
|
|
2
|
-
import {
|
|
2
|
+
import { contentMentions, hasAnyAffirmedMatch, hasApplicationCacheEvidence, } from './scenarios-utils.js';
|
|
3
3
|
const GIT_CHECKOUT_PREFIX = '(?<!\\b(?:git|branch|worktree|main)\\s)';
|
|
4
4
|
const WRITE_SIGNALS = [
|
|
5
5
|
/\b(transaction|persist|database write|save record|create record|update record|delete record)\b/i,
|
|
@@ -9,7 +9,7 @@ const WRITE_SIGNALS = [
|
|
|
9
9
|
/\bplaces?\s+an\s+order\b/i,
|
|
10
10
|
new RegExp(`${GIT_CHECKOUT_PREFIX}\\bcheckout\\s+(?:flow|process|order|endpoint)\\b`, 'i'),
|
|
11
11
|
];
|
|
12
|
-
const
|
|
12
|
+
const CACHE_FRESHNESS_SIGNALS = [/\b(?:real-time|realtime|websocket|stale data)\b/i];
|
|
13
13
|
const DUPLICATE_OPERATION_SIGNALS = [
|
|
14
14
|
/\bsubmit(?:s|ted|ting)?\s+(?:a\s+|the\s+)?form\b/i,
|
|
15
15
|
/\bform\s+submission\b/i,
|
|
@@ -40,7 +40,8 @@ export function generateDataConsistencyScenarios(_spec, content, _knowledge) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
// Stale data
|
|
43
|
-
if (
|
|
43
|
+
if (hasApplicationCacheEvidence(content) ||
|
|
44
|
+
hasAnyAffirmedMatch(content, CACHE_FRESHNESS_SIGNALS)) {
|
|
44
45
|
scenarios.push({
|
|
45
46
|
scenario: 'Stale data served from cache after underlying data changes',
|
|
46
47
|
probability: 'high',
|
|
@@ -28,8 +28,7 @@ export interface ChallengeCapabilities {
|
|
|
28
28
|
numericInput: boolean;
|
|
29
29
|
rollout: boolean;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
export declare const CACHE_ACTION_SIGNALS: RegExp[];
|
|
31
|
+
export declare function hasApplicationCacheEvidence(text: string): boolean;
|
|
33
32
|
/** Boundary-aware, affirmative replacement for advisory substring checks. */
|
|
34
33
|
export declare function contentMentions(content: string, keywords: string[]): boolean;
|
|
35
34
|
export declare function detectChallengeCapabilities(spec: Spec, specContent: string): ChallengeCapabilities;
|
|
@@ -107,8 +107,6 @@ const CAPABILITY_SIGNALS = {
|
|
|
107
107
|
/\bdeployment\s+strategy\b/i,
|
|
108
108
|
],
|
|
109
109
|
};
|
|
110
|
-
/** Shared with scenarios-data.ts so the stale-cache scenario uses the same caching-action anchor. */
|
|
111
|
-
export const CACHE_ACTION_SIGNALS = CAPABILITY_SIGNALS.cache;
|
|
112
110
|
const AUTHENTICATION_BARE_TOKEN_RE = /\bauth(?:entication|enticate)?\b/i;
|
|
113
111
|
// A bare "auth" token next to registry/package-manager vocabulary describes a
|
|
114
112
|
// dependency-registry failure, not a product authentication contract, in either
|
|
@@ -150,6 +148,18 @@ function hasProductDatabaseEvidence(contract) {
|
|
|
150
148
|
}
|
|
151
149
|
return contract.split(/[.;\n]/).some(hasDatabasePersistenceEvidenceInClause);
|
|
152
150
|
}
|
|
151
|
+
const CLAUSE_BOUNDARY_RE = /[;\n]|\.(?=\s|$)/;
|
|
152
|
+
const PACKAGE_MANAGER_CACHE_TOKEN_RE = /\b(?:npm|npx|pnpm|yarn|bun|pip|cargo|composer|brew|homebrew|gradle|maven)\b|_cacache|node_modules\/\.cache/i;
|
|
153
|
+
const APPLICATION_CACHE_CONTRACT_RE = /\b(?:invalidat(?:e|es|ed|ing|ion)|stale|ttl|expir(?:e|es|ed|ing|ation|y)|evict(?:s|ed|ing|ion)?|memoi[sz]\w*|redis|memcached|freshness)\b/i;
|
|
154
|
+
function isPackageManagerCacheClause(clause) {
|
|
155
|
+
return PACKAGE_MANAGER_CACHE_TOKEN_RE.test(clause) && !APPLICATION_CACHE_CONTRACT_RE.test(clause);
|
|
156
|
+
}
|
|
157
|
+
export function hasApplicationCacheEvidence(text) {
|
|
158
|
+
return text
|
|
159
|
+
.split(CLAUSE_BOUNDARY_RE)
|
|
160
|
+
.some((clause) => !isPackageManagerCacheClause(clause) &&
|
|
161
|
+
hasAnyAffirmedMatch(clause, CAPABILITY_SIGNALS.cache));
|
|
162
|
+
}
|
|
153
163
|
const NETWORK_API_BARE_TOKEN_RE = /(?<!compiler\s)\bapi\b(?!\s+(?:compatibility|surface|package|type))/i;
|
|
154
164
|
const NETWORK_API_CONTEXT_RE = /\b(?:endpoint|route|http|https|rest|fetch|url|socket|request|response|timeout|retry|webhook|payload|keys?)\b(?:\W+\w+){0,6}?\W+api\b|\bapi\b(?:\W+\w+){0,6}?\W+\b(?:endpoint|route|http|https|rest|fetch|url|socket|request|response|timeout|retry|webhook|payload|keys?)\b/i;
|
|
155
165
|
function hasProductNetworkEvidence(contract) {
|
|
@@ -195,6 +205,7 @@ export function detectChallengeCapabilities(spec, specContent) {
|
|
|
195
205
|
capabilities.authentication = hasProductAuthenticationEvidence(contract);
|
|
196
206
|
capabilities.networkApi = hasProductNetworkEvidence(contract);
|
|
197
207
|
capabilities.database = hasProductDatabaseEvidence(contract);
|
|
208
|
+
capabilities.cache = hasApplicationCacheEvidence(contract);
|
|
198
209
|
return capabilities;
|
|
199
210
|
}
|
|
200
211
|
export function hasAnyChallengeCapability(capabilities, names) {
|
|
@@ -459,6 +459,11 @@ export function registerCoreSpecTools(server) {
|
|
|
459
459
|
.max(10_000)
|
|
460
460
|
.optional()
|
|
461
461
|
.describe('Optional notes for each transition. Max 10000 characters.'),
|
|
462
|
+
reason: z
|
|
463
|
+
.string()
|
|
464
|
+
.max(2000)
|
|
465
|
+
.optional()
|
|
466
|
+
.describe('Must be ≥30 and <=2000 chars. Forwarded verbatim to every per-spec transition; required by reverse transitions (discarded→draft, done→implementing).'),
|
|
462
467
|
evidence: z
|
|
463
468
|
.record(z.string(), z.object({
|
|
464
469
|
modelTierUsed: z
|
|
@@ -120,6 +120,7 @@ export async function handleUpdateStatusBatch(input) {
|
|
|
120
120
|
projectId: resolved.projectId,
|
|
121
121
|
projectPath: resolved.projectPath,
|
|
122
122
|
reviewNotes: input.reviewNotes,
|
|
123
|
+
reason: input.reason,
|
|
123
124
|
});
|
|
124
125
|
const message = firstText(result);
|
|
125
126
|
if (result.isError === true) {
|
|
@@ -10,7 +10,7 @@ export interface FrontmatterSyncWarning {
|
|
|
10
10
|
specPath: string | null;
|
|
11
11
|
reason: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function syncSpecFiles(updatedSpec: Spec, _currentStatus: SpecStatus, newStatus: SpecStatus, projectPath?: string, qualityWarnings?: readonly string[]): Promise<{
|
|
13
|
+
export declare function syncSpecFiles(updatedSpec: Spec, _currentStatus: SpecStatus, newStatus: SpecStatus, projectPath?: string, qualityWarnings?: readonly string[], frozenTransitionReason?: string): Promise<{
|
|
14
14
|
warning?: FrontmatterSyncWarning;
|
|
15
15
|
title?: string;
|
|
16
16
|
driftReconciled?: boolean;
|
|
@@ -132,7 +132,7 @@ function assertSpecBodyIntegrity(args) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
const FROZEN_TERMINAL_STATUSES = ['done', 'discarded'];
|
|
135
|
-
export async function syncSpecFiles(updatedSpec, _currentStatus, newStatus, projectPath, qualityWarnings = []) {
|
|
135
|
+
export async function syncSpecFiles(updatedSpec, _currentStatus, newStatus, projectPath, qualityWarnings = [], frozenTransitionReason) {
|
|
136
136
|
let warning;
|
|
137
137
|
let refreshedTitle;
|
|
138
138
|
let transitionSpecPath;
|
|
@@ -171,7 +171,9 @@ export async function syncSpecFiles(updatedSpec, _currentStatus, newStatus, proj
|
|
|
171
171
|
newStatus,
|
|
172
172
|
specId: updatedSpec.id,
|
|
173
173
|
});
|
|
174
|
-
await atomicWriteFile(transitionSpecPath, updatedContent)
|
|
174
|
+
await atomicWriteFile(transitionSpecPath, updatedContent, ...(frozenTransitionReason !== undefined && frozenTransitionReason.trim().length >= 30
|
|
175
|
+
? [{ forceEdit: { reason: frozenTransitionReason } }]
|
|
176
|
+
: []));
|
|
175
177
|
// SPEC-544: Auto-stage spec.md after writing so it's included in the user's next commit
|
|
176
178
|
// SPEC-575: Auto-commit staged planu/ docs (idempotent, safe-fail)
|
|
177
179
|
// Commit message must reflect the actual transition — 'mark-done' is only
|
|
@@ -653,7 +653,10 @@ async function commitTransitionWithNarrowLock(args) {
|
|
|
653
653
|
expectedSpec: freshSpec,
|
|
654
654
|
});
|
|
655
655
|
const updatedSpec = transitionRecord.spec;
|
|
656
|
-
const
|
|
656
|
+
const frozenReasonArgs = isReverseTransition(args.originalStatus, args.newStatus)
|
|
657
|
+
? [args.options.reason]
|
|
658
|
+
: [];
|
|
659
|
+
const syncResult = await syncSpecFiles(updatedSpec, args.originalStatus, args.newStatus, args.projectPath, args.qualityWarnings, ...frozenReasonArgs);
|
|
657
660
|
if (!syncResult.warning) {
|
|
658
661
|
if (syncResult.title) {
|
|
659
662
|
updatedSpec.title = syncResult.title;
|
|
@@ -12,7 +12,6 @@ import type { Spec } from '../../types/spec/core.js';
|
|
|
12
12
|
export declare const VALID_TRANSITIONS: Record<SpecStatus, SpecStatus[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Allowed reverse transition pairs (from terminal state back to active).
|
|
15
|
-
* Only these two pairs are supported. Any other reverse pair is rejected.
|
|
16
15
|
*/
|
|
17
16
|
export declare const REVERSE_TRANSITIONS: (readonly [SpecStatus, SpecStatus])[];
|
|
18
17
|
/**
|
|
@@ -27,7 +27,7 @@ export const VALID_TRANSITIONS = {
|
|
|
27
27
|
review: ['draft', 'approved', 'discarded'],
|
|
28
28
|
approved: ['draft', 'review', 'implementing', 'discarded'],
|
|
29
29
|
implementing: ['approved', 'done', 'discarded'],
|
|
30
|
-
done: ['implementing'], // SPEC-733: reverse transition with mandatory reason
|
|
30
|
+
done: ['implementing', 'discarded'], // SPEC-733: reverse transition with mandatory reason
|
|
31
31
|
discarded: ['draft'], // SPEC-733: reverse transition with mandatory reason
|
|
32
32
|
};
|
|
33
33
|
// ---------------------------------------------------------------------------
|
|
@@ -35,12 +35,15 @@ export const VALID_TRANSITIONS = {
|
|
|
35
35
|
// ---------------------------------------------------------------------------
|
|
36
36
|
/**
|
|
37
37
|
* Allowed reverse transition pairs (from terminal state back to active).
|
|
38
|
-
* Only these two pairs are supported. Any other reverse pair is rejected.
|
|
39
38
|
*/
|
|
40
39
|
export const REVERSE_TRANSITIONS = [
|
|
41
40
|
['done', 'implementing'],
|
|
41
|
+
['done', 'discarded'],
|
|
42
42
|
['discarded', 'draft'],
|
|
43
43
|
];
|
|
44
|
+
function allowedReversePairs() {
|
|
45
|
+
return REVERSE_TRANSITIONS.map(([from, to]) => `${from}→${to}`).join(', ');
|
|
46
|
+
}
|
|
44
47
|
/**
|
|
45
48
|
* Returns true if the (from, to) pair is a whitelisted reverse transition.
|
|
46
49
|
*/
|
|
@@ -57,15 +60,15 @@ export function validateReverseTransition(input) {
|
|
|
57
60
|
if (!isReverseTransition(from, to)) {
|
|
58
61
|
return {
|
|
59
62
|
ok: false,
|
|
60
|
-
error: `Reverse transition ${from} → ${to} is not supported. Allowed:
|
|
61
|
-
fixHint:
|
|
63
|
+
error: `Reverse transition ${from} → ${to} is not supported. Allowed: ${allowedReversePairs()}.`,
|
|
64
|
+
fixHint: `Only ${allowedReversePairs()} are supported reverse transitions.`,
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
if (!reason || reason.trim().length < 30) {
|
|
65
68
|
return {
|
|
66
69
|
ok: false,
|
|
67
70
|
error: `Reverse transition ${from} → ${to} requires reason (≥ 30 chars). Received: "${reason ?? ''}" (${String(reason?.trim().length ?? 0)} chars).`,
|
|
68
|
-
fixHint:
|
|
71
|
+
fixHint: `Reverse transitions (${allowedReversePairs()}) require reason (>= 30 chars). Example: "Regression found in prod traced to AC#3 — reopening to fix."`,
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
return { ok: true };
|
|
@@ -107,6 +110,7 @@ export function checkTransition(currentStatus, newStatus) {
|
|
|
107
110
|
text: ti('spec.invalidTransition', {
|
|
108
111
|
from: currentStatus,
|
|
109
112
|
to: newStatus,
|
|
113
|
+
valid: validNextStates.join(', '),
|
|
110
114
|
}),
|
|
111
115
|
},
|
|
112
116
|
],
|
package/dist/tools/validate.js
CHANGED
|
@@ -74,6 +74,7 @@ import { isAbsolute, join } from 'node:path';
|
|
|
74
74
|
import { writeImplementationReviewReport } from '../engine/validator/validation-report-writer.js';
|
|
75
75
|
import { runReliabilityGate } from '../engine/validator/reliability-gate.js';
|
|
76
76
|
import { runBlastRadiusGate } from '../engine/validator/blast-radius-gate.js';
|
|
77
|
+
import { runStrictAuditsGate } from '../engine/validator/strict-audits-gate.js';
|
|
77
78
|
import { collectDeclaredSpecFiles } from '../engine/validator/spec-compliance-runner.js';
|
|
78
79
|
import { buildGraphCoverageReport, formatGraphCoverageText } from './validate-graph-coverage.js';
|
|
79
80
|
import { buildMinimalityReport } from './validate-minimality.js';
|
|
@@ -82,6 +83,7 @@ import { runLintCheck } from './validate-lint.js';
|
|
|
82
83
|
import { checkPlanuUncommittedChanges, runAssuranceGates } from './validate-assurance.js';
|
|
83
84
|
import { applyValidateStructuredCompat } from './validate-structured-compat.js';
|
|
84
85
|
import { getToolExecutionSignal } from './safe-handler.js';
|
|
86
|
+
import { remainingExecutionMs } from '../engine/execution/context.js';
|
|
85
87
|
import { DurableJobRuntime, publicJobCursor } from '../engine/execution/job-runtime.js';
|
|
86
88
|
import { scheduleValidateJobExecution } from '../engine/execution/validate-job-executor.js';
|
|
87
89
|
import { createPendingValidationSubmission } from '../engine/validation/durable-validation.js';
|
|
@@ -91,7 +93,7 @@ import { getRuntimePolicy } from '../engine/runtime-policy.js';
|
|
|
91
93
|
import { resolveValidationWorktree, ValidationWorktreeError, } from '../engine/validation/validation-worktree.js';
|
|
92
94
|
// Re-export for external use (SPEC-018)
|
|
93
95
|
export { validateContractCompliance };
|
|
94
|
-
const VALIDATION_GATE_TOTAL =
|
|
96
|
+
const VALIDATION_GATE_TOTAL = 11;
|
|
95
97
|
const GATE_DEADLINE_EXEMPT_PHASES = new Set(['lint', 'compliance']);
|
|
96
98
|
async function runWithGateDeadline(phase, command, work) {
|
|
97
99
|
if (GATE_DEADLINE_EXEMPT_PHASES.has(phase)) {
|
|
@@ -111,6 +113,58 @@ async function runWithGateDeadline(phase, command, work) {
|
|
|
111
113
|
clearTimeout(timer);
|
|
112
114
|
}
|
|
113
115
|
}
|
|
116
|
+
function computeIntegrationTimeoutMs() {
|
|
117
|
+
const blastRadiusTimeoutMs = getRuntimePolicy().validation.blastRadiusTimeoutMs;
|
|
118
|
+
return Math.max(0, Math.min(blastRadiusTimeoutMs, remainingExecutionMs() - blastRadiusTimeoutMs));
|
|
119
|
+
}
|
|
120
|
+
function isBlastRadiusPassed(blastRadiusGate) {
|
|
121
|
+
return blastRadiusGate.passed && blastRadiusGate.warningReason === null;
|
|
122
|
+
}
|
|
123
|
+
function blastRadiusIntegrationWarnings(blastRadiusGate) {
|
|
124
|
+
return blastRadiusGate.warningReason === null
|
|
125
|
+
? []
|
|
126
|
+
: [
|
|
127
|
+
{
|
|
128
|
+
file: 'blast-radius',
|
|
129
|
+
line: 0,
|
|
130
|
+
severity: 'warning',
|
|
131
|
+
rule: blastRadiusGate.warningReason,
|
|
132
|
+
message: 'Integration importers of the changed files were not exercised within the validate budget.',
|
|
133
|
+
suggestion: 'Run `npx vitest related --run <changed files>` without PLANU_EXCLUDE_INTEGRATION_TESTS, or raise validation.blastRadiusTimeoutMs, before marking this spec done.',
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
function strictAuditsQualityIssues(strictAuditsGate) {
|
|
138
|
+
const findingIssues = strictAuditsGate.findings.map((finding) => ({
|
|
139
|
+
file: finding.script,
|
|
140
|
+
line: 0,
|
|
141
|
+
severity: 'critical',
|
|
142
|
+
rule: 'strict-audits',
|
|
143
|
+
message: `Strict audit ${finding.script} failed: ${finding.line}`,
|
|
144
|
+
suggestion: 'Fix the strict audit finding before marking this spec done — the release runs the same script.',
|
|
145
|
+
}));
|
|
146
|
+
if (strictAuditsGate.skipped !== 'deadline-exceeded') {
|
|
147
|
+
return findingIssues;
|
|
148
|
+
}
|
|
149
|
+
return [
|
|
150
|
+
...findingIssues,
|
|
151
|
+
{
|
|
152
|
+
file: 'strict-audits',
|
|
153
|
+
line: 0,
|
|
154
|
+
severity: 'warning',
|
|
155
|
+
rule: 'strict-audits-skipped',
|
|
156
|
+
message: `Strict audits stopped at the validate deadline after: ${strictAuditsGate.executedScripts.join(', ')}`,
|
|
157
|
+
suggestion: 'Run `pnpm check:strict` locally before marking this spec done.',
|
|
158
|
+
},
|
|
159
|
+
];
|
|
160
|
+
}
|
|
161
|
+
function strictAuditsSuggestions(strictAuditsGate) {
|
|
162
|
+
return strictAuditsGate.passed
|
|
163
|
+
? []
|
|
164
|
+
: [
|
|
165
|
+
`Strict audits failed: ${String(strictAuditsGate.findings.length)} finding(s). Fix before marking as done.`,
|
|
166
|
+
];
|
|
167
|
+
}
|
|
114
168
|
export function createValidationStageRunner(onProgress) {
|
|
115
169
|
const startedAt = Date.now();
|
|
116
170
|
let completedGates = 0;
|
|
@@ -384,6 +438,7 @@ export async function executeValidate(args, server, onProgress) {
|
|
|
384
438
|
];
|
|
385
439
|
return runBlastRadiusGate(projectPath, candidateFiles, {
|
|
386
440
|
timeoutMs: getRuntimePolicy().validation.blastRadiusTimeoutMs,
|
|
441
|
+
integrationTimeoutMs: computeIntegrationTimeoutMs(),
|
|
387
442
|
signal: getToolExecutionSignal(),
|
|
388
443
|
});
|
|
389
444
|
});
|
|
@@ -393,6 +448,10 @@ export async function executeValidate(args, server, onProgress) {
|
|
|
393
448
|
specId,
|
|
394
449
|
maximumTimeoutMs: getRuntimePolicy().validation.durableLintTimeoutMs,
|
|
395
450
|
}));
|
|
451
|
+
const strictAuditsGate = await runStage('strict-audits', 'strict release audits declared by the project', () => runStrictAuditsGate(projectPath, {
|
|
452
|
+
timeoutMs: getRuntimePolicy().validation.durableLintTimeoutMs,
|
|
453
|
+
signal: getToolExecutionSignal(),
|
|
454
|
+
}));
|
|
396
455
|
const { assuranceGates, minimalityReport } = await runStage('assurance', 'validate assurance and minimality', async () => ({
|
|
397
456
|
assuranceGates: runAssuranceGates(projectPath),
|
|
398
457
|
minimalityReport: await buildMinimalityReport({
|
|
@@ -426,7 +485,8 @@ export async function executeValidate(args, server, onProgress) {
|
|
|
426
485
|
assurancePassed: assuranceGates.newCode.passed,
|
|
427
486
|
minimalityBlocked: minimalityReport?.blocked === true,
|
|
428
487
|
reliabilityPassed: reliabilityGate.passed,
|
|
429
|
-
blastRadiusPassed: blastRadiusGate
|
|
488
|
+
blastRadiusPassed: isBlastRadiusPassed(blastRadiusGate),
|
|
489
|
+
strictAuditsPassed: strictAuditsGate.passed,
|
|
430
490
|
score: effectiveResult.score,
|
|
431
491
|
});
|
|
432
492
|
const output = {
|
|
@@ -562,6 +622,8 @@ export async function executeValidate(args, server, onProgress) {
|
|
|
562
622
|
suggestion: 'No importer regression coverage ran for this validate call.',
|
|
563
623
|
});
|
|
564
624
|
}
|
|
625
|
+
output.qualityIssues.push(...blastRadiusIntegrationWarnings(blastRadiusGate));
|
|
626
|
+
output.qualityIssues.push(...strictAuditsQualityIssues(strictAuditsGate));
|
|
565
627
|
// Auto-suggest corrective actions based on validation results
|
|
566
628
|
// score is null when no criteria can be extracted — treat as 0 for comparisons.
|
|
567
629
|
const scoreValue = effectiveResult.score ?? 0;
|
|
@@ -602,6 +664,7 @@ export async function executeValidate(args, server, onProgress) {
|
|
|
602
664
|
if (blastRadiusGate.skipped === null && !blastRadiusGate.passed) {
|
|
603
665
|
suggestions.push('Fix the failing importer tests (or raise validation.blastRadiusTimeoutMs) before marking this spec done.');
|
|
604
666
|
}
|
|
667
|
+
suggestions.push(...strictAuditsSuggestions(strictAuditsGate));
|
|
605
668
|
if (!assuranceGates.newCode.passed) {
|
|
606
669
|
suggestions.push(`Assurance gate failed: ${String(assuranceGates.newCode.findings.length)} new-code domain inference issue(s) found.`);
|
|
607
670
|
}
|
|
@@ -754,6 +817,7 @@ function buildQualityGateSummary(input) {
|
|
|
754
817
|
...(input.minimalityBlocked ? ['minimality'] : []),
|
|
755
818
|
...(!input.reliabilityPassed ? ['reliability'] : []),
|
|
756
819
|
...(!input.blastRadiusPassed ? ['blast-radius'] : []),
|
|
820
|
+
...(!input.strictAuditsPassed ? ['strict-audits'] : []),
|
|
757
821
|
];
|
|
758
822
|
return {
|
|
759
823
|
passed: failures.length === 0,
|
|
@@ -766,6 +830,7 @@ function buildQualityGateSummary(input) {
|
|
|
766
830
|
minimalityPassed: !input.minimalityBlocked,
|
|
767
831
|
reliabilityPassed: input.reliabilityPassed,
|
|
768
832
|
blastRadiusPassed: input.blastRadiusPassed,
|
|
833
|
+
strictAuditsPassed: input.strictAuditsPassed,
|
|
769
834
|
};
|
|
770
835
|
}
|
|
771
836
|
function buildExecutableCoverage(specCompliance) {
|
|
@@ -13,4 +13,14 @@ export interface InstallationManifest {
|
|
|
13
13
|
updatedAt: string;
|
|
14
14
|
installations: InstallationRecord[];
|
|
15
15
|
}
|
|
16
|
+
export type NpmCacheStatus = 'ok' | 'foreign-owned' | 'unreadable';
|
|
17
|
+
export interface NpmCacheFinding {
|
|
18
|
+
status: NpmCacheStatus;
|
|
19
|
+
cacheDir: string;
|
|
20
|
+
foreignCount: number;
|
|
21
|
+
scanned: number;
|
|
22
|
+
truncated: boolean;
|
|
23
|
+
sampleEntries: string[];
|
|
24
|
+
fix: string;
|
|
25
|
+
}
|
|
16
26
|
//# sourceMappingURL=installation.d.ts.map
|
|
@@ -130,6 +130,7 @@ export interface UpdateStatusBatchInput {
|
|
|
130
130
|
projectPath?: string;
|
|
131
131
|
dryRun?: boolean;
|
|
132
132
|
reviewNotes?: string;
|
|
133
|
+
reason?: string;
|
|
133
134
|
evidence?: Record<string, UpdateStatusBatchEvidence>;
|
|
134
135
|
}
|
|
135
136
|
/** Report of detected migration drift (SPEC-715). Read-only — no FS mutations. */
|