@planu/cli 8.5.1 → 8.7.0
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 +16 -4
- package/dist/sdd-engine/completion-guard.js +2 -3
- package/dist/sdd-engine/contracts.d.ts +172 -0
- package/dist/sdd-engine/contracts.js +235 -10
- package/dist/sdd-engine/evidence-checkpoints.d.ts +6 -0
- package/dist/sdd-engine/evidence-checkpoints.js +280 -0
- package/dist/sdd-engine/evidence-journal.d.ts +25 -0
- package/dist/sdd-engine/evidence-journal.js +326 -0
- package/dist/sdd-engine/feature-manifest.d.ts +2 -1
- package/dist/sdd-engine/host-rule-pack.d.ts +4 -0
- package/dist/sdd-engine/host-rule-pack.js +114 -55
- package/dist/sdd-engine/host-skill-reader.d.ts +8 -1
- package/dist/sdd-engine/host-skill-reader.js +73 -0
- package/dist/sdd-engine/resume-history.d.ts +35 -3
- package/dist/sdd-engine/resume-history.js +242 -13
- package/dist/sdd-engine/resume-views.d.ts +7 -6
- package/dist/sdd-engine/resume-views.js +246 -114
- package/dist/sdd-engine/task-content.d.ts +2 -1
- 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/compact-result.d.ts +35 -5
- package/dist/sdd-engine/tools/compact-result.js +279 -2
- package/dist/sdd-engine/tools/execution-tools.js +20 -9
- package/dist/sdd-engine/tools/workspace-tools.js +80 -51
- package/dist/sdd-engine/trinity-structure.d.ts +2 -2
- package/dist/sdd-engine/verification-inputs.d.ts +2 -1
- package/dist/sdd-engine/verification-policy.d.ts +7 -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.d.ts +2 -2
- package/dist/sdd-engine/verification-receipts.js +2 -1
- package/dist/sdd-engine/verification-runner.d.ts +3 -1
- package/dist/sdd-engine/verification-runner.js +12 -7
- package/dist/types/completion.d.ts +183 -3
- package/dist/types/resume-views.d.ts +221 -2
- package/dist/types/sdd-engine.d.ts +52 -112
- package/dist/types/verification.d.ts +26 -9
- package/package.json +5 -5
- package/templates/AGENTS.md +4 -0
- package/templates/host/planu-sdd.md +4 -0
- package/templates/skills/preflight-guardian.md +4 -0
- package/templates/skills/reconciler.md +6 -0
- package/templates/skills/spec-architect.md +44 -0
- package/templates/skills/spec-executor.md +6 -0
- package/templates/skills/verification-auditor.md +6 -0
- package/dist/sdd-engine/tools/format-result.d.ts +0 -3
- package/dist/sdd-engine/tools/format-result.js +0 -22
|
@@ -1,46 +1,62 @@
|
|
|
1
1
|
import { CompletionGuardError } from './feature-authority.js';
|
|
2
2
|
import { VerificationInputError } from './verification-inputs.js';
|
|
3
|
+
function makeFailure(error) {
|
|
4
|
+
return { success: false, error };
|
|
5
|
+
}
|
|
6
|
+
export function verificationProcessEvidence(run) {
|
|
7
|
+
return {
|
|
8
|
+
version: 1,
|
|
9
|
+
timeoutMs: run.timeoutMs,
|
|
10
|
+
timedOut: run.timedOut,
|
|
11
|
+
cancelled: run.cancelled,
|
|
12
|
+
exitCode: run.exitCode,
|
|
13
|
+
signal: run.signal,
|
|
14
|
+
cleanupComplete: run.cleanupComplete,
|
|
15
|
+
cleanupScope: 'owned_process_group',
|
|
16
|
+
fixturePostconditions: 'unknown',
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function withVerificationProcess(result, run) {
|
|
20
|
+
const verificationProcess = verificationProcessEvidence(run);
|
|
21
|
+
return result.success
|
|
22
|
+
? { ...result, data: { ...result.data, verificationProcess } }
|
|
23
|
+
: {
|
|
24
|
+
...result,
|
|
25
|
+
error: { ...result.error, details: { ...result.error.details, verificationProcess } },
|
|
26
|
+
};
|
|
27
|
+
}
|
|
3
28
|
export function completionFailure(reason, code = reason === 'contract_drift'
|
|
4
29
|
? 'ERR_SPEC_DRIFT'
|
|
5
30
|
: 'ERR_VERIFICATION_FAILED', trigger = 'sdd_complete_task') {
|
|
6
|
-
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
details: { reason },
|
|
15
|
-
},
|
|
16
|
-
};
|
|
31
|
+
return makeFailure({
|
|
32
|
+
code,
|
|
33
|
+
message: reason === 'persistence_uncertain'
|
|
34
|
+
? 'Completion state requires explicit reviewed recovery with sdd_lock_spec.'
|
|
35
|
+
: 'Completion was denied; inspect the bounded reason before retrying.',
|
|
36
|
+
trigger,
|
|
37
|
+
details: { reason },
|
|
38
|
+
});
|
|
17
39
|
}
|
|
18
40
|
export function patchMutationError(error) {
|
|
19
41
|
const guarded = error instanceof CompletionGuardError || error instanceof VerificationInputError;
|
|
20
|
-
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
?
|
|
25
|
-
:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
details: { reason: guarded ? error.reason : 'failed' },
|
|
31
|
-
},
|
|
32
|
-
};
|
|
42
|
+
return makeFailure({
|
|
43
|
+
code: error instanceof VerificationInputError
|
|
44
|
+
? 'ERR_PERMISSION_VIOLATION'
|
|
45
|
+
: error instanceof CompletionGuardError
|
|
46
|
+
? error.code
|
|
47
|
+
: 'ERR_VERIFICATION_FAILED',
|
|
48
|
+
message: guarded ? error.message : 'Feature mutation was denied.',
|
|
49
|
+
trigger: 'sdd_apply_file_patch',
|
|
50
|
+
details: { reason: guarded ? error.reason : 'failed' },
|
|
51
|
+
});
|
|
33
52
|
}
|
|
34
53
|
export function receiptFailure(reason, details = {}, trigger = 'sdd_complete_task') {
|
|
35
|
-
return {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
details: { reason, ...details },
|
|
42
|
-
},
|
|
43
|
-
};
|
|
54
|
+
return makeFailure({
|
|
55
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
56
|
+
message: 'Receipt verification was denied.',
|
|
57
|
+
trigger,
|
|
58
|
+
details: { reason, ...details },
|
|
59
|
+
});
|
|
44
60
|
}
|
|
45
61
|
export function completionError(error, trigger = 'sdd_complete_task') {
|
|
46
62
|
if (error instanceof VerificationInputError) {
|
|
@@ -50,110 +66,263 @@ export function completionError(error, trigger = 'sdd_complete_task') {
|
|
|
50
66
|
}, trigger);
|
|
51
67
|
}
|
|
52
68
|
if (error instanceof CompletionGuardError) {
|
|
53
|
-
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
details: { reason: error.reason },
|
|
60
|
-
},
|
|
61
|
-
};
|
|
69
|
+
return makeFailure({
|
|
70
|
+
code: error.code,
|
|
71
|
+
message: error.message,
|
|
72
|
+
trigger,
|
|
73
|
+
details: { reason: error.reason },
|
|
74
|
+
});
|
|
62
75
|
}
|
|
63
76
|
return completionFailure('failed', undefined, trigger);
|
|
64
77
|
}
|
|
65
78
|
export function taskOutOfSequence(taskId, activeTaskId, alreadyCompleted = false) {
|
|
66
|
-
return {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
activeTaskId,
|
|
75
|
-
...(alreadyCompleted ? { reason: 'already_completed' } : {}),
|
|
76
|
-
},
|
|
79
|
+
return makeFailure({
|
|
80
|
+
code: 'ERR_TASK_OUT_OF_SEQUENCE',
|
|
81
|
+
message: `Task '${taskId}' is not active or was already completed.`,
|
|
82
|
+
trigger: 'sdd_complete_task',
|
|
83
|
+
details: {
|
|
84
|
+
requestedTaskId: taskId,
|
|
85
|
+
activeTaskId,
|
|
86
|
+
...(alreadyCompleted ? { reason: 'already_completed' } : {}),
|
|
77
87
|
},
|
|
78
|
-
};
|
|
88
|
+
});
|
|
79
89
|
}
|
|
80
90
|
export function verificationMissing() {
|
|
81
|
-
return {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
trigger: 'sdd_complete_task',
|
|
87
|
-
},
|
|
88
|
-
};
|
|
91
|
+
return makeFailure({
|
|
92
|
+
code: 'ERR_VERIFICATION_MISSING',
|
|
93
|
+
message: 'The active task needs one Verification line whose command does not contain < or >.',
|
|
94
|
+
trigger: 'sdd_complete_task',
|
|
95
|
+
});
|
|
89
96
|
}
|
|
90
97
|
export function verificationFailed(run) {
|
|
91
98
|
const exitCode = run.exitCode ?? 1;
|
|
92
|
-
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
cleanupComplete: run.cleanupComplete,
|
|
103
|
-
},
|
|
99
|
+
return makeFailure({
|
|
100
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
101
|
+
message: `Verification command exited ${String(exitCode)}.`,
|
|
102
|
+
trigger: 'sdd_complete_task',
|
|
103
|
+
details: {
|
|
104
|
+
reason: run.cancelled ? 'cancelled' : run.timedOut ? 'timeout' : 'failed',
|
|
105
|
+
exitCode,
|
|
106
|
+
outputTail: run.output.slice(-2000),
|
|
107
|
+
verificationProcess: verificationProcessEvidence(run),
|
|
108
|
+
cleanupComplete: run.cleanupComplete,
|
|
104
109
|
},
|
|
105
|
-
};
|
|
110
|
+
});
|
|
106
111
|
}
|
|
107
112
|
export function unsupportedVerificationPlatform() {
|
|
108
|
-
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
platform: process.platform,
|
|
117
|
-
verificationSupported: false,
|
|
118
|
-
},
|
|
113
|
+
return makeFailure({
|
|
114
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
115
|
+
message: 'Automatic task verification currently requires local macOS or Linux for owned process-tree cleanup. Planning and read-only tools remain available.',
|
|
116
|
+
trigger: 'sdd_complete_task',
|
|
117
|
+
details: {
|
|
118
|
+
reason: 'failed',
|
|
119
|
+
platform: process.platform,
|
|
120
|
+
verificationSupported: false,
|
|
119
121
|
},
|
|
120
|
-
};
|
|
122
|
+
});
|
|
121
123
|
}
|
|
122
124
|
export function scopedPathMismatch() {
|
|
123
|
-
return {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
details: { reason: 'verification_policy_workspace_mismatch' },
|
|
130
|
-
},
|
|
131
|
-
};
|
|
125
|
+
return makeFailure({
|
|
126
|
+
code: 'ERR_WORKSPACE_UNRESOLVED',
|
|
127
|
+
message: 'Scoped verification path does not match its trusted policy.',
|
|
128
|
+
trigger: 'sdd_complete_task',
|
|
129
|
+
details: { reason: 'verification_policy_workspace_mismatch' },
|
|
130
|
+
});
|
|
132
131
|
}
|
|
133
132
|
export function taskFileMissing(tasksFilePath) {
|
|
134
|
-
return {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
return makeFailure({
|
|
134
|
+
code: 'ERR_TASK_NOT_FOUND',
|
|
135
|
+
message: `File tasks.md not found at: '${tasksFilePath}'.`,
|
|
136
|
+
trigger: 'sdd_get_active_task',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
export function catalogueReadFailure(error, id) {
|
|
140
|
+
return makeFailure({
|
|
141
|
+
code: error instanceof CompletionGuardError ? error.code : 'ERR_INVALID_ARTIFACT',
|
|
142
|
+
message: error instanceof CompletionGuardError
|
|
143
|
+
? error.message
|
|
144
|
+
: 'Could not read the complete feature catalogue.',
|
|
145
|
+
trigger: 'sdd_list_features',
|
|
146
|
+
details: {
|
|
147
|
+
entry: id,
|
|
148
|
+
...(error instanceof CompletionGuardError ? { reason: error.reason } : {}),
|
|
140
149
|
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export function snapshotFailure(workspace = false) {
|
|
153
|
+
return makeFailure({
|
|
154
|
+
code: workspace ? 'ERR_WORKSPACE_UNRESOLVED' : 'ERR_SPEC_DRIFT',
|
|
155
|
+
message: 'Scoped verification context does not match the trusted startup policy.',
|
|
156
|
+
trigger: 'sdd_complete_task',
|
|
157
|
+
details: {
|
|
158
|
+
reason: workspace ? 'verification_policy_workspace_mismatch' : 'verification_policy_mismatch',
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export function uncertainCompletion() {
|
|
163
|
+
return makeFailure({
|
|
164
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
165
|
+
message: 'Completion persistence is uncertain; operator reconciliation is required.',
|
|
166
|
+
trigger: 'sdd_complete_task',
|
|
167
|
+
details: { reason: 'verification_completion_io', completionState: 'uncertain' },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
export function scopedFailure(details) {
|
|
171
|
+
return makeFailure({
|
|
172
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
173
|
+
message: 'Scoped verification did not produce a safely committed certificate.',
|
|
174
|
+
trigger: 'sdd_complete_task',
|
|
175
|
+
details,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
export function cancelledVerification(signal) {
|
|
179
|
+
if (!signal.aborted) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
return scopedFailure({ reason: 'verification_cancelled', cancelled: true, timedOut: false });
|
|
183
|
+
}
|
|
184
|
+
export function nextAction(reasons) {
|
|
185
|
+
if (reasons.has('unlocked')) {
|
|
186
|
+
return 'review_lock';
|
|
187
|
+
}
|
|
188
|
+
if (reasons.has('platform_unsupported') || reasons.has('receipt_scoped_unsupported')) {
|
|
189
|
+
return 'use_supported_runtime';
|
|
190
|
+
}
|
|
191
|
+
if (reasons.has('command_missing')) {
|
|
192
|
+
return 'restore_verification';
|
|
193
|
+
}
|
|
194
|
+
if (reasons.has('receipt_input_unavailable')) {
|
|
195
|
+
return 'fix_inputs';
|
|
196
|
+
}
|
|
197
|
+
if (reasons.has('receipt_observed_baseline_drift')) {
|
|
198
|
+
return 'review_observed_drift';
|
|
199
|
+
}
|
|
200
|
+
if (reasons.has('receipt_not_configured')) {
|
|
201
|
+
return 'restore_verification';
|
|
202
|
+
}
|
|
203
|
+
if ([...reasons].some((reason) => reason.startsWith('verification_'))) {
|
|
204
|
+
return 'review_verification_policy';
|
|
205
|
+
}
|
|
206
|
+
return reasons.size ? 'obtain_receipts' : 'attempt_integration';
|
|
207
|
+
}
|
|
208
|
+
export function verificationCommand(taskMarkdown) {
|
|
209
|
+
const line = taskMarkdown
|
|
210
|
+
.split('\n')
|
|
211
|
+
.map((entry) => entry.trim())
|
|
212
|
+
.find((entry) => /^verification:/iu.test(entry));
|
|
213
|
+
if (!line) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const command = line.replace(/^verification:\s*/iu, '').trim();
|
|
217
|
+
if (command.length === 0 || command.includes('<') || command.includes('>')) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return command;
|
|
221
|
+
}
|
|
222
|
+
export function withVerificationBudget(preflight, budget) {
|
|
223
|
+
if (budget.admission !== 'denied' || !preflight.taskId || budget.reason === 'unlocked') {
|
|
224
|
+
return { ...preflight, budget };
|
|
225
|
+
}
|
|
226
|
+
if (budget.reason === 'no_active_task') {
|
|
227
|
+
return { ...preflight, budget };
|
|
228
|
+
}
|
|
229
|
+
const reasons = new Set([
|
|
230
|
+
...preflight.blockers.map(({ reason }) => reason),
|
|
231
|
+
budget.reason,
|
|
232
|
+
]);
|
|
233
|
+
return {
|
|
234
|
+
...preflight,
|
|
235
|
+
budget,
|
|
236
|
+
status: 'blocked',
|
|
237
|
+
blockers: [...reasons]
|
|
238
|
+
.sort()
|
|
239
|
+
.slice(0, 16)
|
|
240
|
+
.map((reason) => ({ reason })),
|
|
241
|
+
nextAction: preflight.nextAction === 'attempt_integration' ? nextAction(reasons) : preflight.nextAction,
|
|
141
242
|
};
|
|
142
243
|
}
|
|
143
|
-
|
|
244
|
+
function checkpointStatus(snapshot, summary) {
|
|
245
|
+
if (!snapshot.locked) {
|
|
246
|
+
return 'unlocked';
|
|
247
|
+
}
|
|
248
|
+
if (summary.progress.total) {
|
|
249
|
+
return summary.current.success && summary.current.data.activeTask ? 'active' : 'complete';
|
|
250
|
+
}
|
|
251
|
+
return 'no_tasks';
|
|
252
|
+
}
|
|
253
|
+
export function checkpointPresentation(snapshot, summary, assessment) {
|
|
254
|
+
const status = checkpointStatus(snapshot, summary);
|
|
255
|
+
const active = summary.current.success ? summary.current.data.activeTask : null;
|
|
256
|
+
if (status === 'active' && active && assessment) {
|
|
257
|
+
return {
|
|
258
|
+
status,
|
|
259
|
+
task: { id: active.taskId, index: active.taskIndex },
|
|
260
|
+
readiness: assessment.preflight.status,
|
|
261
|
+
integration: 'pending',
|
|
262
|
+
blockers: assessment.preflight.blockers,
|
|
263
|
+
nextAction: assessment.preflight.nextAction,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
144
266
|
return {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
trigger: 'sdd_list_features',
|
|
152
|
-
details: {
|
|
153
|
-
entry: id,
|
|
154
|
-
...(error instanceof CompletionGuardError ? { reason: error.reason } : {}),
|
|
155
|
-
},
|
|
156
|
-
},
|
|
267
|
+
status,
|
|
268
|
+
task: null,
|
|
269
|
+
readiness: status === 'unlocked' ? 'blocked' : 'not_applicable',
|
|
270
|
+
integration: 'not_applicable',
|
|
271
|
+
blockers: status === 'unlocked' ? [{ reason: 'unlocked' }] : [],
|
|
272
|
+
nextAction: status === 'unlocked' ? 'review_lock' : status === 'no_tasks' ? 'inspect_tasks' : 'none',
|
|
157
273
|
};
|
|
158
274
|
}
|
|
275
|
+
export function preflightError(error) {
|
|
276
|
+
const failure = completionError(error, 'sdd_get_active_task');
|
|
277
|
+
if (failure.success) {
|
|
278
|
+
return makeFailure({
|
|
279
|
+
code: 'ERR_VERIFICATION_FAILED',
|
|
280
|
+
message: 'Verification preflight is unavailable.',
|
|
281
|
+
trigger: 'sdd_get_active_task',
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const rawReason = failure.error.details?.reason;
|
|
285
|
+
const reasons = new Set([
|
|
286
|
+
'guard_present',
|
|
287
|
+
'contract_drift',
|
|
288
|
+
'cancelled',
|
|
289
|
+
'persistence_uncertain',
|
|
290
|
+
'receipt_input_drift',
|
|
291
|
+
'receipt_input_unavailable',
|
|
292
|
+
]);
|
|
293
|
+
const reason = typeof rawReason === 'string' && reasons.has(rawReason) ? rawReason : 'failed';
|
|
294
|
+
return makeFailure({
|
|
295
|
+
code: failure.error.code,
|
|
296
|
+
message: 'Verification preflight is unavailable; inspect the bounded reason before retrying.',
|
|
297
|
+
trigger: 'sdd_get_active_task',
|
|
298
|
+
details: { reason },
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
export function deniedBudget(reason) {
|
|
302
|
+
return { version: 1, admission: 'denied', effectiveTimeoutMs: null, reason };
|
|
303
|
+
}
|
|
304
|
+
export function budgetPrecondition(context) {
|
|
305
|
+
if (!context.snapshot.locked) {
|
|
306
|
+
return 'unlocked';
|
|
307
|
+
}
|
|
308
|
+
if (!context.selected) {
|
|
309
|
+
return 'no_active_task';
|
|
310
|
+
}
|
|
311
|
+
for (const reason of [
|
|
312
|
+
'command_missing',
|
|
313
|
+
'platform_unsupported',
|
|
314
|
+
'receipt_scoped_unsupported',
|
|
315
|
+
]) {
|
|
316
|
+
if (context.preflight.blockers.some((blocker) => blocker.reason === reason)) {
|
|
317
|
+
return reason;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
export function defaultBudget(reason) {
|
|
323
|
+
return { version: 1, admission: 'default', effectiveTimeoutMs: 180000, reason };
|
|
324
|
+
}
|
|
325
|
+
export function validCompactIdentifier(id) {
|
|
326
|
+
return id.length <= 128 && /^[A-Z0-9_-]+$/u.test(id);
|
|
327
|
+
}
|
|
159
328
|
//# sourceMappingURL=task-failures.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { ActiveTaskResult, CompleteTaskResult, FeatureSummary, SddResult } from '../types/sdd-engine.js';
|
|
1
|
+
import type { ActiveTaskResult, CompleteTaskResult, FeatureSummary, SddResult, SddWorkspaceHandle } from '../types/sdd-engine.js';
|
|
2
|
+
import type { VerificationBudgetReader } from '../types/completion.js';
|
|
2
3
|
import type { VerificationPolicy } from '../types/verification.js';
|
|
4
|
+
import { getResumeToolResult } from './resume-views.js';
|
|
3
5
|
export declare class TaskWindowManager {
|
|
4
6
|
private readonly scopedPolicy;
|
|
5
7
|
private readonly scoped;
|
|
@@ -7,9 +9,10 @@ export declare class TaskWindowManager {
|
|
|
7
9
|
private readonly pending;
|
|
8
10
|
constructor(policy?: VerificationPolicy);
|
|
9
11
|
shutdown(): Promise<void>;
|
|
10
|
-
private activeTaskFromContent;
|
|
11
12
|
private selectScopedTask;
|
|
12
13
|
getActiveTask(tasksFilePath: string): Promise<SddResult<ActiveTaskResult>>;
|
|
14
|
+
readonly inspectVerificationBudget: VerificationBudgetReader;
|
|
15
|
+
getResumeToolResult(args: unknown, workspace: SddWorkspaceHandle, signal?: AbortSignal): ReturnType<typeof getResumeToolResult>;
|
|
13
16
|
getVerificationPreflight(tasksPath: string, workspaceRoot: string, receipts?: unknown, signal?: AbortSignal): Promise<SddResult<ActiveTaskResult>>;
|
|
14
17
|
getCatalogueEntry(featDir: string): Promise<SddResult<FeatureSummary>>;
|
|
15
18
|
completeTask(tasksFilePath: string, taskId: string, workspaceRoot: string, _verificationOutput: string, signal?: AbortSignal, receipts?: unknown): Promise<SddResult<CompleteTaskResult>>;
|
|
@@ -19,5 +22,5 @@ export declare class TaskWindowManager {
|
|
|
19
22
|
private attemptScopedCompletion;
|
|
20
23
|
private completeOrdinary;
|
|
21
24
|
}
|
|
22
|
-
export
|
|
25
|
+
export { verificationCommand } from './task-failures.js';
|
|
23
26
|
//# sourceMappingURL=task-window.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as path from 'node:path';
|
|
2
2
|
import { ScopedVerificationCoordinator, runScopedVerification } from './verification-runner.js';
|
|
3
3
|
import { isScopedVerificationFeature, persistScopedCompletionFiles, scopedFeaturePathFailure, } from './verification-policy.js';
|
|
4
|
+
import { getResumeToolResult } from './resume-views.js';
|
|
4
5
|
import { getVerificationPreflight } from './verification-preflight.js';
|
|
5
6
|
import { executionCard } from './lock-integrity.js';
|
|
6
7
|
import { parseVerificationReceiptPolicy } from './feature-manifest.js';
|
|
@@ -9,7 +10,7 @@ import { CompletionGuardError, readFeatureArtifact } from './feature-authority.j
|
|
|
9
10
|
import { acquireCompletionLease, inspectCompletionGuard, } from './completion-guard.js';
|
|
10
11
|
import { captureCompletionSnapshot, revalidateCompletionSnapshot, commitOrdinaryTask, commitOwnedScopedTask, readCatalogueArtifacts, } from './completion-snapshot.js';
|
|
11
12
|
import { activeTaskFromContent, catalogueFromContent, wasTaskCompleted } from './task-content.js';
|
|
12
|
-
import { completionFailure, completionError, taskOutOfSequence, receiptFailure, verificationMissing, verificationFailed, unsupportedVerificationPlatform, scopedPathMismatch, taskFileMissing, catalogueReadFailure, } from './task-failures.js';
|
|
13
|
+
import { verificationCommand, completionFailure, completionError, taskOutOfSequence, receiptFailure, verificationMissing, verificationFailed, withVerificationProcess, unsupportedVerificationPlatform, scopedPathMismatch, taskFileMissing, catalogueReadFailure, } from './task-failures.js';
|
|
13
14
|
export class TaskWindowManager {
|
|
14
15
|
scopedPolicy;
|
|
15
16
|
scoped;
|
|
@@ -26,11 +27,8 @@ export class TaskWindowManager {
|
|
|
26
27
|
await this.scoped?.shutdown();
|
|
27
28
|
await Promise.allSettled([...this.pending]);
|
|
28
29
|
}
|
|
29
|
-
activeTaskFromContent(content) {
|
|
30
|
-
return activeTaskFromContent(content, verificationCommand);
|
|
31
|
-
}
|
|
32
30
|
selectScopedTask(content) {
|
|
33
|
-
const result =
|
|
31
|
+
const result = activeTaskFromContent(content, verificationCommand);
|
|
34
32
|
const active = result.success ? result.data.activeTask : null;
|
|
35
33
|
return active
|
|
36
34
|
? {
|
|
@@ -55,7 +53,7 @@ export class TaskWindowManager {
|
|
|
55
53
|
}
|
|
56
54
|
return taskFileMissing(tasksFilePath);
|
|
57
55
|
}
|
|
58
|
-
const built =
|
|
56
|
+
const built = activeTaskFromContent(content, verificationCommand);
|
|
59
57
|
if (!built.success) {
|
|
60
58
|
return built;
|
|
61
59
|
}
|
|
@@ -76,8 +74,12 @@ export class TaskWindowManager {
|
|
|
76
74
|
return completionError(error, 'sdd_get_active_task');
|
|
77
75
|
}
|
|
78
76
|
}
|
|
77
|
+
inspectVerificationBudget = (taskId) => this.scoped?.inspectState(taskId);
|
|
78
|
+
getResumeToolResult(args, workspace, signal) {
|
|
79
|
+
return getResumeToolResult(args, workspace, this.scopedPolicy, signal, this.inspectVerificationBudget);
|
|
80
|
+
}
|
|
79
81
|
async getVerificationPreflight(tasksPath, workspaceRoot, receipts, signal) {
|
|
80
|
-
return getVerificationPreflight(tasksPath, workspaceRoot, verificationCommand, receipts, this.scopedPolicy, signal);
|
|
82
|
+
return getVerificationPreflight(tasksPath, workspaceRoot, verificationCommand, receipts, this.scopedPolicy, signal, this.inspectVerificationBudget);
|
|
81
83
|
}
|
|
82
84
|
async getCatalogueEntry(featDir) {
|
|
83
85
|
const id = path.basename(featDir);
|
|
@@ -199,7 +201,7 @@ export class TaskWindowManager {
|
|
|
199
201
|
return null;
|
|
200
202
|
}
|
|
201
203
|
async completeOrdinary(snapshot, lease, taskId, workspaceRoot, signal) {
|
|
202
|
-
const active =
|
|
204
|
+
const active = activeTaskFromContent(snapshot.tasksContent, verificationCommand);
|
|
203
205
|
if (!active.success) {
|
|
204
206
|
return active;
|
|
205
207
|
}
|
|
@@ -237,22 +239,9 @@ export class TaskWindowManager {
|
|
|
237
239
|
if (!run.ok) {
|
|
238
240
|
return verificationFailed(run);
|
|
239
241
|
}
|
|
240
|
-
return commitOrdinaryTask(snapshot, lease, taskId, run.output, signal);
|
|
242
|
+
return withVerificationProcess(await commitOrdinaryTask(snapshot, lease, taskId, run.output, signal), run);
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
const VERIFICATION_TIMEOUT_MS = 180_000;
|
|
244
|
-
export
|
|
245
|
-
const line = taskMarkdown
|
|
246
|
-
.split('\n')
|
|
247
|
-
.map((entry) => entry.trim())
|
|
248
|
-
.find((entry) => /^verification:/iu.test(entry));
|
|
249
|
-
if (!line) {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
const command = line.replace(/^verification:\s*/iu, '').trim();
|
|
253
|
-
if (command.length === 0 || command.includes('<') || command.includes('>')) {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
return command;
|
|
257
|
-
}
|
|
246
|
+
export { verificationCommand } from './task-failures.js';
|
|
258
247
|
//# sourceMappingURL=task-window.js.map
|
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import type { CheckpointFailureReason, CompletionSnapshot } from '../../types/completion.js';
|
|
2
|
+
import type * as engineTypes from '../../types/sdd-engine.js';
|
|
3
|
+
import type * as resumeTypes from '../../types/resume-views.js';
|
|
4
|
+
export declare function compactFailure(reason: resumeTypes.CompactFailureReason, code?: engineTypes.ErrorCode): engineTypes.SddResult<never>;
|
|
5
|
+
export declare function compactReadError(error: unknown): engineTypes.SddResult<never>;
|
|
6
|
+
export declare function formatCompactResult<T>(result: engineTypes.SddResult<T>): engineTypes.ToolResult;
|
|
7
|
+
export declare function formatResult<T>(result: engineTypes.SddResult<T>): engineTypes.ToolResult;
|
|
8
|
+
export declare class CheckpointCapabilityError extends Error {
|
|
9
|
+
}
|
|
10
|
+
export declare function checkpointCapabilityFailure(trigger?: string): engineTypes.SddResult<never>;
|
|
11
|
+
export declare class CheckpointError extends Error {
|
|
12
|
+
readonly reason: CheckpointFailureReason;
|
|
13
|
+
readonly code: engineTypes.ErrorCode;
|
|
14
|
+
readonly nextAction?: string;
|
|
15
|
+
constructor(reason: CheckpointFailureReason);
|
|
16
|
+
}
|
|
17
|
+
export declare function checkpointError(reason: CheckpointFailureReason, trigger?: string): engineTypes.SddResult<never>;
|
|
18
|
+
export declare function checkpointSuccess(seq: number, recordSha256: string, journal: engineTypes.CheckpointJournalReference): engineTypes.SddResult<{
|
|
19
|
+
checkpoint: engineTypes.EvidenceCheckpointResult;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function checkpointException(error: unknown, capabilityUnavailable: boolean): engineTypes.SddResult<never>;
|
|
22
|
+
export declare function checkpointOpenUnsupported(error: unknown): boolean;
|
|
23
|
+
export declare function checkpointUnsupported(error: unknown): boolean;
|
|
24
|
+
export declare function checkpointOpenDenied(error: unknown): boolean;
|
|
25
|
+
export declare function checkpointRevalidationError(error: unknown): never;
|
|
26
|
+
export declare function checkpointInitialLockError(error: unknown): never;
|
|
27
|
+
export declare function checkpointDirectoryError(): never;
|
|
28
|
+
export declare function checkpointAcquireIoError(error: unknown): boolean;
|
|
29
|
+
export declare function checkpointGuardInspectionError(error: unknown): never;
|
|
30
|
+
export declare function journalPage(featureId: string, snapshotSha256: string, journal: engineTypes.CheckpointJournalReference | null, records: resumeTypes.EvidenceCheckpointRecord[], startSeq: number): resumeTypes.EvidenceHistoryPage | null;
|
|
31
|
+
export declare function detailEnvelope(featureId: string, cursor: engineTypes.ExecutionDetailCursor, bytes: Buffer, end: number): resumeTypes.ExecutionDetailPage;
|
|
32
|
+
export declare function resumeProjection(featureId: string, progress: resumeTypes.ResumeCheckpoint['progress'], presentation: resumeTypes.ResumePresentation, contract: resumeTypes.ResumeCheckpoint['contract'], assessment: resumeTypes.PreflightAssessment | undefined, history: resumeTypes.ResumeHistory): resumeTypes.ResumeCheckpoint;
|
|
33
|
+
export declare function executionWindowResult(window: resumeTypes.ExecutionWindow): engineTypes.SddResult<unknown>;
|
|
34
|
+
export declare function historyRef(locked: CompletionSnapshot, count: number): resumeTypes.ResumeHistory;
|
|
35
|
+
export declare function executionReadError(error: unknown): engineTypes.SddResult<never>;
|
|
6
36
|
//# sourceMappingURL=compact-result.d.ts.map
|