@gtrabanco/agentic-workflow-schema 3.3.0 → 3.5.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/README.es.md +549 -3
- package/README.md +539 -3
- package/dist/canonical-json.d.ts +60 -0
- package/dist/canonical-json.js +119 -0
- package/dist/index.d.ts +263 -2
- package/dist/index.js +587 -52
- package/dist/pre-execution-contract.d.ts +175 -0
- package/dist/pre-execution-contract.js +676 -0
- package/dist/pre-execution-vectors.d.ts +19 -0
- package/dist/pre-execution-vectors.js +35 -0
- package/dist/pre-execution.d.ts +363 -0
- package/dist/pre-execution.js +838 -0
- package/dist/sha256.d.ts +43 -0
- package/dist/sha256.js +189 -0
- package/dist/verification-contract.d.ts +294 -0
- package/dist/verification-contract.js +1229 -0
- package/package.json +21 -3
- package/pre-execution-artifact-snapshot.schema.json +383 -0
- package/pre-execution-review-receipt.schema.json +457 -0
- package/verification-plan.schema.json +197 -0
- package/verification-receipt.schema.json +309 -0
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@ keeps the established `workflow-status` envelope while giving headless drivers
|
|
|
8
8
|
a smaller result for working skills and deterministic state compiled from
|
|
9
9
|
documents.
|
|
10
10
|
|
|
11
|
+
That claim has an exact shape, and it is the shipped shape: `package.json`
|
|
12
|
+
declares no `dependencies`, and no module under `src/` carries a static built-in
|
|
13
|
+
specifier (`from "node:…"`) — so the same code loads in Node, Bun and a browser.
|
|
14
|
+
The package still takes the host's own SHA-256 when the host happens to offer
|
|
15
|
+
one, opportunistically and per call: see "Canonical form and vectors".
|
|
16
|
+
|
|
11
17
|
## Install
|
|
12
18
|
|
|
13
19
|
```sh
|
|
@@ -163,9 +169,12 @@ overwriting it.
|
|
|
163
169
|
|
|
164
170
|
## Validate or use another language
|
|
165
171
|
|
|
166
|
-
The public validators are `validateEnvelopeV2Strict`,
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
The public contract validators are `validateEnvelopeV2Strict`,
|
|
173
|
+
`validateSkillOutcomeV1`, `validateWorkflowSnapshotV1`,
|
|
174
|
+
`validateCandidateSnapshotV1`, and `validateReviewReceiptV1`; the staged
|
|
175
|
+
verification contracts add exactly the two authoritative entries named above,
|
|
176
|
+
`validateVerificationPlanV1` and `validateVerificationReceiptAgainstPlan`. Import a
|
|
177
|
+
JSON Schema when a non-TypeScript consumer needs the same structural boundary:
|
|
169
178
|
|
|
170
179
|
```ts
|
|
171
180
|
import schema from "@gtrabanco/agentic-workflow-schema/skill-outcome.schema.json" with { type: "json" };
|
|
@@ -218,3 +227,530 @@ Additive contract fields are minor; parser, documentation, or implementation
|
|
|
218
227
|
fixes are patch releases. See
|
|
219
228
|
[programmatic orchestration](../../docs/workflow/ORCHESTRATION.md) for the
|
|
220
229
|
driver protocol.
|
|
230
|
+
|
|
231
|
+
## Evidence-Grounded Pre-Execution Review (feature 28)
|
|
232
|
+
|
|
233
|
+
Two versioned wire contracts that let a reviewer prove *which bytes* it judged,
|
|
234
|
+
before any code exists:
|
|
235
|
+
|
|
236
|
+
- `PreExecutionArtifactSnapshot v1`
|
|
237
|
+
(`agentic-workflow/pre-execution-artifact-snapshot@1`) — the exact artifact set
|
|
238
|
+
and authoritative contexts a review was allowed to rely on, at one source
|
|
239
|
+
revision and one causal artifact revision.
|
|
240
|
+
- `PreExecutionReviewReceipt v1` (`agentic-workflow/pre-execution-review-receipt@1`)
|
|
241
|
+
— one reviewer's verdict over one snapshot, with structured findings, opaque
|
|
242
|
+
author identity, and an optional parent topology.
|
|
243
|
+
|
|
244
|
+
These are **pre-execution** contracts. They are distinct from
|
|
245
|
+
`CandidateSnapshotV1`/`ReviewReceiptV1` (which bind a built candidate) and from
|
|
246
|
+
`VerificationPlanV1`/`VerificationReceiptV1` (which bind command execution). No
|
|
247
|
+
contract in this family substitutes for another: a candidate or verification
|
|
248
|
+
receipt never validates as a pre-execution receipt, and no approval survives a
|
|
249
|
+
change in what was approved.
|
|
250
|
+
|
|
251
|
+
### Public entries
|
|
252
|
+
|
|
253
|
+
| Entry | Contract |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| `validatePreExecutionArtifactSnapshotV1(value)` | `{ ok, snapshot?, diagnostics, truncated }` |
|
|
256
|
+
| `validatePreExecutionReviewReceiptV1(value)` | `{ ok, receipt?, diagnostics, truncated }` |
|
|
257
|
+
| `validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, policyVersion)` | the only PASS authority |
|
|
258
|
+
| `buildPreExecutionArtifactSnapshot(input)` | stage-aware set builder over caller-supplied bytes |
|
|
259
|
+
| `selectSpecProduct(text)` | deterministic `spec-product-v1` projection |
|
|
260
|
+
| `canonicalizePreExecutionArtifactSnapshot(snapshot)` | canonical JSON string |
|
|
261
|
+
| `digestPreExecutionArtifactSnapshot(snapshot)` | lowercase SHA-256 hex |
|
|
262
|
+
| `canonicalizePreExecutionReviewReceipt(receipt)` / `digestPreExecutionReviewReceipt(receipt)` | same pair for receipts |
|
|
263
|
+
| `comparePreExecutionReceiptToSnapshot(receipt, reviewed, current, policyVersion)` | freshness decision |
|
|
264
|
+
|
|
265
|
+
Every entry accepts `unknown`, never throws on hostile input, and answers the
|
|
266
|
+
closed, redacted diagnostic vocabulary `PRE_EXECUTION_DIAGNOSTIC_CODES` — codes
|
|
267
|
+
and field pointers only, never a submitted value.
|
|
268
|
+
|
|
269
|
+
### Contract identifiers
|
|
270
|
+
|
|
271
|
+
The two `contract` discriminators are exported as
|
|
272
|
+
`PRE_EXECUTION_SNAPSHOT_CONTRACT_ID` and
|
|
273
|
+
`PRE_EXECUTION_RECEIPT_CONTRACT_ID`; the SPEC-stage Product projection name is
|
|
274
|
+
`PRE_EXECUTION_SNAPSHOT_SELECTOR` (`spec-product-v1`). Compare them by string
|
|
275
|
+
equality — a snapshot or receipt whose `contract` is anything else is refused with
|
|
276
|
+
`invalid-value`, which is what keeps a candidate, verification, or future-version
|
|
277
|
+
document from being mistaken for one of these.
|
|
278
|
+
|
|
279
|
+
### Closed vocabularies
|
|
280
|
+
|
|
281
|
+
Every value below is exported as a frozen array; nothing outside them validates.
|
|
282
|
+
`PRE_EXECUTION_RUNTIME_RULES` publishes the same split the prose describes —
|
|
283
|
+
`{ snapshot: [...], receipt: [...] }`, each row `{ id, claim }` — so a driver can
|
|
284
|
+
display the guarantees the schema cannot state.
|
|
285
|
+
|
|
286
|
+
| Export | Values and meaning |
|
|
287
|
+
| --- | --- |
|
|
288
|
+
| `PRE_EXECUTION_STAGES` | `spec` · `plan` — The two review stages. Drives the required artifact set and the verdict matrix. |
|
|
289
|
+
| `PRE_EXECUTION_UNIT_KINDS` | `feature` · `fix` — `fix` has no Product half, so it has no SPEC-stage snapshot. |
|
|
290
|
+
| `PRE_EXECUTION_ARTIFACT_KINDS` | `spec` · `acceptance` · `plan` · `tasks` · `testing` · `decisions` · `architecture-notes` · `planning-evidence` · `obligations` — Roles a bound document may play. |
|
|
291
|
+
| `PRE_EXECUTION_SELECTORS` | `whole-file` · `spec-product-v1` — How bound bytes were chosen out of a file. |
|
|
292
|
+
| `PRE_EXECUTION_CONTEXT_KINDS` | `roadmap-row` · `governing-issue` · `normalized-repository-state` · `architectural-invariants` · `dependency-unit` · `project-guide` — Authorities a reviewer was allowed to rely on. |
|
|
293
|
+
| `PRE_EXECUTION_CONTEXT_PRESENCE` | `present` · `absent` — `absent` is a recorded fact, never a skipped field. |
|
|
294
|
+
| `PRE_EXECUTION_VERDICTS` | `spec-review-pass` · `spec-review-fail` · `plan-review-pass` · `plan-review-fail` · `needs-design` — Each verdict names the stage it is legal on. |
|
|
295
|
+
| `PRE_EXECUTION_FINDING_SEVERITIES` | `info` · `low` · `medium` · `high` · `critical` — `info` never blocks a PASS on its own merits. |
|
|
296
|
+
| `PRE_EXECUTION_FINDING_CLASSES` | `product` · `plan` · `source` · `environment` · `runtime` — Which contract layer the finding is about. |
|
|
297
|
+
| `PRE_EXECUTION_FINDING_VERIFICATION` | `verified` · `unverified` — Only `verified` material findings can support a PASS. |
|
|
298
|
+
| `PRE_EXECUTION_FINDING_RESOLUTIONS` | `open` · `resolved` · `dismissed` — `dismissed` requires recorded counter-evidence. |
|
|
299
|
+
| `PRE_EXECUTION_REVIEW_ROLES` | `reviewer` · `critic` · `synthesizer` · `arbiter` — What this receipt is in the topology. |
|
|
300
|
+
| `PRE_EXECUTION_PARENT_ROLES` | `critic` · `synthesis` · `arbitration` — What a parent receipt was — there is no quorum over them. |
|
|
301
|
+
| `PRE_EXECUTION_AUTHOR_EXCLUSIONS` | `enforced` · `not-enforceable` — Whether the runtime can prove the reviewer did not author the artifact set. |
|
|
302
|
+
| `PRE_EXECUTION_MODEL_DIVERSITY` | `same-model` · `cross-model` · `not-applicable` — A truthful label, never a threshold. |
|
|
303
|
+
| `PRE_EXECUTION_FRESHNESS_CODES` | `invalid-stage` · `invalid-unit` · `stale-policy` · `stale-context` · `stale-source-revision` · `stale-parent` · `stale-artifact-revision` · `stale-artifact-content` · `missing-receipt-snapshot` — Ordered precedence: see Freshness. |
|
|
304
|
+
| `PRE_EXECUTION_DIAGNOSTIC_CODES` | `invalid-type` · `missing-field` · `unknown-field` · `invalid-value` · `limit-exceeded` · `duplicate-id` · `unknown-command` · `invalid-order` · `invalid-stage` · `invalid-exit-state` · `invalid-evidence` · `invalid-skip` · `invalid-fail-fast` · `digest-mismatch` · `verdict-mismatch` · `budget-exceeded` · `missing-artifact-kind` · `invalid-artifact-set` · `invalid-selector` · `invalid-author` · `invalid-context` · `invalid-topology` · `stale-snapshot` · `stale-policy` — Redacted: codes and pointers only, never a submitted value. |
|
|
305
|
+
|
|
306
|
+
### What the snapshot binds
|
|
307
|
+
|
|
308
|
+
`contract`, `stage` (`spec | plan`), `unitKind` (`feature | fix`), `unitId`,
|
|
309
|
+
`sourceRevision` (40- or 64-hex git object id), `artifactRevisionId` (the causal
|
|
310
|
+
revision — a deliberate rotation even when content reverts), `artifacts[]`,
|
|
311
|
+
`contexts[]`, and `parentSpecSnapshotDigest` (null iff `stage === "spec"`).
|
|
312
|
+
|
|
313
|
+
Each artifact row is `{ kind, path, selector, byteLength, digest }`:
|
|
314
|
+
|
|
315
|
+
- `kind` ∈ `PRE_EXECUTION_ARTIFACT_KINDS` (`spec`, `acceptance`, `plan`, `tasks`,
|
|
316
|
+
`testing`, `decisions`, `architecture-notes`, `planning-evidence`,
|
|
317
|
+
`obligations`).
|
|
318
|
+
- `path` is normalized repository-relative — absolute, drive-letter, backslash,
|
|
319
|
+
`.`/`..` segments, trailing separators, and empty segments are refused.
|
|
320
|
+
- `selector` ∈ `whole-file | spec-product-v1`. The SPEC stage binds its SPEC row
|
|
321
|
+
with `spec-product-v1` and nothing else; the Plan stage binds whole files.
|
|
322
|
+
- `byteLength`/`digest` describe the **selection**, not the file.
|
|
323
|
+
|
|
324
|
+
Required sets are stage-driven: SPEC = exactly the projected `spec` row;
|
|
325
|
+
Plan = `spec` + `acceptance`, plus whichever of `plan`, `tasks`, `testing`,
|
|
326
|
+
`decisions`, `architecture-notes`, `planning-evidence`, `obligations` exist for
|
|
327
|
+
that unit size. A `fix` unit has no Product half, so it has no SPEC-stage
|
|
328
|
+
snapshot — Plan review is its pre-execution gate.
|
|
329
|
+
|
|
330
|
+
Each context row is `{ kind, identifier, presence, digest }` with `kind` ∈
|
|
331
|
+
`roadmap-row | governing-issue | normalized-repository-state |
|
|
332
|
+
architectural-invariants | dependency-unit | project-guide`. `presence` is
|
|
333
|
+
`present | absent`; a present authority carries its 64-hex digest, an absent one
|
|
334
|
+
binds exactly `null`. Absence is a recorded fact, never a skipped field.
|
|
335
|
+
|
|
336
|
+
Rows are canonically ordered — artifacts by UTF-8 path bytes, contexts by kind
|
|
337
|
+
then identifier — and identities are unique within each list.
|
|
338
|
+
|
|
339
|
+
### Collection rules live in the runtime, not the schema
|
|
340
|
+
|
|
341
|
+
The published projections
|
|
342
|
+
([`pre-execution-artifact-snapshot.schema.json`](./pre-execution-artifact-snapshot.schema.json),
|
|
343
|
+
[`pre-execution-review-receipt.schema.json`](./pre-execution-review-receipt.schema.json))
|
|
344
|
+
are rendered from the same internal definition the runtime enforces, so they can
|
|
345
|
+
never contradict it. Draft 07 has no form for properties **of a collection**
|
|
346
|
+
(path-byte ordering, per-kind/per-path uniqueness, the stage↔selector matrix,
|
|
347
|
+
context identity uniqueness), so those five-plus rules —
|
|
348
|
+
`artifact-rows-ordered`, `artifact-kinds-unique`, `artifact-paths-unique`,
|
|
349
|
+
`context-rows-ordered`, `context-identities-unique`,
|
|
350
|
+
`spec-artifact-uses-product-selector`, `stage-selector-matrix` — are enforced by
|
|
351
|
+
this package only. Validate them here; do not trust a third-party draft-07
|
|
352
|
+
validator to refuse an unordered snapshot.
|
|
353
|
+
|
|
354
|
+
### Verdicts, findings, and the PASS authority
|
|
355
|
+
|
|
356
|
+
`verdict` ∈ `spec-review-pass | spec-review-fail | plan-review-pass |
|
|
357
|
+
plan-review-fail | needs-design`, and the verdict must match the snapshot stage.
|
|
358
|
+
A finding is `{ id, severity, class, claim, evidenceRefs, verification,
|
|
359
|
+
resolution, resolutionEvidence }` with `severity` ∈ `info | low | medium | high
|
|
360
|
+
| critical`, `class` ∈ `product | plan | source | environment | runtime`,
|
|
361
|
+
`verification` ∈ `verified | unverified`, and `resolution` ∈ `open | resolved |
|
|
362
|
+
dismissed`. Every finding carries at least one evidence reference, and a
|
|
363
|
+
dismissal requires recorded counter-evidence.
|
|
364
|
+
|
|
365
|
+
`validatePreExecutionReceiptAgainstSnapshot` is the only entry that can bless a
|
|
366
|
+
PASS. It refuses a PASS while any material finding is open or unverified
|
|
367
|
+
(`info`-severity findings never block on their own merits), while the receipt
|
|
368
|
+
binds a different snapshot, while the policy version differs, when the claimed
|
|
369
|
+
author exclusion is violated under `enforced`, or when the reviewer's own
|
|
370
|
+
identity authored the artifact set (`invalid-author`). Parent receipts model a
|
|
371
|
+
bounded critic/synthesis/arbitration topology (`role` ∈ `critic | synthesis |
|
|
372
|
+
arbitration`, unique `receiptDigest`) — there is **no quorum**: votes never erase
|
|
373
|
+
an unresolved material finding, and `modelDiversity` is a truthful label
|
|
374
|
+
(`same-model | cross-model | not-applicable`), never a threshold.
|
|
375
|
+
|
|
376
|
+
### Freshness
|
|
377
|
+
|
|
378
|
+
`comparePreExecutionReceiptToSnapshot` answers `{ fresh: true }` or
|
|
379
|
+
`{ fresh: false, reasonCode }` from the closed `PRE_EXECUTION_FRESHNESS_CODES`,
|
|
380
|
+
in this fixed precedence: `stale-policy` → `stale-context` →
|
|
381
|
+
`stale-source-revision` → `stale-parent` → `stale-artifact-content` →
|
|
382
|
+
`stale-artifact-revision` → `missing-receipt-snapshot`, with `invalid-stage` and
|
|
383
|
+
`invalid-unit` refused before any comparison. Because a revert that rotates
|
|
384
|
+
`artifactRevisionId` still changes the snapshot digest, an old PASS cannot be
|
|
385
|
+
resurrected by editing a document back to its previous bytes.
|
|
386
|
+
|
|
387
|
+
### Published limits
|
|
388
|
+
|
|
389
|
+
`PRE_EXECUTION_LIMITS` (all exact ceilings, one diagnostic sink shared with the
|
|
390
|
+
other families):
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
artifacts 32 · contexts 16 · findings 64 · evidencePerFinding 8
|
|
394
|
+
parentReceipts 8 · receiptDiagnostics 8 · diagnostics 50
|
|
395
|
+
unitIdChars 128 · revisionIdChars 128 · idChars 128 · identifierChars 160
|
|
396
|
+
pathChars 1024 · claimChars 2048 · evidenceChars 1024
|
|
397
|
+
resolutionEvidenceChars 2048 · policyChars 64 · diagnosticChars 512
|
|
398
|
+
artifactBytes 4194304 · snapshotBytes 32768 · receiptBytes 65536
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Canonical form and vectors
|
|
402
|
+
|
|
403
|
+
Canonicalization sorts object keys, preserves declared array order, emits UTF-8
|
|
404
|
+
with no whitespace, and refuses leaves outside the JSON data model. Digests are
|
|
405
|
+
lowercase SHA-256 over those canonical bytes. Four payloads are published in
|
|
406
|
+
`PRE_EXECUTION_CANONICAL_VECTORS` (both stages × both contracts); the suite
|
|
407
|
+
reproduces every digest from its fixture independently through `node:crypto`, so
|
|
408
|
+
a serializer change breaks a test instead of silently moving a consumer's lineage.
|
|
409
|
+
|
|
410
|
+
The synchronous digest (`sha256HexSync`, used by the artifact builder) answers
|
|
411
|
+
from the host's native SHA-256 wherever the host exposes one through
|
|
412
|
+
`globalThis.process?.getBuiltinModule?.("crypto")` — Node v22.3.0 and v20.16.0
|
|
413
|
+
and later, and Bun; browsers expose no such binding — and from this package's
|
|
414
|
+
pure-JS FIPS 180-4 core everywhere else. The binding is looked up on every call
|
|
415
|
+
and never cached, so a bundle that moves between hosts cannot strand a stale
|
|
416
|
+
verdict, and a digest never throws because a host builtin did. Both paths return
|
|
417
|
+
one identical lowercase 64-hex digest for identical bytes; the three-path case in
|
|
418
|
+
`test/pre-execution-canonical.test.mjs` pins native, pure JS and async WebCrypto
|
|
419
|
+
against each other, and `npm run probe:sha256-paths` prints the digests and the
|
|
420
|
+
per-path cost of each on your host (check-only: it writes nothing).
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
npm run gate:pre-execution # tests + schema drift + package checks + pack
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Consumer example
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
import {
|
|
430
|
+
buildPreExecutionArtifactSnapshot,
|
|
431
|
+
comparePreExecutionReceiptToSnapshot,
|
|
432
|
+
digestPreExecutionArtifactSnapshot,
|
|
433
|
+
selectSpecProduct,
|
|
434
|
+
validatePreExecutionReceiptAgainstSnapshot,
|
|
435
|
+
} from "@gtrabanco/agentic-workflow-schema";
|
|
436
|
+
|
|
437
|
+
const POLICY_VERSION = "2026-08-30";
|
|
438
|
+
|
|
439
|
+
// The caller reads the documents: this package never touches Git or the filesystem.
|
|
440
|
+
const spec = [
|
|
441
|
+
"# Toy feature", "", "## Goal", "", "Ship one usable slice.", "",
|
|
442
|
+
"## Branch", "", "`feat/toy`", "", "## Size", "", "`S`", "",
|
|
443
|
+
"## Dependencies", "", "- none", "", "## Product half", "", "### Scope", "",
|
|
444
|
+
"- **S1:** the slice.", "", "## Design status", "", "`designed`", "",
|
|
445
|
+
].join("\n");
|
|
446
|
+
|
|
447
|
+
/** 1. Freeze the exact bytes a reviewer may rely on, at one causal revision. */
|
|
448
|
+
async function freeze(artifactRevisionId: string) {
|
|
449
|
+
const built = buildPreExecutionArtifactSnapshot({
|
|
450
|
+
stage: "spec",
|
|
451
|
+
unitKind: "feature",
|
|
452
|
+
unitId: "toy",
|
|
453
|
+
sourceRevision: "8ab22ea6c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6",
|
|
454
|
+
artifactRevisionId,
|
|
455
|
+
files: [{ kind: "spec", path: "docs/features/toy/SPEC.md", content: spec }],
|
|
456
|
+
contexts: [{ kind: "governing-issue", identifier: "#146", content: "the issue body" }],
|
|
457
|
+
});
|
|
458
|
+
const snapshot = built.ok ? built.snapshot : undefined;
|
|
459
|
+
if (!snapshot) throw new Error(JSON.stringify(built.diagnostics));
|
|
460
|
+
return snapshot;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const snapshot = await freeze("rev-0001");
|
|
464
|
+
|
|
465
|
+
// 2. A reviewer records a verdict bound to that digest, never to the mutable file.
|
|
466
|
+
const receipt = {
|
|
467
|
+
contract: "agentic-workflow/pre-execution-review-receipt@1",
|
|
468
|
+
id: "review-0001",
|
|
469
|
+
stage: snapshot.stage,
|
|
470
|
+
snapshotDigest: digestPreExecutionArtifactSnapshot(snapshot),
|
|
471
|
+
verdict: "spec-review-pass",
|
|
472
|
+
findings: [],
|
|
473
|
+
reviewer: "reviewer-7",
|
|
474
|
+
sessionId: "session-7",
|
|
475
|
+
reviewerRole: "reviewer",
|
|
476
|
+
authorId: "author-3",
|
|
477
|
+
authorExclusion: "enforced",
|
|
478
|
+
contextClean: true,
|
|
479
|
+
modelDiversity: "cross-model",
|
|
480
|
+
policyVersion: POLICY_VERSION,
|
|
481
|
+
startedAt: "2026-08-30T00:00:00Z",
|
|
482
|
+
finishedAt: "2026-08-30T00:04:00Z",
|
|
483
|
+
parentReceipts: [],
|
|
484
|
+
diagnostics: [],
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// 3. Only this entry can bless a PASS; it answers with codes, never submitted values.
|
|
488
|
+
const blessed = validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, POLICY_VERSION);
|
|
489
|
+
if (!blessed.ok) throw new Error(JSON.stringify(blessed.diagnostics));
|
|
490
|
+
|
|
491
|
+
// 4. Before executing, freeze again: unchanged authority stays fresh.
|
|
492
|
+
const fresh = comparePreExecutionReceiptToSnapshot(
|
|
493
|
+
receipt, snapshot, await freeze("rev-0001"), POLICY_VERSION,
|
|
494
|
+
);
|
|
495
|
+
if (fresh.fresh !== true) throw new Error(JSON.stringify(fresh));
|
|
496
|
+
|
|
497
|
+
// 5. Edit, revert, and rotate the revision anyway and the PASS is void: a stale
|
|
498
|
+
// approval can never be resurrected by restoring the previous bytes.
|
|
499
|
+
const stale = comparePreExecutionReceiptToSnapshot(
|
|
500
|
+
receipt, snapshot, await freeze("rev-0002"), POLICY_VERSION,
|
|
501
|
+
);
|
|
502
|
+
if (stale.fresh === true || stale.reasonCode !== "stale-artifact-revision") {
|
|
503
|
+
throw new Error(JSON.stringify(stale));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// 6. The projection is why a plan-side write cannot erase Product lineage: the
|
|
507
|
+
// selector never saw anything outside the named Product headings.
|
|
508
|
+
const projection = selectSpecProduct(`${spec}\n## Engineering half\n\n### Phases\n\n- P1\n`);
|
|
509
|
+
if (projection.ok !== true) throw new Error(JSON.stringify(projection.errors));
|
|
510
|
+
if (projection.content.includes("Engineering half")) throw new Error("the projection leaked");
|
|
511
|
+
|
|
512
|
+
console.log("review bound", projection.byteLength, receipt.snapshotDigest.slice(0, 12), fresh, stale);
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## Staged Verification Contracts (feature 26)
|
|
516
|
+
|
|
517
|
+
Two versioned wire contracts for staged verification:
|
|
518
|
+
|
|
519
|
+
- `VerificationPlan v1` (`agentic-workflow/verification-plan@1`) — an ordered,
|
|
520
|
+
non-empty command list where each command carries a stable `id`,
|
|
521
|
+
`stage: fast | full` (the closed `VERIFICATION_STAGES` vocabulary), an
|
|
522
|
+
`executable` and ordered `args` (never a shell
|
|
523
|
+
string), a working-directory policy (`candidate-root` or `relative-path` with
|
|
524
|
+
validated relative path), a positive `timeoutMs`, `stopOnFailure`, and a
|
|
525
|
+
cost class (`VERIFICATION_COST_CLASSES`). The validated relative path is an **opaque** string: resolve it
|
|
526
|
+
under the candidate root exactly as submitted, and never percent-decode it
|
|
527
|
+
before resolution — decoding can turn a path the validator rejected into one
|
|
528
|
+
that escapes the root.
|
|
529
|
+
|
|
530
|
+
- `VerificationReceipt v1` (`agentic-workflow/verification-receipt@1`) — a receipt that
|
|
531
|
+
binds to the plan digest, candidate-snapshot digest, and acceptance
|
|
532
|
+
fingerprint, carrying per-command results with status (`passed | failed |
|
|
533
|
+
timed-out | skipped | infrastructure-error`), exit-code/signal per the D4
|
|
534
|
+
matrix, bounded evidence references, and an explicit skip reason. The
|
|
535
|
+
overall verdict (`pass | fail | incomplete`) is derived from the receipt
|
|
536
|
+
content.
|
|
537
|
+
|
|
538
|
+
**Validation authority.** Exactly two public authoritative entries decide runtime
|
|
539
|
+
validity: `validateVerificationPlanV1(value)` for a plan, and
|
|
540
|
+
`await validateVerificationReceiptAgainstPlan(receipt, plan)` for a receipt, which
|
|
541
|
+
performs the structural check and every plan-bound rule in one call. No standalone
|
|
542
|
+
receipt validator is exported — a receipt is only meaningful against the plan it
|
|
543
|
+
binds to. Both accept unknown input and both return a **normalized** own-property
|
|
544
|
+
DTO on success rather than the object you handed them, so digests and downstream
|
|
545
|
+
semantics never depend on inherited, duplicated or undeclared properties.
|
|
546
|
+
|
|
547
|
+
**Failure diagnostics.** A rejection is `{ ok: false, diagnostics, truncated }`.
|
|
548
|
+
`diagnostics` holds at most 50 frozen `{ code, path }` rows in document order and
|
|
549
|
+
`truncated` says whether that ceiling dropped any. A row is never a message: no
|
|
550
|
+
prose and no submitted value is ever returned. `code` comes from the closed
|
|
551
|
+
`VERIFICATION_DIAGNOSTIC_CODES` vocabulary and `path` is an RFC 6901 JSON Pointer
|
|
552
|
+
built only from declared property names and array indices — `/commands/3/id`,
|
|
553
|
+
`/results/1/commandId`, or `""` for the payload as a whole. An undeclared key is
|
|
554
|
+
reported as `unknown-field` on its **container**, because the key name is itself
|
|
555
|
+
submitted data. Recover from diagnostics using only each stable `code` and `path`,
|
|
556
|
+
without copying submitted values into logs, errors, or telemetry.
|
|
557
|
+
|
|
558
|
+
| Diagnostic code | What it answers for | Caller recovery |
|
|
559
|
+
| --- | --- | --- |
|
|
560
|
+
| `invalid-type` | a field holds a value of the wrong JSON type | Supply the declared JSON type at `path`. |
|
|
561
|
+
| `missing-field` | a declared field is absent | Add the required field at `path`. |
|
|
562
|
+
| `unknown-field` | the object carries an undeclared property | Remove undeclared keys from the container at `path`. |
|
|
563
|
+
| `invalid-value` | a value breaks its own rule (vocabulary, pattern, NUL) | Replace it with an allowed vocabulary member or format-valid, NUL-free value. |
|
|
564
|
+
| `limit-exceeded` | a cardinality or length ceiling is crossed | Reduce the indicated collection or string to `VERIFICATION_LIMITS`. |
|
|
565
|
+
| `duplicate-id` | the same command id appears twice | Assign unique command ids, then update their result references. |
|
|
566
|
+
| `unknown-command` | a result or skip reason names no declared command | Reference an id declared by the bound plan. |
|
|
567
|
+
| `invalid-order` | results do not follow the plan's declared order | Reorder result rows to match plan order. |
|
|
568
|
+
| `invalid-stage` | a receipt carries a row outside its requested stage | Remove out-of-stage rows or request the stage that includes them. |
|
|
569
|
+
| `invalid-exit-state` | exit code and signal break the D4 matrix | Align `exitCode` and `signal` with the row's status matrix. |
|
|
570
|
+
| `invalid-evidence` | an evidence reference is malformed (D5 content rules) | Provide a bounded `ref`, non-negative byte count, and lowercase SHA-256. |
|
|
571
|
+
| `invalid-skip` | a skip reason is not justified by a failed predecessor | Use `null` when unattributed, or name an earlier actual non-pass trigger. |
|
|
572
|
+
| `invalid-fail-fast` | `stopOnFailure` sequencing is broken | Mark rows after the trigger skipped and attribute them to that trigger. |
|
|
573
|
+
| `digest-mismatch` | the receipt's `planDigest` is not the bound plan's | Recompute it from the validated, normalized bound plan. |
|
|
574
|
+
| `verdict-mismatch` | the stored verdict differs from the derived one | Store the result of `deriveVerificationVerdict`. |
|
|
575
|
+
| `budget-exceeded` | a stage's declared timeouts exceed its aggregate budget | Reduce command timeouts until the stage sum is within `VERIFICATION_LIMITS`. |
|
|
576
|
+
|
|
577
|
+
**JSON Schema status.** `verification-plan.schema.json` and
|
|
578
|
+
`verification-receipt.schema.json` are generated, **non-authoritative structural
|
|
579
|
+
projections** of the package's canonical contract definition. They exist for editors
|
|
580
|
+
and transport checks; a Draft-07 match is not contract validity, and semantic rules
|
|
581
|
+
(`unique-command-ids`, both aggregate stage budgets, both canonical byte budgets) are
|
|
582
|
+
enforced only by the two runtime entries above — each projection discloses them in
|
|
583
|
+
its `$comment`. The projections are generated rather than hand-edited. In a source
|
|
584
|
+
checkout, maintainers change the canonical definition; the only writer is
|
|
585
|
+
`node scripts/generate-verification-schemas.mjs`, and the source-only drift check
|
|
586
|
+
rebuilds before comparing bytes.
|
|
587
|
+
|
|
588
|
+
**Source-checkout-only commands.** The published tarball intentionally omits the
|
|
589
|
+
repository's `scripts/`, `test/`, source, and TypeScript configuration. These
|
|
590
|
+
manifest commands are maintainer checks for a source checkout, not commands an
|
|
591
|
+
installed-package consumer can run:
|
|
592
|
+
|
|
593
|
+
| Source-checkout-only command | Purpose |
|
|
594
|
+
| --- | --- |
|
|
595
|
+
| `npm run check:verification-schemas` | rebuild and byte-check generated projections |
|
|
596
|
+
| `npm run check:verification-package` | inspect the package tarball contract |
|
|
597
|
+
| `npm run bench:verification -- --commands 128` | run the AC10 warm-process benchmark |
|
|
598
|
+
| `npm run test:verification-docs` | run the executable bilingual documentation suite |
|
|
599
|
+
| `npm run gate:verification` | compose all verification release checks |
|
|
600
|
+
|
|
601
|
+
**Two-stage model:** requesting `fast` executes only fast commands; requesting
|
|
602
|
+
`full` executes every fast and full command. The freshness predicate returns
|
|
603
|
+
one of the stable `VERIFICATION_FRESHNESS_CODES` reason codes (`stale-plan | stale-candidate-snapshot |
|
|
604
|
+
stale-acceptance-fingerprint | incomplete-missing-results |
|
|
605
|
+
incomplete-unjustified-skip | incomplete-stage-coverage`) or `{ fresh: true }`.
|
|
606
|
+
|
|
607
|
+
**Delivery-gate rule:** a delivery verification gate is satisfied ONLY by a
|
|
608
|
+
receipt that is fresh, requests `full`, and has verdict `pass`.
|
|
609
|
+
|
|
610
|
+
**No-execution boundary:** the package validates, canonicalizes, digests,
|
|
611
|
+
derives, and compares — it does not execute commands. The caller owns execution.
|
|
612
|
+
|
|
613
|
+
### Public verification API inventory
|
|
614
|
+
|
|
615
|
+
The complete runtime surface for these contracts is:
|
|
616
|
+
|
|
617
|
+
| Runtime group | Exports |
|
|
618
|
+
| --- | --- |
|
|
619
|
+
| Contract and vocabulary values | `VERIFICATION_PLAN_CONTRACT_ID`, `VERIFICATION_RECEIPT_CONTRACT_ID`, `VERIFICATION_STAGES`, `VERIFICATION_COST_CLASSES`, `VERIFICATION_COMMAND_STATUSES`, `VERIFICATION_VERDICTS`, `VERIFICATION_DIAGNOSTIC_CODES`, `VERIFICATION_FRESHNESS_CODES`, `VERIFICATION_LIMITS`, `VERIFICATION_CANONICAL_VECTORS` |
|
|
620
|
+
| Validation and semantics | `validateVerificationPlanV1`, `validateVerificationReceiptAgainstPlan`, `deriveVerificationVerdict`, `compareVerificationReceiptToCurrent` |
|
|
621
|
+
| Canonicalization and digests | `canonicalizeVerificationPlan`, `canonicalizeVerificationReceipt`, `digestVerificationPlan`, `digestVerificationReceipt` |
|
|
622
|
+
|
|
623
|
+
TypeScript also publishes these type-only names:
|
|
624
|
+
|
|
625
|
+
| Type group | Exports |
|
|
626
|
+
| --- | --- |
|
|
627
|
+
| Plan | `VerificationStage`, `VerificationCostClass`, `WorkingDirectoryPolicy`, `VerificationCommandV1`, `VerificationPlanV1`, `VerificationPlanValidationResult` |
|
|
628
|
+
| Receipt | `VerificationCommandStatus`, `VerificationVerdict`, `VerificationStageRequest`, `EvidenceReferenceV1`, `VerificationResultV1`, `VerificationReceiptV1`, `VerificationReceiptValidationResult` |
|
|
629
|
+
| Diagnostics and freshness | `VerificationDiagnosticCode`, `VerificationDiagnosticV1`, `VerificationFreshnessReasonCode`, `VerificationFreshnessResult` |
|
|
630
|
+
|
|
631
|
+
### Usability limits
|
|
632
|
+
|
|
633
|
+
Every v1 ceiling is published once, as the frozen `VERIFICATION_LIMITS` object, and
|
|
634
|
+
is enforced by the two authoritative entries: an over-limit plan or receipt is
|
|
635
|
+
rejected, never silently truncated.
|
|
636
|
+
|
|
637
|
+
| Limit | Value | Applies to |
|
|
638
|
+
| --- | --- | --- |
|
|
639
|
+
| `commands` | 128 | commands declared in one plan |
|
|
640
|
+
| `results` | 128 | result rows in one receipt |
|
|
641
|
+
| `argsPerCommand` | 64 | arguments in one command |
|
|
642
|
+
| `idChars` | 128 | a command `id` or result `commandId` |
|
|
643
|
+
| `pathChars` | 1024 | `executable` and `workingDirectory` |
|
|
644
|
+
| `argChars` | 4096 | a single argument string |
|
|
645
|
+
| `skipReasonChars` | 1024 | a `skipReason` |
|
|
646
|
+
| `evidenceRefChars` | 1024 | an evidence `ref` |
|
|
647
|
+
| `planBytes` | 262144 | canonical plan size (256 KiB) |
|
|
648
|
+
| `receiptBytes` | 524288 | canonical receipt size (512 KiB) |
|
|
649
|
+
| `fastCommandTimeoutMs` | 600000 | one fast command's timeout (10 min) |
|
|
650
|
+
| `fastStageTimeoutMs` | 900000 | every fast command's timeouts summed (15 min) |
|
|
651
|
+
| `fullCommandTimeoutMs` | 3600000 | one full command's timeout (60 min) |
|
|
652
|
+
| `fullStageTimeoutMs` | 7200000 | every full command's timeouts summed (2 h, i.e. 120 min) |
|
|
653
|
+
| `diagnostics` | 50 | rows in one failure result |
|
|
654
|
+
|
|
655
|
+
The canonical byte budget is measured before a payload is examined, so an oversized
|
|
656
|
+
document is refused by the budget alone. The time ceilings are deliberately
|
|
657
|
+
asymmetric: one maximum-length fast command leaves 5 minutes for the rest of the
|
|
658
|
+
fast stage. `npm run bench:verification -- --commands 128` is a
|
|
659
|
+
source-checkout-only maintainer command: run it from a source checkout, never
|
|
660
|
+
from the installed tarball, and it proves the declared performance bound — a warm
|
|
661
|
+
128-command plan+receipt validate → canonicalize → digest cycle at p95 ≤ 100 ms —
|
|
662
|
+
and exits non-zero when it is not met. Cross-implementation
|
|
663
|
+
interoperability is pinned by `VERIFICATION_CANONICAL_VECTORS`, the frozen
|
|
664
|
+
`{ contract, digest, description }` fixtures whose digests any correct
|
|
665
|
+
canonicalizer must reproduce — the package's own digest tests consume exactly
|
|
666
|
+
these payloads.
|
|
667
|
+
|
|
668
|
+
### Consumer example
|
|
669
|
+
|
|
670
|
+
```ts
|
|
671
|
+
import {
|
|
672
|
+
compareVerificationReceiptToCurrent,
|
|
673
|
+
deriveVerificationVerdict,
|
|
674
|
+
digestVerificationPlan,
|
|
675
|
+
validateVerificationPlanV1,
|
|
676
|
+
validateVerificationReceiptAgainstPlan,
|
|
677
|
+
VERIFICATION_PLAN_CONTRACT_ID,
|
|
678
|
+
VERIFICATION_RECEIPT_CONTRACT_ID,
|
|
679
|
+
} from "@gtrabanco/agentic-workflow-schema";
|
|
680
|
+
|
|
681
|
+
const candidateDigest = "3f2a9c1e5b7d4f8a0c2e5b7d9f1a3c5e7b9d1f3a5c7e9b1d3f5a7c9e1b3d5f7a";
|
|
682
|
+
const acceptanceDigest = "9c4e7b1d3f5a8c2e4b6d0f2a4c6e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c24";
|
|
683
|
+
|
|
684
|
+
// 1. Declare the plan: a fast lint that stops the stage, then a full test run.
|
|
685
|
+
const plan = {
|
|
686
|
+
contract: VERIFICATION_PLAN_CONTRACT_ID,
|
|
687
|
+
commands: [
|
|
688
|
+
{ id: "lint", stage: "fast" as const, executable: "npm", args: ["run", "lint"],
|
|
689
|
+
workingDirectoryPolicy: "candidate-root" as const, workingDirectory: null,
|
|
690
|
+
timeoutMs: 30_000, stopOnFailure: true, costClass: "cheap" as const },
|
|
691
|
+
{ id: "test", stage: "full" as const, executable: "npm", args: ["test"],
|
|
692
|
+
workingDirectoryPolicy: "candidate-root" as const, workingDirectory: null,
|
|
693
|
+
timeoutMs: 120_000, stopOnFailure: false, costClass: "moderate" as const },
|
|
694
|
+
],
|
|
695
|
+
} as const;
|
|
696
|
+
|
|
697
|
+
const pv = validateVerificationPlanV1(plan);
|
|
698
|
+
if (!pv.ok) throw new Error(`plan rejected: ${JSON.stringify(pv.diagnostics)}`);
|
|
699
|
+
|
|
700
|
+
// 2. Bind the receipt to one candidate and one acceptance manifest. In a real
|
|
701
|
+
// gate `candidateDigest` comes from `digestCandidateSnapshot(snapshot)` and
|
|
702
|
+
// `acceptanceDigest` comes from `computeAcceptanceFingerprint(rows)`, which
|
|
703
|
+
// hashes the ordered `{ id, blobSha256 }` acceptance rows — not the raw
|
|
704
|
+
// `ACCEPTANCE.md` blob itself.
|
|
705
|
+
const planDigest = await digestVerificationPlan(pv.plan);
|
|
706
|
+
const receipt = {
|
|
707
|
+
contract: VERIFICATION_RECEIPT_CONTRACT_ID,
|
|
708
|
+
planDigest,
|
|
709
|
+
candidateSnapshotDigest: candidateDigest,
|
|
710
|
+
acceptanceFingerprint: acceptanceDigest,
|
|
711
|
+
stageRequested: "full" as const,
|
|
712
|
+
results: [
|
|
713
|
+
{ commandId: "lint", status: "passed" as const, exitCode: 0, signal: null,
|
|
714
|
+
startedAt: "2026-08-27T09:00:00Z", endedAt: "2026-08-27T09:00:12Z",
|
|
715
|
+
stdout: null, stderr: null, skipReason: null },
|
|
716
|
+
{ commandId: "test", status: "passed" as const, exitCode: 0, signal: null,
|
|
717
|
+
startedAt: "2026-08-27T09:00:12Z", endedAt: "2026-08-27T09:02:00Z",
|
|
718
|
+
stdout: { ref: "evidence/test/stdout.log", bytes: 18213,
|
|
719
|
+
sha256: "6b1f4d8a2c5e7b0d3f6a9c2e5b8d1f4a7c0e3b6d9f2a5c8e1b4d7f0a3c6e9b2d" },
|
|
720
|
+
stderr: null, skipReason: null },
|
|
721
|
+
],
|
|
722
|
+
verdict: "pass" as const,
|
|
723
|
+
} as const;
|
|
724
|
+
|
|
725
|
+
// 3. One call proves receipt structure and plan binding.
|
|
726
|
+
const rv = await validateVerificationReceiptAgainstPlan(receipt, plan);
|
|
727
|
+
if (!rv.ok) throw new Error(`receipt rejected: ${JSON.stringify(rv.diagnostics)}`);
|
|
728
|
+
|
|
729
|
+
// 4. A row that ran longer than its command's declared timeout is incoherent.
|
|
730
|
+
for (const result of rv.receipt.results) {
|
|
731
|
+
const declared = pv.plan.commands.find((command) => command.id === result.commandId);
|
|
732
|
+
if (declared === undefined || Date.parse(result.endedAt) - Date.parse(result.startedAt) > declared.timeoutMs) {
|
|
733
|
+
throw new Error(`${result.commandId} outran the timeout its command declared`);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// 5. The verdict is derived from content; the payload's copy is never trusted.
|
|
738
|
+
const derived = deriveVerificationVerdict(rv.receipt, pv.plan); // => "pass"
|
|
739
|
+
|
|
740
|
+
// 6. Freshness compares the digests the receipt was bound to with the current ones.
|
|
741
|
+
const freshness = await compareVerificationReceiptToCurrent(
|
|
742
|
+
rv.receipt, pv.plan, candidateDigest, acceptanceDigest,
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
// 7. The delivery gate needs all three conditions at once.
|
|
746
|
+
if (freshness.fresh === true && rv.receipt.stageRequested === "full" && derived === "pass") {
|
|
747
|
+
console.log("Delivery verified");
|
|
748
|
+
}
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
### Consumer boundary
|
|
752
|
+
|
|
753
|
+
An AWL dialect, runner or adapter that emits plans and executes them is **not part
|
|
754
|
+
of this package**, and no issue tracks it: this schema owns the contracts, the
|
|
755
|
+
canonical forms and the digests only. It becomes independent future work once AWL
|
|
756
|
+
consumes the released package.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serialization primitives — the byte-level authority behind
|
|
3
|
+
* every digest in the package.
|
|
4
|
+
*
|
|
5
|
+
* Two domains, one walker:
|
|
6
|
+
* - `verification` (which the pre-execution contracts also use): a leaf
|
|
7
|
+
* outside the JSON data model is a NAMED refusal, so a digest can never be
|
|
8
|
+
* produced over a document the validators would refuse.
|
|
9
|
+
* - `legacy`: the 3.3.0 behaviour, kept byte-for-byte for the candidate-review
|
|
10
|
+
* family whose digests are already published in receipts. Non-finite numbers
|
|
11
|
+
* serialize as `null` there; that collision class stays on the legacy path
|
|
12
|
+
* and the cost is stated in `decisions.md`, not hidden.
|
|
13
|
+
*
|
|
14
|
+
* Extracted from the package root so the verification and pre-execution
|
|
15
|
+
* contracts share ONE serializer with the candidate family instead of restating
|
|
16
|
+
* it. Behaviour is unchanged and pinned by
|
|
17
|
+
* `test/fixtures/canonical-legacy-vectors.mjs` and the published vector sets.
|
|
18
|
+
*/
|
|
19
|
+
import { type VerificationContractSpec } from "./verification-contract.js";
|
|
20
|
+
export type CanonicalLeafDomain = "legacy" | "verification";
|
|
21
|
+
/** Byte length of a string in UTF-8 — the only length any budget uses. */
|
|
22
|
+
export declare function utf8Bytes(text: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Unsigned UTF-8 byte comparison: the canonical ordering used for every ordered
|
|
25
|
+
* collection in the package (artifact paths, context identities, finding ids,
|
|
26
|
+
* acceptance inputs). JS's default string compare is code-unit order, which
|
|
27
|
+
* differs for non-ASCII, so it is never used for a digest input.
|
|
28
|
+
*/
|
|
29
|
+
export declare function utf8ByteCompare(a: string, b: string): number;
|
|
30
|
+
/**
|
|
31
|
+
* D4/D6 — Canonical serialization of one value: object keys sorted, compact
|
|
32
|
+
* separators, and no formatting a second implementation could drift on.
|
|
33
|
+
*/
|
|
34
|
+
export declare function canonicalJSONValue(v: unknown, domain?: CanonicalLeafDomain): string;
|
|
35
|
+
/**
|
|
36
|
+
* F91 — canonical serialization of a contract value, guarded by the contract's
|
|
37
|
+
* own ceilings.
|
|
38
|
+
*
|
|
39
|
+
* A digest must never be produced over a document the validators would refuse, so
|
|
40
|
+
* before any bytes are written this checks the declared-collection cardinality
|
|
41
|
+
* and the canonical byte budget, and it does both on ONE bounded capture of the
|
|
42
|
+
* input. Without the capture, the guard and the projection would read the same
|
|
43
|
+
* submission twice and an accessor that changes value could make a digest cover a
|
|
44
|
+
* document the guard never saw (F97/F99).
|
|
45
|
+
*
|
|
46
|
+
* A refusal is a named `TypeError` quoting only the violated limit — never the
|
|
47
|
+
* submitted content. `family`/`label` name the contract in the message
|
|
48
|
+
* (`verification plan`, `pre-execution receipt`) so the failure is self-locating.
|
|
49
|
+
* `budgetTag` optionally carries the decision tag a family pins on its byte
|
|
50
|
+
* budget (feature 26 pins `D14`; F91 asserts it), keeping each family's
|
|
51
|
+
* published message surface byte-identical across the shared serializer.
|
|
52
|
+
*/
|
|
53
|
+
export declare function canonicalizeContractInput(value: unknown, contract: VerificationContractSpec, options: {
|
|
54
|
+
readonly collectionField: string;
|
|
55
|
+
readonly maxItems: number;
|
|
56
|
+
readonly budgetBytes: number;
|
|
57
|
+
readonly family: string;
|
|
58
|
+
readonly label: string;
|
|
59
|
+
readonly budgetTag?: string;
|
|
60
|
+
}): string;
|