@planu/cli 8.6.0 → 8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +9 -3
- package/dist/sdd-engine/host-rule-pack.js +4 -0
- package/dist/sdd-engine/patch-sandbox.d.ts +2 -1
- package/dist/sdd-engine/patch-sandbox.js +67 -93
- package/dist/sdd-engine/resume-views.d.ts +3 -2
- package/dist/sdd-engine/resume-views.js +36 -48
- package/dist/sdd-engine/task-failures.d.ts +30 -13
- package/dist/sdd-engine/task-failures.js +284 -115
- package/dist/sdd-engine/task-window.d.ts +6 -3
- package/dist/sdd-engine/task-window.js +12 -23
- package/dist/sdd-engine/tools/execution-tools.js +3 -4
- package/dist/sdd-engine/verification-policy.d.ts +6 -6
- package/dist/sdd-engine/verification-policy.js +74 -85
- package/dist/sdd-engine/verification-preflight.d.ts +9 -7
- package/dist/sdd-engine/verification-preflight.js +108 -89
- package/dist/sdd-engine/verification-receipts.js +2 -1
- package/dist/sdd-engine/verification-runner.d.ts +2 -1
- package/dist/sdd-engine/verification-runner.js +12 -7
- package/dist/types/completion.d.ts +17 -2
- package/dist/types/resume-views.d.ts +2 -1
- package/dist/types/sdd-engine.d.ts +5 -2
- package/dist/types/verification.d.ts +27 -0
- package/package.json +1 -1
- package/templates/AGENTS.md +4 -0
- package/templates/host/planu-sdd.md +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [8.7.1]
|
|
2
|
+
|
|
3
|
+
- Reject hardlinked or nonregular effective MODIFY targets and invalid UTF-8 before mutation; enforce ownership where supported and preserve safe internal symlinks.
|
|
4
|
+
- Recheck identity and path bindings before write admission. Write failures may leave partial changes; this is not atomic rollback or a complete same-user filesystem boundary.
|
|
5
|
+
- Preserve the nine tools and input schemas, existing dependencies and package surface.
|
|
6
|
+
|
|
7
|
+
## [8.7.0]
|
|
8
|
+
|
|
9
|
+
- Expose advisory `budget.version=1` observations in preflight and resume; completion revalidates authority and consumes a matching grant before spawning.
|
|
10
|
+
- Report spawned verification process and owned-process-group cleanup evidence; fixture postconditions remain unknown and require separate inspection.
|
|
11
|
+
- Preserve the nine tools and their input schemas, existing verification limits and dependencies.
|
|
12
|
+
|
|
1
13
|
## [8.6.0]
|
|
2
14
|
|
|
3
15
|
- Add bounded execution window, detail and evidence history views, selected-host setup diagnostics, and explicit evidence checkpoints to the existing nine tools.
|
package/README.md
CHANGED
|
@@ -132,20 +132,24 @@ This is role guidance, not a runtime dispatcher or a guarantee that a host loads
|
|
|
132
132
|
|
|
133
133
|
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.
|
|
134
134
|
|
|
135
|
+
Explicit `verification_preflight` and `resume` views expose `budget.version=1` with admission, reason and effective timeout when available. This read-only observation is not a reservation: state may change, and completion revalidates and consumes any matching grant before spawning.
|
|
136
|
+
|
|
137
|
+
Completion can expose `verificationProcess` after a spawned verification, including timeout, cancellation, exit and cleanup evidence. Its `cleanupScope` is `owned_process_group`; `fixturePostconditions` remains `unknown`. Group cleanup does not prove fixture-owned state is safe. Reconcile uncertain attempts before retrying.
|
|
138
|
+
|
|
135
139
|
There is no timeout tool argument. The nine tool names are unchanged. The optional verification_receipts field carries signed evidence and grants no extra time. The programmatic factory ignores the CLI environment unless its optional typed policy is explicitly supplied. Agents must not create or widen grants themselves.
|
|
136
140
|
|
|
137
141
|
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.
|
|
138
142
|
|
|
139
143
|
## Read-only diagnostics
|
|
140
144
|
|
|
141
|
-
The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds compact resume and history views, and 8.6.0 adds bounded execution views and explicit evidence checkpoints. An ordinary `sdd_get_active_task` request keeps its previous response shape.
|
|
145
|
+
The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds compact resume and history views, and 8.6.0 adds bounded execution views and explicit evidence checkpoints. 8.7.0 adds advisory budget observations and verification process evidence. An ordinary `sdd_get_active_task` request keeps its previous response shape.
|
|
142
146
|
|
|
143
147
|
`sdd_list_features` includes `hostSkills`. For example, a missing installed role can produce this field (other installed files match the available bundled reference):
|
|
144
148
|
|
|
145
149
|
```json
|
|
146
150
|
{
|
|
147
151
|
"version": 1,
|
|
148
|
-
"bundledVersion": "8.
|
|
152
|
+
"bundledVersion": "8.7.1",
|
|
149
153
|
"baseline": "available",
|
|
150
154
|
"catalog": "unverified",
|
|
151
155
|
"issues": [{
|
|
@@ -297,6 +301,8 @@ sdd_init_workspace → sdd_create_feature → architect trinity → sdd_lock_spe
|
|
|
297
301
|
5. **Verify:** independently prove acceptance criteria with `verification-auditor.md`.
|
|
298
302
|
6. **Janitor:** prune local branches and orphaned worktrees only with authorization.
|
|
299
303
|
|
|
304
|
+
Effective MODIFY (including CREATE with a nonempty search) requires a regular single-link UTF-8 target and checks ownership where supported; safe internal symlinks remain usable. Identity and path checks reject detected changes before write admission. A write failure may leave partial changes: inspect the file before retrying. These checks do not provide atomic rollback or a complete boundary against a hostile process running as the same user.
|
|
305
|
+
|
|
300
306
|
`sdd_list_features` enumerates executable `.sdd/features/FEAT-*` records only. Historical v6 records are not executed, enumerated, generated, or shipped by the v8 runtime.
|
|
301
307
|
|
|
302
308
|
### Canonical tools
|
|
@@ -374,7 +380,7 @@ See the [Planu Proprietary Free-Use License](LICENSE) and [planu.dev/license](ht
|
|
|
374
380
|
"mcpServers": {
|
|
375
381
|
"planu": {
|
|
376
382
|
"command": "npx",
|
|
377
|
-
"args": ["-y", "@planu/cli@8.
|
|
383
|
+
"args": ["-y", "@planu/cli@8.7.1"],
|
|
378
384
|
"cwd": ".",
|
|
379
385
|
"env": {
|
|
380
386
|
"PLANU_WORKSPACE": "."
|
|
@@ -29,6 +29,10 @@ If \`history\` is null, follow \`nextAction\` without requesting history. If \`h
|
|
|
29
29
|
|
|
30
30
|
For setup diagnostics and execution window, detail and evidence history views, load \`preflight-guardian.md\` and \`spec-executor.md\` on demand. Verify the selected connection advertises the checkpoint inputs and a supporting engine before any checkpoint mutation; never probe the global 8.5.1 server or fall back to lock/relock. Recorded observations are caller-reported, non-certifying and never automatic. Matching files do not prove a loaded catalogue. Preserve uncertain guards for operator review.
|
|
31
31
|
|
|
32
|
+
Before attempting completion, request a fresh explicit \`verification_preflight\` or \`resume\` and require \`budget.version=1\`; absence is unavailable, never a grant. An older producer may omit it. The observation is advisory, not a reservation or grant. \`execution_window\` and \`execution_detail\` are not decorated with budget and cannot substitute for that fresh request. When a verification process actually ran, its \`verificationProcess\` reports the effective timeout, outcome and owned process group cleanup; \`fixturePostconditions\` remains \`unknown\`. Group cleanup alone does not prove fixture safety. These diagnostics do not record attempts automatically or authorize policy changes, retries or extra time. Reconcile uncertain state before acting.
|
|
33
|
+
|
|
34
|
+
Effective MODIFY (including CREATE with a nonempty search) requires a regular single-link target with strict UTF-8; ownership is checked where the platform provides getuid. Stable safe internal symlinks remain supported. A write, truncate, sync or close failure may leave partial changes; inspect before retrying. Checks do not guarantee protection against a hostile same-UID process inserting a link after the final check.
|
|
35
|
+
|
|
32
36
|
## Delegation
|
|
33
37
|
|
|
34
38
|
Delegate useful independent work within the active TASK through available native agents; keep trivial/dependent work sequential. Load the bounded protocol from \`spec-executor.md\` on demand; use \`spec-architect.md\` for workstream routing and \`verification-auditor.md\` for provenance checks. The parent alone applies canonical patches and certifies. Preserve all nine tools, lock, File Manifest, limits and protected-root controls; host capabilities grant no extra authority.
|
|
@@ -7,7 +7,6 @@ export declare class PatchSandbox {
|
|
|
7
7
|
private validateTargetContainment;
|
|
8
8
|
private rejectsProtectedRoot;
|
|
9
9
|
private rejectsResolvedProtectedRoot;
|
|
10
|
-
private isRawProtectedDelete;
|
|
11
10
|
private validateCreateTargetAbsent;
|
|
12
11
|
private nearestExistingParent;
|
|
13
12
|
private isWithin;
|
|
@@ -17,5 +16,7 @@ export declare class PatchSandbox {
|
|
|
17
16
|
private executeCreatePatch;
|
|
18
17
|
private executeDeletePatch;
|
|
19
18
|
private executeModifyPatch;
|
|
19
|
+
private isAllowedCanonical;
|
|
20
|
+
private modifyFailure;
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=patch-sandbox.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { parseManifestContent, toPosixPath } from './feature-manifest.js';
|
|
4
|
+
import { CompletionGuardError, readArtifact, rewriteArtifact } from './feature-authority.js';
|
|
4
5
|
export class PatchSandbox {
|
|
5
6
|
workspaceRoot;
|
|
6
7
|
constructor(workspaceRoot) {
|
|
@@ -98,7 +99,7 @@ export class PatchSandbox {
|
|
|
98
99
|
this.isWithin(legacySpecsRoot, fullPath)) {
|
|
99
100
|
return true;
|
|
100
101
|
}
|
|
101
|
-
return permission === 'DELETE' &&
|
|
102
|
+
return permission === 'DELETE' && fullPath === workspacePath;
|
|
102
103
|
}
|
|
103
104
|
async rejectsResolvedProtectedRoot(workspaceRealPath, containmentTarget) {
|
|
104
105
|
for (const dirName of ['.sdd', '.git', path.join('planu', 'specs')]) {
|
|
@@ -109,9 +110,6 @@ export class PatchSandbox {
|
|
|
109
110
|
}
|
|
110
111
|
return false;
|
|
111
112
|
}
|
|
112
|
-
isRawProtectedDelete(workspacePath, fullPath) {
|
|
113
|
-
return fullPath === workspacePath;
|
|
114
|
-
}
|
|
115
113
|
async validateCreateTargetAbsent(fullPath, normalizedTarget) {
|
|
116
114
|
try {
|
|
117
115
|
await fs.lstat(fullPath);
|
|
@@ -147,24 +145,19 @@ export class PatchSandbox {
|
|
|
147
145
|
(relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)));
|
|
148
146
|
}
|
|
149
147
|
permissionViolation(normalizedTarget) {
|
|
148
|
+
const message = `Access outside protected workspace boundaries denied: '${normalizedTarget}'.`;
|
|
150
149
|
return {
|
|
151
150
|
success: false,
|
|
152
|
-
error: {
|
|
153
|
-
code: 'ERR_PERMISSION_VIOLATION',
|
|
154
|
-
message: `Access outside protected workspace boundaries denied: '${normalizedTarget}'.`,
|
|
155
|
-
trigger: 'sdd_apply_file_patch',
|
|
156
|
-
},
|
|
151
|
+
error: { code: 'ERR_PERMISSION_VIOLATION', message, trigger: 'sdd_apply_file_patch' },
|
|
157
152
|
};
|
|
158
153
|
}
|
|
159
154
|
patchFailure(message) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
message,
|
|
165
|
-
trigger: 'sdd_apply_file_patch',
|
|
166
|
-
},
|
|
155
|
+
const error = {
|
|
156
|
+
code: 'ERR_PATCH_FAILED',
|
|
157
|
+
message,
|
|
158
|
+
trigger: 'sdd_apply_file_patch',
|
|
167
159
|
};
|
|
160
|
+
return { success: false, error };
|
|
168
161
|
}
|
|
169
162
|
isNodeErrorCode(err, code) {
|
|
170
163
|
return typeof err === 'object' && err !== null && 'code' in err && err.code === code;
|
|
@@ -173,35 +166,16 @@ export class PatchSandbox {
|
|
|
173
166
|
try {
|
|
174
167
|
await fs.mkdir(path.dirname(fullPath), { recursive: true });
|
|
175
168
|
await fs.writeFile(fullPath, replaceContent, { encoding: 'utf-8', flag: 'wx' });
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
data: {
|
|
179
|
-
appliedTo: normalizedTarget,
|
|
180
|
-
bytesWritten: Buffer.byteLength(replaceContent, 'utf-8'),
|
|
181
|
-
},
|
|
182
|
-
};
|
|
169
|
+
const bytesWritten = Buffer.byteLength(replaceContent, 'utf-8');
|
|
170
|
+
return { success: true, data: { appliedTo: normalizedTarget, bytesWritten } };
|
|
183
171
|
}
|
|
184
172
|
catch (err) {
|
|
185
|
-
return {
|
|
186
|
-
success: false,
|
|
187
|
-
error: {
|
|
188
|
-
code: 'ERR_PATCH_FAILED',
|
|
189
|
-
message: `Failed to create file: ${err instanceof Error ? err.message : String(err)}`,
|
|
190
|
-
trigger: 'sdd_apply_file_patch',
|
|
191
|
-
},
|
|
192
|
-
};
|
|
173
|
+
return this.patchFailure(`Failed to create file: ${err instanceof Error ? err.message : String(err)}`);
|
|
193
174
|
}
|
|
194
175
|
}
|
|
195
176
|
async executeDeletePatch(fullPath, normalizedTarget, searchContent, replaceContent) {
|
|
196
177
|
if (searchContent !== '' || replaceContent !== '') {
|
|
197
|
-
return {
|
|
198
|
-
success: false,
|
|
199
|
-
error: {
|
|
200
|
-
code: 'ERR_PATCH_FAILED',
|
|
201
|
-
message: `DELETE requires empty search_content and replace_content for '${normalizedTarget}'.`,
|
|
202
|
-
trigger: 'sdd_apply_file_patch',
|
|
203
|
-
},
|
|
204
|
-
};
|
|
178
|
+
return this.patchFailure(`DELETE requires empty search_content and replace_content for '${normalizedTarget}'.`);
|
|
205
179
|
}
|
|
206
180
|
try {
|
|
207
181
|
const stat = await fs.lstat(fullPath);
|
|
@@ -212,47 +186,42 @@ export class PatchSandbox {
|
|
|
212
186
|
};
|
|
213
187
|
}
|
|
214
188
|
catch (err) {
|
|
215
|
-
return {
|
|
216
|
-
success: false,
|
|
217
|
-
error: {
|
|
218
|
-
code: 'ERR_PATCH_FAILED',
|
|
219
|
-
message: `Failed to delete '${normalizedTarget}': ${err instanceof Error ? err.message : String(err)}`,
|
|
220
|
-
trigger: 'sdd_apply_file_patch',
|
|
221
|
-
},
|
|
222
|
-
};
|
|
189
|
+
return this.patchFailure(`Failed to delete '${normalizedTarget}': ${err instanceof Error ? err.message : String(err)}`);
|
|
223
190
|
}
|
|
224
191
|
}
|
|
225
192
|
async executeModifyPatch(fullPath, normalizedTarget, searchContent, replaceContent) {
|
|
226
|
-
let
|
|
193
|
+
let writeStarted = false;
|
|
194
|
+
let canonicalResolved = false;
|
|
227
195
|
try {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
196
|
+
const canonical = await fs.realpath(fullPath);
|
|
197
|
+
canonicalResolved = true;
|
|
198
|
+
if (!(await this.isAllowedCanonical(canonical))) {
|
|
199
|
+
return this.permissionViolation(normalizedTarget);
|
|
200
|
+
}
|
|
201
|
+
const directory = path.dirname(canonical);
|
|
202
|
+
const name = path.basename(canonical);
|
|
203
|
+
const artifact = await readArtifact(directory, name);
|
|
204
|
+
const matchCount = countOccurrences(artifact.content, searchContent);
|
|
205
|
+
if (matchCount !== 1) {
|
|
206
|
+
return {
|
|
207
|
+
success: false,
|
|
208
|
+
error: {
|
|
209
|
+
code: 'ERR_PATCH_FAILED',
|
|
210
|
+
message: `MODIFY search_content must occur exactly once in '${normalizedTarget}'.`,
|
|
211
|
+
trigger: 'sdd_apply_file_patch',
|
|
212
|
+
details: { matchCount, requestedPath: normalizedTarget },
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const updatedContent = artifact.content.replace(searchContent, () => replaceContent);
|
|
217
|
+
await rewriteArtifact(directory, name, artifact, updatedContent, () => {
|
|
218
|
+
writeStarted = true;
|
|
219
|
+
}, async () => {
|
|
220
|
+
const denial = await this.validateTargetContainment(fullPath, normalizedTarget, 'MODIFY');
|
|
221
|
+
if (denial || (await fs.realpath(fullPath).catch(() => null)) !== canonical) {
|
|
222
|
+
throw new CompletionGuardError('contract_drift', 'Target binding changed.');
|
|
223
|
+
}
|
|
224
|
+
});
|
|
256
225
|
return {
|
|
257
226
|
success: true,
|
|
258
227
|
data: {
|
|
@@ -262,16 +231,27 @@ export class PatchSandbox {
|
|
|
262
231
|
};
|
|
263
232
|
}
|
|
264
233
|
catch (err) {
|
|
265
|
-
return
|
|
266
|
-
success: false,
|
|
267
|
-
error: {
|
|
268
|
-
code: 'ERR_PATCH_FAILED',
|
|
269
|
-
message: `Failed to write changes: ${err instanceof Error ? err.message : String(err)}`,
|
|
270
|
-
trigger: 'sdd_apply_file_patch',
|
|
271
|
-
},
|
|
272
|
-
};
|
|
234
|
+
return this.modifyFailure(err, normalizedTarget, writeStarted, canonicalResolved);
|
|
273
235
|
}
|
|
274
236
|
}
|
|
237
|
+
async isAllowedCanonical(canonical) {
|
|
238
|
+
const workspaceReal = await fs.realpath(this.workspaceRoot);
|
|
239
|
+
return (this.isWithin(workspaceReal, canonical) &&
|
|
240
|
+
!(await this.rejectsResolvedProtectedRoot(workspaceReal, canonical)));
|
|
241
|
+
}
|
|
242
|
+
modifyFailure(err, normalizedTarget, writeStarted, canonicalResolved) {
|
|
243
|
+
if (!writeStarted &&
|
|
244
|
+
((err instanceof CompletionGuardError && err.code !== 'ERR_INVALID_ARTIFACT') ||
|
|
245
|
+
this.isNodeErrorCode(err, 'EACCES') ||
|
|
246
|
+
this.isNodeErrorCode(err, 'EPERM') ||
|
|
247
|
+
(canonicalResolved &&
|
|
248
|
+
(this.isNodeErrorCode(err, 'ENOENT') || this.isNodeErrorCode(err, 'ELOOP'))))) {
|
|
249
|
+
return this.permissionViolation(normalizedTarget);
|
|
250
|
+
}
|
|
251
|
+
return this.patchFailure(writeStarted
|
|
252
|
+
? 'Failed to write changes; the target may be partially modified.'
|
|
253
|
+
: 'Failed to read or write the target file.');
|
|
254
|
+
}
|
|
275
255
|
}
|
|
276
256
|
function resolveManifestPermission(allowedFiles, normalizedTarget) {
|
|
277
257
|
const exact = allowedFiles.get(normalizedTarget);
|
|
@@ -308,18 +288,12 @@ function isProtectedPrefix(relativePath, root) {
|
|
|
308
288
|
return posix === root || posix.startsWith(`${root}/`);
|
|
309
289
|
}
|
|
310
290
|
function countOccurrences(haystack, needle) {
|
|
311
|
-
if (needle
|
|
291
|
+
if (!needle) {
|
|
312
292
|
return 0;
|
|
313
293
|
}
|
|
314
294
|
let count = 0;
|
|
315
|
-
let
|
|
316
|
-
|
|
317
|
-
const at = haystack.indexOf(needle, from);
|
|
318
|
-
if (at < 0) {
|
|
319
|
-
return count;
|
|
320
|
-
}
|
|
321
|
-
count += 1;
|
|
322
|
-
from = at + needle.length;
|
|
295
|
+
for (let at = haystack.indexOf(needle); at !== -1; at = haystack.indexOf(needle, at + needle.length)) {
|
|
296
|
+
count++;
|
|
323
297
|
}
|
|
324
298
|
return count;
|
|
325
299
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type * as completion from '../types/completion.js';
|
|
1
2
|
import type * as resumeTypes from '../types/resume-views.js';
|
|
2
3
|
import type * as engineTypes from '../types/sdd-engine.js';
|
|
3
4
|
import type { ScopedPolicy, VerificationPolicy } from '../types/verification.js';
|
|
4
5
|
import * as compact from './tools/compact-result.js';
|
|
5
|
-
export declare function getResumeCheckpoint(tasksPath: string, workspaceRoot: string, extractCommand: (markdown: string) => string | null, receipts?: unknown, scopedPolicy?: ScopedPolicy, signal?: AbortSignal): Promise<engineTypes.SddResult<{
|
|
6
|
+
export declare function getResumeCheckpoint(tasksPath: string, workspaceRoot: string, extractCommand: (markdown: string) => string | null, receipts?: unknown, scopedPolicy?: ScopedPolicy, signal?: AbortSignal, reader?: completion.VerificationBudgetReader, explicit?: boolean): Promise<engineTypes.SddResult<{
|
|
6
7
|
resume: resumeTypes.ResumeCheckpoint;
|
|
7
8
|
}>>;
|
|
8
|
-
export declare function getResumeToolResult(rawArgs: unknown, workspace: engineTypes.SddWorkspaceHandle, policy?: VerificationPolicy, signal?: AbortSignal): Promise<ReturnType<typeof compact.formatCompactResult>>;
|
|
9
|
+
export declare function getResumeToolResult(rawArgs: unknown, workspace: engineTypes.SddWorkspaceHandle, policy?: VerificationPolicy, signal?: AbortSignal, reader?: completion.VerificationBudgetReader): Promise<ReturnType<typeof compact.formatCompactResult>>;
|
|
9
10
|
//# sourceMappingURL=resume-views.d.ts.map
|
|
@@ -3,9 +3,9 @@ import * as evidenceJournal from './evidence-journal.js';
|
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import * as history from './resume-history.js';
|
|
5
5
|
import { GetActiveTaskInputSchema } from './contracts.js';
|
|
6
|
-
import
|
|
6
|
+
import * as failures from './task-failures.js';
|
|
7
7
|
import { homeFallbackFailure } from './workspace-root.js';
|
|
8
|
-
import
|
|
8
|
+
import * as featureAuthority from './feature-authority.js';
|
|
9
9
|
import { summarizeTaskContent } from './task-content.js';
|
|
10
10
|
import { captureVerificationRoot, revalidateVerificationInputs } from './verification-inputs.js';
|
|
11
11
|
import * as preflight from './verification-preflight.js';
|
|
@@ -13,50 +13,38 @@ import * as compact from './tools/compact-result.js';
|
|
|
13
13
|
class InvalidCompactIdentifierError extends Error {
|
|
14
14
|
}
|
|
15
15
|
function checkpoint(snapshot, summary, assessment) {
|
|
16
|
-
return compact.resumeProjection(path.basename(snapshot.feature), summary.progress, checkpointPresentation(snapshot, summary, assessment), history.contractReference(snapshot), assessment, history.historyRef(snapshot));
|
|
16
|
+
return compact.resumeProjection(path.basename(snapshot.feature), summary.progress, failures.checkpointPresentation(snapshot, summary, assessment), history.contractReference(snapshot), assessment, history.historyRef(snapshot));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
integration: 'pending',
|
|
36
|
-
blockers: assessment.preflight.blockers,
|
|
37
|
-
nextAction: assessment.preflight.nextAction,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
status,
|
|
42
|
-
task: null,
|
|
43
|
-
readiness: status === 'unlocked' ? 'blocked' : 'not_applicable',
|
|
44
|
-
integration: 'not_applicable',
|
|
45
|
-
blockers: status === 'unlocked' ? [{ reason: 'unlocked' }] : [],
|
|
46
|
-
nextAction: status === 'unlocked' ? 'review_lock' : status === 'no_tasks' ? 'inspect_tasks' : 'none',
|
|
18
|
+
async function budgetCheckpoint(core, assessment, tasksPath, workspaceRoot, scopedPolicy, reader) {
|
|
19
|
+
const { root, snapshot, summary } = core;
|
|
20
|
+
const base = assessment?.preflight ?? preflight.report(core.active?.taskId ?? null, [], [], false);
|
|
21
|
+
const budget = await preflight.observeVerificationBudget({
|
|
22
|
+
tasksPath,
|
|
23
|
+
workspaceRoot,
|
|
24
|
+
root,
|
|
25
|
+
snapshot,
|
|
26
|
+
selected: core.active && {
|
|
27
|
+
taskId: core.active.taskId,
|
|
28
|
+
command: core.active.verificationCommand,
|
|
29
|
+
},
|
|
30
|
+
preflight: base,
|
|
31
|
+
}, scopedPolicy, reader);
|
|
32
|
+
const decorated = assessment && {
|
|
33
|
+
...assessment,
|
|
34
|
+
preflight: failures.withVerificationBudget(base, budget),
|
|
47
35
|
};
|
|
36
|
+
return { ...checkpoint(snapshot, summary, decorated), budget };
|
|
48
37
|
}
|
|
49
|
-
function
|
|
50
|
-
return id.length <= 128 && /^[A-Z0-9_-]+$/u.test(id);
|
|
51
|
-
}
|
|
52
|
-
export async function getResumeCheckpoint(tasksPath, workspaceRoot, extractCommand, receipts, scopedPolicy, signal) {
|
|
38
|
+
export async function getResumeCheckpoint(tasksPath, workspaceRoot, extractCommand, receipts, scopedPolicy, signal, reader, explicit = true) {
|
|
53
39
|
try {
|
|
54
40
|
const core = await captureCore(tasksPath, workspaceRoot, extractCommand);
|
|
55
41
|
const assessment = await assessCore(core, workspaceRoot, receipts, scopedPolicy, signal);
|
|
56
42
|
const { root, snapshot, summary } = core;
|
|
57
|
-
const resume =
|
|
43
|
+
const resume = explicit
|
|
44
|
+
? await budgetCheckpoint(core, assessment, tasksPath, workspaceRoot, scopedPolicy, reader)
|
|
45
|
+
: checkpoint(snapshot, summary, assessment);
|
|
58
46
|
if (signal?.aborted) {
|
|
59
|
-
throw new CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
47
|
+
throw new featureAuthority.CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
60
48
|
}
|
|
61
49
|
await preflight.revalidateReadSnapshot(snapshot, root, workspaceRoot);
|
|
62
50
|
if (signal?.aborted) {
|
|
@@ -73,14 +61,14 @@ export async function getResumeCheckpoint(tasksPath, workspaceRoot, extractComma
|
|
|
73
61
|
: compact.compactReadError(error);
|
|
74
62
|
}
|
|
75
63
|
}
|
|
76
|
-
export async function getResumeToolResult(rawArgs, workspace, policy, signal) {
|
|
64
|
+
export async function getResumeToolResult(rawArgs, workspace, policy, signal, reader) {
|
|
77
65
|
try {
|
|
78
66
|
const parsed = GetActiveTaskInputSchema.safeParse(rawArgs);
|
|
79
67
|
if (!parsed.success) {
|
|
80
68
|
return compact.formatCompactResult(compact.compactFailure('compact_input_invalid'));
|
|
81
69
|
}
|
|
82
70
|
const args = parsed.data;
|
|
83
|
-
if (!
|
|
71
|
+
if (!failures.validCompactIdentifier(args.feature_id)) {
|
|
84
72
|
return compact.formatCompactResult(compact.compactFailure('compact_identifier_invalid'));
|
|
85
73
|
}
|
|
86
74
|
const newView = ['execution_window', 'execution_detail', 'evidence_history'].includes(args.view ?? '');
|
|
@@ -107,7 +95,7 @@ export async function getResumeToolResult(rawArgs, workspace, policy, signal) {
|
|
|
107
95
|
result = await history.getRelockHistory(tasksPath, resolved.workspaceRoot, args.history_cursor, signal);
|
|
108
96
|
}
|
|
109
97
|
else {
|
|
110
|
-
result = await getResumeCheckpoint(tasksPath, resolved.workspaceRoot, verificationCommand, args.verification_receipts, policy?.mode === 'scoped' ? policy : undefined, signal);
|
|
98
|
+
result = await getResumeCheckpoint(tasksPath, resolved.workspaceRoot, failures.verificationCommand, args.verification_receipts, policy?.mode === 'scoped' ? policy : undefined, signal, reader, args.view === 'resume');
|
|
111
99
|
}
|
|
112
100
|
return compact.formatCompactResult(result);
|
|
113
101
|
}
|
|
@@ -132,8 +120,8 @@ async function captureCore(tasksPath, workspaceRoot, extractCommand) {
|
|
|
132
120
|
await preflight.assertGuardAbsent(snapshot.feature);
|
|
133
121
|
const summary = summarizeTaskContent(snapshot.artifacts['tasks.md']?.content ?? '', extractCommand);
|
|
134
122
|
const active = summary.current.success ? summary.current.data.activeTask : null;
|
|
135
|
-
if (!
|
|
136
|
-
(active && !
|
|
123
|
+
if (!failures.validCompactIdentifier(path.basename(snapshot.feature)) ||
|
|
124
|
+
(active && !failures.validCompactIdentifier(active.taskId))) {
|
|
137
125
|
throw new InvalidCompactIdentifierError();
|
|
138
126
|
}
|
|
139
127
|
return { root, snapshot, summary, active };
|
|
@@ -146,7 +134,7 @@ async function assessCore(core, workspaceRoot, receipts, policy, signal) {
|
|
|
146
134
|
async function compactCapture(args, context) {
|
|
147
135
|
const { tasksPath, workspaceRoot, capability, scopedPolicy, signal } = context;
|
|
148
136
|
const startSeq = args.evidence_cursor?.startSeq;
|
|
149
|
-
const core = await captureCore(tasksPath, workspaceRoot, verificationCommand);
|
|
137
|
+
const core = await captureCore(tasksPath, workspaceRoot, failures.verificationCommand);
|
|
150
138
|
const { root, snapshot } = core;
|
|
151
139
|
const records = [];
|
|
152
140
|
let journal = null;
|
|
@@ -174,7 +162,7 @@ async function compactCapture(args, context) {
|
|
|
174
162
|
async function revalidateCompact(c, context) {
|
|
175
163
|
const { workspaceRoot, capability, signal } = context;
|
|
176
164
|
if (signal?.aborted) {
|
|
177
|
-
throw new CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
165
|
+
throw new featureAuthority.CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
178
166
|
}
|
|
179
167
|
if (c.assessment?.inputs) {
|
|
180
168
|
await revalidateVerificationInputs(c.assessment.inputs, signal);
|
|
@@ -182,7 +170,7 @@ async function revalidateCompact(c, context) {
|
|
|
182
170
|
if (c.snapshot.locked) {
|
|
183
171
|
const again = await evidenceJournal.captureJournal(c.snapshot.locked, c.root, capability);
|
|
184
172
|
if (JSON.stringify(again.reference) !== JSON.stringify(c.journal)) {
|
|
185
|
-
throw new CompletionGuardError('contract_drift', 'Compact authority changed.');
|
|
173
|
+
throw new featureAuthority.CompletionGuardError('contract_drift', 'Compact authority changed.');
|
|
186
174
|
}
|
|
187
175
|
}
|
|
188
176
|
else {
|
|
@@ -190,7 +178,7 @@ async function revalidateCompact(c, context) {
|
|
|
190
178
|
}
|
|
191
179
|
await preflight.revalidateReadSnapshot(c.snapshot, c.root, workspaceRoot);
|
|
192
180
|
if (signal?.aborted) {
|
|
193
|
-
throw new CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
181
|
+
throw new featureAuthority.CompletionGuardError('cancelled', 'Compact read was cancelled.');
|
|
194
182
|
}
|
|
195
183
|
}
|
|
196
184
|
async function getExecutionView(args, context) {
|
|
@@ -240,7 +228,7 @@ function selectDetail(c, cursor) {
|
|
|
240
228
|
return compact.compactFailure('detail_cursor_stale', 'ERR_INVALID_SLICE');
|
|
241
229
|
}
|
|
242
230
|
const content = history.sections(c).texts[cursor.section];
|
|
243
|
-
if (hashArtifact(content) !== cursor.contentSha256) {
|
|
231
|
+
if (featureAuthority.hashArtifact(content) !== cursor.contentSha256) {
|
|
244
232
|
return compact.compactFailure('detail_cursor_stale', 'ERR_INVALID_SLICE');
|
|
245
233
|
}
|
|
246
234
|
const page = history.detailPage(path.basename(c.snapshot.feature), cursor, content);
|
|
@@ -1,14 +1,31 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
1
|
+
import type * as completion from '../types/completion.js';
|
|
2
|
+
import type * as resumeTypes from '../types/resume-views.js';
|
|
3
|
+
import type * as engine from '../types/sdd-engine.js';
|
|
4
|
+
import type { ScopedVerificationRun, VerificationBudgetDiagnostic, VerificationProcessEvidence } from '../types/verification.js';
|
|
5
|
+
export declare function verificationProcessEvidence(run: ScopedVerificationRun): VerificationProcessEvidence;
|
|
6
|
+
export declare function withVerificationProcess(result: engine.SddResult<engine.CompleteTaskResult>, run: ScopedVerificationRun): engine.SddResult<engine.CompleteTaskResult>;
|
|
7
|
+
export declare function completionFailure(reason: string, code?: 'ERR_VERIFICATION_FAILED' | 'ERR_SPEC_DRIFT', trigger?: string): engine.SddResult<never>;
|
|
8
|
+
export declare function patchMutationError(error: unknown): engine.SddResult<never>;
|
|
9
|
+
export declare function receiptFailure(reason: string, details?: Record<string, unknown>, trigger?: string): engine.SddResult<never>;
|
|
10
|
+
export declare function completionError(error: unknown, trigger?: string): engine.SddResult<never>;
|
|
11
|
+
export declare function taskOutOfSequence(taskId: string, activeTaskId: string | null, alreadyCompleted?: boolean): engine.SddResult<engine.CompleteTaskResult>;
|
|
12
|
+
export declare function verificationMissing(): engine.SddResult<engine.CompleteTaskResult>;
|
|
13
|
+
export declare function verificationFailed(run: ScopedVerificationRun): engine.SddResult<engine.CompleteTaskResult>;
|
|
14
|
+
export declare function unsupportedVerificationPlatform(): engine.SddResult<engine.CompleteTaskResult>;
|
|
15
|
+
export declare function scopedPathMismatch(): engine.SddResult<never>;
|
|
16
|
+
export declare function taskFileMissing(tasksFilePath: string): engine.SddResult<never>;
|
|
17
|
+
export declare function catalogueReadFailure(error: unknown, id: string): engine.SddResult<never>;
|
|
18
|
+
export declare function snapshotFailure(workspace?: boolean): engine.SddFailure;
|
|
19
|
+
export declare function uncertainCompletion(): engine.SddFailure;
|
|
20
|
+
export declare function scopedFailure(details: Record<string, unknown>): engine.SddFailure;
|
|
21
|
+
export declare function cancelledVerification(signal: AbortSignal): engine.SddFailure | null;
|
|
22
|
+
export declare function nextAction(reasons: ReadonlySet<engine.PreflightBlockerReason>): engine.PreflightAction;
|
|
23
|
+
export declare function verificationCommand(taskMarkdown: string): string | null;
|
|
24
|
+
export declare function withVerificationBudget(preflight: engine.VerificationPreflight, budget: VerificationBudgetDiagnostic): engine.VerificationPreflight;
|
|
25
|
+
export declare function checkpointPresentation(snapshot: completion.PreflightReadSnapshot, summary: resumeTypes.CompactCore['summary'], assessment?: resumeTypes.PreflightAssessment): resumeTypes.ResumePresentation;
|
|
26
|
+
export declare function preflightError(error: unknown): engine.SddResult<never>;
|
|
27
|
+
export declare function deniedBudget(reason: completion.BudgetDeniedReason): VerificationBudgetDiagnostic;
|
|
28
|
+
export declare function budgetPrecondition(context: completion.VerificationBudgetContext): completion.BudgetDeniedReason | null;
|
|
29
|
+
export declare function defaultBudget(reason: 'default_policy' | 'outside_scoped_grant'): VerificationBudgetDiagnostic;
|
|
30
|
+
export declare function validCompactIdentifier(id: string): boolean;
|
|
14
31
|
//# sourceMappingURL=task-failures.d.ts.map
|