@planu/cli 5.7.10 → 5.7.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/.planu-build.json +1 -1
  3. package/dist/cli/commands/package-handoff.js +10 -3
  4. package/dist/config/runtime-policy.json +2 -1
  5. package/dist/engine/abortable-process-runner.js +1 -0
  6. package/dist/engine/bump-carrier-binding.d.ts +10 -0
  7. package/dist/engine/bump-carrier-binding.js +276 -0
  8. package/dist/engine/handoff-artifacts/schemas.d.ts +20 -0
  9. package/dist/engine/handoff-artifacts/schemas.js +12 -0
  10. package/dist/engine/runtime-policy.js +4 -0
  11. package/dist/engine/source-quality-binding.d.ts +26 -0
  12. package/dist/engine/source-quality-binding.js +162 -0
  13. package/dist/engine/source-quality-receipt-reader.d.ts +3 -0
  14. package/dist/engine/source-quality-receipt-reader.js +51 -0
  15. package/dist/engine/spec-format/bdd-parser.js +13 -7
  16. package/dist/engine/spec-format/technical-md-populator.js +114 -3
  17. package/dist/engine/spec-format/unified-spec-builder.js +41 -7
  18. package/dist/engine/validation/validation-freshness.js +3 -2
  19. package/dist/engine/validator/blast-radius-gate.d.ts +3 -0
  20. package/dist/engine/validator/blast-radius-gate.js +139 -0
  21. package/dist/engine/validator/spec-compliance-runner.d.ts +1 -0
  22. package/dist/engine/validator/spec-compliance-runner.js +3 -0
  23. package/dist/engine/validator/validation-report-writer.d.ts +2 -0
  24. package/dist/engine/validator/validation-report-writer.js +68 -30
  25. package/dist/storage/runtime-db.js +7 -3
  26. package/dist/storage/spec-store.js +17 -6
  27. package/dist/tools/challenge-spec/scenarios-data.js +2 -2
  28. package/dist/tools/challenge-spec/scenarios-utils.d.ts +2 -0
  29. package/dist/tools/challenge-spec/scenarios-utils.js +36 -3
  30. package/dist/tools/update-status/side-effects.js +3 -1
  31. package/dist/tools/validate-lint.js +19 -0
  32. package/dist/tools/validate.js +46 -4
  33. package/dist/transports/transport-factory.js +15 -6
  34. package/dist/types/abortable-process.d.ts +1 -0
  35. package/dist/types/handoff-artifacts.d.ts +10 -0
  36. package/dist/types/runtime-policy.d.ts +1 -0
  37. package/dist/types/spec-format.d.ts +9 -0
  38. package/dist/types/validation-evidence.d.ts +21 -0
  39. package/package.json +3 -2
  40. package/planu-plugin.json +1 -1
@@ -0,0 +1,51 @@
1
+ import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
2
+ import { isAbsolute, join } from 'node:path';
3
+ import { canonical } from './bump-carrier-binding.js';
4
+ import { computeBinding, runIdentity, sha256 } from './source-quality-binding.js';
5
+ import { VALIDATION_COMMANDS } from './validation-impact-planner.js';
6
+ function successfulResults(commandPlan) {
7
+ return commandPlan.map(({ id, executable, args }) => ({ id, executable, args, exitCode: 0 }));
8
+ }
9
+ function gitDirectory(projectPath) {
10
+ const value = runIdentity('git', ['rev-parse', '--git-dir'], projectPath);
11
+ return realpathSync(isAbsolute(value) ? value : join(projectPath, value));
12
+ }
13
+ function isCanonicalReceiptFile(path) {
14
+ return (existsSync(path) &&
15
+ !lstatSync(path).isSymbolicLink() &&
16
+ lstatSync(path).isFile() &&
17
+ realpathSync(path) === path &&
18
+ (statSync(path).mode & 0o777) === 0o600);
19
+ }
20
+ function receiptDirectoryHasReceipts(receiptDirectory) {
21
+ return (existsSync(receiptDirectory) &&
22
+ readdirSync(receiptDirectory).some((entry) => entry.endsWith('.json')));
23
+ }
24
+ export function readMatchingSourceQualityReceipt(projectPath, command) {
25
+ if (command !== VALIDATION_COMMANDS.lint) {
26
+ return null;
27
+ }
28
+ try {
29
+ const receiptDirectory = join(gitDirectory(projectPath), 'planu-release-artifacts', 'source-quality');
30
+ if (!receiptDirectoryHasReceipts(receiptDirectory)) {
31
+ return null;
32
+ }
33
+ const binding = computeBinding(projectPath);
34
+ const results = successfulResults(binding.commandPlan);
35
+ const key = sha256(canonical({ binding, results }));
36
+ const path = join(receiptDirectory, `${key}.json`);
37
+ if (!isCanonicalReceiptFile(path)) {
38
+ return null;
39
+ }
40
+ const actual = JSON.parse(readFileSync(path, 'utf8'));
41
+ const expected = { schemaVersion: 1, key, binding, results };
42
+ if (canonical(actual) !== canonical(expected)) {
43
+ return null;
44
+ }
45
+ return { key, path };
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
51
+ //# sourceMappingURL=source-quality-receipt-reader.js.map
@@ -41,18 +41,25 @@ function hasThenSignal(scenario) {
41
41
  function isSingleLineGivenWhenThenText(text) {
42
42
  return WHEN_WORD_RE.test(text) && THEN_WORD_RE.test(text);
43
43
  }
44
- function opensHeaderlessScenario(rawKeyword, text) {
45
- return rawKeyword === 'given' || isSingleLineGivenWhenThenText(text);
44
+ const UPPERCASE_WHEN_LINE_RE = /^WHEN\s/;
45
+ function opensHeaderlessScenario(rawKeyword, text, rawLine) {
46
+ return (rawKeyword === 'given' ||
47
+ isSingleLineGivenWhenThenText(text) ||
48
+ UPPERCASE_WHEN_LINE_RE.test(rawLine));
49
+ }
50
+ function suffixedTitle(thenText, steps) {
51
+ return `${thenText} (given ${steps.find((step) => step.keyword === 'given')?.text ?? ''})`;
46
52
  }
47
53
  export function parseBddScenarios(markdown) {
48
54
  const scenarios = [];
49
55
  const lines = markdown.split('\n');
50
56
  let current = null;
51
- // Tracks whether the current scenario was auto-created (no Scenario: header)
52
57
  let currentIsHeaderless = false;
58
+ const closedTitles = new Set();
53
59
  const closeCurrent = () => {
54
60
  if (current && hasThenSignal(current)) {
55
61
  scenarios.push(current);
62
+ closedTitles.add(current.title);
56
63
  }
57
64
  current = null;
58
65
  currentIsHeaderless = false;
@@ -60,7 +67,7 @@ export function parseBddScenarios(markdown) {
60
67
  for (const raw of lines) {
61
68
  const line = raw.trim();
62
69
  // Detect scenario header
63
- const scenarioMatch = /^scenario:\s*(.+)$/i.exec(line);
70
+ const scenarioMatch = /^(?:#{1,6}\s*)?scenario(?:\s+\d+)?:\s*(.+)$/i.exec(line);
64
71
  if (scenarioMatch) {
65
72
  closeCurrent();
66
73
  current = { title: (scenarioMatch[1] ?? '').trim(), steps: [], done: false };
@@ -81,16 +88,15 @@ export function parseBddScenarios(markdown) {
81
88
  closeCurrent();
82
89
  }
83
90
  if (!current) {
84
- if (!opensHeaderlessScenario(rawKeyword, text)) {
91
+ if (!opensHeaderlessScenario(rawKeyword, text, line)) {
85
92
  continue;
86
93
  }
87
94
  current = { title: text, steps: [], done: false };
88
95
  currentIsHeaderless = true;
89
96
  }
90
97
  current.steps.push({ keyword, text });
91
- // For headerless scenarios, update the title to the THEN text for better descriptiveness
92
98
  if (currentIsHeaderless && keyword === 'then') {
93
- current.title = text;
99
+ current.title = closedTitles.has(text) ? suffixedTitle(text, current.steps) : text;
94
100
  }
95
101
  }
96
102
  closeCurrent();
@@ -37,6 +37,115 @@ function extractPathsFromSection(sectionText) {
37
37
  }
38
38
  return paths;
39
39
  }
40
+ const LABELED_LIST_LINE_RE = /^\s*-?\s*(?:Files to (create|modify)|(Create|Modify|Test))\s*:\s*(.*)$/i;
41
+ const NONE_TOKEN_RE = /^none\.?$/i;
42
+ const TRAILING_LIST_PUNCTUATION_RE = /[.,;:]+$/;
43
+ function labeledBucketKind(labelMatch) {
44
+ const kind = (labelMatch[1] ?? labelMatch[2])?.toLowerCase();
45
+ return kind === 'create' || kind === 'modify' || kind === 'test' ? kind : null;
46
+ }
47
+ function stripLabeledListToken(token) {
48
+ return token
49
+ .replace(/\([^)]*\)/g, '')
50
+ .trim()
51
+ .replace(/^`|`$/g, '')
52
+ .trim()
53
+ .replace(TRAILING_LIST_PUNCTUATION_RE, '');
54
+ }
55
+ const LABELED_PATH_SHAPE_RE = /^[\w./-]+$/;
56
+ function isPathShapedLabelToken(token) {
57
+ return (LABELED_PATH_SHAPE_RE.test(token) && (token.includes('/') || /\.[a-zA-Z0-9]+$/.test(token)));
58
+ }
59
+ function splitLabeledList(text) {
60
+ return text
61
+ .split(',')
62
+ .map(stripLabeledListToken)
63
+ .filter((token) => token.length > 0 && !NONE_TOKEN_RE.test(token) && isPathShapedLabelToken(token));
64
+ }
65
+ function consumeLabeledBulletLines(lines, start) {
66
+ const paths = [];
67
+ let i = start;
68
+ while (i < lines.length && (lines[i] ?? '').trim().length > 0) {
69
+ const line = lines[i] ?? '';
70
+ if (LABELED_LIST_LINE_RE.test(line)) {
71
+ break;
72
+ }
73
+ const bulletMatch = /^\s*-\s*(.+)$/.exec(line);
74
+ if (!bulletMatch?.[1]) {
75
+ break;
76
+ }
77
+ paths.push(...splitLabeledList(bulletMatch[1]));
78
+ i += 1;
79
+ }
80
+ return { paths, next: i };
81
+ }
82
+ function parseLabeledFileLists(body) {
83
+ const lines = body.split('\n');
84
+ const lists = { create: [], modify: [], test: [] };
85
+ let found = false;
86
+ for (let i = 0; i < lines.length; i += 1) {
87
+ const labelMatch = LABELED_LIST_LINE_RE.exec(lines[i] ?? '');
88
+ if (!labelMatch) {
89
+ continue;
90
+ }
91
+ const kind = labeledBucketKind(labelMatch);
92
+ if (!kind || labelMatch[3] === undefined) {
93
+ continue;
94
+ }
95
+ found = true;
96
+ const inline = labelMatch[3].trim();
97
+ if (inline.length > 0) {
98
+ lists[kind].push(...splitLabeledList(inline));
99
+ continue;
100
+ }
101
+ const { paths, next } = consumeLabeledBulletLines(lines, i + 1);
102
+ lists[kind].push(...paths);
103
+ i = next - 1;
104
+ }
105
+ return found ? lists : null;
106
+ }
107
+ function buildEntriesFromLabeledLists(labeled) {
108
+ const create = [];
109
+ const modify = [];
110
+ const test = labeled.test.map((p) => ({ path: p, status: 'pending' }));
111
+ for (const p of labeled.create) {
112
+ create.push({ path: p, status: 'pending' });
113
+ if (isExecutableTestPath(p)) {
114
+ test.push({ path: p, status: 'pending' });
115
+ }
116
+ }
117
+ for (const p of labeled.modify) {
118
+ modify.push({ path: p, status: 'pending' });
119
+ if (isExecutableTestPath(p)) {
120
+ test.push({ path: p, status: 'pending' });
121
+ }
122
+ }
123
+ return { create, modify, test };
124
+ }
125
+ function dedupeByPath(entries) {
126
+ const seen = new Set();
127
+ const result = [];
128
+ for (const entry of entries) {
129
+ if (!seen.has(entry.path)) {
130
+ seen.add(entry.path);
131
+ result.push(entry);
132
+ }
133
+ }
134
+ return result;
135
+ }
136
+ function mergeStructuredAndLabeled(structured, labeled) {
137
+ if (structured === null && labeled === null) {
138
+ return null;
139
+ }
140
+ const fromLabels = labeled === null ? null : buildEntriesFromLabeledLists(labeled);
141
+ const base = structured ?? { create: [], modify: [], test: [] };
142
+ const extra = fromLabels ?? { create: [], modify: [], test: [] };
143
+ return {
144
+ create: dedupeByPath([...base.create, ...extra.create]),
145
+ modify: dedupeByPath([...base.modify, ...extra.modify]),
146
+ test: dedupeByPath([...base.test, ...extra.test]),
147
+ };
148
+ }
40
149
  function parseSectionedFileLists(body) {
41
150
  const filesRange = findMarkdownSectionRange(body, 'Files') ??
42
151
  findMarkdownSectionRange(body, 'Files likely to change');
@@ -189,9 +298,11 @@ export function extractMarkerDeclaredPaths(description) {
189
298
  */
190
299
  export async function extractFilesFromSpecBody(specBody, projectPath) {
191
300
  const structured = parseSectionedFileLists(specBody);
192
- if (structured !== null &&
193
- (structured.create.length > 0 || structured.modify.length > 0 || structured.test.length > 0)) {
194
- return structured;
301
+ const labeled = parseLabeledFileLists(specBody);
302
+ const merged = mergeStructuredAndLabeled(structured, labeled);
303
+ if (merged !== null &&
304
+ (merged.create.length > 0 || merged.modify.length > 0 || merged.test.length > 0)) {
305
+ return merged;
195
306
  }
196
307
  const candidates = [
197
308
  ...new Set(Array.from(stripFencedBlocks(specBody).matchAll(FILE_PATH_RE), (m) => m[0])),
@@ -20,9 +20,10 @@ export function buildCanonicalUnifiedSpecContent(input) {
20
20
  const source = input.sourceDescription.replace(/\r\n/g, '\n').trim();
21
21
  const explicitProblem = extractTopLevelSectionBody(source, 'Problem');
22
22
  const proseBeforeHeading = source.split(/^##[ \t]+\S.*$/m, 1)[0]?.trim() ?? '';
23
- const problem = firstNonEmpty(explicitProblem, proseBeforeHeading, source);
23
+ const fallbackSection = explicitProblem === null && proseBeforeHeading.length === 0 ? firstAuthorSection(source) : null;
24
+ const problem = firstNonEmpty(explicitProblem, proseBeforeHeading, fallbackSection?.body, source);
24
25
  const explicitGoal = extractTopLevelSectionBody(source, 'Goal');
25
- const goal = firstNonEmpty(explicitGoal, input.criteria[0]?.text, 'Needs decision: define the goal this spec must achieve.');
26
+ const goal = firstNonEmpty(explicitGoal, firstSentence(problem), 'Needs decision: define the goal this spec must achieve.');
26
27
  const explicitTechnical = extractTopLevelSectionBody(source, 'Technical');
27
28
  const generatedNotes = extractTopLevelSectionBody(input.technicalBody, 'Implementation Notes');
28
29
  const technical = firstNonEmpty(explicitTechnical, generatedNotes, groundedTechnicalFallback(input.files, input.criteria));
@@ -39,7 +40,7 @@ export function buildCanonicalUnifiedSpecContent(input) {
39
40
  renderSection('Acceptance Criteria', acceptance),
40
41
  renderSection('Files', renderOwnedFiles(input.files)),
41
42
  renderSection('Out of scope', outOfScope),
42
- ...extractAuthorSections(source),
43
+ ...extractAuthorSections(source, fallbackSection?.name),
43
44
  ];
44
45
  return `${frontmatter ? `${frontmatter}\n\n` : ''}${sections.join('\n\n')}\n`;
45
46
  }
@@ -52,7 +53,7 @@ const CANONICAL_SECTION_NAMES = new Set([
52
53
  'Files',
53
54
  'Out of scope',
54
55
  ].map((name) => name.toLowerCase()));
55
- function extractAuthorSections(source) {
56
+ function extractAuthorSections(source, skipName) {
56
57
  const scannable = stripFencedCodeBlocks(source);
57
58
  const headingRe = /^##[ \t]+(\S.*?)[ \t]*$/gm;
58
59
  const preserved = [];
@@ -62,6 +63,9 @@ function extractAuthorSections(source) {
62
63
  if (CANONICAL_SECTION_NAMES.has(name.toLowerCase())) {
63
64
  continue;
64
65
  }
66
+ if (skipName?.toLowerCase() === name.toLowerCase()) {
67
+ continue;
68
+ }
65
69
  const body = extractTopLevelSectionBody(source, name);
66
70
  if (body !== null && body.length > 0) {
67
71
  preserved.push(renderSection(name, body));
@@ -69,6 +73,27 @@ function extractAuthorSections(source) {
69
73
  }
70
74
  return preserved;
71
75
  }
76
+ /**
77
+ * The first non-canonical `##` section with a non-empty body, used as the
78
+ * problem fallback when the description opens directly with a heading
79
+ * (SPEC-1753). Returns null when no such section exists.
80
+ */
81
+ function firstAuthorSection(source) {
82
+ const scannable = stripFencedCodeBlocks(source);
83
+ const headingRe = /^##[ \t]+(\S.*?)[ \t]*$/gm;
84
+ let match;
85
+ while ((match = headingRe.exec(scannable)) !== null) {
86
+ const name = match[1] ?? '';
87
+ if (CANONICAL_SECTION_NAMES.has(name.toLowerCase())) {
88
+ continue;
89
+ }
90
+ const body = extractTopLevelSectionBody(source, name);
91
+ if (body !== null && body.length > 0) {
92
+ return { name, body };
93
+ }
94
+ }
95
+ return null;
96
+ }
72
97
  /**
73
98
  * Combine a generated lean spec.md body and a generated lean technical.md body
74
99
  * into a single unified spec.md content. The technical body's YAML frontmatter
@@ -294,18 +319,27 @@ function findEmbeddedRequiredSections(body) {
294
319
  return [...embedded];
295
320
  }
296
321
  function extractTopLevelSectionBody(body, section) {
297
- const heading = new RegExp(`^##[ \\t]+${escapeRegex(section)}[ \\t]*$`, 'mi').exec(body);
322
+ const scannable = maskFencedAndQuotedText(body);
323
+ const heading = new RegExp(`^##[ \\t]+${escapeRegex(section)}[ \\t]*$`, 'mi').exec(scannable);
298
324
  if (!heading) {
299
325
  return null;
300
326
  }
301
327
  const start = heading.index + heading[0].length;
302
- const rest = body.slice(start);
328
+ const rest = scannable.slice(start);
303
329
  const next = /^##[ \t]+\S.*$/m.exec(rest);
304
- return rest.slice(0, next?.index ?? rest.length).trim();
330
+ const end = start + (next?.index ?? rest.length);
331
+ return body.slice(start, end).trim();
305
332
  }
306
333
  function renderSection(title, body) {
307
334
  return `## ${title}\n\n${body.trim()}`;
308
335
  }
336
+ function firstSentence(text) {
337
+ const paragraph = (text.split(/\n\s*\n/).find((part) => part.trim().length > 0) ?? '')
338
+ .trim()
339
+ .replace(/\s+/g, ' ')
340
+ .replace(/^(?:\d+[.)]|[-*+])\s+/, '');
341
+ return /^[\s\S]*?[.!?](?=\s|$)/.exec(paragraph)?.[0] ?? paragraph;
342
+ }
309
343
  function firstNonEmpty(...values) {
310
344
  return (values.find((value) => value !== undefined && value !== null && value.length > 0) ?? '');
311
345
  }
@@ -658,9 +658,10 @@ export async function evaluateValidationFreshnessBarrier(lease, bindings) {
658
658
  invalidateExactEpoch(lease, candidate);
659
659
  return { fresh: false, reason: 'evidence-changed', changedInput: candidate.handoffPath };
660
660
  }
661
+ const boundSourceDigest = candidate.bindings?.sourceDigest;
661
662
  try {
662
- if (candidate.bindings &&
663
- (await gitSourceTreeDigest(candidate.projectPath)) !== candidate.bindings.sourceDigest) {
663
+ if (boundSourceDigest !== undefined &&
664
+ (await gitSourceTreeDigest(candidate.projectPath)) !== boundSourceDigest) {
664
665
  invalidateExactEpoch(lease, candidate);
665
666
  return { fresh: false, reason: 'source-changed', changedInput: candidate.projectPath };
666
667
  }
@@ -0,0 +1,3 @@
1
+ import type { BlastRadiusGateResult, RunBlastRadiusGateOptions } from '../../types/validation-evidence.js';
2
+ export declare function runBlastRadiusGate(projectPath: string, candidateFiles: string[], options: RunBlastRadiusGateOptions): Promise<BlastRadiusGateResult>;
3
+ //# sourceMappingURL=blast-radius-gate.d.ts.map
@@ -0,0 +1,139 @@
1
+ import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
2
+ import { tmpdir } from 'node:os';
3
+ import { isAbsolute, join, relative } from 'node:path';
4
+ import { runAbortableProcess } from '../abortable-process-runner.js';
5
+ import { technologyValue } from '../technology-registry.js';
6
+ const IMPORTABLE_SOURCE_PATTERN = /\.(?:ts|tsx|js|jsx|mjs|cjs)$/u;
7
+ function skippedResult(skipped) {
8
+ return { skipped, selectedFiles: [], passed: true, timedOut: false, failures: [] };
9
+ }
10
+ function normalizeCandidate(projectPath, file) {
11
+ const absolute = isAbsolute(file) ? file : join(projectPath, file);
12
+ const relativePath = relative(projectPath, absolute);
13
+ return relativePath.startsWith('..') ? null : relativePath;
14
+ }
15
+ function selectCandidateFiles(projectPath, candidateFiles) {
16
+ const normalized = candidateFiles
17
+ .map((file) => normalizeCandidate(projectPath, file))
18
+ .filter((file) => file !== null);
19
+ return [...new Set(normalized)].filter((file) => IMPORTABLE_SOURCE_PATTERN.test(file) && existsSync(join(projectPath, file)));
20
+ }
21
+ function firstFailureLine(assertion) {
22
+ const message = assertion.failureMessages?.[0] ?? 'test failed';
23
+ return message.split('\n')[0] ?? message;
24
+ }
25
+ function relativeReportPath(projectPath, reportedPath) {
26
+ return isAbsolute(reportedPath) ? relative(projectPath, reportedPath) : reportedPath;
27
+ }
28
+ function parseVitestReport(projectPath, reportPath) {
29
+ const raw = readFileSync(reportPath, 'utf-8');
30
+ const parsed = JSON.parse(raw);
31
+ if (!Array.isArray(parsed.testResults)) {
32
+ throw new Error('vitest report has no testResults array');
33
+ }
34
+ const failures = [];
35
+ for (const testResult of parsed.testResults) {
36
+ const reportedPath = testResult.testFilePath ?? testResult.name;
37
+ if (!reportedPath) {
38
+ continue;
39
+ }
40
+ const file = relativeReportPath(projectPath, reportedPath);
41
+ for (const assertion of testResult.assertionResults ?? []) {
42
+ if (assertion.status === 'failed') {
43
+ failures.push({ file, message: firstFailureLine(assertion) });
44
+ }
45
+ }
46
+ }
47
+ return failures;
48
+ }
49
+ function abortFailure(reportPath, signal, selectedFiles) {
50
+ const message = signal !== null ? `vitest related aborted (signal ${signal})` : 'vitest related aborted';
51
+ return {
52
+ skipped: null,
53
+ selectedFiles,
54
+ passed: false,
55
+ timedOut: false,
56
+ failures: [{ file: reportPath, message }],
57
+ };
58
+ }
59
+ function exitStatusFailure(reportPath, status, selectedFiles) {
60
+ return {
61
+ skipped: null,
62
+ selectedFiles,
63
+ passed: false,
64
+ timedOut: false,
65
+ failures: [
66
+ {
67
+ file: reportPath,
68
+ message: `vitest related exited with status ${status} without parseable failures`,
69
+ },
70
+ ],
71
+ };
72
+ }
73
+ function reportFailure(reportPath, selectedFiles, error) {
74
+ const detail = error instanceof Error ? error.message : String(error);
75
+ return {
76
+ skipped: null,
77
+ selectedFiles,
78
+ passed: false,
79
+ timedOut: false,
80
+ failures: [
81
+ { file: reportPath, message: `blast radius report missing or unreadable: ${detail}` },
82
+ ],
83
+ };
84
+ }
85
+ export async function runBlastRadiusGate(projectPath, candidateFiles, options) {
86
+ const selectedFiles = selectCandidateFiles(projectPath, candidateFiles);
87
+ if (selectedFiles.length === 0) {
88
+ return skippedResult('no-importable-files');
89
+ }
90
+ const vitestBin = join(projectPath, 'node_modules', '.bin', technologyValue('technology-vitest-a9127f'));
91
+ if (!existsSync(vitestBin)) {
92
+ return skippedResult('vitest-not-installed');
93
+ }
94
+ const runProcess = options.runProcess ?? runAbortableProcess;
95
+ const reportDir = mkdtempSync(join(tmpdir(), 'planu-blast-radius-'));
96
+ const reportPath = join(reportDir, 'blast-radius.json');
97
+ try {
98
+ const result = await runProcess(vitestBin, [
99
+ 'related',
100
+ '--run',
101
+ '--maxWorkers=6',
102
+ '--reporter=json',
103
+ `--outputFile.json=${reportPath}`,
104
+ ...selectedFiles,
105
+ ], {
106
+ cwd: projectPath,
107
+ timeoutMs: options.timeoutMs,
108
+ maxBufferBytes: 64 * 1024 * 1024,
109
+ signal: options.signal,
110
+ env: { ...process.env, PLANU_EXCLUDE_INTEGRATION_TESTS: '1' },
111
+ });
112
+ if (result.timedOut) {
113
+ return { skipped: null, selectedFiles, passed: false, timedOut: true, failures: [] };
114
+ }
115
+ if (result.aborted || result.signal !== null) {
116
+ return abortFailure(reportPath, result.signal, selectedFiles);
117
+ }
118
+ try {
119
+ const failures = parseVitestReport(projectPath, reportPath);
120
+ if (failures.length === 0 && result.status !== null && result.status !== 0) {
121
+ return exitStatusFailure(reportPath, result.status, selectedFiles);
122
+ }
123
+ return {
124
+ skipped: null,
125
+ selectedFiles,
126
+ passed: failures.length === 0,
127
+ timedOut: false,
128
+ failures,
129
+ };
130
+ }
131
+ catch (error) {
132
+ return reportFailure(reportPath, selectedFiles, error);
133
+ }
134
+ }
135
+ finally {
136
+ rmSync(reportDir, { recursive: true, force: true });
137
+ }
138
+ }
139
+ //# sourceMappingURL=blast-radius-gate.js.map
@@ -8,5 +8,6 @@ export declare class ComplianceCommandTerminalError extends Error {
8
8
  export declare function parseFrontmatterScenarios(raw: string): FrontmatterScenario[];
9
9
  export declare function runSpecCompliance(spec: Spec, projectPath: string, signal?: AbortSignal, canonicalProjectId?: string): Promise<SpecComplianceResult>;
10
10
  export declare function findScenariosWithoutTests(raw: string): string[];
11
+ export declare function collectDeclaredSpecFiles(raw: string): string[];
11
12
  export declare function findDoneDriftMissingFiles(spec: Spec, raw: string, projectPath: string, fileExists: (path: string) => boolean): DoneDriftMissingFileFinding[];
12
13
  //# sourceMappingURL=spec-compliance-runner.d.ts.map
@@ -701,6 +701,9 @@ function extractFilesSectionPaths(raw) {
701
701
  }
702
702
  return paths;
703
703
  }
704
+ export function collectDeclaredSpecFiles(raw) {
705
+ return [...new Set([...extractFilesMarkerPaths(raw), ...extractFilesSectionPaths(raw)])];
706
+ }
704
707
  export function findDoneDriftMissingFiles(spec, raw, projectPath, fileExists) {
705
708
  if (spec.status !== 'done') {
706
709
  return [];
@@ -1,5 +1,6 @@
1
1
  import type { Spec } from '../../types/index.js';
2
2
  import type { ValidationReportV1 } from '../../types/handoff-artifacts.js';
3
+ import type { BlastRadiusGateResult } from '../../types/validation-evidence.js';
3
4
  import type { MinimalImplementationReport } from '../../types/minimal-implementation-gate.js';
4
5
  export declare const AUTOMATED_VALIDATOR_AGENT = "planu-automated-validator";
5
6
  export declare function writeImplementationReviewReport(input: {
@@ -12,6 +13,7 @@ export declare function writeImplementationReviewReport(input: {
12
13
  conventionRegression?: boolean;
13
14
  minimalityReport?: MinimalImplementationReport;
14
15
  signal?: AbortSignal;
16
+ blastRadius?: BlastRadiusGateResult;
15
17
  }): Promise<{
16
18
  written: boolean;
17
19
  path?: string;