@planu/cli 6.0.0 → 6.0.2
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 +26 -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/code-scanner/layer-scanner.d.ts +3 -1
- package/dist/engine/code-scanner/layer-scanner.js +19 -3
- 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/deadline-io.d.ts +1 -1
- package/dist/engine/execution/deadline-io.js +2 -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 +18 -22
- 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.d.ts +1 -1
- package/dist/tools/update-status/index.js +25 -12
- 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 +10 -9
- 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,29 @@
|
|
|
1
|
+
## [6.0.2] - 2026-09-10
|
|
2
|
+
|
|
3
|
+
### Reliability
|
|
4
|
+
- prove lifecycle persistence, registered-worktree isolation, and implementation-change attribution end to end
|
|
5
|
+
- enforce current stable direct dependencies through a deterministic read-only preflight and pre-push guard
|
|
6
|
+
- distinguish actionable dependency drift from registry, timeout, empty-output, and malformed-output failures
|
|
7
|
+
|
|
8
|
+
### Maintenance
|
|
9
|
+
- refresh direct dependencies to their current stable compatible releases
|
|
10
|
+
- consolidate overlapping lifecycle specs and discard obsolete work
|
|
11
|
+
|
|
12
|
+
## [6.0.1] - 2026-09-10
|
|
13
|
+
|
|
14
|
+
### Cleanup
|
|
15
|
+
- remove 17 unreachable TypeScript modules and retired plugin, website, marketplace, release-orchestration, telemetry, native-launcher, and host assets
|
|
16
|
+
- reduce the maintained surface to the SDD runtime, CLI, lifecycle gates, and supported project detectors
|
|
17
|
+
|
|
18
|
+
### Reliability
|
|
19
|
+
- recover durable validation and handoff jobs before accepting traffic and report detached scheduler failures
|
|
20
|
+
- make migration lock reconciliation crash-safe and concurrent through an operating-system-backed SQLite guard
|
|
21
|
+
- enforce offline startup and equivalent reliability-policy checks in source and packed installations
|
|
22
|
+
|
|
23
|
+
### Performance
|
|
24
|
+
- reduce the production closure by about 54% and packed non-map bytes by about 49%
|
|
25
|
+
- improve median stdio startup by about 8% and reduce peak RSS by about 16%
|
|
26
|
+
|
|
1
27
|
## [6.0.0] - 2026-09-10
|
|
2
28
|
|
|
3
29
|
### Breaking Changes
|
package/dist/.planu-build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion":1,"commit":"
|
|
1
|
+
{"schemaVersion":1,"commit":"0b3ee8aba0826533bef0aebc7dc3aeb43999ab00"}
|
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
|
}
|
|
@@ -13,7 +13,9 @@ type AttributableOwnedPaths = {
|
|
|
13
13
|
* committed baseline. Failure is deliberately quiet: callers must not turn
|
|
14
14
|
* baseline tokens into implementation evidence when attribution is unavailable.
|
|
15
15
|
*/
|
|
16
|
-
export declare function resolveAttributableOwnedPaths(projectPath: string, ownedPaths: string[]): Promise<AttributableOwnedPaths>;
|
|
16
|
+
export declare function resolveAttributableOwnedPaths(projectPath: string, ownedPaths: string[], baselineSha?: string | null): Promise<AttributableOwnedPaths>;
|
|
17
|
+
/** Capture the selected checkout commit once so a lifecycle call has one stable diff baseline. */
|
|
18
|
+
export declare function captureAttributionBaseline(projectPath: string): Promise<string | null>;
|
|
17
19
|
/**
|
|
18
20
|
* Scan the spec's owned paths for evidence of implementation across 4 layers.
|
|
19
21
|
* Empty ownership yields an empty result — never a repository-wide scan.
|
|
@@ -6,13 +6,14 @@ import { execFile } from 'node:child_process';
|
|
|
6
6
|
import { promisify } from 'node:util';
|
|
7
7
|
import { fastReadFiles } from '../core-bridge.js';
|
|
8
8
|
const CODE_FILE_RE = /\.(ts|js|tsx|jsx)$/;
|
|
9
|
+
const GIT_COMMIT_RE = /^[a-f0-9]{40,64}$/u;
|
|
9
10
|
const execFileAsync = promisify(execFile);
|
|
10
11
|
/**
|
|
11
12
|
* Reduce the already-bounded ownership list to files changed from the current
|
|
12
13
|
* committed baseline. Failure is deliberately quiet: callers must not turn
|
|
13
14
|
* baseline tokens into implementation evidence when attribution is unavailable.
|
|
14
15
|
*/
|
|
15
|
-
export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
|
|
16
|
+
export async function resolveAttributableOwnedPaths(projectPath, ownedPaths, baselineSha) {
|
|
16
17
|
const bounded = [
|
|
17
18
|
...new Set(ownedPaths
|
|
18
19
|
.map((path) => normalize(path))
|
|
@@ -22,9 +23,13 @@ export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
|
|
|
22
23
|
return { available: true, paths: [] };
|
|
23
24
|
}
|
|
24
25
|
try {
|
|
26
|
+
const baseline = baselineSha === undefined ? await captureAttributionBaseline(projectPath) : baselineSha;
|
|
27
|
+
if (baseline === null) {
|
|
28
|
+
return { available: false, paths: [], diagnostic: 'git-baseline-unavailable' };
|
|
29
|
+
}
|
|
25
30
|
const commands = [
|
|
26
|
-
['diff', '--name-only', '--diff-filter=ACMRTUXB',
|
|
27
|
-
['diff', '--cached', '--name-only', '--diff-filter=ACMRTUXB',
|
|
31
|
+
['diff', '--name-only', '--diff-filter=ACMRTUXB', baseline, '--', ...bounded],
|
|
32
|
+
['diff', '--cached', '--name-only', '--diff-filter=ACMRTUXB', baseline, '--', ...bounded],
|
|
28
33
|
['ls-files', '--others', '--exclude-standard', '--', ...bounded],
|
|
29
34
|
];
|
|
30
35
|
const outputs = await Promise.all(commands.map((args) => execFileAsync('git', ['-C', projectPath, ...args], {
|
|
@@ -44,6 +49,17 @@ export async function resolveAttributableOwnedPaths(projectPath, ownedPaths) {
|
|
|
44
49
|
return { available: false, paths: [], diagnostic: 'git-baseline-unavailable' };
|
|
45
50
|
}
|
|
46
51
|
}
|
|
52
|
+
/** Capture the selected checkout commit once so a lifecycle call has one stable diff baseline. */
|
|
53
|
+
export async function captureAttributionBaseline(projectPath) {
|
|
54
|
+
try {
|
|
55
|
+
const { stdout } = await execFileAsync('git', ['-C', projectPath, 'rev-parse', '--verify', 'HEAD'], { encoding: 'utf8', maxBuffer: 1024 * 1024 });
|
|
56
|
+
const baseline = stdout.trim();
|
|
57
|
+
return GIT_COMMIT_RE.test(baseline) ? baseline : null;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
47
63
|
/**
|
|
48
64
|
* Scan the spec's owned paths for evidence of implementation across 4 layers.
|
|
49
65
|
* Empty ownership yields an empty result — never a repository-wide scan.
|
|
@@ -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>;
|
|
@@ -5,7 +5,7 @@ export declare function executionMkdir(path: string, options: MakeDirectoryOptio
|
|
|
5
5
|
recursive: true;
|
|
6
6
|
}): Promise<string | undefined>;
|
|
7
7
|
/** Exclusive-create helper for idempotency claims; never overwrites an owner. */
|
|
8
|
-
export declare function executionWriteFileExclusive(path: string, content: string, options?:
|
|
8
|
+
export declare function executionWriteFileExclusive(path: string, content: string, options?: Exclude<WriteFileOptions, BufferEncoding>): Promise<void>;
|
|
9
9
|
export declare function executionRename(source: string, target: string): Promise<void>;
|
|
10
10
|
export declare function executionLink(source: string, target: string): Promise<void>;
|
|
11
11
|
export declare function executionRemove(path: string, options?: {
|
|
@@ -7,9 +7,9 @@ export async function executionMkdir(path, options) {
|
|
|
7
7
|
return mkdir(path, options);
|
|
8
8
|
}
|
|
9
9
|
/** Exclusive-create helper for idempotency claims; never overwrites an owner. */
|
|
10
|
-
export async function executionWriteFileExclusive(path, content, options
|
|
10
|
+
export async function executionWriteFileExclusive(path, content, options) {
|
|
11
11
|
assertExecutionCanCommit();
|
|
12
|
-
await writeFile(path, content, { ...options, flag: 'wx' });
|
|
12
|
+
await writeFile(path, content, { ...(options ?? {}), flag: 'wx' });
|
|
13
13
|
}
|
|
14
14
|
export async function executionRename(source, target) {
|
|
15
15
|
assertExecutionCanCommit();
|
|
@@ -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
|