@planu/cli 8.2.20 → 8.4.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 +118 -3
- package/dist/sdd-engine/completion-snapshot.d.ts +5 -1
- package/dist/sdd-engine/completion-snapshot.js +79 -2
- package/dist/sdd-engine/contracts.d.ts +6 -3
- package/dist/sdd-engine/contracts.js +30 -3
- package/dist/sdd-engine/feature-authority.d.ts +3 -1
- package/dist/sdd-engine/feature-authority.js +33 -1
- package/dist/sdd-engine/feature-manifest.d.ts +4 -5
- package/dist/sdd-engine/feature-manifest.js +206 -93
- package/dist/sdd-engine/host-rule-pack.d.ts +5 -0
- package/dist/sdd-engine/host-rule-pack.js +103 -43
- package/dist/sdd-engine/host-skill-reader.d.ts +6 -0
- package/dist/sdd-engine/host-skill-reader.js +187 -0
- package/dist/sdd-engine/lock-integrity.d.ts +3 -2
- package/dist/sdd-engine/lock-integrity.js +30 -18
- package/dist/sdd-engine/receipt-assessment.d.ts +12 -0
- package/dist/sdd-engine/receipt-assessment.js +223 -0
- package/dist/sdd-engine/server.js +2 -4
- package/dist/sdd-engine/task-content.d.ts +19 -1
- package/dist/sdd-engine/task-content.js +128 -3
- package/dist/sdd-engine/task-failures.d.ts +2 -0
- package/dist/sdd-engine/task-failures.js +34 -0
- package/dist/sdd-engine/task-window.d.ts +3 -4
- package/dist/sdd-engine/task-window.js +49 -79
- package/dist/sdd-engine/tools/execution-tools.d.ts +1 -11
- package/dist/sdd-engine/tools/execution-tools.js +86 -57
- package/dist/sdd-engine/tools/workspace-tools.d.ts +1 -1
- package/dist/sdd-engine/tools/workspace-tools.js +17 -9
- package/dist/sdd-engine/tools.d.ts +2 -1
- package/dist/sdd-engine/tools.js +4 -2
- package/dist/sdd-engine/trinity-structure.d.ts +25 -0
- package/dist/sdd-engine/trinity-structure.js +317 -0
- package/dist/sdd-engine/verification-inputs.d.ts +12 -0
- package/dist/sdd-engine/verification-inputs.js +302 -0
- package/dist/sdd-engine/verification-preflight.d.ts +4 -0
- package/dist/sdd-engine/verification-preflight.js +271 -0
- package/dist/sdd-engine/verification-receipts.d.ts +16 -0
- package/dist/sdd-engine/verification-receipts.js +98 -0
- package/dist/sdd-engine/workspace-root.d.ts +1 -0
- package/dist/sdd-engine/workspace-root.js +1 -0
- package/dist/types/completion.d.ts +9 -2
- package/dist/types/sdd-engine.d.ts +203 -0
- package/package.json +1 -1
- package/templates/AGENTS.md +9 -1
- package/templates/host/planu-sdd.md +9 -0
- package/templates/skills/spec-architect.md +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [8.4.0] - 2026-11-07
|
|
2
|
+
|
|
3
|
+
- Diagnose installed host roles through `sdd_list_features`: fixed paths, concrete causes, bundled reference version and safe next action. The host catalogue remains unverified.
|
|
4
|
+
- Add artifact, stable rule and exact 1-based source locations to trinity rejection issues where a location exists, preserving rejection codes, legacy details and lock bytes on rejection.
|
|
5
|
+
- Add the explicit `verification_preflight` view to `sdd_get_active_task`, with optional signed receipts, per-gate evidence states, blockers and next action. It runs no command, writes no artifact and keeps integration `not_run`; readiness permits an attempt, not a runtime or integration claim.
|
|
6
|
+
- Preserve the nine tools, ordinary active-task response, dependencies and verification authority. Synchronize shipped guidance and EN/ES/PT website facts.
|
|
7
|
+
|
|
8
|
+
## [8.3.0] - 2026-11-06
|
|
9
|
+
|
|
10
|
+
- Opted-in tasks can require reusable Ed25519 receipts for locally verified gates. Planu binds the evidence to the active task, workspace, lock, candidate files, and reviewed dependencies before running the integration command.
|
|
11
|
+
- A changed observed input requires restoring the baseline or a reviewed relock. The File Manifest remains the authority for patches.
|
|
12
|
+
|
|
1
13
|
## [8.2.20] - 2026-10-26
|
|
2
14
|
|
|
3
15
|
- refresh the development and runtime resolution within existing ranges: @modelcontextprotocol/sdk 1.32.2, vite 8.3.5, knip 6.43.0 and tsc-alias 1.9.9
|
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ After the one-time client registration above, ask your agent:
|
|
|
112
112
|
|
|
113
113
|
> Set up Planu in this project and tell me the next step.
|
|
114
114
|
|
|
115
|
-
The guided route starts with `sdd_list_features`.
|
|
115
|
+
The guided route starts with `sdd_list_features`. Inspect `hostSkills` for installed role issues. When project setup is authorized and the installed pack needs repair, use `sdd_init_workspace(scope=project)` without `force` for the identified project. The setup request already supplies that project's setup intent; `catalog: "unverified"` alone does not establish a file problem or authorize setup. Keep the MCP server bound to the project through roots or cwd, rather than `$HOME`.
|
|
116
116
|
|
|
117
117
|
Immediately after init, use the canonical `sdd_read_file_slice` tool to read `.agents/skills/planu-preflight-guardian/SKILL.md` and the installed role for the next action, such as `.agents/skills/planu-spec-architect/SKILL.md` for planning. Init installs role files; native discovery in the client's skill catalog may require a client reload or a new session. That catalog reload is separate from restarting MCP. The instructions guide an agent; the server cannot guarantee that a host has loaded a role or that a model follows it.
|
|
118
118
|
|
|
@@ -132,10 +132,125 @@ 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
|
-
There is no timeout tool argument. The nine
|
|
135
|
+
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
136
|
|
|
137
137
|
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
138
|
|
|
139
|
+
## Read-only diagnostics
|
|
140
|
+
|
|
141
|
+
The existing nine tools expose additive diagnostics in 8.4.0; an ordinary `sdd_get_active_task` request keeps its previous response shape.
|
|
142
|
+
|
|
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
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"version": 1,
|
|
148
|
+
"bundledVersion": "8.4.0",
|
|
149
|
+
"baseline": "available",
|
|
150
|
+
"catalog": "unverified",
|
|
151
|
+
"issues": [{
|
|
152
|
+
"path": ".agents/skills/planu-spec-executor/SKILL.md",
|
|
153
|
+
"status": "missing",
|
|
154
|
+
"cause": "not_found"
|
|
155
|
+
}],
|
|
156
|
+
"nextAction": "review_project_setup"
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Issues use the fixed workspace-relative paths of the nine roles across four hosts and concrete causes such as `content_mismatch`, `access_denied` or `unsafe_path`. `bundledVersion` identifies the shipped reference, not the installed role or client. An unavailable reference reports `baseline: "unavailable"` and `inspect_installation` rather than inferring project mismatches. Inspect unsafe paths before setup; use the explicit project setup route for repair only when authorized. A matching pack still leaves `catalog: "unverified"`; client catalogue reload and MCP restart remain separate actions.
|
|
161
|
+
|
|
162
|
+
`sdd_lock_spec` keeps existing rejection codes and legacy details, adding bounded `error.details.issues`. For a protected manifest declaration on the fifth source line, the diagnostic includes:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"artifact": "plan.md",
|
|
167
|
+
"rule": "protected_write",
|
|
168
|
+
"line": 5
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
That structural rejection keeps `ERR_TRINITY_INCOMPLETE`. Lines are 1-based original source locations. Missing sections and ambiguous cross-declaration failures omit `line`; errors do not echo the manifest path or source text. A rejected initial lock or relock writes no lock. Diagnostics do not authorize automatic relocking.
|
|
173
|
+
|
|
174
|
+
Request preflight explicitly through `sdd_get_active_task`:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{"feature_id":"FEAT-EXAMPLE","view":"verification_preflight"}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Optionally supply `verification_receipts` with the signed receipt array described below. Receipts require this view. For an opted-in task with one required gate named `contents`, no supplied receipts and otherwise available inputs, `data.verificationPreflight` is:
|
|
181
|
+
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"version": 1,
|
|
185
|
+
"taskId": "TASK-1",
|
|
186
|
+
"status": "blocked",
|
|
187
|
+
"gates": [{"gateId":"contents","state":"receipt_missing","reason":"receipt_missing"}],
|
|
188
|
+
"blockers": [],
|
|
189
|
+
"integration": "not_run",
|
|
190
|
+
"nextAction": "obtain_receipts"
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Check `version: 1` on the requested response: an older server may ignore optional arguments. Inspect both per-gate states and aggregate blockers. Preflight can identify rejected evidence, unavailable inputs, changed observed baselines, missing commands, unsupported platforms or matching scoped receipt grants, and lock/guard problems. Follow `nextAction`; a changed observed baseline requires restoring the input or the existing reviewed relock route. An ordinary task rejects supplied receipts with `receipt_not_configured`.
|
|
195
|
+
|
|
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
|
+
|
|
198
|
+
## Reusable verification receipts
|
|
199
|
+
|
|
200
|
+
Opt in by adding a level-two `Verification Receipts v1` heading to the locked plan, followed by a single JSON fence with the policy formatted using `JSON.stringify(policy, null, 2)`. It contains:
|
|
201
|
+
|
|
202
|
+
- `publicKey`, the operator's Ed25519 SPKI public key in canonical unpadded base64url.
|
|
203
|
+
- `tasks`, the opted-in entries with `taskId`, `gates`, `observed`, and `observedBaselineSha256`. Each gate has an `id`, `procedureSha256`, and `environmentSha256`.
|
|
204
|
+
- `candidateCreates`, with one `{ path, requiredFromTaskId }` for each exact `CREATE` path. The due task is identified by its explicit ID and its position in the task list.
|
|
205
|
+
|
|
206
|
+
Use exactly one literal `Verification (receipts v1):` command on each opted-in task. Use exact `CREATE` and `MODIFY` paths for candidate inputs. Observed files are separate and carry no write authority. A future create is hashed as absent until it exists, and must exist at its due task. Keep an ordinary `Verification:` task for a later integration step if the feature requires one.
|
|
207
|
+
|
|
208
|
+
For observed baseline and candidate digests, sort exact relative paths in ASCII order. Use the SHA-256 of the UTF-8 compact JSON `["planu.verification-inputs.v1", category, entries]`. A present entry is `[path, "present", mode & 0o7777, sha256(rawBytes)]`. A future create that is absent before its due task is `[path, "absent"]`. An empty observed list has the digest of `["planu.verification-inputs.v1","observed",[]]`.
|
|
209
|
+
|
|
210
|
+
Read `verificationEvidence` from `sdd_get_active_task` after sealing. A trusted issuer measures the inputs, runs the reviewed checks against that challenge, and compares the inputs again before signing. It attests the exact procedure, measured immutable environment, outcome, and digest of complete evidence. Keep the signing key outside the workspace, Planu process, integration command, and agents. Only use receipts for checks whose inputs and environment are stable across attempts. Live checks belong in the fresh integration command.
|
|
211
|
+
|
|
212
|
+
This offline Node.js example signs one gate in a disposable fixture with one exact candidate named `candidate.txt`, no observed files, and no future creates. Run the issuer separately with its own key file and the challenge saved to an operator-controlled file. Pin the digests of the example procedure and environment shown below when preparing the fixture policy.
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
import { createHash, createPrivateKey, sign } from 'node:crypto';
|
|
216
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
217
|
+
|
|
218
|
+
const [keyPath, challengePath] = process.argv.slice(2);
|
|
219
|
+
const key = createPrivateKey(readFileSync(keyPath));
|
|
220
|
+
const { gates, ...challenge } = JSON.parse(readFileSync(challengePath, 'utf8'));
|
|
221
|
+
const gate = gates.find(({ id }) => id === 'contents');
|
|
222
|
+
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
223
|
+
const hashJson = (value) => sha(JSON.stringify(value));
|
|
224
|
+
const procedure = 'Read candidate.txt and require exactly hello followed by LF';
|
|
225
|
+
const environment = JSON.stringify([process.platform, process.arch, process.version, 'fixture-v1']);
|
|
226
|
+
const snapshot = () => {
|
|
227
|
+
const bytes = readFileSync('candidate.txt');
|
|
228
|
+
const mode = statSync('candidate.txt').mode & 0o7777;
|
|
229
|
+
return { bytes, digest: hashJson(['planu.verification-inputs.v1', 'candidate',
|
|
230
|
+
[['candidate.txt', 'present', mode, sha(bytes)]]]) };
|
|
231
|
+
};
|
|
232
|
+
const before = snapshot();
|
|
233
|
+
if (before.digest !== challenge.candidateSha256 ||
|
|
234
|
+
hashJson(['planu.verification-inputs.v1', 'observed', []]) !== challenge.observedSha256 ||
|
|
235
|
+
sha(procedure) !== gate?.procedureSha256 || sha(environment) !== gate.environmentSha256 ||
|
|
236
|
+
!before.bytes.equals(Buffer.from('hello\n')) || snapshot().digest !== before.digest) {
|
|
237
|
+
throw new Error('The fixture check or reviewed challenge did not match');
|
|
238
|
+
}
|
|
239
|
+
const outcome = 'pass';
|
|
240
|
+
const evidenceSha256 = hashJson({ procedure, environment, outcome, candidate: before.digest });
|
|
241
|
+
const message = ['planu.verification-receipt.v1', challenge.featureId, challenge.taskId,
|
|
242
|
+
challenge.workspaceSha256, challenge.lockSha256, challenge.candidateSha256,
|
|
243
|
+
challenge.observedSha256, gate.id, gate.procedureSha256, gate.environmentSha256,
|
|
244
|
+
outcome, evidenceSha256];
|
|
245
|
+
const signature = sign(null, Buffer.from(JSON.stringify(message)), key).toString('base64url');
|
|
246
|
+
console.log(JSON.stringify({ ...challenge, gateId: gate.id, procedureSha256: gate.procedureSha256,
|
|
247
|
+
environmentSha256: gate.environmentSha256, outcome, evidenceSha256, signature }));
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Supply exactly one matching receipt per gate through `verification_receipts` on `sdd_complete_task`. Planu verifies the set and reruns the integration command. A failed command leaves the task open. Retry with the same receipts only while the challenge matches. Advancing or resealing the task changes the lock and requires a fresh challenge. If an observed dependency changes, restore the locked baseline or review and record a new baseline using a relock with reason, then obtain fresh receipts. The completion record stores the accepted set digest rather than the receipts or issuer logs.
|
|
251
|
+
|
|
252
|
+
A matching scoped time grant cannot run an opted-in receipt task in this version. Older Planu versions cannot complete these tasks because the receipt directive has no legacy Verification line. To return a pending task to ordinary verification, use a reviewed relock and run all required checks in the ordinary command.
|
|
253
|
+
|
|
139
254
|
## The SDD Lifecycle (v8)
|
|
140
255
|
|
|
141
256
|
```text
|
|
@@ -214,7 +329,7 @@ See the [Planu Proprietary Free-Use License](LICENSE) and [planu.dev/license](ht
|
|
|
214
329
|
"mcpServers": {
|
|
215
330
|
"planu": {
|
|
216
331
|
"command": "npx",
|
|
217
|
-
"args": ["-y", "@planu/cli@8.
|
|
332
|
+
"args": ["-y", "@planu/cli@8.4.0"],
|
|
218
333
|
"cwd": ".",
|
|
219
334
|
"env": {
|
|
220
335
|
"PLANU_WORKSPACE": "."
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ScopedVerificationSnapshot } from '../types/verification.js';
|
|
2
|
+
import type { CompleteTaskResult, SddResult } from '../types/sdd-engine.js';
|
|
1
3
|
import type { CompletionSnapshot, CompletionSnapshotOptions } from '../types/completion.js';
|
|
2
4
|
import { type CompletionLease } from './completion-guard.js';
|
|
3
5
|
/** Catalogue reads need task status and lock presence, not an execution readiness card. */
|
|
@@ -7,5 +9,7 @@ export declare function readCatalogueArtifacts(featDir: string): Promise<{
|
|
|
7
9
|
}>;
|
|
8
10
|
export declare function captureCompletionSnapshot(requestedFeatDir: string, options?: CompletionSnapshotOptions): Promise<CompletionSnapshot>;
|
|
9
11
|
export declare function revalidateCompletionSnapshot(snapshot: CompletionSnapshot): Promise<void>;
|
|
10
|
-
export declare function
|
|
12
|
+
export declare function commitOwnedScopedTask(taskId: string, scopedSnapshot: ScopedVerificationSnapshot, output: string, signal: AbortSignal, snapshot: CompletionSnapshot, lease: CompletionLease, persist: (written: string) => Promise<SddResult<null>>): Promise<SddResult<CompleteTaskResult>>;
|
|
13
|
+
export declare function commitOrdinaryTask(snapshot: CompletionSnapshot, lease: CompletionLease, taskId: string, output: string, signal: AbortSignal): Promise<SddResult<CompleteTaskResult>>;
|
|
14
|
+
export declare function persistCompletionSnapshot(lease: CompletionLease, snapshot: CompletionSnapshot, writtenTasks: string, signal?: AbortSignal, checkEvidence?: () => Promise<void>): Promise<void>;
|
|
11
15
|
//# sourceMappingURL=completion-snapshot.d.ts.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs/promises';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
|
+
import { activeTaskFromContent, markTaskVerified, remainingTaskCount, summarizeEvidence, } from './task-content.js';
|
|
4
|
+
import { completionFailure, taskOutOfSequence } from './task-failures.js';
|
|
3
5
|
import { CompletionGuardError, captureDirectories, lastAuthorityDirectory, checkWritable, guardFailure, hashArtifact, readArtifact, revalidateDirectories, rewriteArtifact, sameIdentity, } from './feature-authority.js';
|
|
4
6
|
import { assertCatalogueAvailable } from './completion-guard.js';
|
|
5
7
|
/** Catalogue reads need task status and lock presence, not an execution readiness card. */
|
|
@@ -75,7 +77,82 @@ export async function revalidateCompletionSnapshot(snapshot) {
|
|
|
75
77
|
guardFailure('contract_drift', 'Authoritative completion snapshot changed after selection.');
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
|
-
|
|
80
|
+
async function commitScopedTask(taskId, snapshot, output, persist) {
|
|
81
|
+
const summary = summarizeEvidence(output);
|
|
82
|
+
const marked = markTaskVerified(snapshot.tasksContent.split('\n'), taskId, summary);
|
|
83
|
+
if (marked === null) {
|
|
84
|
+
return taskOutOfSequence(taskId, null);
|
|
85
|
+
}
|
|
86
|
+
const written = marked.join('\n');
|
|
87
|
+
const persisted = await persist(written);
|
|
88
|
+
if (!persisted.success) {
|
|
89
|
+
return persisted;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
success: true,
|
|
93
|
+
data: {
|
|
94
|
+
completedTaskId: taskId,
|
|
95
|
+
verificationSummary: summary,
|
|
96
|
+
remainingTasks: remainingTaskCount(activeTaskFromContent(written, () => null)),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export async function commitOwnedScopedTask(taskId, scopedSnapshot, output, signal, snapshot, lease, persist) {
|
|
101
|
+
await revalidateCompletionSnapshot(snapshot);
|
|
102
|
+
if (signal.aborted) {
|
|
103
|
+
return completionFailure('cancelled');
|
|
104
|
+
}
|
|
105
|
+
await lease.beginPersistence();
|
|
106
|
+
try {
|
|
107
|
+
const outcome = await commitScopedTask(taskId, scopedSnapshot, output, persist);
|
|
108
|
+
if (outcome.success) {
|
|
109
|
+
lease.notePersistenceWrite();
|
|
110
|
+
}
|
|
111
|
+
if (isAborted(signal) ||
|
|
112
|
+
(!outcome.success && outcome.error.details?.completionState === 'uncertain')) {
|
|
113
|
+
lease.retain();
|
|
114
|
+
}
|
|
115
|
+
return outcome;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
lease.retain();
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export async function commitOrdinaryTask(snapshot, lease, taskId, output, signal) {
|
|
123
|
+
await revalidateCompletionSnapshot(snapshot);
|
|
124
|
+
if (signal.aborted) {
|
|
125
|
+
return completionFailure('cancelled');
|
|
126
|
+
}
|
|
127
|
+
const summary = summarizeEvidence(output);
|
|
128
|
+
const marked = markTaskVerified(snapshot.tasksContent.split('\n'), taskId, summary);
|
|
129
|
+
if (marked === null) {
|
|
130
|
+
return taskOutOfSequence(taskId, null, true);
|
|
131
|
+
}
|
|
132
|
+
const written = marked.join('\n');
|
|
133
|
+
await persistCompletionSnapshot(lease, snapshot, written, signal);
|
|
134
|
+
const next = activeTaskFromContent(written, () => null);
|
|
135
|
+
return {
|
|
136
|
+
success: true,
|
|
137
|
+
data: {
|
|
138
|
+
completedTaskId: taskId,
|
|
139
|
+
verificationSummary: summary,
|
|
140
|
+
remainingTasks: remainingTaskCount(next),
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function isAborted(signal) {
|
|
145
|
+
return signal.aborted;
|
|
146
|
+
}
|
|
147
|
+
function prepareEvidenceWrite(snapshot, checkEvidence) {
|
|
148
|
+
return checkEvidence
|
|
149
|
+
? async () => {
|
|
150
|
+
await checkEvidence();
|
|
151
|
+
await revalidateCompletionSnapshot(snapshot);
|
|
152
|
+
}
|
|
153
|
+
: undefined;
|
|
154
|
+
}
|
|
155
|
+
export async function persistCompletionSnapshot(lease, snapshot, writtenTasks, signal, checkEvidence) {
|
|
79
156
|
if (signal?.aborted) {
|
|
80
157
|
guardFailure('cancelled', 'Completion was cancelled before persistence.');
|
|
81
158
|
}
|
|
@@ -93,7 +170,7 @@ export async function persistCompletionSnapshot(lease, snapshot, writtenTasks, s
|
|
|
93
170
|
// The following syscall can write a prefix even when it rejects.
|
|
94
171
|
persistence.writeStarted = true;
|
|
95
172
|
lease.notePersistenceWrite();
|
|
96
|
-
});
|
|
173
|
+
}, prepareEvidenceWrite(snapshot, checkEvidence));
|
|
97
174
|
const writtenLock = JSON.stringify({ ...snapshot.lock, tasksHash: hashArtifact(writtenTasks) }, null, 2);
|
|
98
175
|
await revalidatePersistedContract(snapshot);
|
|
99
176
|
await rewriteArtifact(snapshot.featDir, '.lock', snapshot.artifacts['.lock'], writtenLock);
|
|
@@ -66,18 +66,21 @@ export declare const ReadFileSliceInputSchema: z.ZodObject<{
|
|
|
66
66
|
start_line: z.ZodNumber;
|
|
67
67
|
end_line: z.ZodNumber;
|
|
68
68
|
}, z.core.$strip>;
|
|
69
|
-
export declare const GetActiveTaskInputSchema: z.ZodObject<{
|
|
70
|
-
feature_id: z.ZodString;
|
|
71
|
-
}, z.core.$strip>;
|
|
72
69
|
export declare const ApplyFilePatchInputSchema: z.ZodObject<{
|
|
73
70
|
feature_id: z.ZodString;
|
|
74
71
|
path: z.ZodString;
|
|
75
72
|
search_content: z.ZodString;
|
|
76
73
|
replace_content: z.ZodString;
|
|
77
74
|
}, z.core.$strip>;
|
|
75
|
+
export declare const GetActiveTaskInputSchema: z.ZodObject<{
|
|
76
|
+
feature_id: z.ZodString;
|
|
77
|
+
view: z.ZodOptional<z.ZodLiteral<"verification_preflight">>;
|
|
78
|
+
verification_receipts: z.ZodOptional<z.ZodArray<z.ZodPreprocess<z.ZodObject<{}, z.core.$loose>, unknown>>>;
|
|
79
|
+
}, z.core.$strip>;
|
|
78
80
|
export declare const CompleteTaskInputSchema: z.ZodObject<{
|
|
79
81
|
feature_id: z.ZodString;
|
|
80
82
|
task_id: z.ZodString;
|
|
81
83
|
verification_output: z.ZodOptional<z.ZodString>;
|
|
84
|
+
verification_receipts: z.ZodOptional<z.ZodArray<z.ZodPreprocess<z.ZodObject<{}, z.core.$loose>, unknown>>>;
|
|
82
85
|
}, z.core.$strip>;
|
|
83
86
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -49,18 +49,45 @@ export const ReadFileSliceInputSchema = z.object({
|
|
|
49
49
|
start_line: z.number().int().min(1),
|
|
50
50
|
end_line: z.number().int().min(1),
|
|
51
51
|
});
|
|
52
|
-
export const GetActiveTaskInputSchema = z.object({
|
|
53
|
-
feature_id: FeatureIdSchema,
|
|
54
|
-
});
|
|
55
52
|
export const ApplyFilePatchInputSchema = z.object({
|
|
56
53
|
feature_id: FeatureIdSchema,
|
|
57
54
|
path: z.string().min(1),
|
|
58
55
|
search_content: z.string(),
|
|
59
56
|
replace_content: z.string(),
|
|
60
57
|
});
|
|
58
|
+
const VerificationReceiptInputSchema = z.preprocess((input, context) => {
|
|
59
|
+
if (typeof input === 'object' && input !== null && Object.hasOwn(input, '__proto__')) {
|
|
60
|
+
context.addIssue({ code: 'custom', message: 'Invalid verification receipt element.' });
|
|
61
|
+
return z.NEVER;
|
|
62
|
+
}
|
|
63
|
+
return input;
|
|
64
|
+
}, z.looseObject({}, { error: 'Invalid verification receipt element.' }));
|
|
65
|
+
const VerificationReceiptsInputSchema = z
|
|
66
|
+
.array(VerificationReceiptInputSchema, {
|
|
67
|
+
error: 'Invalid verification receipt array.',
|
|
68
|
+
})
|
|
69
|
+
.min(1, { error: 'Invalid verification receipt array length.' })
|
|
70
|
+
.max(32, { error: 'Invalid verification receipt array length.' })
|
|
71
|
+
.optional();
|
|
72
|
+
export const GetActiveTaskInputSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
feature_id: FeatureIdSchema,
|
|
75
|
+
view: z.literal('verification_preflight', { error: 'Invalid active task view.' }).optional(),
|
|
76
|
+
verification_receipts: VerificationReceiptsInputSchema,
|
|
77
|
+
})
|
|
78
|
+
.superRefine((input, context) => {
|
|
79
|
+
if (input.verification_receipts !== undefined && input.view !== 'verification_preflight') {
|
|
80
|
+
context.addIssue({
|
|
81
|
+
code: 'custom',
|
|
82
|
+
message: 'Verification receipts require the verification_preflight view.',
|
|
83
|
+
path: ['verification_receipts'],
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
61
87
|
export const CompleteTaskInputSchema = z.object({
|
|
62
88
|
feature_id: FeatureIdSchema,
|
|
63
89
|
task_id: z.string().min(1),
|
|
64
90
|
verification_output: z.string().min(1).optional(),
|
|
91
|
+
verification_receipts: VerificationReceiptsInputSchema,
|
|
65
92
|
});
|
|
66
93
|
//# sourceMappingURL=contracts.js.map
|
|
@@ -14,7 +14,9 @@ export declare function captureDirectories(featDir: string, workspaceRoot?: stri
|
|
|
14
14
|
export declare function revalidateDirectories(directories: AuthorityDirectory[]): Promise<void>;
|
|
15
15
|
export declare function readArtifact(featDir: string, name: string, limit?: number, nonRegularCode?: ErrorCode, initialStat?: Stats): Promise<ArtifactCapture>;
|
|
16
16
|
export declare function readFeatureArtifact(featDir: string, name: 'spec.md' | 'plan.md' | 'tasks.md' | '.lock', workspaceRoot?: string): Promise<string>;
|
|
17
|
-
export declare function rewriteArtifact(featDir: string, name: string, expected: ArtifactCapture, content: string, beforeWrite?: () => void): Promise<void>;
|
|
17
|
+
export declare function rewriteArtifact(featDir: string, name: string, expected: ArtifactCapture, content: string, beforeWrite?: () => void, prepareWrite?: () => Promise<void>): Promise<void>;
|
|
18
|
+
export declare function isEvidencePath(value: string): boolean;
|
|
19
|
+
export declare function disjointPaths(paths: readonly string[]): boolean;
|
|
18
20
|
export declare function hashArtifact(content: string): string;
|
|
19
21
|
export declare function lastAuthorityDirectory(directories: AuthorityDirectory[]): AuthorityDirectory;
|
|
20
22
|
//# sourceMappingURL=feature-authority.d.ts.map
|
|
@@ -159,9 +159,12 @@ export async function readFeatureArtifact(featDir, name, workspaceRoot) {
|
|
|
159
159
|
await revalidateDirectories(directories);
|
|
160
160
|
return artifact.content;
|
|
161
161
|
}
|
|
162
|
-
export async function rewriteArtifact(featDir, name, expected, content, beforeWrite) {
|
|
162
|
+
export async function rewriteArtifact(featDir, name, expected, content, beforeWrite, prepareWrite) {
|
|
163
163
|
const handle = await fs.open(path.join(featDir, name), fsConstants.O_RDWR | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK);
|
|
164
164
|
try {
|
|
165
|
+
if (prepareWrite) {
|
|
166
|
+
await prepareWrite();
|
|
167
|
+
}
|
|
165
168
|
const stat = await handle.stat();
|
|
166
169
|
checkWritable(stat);
|
|
167
170
|
if (!ownedRegular(stat) ||
|
|
@@ -169,6 +172,9 @@ export async function rewriteArtifact(featDir, name, expected, content, beforeWr
|
|
|
169
172
|
decodeArtifact(await handle.readFile()) !== expected.content) {
|
|
170
173
|
guardFailure('contract_drift', 'Authoritative write checkpoint changed.');
|
|
171
174
|
}
|
|
175
|
+
if (prepareWrite) {
|
|
176
|
+
await validateArtifactRead(path.join(featDir, name), handle, stat);
|
|
177
|
+
}
|
|
172
178
|
const bytes = Buffer.from(content);
|
|
173
179
|
beforeWrite?.();
|
|
174
180
|
const written = await handle.write(bytes, 0, bytes.length, 0);
|
|
@@ -186,6 +192,32 @@ export async function rewriteArtifact(featDir, name, expected, content, beforeWr
|
|
|
186
192
|
await handle.close();
|
|
187
193
|
}
|
|
188
194
|
}
|
|
195
|
+
export function isEvidencePath(value) {
|
|
196
|
+
const lower = value.toLowerCase();
|
|
197
|
+
if (value.length > 240 ||
|
|
198
|
+
!/^[A-Za-z0-9._/-]+$/u.test(value) ||
|
|
199
|
+
lower === 'planu/specs' ||
|
|
200
|
+
lower.startsWith('planu/specs/') ||
|
|
201
|
+
/\.(?:pem|key|p12|pfx)$/u.test(lower)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
return lower
|
|
205
|
+
.split('/')
|
|
206
|
+
.every((part) => /^[a-z0-9._-]+$/u.test(part) &&
|
|
207
|
+
!['.', '..', '.git', '.sdd', 'node_modules', '.env'].includes(part) &&
|
|
208
|
+
!part.startsWith('.env.'));
|
|
209
|
+
}
|
|
210
|
+
export function disjointPaths(paths) {
|
|
211
|
+
const canonical = new Set(paths.map((item) => item.toLowerCase()));
|
|
212
|
+
if (canonical.size !== paths.length) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return paths.every((item) => {
|
|
216
|
+
const parts = item.toLowerCase().split('/');
|
|
217
|
+
parts.pop();
|
|
218
|
+
return parts.every((_, index) => !canonical.has(parts.slice(0, index + 1).join('/')));
|
|
219
|
+
});
|
|
220
|
+
}
|
|
189
221
|
export function hashArtifact(content) {
|
|
190
222
|
return createHash('sha256').update(content).digest('hex');
|
|
191
223
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function toPosixPath(value: string): string;
|
|
1
|
+
import type { ReceiptPolicyResult, ReceiptSealFailure } from '../types/sdd-engine.js';
|
|
2
|
+
export { assessTrinityCompleteness, parseManifestContent, toPosixPath, } from './trinity-structure.js';
|
|
3
|
+
export declare function parseVerificationReceiptPolicy(featureId: string, plan: string, taskText: string): ReceiptPolicyResult;
|
|
4
|
+
export declare function receiptSealFailure(featureId: string, plan: string, tasks: string): ReceiptSealFailure | undefined;
|
|
6
5
|
//# sourceMappingURL=feature-manifest.d.ts.map
|