@planu/cli 8.5.1 → 8.6.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 +6 -0
- package/README.md +12 -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 +112 -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 +6 -6
- package/dist/sdd-engine/resume-views.js +222 -78
- package/dist/sdd-engine/task-content.d.ts +2 -1
- 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 +17 -5
- 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 +2 -1
- package/dist/sdd-engine/verification-preflight.d.ts +2 -2
- package/dist/sdd-engine/verification-receipts.d.ts +2 -2
- package/dist/sdd-engine/verification-runner.d.ts +2 -1
- package/dist/types/completion.d.ts +168 -3
- package/dist/types/resume-views.d.ts +220 -2
- package/dist/types/sdd-engine.d.ts +47 -110
- package/dist/types/verification.d.ts +0 -10
- package/package.json +5 -5
- package/templates/AGENTS.md +2 -0
- package/templates/host/planu-sdd.md +2 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [8.6.0]
|
|
2
|
+
|
|
3
|
+
- Add bounded execution window, detail and evidence history views, selected-host setup diagnostics, and explicit evidence checkpoints to the existing nine tools.
|
|
4
|
+
- Record only caller-reported observations explicitly; they are not certification or receipt coverage. Valid signed receipts still require fresh integration.
|
|
5
|
+
- Preserve locked authority and verification budgets; reject unsafe journal paths and retain uncertain guards for operator review.
|
|
6
|
+
|
|
1
7
|
## [8.5.1] - 2026-11-07
|
|
2
8
|
|
|
3
9
|
- Refresh the reviewed development tooling and advisory resolutions while preserving the Node floor, TypeScript compiler/library aliases, nine tools and finite package contract.
|
package/README.md
CHANGED
|
@@ -138,14 +138,14 @@ The reviewed operator procedure is in the repository guide `docs/verification-bu
|
|
|
138
138
|
|
|
139
139
|
## Read-only diagnostics
|
|
140
140
|
|
|
141
|
-
The existing nine tools expose additive diagnostics since 8.4.0; 8.5.0 adds compact resume and history views. An ordinary `sdd_get_active_task` request keeps its previous response shape.
|
|
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.
|
|
142
142
|
|
|
143
143
|
`sdd_list_features` includes `hostSkills`. For example, a missing installed role can produce this field (other installed files match the available bundled reference):
|
|
144
144
|
|
|
145
145
|
```json
|
|
146
146
|
{
|
|
147
147
|
"version": 1,
|
|
148
|
-
"bundledVersion": "8.
|
|
148
|
+
"bundledVersion": "8.6.0",
|
|
149
149
|
"baseline": "available",
|
|
150
150
|
"catalog": "unverified",
|
|
151
151
|
"issues": [{
|
|
@@ -177,7 +177,7 @@ Request preflight explicitly through `sdd_get_active_task`:
|
|
|
177
177
|
{"feature_id":"FEAT-EXAMPLE","view":"verification_preflight"}
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
Optionally supply `verification_receipts` with the signed receipt array described below. Receipts require an explicit `verification_preflight` or `
|
|
180
|
+
Optionally supply `verification_receipts` with the signed receipt array described below. Receipts require an explicit `verification_preflight`, `resume`, or `execution_window` view, or a verification section of `execution_detail`. For an opted-in task with one required gate named `contents`, no supplied receipts and otherwise available inputs, `data.verificationPreflight` is:
|
|
181
181
|
|
|
182
182
|
```json
|
|
183
183
|
{
|
|
@@ -195,6 +195,14 @@ Check `version: 1` on the requested response: an older server may ignore optiona
|
|
|
195
195
|
|
|
196
196
|
`ready_to_attempt` with `attempt_integration` means these read-only checks passed for the current candidate. Runtime prerequisites, write access and integration remain unverified. `not_applicable` means a locked feature has no active task. Preflight runs no command, consumes no grant, writes no artifact and issues no certificate; setup, relock and completion remain explicit actions.
|
|
197
197
|
|
|
198
|
+
### Execution window and explicit evidence journal
|
|
199
|
+
|
|
200
|
+
On a supporting connection, request `sdd_list_features` with `view="setup_diagnostics"` and an optional fixed `host`. Installed hashes, server registration and client-reported identity do not prove the host-effective catalogue. For a locked task, request `sdd_get_active_task` with `view="execution_window"`, follow its `execution_detail` cursors and `evidence_history` pages, and reread the window if a cursor is stale. These views are read-only and non-certifying.
|
|
201
|
+
|
|
202
|
+
To record an already observed attempt, first inspect the selected connection's advertised schema for `operation`, `checkpoint` and `task_id` and confirm a supporting engine version. Only then use `sdd_lock_spec(operation="evidence_checkpoint")`. Do not probe an older schema or fall back to lock or relock: unknown inputs can be stripped. The journal records only explicit observations; failures are not recorded automatically. Outcomes are caller-reported, not certification; the server captures identity and eligible digests. The checkpoint operation requires a supported native runtime with ownership and no-follow capability. Preserve uncertain guards for operator review.
|
|
203
|
+
|
|
204
|
+
Optional smoke observations never cover required gates. For receipt-enabled tasks, each required gate needs a valid matching PASS receipt; missing or partial evidence is pending, and mismatches or invalid receipts are rejected. Receipt v1 has no TTL. Even valid receipts require fresh integration; `ready_to_attempt` permits an attempt only. Obtain signed receipts from the operator-controlled issuer; neither the journal nor its observations grant time or certify completion.
|
|
205
|
+
|
|
198
206
|
### Resume a task from one compact checkpoint
|
|
199
207
|
|
|
200
208
|
```json
|
|
@@ -366,7 +374,7 @@ See the [Planu Proprietary Free-Use License](LICENSE) and [planu.dev/license](ht
|
|
|
366
374
|
"mcpServers": {
|
|
367
375
|
"planu": {
|
|
368
376
|
"command": "npx",
|
|
369
|
-
"args": ["-y", "@planu/cli@8.
|
|
377
|
+
"args": ["-y", "@planu/cli@8.6.0"],
|
|
370
378
|
"cwd": ".",
|
|
371
379
|
"env": {
|
|
372
380
|
"PLANU_WORKSPACE": "."
|
|
@@ -35,9 +35,8 @@ function isGuardRecord(value, feature) {
|
|
|
35
35
|
}
|
|
36
36
|
const record = value;
|
|
37
37
|
return (hasGuardOwner(record) &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
record.operation === 'lock') &&
|
|
38
|
+
typeof record.operation === 'string' &&
|
|
39
|
+
['complete', 'patch', 'lock', 'checkpoint'].includes(record.operation) &&
|
|
41
40
|
(record.phase === 'running' || record.phase === 'persisting') &&
|
|
42
41
|
record.featureDev === feature.dev &&
|
|
43
42
|
record.featureIno === feature.ino &&
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { EvidenceCheckpointInput } from '../types/sdd-engine.js';
|
|
2
3
|
export type { ArtifactType, FilePermission, ErrorCode, SddErrorDetails, SddSuccess, SddFailure, SddResult, InitWorkspaceInput, ListFeaturesInput, CreateFeatureInput, LockSpecInput, ReadSpecArtifactInput, ReadFileSliceInput, GetActiveTaskInput, ApplyFilePatchInput, CompleteTaskInput, ParsedManifest, ActiveTaskDetails, ActiveTaskResult, CompleteTaskResult, FeatureSummary, } from '../types/sdd-engine.js';
|
|
3
4
|
export declare const FeatureIdSchema: z.ZodString;
|
|
4
5
|
export declare const ArtifactTypeSchema: z.ZodEnum<{
|
|
@@ -43,16 +44,165 @@ export declare const ListFeaturesInputSchema: z.ZodObject<{
|
|
|
43
44
|
executing: "executing";
|
|
44
45
|
planning: "planning";
|
|
45
46
|
}>>;
|
|
47
|
+
view: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
setup_diagnostics: "setup_diagnostics";
|
|
49
|
+
}>>;
|
|
50
|
+
host: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
all: "all";
|
|
52
|
+
claude: "claude";
|
|
53
|
+
codex: "codex";
|
|
54
|
+
cursor: "cursor";
|
|
55
|
+
gemini: "gemini";
|
|
56
|
+
}>>;
|
|
46
57
|
}, z.core.$strip>;
|
|
47
58
|
export declare const CreateFeatureInputSchema: z.ZodObject<{
|
|
48
59
|
id: z.ZodOptional<z.ZodString>;
|
|
49
60
|
title: z.ZodString;
|
|
50
61
|
}, z.core.$strip>;
|
|
62
|
+
export declare const CheckpointReportedSchema: z.ZodObject<{
|
|
63
|
+
kind: z.ZodEnum<{
|
|
64
|
+
progress: "progress";
|
|
65
|
+
required_gate: "required_gate";
|
|
66
|
+
review: "review";
|
|
67
|
+
smoke: "smoke";
|
|
68
|
+
}>;
|
|
69
|
+
outcome: z.ZodEnum<{
|
|
70
|
+
blocked: "blocked";
|
|
71
|
+
fail: "fail";
|
|
72
|
+
partial: "partial";
|
|
73
|
+
pass: "pass";
|
|
74
|
+
pending: "pending";
|
|
75
|
+
skipped: "skipped";
|
|
76
|
+
}>;
|
|
77
|
+
cause: z.ZodEnum<{
|
|
78
|
+
check_failed: "check_failed";
|
|
79
|
+
check_passed: "check_passed";
|
|
80
|
+
contract_change_proposed: "contract_change_proposed";
|
|
81
|
+
environment_blocked: "environment_blocked";
|
|
82
|
+
evidence_invalidated: "evidence_invalidated";
|
|
83
|
+
implementation_checkpoint: "implementation_checkpoint";
|
|
84
|
+
required_evidence_pending: "required_evidence_pending";
|
|
85
|
+
review_failed: "review_failed";
|
|
86
|
+
review_passed: "review_passed";
|
|
87
|
+
review_requested: "review_requested";
|
|
88
|
+
}>;
|
|
89
|
+
gateId: z.ZodNullable<z.ZodString>;
|
|
90
|
+
evidenceSha256: z.ZodNullable<z.ZodString>;
|
|
91
|
+
reviewRefSha256: z.ZodNullable<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>;
|
|
51
93
|
export declare const LockSpecInputSchema: z.ZodObject<{
|
|
52
94
|
feature_id: z.ZodString;
|
|
53
95
|
relock: z.ZodOptional<z.ZodBoolean>;
|
|
54
96
|
reason: z.ZodOptional<z.ZodString>;
|
|
97
|
+
operation: z.ZodOptional<z.ZodEnum<{
|
|
98
|
+
evidence_checkpoint: "evidence_checkpoint";
|
|
99
|
+
lock: "lock";
|
|
100
|
+
}>>;
|
|
101
|
+
task_id: z.ZodOptional<z.ZodString>;
|
|
102
|
+
checkpoint: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
|
|
103
|
+
version: z.ZodLiteral<1>;
|
|
104
|
+
expectedSnapshotSha256: z.ZodString;
|
|
105
|
+
expectedJournal: z.ZodNullable<z.ZodObject<{
|
|
106
|
+
snapshotSha256: z.ZodString;
|
|
107
|
+
headSha256: z.ZodString;
|
|
108
|
+
count: z.ZodNumber;
|
|
109
|
+
}, z.core.$strict>>;
|
|
110
|
+
reported: z.ZodObject<{
|
|
111
|
+
kind: z.ZodEnum<{
|
|
112
|
+
progress: "progress";
|
|
113
|
+
required_gate: "required_gate";
|
|
114
|
+
review: "review";
|
|
115
|
+
smoke: "smoke";
|
|
116
|
+
}>;
|
|
117
|
+
outcome: z.ZodEnum<{
|
|
118
|
+
blocked: "blocked";
|
|
119
|
+
fail: "fail";
|
|
120
|
+
partial: "partial";
|
|
121
|
+
pass: "pass";
|
|
122
|
+
pending: "pending";
|
|
123
|
+
skipped: "skipped";
|
|
124
|
+
}>;
|
|
125
|
+
cause: z.ZodEnum<{
|
|
126
|
+
check_failed: "check_failed";
|
|
127
|
+
check_passed: "check_passed";
|
|
128
|
+
contract_change_proposed: "contract_change_proposed";
|
|
129
|
+
environment_blocked: "environment_blocked";
|
|
130
|
+
evidence_invalidated: "evidence_invalidated";
|
|
131
|
+
implementation_checkpoint: "implementation_checkpoint";
|
|
132
|
+
required_evidence_pending: "required_evidence_pending";
|
|
133
|
+
review_failed: "review_failed";
|
|
134
|
+
review_passed: "review_passed";
|
|
135
|
+
review_requested: "review_requested";
|
|
136
|
+
}>;
|
|
137
|
+
gateId: z.ZodNullable<z.ZodString>;
|
|
138
|
+
evidenceSha256: z.ZodNullable<z.ZodString>;
|
|
139
|
+
reviewRefSha256: z.ZodNullable<z.ZodString>;
|
|
140
|
+
}, z.core.$strict>;
|
|
141
|
+
}, z.core.$strict>, unknown>>;
|
|
55
142
|
}, z.core.$strip>;
|
|
143
|
+
export declare function parseCheckpoint(featureId: string, taskId: string, input: EvidenceCheckpointInput): EvidenceCheckpointInput | undefined;
|
|
144
|
+
export declare const CheckpointRecordSchema: z.ZodObject<{
|
|
145
|
+
version: z.ZodLiteral<1>;
|
|
146
|
+
seq: z.ZodNumber;
|
|
147
|
+
recordedAt: z.ZodString;
|
|
148
|
+
previousSha256: z.ZodNullable<z.ZodString>;
|
|
149
|
+
context: z.ZodObject<{
|
|
150
|
+
featureId: z.ZodString;
|
|
151
|
+
taskId: z.ZodString;
|
|
152
|
+
snapshotSha256: z.ZodString;
|
|
153
|
+
contract: z.ZodObject<{
|
|
154
|
+
specSha256: z.ZodString;
|
|
155
|
+
planSha256: z.ZodString;
|
|
156
|
+
tasksSha256: z.ZodString;
|
|
157
|
+
lockSha256: z.ZodString;
|
|
158
|
+
}, z.core.$strict>;
|
|
159
|
+
candidate: z.ZodNullable<z.ZodObject<{
|
|
160
|
+
workspaceSha256: z.ZodString;
|
|
161
|
+
candidateSha256: z.ZodString;
|
|
162
|
+
observedSha256: z.ZodString;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
candidateState: z.ZodEnum<{
|
|
165
|
+
captured: "captured";
|
|
166
|
+
not_configured: "not_configured";
|
|
167
|
+
unavailable: "unavailable";
|
|
168
|
+
}>;
|
|
169
|
+
}, z.core.$strict>;
|
|
170
|
+
reported: z.ZodObject<{
|
|
171
|
+
kind: z.ZodEnum<{
|
|
172
|
+
progress: "progress";
|
|
173
|
+
required_gate: "required_gate";
|
|
174
|
+
review: "review";
|
|
175
|
+
smoke: "smoke";
|
|
176
|
+
}>;
|
|
177
|
+
outcome: z.ZodEnum<{
|
|
178
|
+
blocked: "blocked";
|
|
179
|
+
fail: "fail";
|
|
180
|
+
partial: "partial";
|
|
181
|
+
pass: "pass";
|
|
182
|
+
pending: "pending";
|
|
183
|
+
skipped: "skipped";
|
|
184
|
+
}>;
|
|
185
|
+
cause: z.ZodEnum<{
|
|
186
|
+
check_failed: "check_failed";
|
|
187
|
+
check_passed: "check_passed";
|
|
188
|
+
contract_change_proposed: "contract_change_proposed";
|
|
189
|
+
environment_blocked: "environment_blocked";
|
|
190
|
+
evidence_invalidated: "evidence_invalidated";
|
|
191
|
+
implementation_checkpoint: "implementation_checkpoint";
|
|
192
|
+
required_evidence_pending: "required_evidence_pending";
|
|
193
|
+
review_failed: "review_failed";
|
|
194
|
+
review_passed: "review_passed";
|
|
195
|
+
review_requested: "review_requested";
|
|
196
|
+
}>;
|
|
197
|
+
gateId: z.ZodNullable<z.ZodString>;
|
|
198
|
+
evidenceSha256: z.ZodNullable<z.ZodString>;
|
|
199
|
+
reviewRefSha256: z.ZodNullable<z.ZodString>;
|
|
200
|
+
provenance: z.ZodLiteral<"caller_reported">;
|
|
201
|
+
certification: z.ZodLiteral<"none">;
|
|
202
|
+
}, z.core.$strict>;
|
|
203
|
+
recordSha256: z.ZodString;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
export declare function parseCheckpointJournalRecord(line: string): z.infer<typeof CheckpointRecordSchema> | undefined;
|
|
56
206
|
export declare const ReadSpecArtifactInputSchema: z.ZodObject<{
|
|
57
207
|
feature_id: z.ZodString;
|
|
58
208
|
artifact: z.ZodEnum<{
|
|
@@ -75,6 +225,9 @@ export declare const ApplyFilePatchInputSchema: z.ZodObject<{
|
|
|
75
225
|
export declare const GetActiveTaskInputSchema: z.ZodObject<{
|
|
76
226
|
feature_id: z.ZodString;
|
|
77
227
|
view: z.ZodOptional<z.ZodEnum<{
|
|
228
|
+
evidence_history: "evidence_history";
|
|
229
|
+
execution_detail: "execution_detail";
|
|
230
|
+
execution_window: "execution_window";
|
|
78
231
|
relock_history: "relock_history";
|
|
79
232
|
resume: "resume";
|
|
80
233
|
verification_preflight: "verification_preflight";
|
|
@@ -84,6 +237,24 @@ export declare const GetActiveTaskInputSchema: z.ZodObject<{
|
|
|
84
237
|
snapshotSha256: z.ZodString;
|
|
85
238
|
startIndex: z.ZodNumber;
|
|
86
239
|
}, z.core.$strip>, unknown>>;
|
|
240
|
+
execution_cursor: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
|
|
241
|
+
snapshotSha256: z.ZodString;
|
|
242
|
+
journalSnapshotSha256: z.ZodNullable<z.ZodString>;
|
|
243
|
+
section: z.ZodEnum<{
|
|
244
|
+
active_task: "active_task";
|
|
245
|
+
read_scope: "read_scope";
|
|
246
|
+
verification: "verification";
|
|
247
|
+
write_scope: "write_scope";
|
|
248
|
+
}>;
|
|
249
|
+
contentSha256: z.ZodString;
|
|
250
|
+
offset: z.ZodNumber;
|
|
251
|
+
}, z.core.$strict>, unknown>>;
|
|
252
|
+
evidence_cursor: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
|
|
253
|
+
snapshotSha256: z.ZodString;
|
|
254
|
+
journalSnapshotSha256: z.ZodString;
|
|
255
|
+
headSha256: z.ZodString;
|
|
256
|
+
startSeq: z.ZodNumber;
|
|
257
|
+
}, z.core.$strict>, unknown>>;
|
|
87
258
|
}, z.core.$strip>;
|
|
88
259
|
export declare const CompleteTaskInputSchema: z.ZodObject<{
|
|
89
260
|
feature_id: z.ZodString;
|
|
@@ -91,4 +262,5 @@ export declare const CompleteTaskInputSchema: z.ZodObject<{
|
|
|
91
262
|
verification_output: z.ZodOptional<z.ZodString>;
|
|
92
263
|
verification_receipts: z.ZodOptional<z.ZodArray<z.ZodPreprocess<z.ZodObject<{}, z.core.$loose>, unknown>>>;
|
|
93
264
|
}, z.core.$strip>;
|
|
265
|
+
export declare function isInitialCheckpointLock(content: string): boolean;
|
|
94
266
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExecutionCursorInputSchema, EvidenceCursorInputSchema } from './resume-history.js';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
export const FeatureIdSchema = z
|
|
3
4
|
.string()
|
|
@@ -28,18 +29,216 @@ export const InitWorkspaceInputSchema = z.object({
|
|
|
28
29
|
scope: z.enum(['global', 'project']),
|
|
29
30
|
force: z.boolean().optional(),
|
|
30
31
|
});
|
|
31
|
-
export const ListFeaturesInputSchema = z
|
|
32
|
+
export const ListFeaturesInputSchema = z
|
|
33
|
+
.object({
|
|
32
34
|
status_filter: z.enum(['all', 'planning', 'executing', 'done']).optional(),
|
|
35
|
+
view: z.enum(['setup_diagnostics'], { error: 'Invalid setup diagnostic view.' }).optional(),
|
|
36
|
+
host: z
|
|
37
|
+
.enum(['all', 'claude', 'cursor', 'codex', 'gemini'], {
|
|
38
|
+
error: 'Invalid setup diagnostic host.',
|
|
39
|
+
})
|
|
40
|
+
.optional(),
|
|
41
|
+
})
|
|
42
|
+
.refine((input) => input.host === undefined || input.view === 'setup_diagnostics', {
|
|
43
|
+
message: 'Host requires setup diagnostics view.',
|
|
33
44
|
});
|
|
34
45
|
export const CreateFeatureInputSchema = z.object({
|
|
35
46
|
id: FeatureIdSchema.optional(),
|
|
36
47
|
title: z.string().min(3),
|
|
37
48
|
});
|
|
38
|
-
|
|
49
|
+
const CheckpointHashSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
50
|
+
export const CheckpointReportedSchema = z.strictObject({
|
|
51
|
+
kind: z.enum(['smoke', 'required_gate', 'review', 'progress']),
|
|
52
|
+
outcome: z.enum(['pass', 'fail', 'pending', 'blocked', 'skipped', 'partial']),
|
|
53
|
+
cause: z.enum([
|
|
54
|
+
'implementation_checkpoint',
|
|
55
|
+
'check_passed',
|
|
56
|
+
'check_failed',
|
|
57
|
+
'required_evidence_pending',
|
|
58
|
+
'evidence_invalidated',
|
|
59
|
+
'environment_blocked',
|
|
60
|
+
'review_requested',
|
|
61
|
+
'review_passed',
|
|
62
|
+
'review_failed',
|
|
63
|
+
'contract_change_proposed',
|
|
64
|
+
]),
|
|
65
|
+
gateId: z
|
|
66
|
+
.string()
|
|
67
|
+
.regex(/^[a-z][a-z0-9-]{0,31}$/u)
|
|
68
|
+
.nullable(),
|
|
69
|
+
evidenceSha256: CheckpointHashSchema.nullable(),
|
|
70
|
+
reviewRefSha256: CheckpointHashSchema.nullable(),
|
|
71
|
+
});
|
|
72
|
+
function validCheckpointReported(value) {
|
|
73
|
+
const { kind, outcome, cause, gateId, evidenceSha256, reviewRefSha256 } = value;
|
|
74
|
+
if ((kind === 'required_gate') !== (gateId !== null)) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if ((kind === 'review') !== (reviewRefSha256 !== null)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (kind !== 'progress' && ['pass', 'fail', 'partial'].includes(outcome) && !evidenceSha256) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return validCheckpointCause(kind, outcome, cause);
|
|
84
|
+
}
|
|
85
|
+
function validCheckpointCause(kind, outcome, cause) {
|
|
86
|
+
switch (cause) {
|
|
87
|
+
case 'implementation_checkpoint':
|
|
88
|
+
return kind === 'progress' && ['pending', 'pass'].includes(outcome);
|
|
89
|
+
case 'contract_change_proposed':
|
|
90
|
+
return kind === 'progress' && outcome === 'pending';
|
|
91
|
+
case 'check_passed':
|
|
92
|
+
return validCheckpointCheck(kind, outcome, true);
|
|
93
|
+
case 'check_failed':
|
|
94
|
+
return validCheckpointCheck(kind, outcome, false);
|
|
95
|
+
case 'required_evidence_pending':
|
|
96
|
+
return kind === 'required_gate' && ['pending', 'blocked', 'skipped'].includes(outcome);
|
|
97
|
+
case 'evidence_invalidated':
|
|
98
|
+
return ['required_gate', 'review'].includes(kind) && ['pending', 'blocked'].includes(outcome);
|
|
99
|
+
case 'environment_blocked':
|
|
100
|
+
return outcome === 'blocked';
|
|
101
|
+
case 'review_requested':
|
|
102
|
+
case 'review_passed':
|
|
103
|
+
case 'review_failed':
|
|
104
|
+
return validCheckpointReview(kind, outcome, cause);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function validCheckpointCheck(kind, outcome, passed) {
|
|
108
|
+
return (['smoke', 'required_gate'].includes(kind) &&
|
|
109
|
+
(passed ? outcome === 'pass' : ['fail', 'partial'].includes(outcome)));
|
|
110
|
+
}
|
|
111
|
+
function validCheckpointReview(kind, outcome, cause) {
|
|
112
|
+
return (kind === 'review' &&
|
|
113
|
+
((cause === 'review_requested' && outcome === 'pending') ||
|
|
114
|
+
(cause === 'review_passed' && outcome === 'pass') ||
|
|
115
|
+
(cause === 'review_failed' && ['fail', 'partial'].includes(outcome))));
|
|
116
|
+
}
|
|
117
|
+
const CheckpointShape = z
|
|
118
|
+
.strictObject({
|
|
119
|
+
version: z.literal(1),
|
|
120
|
+
expectedSnapshotSha256: CheckpointHashSchema,
|
|
121
|
+
expectedJournal: z
|
|
122
|
+
.strictObject({
|
|
123
|
+
snapshotSha256: CheckpointHashSchema,
|
|
124
|
+
headSha256: CheckpointHashSchema,
|
|
125
|
+
count: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
126
|
+
})
|
|
127
|
+
.nullable(),
|
|
128
|
+
reported: CheckpointReportedSchema,
|
|
129
|
+
})
|
|
130
|
+
.refine((value) => validCheckpointReported(value.reported));
|
|
131
|
+
// Never let SDK schema validation reveal caller-selected metadata keys.
|
|
132
|
+
const CheckpointInputSchema = z.preprocess((input, context) => {
|
|
133
|
+
const parsed = CheckpointShape.safeParse(input);
|
|
134
|
+
if (!parsed.success) {
|
|
135
|
+
context.addIssue({
|
|
136
|
+
code: 'custom',
|
|
137
|
+
message: 'Invalid checkpoint metadata.',
|
|
138
|
+
});
|
|
139
|
+
return z.NEVER;
|
|
140
|
+
}
|
|
141
|
+
return parsed.data;
|
|
142
|
+
}, CheckpointShape);
|
|
143
|
+
const identity = z.string().regex(/^[A-Z0-9_-]{1,128}$/u);
|
|
144
|
+
export const LockSpecInputSchema = z
|
|
145
|
+
.object({
|
|
39
146
|
feature_id: FeatureIdSchema,
|
|
40
147
|
relock: z.boolean().optional(),
|
|
41
148
|
reason: z.string().optional(),
|
|
149
|
+
operation: z.enum(['lock', 'evidence_checkpoint']).optional(),
|
|
150
|
+
task_id: identity.optional(),
|
|
151
|
+
checkpoint: CheckpointInputSchema.optional(),
|
|
152
|
+
})
|
|
153
|
+
.superRefine((input, context) => {
|
|
154
|
+
const isCheckpoint = input.operation === 'evidence_checkpoint';
|
|
155
|
+
if (isCheckpoint
|
|
156
|
+
? input.feature_id.length > 128 ||
|
|
157
|
+
input.task_id === undefined ||
|
|
158
|
+
input.checkpoint === undefined ||
|
|
159
|
+
input.relock !== undefined ||
|
|
160
|
+
input.reason !== undefined
|
|
161
|
+
: input.task_id !== undefined || input.checkpoint !== undefined) {
|
|
162
|
+
context.addIssue({
|
|
163
|
+
code: 'custom',
|
|
164
|
+
message: 'Invalid checkpoint operation.',
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
export function parseCheckpoint(featureId, taskId, input) {
|
|
169
|
+
const parsed = LockSpecInputSchema.safeParse({
|
|
170
|
+
feature_id: featureId,
|
|
171
|
+
operation: 'evidence_checkpoint',
|
|
172
|
+
task_id: taskId,
|
|
173
|
+
checkpoint: input,
|
|
174
|
+
});
|
|
175
|
+
return parsed.success ? parsed.data.checkpoint : undefined;
|
|
176
|
+
}
|
|
177
|
+
const contract = z.strictObject({
|
|
178
|
+
specSha256: CheckpointHashSchema,
|
|
179
|
+
planSha256: CheckpointHashSchema,
|
|
180
|
+
tasksSha256: CheckpointHashSchema,
|
|
181
|
+
lockSha256: CheckpointHashSchema,
|
|
42
182
|
});
|
|
183
|
+
const candidate = z.strictObject({
|
|
184
|
+
workspaceSha256: CheckpointHashSchema,
|
|
185
|
+
candidateSha256: CheckpointHashSchema,
|
|
186
|
+
observedSha256: CheckpointHashSchema,
|
|
187
|
+
});
|
|
188
|
+
const report = CheckpointReportedSchema.extend({
|
|
189
|
+
provenance: z.literal('caller_reported'),
|
|
190
|
+
certification: z.literal('none'),
|
|
191
|
+
});
|
|
192
|
+
export const CheckpointRecordSchema = z.strictObject({
|
|
193
|
+
version: z.literal(1),
|
|
194
|
+
seq: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
195
|
+
recordedAt: z.string(),
|
|
196
|
+
previousSha256: CheckpointHashSchema.nullable(),
|
|
197
|
+
context: z.strictObject({
|
|
198
|
+
featureId: identity,
|
|
199
|
+
taskId: identity,
|
|
200
|
+
snapshotSha256: CheckpointHashSchema,
|
|
201
|
+
contract,
|
|
202
|
+
candidate: candidate.nullable(),
|
|
203
|
+
candidateState: z.enum(['captured', 'not_configured', 'unavailable']),
|
|
204
|
+
}),
|
|
205
|
+
reported: report,
|
|
206
|
+
recordSha256: CheckpointHashSchema,
|
|
207
|
+
});
|
|
208
|
+
export function parseCheckpointJournalRecord(line) {
|
|
209
|
+
let json;
|
|
210
|
+
try {
|
|
211
|
+
json = JSON.parse(line);
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
const parsed = CheckpointRecordSchema.safeParse(json);
|
|
217
|
+
if (!parsed.success) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
const value = parsed.data;
|
|
221
|
+
const { provenance: _provenance, certification: _certification, ...reported } = value.reported;
|
|
222
|
+
const input = {
|
|
223
|
+
feature_id: value.context.featureId,
|
|
224
|
+
operation: 'evidence_checkpoint',
|
|
225
|
+
task_id: value.context.taskId,
|
|
226
|
+
checkpoint: {
|
|
227
|
+
version: 1,
|
|
228
|
+
expectedSnapshotSha256: value.context.snapshotSha256,
|
|
229
|
+
expectedJournal: null,
|
|
230
|
+
reported,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const when = new Date(value.recordedAt);
|
|
234
|
+
if (!LockSpecInputSchema.safeParse(input).success ||
|
|
235
|
+
Number.isNaN(when.valueOf()) ||
|
|
236
|
+
when.toISOString() !== value.recordedAt ||
|
|
237
|
+
(value.context.candidateState === 'captured') !== (value.context.candidate !== null)) {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
return value;
|
|
241
|
+
}
|
|
43
242
|
export const ReadSpecArtifactInputSchema = z.object({
|
|
44
243
|
feature_id: FeatureIdSchema,
|
|
45
244
|
artifact: ArtifactTypeSchema,
|
|
@@ -85,23 +284,36 @@ export const GetActiveTaskInputSchema = z
|
|
|
85
284
|
.object({
|
|
86
285
|
feature_id: FeatureIdSchema,
|
|
87
286
|
view: z
|
|
88
|
-
.enum([
|
|
287
|
+
.enum([
|
|
288
|
+
'verification_preflight',
|
|
289
|
+
'resume',
|
|
290
|
+
'relock_history',
|
|
291
|
+
'execution_window',
|
|
292
|
+
'execution_detail',
|
|
293
|
+
'evidence_history',
|
|
294
|
+
], {
|
|
89
295
|
error: 'Invalid active task view.',
|
|
90
296
|
})
|
|
91
297
|
.optional(),
|
|
92
298
|
verification_receipts: VerificationReceiptsInputSchema,
|
|
93
299
|
history_cursor: HistoryCursorInputSchema.optional(),
|
|
300
|
+
execution_cursor: ExecutionCursorInputSchema.optional(),
|
|
301
|
+
evidence_cursor: EvidenceCursorInputSchema.optional(),
|
|
94
302
|
})
|
|
95
303
|
.superRefine((input, context) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
304
|
+
const cursors = [
|
|
305
|
+
['execution_cursor', 'execution_detail', 'Invalid execution cursor view.'],
|
|
306
|
+
['evidence_cursor', 'evidence_history', 'Invalid evidence cursor view.'],
|
|
307
|
+
['history_cursor', 'relock_history', 'History cursor requires the history view.'],
|
|
308
|
+
];
|
|
309
|
+
for (const [field, view, message] of cursors) {
|
|
310
|
+
if (input[field] !== undefined && input.view !== view) {
|
|
311
|
+
context.addIssue({ code: 'custom', message, path: [field] });
|
|
312
|
+
}
|
|
102
313
|
}
|
|
103
314
|
if (input.verification_receipts !== undefined &&
|
|
104
|
-
!['verification_preflight', 'resume'].includes(input.view ?? '')
|
|
315
|
+
!['verification_preflight', 'resume', 'execution_window'].includes(input.view ?? '') &&
|
|
316
|
+
!(input.view === 'execution_detail' && input.execution_cursor?.section === 'verification')) {
|
|
105
317
|
context.addIssue({
|
|
106
318
|
code: 'custom',
|
|
107
319
|
message: 'Verification receipts require the verification_preflight view.',
|
|
@@ -115,4 +327,17 @@ export const CompleteTaskInputSchema = z.object({
|
|
|
115
327
|
verification_output: z.string().min(1).optional(),
|
|
116
328
|
verification_receipts: VerificationReceiptsInputSchema,
|
|
117
329
|
});
|
|
330
|
+
const InitialCheckpointLockSchema = z.looseObject({
|
|
331
|
+
specHash: CheckpointHashSchema,
|
|
332
|
+
planHash: CheckpointHashSchema,
|
|
333
|
+
tasksHash: CheckpointHashSchema,
|
|
334
|
+
});
|
|
335
|
+
export function isInitialCheckpointLock(content) {
|
|
336
|
+
try {
|
|
337
|
+
return InitialCheckpointLockSchema.safeParse(JSON.parse(content)).success;
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
118
343
|
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CheckpointCapability } from '../types/completion.js';
|
|
2
|
+
import type { EvidenceCheckpointInput, EvidenceCheckpointResult, SddResult } from '../types/sdd-engine.js';
|
|
3
|
+
export declare function appendEvidenceCheckpoint(featureId: string, taskId: string, input: EvidenceCheckpointInput, workspaceRoot: string, featDir: string, capability: CheckpointCapability, signal?: AbortSignal): Promise<SddResult<{
|
|
4
|
+
checkpoint: EvidenceCheckpointResult;
|
|
5
|
+
}>>;
|
|
6
|
+
//# sourceMappingURL=evidence-checkpoints.d.ts.map
|