@planu/cli 8.2.12 → 8.2.14
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 +14 -0
- package/README.md +8 -0
- package/dist/sdd-engine/cli.js +0 -0
- package/dist/sdd-engine/host-rule-pack.js +1 -0
- package/dist/sdd-engine/server.d.ts +2 -1
- package/dist/sdd-engine/server.js +58 -10
- package/dist/sdd-engine/task-window.d.ts +9 -1
- package/dist/sdd-engine/task-window.js +65 -5
- package/dist/sdd-engine/tools/execution-tools.d.ts +3 -1
- package/dist/sdd-engine/tools/execution-tools.js +5 -4
- package/dist/sdd-engine/tools.d.ts +3 -1
- package/dist/sdd-engine/tools.js +2 -2
- package/dist/sdd-engine/verification-policy.d.ts +16 -0
- package/dist/sdd-engine/verification-policy.js +337 -0
- package/dist/sdd-engine/verification-runner.d.ts +17 -0
- package/dist/sdd-engine/verification-runner.js +347 -0
- package/dist/types/verification.d.ts +83 -0
- package/dist/types/verification.js +2 -0
- package/package.json +44 -41
- package/templates/AGENTS.md +3 -0
- package/templates/host/planu-sdd.md +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [8.2.14] - 2026-10-21
|
|
2
|
+
|
|
3
|
+
- retain the default 180-second verification limit and nine-tool contract; allow an operator-reviewed startup-only grant for one exact task, up to 600 seconds on Darwin/Linux
|
|
4
|
+
- pin canonical paths and full lock/command hashes; consume the grant at first spawn and quarantine uncertain cleanup or persistence
|
|
5
|
+
- propagate request cancellation, stdio EOF and repeated shutdown signals to owned-group cleanup; bound completion I/O and verify persisted task/lock bytes
|
|
6
|
+
- refresh devDependencies: commitlint 21.2.4, vitest 5.0.5, eslint 10.13.0, typescript-eslint 8.72.0, knip 6.42.1, happy-dom 21.0.4, tsc-alias 1.9.8, and type-coverage 2.30.4
|
|
7
|
+
- keep @types/node on 22.20.5, Vite on 8.3.4, and engines on Node >=22.13.0
|
|
8
|
+
|
|
9
|
+
## [8.2.13] - 2026-10-14
|
|
10
|
+
|
|
11
|
+
- the bug report form keeps the prefilled Planu version and host after a successful send and clears the previous status while sending
|
|
12
|
+
- planu.dev also skips WhatsApp previews, python-httpx, aiohttp, Postman, Java, libwww-perl, Node fetch, and Google-InspectionTool in its counters, and no longer mistakes CUBOT phones for bots
|
|
13
|
+
- the repository's executor, validator, auditor, and challenger agents can reach the sdd tools they are told to use
|
|
14
|
+
|
|
1
15
|
## [8.2.12] - 2026-10-14
|
|
2
16
|
|
|
3
17
|
- planu.dev/report takes bug reports: summary, details, Planu version, host, and optional contact email, stored without an IP for 365 days
|
package/README.md
CHANGED
|
@@ -108,6 +108,14 @@ The published server asks the host for MCP roots and binds to the open project t
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
## Trusted verification budget
|
|
112
|
+
|
|
113
|
+
Normal task verification still has a 180000 ms limit. An operator may authorize one pinned task in an isolated Darwin/Linux server with a strict startup-only budget of 180001–600000 ms. The grant binds the canonical workspace, feature, task, raw lock SHA-256 and exact command SHA-256. It is consumed before the first spawn, including failed attempts; uncertain cleanup or persistence quarantines that feature.
|
|
114
|
+
|
|
115
|
+
There is no timeout tool argument. The nine tools and the three complete-task fields are unchanged. The programmatic factory ignores the CLI environment unless its optional typed policy is explicitly supplied. Agents must not create or widen grants themselves.
|
|
116
|
+
|
|
117
|
+
The reviewed operator procedure is in the repository guide `docs/verification-budget.md`: finite local-build fingerprint, exact policy schema, per-process Node 24.22.1 PATH, SDK request budget of 660000 ms, one-use launch and safe disable/reconciliation. The grant is not a global registration or a cache replacement. Barbuno acceptance remains a separate handoff.
|
|
118
|
+
|
|
111
119
|
## The SDD Lifecycle (v8)
|
|
112
120
|
|
|
113
121
|
```text
|
package/dist/sdd-engine/cli.js
CHANGED
|
File without changes
|
|
@@ -12,6 +12,7 @@ The only SDD contract is \`.sdd/features/{FEAT-*}/spec.md\`, \`plan.md\`, and \`
|
|
|
12
12
|
- Never create, thin, or copy files under \`planu/specs/\`. Planu does not read that tree.
|
|
13
13
|
- If a pre-push, commitlint, or husky guard still requires \`planu/specs/SPEC-*/spec.md\`, that guard is the defect. Delete or rewrite it. Do not stub a SPEC file.
|
|
14
14
|
- Quality lives in \`.claude/skills/\`, \`.cursor/skills/\`, \`.agents/skills/\`, and \`.gemini/skills/\`. Specs stay in \`.sdd/features\`. There is no validate MCP tool.
|
|
15
|
+
- Agents must never grant themselves extra verification time or edit trusted launcher policy. Report budget failures for operator review; an approved startup grant does not change task or File Manifest authority.
|
|
15
16
|
`;
|
|
16
17
|
const PROHIBITION = /\b(never|do not|don't|no longer|not|forbidden|prohibited|deleted|removed|retired|invalid|reject(?:s|ed)?)\b/iu;
|
|
17
18
|
const LEGACY_TREE = /planu\/specs\/SPEC-|write (?:specs )?to planu\/specs/iu;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
|
|
2
|
+
import type { VerificationServerOptions } from '../types/verification.js';
|
|
3
|
+
export declare function createUltralightSddServer(workspaceRoot?: string, options?: VerificationServerOptions): McpServer;
|
|
3
4
|
export declare function runServer(): Promise<void>;
|
|
4
5
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1,24 +1,72 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { captureVerificationPolicy, resolveVerificationPolicy } from './verification-policy.js';
|
|
4
5
|
import { registerUltralightSddTools } from './tools.js';
|
|
5
6
|
const { version } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
6
|
-
export function createUltralightSddServer(workspaceRoot) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}, {
|
|
11
|
-
capabilities: {
|
|
12
|
-
tools: {},
|
|
13
|
-
},
|
|
7
|
+
export function createUltralightSddServer(workspaceRoot, options) {
|
|
8
|
+
const policy = resolveVerificationPolicy(options?.verificationPolicy, workspaceRoot);
|
|
9
|
+
const server = new McpServer({ name: 'sdd-engine', version }, {
|
|
10
|
+
capabilities: { tools: {} },
|
|
14
11
|
instructions: 'SDD Engine v8: FEAT-only state arbiter, File Manifest sandbox, and single-task context window for Spec-Driven Development.',
|
|
15
12
|
});
|
|
16
|
-
|
|
13
|
+
const pinnedRoot = policy.mode === 'scoped' ? policy.workspaceRoot : workspaceRoot;
|
|
14
|
+
const tasks = registerUltralightSddTools(server, pinnedRoot, policy);
|
|
15
|
+
if (policy.mode === 'scoped') {
|
|
16
|
+
const close = server.close.bind(server);
|
|
17
|
+
server.close = async () => {
|
|
18
|
+
await tasks.shutdown();
|
|
19
|
+
await close();
|
|
20
|
+
};
|
|
21
|
+
const previous = server.server.onclose;
|
|
22
|
+
server.server.onclose = () => {
|
|
23
|
+
previous?.();
|
|
24
|
+
void tasks.shutdown().catch(() => {
|
|
25
|
+
console.error('ERR_VERIFICATION_SHUTDOWN');
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
}
|
|
17
29
|
return server;
|
|
18
30
|
}
|
|
19
31
|
export async function runServer() {
|
|
20
|
-
const
|
|
32
|
+
const policy = captureVerificationPolicy(process.env.PLANU_VERIFICATION_TIMEOUT_POLICY);
|
|
33
|
+
const server = createUltralightSddServer(undefined, policy.mode === 'scoped' ? { verificationPolicy: policy } : undefined);
|
|
34
|
+
if (policy.mode === 'scoped') {
|
|
35
|
+
bindScopedShutdown(server);
|
|
36
|
+
}
|
|
21
37
|
const transport = new StdioServerTransport();
|
|
22
38
|
await server.connect(transport);
|
|
23
39
|
}
|
|
40
|
+
function bindScopedShutdown(server) {
|
|
41
|
+
let closing = false;
|
|
42
|
+
const shutdown = () => {
|
|
43
|
+
if (closing) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
closing = true;
|
|
47
|
+
void server
|
|
48
|
+
.close()
|
|
49
|
+
.catch(() => {
|
|
50
|
+
console.error('ERR_VERIFICATION_SHUTDOWN');
|
|
51
|
+
})
|
|
52
|
+
.finally(() => {
|
|
53
|
+
process.stdin.pause();
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
process.stdin.once('end', shutdown);
|
|
57
|
+
process.stdin.once('close', shutdown);
|
|
58
|
+
for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) {
|
|
59
|
+
process.on(signal, shutdown);
|
|
60
|
+
}
|
|
61
|
+
const protocol = server.server;
|
|
62
|
+
const previous = protocol.onclose;
|
|
63
|
+
protocol.onclose = () => {
|
|
64
|
+
previous?.();
|
|
65
|
+
process.stdin.removeListener('end', shutdown);
|
|
66
|
+
process.stdin.removeListener('close', shutdown);
|
|
67
|
+
for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) {
|
|
68
|
+
process.removeListener(signal, shutdown);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
24
72
|
//# sourceMappingURL=server.js.map
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { ActiveTaskResult, CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
|
|
2
|
+
import type { VerificationPolicy } from '../types/verification.js';
|
|
2
3
|
export declare class TaskWindowManager {
|
|
4
|
+
private readonly scopedPolicy;
|
|
5
|
+
private readonly scoped;
|
|
6
|
+
constructor(policy?: VerificationPolicy);
|
|
7
|
+
shutdown(): Promise<void>;
|
|
8
|
+
private activeTaskFromContent;
|
|
9
|
+
private selectScopedTask;
|
|
10
|
+
private commitScopedTask;
|
|
3
11
|
getActiveTask(tasksFilePath: string): Promise<SddResult<ActiveTaskResult>>;
|
|
4
12
|
private buildActiveTaskResult;
|
|
5
13
|
private parseTasks;
|
|
6
14
|
private extractTaskId;
|
|
7
|
-
completeTask(tasksFilePath: string, taskId: string, workspaceRoot: string, _verificationOutput: string): Promise<SddResult<CompleteTaskResult>>;
|
|
15
|
+
completeTask(tasksFilePath: string, taskId: string, workspaceRoot: string, _verificationOutput: string, signal?: AbortSignal): Promise<SddResult<CompleteTaskResult>>;
|
|
8
16
|
}
|
|
9
17
|
export declare function verificationCommand(taskMarkdown: string): string | null;
|
|
10
18
|
//# sourceMappingURL=task-window.d.ts.map
|
|
@@ -1,8 +1,54 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import * as fs from 'node:fs/promises';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
|
+
import { ScopedVerificationCoordinator } from './verification-runner.js';
|
|
5
|
+
import { persistScopedCompletionFiles, scopedVerificationEnvironment, } from './verification-policy.js';
|
|
4
6
|
import { hashArtifact } from './lock-integrity.js';
|
|
5
7
|
export class TaskWindowManager {
|
|
8
|
+
scopedPolicy;
|
|
9
|
+
scoped;
|
|
10
|
+
constructor(policy) {
|
|
11
|
+
this.scopedPolicy = policy?.mode === 'scoped' ? policy : undefined;
|
|
12
|
+
this.scoped = this.scopedPolicy
|
|
13
|
+
? new ScopedVerificationCoordinator(this.scopedPolicy)
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
async shutdown() {
|
|
17
|
+
await this.scoped?.shutdown();
|
|
18
|
+
}
|
|
19
|
+
activeTaskFromContent(content) {
|
|
20
|
+
return this.buildActiveTaskResult(this.parseTasks(content.split('\n')));
|
|
21
|
+
}
|
|
22
|
+
selectScopedTask(content) {
|
|
23
|
+
const result = this.activeTaskFromContent(content);
|
|
24
|
+
const active = result.success ? result.data.activeTask : null;
|
|
25
|
+
return active
|
|
26
|
+
? {
|
|
27
|
+
taskId: active.taskId,
|
|
28
|
+
command: verificationCommand(active.fullTaskMarkdown),
|
|
29
|
+
}
|
|
30
|
+
: null;
|
|
31
|
+
}
|
|
32
|
+
async commitScopedTask(policy, taskId, snapshot, output, signal) {
|
|
33
|
+
const summary = summarizeEvidence(output);
|
|
34
|
+
const marked = markTaskVerified(snapshot.tasksContent.split('\n'), taskId, summary);
|
|
35
|
+
if (marked === null) {
|
|
36
|
+
return taskOutOfSequence(taskId, null);
|
|
37
|
+
}
|
|
38
|
+
const written = marked.join('\n');
|
|
39
|
+
const persisted = await persistScopedCompletionFiles(policy, snapshot, written, signal);
|
|
40
|
+
if (!persisted.success) {
|
|
41
|
+
return persisted;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
success: true,
|
|
45
|
+
data: {
|
|
46
|
+
completedTaskId: taskId,
|
|
47
|
+
verificationSummary: summary,
|
|
48
|
+
remainingTasks: remainingTaskCount(this.activeTaskFromContent(written)),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
6
52
|
async getActiveTask(tasksFilePath) {
|
|
7
53
|
let content;
|
|
8
54
|
try {
|
|
@@ -18,8 +64,7 @@ export class TaskWindowManager {
|
|
|
18
64
|
},
|
|
19
65
|
};
|
|
20
66
|
}
|
|
21
|
-
|
|
22
|
-
return this.buildActiveTaskResult(acc);
|
|
67
|
+
return this.activeTaskFromContent(content);
|
|
23
68
|
}
|
|
24
69
|
buildActiveTaskResult(acc) {
|
|
25
70
|
if (acc.totalTasks === 0) {
|
|
@@ -97,7 +142,21 @@ export class TaskWindowManager {
|
|
|
97
142
|
}
|
|
98
143
|
return { id: `TASK-${index}`, title: rawTitle };
|
|
99
144
|
}
|
|
100
|
-
async completeTask(tasksFilePath, taskId, workspaceRoot, _verificationOutput) {
|
|
145
|
+
async completeTask(tasksFilePath, taskId, workspaceRoot, _verificationOutput, signal) {
|
|
146
|
+
const policy = this.scopedPolicy;
|
|
147
|
+
if (this.scoped && policy) {
|
|
148
|
+
const scoped = await this.scoped.complete({
|
|
149
|
+
tasksPath: tasksFilePath,
|
|
150
|
+
taskId,
|
|
151
|
+
workspaceRoot,
|
|
152
|
+
signal,
|
|
153
|
+
selectTask: (content) => this.selectScopedTask(content),
|
|
154
|
+
commit: (snapshot, output, abortSignal) => this.commitScopedTask(policy, taskId, snapshot, output, abortSignal),
|
|
155
|
+
});
|
|
156
|
+
if (scoped) {
|
|
157
|
+
return scoped;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
101
160
|
let content;
|
|
102
161
|
try {
|
|
103
162
|
content = await fs.readFile(tasksFilePath, 'utf-8');
|
|
@@ -117,7 +176,7 @@ export class TaskWindowManager {
|
|
|
117
176
|
if (command === null) {
|
|
118
177
|
return verificationMissing();
|
|
119
178
|
}
|
|
120
|
-
const run = await runVerification(workspaceRoot, command);
|
|
179
|
+
const run = await runVerification(workspaceRoot, command, this.scopedPolicy ? scopedVerificationEnvironment() : undefined);
|
|
121
180
|
if (!run.ok) {
|
|
122
181
|
return verificationFailed(run);
|
|
123
182
|
}
|
|
@@ -224,12 +283,13 @@ export function verificationCommand(taskMarkdown) {
|
|
|
224
283
|
}
|
|
225
284
|
return command;
|
|
226
285
|
}
|
|
227
|
-
function runVerification(cwd, command) {
|
|
286
|
+
function runVerification(cwd, command, env) {
|
|
228
287
|
return new Promise((resolve) => {
|
|
229
288
|
const child = spawn(command, {
|
|
230
289
|
cwd,
|
|
231
290
|
shell: true,
|
|
232
291
|
timeout: VERIFICATION_TIMEOUT_MS,
|
|
292
|
+
...(env ? { env } : {}),
|
|
233
293
|
windowsHide: true,
|
|
234
294
|
});
|
|
235
295
|
let output = '';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { VerificationPolicy } from '../../types/verification.js';
|
|
1
2
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { TaskWindowManager } from '../task-window.js';
|
|
2
4
|
import type { SddWorkspaceHandle } from '../../types/sdd-engine.js';
|
|
3
|
-
export declare function registerExecutionTools(server: McpServer, workspace: SddWorkspaceHandle):
|
|
5
|
+
export declare function registerExecutionTools(server: McpServer, workspace: SddWorkspaceHandle, policy?: VerificationPolicy): TaskWindowManager;
|
|
4
6
|
//# sourceMappingURL=execution-tools.d.ts.map
|
|
@@ -6,13 +6,14 @@ import { TaskWindowManager } from '../task-window.js';
|
|
|
6
6
|
import { formatResult } from './format-result.js';
|
|
7
7
|
import { verifyLockedTrinity } from '../lock-integrity.js';
|
|
8
8
|
import { homeFallbackFailure } from '../workspace-root.js';
|
|
9
|
-
export function registerExecutionTools(server, workspace) {
|
|
10
|
-
const taskWindow = new TaskWindowManager();
|
|
9
|
+
export function registerExecutionTools(server, workspace, policy) {
|
|
10
|
+
const taskWindow = new TaskWindowManager(policy);
|
|
11
11
|
registerReadArtifactTool(server, workspace);
|
|
12
12
|
registerReadFileSliceTool(server, workspace);
|
|
13
13
|
registerGetActiveTaskTool(server, workspace, taskWindow);
|
|
14
14
|
registerApplyPatchTool(server, workspace);
|
|
15
15
|
registerCompleteTaskTool(server, workspace, taskWindow);
|
|
16
|
+
return taskWindow;
|
|
16
17
|
}
|
|
17
18
|
function registerReadArtifactTool(server, workspace) {
|
|
18
19
|
server.registerTool('sdd_read_spec_artifact', {
|
|
@@ -91,7 +92,7 @@ function registerCompleteTaskTool(server, workspace, taskWindow) {
|
|
|
91
92
|
server.registerTool('sdd_complete_task', {
|
|
92
93
|
description: 'Completes the active task by running its Verification command in the workspace and storing that output. verification_output is accepted and ignored.',
|
|
93
94
|
inputSchema: CompleteTaskInputSchema.shape,
|
|
94
|
-
}, async (rawArgs) => {
|
|
95
|
+
}, async (rawArgs, extra) => {
|
|
95
96
|
const args = CompleteTaskInputSchema.parse(rawArgs);
|
|
96
97
|
const resolved = await workspace.resolve();
|
|
97
98
|
const homeError = homeFallbackFailure(resolved, 'sdd_complete_task');
|
|
@@ -104,7 +105,7 @@ function registerCompleteTaskTool(server, workspace, taskWindow) {
|
|
|
104
105
|
return lockError;
|
|
105
106
|
}
|
|
106
107
|
const tasksPath = path.join(featDir, 'tasks.md');
|
|
107
|
-
const result = await taskWindow.completeTask(tasksPath, args.task_id, resolved.workspaceRoot, args.verification_output);
|
|
108
|
+
const result = await taskWindow.completeTask(tasksPath, args.task_id, resolved.workspaceRoot, args.verification_output, extra.signal);
|
|
108
109
|
return formatResult(result);
|
|
109
110
|
});
|
|
110
111
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { VerificationPolicy } from '../types/verification.js';
|
|
2
|
+
import type { TaskWindowManager } from './task-window.js';
|
|
1
3
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
export declare function registerUltralightSddTools(server: McpServer, pinnedRoot?: string):
|
|
4
|
+
export declare function registerUltralightSddTools(server: McpServer, pinnedRoot?: string, policy?: VerificationPolicy): TaskWindowManager;
|
|
3
5
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/sdd-engine/tools.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { McpClientWorkspace } from './client-workspace.js';
|
|
2
2
|
import { registerWorkspaceTools } from './tools/workspace-tools.js';
|
|
3
3
|
import { registerExecutionTools } from './tools/execution-tools.js';
|
|
4
|
-
export function registerUltralightSddTools(server, pinnedRoot) {
|
|
4
|
+
export function registerUltralightSddTools(server, pinnedRoot, policy) {
|
|
5
5
|
const workspace = new McpClientWorkspace(server, pinnedRoot);
|
|
6
6
|
registerWorkspaceTools(server, workspace);
|
|
7
|
-
registerExecutionTools(server, workspace);
|
|
7
|
+
return registerExecutionTools(server, workspace, policy);
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SddFailure, SddResult } from '../types/sdd-engine.js';
|
|
2
|
+
import type { ScopedPolicy, ScopedSnapshotResult, ScopedTaskSelector, ScopedVerificationSnapshot, VerificationPolicy } from '../types/verification.js';
|
|
3
|
+
export declare const DEFAULT_VERIFICATION_TIMEOUT_MS = 180000;
|
|
4
|
+
export declare function resolveVerificationPolicy(input?: unknown, workspaceRoot?: string, platform?: NodeJS.Platform): VerificationPolicy;
|
|
5
|
+
export declare function captureVerificationPolicy(raw: string | undefined, workspaceRoot?: string): VerificationPolicy;
|
|
6
|
+
export declare function verificationDigest(content: string | Uint8Array): string;
|
|
7
|
+
export declare function isScopedVerificationFeature(policy: ScopedPolicy, featureDirectory: string): Promise<boolean>;
|
|
8
|
+
export declare function readScopedVerificationSnapshot(policy: ScopedPolicy, tasksPath: string, workspaceRoot: string, requestedTaskId: string, selectTask: ScopedTaskSelector): Promise<ScopedSnapshotResult>;
|
|
9
|
+
export declare function revalidateScopedVerificationSnapshot(policy: ScopedPolicy, snapshot: ScopedVerificationSnapshot, selectTask: ScopedTaskSelector): Promise<ScopedSnapshotResult>;
|
|
10
|
+
export declare function uncertainCompletion(): SddFailure;
|
|
11
|
+
export declare function persistScopedCompletionFiles(policy: ScopedPolicy, snapshot: ScopedVerificationSnapshot, writtenTasks: string, signal: AbortSignal): Promise<SddResult<null>>;
|
|
12
|
+
export declare function scopedFeaturePathFailure(policy: ScopedPolicy): Promise<SddFailure | null>;
|
|
13
|
+
export declare function scopedVerificationEnvironment(): NodeJS.ProcessEnv;
|
|
14
|
+
export declare function scopedFailure(details: Record<string, unknown>): SddFailure;
|
|
15
|
+
export declare function cancelledVerification(signal: AbortSignal): SddFailure | null;
|
|
16
|
+
//# sourceMappingURL=verification-policy.d.ts.map
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync, realpathSync } from 'node:fs';
|
|
3
|
+
import * as fs from 'node:fs/promises';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export const DEFAULT_VERIFICATION_TIMEOUT_MS = 180000;
|
|
7
|
+
const MAX_VERIFICATION_TIMEOUT_MS = 600000;
|
|
8
|
+
const hashSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
9
|
+
const policySchema = z.discriminatedUnion('mode', [
|
|
10
|
+
z.strictObject({ version: z.literal(1), mode: z.literal('disabled') }),
|
|
11
|
+
z.strictObject({
|
|
12
|
+
version: z.literal(1),
|
|
13
|
+
mode: z.literal('scoped'),
|
|
14
|
+
workspaceRoot: z.string().min(1),
|
|
15
|
+
featureId: z.string().regex(/^FEAT[-_][A-Z0-9_-]+$/u),
|
|
16
|
+
taskId: z.string().regex(/^TASK-[A-Z0-9_-]+$/u),
|
|
17
|
+
timeoutMs: z.number().int().min(180001).max(MAX_VERIFICATION_TIMEOUT_MS),
|
|
18
|
+
lockSha256: hashSchema,
|
|
19
|
+
verificationCommandSha256: hashSchema,
|
|
20
|
+
}),
|
|
21
|
+
]);
|
|
22
|
+
const lockSchema = z.object({
|
|
23
|
+
specHash: hashSchema,
|
|
24
|
+
planHash: hashSchema,
|
|
25
|
+
tasksHash: hashSchema,
|
|
26
|
+
});
|
|
27
|
+
export function resolveVerificationPolicy(input, workspaceRoot, platform = process.platform) {
|
|
28
|
+
try {
|
|
29
|
+
if (input === undefined) {
|
|
30
|
+
return Object.freeze({ mode: 'default', timeoutMs: DEFAULT_VERIFICATION_TIMEOUT_MS });
|
|
31
|
+
}
|
|
32
|
+
const policy = policySchema.parse(input);
|
|
33
|
+
if (policy.mode === 'disabled') {
|
|
34
|
+
return Object.freeze({ mode: 'default', timeoutMs: DEFAULT_VERIFICATION_TIMEOUT_MS });
|
|
35
|
+
}
|
|
36
|
+
if (!['darwin', 'linux'].includes(platform) ||
|
|
37
|
+
!isCanonicalRoot(policy.workspaceRoot) ||
|
|
38
|
+
(workspaceRoot !== undefined && workspaceRoot !== policy.workspaceRoot)) {
|
|
39
|
+
throw new Error('Invalid pin');
|
|
40
|
+
}
|
|
41
|
+
return Object.freeze({ ...policy });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new Error('ERR_VERIFICATION_POLICY_INVALID');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function captureVerificationPolicy(raw, workspaceRoot) {
|
|
48
|
+
if (raw === undefined) {
|
|
49
|
+
return resolveVerificationPolicy(undefined, workspaceRoot);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const input = JSON.parse(raw);
|
|
53
|
+
return resolveVerificationPolicy(input, workspaceRoot);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error('ERR_VERIFICATION_POLICY_INVALID');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function isCanonicalRoot(root) {
|
|
60
|
+
return (path.isAbsolute(root) &&
|
|
61
|
+
path.normalize(root) === root &&
|
|
62
|
+
realpathSync(root) === root &&
|
|
63
|
+
!lstatSync(root).isSymbolicLink() &&
|
|
64
|
+
lstatSync(root).isDirectory());
|
|
65
|
+
}
|
|
66
|
+
export function verificationDigest(content) {
|
|
67
|
+
return createHash('sha256').update(content).digest('hex');
|
|
68
|
+
}
|
|
69
|
+
export async function isScopedVerificationFeature(policy, featureDirectory) {
|
|
70
|
+
const granted = path.join(policy.workspaceRoot, '.sdd', 'features', policy.featureId);
|
|
71
|
+
if (path.resolve(featureDirectory) === granted) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const [requested, expected] = await Promise.all([fs.stat(featureDirectory), fs.stat(granted)]);
|
|
76
|
+
return requested.dev === expected.dev && requested.ino === expected.ino;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function snapshotFailure(workspace = false) {
|
|
83
|
+
return {
|
|
84
|
+
success: false,
|
|
85
|
+
error: {
|
|
86
|
+
code: workspace ? 'ERR_WORKSPACE_UNRESOLVED' : 'ERR_SPEC_DRIFT',
|
|
87
|
+
message: 'Scoped verification context does not match the trusted startup policy.',
|
|
88
|
+
trigger: 'sdd_complete_task',
|
|
89
|
+
details: {
|
|
90
|
+
reason: workspace
|
|
91
|
+
? 'verification_policy_workspace_mismatch'
|
|
92
|
+
: 'verification_policy_mismatch',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
class ScopedPathBindingError extends Error {
|
|
98
|
+
}
|
|
99
|
+
async function physicalIdentity(expected, directory) {
|
|
100
|
+
const binding = await Promise.all([fs.realpath(expected), fs.lstat(expected)]).catch(() => {
|
|
101
|
+
if (directory) {
|
|
102
|
+
throw new ScopedPathBindingError('Missing physical directory');
|
|
103
|
+
}
|
|
104
|
+
throw new Error('Missing artifact');
|
|
105
|
+
});
|
|
106
|
+
const [real, stat] = binding;
|
|
107
|
+
if (real !== expected ||
|
|
108
|
+
stat.isSymbolicLink() ||
|
|
109
|
+
(directory ? !stat.isDirectory() : !stat.isFile())) {
|
|
110
|
+
throw new ScopedPathBindingError('Invalid physical binding');
|
|
111
|
+
}
|
|
112
|
+
return Object.freeze({ path: expected, device: stat.dev, inode: stat.ino });
|
|
113
|
+
}
|
|
114
|
+
async function snapshotIdentities(policy) {
|
|
115
|
+
const sdd = path.join(policy.workspaceRoot, '.sdd');
|
|
116
|
+
const features = path.join(sdd, 'features');
|
|
117
|
+
const feature = path.join(features, policy.featureId);
|
|
118
|
+
const directories = [policy.workspaceRoot, sdd, features, feature];
|
|
119
|
+
const files = ['.lock', 'spec.md', 'plan.md', 'tasks.md'].map((name) => path.join(feature, name));
|
|
120
|
+
const directoryBindings = [];
|
|
121
|
+
for (const entry of directories) {
|
|
122
|
+
directoryBindings.push(await physicalIdentity(entry, true));
|
|
123
|
+
}
|
|
124
|
+
const fileBindings = await Promise.all(files.map((entry) => physicalIdentity(entry, false)));
|
|
125
|
+
return Object.freeze([...directoryBindings, ...fileBindings]);
|
|
126
|
+
}
|
|
127
|
+
function sameIdentities(before, after) {
|
|
128
|
+
return (before.length === after.length &&
|
|
129
|
+
before.every((entry, index) => {
|
|
130
|
+
const next = after[index];
|
|
131
|
+
return (entry.path === next?.path && entry.device === next.device && entry.inode === next.inode);
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
async function readUtf8(file, signal) {
|
|
135
|
+
const bytes = await fs.readFile(file, { signal });
|
|
136
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
137
|
+
}
|
|
138
|
+
export async function readScopedVerificationSnapshot(policy, tasksPath, workspaceRoot, requestedTaskId, selectTask) {
|
|
139
|
+
if (workspaceRoot !== policy.workspaceRoot) {
|
|
140
|
+
return snapshotFailure(true);
|
|
141
|
+
}
|
|
142
|
+
const featurePath = path.join(workspaceRoot, '.sdd', 'features', policy.featureId);
|
|
143
|
+
if (tasksPath !== path.join(featurePath, 'tasks.md')) {
|
|
144
|
+
return snapshotFailure(true);
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const identities = await snapshotIdentities(policy);
|
|
148
|
+
const [specContent, planContent, tasksContent, lockContent] = await Promise.all([
|
|
149
|
+
readUtf8(path.join(featurePath, 'spec.md')),
|
|
150
|
+
readUtf8(path.join(featurePath, 'plan.md')),
|
|
151
|
+
readUtf8(path.join(featurePath, 'tasks.md')),
|
|
152
|
+
readUtf8(path.join(featurePath, '.lock')),
|
|
153
|
+
]);
|
|
154
|
+
const lockValue = JSON.parse(lockContent);
|
|
155
|
+
const lock = lockSchema.parse(lockValue);
|
|
156
|
+
if (verificationDigest(lockContent) !== policy.lockSha256 ||
|
|
157
|
+
verificationDigest(specContent) !== lock.specHash ||
|
|
158
|
+
verificationDigest(planContent) !== lock.planHash ||
|
|
159
|
+
verificationDigest(tasksContent) !== lock.tasksHash ||
|
|
160
|
+
!sameIdentities(identities, await snapshotIdentities(policy))) {
|
|
161
|
+
return snapshotFailure();
|
|
162
|
+
}
|
|
163
|
+
const selected = selectTask(tasksContent);
|
|
164
|
+
if (requestedTaskId.toUpperCase() !== policy.taskId ||
|
|
165
|
+
selected?.taskId.toUpperCase() !== requestedTaskId.toUpperCase()) {
|
|
166
|
+
return {
|
|
167
|
+
success: false,
|
|
168
|
+
error: {
|
|
169
|
+
code: 'ERR_TASK_OUT_OF_SEQUENCE',
|
|
170
|
+
message: 'The requested task is not the granted active task.',
|
|
171
|
+
trigger: 'sdd_complete_task',
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (selected.command === null) {
|
|
176
|
+
return {
|
|
177
|
+
success: false,
|
|
178
|
+
error: {
|
|
179
|
+
code: 'ERR_VERIFICATION_MISSING',
|
|
180
|
+
message: 'The granted active task requires one valid Verification command.',
|
|
181
|
+
trigger: 'sdd_complete_task',
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
if (verificationDigest(selected.command) !== policy.verificationCommandSha256) {
|
|
186
|
+
return snapshotFailure();
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
success: true,
|
|
190
|
+
data: Object.freeze({
|
|
191
|
+
workspaceRoot,
|
|
192
|
+
featureId: policy.featureId,
|
|
193
|
+
taskId: policy.taskId,
|
|
194
|
+
tasksPath,
|
|
195
|
+
specContent,
|
|
196
|
+
planContent,
|
|
197
|
+
tasksContent,
|
|
198
|
+
lockContent,
|
|
199
|
+
command: selected.command,
|
|
200
|
+
timeoutMs: policy.timeoutMs,
|
|
201
|
+
identities,
|
|
202
|
+
}),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
return snapshotFailure(error instanceof ScopedPathBindingError);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
export async function revalidateScopedVerificationSnapshot(policy, snapshot, selectTask) {
|
|
210
|
+
const current = await readScopedVerificationSnapshot(policy, snapshot.tasksPath, snapshot.workspaceRoot, snapshot.taskId, selectTask);
|
|
211
|
+
if (!current.success) {
|
|
212
|
+
return current;
|
|
213
|
+
}
|
|
214
|
+
if (!sameIdentities(snapshot.identities, current.data.identities)) {
|
|
215
|
+
return snapshotFailure(true);
|
|
216
|
+
}
|
|
217
|
+
if (current.data.specContent !== snapshot.specContent ||
|
|
218
|
+
current.data.planContent !== snapshot.planContent ||
|
|
219
|
+
current.data.tasksContent !== snapshot.tasksContent ||
|
|
220
|
+
current.data.lockContent !== snapshot.lockContent ||
|
|
221
|
+
current.data.command !== snapshot.command) {
|
|
222
|
+
return snapshotFailure();
|
|
223
|
+
}
|
|
224
|
+
return current;
|
|
225
|
+
}
|
|
226
|
+
export function uncertainCompletion() {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
error: {
|
|
230
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
231
|
+
message: 'Completion persistence is uncertain; operator reconciliation is required.',
|
|
232
|
+
trigger: 'sdd_complete_task',
|
|
233
|
+
details: { reason: 'verification_completion_io', completionState: 'uncertain' },
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
export async function persistScopedCompletionFiles(policy, snapshot, writtenTasks, signal) {
|
|
238
|
+
const feature = path.dirname(snapshot.tasksPath);
|
|
239
|
+
const lockPath = path.join(feature, '.lock');
|
|
240
|
+
const lockValue = JSON.parse(snapshot.lockContent);
|
|
241
|
+
const lock = z.record(z.string(), z.unknown()).parse(lockValue);
|
|
242
|
+
const writtenLock = JSON.stringify({ ...lock, tasksHash: verificationDigest(writtenTasks) }, null, 2);
|
|
243
|
+
const cancelled = cancelledVerification(signal);
|
|
244
|
+
if (cancelled) {
|
|
245
|
+
return cancelled;
|
|
246
|
+
}
|
|
247
|
+
const deadline = new AbortController();
|
|
248
|
+
const deadlineAt = performance.now() + 5000;
|
|
249
|
+
const timer = setTimeout(() => {
|
|
250
|
+
deadline.abort();
|
|
251
|
+
}, 5000);
|
|
252
|
+
const step = (operation) => boundedPersistenceStep(operation, deadline.signal);
|
|
253
|
+
try {
|
|
254
|
+
await step((io) => fs.writeFile(snapshot.tasksPath, writtenTasks, { encoding: 'utf8', signal: io }));
|
|
255
|
+
if ((await step((io) => readUtf8(lockPath, io))) !== snapshot.lockContent) {
|
|
256
|
+
return uncertainCompletion();
|
|
257
|
+
}
|
|
258
|
+
await step((io) => fs.writeFile(lockPath, writtenLock, { encoding: 'utf8', signal: io }));
|
|
259
|
+
const identities = await step(() => snapshotIdentities(policy));
|
|
260
|
+
const [tasks, rawLock, spec, plan] = await step((io) => Promise.all([
|
|
261
|
+
readUtf8(snapshot.tasksPath, io),
|
|
262
|
+
readUtf8(lockPath, io),
|
|
263
|
+
readUtf8(path.join(feature, 'spec.md'), io),
|
|
264
|
+
readUtf8(path.join(feature, 'plan.md'), io),
|
|
265
|
+
]));
|
|
266
|
+
const finalIdentities = await step(() => snapshotIdentities(policy));
|
|
267
|
+
signal.throwIfAborted();
|
|
268
|
+
if (performance.now() >= deadlineAt) {
|
|
269
|
+
return uncertainCompletion();
|
|
270
|
+
}
|
|
271
|
+
if (!sameIdentities(snapshot.identities, identities) ||
|
|
272
|
+
!sameIdentities(identities, finalIdentities) ||
|
|
273
|
+
tasks !== writtenTasks ||
|
|
274
|
+
rawLock !== writtenLock ||
|
|
275
|
+
spec !== snapshot.specContent ||
|
|
276
|
+
plan !== snapshot.planContent) {
|
|
277
|
+
return uncertainCompletion();
|
|
278
|
+
}
|
|
279
|
+
return { success: true, data: null };
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return uncertainCompletion();
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
clearTimeout(timer);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async function boundedPersistenceStep(operation, signal) {
|
|
289
|
+
signal.throwIfAborted();
|
|
290
|
+
let rejectAbort;
|
|
291
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
292
|
+
rejectAbort = () => {
|
|
293
|
+
reject(new Error('Completion I/O deadline exceeded'));
|
|
294
|
+
};
|
|
295
|
+
signal.addEventListener('abort', rejectAbort, { once: true });
|
|
296
|
+
});
|
|
297
|
+
try {
|
|
298
|
+
return await Promise.race([operation(signal), aborted]);
|
|
299
|
+
}
|
|
300
|
+
finally {
|
|
301
|
+
if (rejectAbort) {
|
|
302
|
+
signal.removeEventListener('abort', rejectAbort);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
export async function scopedFeaturePathFailure(policy) {
|
|
307
|
+
try {
|
|
308
|
+
await snapshotIdentities(policy);
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return snapshotFailure(true);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
export function scopedVerificationEnvironment() {
|
|
316
|
+
const env = { ...process.env };
|
|
317
|
+
delete env.PLANU_VERIFICATION_TIMEOUT_POLICY;
|
|
318
|
+
return env;
|
|
319
|
+
}
|
|
320
|
+
export function scopedFailure(details) {
|
|
321
|
+
return {
|
|
322
|
+
success: false,
|
|
323
|
+
error: {
|
|
324
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
325
|
+
message: 'Scoped verification did not produce a safely committed certificate.',
|
|
326
|
+
trigger: 'sdd_complete_task',
|
|
327
|
+
details,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
export function cancelledVerification(signal) {
|
|
332
|
+
if (!signal.aborted) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
return scopedFailure({ reason: 'verification_cancelled', cancelled: true, timedOut: false });
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=verification-policy.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SddResult, CompleteTaskResult } from '../types/sdd-engine.js';
|
|
2
|
+
import type { ScopedVerificationRun, ScopedPolicy, ScopedVerificationCompletionContext, ScopedVerificationRunnerOptions, ScopedVerificationRunnerTiming } from '../types/verification.js';
|
|
3
|
+
export declare function runScopedVerification(options: ScopedVerificationRunnerOptions, timing?: ScopedVerificationRunnerTiming): Promise<ScopedVerificationRun>;
|
|
4
|
+
export declare class ScopedVerificationCoordinator {
|
|
5
|
+
private readonly policy;
|
|
6
|
+
private running;
|
|
7
|
+
private consumed;
|
|
8
|
+
private quarantined;
|
|
9
|
+
private readonly shutdownController;
|
|
10
|
+
private pending;
|
|
11
|
+
constructor(policy: ScopedPolicy);
|
|
12
|
+
shutdown(): Promise<void>;
|
|
13
|
+
complete(context: ScopedVerificationCompletionContext): Promise<SddResult<CompleteTaskResult> | null>;
|
|
14
|
+
private stateFailure;
|
|
15
|
+
private execute;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=verification-runner.d.ts.map
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { isScopedVerificationFeature, scopedFeaturePathFailure, scopedVerificationEnvironment, scopedFailure, cancelledVerification, uncertainCompletion, readScopedVerificationSnapshot, revalidateScopedVerificationSnapshot, } from './verification-policy.js';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
function groupState(pid) {
|
|
5
|
+
if (pid === undefined) {
|
|
6
|
+
return 'absent';
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
process.kill(-pid, 0);
|
|
10
|
+
return 'present';
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return error instanceof Error && 'code' in error && error.code === 'ESRCH'
|
|
14
|
+
? 'absent'
|
|
15
|
+
: 'unknown';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
class ScopedVerificationExecution {
|
|
19
|
+
options;
|
|
20
|
+
resolve;
|
|
21
|
+
child;
|
|
22
|
+
output = '';
|
|
23
|
+
exitCode = null;
|
|
24
|
+
exitSignal = null;
|
|
25
|
+
timedOut = false;
|
|
26
|
+
cancelled = false;
|
|
27
|
+
closed = false;
|
|
28
|
+
exited = false;
|
|
29
|
+
spawnFailed = false;
|
|
30
|
+
residual = false;
|
|
31
|
+
settled = false;
|
|
32
|
+
cleaning = false;
|
|
33
|
+
killed = false;
|
|
34
|
+
cleanupStartedAt = 0;
|
|
35
|
+
deadlineAt = Infinity;
|
|
36
|
+
deadlineTimer;
|
|
37
|
+
pollTimer;
|
|
38
|
+
terminationGraceMs;
|
|
39
|
+
closureGraceMs;
|
|
40
|
+
pollIntervalMs;
|
|
41
|
+
constructor(options, timing, resolve) {
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.resolve = resolve;
|
|
44
|
+
this.terminationGraceMs = Math.min(Math.max(timing.terminationGraceMs ?? 3000, 0), 3000);
|
|
45
|
+
this.closureGraceMs = Math.min(Math.max(timing.closureGraceMs ?? 2000, 0), 2000);
|
|
46
|
+
this.pollIntervalMs = Math.min(Math.max(timing.pollIntervalMs ?? 25, 1), 100);
|
|
47
|
+
}
|
|
48
|
+
start() {
|
|
49
|
+
if (this.options.signal?.aborted) {
|
|
50
|
+
this.cancelled = true;
|
|
51
|
+
this.closed = true;
|
|
52
|
+
this.finish(true);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const env = scopedVerificationEnvironment();
|
|
56
|
+
try {
|
|
57
|
+
this.deadlineAt = performance.now() + this.options.timeoutMs;
|
|
58
|
+
this.child = spawn(this.options.command, {
|
|
59
|
+
cwd: this.options.cwd,
|
|
60
|
+
shell: true,
|
|
61
|
+
detached: true,
|
|
62
|
+
windowsHide: true,
|
|
63
|
+
env,
|
|
64
|
+
});
|
|
65
|
+
this.child.stdout.on('data', this.append);
|
|
66
|
+
this.child.stderr.on('data', this.append);
|
|
67
|
+
this.child.on('error', this.onError);
|
|
68
|
+
this.child.on('exit', this.onExit);
|
|
69
|
+
this.child.on('close', this.onClose);
|
|
70
|
+
this.options.signal?.addEventListener('abort', this.onAbort, { once: true });
|
|
71
|
+
this.deadlineTimer = setTimeout(this.onDeadline, Math.max(0, this.deadlineAt - performance.now()));
|
|
72
|
+
if (this.options.signal?.aborted) {
|
|
73
|
+
this.onAbort();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
this.spawnFailed = true;
|
|
78
|
+
this.closed = true;
|
|
79
|
+
this.finish(groupState(this.child?.pid) === 'absent');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
append = (chunk) => {
|
|
83
|
+
this.output = (this.output + chunk.toString('utf8')).slice(-100000);
|
|
84
|
+
};
|
|
85
|
+
onError = () => {
|
|
86
|
+
this.spawnFailed = true;
|
|
87
|
+
this.startCleanup();
|
|
88
|
+
};
|
|
89
|
+
onExit = (code, signal) => {
|
|
90
|
+
this.exited = true;
|
|
91
|
+
this.exitCode = code;
|
|
92
|
+
this.exitSignal = signal;
|
|
93
|
+
if (groupState(this.child?.pid) !== 'absent') {
|
|
94
|
+
if (!this.cleaning) {
|
|
95
|
+
this.residual = true;
|
|
96
|
+
}
|
|
97
|
+
this.startCleanup();
|
|
98
|
+
}
|
|
99
|
+
else if (this.closed) {
|
|
100
|
+
this.finish(true);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.startCleanup();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
onClose = (code, signal) => {
|
|
107
|
+
this.closed = true;
|
|
108
|
+
this.exitCode = code;
|
|
109
|
+
this.exitSignal = signal;
|
|
110
|
+
if (groupState(this.child?.pid) === 'absent') {
|
|
111
|
+
this.finish(true);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
if (!this.cleaning) {
|
|
115
|
+
this.residual = true;
|
|
116
|
+
}
|
|
117
|
+
this.startCleanup();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
onDeadline = () => {
|
|
121
|
+
this.timedOut = true;
|
|
122
|
+
this.startCleanup();
|
|
123
|
+
};
|
|
124
|
+
onAbort = () => {
|
|
125
|
+
this.cancelled = true;
|
|
126
|
+
this.startCleanup();
|
|
127
|
+
};
|
|
128
|
+
signalGroup(signal) {
|
|
129
|
+
const pid = this.child?.pid;
|
|
130
|
+
if (pid === undefined) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
process.kill(-pid, signal);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// The following group probe determines whether cleanup was actually observed.
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
startCleanup() {
|
|
141
|
+
if (this.settled || this.cleaning) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.cleaning = true;
|
|
145
|
+
this.cleanupStartedAt = performance.now();
|
|
146
|
+
this.signalGroup('SIGTERM');
|
|
147
|
+
this.pollCleanup();
|
|
148
|
+
}
|
|
149
|
+
pollCleanup = () => {
|
|
150
|
+
if (this.settled) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const state = groupState(this.child?.pid);
|
|
154
|
+
if (state === 'absent' && this.closed) {
|
|
155
|
+
this.finish(true);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const elapsed = performance.now() - this.cleanupStartedAt;
|
|
159
|
+
if (!this.killed && elapsed >= this.terminationGraceMs) {
|
|
160
|
+
this.killed = true;
|
|
161
|
+
this.signalGroup('SIGKILL');
|
|
162
|
+
}
|
|
163
|
+
if (elapsed >= this.terminationGraceMs + this.closureGraceMs) {
|
|
164
|
+
this.finish(state === 'absent' && this.closed);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const nextBoundary = this.killed
|
|
168
|
+
? this.terminationGraceMs + this.closureGraceMs
|
|
169
|
+
: this.terminationGraceMs;
|
|
170
|
+
this.pollTimer = setTimeout(this.pollCleanup, Math.min(this.pollIntervalMs, Math.max(0, nextBoundary - elapsed)));
|
|
171
|
+
};
|
|
172
|
+
finish(cleanupComplete) {
|
|
173
|
+
if (this.settled) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.settled = true;
|
|
177
|
+
if (performance.now() >= this.deadlineAt) {
|
|
178
|
+
this.timedOut = true;
|
|
179
|
+
}
|
|
180
|
+
clearTimeout(this.deadlineTimer);
|
|
181
|
+
clearTimeout(this.pollTimer);
|
|
182
|
+
this.options.signal?.removeEventListener('abort', this.onAbort);
|
|
183
|
+
this.child?.stdout.removeListener('data', this.append);
|
|
184
|
+
this.child?.stderr.removeListener('data', this.append);
|
|
185
|
+
this.child?.removeListener('error', this.onError);
|
|
186
|
+
this.child?.removeListener('exit', this.onExit);
|
|
187
|
+
this.child?.removeListener('close', this.onClose);
|
|
188
|
+
this.resolve({
|
|
189
|
+
ok: this.exited &&
|
|
190
|
+
this.exitCode === 0 &&
|
|
191
|
+
!this.timedOut &&
|
|
192
|
+
!this.cancelled &&
|
|
193
|
+
!this.spawnFailed &&
|
|
194
|
+
!this.residual &&
|
|
195
|
+
cleanupComplete,
|
|
196
|
+
exitCode: this.exitCode,
|
|
197
|
+
signal: this.exitSignal,
|
|
198
|
+
output: this.output,
|
|
199
|
+
timedOut: this.timedOut,
|
|
200
|
+
cancelled: this.cancelled,
|
|
201
|
+
timeoutMs: this.options.timeoutMs,
|
|
202
|
+
cleanupComplete,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
export function runScopedVerification(options, timing = {}) {
|
|
207
|
+
if (!['darwin', 'linux'].includes(process.platform) ||
|
|
208
|
+
!Number.isInteger(options.timeoutMs) ||
|
|
209
|
+
options.timeoutMs <= 0 ||
|
|
210
|
+
options.timeoutMs > 600000) {
|
|
211
|
+
return Promise.resolve({
|
|
212
|
+
ok: false,
|
|
213
|
+
exitCode: null,
|
|
214
|
+
signal: null,
|
|
215
|
+
output: '',
|
|
216
|
+
timedOut: false,
|
|
217
|
+
cancelled: false,
|
|
218
|
+
timeoutMs: options.timeoutMs,
|
|
219
|
+
cleanupComplete: true,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return new Promise((resolve) => {
|
|
223
|
+
new ScopedVerificationExecution(options, timing, resolve).start();
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
export class ScopedVerificationCoordinator {
|
|
227
|
+
policy;
|
|
228
|
+
running = false;
|
|
229
|
+
consumed = false;
|
|
230
|
+
quarantined = false;
|
|
231
|
+
shutdownController = new AbortController();
|
|
232
|
+
pending;
|
|
233
|
+
constructor(policy) {
|
|
234
|
+
this.policy = policy;
|
|
235
|
+
}
|
|
236
|
+
async shutdown() {
|
|
237
|
+
this.shutdownController.abort();
|
|
238
|
+
await this.pending?.catch(() => undefined);
|
|
239
|
+
}
|
|
240
|
+
async complete(context) {
|
|
241
|
+
if (!(await isScopedVerificationFeature(this.policy, path.dirname(context.tasksPath)))) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
const stateError = this.stateFailure(context.taskId);
|
|
245
|
+
if (stateError) {
|
|
246
|
+
return stateError;
|
|
247
|
+
}
|
|
248
|
+
const grantedTasksPath = path.join(this.policy.workspaceRoot, '.sdd', 'features', this.policy.featureId, 'tasks.md');
|
|
249
|
+
if (context.tasksPath !== grantedTasksPath) {
|
|
250
|
+
return {
|
|
251
|
+
success: false,
|
|
252
|
+
error: {
|
|
253
|
+
code: 'ERR_WORKSPACE_UNRESOLVED',
|
|
254
|
+
message: 'Scoped verification path is not canonical.',
|
|
255
|
+
trigger: 'sdd_complete_task',
|
|
256
|
+
details: { reason: 'verification_policy_workspace_mismatch' },
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (context.taskId.toUpperCase() !== this.policy.taskId) {
|
|
261
|
+
const pathError = await scopedFeaturePathFailure(this.policy);
|
|
262
|
+
return this.stateFailure(context.taskId) ?? pathError;
|
|
263
|
+
}
|
|
264
|
+
this.running = true;
|
|
265
|
+
this.pending = this.execute(context);
|
|
266
|
+
try {
|
|
267
|
+
return await this.pending;
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
this.quarantined = this.consumed;
|
|
271
|
+
return scopedFailure({ reason: 'verification_runner_error' });
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
this.running = false;
|
|
275
|
+
this.pending = undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
stateFailure(taskId) {
|
|
279
|
+
if (this.quarantined) {
|
|
280
|
+
return scopedFailure({ reason: 'verification_grant_quarantined' });
|
|
281
|
+
}
|
|
282
|
+
if (this.running) {
|
|
283
|
+
return scopedFailure({ reason: 'verification_in_progress' });
|
|
284
|
+
}
|
|
285
|
+
if (this.consumed && taskId.toUpperCase() === this.policy.taskId) {
|
|
286
|
+
return scopedFailure({ reason: 'verification_grant_consumed' });
|
|
287
|
+
}
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
async execute(context) {
|
|
291
|
+
const snapshot = await readScopedVerificationSnapshot(this.policy, context.tasksPath, context.workspaceRoot, context.taskId, context.selectTask);
|
|
292
|
+
if (!snapshot.success) {
|
|
293
|
+
return snapshot;
|
|
294
|
+
}
|
|
295
|
+
const before = await revalidateScopedVerificationSnapshot(this.policy, snapshot.data, context.selectTask);
|
|
296
|
+
if (!before.success) {
|
|
297
|
+
return before;
|
|
298
|
+
}
|
|
299
|
+
const signal = AbortSignal.any([
|
|
300
|
+
this.shutdownController.signal,
|
|
301
|
+
...(context.signal ? [context.signal] : []),
|
|
302
|
+
]);
|
|
303
|
+
const cancelled = cancelledVerification(signal);
|
|
304
|
+
if (cancelled) {
|
|
305
|
+
return cancelled;
|
|
306
|
+
}
|
|
307
|
+
this.consumed = true;
|
|
308
|
+
const run = await runScopedVerification({
|
|
309
|
+
cwd: snapshot.data.workspaceRoot,
|
|
310
|
+
command: snapshot.data.command,
|
|
311
|
+
timeoutMs: snapshot.data.timeoutMs,
|
|
312
|
+
signal,
|
|
313
|
+
});
|
|
314
|
+
if (!run.cleanupComplete) {
|
|
315
|
+
this.quarantined = true;
|
|
316
|
+
}
|
|
317
|
+
if (!run.ok) {
|
|
318
|
+
return scopedFailure({
|
|
319
|
+
reason: 'verification_process_failed',
|
|
320
|
+
exitCode: run.exitCode,
|
|
321
|
+
signal: run.signal,
|
|
322
|
+
timedOut: run.timedOut,
|
|
323
|
+
cancelled: run.cancelled,
|
|
324
|
+
timeoutMs: run.timeoutMs,
|
|
325
|
+
cleanupComplete: run.cleanupComplete,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
const after = await revalidateScopedVerificationSnapshot(this.policy, snapshot.data, context.selectTask);
|
|
329
|
+
if (!after.success) {
|
|
330
|
+
return after;
|
|
331
|
+
}
|
|
332
|
+
const cancelledAfter = cancelledVerification(signal);
|
|
333
|
+
if (cancelledAfter) {
|
|
334
|
+
return cancelledAfter;
|
|
335
|
+
}
|
|
336
|
+
const committed = await context.commit(snapshot.data, run.output, signal);
|
|
337
|
+
if (committed.success && signal.aborted) {
|
|
338
|
+
this.quarantined = true;
|
|
339
|
+
return uncertainCompletion();
|
|
340
|
+
}
|
|
341
|
+
if (!committed.success && committed.error.details?.completionState === 'uncertain') {
|
|
342
|
+
this.quarantined = true;
|
|
343
|
+
}
|
|
344
|
+
return committed;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=verification-runner.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SddResult, CompleteTaskResult } from './sdd-engine.js';
|
|
2
|
+
export type VerificationPolicyInput = Readonly<{
|
|
3
|
+
version: 1;
|
|
4
|
+
mode: 'disabled';
|
|
5
|
+
}> | Readonly<{
|
|
6
|
+
version: 1;
|
|
7
|
+
mode: 'scoped';
|
|
8
|
+
workspaceRoot: string;
|
|
9
|
+
featureId: string;
|
|
10
|
+
taskId: string;
|
|
11
|
+
timeoutMs: number;
|
|
12
|
+
lockSha256: string;
|
|
13
|
+
verificationCommandSha256: string;
|
|
14
|
+
}>;
|
|
15
|
+
export type VerificationPolicy = Readonly<{
|
|
16
|
+
mode: 'default';
|
|
17
|
+
timeoutMs: 180000;
|
|
18
|
+
}> | Exclude<VerificationPolicyInput, Readonly<{
|
|
19
|
+
version: 1;
|
|
20
|
+
mode: 'disabled';
|
|
21
|
+
}>>;
|
|
22
|
+
export interface VerificationServerOptions {
|
|
23
|
+
readonly verificationPolicy?: VerificationPolicyInput;
|
|
24
|
+
}
|
|
25
|
+
export interface ScopedPathIdentity {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly device: number;
|
|
28
|
+
readonly inode: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ScopedVerificationSnapshot {
|
|
31
|
+
readonly workspaceRoot: string;
|
|
32
|
+
readonly featureId: string;
|
|
33
|
+
readonly taskId: string;
|
|
34
|
+
readonly tasksPath: string;
|
|
35
|
+
readonly specContent: string;
|
|
36
|
+
readonly planContent: string;
|
|
37
|
+
readonly tasksContent: string;
|
|
38
|
+
readonly lockContent: string;
|
|
39
|
+
readonly command: string;
|
|
40
|
+
readonly timeoutMs: number;
|
|
41
|
+
readonly identities: readonly ScopedPathIdentity[];
|
|
42
|
+
}
|
|
43
|
+
export interface ScopedTaskSelection {
|
|
44
|
+
readonly taskId: string;
|
|
45
|
+
readonly command: string | null;
|
|
46
|
+
}
|
|
47
|
+
export type ScopedTaskSelector = (content: string) => ScopedTaskSelection | null;
|
|
48
|
+
export type ScopedPolicy = Extract<VerificationPolicy, {
|
|
49
|
+
mode: 'scoped';
|
|
50
|
+
}>;
|
|
51
|
+
export type ScopedSnapshotResult = SddResult<ScopedVerificationSnapshot>;
|
|
52
|
+
export interface ScopedVerificationRun {
|
|
53
|
+
readonly ok: boolean;
|
|
54
|
+
readonly exitCode: number | null;
|
|
55
|
+
readonly signal: NodeJS.Signals | null;
|
|
56
|
+
readonly output: string;
|
|
57
|
+
readonly timedOut: boolean;
|
|
58
|
+
readonly cancelled: boolean;
|
|
59
|
+
readonly timeoutMs: number;
|
|
60
|
+
readonly cleanupComplete: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface ScopedVerificationRunnerOptions {
|
|
63
|
+
readonly cwd: string;
|
|
64
|
+
readonly command: string;
|
|
65
|
+
readonly timeoutMs: number;
|
|
66
|
+
readonly signal?: AbortSignal;
|
|
67
|
+
}
|
|
68
|
+
/** Internal test seam, never populated from MCP or startup policy. */
|
|
69
|
+
export interface ScopedVerificationRunnerTiming {
|
|
70
|
+
readonly terminationGraceMs?: number;
|
|
71
|
+
readonly closureGraceMs?: number;
|
|
72
|
+
readonly pollIntervalMs?: number;
|
|
73
|
+
}
|
|
74
|
+
export type VerificationGroupState = 'absent' | 'present' | 'unknown';
|
|
75
|
+
export interface ScopedVerificationCompletionContext {
|
|
76
|
+
readonly tasksPath: string;
|
|
77
|
+
readonly taskId: string;
|
|
78
|
+
readonly workspaceRoot: string;
|
|
79
|
+
readonly selectTask: ScopedTaskSelector;
|
|
80
|
+
readonly signal?: AbortSignal;
|
|
81
|
+
readonly commit: (snapshot: ScopedVerificationSnapshot, output: string, signal: AbortSignal) => Promise<SddResult<CompleteTaskResult>>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=verification.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planu/cli",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.14",
|
|
4
4
|
"description": "Planu — MCP Server for Spec Driven Development. Cross-platform (Linux/macOS/Windows, x64/arm64).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,38 @@
|
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=22.13.0"
|
|
26
26
|
},
|
|
27
|
+
"packageManager": "pnpm@12.11.2+sha512.25a51652a196785af5f28bda6dfe8dc582ebefa4ac1d180221ce1390231c5fb76637822ea4b6e4633ce74acdcb0a77f725af11bad38177fdeddaee818a955cb9",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"check:tool-registration": "bash scripts/check-tool-registration.sh",
|
|
30
|
+
"check:skill-sync": "node scripts/check-skill-sync.mjs",
|
|
31
|
+
"build": "pnpm build:ts",
|
|
32
|
+
"build:ts": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
33
|
+
"dev": "tsc --watch",
|
|
34
|
+
"start": "node dist/sdd-engine/cli.js",
|
|
35
|
+
"eval:skills": "node scripts/eval-skills.mjs",
|
|
36
|
+
"clean": "rm -rf dist",
|
|
37
|
+
"lint": "eslint src/ tests/ --max-warnings 0 --cache --cache-strategy content --cache-location node_modules/.cache/eslint/",
|
|
38
|
+
"lint:gate": "eslint src/ tests/ --max-warnings 0",
|
|
39
|
+
"lint:fix": "eslint src/ tests/ --fix --max-warnings 0",
|
|
40
|
+
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.test.ts'",
|
|
41
|
+
"format:check": "prettier --check --cache --cache-strategy content 'src/**/*.ts' 'tests/**/*.test.ts'",
|
|
42
|
+
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/planu-typecheck.tsbuildinfo",
|
|
43
|
+
"test": "vitest run --maxWorkers=6",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"test:coverage": "vitest run --coverage --testTimeout=60000 --maxWorkers=6",
|
|
46
|
+
"check": "pnpm typecheck && pnpm lint:gate && pnpm format:check && pnpm check:destructive-ops && pnpm check:tool-registration && pnpm check:skill-sync && pnpm check:sdd-core",
|
|
47
|
+
"check:sdd-core": "node scripts/check-sdd-core-closure.mjs",
|
|
48
|
+
"check:destructive-ops": "bash scripts/check-no-automatic-destructive-ops.sh",
|
|
49
|
+
"check:deps:fresh": "node scripts/check-dependency-freshness.mjs",
|
|
50
|
+
"check:strict": "pnpm check && pnpm audit:deadcode && pnpm audit:circular && pnpm audit:types",
|
|
51
|
+
"audit:deadcode": "knip",
|
|
52
|
+
"audit:circular": "madge --circular --extensions ts --ts-config tsconfig.json src/",
|
|
53
|
+
"audit:types": "type-coverage --at-least 98 --ignore-catch --strict --ignore-files 'tests/**'",
|
|
54
|
+
"prepare": "husky || true",
|
|
55
|
+
"prepack": "pnpm build:ts && pnpm package:size",
|
|
56
|
+
"validate": "pnpm build && pnpm test && pnpm check:strict",
|
|
57
|
+
"package:size": "node scripts/check-package-size.mjs"
|
|
58
|
+
},
|
|
27
59
|
"lint-staged": {
|
|
28
60
|
"src/**/*.ts": [
|
|
29
61
|
"eslint --fix --max-warnings 0 --no-warn-ignored",
|
|
@@ -75,61 +107,32 @@
|
|
|
75
107
|
"zod": "^4.6.7"
|
|
76
108
|
},
|
|
77
109
|
"devDependencies": {
|
|
78
|
-
"@commitlint/cli": "^21.2.
|
|
79
|
-
"@commitlint/config-conventional": "^21.2.
|
|
110
|
+
"@commitlint/cli": "^21.2.4",
|
|
111
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
80
112
|
"@eslint/js": "^10.0.1",
|
|
81
113
|
"@secretlint/secretlint-rule-no-homedir": "^13.0.7",
|
|
82
114
|
"@secretlint/secretlint-rule-preset-recommend": "^13.0.7",
|
|
83
115
|
"@types/node": "^22.20.5",
|
|
84
116
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
85
|
-
"@vitest/coverage-v8": "^5.0.
|
|
86
|
-
"eslint": "10.
|
|
117
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
118
|
+
"eslint": "10.13.0",
|
|
87
119
|
"eslint-config-prettier": "^10.1.8",
|
|
88
120
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
89
121
|
"eslint-plugin-import": "^2.32.0",
|
|
90
|
-
"happy-dom": "^21.0.
|
|
122
|
+
"happy-dom": "^21.0.4",
|
|
91
123
|
"husky": "^9.1.7",
|
|
92
124
|
"jiti": "2.7.0",
|
|
93
|
-
"knip": "^6.
|
|
125
|
+
"knip": "^6.42.1",
|
|
94
126
|
"lint-staged": "^17.6.0",
|
|
95
127
|
"madge": "^8.0.0",
|
|
96
128
|
"prettier": "^3.9.10",
|
|
97
129
|
"qrcode": "1.5.4",
|
|
98
130
|
"secretlint": "^13.0.7",
|
|
99
|
-
"tsc-alias": "^1.9.
|
|
100
|
-
"type-coverage": "^2.30.
|
|
131
|
+
"tsc-alias": "^1.9.8",
|
|
132
|
+
"type-coverage": "^2.30.4",
|
|
101
133
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
102
|
-
"typescript-eslint": "^8.
|
|
134
|
+
"typescript-eslint": "^8.72.0",
|
|
103
135
|
"vite": "^8.3.4",
|
|
104
|
-
"vitest": "^5.0.
|
|
105
|
-
},
|
|
106
|
-
"scripts": {
|
|
107
|
-
"check:tool-registration": "bash scripts/check-tool-registration.sh",
|
|
108
|
-
"check:skill-sync": "node scripts/check-skill-sync.mjs",
|
|
109
|
-
"build": "pnpm build:ts",
|
|
110
|
-
"build:ts": "pnpm clean && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
|
|
111
|
-
"dev": "tsc --watch",
|
|
112
|
-
"start": "node dist/sdd-engine/cli.js",
|
|
113
|
-
"eval:skills": "node scripts/eval-skills.mjs",
|
|
114
|
-
"clean": "rm -rf dist",
|
|
115
|
-
"lint": "eslint src/ tests/ --max-warnings 0 --cache --cache-strategy content --cache-location node_modules/.cache/eslint/",
|
|
116
|
-
"lint:gate": "eslint src/ tests/ --max-warnings 0",
|
|
117
|
-
"lint:fix": "eslint src/ tests/ --fix --max-warnings 0",
|
|
118
|
-
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.test.ts'",
|
|
119
|
-
"format:check": "prettier --check --cache --cache-strategy content 'src/**/*.ts' 'tests/**/*.test.ts'",
|
|
120
|
-
"typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/planu-typecheck.tsbuildinfo",
|
|
121
|
-
"test": "vitest run --maxWorkers=6",
|
|
122
|
-
"test:watch": "vitest",
|
|
123
|
-
"test:coverage": "vitest run --coverage --testTimeout=60000 --maxWorkers=6",
|
|
124
|
-
"check": "pnpm typecheck && pnpm lint:gate && pnpm format:check && pnpm check:destructive-ops && pnpm check:tool-registration && pnpm check:skill-sync && pnpm check:sdd-core",
|
|
125
|
-
"check:sdd-core": "node scripts/check-sdd-core-closure.mjs",
|
|
126
|
-
"check:destructive-ops": "bash scripts/check-no-automatic-destructive-ops.sh",
|
|
127
|
-
"check:deps:fresh": "node scripts/check-dependency-freshness.mjs",
|
|
128
|
-
"check:strict": "pnpm check && pnpm audit:deadcode && pnpm audit:circular && pnpm audit:types",
|
|
129
|
-
"audit:deadcode": "knip",
|
|
130
|
-
"audit:circular": "madge --circular --extensions ts --ts-config tsconfig.json src/",
|
|
131
|
-
"audit:types": "type-coverage --at-least 98 --ignore-catch --strict --ignore-files 'tests/**'",
|
|
132
|
-
"validate": "pnpm build && pnpm test && pnpm check:strict",
|
|
133
|
-
"package:size": "node scripts/check-package-size.mjs"
|
|
136
|
+
"vitest": "^5.0.5"
|
|
134
137
|
}
|
|
135
|
-
}
|
|
138
|
+
}
|
package/templates/AGENTS.md
CHANGED
|
@@ -37,6 +37,9 @@ Canonical contract: `PLANU_V8_MANIFESTO.txt`.
|
|
|
37
37
|
4. **Language Requirements:**
|
|
38
38
|
- All generated SDD artifacts MUST be written entirely in Technical English.
|
|
39
39
|
|
|
40
|
+
4a. **Trusted verification authority:**
|
|
41
|
+
- Agents must never grant themselves extra verification time or edit trusted launcher policy. Report budget failures for operator review; an approved startup grant does not change task or File Manifest authority.
|
|
42
|
+
|
|
40
43
|
5. **Atomic Task Progression:**
|
|
41
44
|
- Work strictly task-by-task via `sdd_get_active_task`. Verify with the task command before `sdd_complete_task`.
|
|
42
45
|
|
|
@@ -7,3 +7,4 @@ The only SDD contract is `.sdd/features/{FEAT-*}/spec.md`, `plan.md`, and `tasks
|
|
|
7
7
|
- Never create, thin, or copy files under `planu/specs/`. Planu does not read that tree.
|
|
8
8
|
- If a pre-push, commitlint, or husky guard still requires `planu/specs/SPEC-*/spec.md`, that guard is the defect. Delete or rewrite it. Do not stub a SPEC file.
|
|
9
9
|
- Quality lives in `.claude/skills/`, `.cursor/skills/`, `.agents/skills/`, and `.gemini/skills/`. Specs stay in `.sdd/features`. There is no validate MCP tool.
|
|
10
|
+
- Agents must never grant themselves extra verification time or edit trusted launcher policy. Report budget failures for operator review; an approved startup grant does not change task or File Manifest authority.
|