@planu/cli 6.0.0 → 6.0.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.
- package/CHANGELOG.md +15 -0
- package/dist/.planu-build.json +1 -1
- package/dist/cli/commands/job.js +7 -1
- package/dist/cli/router.js +24 -5
- package/dist/config/official-sdd-tools.d.ts +0 -1
- package/dist/config/official-sdd-tools.js +0 -3
- package/dist/core/spec-validator.js +1 -1
- package/dist/engine/coach/i18n.d.ts +1 -1
- package/dist/engine/coach/i18n.js +2 -2
- package/dist/engine/convention-scanner/codebase-scanner.js +140 -8
- package/dist/engine/conventions-ttl.d.ts +0 -2
- package/dist/engine/conventions-ttl.js +1 -1
- package/dist/engine/evidence-gates/artifact-reader.d.ts +0 -2
- package/dist/engine/evidence-gates/artifact-reader.js +0 -2
- package/dist/engine/execution/package-handoff-job-executor.d.ts +1 -1
- package/dist/engine/execution/package-handoff-job-executor.js +42 -13
- package/dist/engine/execution/startup-recovery.d.ts +3 -0
- package/dist/engine/execution/startup-recovery.js +15 -0
- package/dist/engine/execution/validate-job-executor.d.ts +1 -1
- package/dist/engine/execution/validate-job-executor.js +23 -3
- package/dist/engine/handoff-packager.d.ts +2 -0
- package/dist/engine/handoff-packager.js +25 -9
- package/dist/engine/network-policy.js +31 -0
- package/dist/engine/test-selection/policy.js +1 -1
- package/dist/engine/validation-evidence-ledger.js +8 -37
- package/dist/engine/validation-impact-planner.d.ts +1 -3
- package/dist/engine/validation-impact-planner.js +2 -18
- package/dist/engine/validator/analyzer.js +0 -1
- package/dist/engine/validator/reliability-gate.js +6 -1
- package/dist/index.js +3 -11
- package/dist/security/adapters/local-file.js +8 -1
- package/dist/security/secret-provider.js +0 -2
- package/dist/storage/migrations/sdd-core-v6.js +101 -23
- package/dist/storage/project-identity.js +18 -2
- package/dist/tools/check-readiness.js +45 -35
- package/dist/tools/create-spec.js +14 -16
- package/dist/tools/init-project/agents-md-writer.js +0 -3
- package/dist/tools/package-handoff.js +19 -16
- package/dist/tools/update-status/approval-gates.d.ts +1 -1
- package/dist/tools/update-status/approval-gates.js +28 -5
- package/dist/tools/update-status/evidence-payload.d.ts +0 -2
- package/dist/tools/update-status/index.js +18 -8
- package/dist/tools/update-status/transition-guard.d.ts +1 -1
- package/dist/tools/update-status/transition-guard.js +18 -2
- package/dist/tools/validate.js +29 -7
- package/dist/types/common/learning.d.ts +0 -17
- package/dist/types/durable-job.d.ts +15 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/living-spec/annotations.d.ts +0 -30
- package/dist/types/living-spec/annotations.js +14 -0
- package/dist/types/living-spec.d.ts +0 -1
- package/dist/types/living-spec.js +0 -1
- package/dist/types/project/core.d.ts +0 -2
- package/dist/types/project/planu-config.d.ts +0 -1
- package/dist/types/readiness.d.ts +2 -0
- package/dist/types/security.d.ts +1 -1
- package/dist/types/spec-quality.d.ts +0 -20
- package/dist/types/timing.d.ts +0 -6
- package/dist/types/validation-evidence.d.ts +2 -2
- package/dist/types/validation.d.ts +2 -0
- package/package.json +4 -4
- package/scripts/check-reliability-policies.mjs +504 -0
- package/dist/engine/timing/structured-log.d.ts +0 -10
- package/dist/engine/timing/structured-log.js +0 -36
- package/dist/types/analysis-detection.d.ts +0 -14
- package/dist/types/analysis-detection.js +0 -5
- package/dist/types/lessons.d.ts +0 -28
- package/dist/types/lessons.js +0 -3
- package/dist/types/living-spec/dashboard-and-sync.d.ts +0 -82
- package/dist/types/living-spec/dashboard-and-sync.js +0 -3
- package/dist/types/vector-store.d.ts +0 -46
- package/dist/types/vector-store.js +0 -21
- package/planu-plugin.json +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [6.0.1] - 2026-09-10
|
|
2
|
+
|
|
3
|
+
### Cleanup
|
|
4
|
+
- remove 17 unreachable TypeScript modules and retired plugin, website, marketplace, release-orchestration, telemetry, native-launcher, and host assets
|
|
5
|
+
- reduce the maintained surface to the SDD runtime, CLI, lifecycle gates, and supported project detectors
|
|
6
|
+
|
|
7
|
+
### Reliability
|
|
8
|
+
- recover durable validation and handoff jobs before accepting traffic and report detached scheduler failures
|
|
9
|
+
- make migration lock reconciliation crash-safe and concurrent through an operating-system-backed SQLite guard
|
|
10
|
+
- enforce offline startup and equivalent reliability-policy checks in source and packed installations
|
|
11
|
+
|
|
12
|
+
### Performance
|
|
13
|
+
- reduce the production closure by about 54% and packed non-map bytes by about 49%
|
|
14
|
+
- improve median stdio startup by about 8% and reduce peak RSS by about 16%
|
|
15
|
+
|
|
1
16
|
## [6.0.0] - 2026-09-10
|
|
2
17
|
|
|
3
18
|
### Breaking Changes
|
package/dist/.planu-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"commit":"
|
|
1
|
+
{"schemaVersion":1,"commit":"af76d38310eb4ab7b625442c738f40230a8e0b0a"}
|
package/dist/cli/commands/job.js
CHANGED
|
@@ -92,7 +92,13 @@ export const jobCommand = {
|
|
|
92
92
|
const runtime = __addDisposableResource(env_1, new DurableJobRuntime(), false);
|
|
93
93
|
const internalJob = action === 'cancel' ? runtime.cancel(identity) : runtime.get(identity);
|
|
94
94
|
const job = runtime.observe(internalJob);
|
|
95
|
-
|
|
95
|
+
const recovery = action === 'get' && (job.state === 'accepted' || job.state === 'checkpointed')
|
|
96
|
+
? {
|
|
97
|
+
recoveryRequired: true,
|
|
98
|
+
recoveryAction: `planu job restart --operation-id ${identity.operationId} --project-id ${identity.projectId}${identity.workspaceId ? ` --workspace-id ${identity.workspaceId}` : ''}`,
|
|
99
|
+
}
|
|
100
|
+
: {};
|
|
101
|
+
process.stdout.write(`${JSON.stringify({ job, cursor: publicJobCursor(job), ...recovery }, null, flags?.json === true || values.json === true ? undefined : 2)}\n`);
|
|
96
102
|
}
|
|
97
103
|
catch (e_1) {
|
|
98
104
|
env_1.error = e_1;
|
package/dist/cli/router.js
CHANGED
|
@@ -49,20 +49,28 @@ function printHelp(commands) {
|
|
|
49
49
|
lines.push(' --verbose Include stack traces on errors');
|
|
50
50
|
process.stdout.write(lines.join('\n') + '\n');
|
|
51
51
|
}
|
|
52
|
+
function printCommandHelp(command) {
|
|
53
|
+
process.stdout.write([
|
|
54
|
+
`${bold(command.name)} — ${command.description}`,
|
|
55
|
+
'',
|
|
56
|
+
`${cyan('Usage:')} ${command.usage}`,
|
|
57
|
+
'',
|
|
58
|
+
dim('Use --json, --quiet or --verbose where supported.'),
|
|
59
|
+
].join('\n') + '\n');
|
|
60
|
+
}
|
|
52
61
|
export function metadataCommand(args) {
|
|
62
|
+
if (args.length === 0 || args[0] === 'help' || args.includes('--help') || args.includes('-h')) {
|
|
63
|
+
return 'help';
|
|
64
|
+
}
|
|
53
65
|
if (args.includes('--version') || args[0] === 'version') {
|
|
54
66
|
return 'version';
|
|
55
67
|
}
|
|
56
|
-
if (args.length === 0 ||
|
|
57
|
-
args[0] === 'help' ||
|
|
58
|
-
(args.length === 1 && (args[0] === '--help' || args[0] === '-h'))) {
|
|
59
|
-
return 'help';
|
|
60
|
-
}
|
|
61
68
|
return null;
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* Parse the first arg as a command name and dispatch to the appropriate handler.
|
|
65
72
|
*/
|
|
73
|
+
// eslint-disable-next-line complexity -- command dispatch intentionally keeps the public CLI table local
|
|
66
74
|
export async function route(args) {
|
|
67
75
|
// Handle global flags
|
|
68
76
|
const { values } = parseArgs({
|
|
@@ -89,6 +97,17 @@ export async function route(args) {
|
|
|
89
97
|
}
|
|
90
98
|
const commands = await loadCommands();
|
|
91
99
|
if (metadata === 'help') {
|
|
100
|
+
const requestedName = args[0] === 'help' ? args[1] : args[0];
|
|
101
|
+
if (requestedName === 'version') {
|
|
102
|
+
process.stdout.write(`${bold('version')} — Print the installed Planu version\n\n`);
|
|
103
|
+
process.stdout.write(`${cyan('Usage:')} planu version\n`);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const requestedCommand = requestedName ? commands.get(requestedName) : undefined;
|
|
107
|
+
if (requestedCommand) {
|
|
108
|
+
printCommandHelp(requestedCommand);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
92
111
|
printHelp(commands);
|
|
93
112
|
return;
|
|
94
113
|
}
|
|
@@ -4,5 +4,4 @@ export declare const OFFICIAL_SDD_RESOURCE_NAMES: readonly ['SDD Process', 'Proj
|
|
|
4
4
|
export declare const OFFICIAL_SDD_PROMPT_NAMES: readonly ['create-feature', 'review-spec', 'implement-spec', 'project-status'];
|
|
5
5
|
export declare const OFFICIAL_SDD_CLI_COMMAND_NAMES: readonly ['init', 'spec', 'status', 'validate', 'package-handoff', 'job', 'doctor', 'help', 'version'];
|
|
6
6
|
export declare const OFFICIAL_SDD_SKILL_NAMES: readonly ['planu-new-spec', 'planu-implement', 'planu-review', 'planu-validate', 'planu-resume-work', 'planu-dogfood-bug', 'planu-native'];
|
|
7
|
-
export declare function readCanonicalToolNames(): string[];
|
|
8
7
|
//# sourceMappingURL=official-sdd-tools.d.ts.map
|
|
@@ -168,7 +168,7 @@ export async function validateSpecFormat(spec, opts) {
|
|
|
168
168
|
allErrors.push(makeError('MISSING_FRONTMATTER', 'specPath is not set — cannot read spec.md', 'specPath', 'frontmatter'));
|
|
169
169
|
return { valid: false, errors: allErrors, warnings: allWarnings };
|
|
170
170
|
}
|
|
171
|
-
const raw = await readSpecRaw(spec.specPath);
|
|
171
|
+
const raw = opts && 'rawSpec' in opts ? (opts.rawSpec ?? null) : await readSpecRaw(spec.specPath);
|
|
172
172
|
if (raw === null) {
|
|
173
173
|
allErrors.push(makeError('MISSING_FRONTMATTER', `spec.md not found at ${spec.specPath}`, 'specPath', 'frontmatter'));
|
|
174
174
|
return { valid: false, errors: allErrors, warnings: allWarnings };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Translate a coach i18n key with optional param interpolation.
|
|
3
3
|
* Falls back to 'en' when key is absent in the requested locale.
|
|
4
|
-
* Emits a
|
|
4
|
+
* Emits a local console warning for missing keys (non-en).
|
|
5
5
|
*/
|
|
6
6
|
export declare function t(key: string, params?: Record<string, unknown>, locale?: string): string;
|
|
7
7
|
/**
|
|
@@ -44,7 +44,7 @@ function loadCatalog(locale) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Translate a coach i18n key with optional param interpolation.
|
|
46
46
|
* Falls back to 'en' when key is absent in the requested locale.
|
|
47
|
-
* Emits a
|
|
47
|
+
* Emits a local console warning for missing keys (non-en).
|
|
48
48
|
*/
|
|
49
49
|
export function t(key, params, locale = 'en') {
|
|
50
50
|
const catalog = loadCatalog(locale);
|
|
@@ -54,7 +54,7 @@ export function t(key, params, locale = 'en') {
|
|
|
54
54
|
const enCatalog = loadCatalog('en');
|
|
55
55
|
message = enCatalog[key];
|
|
56
56
|
if (message !== undefined) {
|
|
57
|
-
//
|
|
57
|
+
// Emit a local warning so truncation remains visible to operators.
|
|
58
58
|
console.warn(`[coach.i18n.missing_key] locale=${locale} key=${key}`);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// engine/convention-scanner/codebase-scanner.ts — SPEC-192
|
|
2
2
|
// Scans actual codebase files against parsed conventions
|
|
3
|
-
import { readdirSync, readFileSync
|
|
3
|
+
import { lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join, relative } from 'node:path';
|
|
5
5
|
import { execGitCapture } from '../git/exec-git.js';
|
|
6
6
|
const MAX_VIOLATIONS_PER_CATEGORY = 50;
|
|
@@ -48,14 +48,17 @@ function walkSourceFiles(dir, projectPath, extensions, results = []) {
|
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
50
|
const full = join(dir, entry);
|
|
51
|
-
let
|
|
51
|
+
let entryStat;
|
|
52
52
|
try {
|
|
53
|
-
|
|
53
|
+
entryStat = lstatSync(full);
|
|
54
54
|
}
|
|
55
55
|
catch {
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
58
|
+
if (entryStat.isSymbolicLink()) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (entryStat.isDirectory()) {
|
|
59
62
|
walkSourceFiles(full, projectPath, extensions, results);
|
|
60
63
|
}
|
|
61
64
|
else if (extensions.some((ext) => full.endsWith(ext))) {
|
|
@@ -203,6 +206,111 @@ function parseViolationsFromGrep(grepOut, rule, category, severity, makeMessage,
|
|
|
203
206
|
}
|
|
204
207
|
return violations;
|
|
205
208
|
}
|
|
209
|
+
/** Blank comments and string contents while preserving offsets, newlines, and quote delimiters. */
|
|
210
|
+
// eslint-disable-next-line complexity -- compact lexical state machine keeps source offsets stable
|
|
211
|
+
function maskNonCode(source) {
|
|
212
|
+
const chars = source.split('');
|
|
213
|
+
let state = 'code';
|
|
214
|
+
let escaped = false;
|
|
215
|
+
for (let index = 0; index < chars.length; index += 1) {
|
|
216
|
+
const char = chars[index] ?? '';
|
|
217
|
+
const next = chars[index + 1] ?? '';
|
|
218
|
+
if (state === 'code') {
|
|
219
|
+
if (char === '/' && next === '/') {
|
|
220
|
+
chars[index] = ' ';
|
|
221
|
+
chars[index + 1] = ' ';
|
|
222
|
+
state = 'line-comment';
|
|
223
|
+
index += 1;
|
|
224
|
+
}
|
|
225
|
+
else if (char === '/' && next === '*') {
|
|
226
|
+
chars[index] = ' ';
|
|
227
|
+
chars[index + 1] = ' ';
|
|
228
|
+
state = 'block-comment';
|
|
229
|
+
index += 1;
|
|
230
|
+
}
|
|
231
|
+
else if (char === "'") {
|
|
232
|
+
state = 'single';
|
|
233
|
+
}
|
|
234
|
+
else if (char === '"') {
|
|
235
|
+
state = 'double';
|
|
236
|
+
}
|
|
237
|
+
else if (char === '`') {
|
|
238
|
+
state = 'template';
|
|
239
|
+
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (state === 'line-comment') {
|
|
243
|
+
if (char === '\n') {
|
|
244
|
+
state = 'code';
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
chars[index] = ' ';
|
|
248
|
+
}
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (state === 'block-comment') {
|
|
252
|
+
if (char === '*' && next === '/') {
|
|
253
|
+
chars[index] = ' ';
|
|
254
|
+
chars[index + 1] = ' ';
|
|
255
|
+
state = 'code';
|
|
256
|
+
index += 1;
|
|
257
|
+
}
|
|
258
|
+
else if (char !== '\n') {
|
|
259
|
+
chars[index] = ' ';
|
|
260
|
+
}
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const delimiter = state === 'single' ? "'" : state === 'double' ? '"' : '`';
|
|
264
|
+
if (escaped) {
|
|
265
|
+
if (char !== '\n') {
|
|
266
|
+
chars[index] = ' ';
|
|
267
|
+
}
|
|
268
|
+
escaped = false;
|
|
269
|
+
}
|
|
270
|
+
else if (char === '\\') {
|
|
271
|
+
chars[index] = ' ';
|
|
272
|
+
escaped = true;
|
|
273
|
+
}
|
|
274
|
+
else if (char === delimiter) {
|
|
275
|
+
state = 'code';
|
|
276
|
+
}
|
|
277
|
+
else if (char !== '\n') {
|
|
278
|
+
chars[index] = ' ';
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return chars.join('');
|
|
282
|
+
}
|
|
283
|
+
function architectureImports(projectPath, directory) {
|
|
284
|
+
const files = walkSourceFiles(join(projectPath, 'src', directory), projectPath, ['.ts']).filter((file) => !file.includes('/convention-scanner/'));
|
|
285
|
+
const imports = [];
|
|
286
|
+
for (const file of files) {
|
|
287
|
+
let source;
|
|
288
|
+
try {
|
|
289
|
+
source = readFileSync(join(projectPath, file), 'utf8');
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const masked = maskNonCode(source);
|
|
295
|
+
const declaration = /\b(?:import|export)\b[\s\S]{0,2000}?\bfrom\s*(['"])\s*\1/gu;
|
|
296
|
+
for (const match of masked.matchAll(declaration)) {
|
|
297
|
+
const start = match.index;
|
|
298
|
+
const raw = source.slice(start, start + match[0].length);
|
|
299
|
+
const modulePath = /\bfrom\s*(['"])([^'"]+)\1/u.exec(raw)?.[2];
|
|
300
|
+
if (!modulePath) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const fromOffset = match[0].lastIndexOf('from');
|
|
304
|
+
const line = source.slice(0, start + Math.max(0, fromOffset)).split('\n').length;
|
|
305
|
+
const code = raw
|
|
306
|
+
.split('\n')
|
|
307
|
+
.find((candidate) => candidate.includes('from'))
|
|
308
|
+
?.trim() ?? raw.trim();
|
|
309
|
+
imports.push({ file, line, code, modulePath });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return imports;
|
|
313
|
+
}
|
|
206
314
|
function scanArchitecture(projectPath, rules) {
|
|
207
315
|
const relevantRules = rules.filter((r) => r.category === 'architecture');
|
|
208
316
|
if (relevantRules.length === 0) {
|
|
@@ -213,10 +321,34 @@ function scanArchitecture(projectPath, rules) {
|
|
|
213
321
|
return [];
|
|
214
322
|
}
|
|
215
323
|
const violations = [];
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
324
|
+
for (const item of architectureImports(projectPath, 'tools')) {
|
|
325
|
+
if (!/storage\/.+\//u.test(item.modulePath)) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
violations.push({
|
|
329
|
+
ruleId: rule.id,
|
|
330
|
+
category: 'architecture',
|
|
331
|
+
severity: 'warning',
|
|
332
|
+
file: item.file,
|
|
333
|
+
line: item.line,
|
|
334
|
+
message: `Deep import into storage internals: ${item.code.slice(0, 80)}`,
|
|
335
|
+
suggestion: 'Import from barrel export (storage/index.js) instead',
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
for (const item of architectureImports(projectPath, 'engine')) {
|
|
339
|
+
if (!item.modulePath.includes('tools/')) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
violations.push({
|
|
343
|
+
ruleId: rule.id,
|
|
344
|
+
category: 'architecture',
|
|
345
|
+
severity: 'critical',
|
|
346
|
+
file: item.file,
|
|
347
|
+
line: item.line,
|
|
348
|
+
message: `Engine imports from tools layer (violation): ${item.code.slice(0, 80)}`,
|
|
349
|
+
suggestion: 'Engine must not import from tools — invert the dependency',
|
|
350
|
+
});
|
|
351
|
+
}
|
|
220
352
|
return violations.slice(0, MAX_VIOLATIONS_PER_CATEGORY);
|
|
221
353
|
}
|
|
222
354
|
function scanCodeQuality(projectPath, rules) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ScannedConventions } from '../types/index.js';
|
|
2
|
-
export declare function readConventionsFile(projectPath: string): Promise<ScannedConventions | null>;
|
|
3
1
|
/**
|
|
4
2
|
* SPEC-665: Check if conventions.json TTL is expired and trigger a background re-fetch.
|
|
5
3
|
* Fire-and-forget — never blocks the caller. Silent failure on any error.
|
|
@@ -4,7 +4,7 @@ import { readFile, writeFile, mkdir, appendFile } from 'node:fs/promises';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
const TTL_DAYS = 7;
|
|
6
6
|
const MS_PER_DAY = 86_400_000;
|
|
7
|
-
|
|
7
|
+
async function readConventionsFile(projectPath) {
|
|
8
8
|
try {
|
|
9
9
|
const raw = await readFile(join(projectPath, 'planu', 'conventions.json'), 'utf-8');
|
|
10
10
|
return JSON.parse(raw);
|
|
@@ -74,13 +74,11 @@ export declare const TraceabilityMatrixSchema: z.ZodObject<{
|
|
|
74
74
|
"fault-injection": "fault-injection";
|
|
75
75
|
lint: "lint";
|
|
76
76
|
migration: "migration";
|
|
77
|
-
native: "native";
|
|
78
77
|
reproducibility: "reproducibility";
|
|
79
78
|
security: "security";
|
|
80
79
|
"test-full": "test-full";
|
|
81
80
|
"test-related": "test-related";
|
|
82
81
|
typecheck: "typecheck";
|
|
83
|
-
website: "website";
|
|
84
82
|
}>;
|
|
85
83
|
command: z.ZodString;
|
|
86
84
|
scope: z.ZodArray<z.ZodString>;
|
|
@@ -18,5 +18,5 @@ export declare class PackageHandoffJobExecutor {
|
|
|
18
18
|
/** Schedules background execution after the submit response can be flushed. */
|
|
19
19
|
export declare function schedulePackageHandoffJobExecution(projectId: string, workspaceId?: string): void;
|
|
20
20
|
/** Re-enqueues accepted/checkpointed package-handoff work discovered after a process restart. */
|
|
21
|
-
export declare function recoverPackageHandoffJobsAtStartup(): void
|
|
21
|
+
export declare function recoverPackageHandoffJobsAtStartup(): Promise<void>;
|
|
22
22
|
//# sourceMappingURL=package-handoff-job-executor.d.ts.map
|
|
@@ -9,6 +9,8 @@ import { DurableJobRuntime } from './job-runtime.js';
|
|
|
9
9
|
import { reportClassifiedDegradation } from '../../errors/classified-degradation.js';
|
|
10
10
|
// eslint-disable-next-line no-restricted-imports -- grandfathered layer violation, remediation SPEC-1661 SPEC-1662 SPEC-1663
|
|
11
11
|
import { specStore, knowledgeStore } from '../../storage/index.js';
|
|
12
|
+
// eslint-disable-next-line no-restricted-imports -- durable identity failures must retain their stable classification
|
|
13
|
+
import { PortablePathError, resolveVerifiedSpecPath } from '../../storage/project-identity.js';
|
|
12
14
|
import { checkSpecReadiness } from '../readiness-checker.js';
|
|
13
15
|
import { packageHandoff } from '../handoff-packager.js';
|
|
14
16
|
import { detectParadigms } from '../paradigm-detector.js';
|
|
@@ -30,7 +32,10 @@ export function parsePackageHandoffPayload(value) {
|
|
|
30
32
|
}
|
|
31
33
|
const candidate = value;
|
|
32
34
|
if (candidate.kind === 'package-handoff' &&
|
|
33
|
-
candidate.schemaVersion === 1
|
|
35
|
+
(candidate.schemaVersion === 1 ||
|
|
36
|
+
(candidate.schemaVersion === 2 &&
|
|
37
|
+
typeof candidate.selectedProjectPath === 'string' &&
|
|
38
|
+
typeof candidate.selectedSpecPath === 'string')) &&
|
|
34
39
|
typeof candidate.projectId === 'string' &&
|
|
35
40
|
typeof candidate.specId === 'string' &&
|
|
36
41
|
typeof candidate.specVersion === 'string') {
|
|
@@ -123,6 +128,29 @@ async function currentSpecVersion(projectId, specId, projectPath) {
|
|
|
123
128
|
const current = await specStore.getSpec(projectId, specId, projectPath);
|
|
124
129
|
return current?.spec_version;
|
|
125
130
|
}
|
|
131
|
+
async function resolveExecutionContext(payload) {
|
|
132
|
+
const verifiedV2SpecPath = payload.schemaVersion === 2
|
|
133
|
+
? await resolveVerifiedSpecPath(payload.specId, payload.selectedSpecPath, payload.selectedProjectPath)
|
|
134
|
+
: undefined;
|
|
135
|
+
const storedKnowledge = await knowledgeStore.getKnowledge(payload.projectId);
|
|
136
|
+
if (!storedKnowledge) {
|
|
137
|
+
throw new Error(`[Planu] Project '${payload.projectId}' not found. Run init_project first.`);
|
|
138
|
+
}
|
|
139
|
+
const projectPath = payload.schemaVersion === 2 ? payload.selectedProjectPath : storedKnowledge.projectPath;
|
|
140
|
+
if (!projectPath) {
|
|
141
|
+
throw new Error(`[Planu] Package handoff job ${payload.specId} has no registry-verified project path`);
|
|
142
|
+
}
|
|
143
|
+
const spec = await specStore.getSpec(payload.projectId, payload.specId, projectPath);
|
|
144
|
+
if (!spec?.specPath) {
|
|
145
|
+
throw new Error(`[Planu] Spec '${payload.specId}' not found under the selected project path`);
|
|
146
|
+
}
|
|
147
|
+
const absoluteSpecPath = verifiedV2SpecPath ??
|
|
148
|
+
(await resolveVerifiedSpecPath(payload.specId, spec.specPath, projectPath));
|
|
149
|
+
return {
|
|
150
|
+
spec: { ...spec, specPath: absoluteSpecPath },
|
|
151
|
+
knowledge: { ...storedKnowledge, projectPath },
|
|
152
|
+
};
|
|
153
|
+
}
|
|
126
154
|
async function runCoreStages(payload, spec, knowledge) {
|
|
127
155
|
const deadlineAt = Date.now() + coreBudgetMs();
|
|
128
156
|
const stageTimings = {};
|
|
@@ -133,6 +161,7 @@ async function runCoreStages(payload, spec, knowledge) {
|
|
|
133
161
|
}
|
|
134
162
|
const packageCoreResult = await runStageWithDeadline('package-core', Math.max(0, deadlineAt - Date.now()), (signal) => packageHandoff(spec, knowledge, {
|
|
135
163
|
specVersion: payload.specVersion,
|
|
164
|
+
strictSpecRead: true,
|
|
136
165
|
getCurrentSpecVersion: () => currentSpecVersion(payload.projectId, payload.specId, knowledge.projectPath),
|
|
137
166
|
signal,
|
|
138
167
|
}));
|
|
@@ -391,23 +420,21 @@ export class PackageHandoffJobExecutor {
|
|
|
391
420
|
});
|
|
392
421
|
}
|
|
393
422
|
reportClassifiedDegradation('HANDOFF_JOB_EXECUTION_FAILURE', error);
|
|
423
|
+
const message = error instanceof PortablePathError
|
|
424
|
+
? `[Planu] ${error.code}: ${error.message}`
|
|
425
|
+
: error instanceof Error
|
|
426
|
+
? error.message
|
|
427
|
+
: String(error);
|
|
394
428
|
return this.runtime.fail({
|
|
395
429
|
...identity,
|
|
396
430
|
workerId: this.workerId,
|
|
397
431
|
fencingToken: claimed.fencingToken,
|
|
398
|
-
error:
|
|
432
|
+
error: message.slice(0, 4_096),
|
|
399
433
|
});
|
|
400
434
|
}
|
|
401
435
|
}
|
|
402
436
|
async runJob(payload) {
|
|
403
|
-
const spec = await
|
|
404
|
-
if (!spec) {
|
|
405
|
-
throw new Error(`[Planu] Spec '${payload.specId}' not found in project '${payload.projectId}'`);
|
|
406
|
-
}
|
|
407
|
-
const knowledge = await knowledgeStore.getKnowledge(payload.projectId);
|
|
408
|
-
if (!knowledge) {
|
|
409
|
-
throw new Error(`[Planu] Project '${payload.projectId}' not found. Run init_project first.`);
|
|
410
|
-
}
|
|
437
|
+
const { spec, knowledge } = await resolveExecutionContext(payload);
|
|
411
438
|
const core = await runCoreStages(payload, spec, knowledge);
|
|
412
439
|
const pkgWithScore = { ...core.pkg, readinessScore: core.readinessScore };
|
|
413
440
|
const publishDegradation = core.pkg.staleVersionSkipped === true
|
|
@@ -453,14 +480,16 @@ export function schedulePackageHandoffJobExecution(projectId, workspaceId = WORK
|
|
|
453
480
|
runtime.close();
|
|
454
481
|
activeScopes.delete(scope);
|
|
455
482
|
}
|
|
456
|
-
})()
|
|
483
|
+
})().catch((error) => {
|
|
484
|
+
reportClassifiedDegradation('PACKAGE_HANDOFF_JOB_SCHEDULER_FAILURE', error);
|
|
485
|
+
});
|
|
457
486
|
});
|
|
458
487
|
}
|
|
459
488
|
function rescheduleRequested(state) {
|
|
460
489
|
return state.rescheduleRequested;
|
|
461
490
|
}
|
|
462
491
|
/** Re-enqueues accepted/checkpointed package-handoff work discovered after a process restart. */
|
|
463
|
-
export function recoverPackageHandoffJobsAtStartup() {
|
|
492
|
+
export async function recoverPackageHandoffJobsAtStartup() {
|
|
464
493
|
const runtime = new DurableJobRuntime();
|
|
465
494
|
try {
|
|
466
495
|
const scopes = runtime.listRunnableScopes();
|
|
@@ -470,7 +499,7 @@ export function recoverPackageHandoffJobsAtStartup() {
|
|
|
470
499
|
.some((job) => (job.state === 'accepted' || job.state === 'checkpointed') &&
|
|
471
500
|
isPackageHandoffJob(job.payload));
|
|
472
501
|
if (hasHandoffWork) {
|
|
473
|
-
|
|
502
|
+
await new PackageHandoffJobExecutor(runtime).runUntilIdle(scope.projectId, scope.workspaceId);
|
|
474
503
|
}
|
|
475
504
|
}
|
|
476
505
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
async function loadRecoveryActions() {
|
|
2
|
+
const [{ recoverValidateJobsAtStartup }, { recoverPackageHandoffJobsAtStartup }] = await Promise.all([
|
|
3
|
+
import('./validate-job-executor.js'),
|
|
4
|
+
import('./package-handoff-job-executor.js'),
|
|
5
|
+
]);
|
|
6
|
+
return {
|
|
7
|
+
recoverValidate: recoverValidateJobsAtStartup,
|
|
8
|
+
recoverPackageHandoff: recoverPackageHandoffJobsAtStartup,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export async function recoverDurableJobsAtStartup(load = loadRecoveryActions) {
|
|
12
|
+
const actions = await load();
|
|
13
|
+
await Promise.all([actions.recoverValidate(), actions.recoverPackageHandoff()]);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=startup-recovery.js.map
|
|
@@ -33,5 +33,5 @@ export declare function isValidateScopeActive(projectId: string, workspaceId?: s
|
|
|
33
33
|
/** Schedules background execution after the submit response can be flushed. */
|
|
34
34
|
export declare function scheduleValidateJobExecution(projectId: string, workspaceId?: string): void;
|
|
35
35
|
/** Re-enqueues accepted/checkpointed validate work discovered after a process restart. */
|
|
36
|
-
export declare function recoverValidateJobsAtStartup(options?: ValidateJobRecoveryOptions): void
|
|
36
|
+
export declare function recoverValidateJobsAtStartup(options?: ValidateJobRecoveryOptions): Promise<void>;
|
|
37
37
|
//# sourceMappingURL=validate-job-executor.d.ts.map
|
|
@@ -867,14 +867,34 @@ export function scheduleValidateJobExecution(projectId, workspaceId = WORKSPACE_
|
|
|
867
867
|
runtime.close();
|
|
868
868
|
activeScopes.delete(scope);
|
|
869
869
|
}
|
|
870
|
-
})()
|
|
870
|
+
})().catch((error) => {
|
|
871
|
+
reportClassifiedDegradation('VALIDATE_JOB_SCHEDULER_FAILURE', error);
|
|
872
|
+
});
|
|
871
873
|
});
|
|
872
874
|
}
|
|
873
875
|
function rescheduleRequested(state) {
|
|
874
876
|
return state.rescheduleRequested;
|
|
875
877
|
}
|
|
878
|
+
async function runValidateScopeUntilIdle(projectId, workspaceId) {
|
|
879
|
+
const runtime = new DurableJobRuntime();
|
|
880
|
+
try {
|
|
881
|
+
await new ValidateJobExecutor(runtime).runUntilIdle(projectId, workspaceId);
|
|
882
|
+
}
|
|
883
|
+
finally {
|
|
884
|
+
runtime.close();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
876
887
|
/** Re-enqueues accepted/checkpointed validate work discovered after a process restart. */
|
|
877
|
-
export function recoverValidateJobsAtStartup(options = {}) {
|
|
878
|
-
|
|
888
|
+
export async function recoverValidateJobsAtStartup(options = {}) {
|
|
889
|
+
const pending = [];
|
|
890
|
+
const runRecoveredScope = (projectId, workspaceId) => {
|
|
891
|
+
if (options.schedule) {
|
|
892
|
+
options.schedule(projectId, workspaceId);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
pending.push(runValidateScopeUntilIdle(projectId, workspaceId));
|
|
896
|
+
};
|
|
897
|
+
recoverValidateJobs(runRecoveredScope, options);
|
|
898
|
+
await Promise.all(pending);
|
|
879
899
|
}
|
|
880
900
|
//# sourceMappingURL=validate-job-executor.js.map
|
|
@@ -21,6 +21,8 @@ export declare function extractCanonicalFileOwnership(content: string): {
|
|
|
21
21
|
toTestDeclared: string[];
|
|
22
22
|
blockers: string[];
|
|
23
23
|
};
|
|
24
|
+
/** Return the exact ownership blockers enforced by package_handoff for one spec document. */
|
|
25
|
+
export declare function validateHandoffOwnership(content: string): string[];
|
|
24
26
|
export declare function packageHandoff(spec: Spec, knowledge: ProjectKnowledge, versionFence?: HandoffVersionFence): Promise<HandoffPackage & {
|
|
25
27
|
readonly staleVersionSkipped?: boolean;
|
|
26
28
|
}>;
|
|
@@ -500,6 +500,19 @@ function validateOwnershipAgreement(canonical, workPlan, testDeclaredPaths) {
|
|
|
500
500
|
];
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
|
+
function ownershipValidationBlockers(canonicalFiles, canonicalOwnership, workPlanOwnership) {
|
|
504
|
+
return [
|
|
505
|
+
...canonicalFiles.blockers,
|
|
506
|
+
...canonicalOwnership.blockers,
|
|
507
|
+
...workPlanOwnership.blockers,
|
|
508
|
+
...validateOwnershipAgreement(canonicalOwnership, workPlanOwnership, canonicalFiles.toTestDeclared),
|
|
509
|
+
];
|
|
510
|
+
}
|
|
511
|
+
/** Return the exact ownership blockers enforced by package_handoff for one spec document. */
|
|
512
|
+
export function validateHandoffOwnership(content) {
|
|
513
|
+
const ownershipContent = stripInertOwnershipMarkup(content);
|
|
514
|
+
return ownershipValidationBlockers(extractCanonicalFileOwnership(content), extractStrictCanonicalOwnership(ownershipContent), extractFileLevelWorkPlanOwnership(ownershipContent));
|
|
515
|
+
}
|
|
503
516
|
function extractBacktickedFiles(content) {
|
|
504
517
|
const files = new Set();
|
|
505
518
|
for (const match of content.matchAll(/`([^`\n]+)`/gu)) {
|
|
@@ -643,19 +656,25 @@ function buildConstraints(knowledge) {
|
|
|
643
656
|
}
|
|
644
657
|
async function readSpecFile(specPath, projectPath) {
|
|
645
658
|
if (isAbsolute(specPath)) {
|
|
646
|
-
return readFile(specPath, 'utf-8')
|
|
659
|
+
return readFile(specPath, 'utf-8');
|
|
647
660
|
}
|
|
648
661
|
if (!projectPath) {
|
|
649
662
|
return '';
|
|
650
663
|
}
|
|
651
|
-
return readFile(resolvePath(projectPath, specPath), 'utf-8')
|
|
664
|
+
return readFile(resolvePath(projectPath, specPath), 'utf-8');
|
|
652
665
|
}
|
|
653
666
|
// ── Public API ───────────────────────────────────────────────────────────────
|
|
654
667
|
export async function packageHandoff(spec, knowledge, versionFence) {
|
|
655
668
|
const warnings = [];
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
: '';
|
|
669
|
+
let rawSpecContent = '';
|
|
670
|
+
try {
|
|
671
|
+
rawSpecContent = spec.specPath ? await readSpecFile(spec.specPath, knowledge.projectPath) : '';
|
|
672
|
+
}
|
|
673
|
+
catch (error) {
|
|
674
|
+
if (versionFence?.strictSpecRead === true) {
|
|
675
|
+
throw error;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
659
678
|
const huContent = rawSpecContent ? stripFrontmatter(rawSpecContent) : '';
|
|
660
679
|
const fichaContent = huContent;
|
|
661
680
|
if (!huContent) {
|
|
@@ -706,10 +725,7 @@ export async function packageHandoff(spec, knowledge, versionFence) {
|
|
|
706
725
|
...(operational.testPlan.length === 0 ? ['Missing test plan'] : []),
|
|
707
726
|
...(operational.risks.length === 0 ? ['Missing risk analysis'] : []),
|
|
708
727
|
...(operational.ownership.length === 0 ? ['Missing ownership'] : []),
|
|
709
|
-
...canonicalFiles
|
|
710
|
-
...canonicalOwnership.blockers,
|
|
711
|
-
...workPlanOwnership.blockers,
|
|
712
|
-
...validateOwnershipAgreement(canonicalOwnership, workPlanOwnership, canonicalFiles.toTestDeclared),
|
|
728
|
+
...ownershipValidationBlockers(canonicalFiles, canonicalOwnership, workPlanOwnership),
|
|
713
729
|
...(!['draft', 'review', 'approved', 'implementing', 'done', 'discarded'].includes(spec.status)
|
|
714
730
|
? [`UNSUPPORTED_LIFECYCLE_STATUS: ${spec.status}`]
|
|
715
731
|
: []),
|