@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
|
@@ -0,0 +1,119 @@
|
|
|
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 { captureVerificationInput, projectStructure, } from "./verification-contract.js";
|
|
20
|
+
const _utf8Encoder = new TextEncoder();
|
|
21
|
+
/** Byte length of a string in UTF-8 — the only length any budget uses. */
|
|
22
|
+
export function utf8Bytes(text) {
|
|
23
|
+
return _utf8Encoder.encode(text).length;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Unsigned UTF-8 byte comparison: the canonical ordering used for every ordered
|
|
27
|
+
* collection in the package (artifact paths, context identities, finding ids,
|
|
28
|
+
* acceptance inputs). JS's default string compare is code-unit order, which
|
|
29
|
+
* differs for non-ASCII, so it is never used for a digest input.
|
|
30
|
+
*/
|
|
31
|
+
export function utf8ByteCompare(a, b) {
|
|
32
|
+
const ba = _utf8Encoder.encode(a);
|
|
33
|
+
const bb = _utf8Encoder.encode(b);
|
|
34
|
+
const len = Math.min(ba.length, bb.length);
|
|
35
|
+
for (let i = 0; i < len; i++) {
|
|
36
|
+
const diff = ba[i] - bb[i];
|
|
37
|
+
if (diff !== 0)
|
|
38
|
+
return diff;
|
|
39
|
+
}
|
|
40
|
+
return ba.length - bb.length;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* D4/D6 — Canonical serialization of one value: object keys sorted, compact
|
|
44
|
+
* separators, and no formatting a second implementation could drift on.
|
|
45
|
+
*/
|
|
46
|
+
export function canonicalJSONValue(v, domain = "verification") {
|
|
47
|
+
if (v === null)
|
|
48
|
+
return "null";
|
|
49
|
+
const kind = typeof v;
|
|
50
|
+
if (kind === "string")
|
|
51
|
+
return JSON.stringify(v);
|
|
52
|
+
if (kind === "number") {
|
|
53
|
+
if (!Number.isFinite(v)) {
|
|
54
|
+
if (domain === "verification") {
|
|
55
|
+
throw new TypeError(`canonical JSON: unsupported leaf (non-finite ${kind})`);
|
|
56
|
+
}
|
|
57
|
+
return JSON.stringify(v); // 3.3.0: NaN / ±Infinity serialize as `null`
|
|
58
|
+
}
|
|
59
|
+
return JSON.stringify(v);
|
|
60
|
+
}
|
|
61
|
+
if (kind === "boolean")
|
|
62
|
+
return JSON.stringify(v);
|
|
63
|
+
if (Array.isArray(v)) {
|
|
64
|
+
// An explicit arrow, never `.map(canonicalJSONValue)`: `map` would pass the
|
|
65
|
+
// element INDEX as the domain, silently selecting the legacy fallback for
|
|
66
|
+
// every array leaf.
|
|
67
|
+
return "[" + v.map((item) => canonicalJSONValue(item, domain)).join(",") + "]";
|
|
68
|
+
}
|
|
69
|
+
if (kind === "object") {
|
|
70
|
+
const keys = Object.keys(v).sort();
|
|
71
|
+
return "{" + keys.map(k => JSON.stringify(k) + ":" + canonicalJSONValue(v[k], domain)).join(",") + "}";
|
|
72
|
+
}
|
|
73
|
+
if (domain === "verification") {
|
|
74
|
+
throw new TypeError(`canonical JSON: unsupported leaf (${kind})`);
|
|
75
|
+
}
|
|
76
|
+
return JSON.stringify(v);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* F91 — canonical serialization of a contract value, guarded by the contract's
|
|
80
|
+
* own ceilings.
|
|
81
|
+
*
|
|
82
|
+
* A digest must never be produced over a document the validators would refuse, so
|
|
83
|
+
* before any bytes are written this checks the declared-collection cardinality
|
|
84
|
+
* and the canonical byte budget, and it does both on ONE bounded capture of the
|
|
85
|
+
* input. Without the capture, the guard and the projection would read the same
|
|
86
|
+
* submission twice and an accessor that changes value could make a digest cover a
|
|
87
|
+
* document the guard never saw (F97/F99).
|
|
88
|
+
*
|
|
89
|
+
* A refusal is a named `TypeError` quoting only the violated limit — never the
|
|
90
|
+
* submitted content. `family`/`label` name the contract in the message
|
|
91
|
+
* (`verification plan`, `pre-execution receipt`) so the failure is self-locating.
|
|
92
|
+
* `budgetTag` optionally carries the decision tag a family pins on its byte
|
|
93
|
+
* budget (feature 26 pins `D14`; F91 asserts it), keeping each family's
|
|
94
|
+
* published message surface byte-identical across the shared serializer.
|
|
95
|
+
*/
|
|
96
|
+
export function canonicalizeContractInput(value, contract, options) {
|
|
97
|
+
const { collectionField, maxItems, budgetBytes, family, label, budgetTag } = options;
|
|
98
|
+
const budgetName = budgetTag ? `${budgetTag} ${budgetBytes}-byte` : `${budgetBytes}-byte`;
|
|
99
|
+
const submitted = captureVerificationInput(value, budgetBytes);
|
|
100
|
+
if (!submitted.ok) {
|
|
101
|
+
throw new TypeError(submitted.code === "limit-exceeded"
|
|
102
|
+
? // The capture measured the canonical form past the budget — the same
|
|
103
|
+
// refusal F91 names, reached before the serializer could finish it.
|
|
104
|
+
`${family} ${label} canonical form exceeds the ${budgetName} budget — validate before canonicalizing`
|
|
105
|
+
: `${family} ${label} input is not a readable JSON document — validate before canonicalizing`);
|
|
106
|
+
}
|
|
107
|
+
const document = submitted.value;
|
|
108
|
+
if (document !== null && typeof document === "object") {
|
|
109
|
+
const items = document[collectionField];
|
|
110
|
+
if (Array.isArray(items) && items.length > maxItems) {
|
|
111
|
+
throw new TypeError(`${family} ${label} exceeds the limit of at most ${maxItems} ${collectionField} — validate before canonicalizing`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const canonical = canonicalJSONValue(projectStructure(contract, contract.root, document));
|
|
115
|
+
if (utf8Bytes(canonical) > budgetBytes) {
|
|
116
|
+
throw new TypeError(`${family} ${label} canonical form exceeds the ${budgetName} budget — validate before canonicalizing`);
|
|
117
|
+
}
|
|
118
|
+
return canonical;
|
|
119
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* take the LAST fenced ```json block of the assistant's final message;
|
|
9
9
|
* exactly one envelope per turn; all top-level keys always present.
|
|
10
10
|
*/
|
|
11
|
+
import { VERIFICATION_COMMAND_STATUSES, VERIFICATION_COST_CLASSES, VERIFICATION_DIAGNOSTIC_CODES, VERIFICATION_LIMITS, VERIFICATION_PLAN_CONTRACT_ID, VERIFICATION_RECEIPT_CONTRACT_ID, VERIFICATION_STAGES, VERIFICATION_VERDICTS, WORKING_DIRECTORY_POLICIES, type VerificationDiagnosticCodeV1, type VerificationDiagnosticV1 } from "./verification-contract.js";
|
|
11
12
|
export declare const ENVELOPE_STATES: readonly ["OK", "CONTINUE", "READY_FOR_REVIEW", "READY_FOR_AUDIT", "MERGE_READY", "MERGED", "NEEDS_FIXES", "BLOCKED", "NEEDS_INPUT", "FAILED", "HALT"];
|
|
12
13
|
export type EnvelopeState = (typeof ENVELOPE_STATES)[number];
|
|
13
14
|
/** States after which an orchestrator must stop and involve a human. */
|
|
@@ -171,7 +172,7 @@ export type StrictEnvelopeParseResult = {
|
|
|
171
172
|
};
|
|
172
173
|
/** Extract, parse, and validate the strict driver-facing v2 envelope. */
|
|
173
174
|
export declare function parseEnvelopeV2Strict(text: string): StrictEnvelopeParseResult;
|
|
174
|
-
export type WorkflowIntent = "init-workspace" | "status" | "discover-repository-state" | "resolve-repository-state" | "design-feature" | "plan-feature" | "plan-fix" | "triage-issue" | "execute-phase" | "review-change" | "loop-review-fold" | "audit-pr" | "merge" | "ask-human" | "stop" | "none";
|
|
175
|
+
export type WorkflowIntent = "init-workspace" | "status" | "discover-repository-state" | "resolve-repository-state" | "design-feature" | "review-spec" | "plan-feature" | "review-plan" | "plan-fix" | "triage-issue" | "execute-phase" | "review-change" | "loop-review-fold" | "audit-pr" | "merge" | "ask-human" | "stop" | "none";
|
|
175
176
|
export declare const WORKFLOW_INTENTS: readonly WorkflowIntent[];
|
|
176
177
|
/** Sense reason codes: transition cannot proceed without more sensor input. */
|
|
177
178
|
export declare const WORKFLOW_DECISION_SENSE_CODES: readonly ["sense-initial", "sense-stale-revision", "sense-missing-evidence", "sense-unknown-state", "sense-unlisted-transition"];
|
|
@@ -276,7 +277,7 @@ export type SkillReasoning = (typeof SKILL_REASONING)[number];
|
|
|
276
277
|
export declare const SKILL_CONTEXT_SOURCES: readonly ["repository", "semantic-context", "episodic-memory", "execution-state"];
|
|
277
278
|
export type SkillContextSource = (typeof SKILL_CONTEXT_SOURCES)[number];
|
|
278
279
|
/** Evidence a capability-aware driver should require before trusting results. */
|
|
279
|
-
export declare const SKILL_REQUIRED_EVIDENCE: readonly ["workflow-snapshot", "current-candidate", "verification", "independent-review", "audit", "issue-state", "pull-request-state"];
|
|
280
|
+
export declare const SKILL_REQUIRED_EVIDENCE: readonly ["workflow-snapshot", "current-candidate", "verification", "independent-review", "audit", "issue-state", "pull-request-state", "pre-execution-review"];
|
|
280
281
|
export type SkillRequiredEvidence = (typeof SKILL_REQUIRED_EVIDENCE)[number];
|
|
281
282
|
/**
|
|
282
283
|
* Declarative, closed-vocabulary capability metadata for a built-in profile.
|
|
@@ -628,3 +629,263 @@ export interface CanonicalVectorV1 {
|
|
|
628
629
|
* Changing any vector's expected digest would be a reviewed contract change.
|
|
629
630
|
*/
|
|
630
631
|
export declare const CANONICAL_VECTORS: ReadonlyArray<CanonicalVectorV1>;
|
|
632
|
+
/** Contract identifier for VerificationPlan v1 (re-exported from the canonical definition). */
|
|
633
|
+
export { VERIFICATION_PLAN_CONTRACT_ID };
|
|
634
|
+
/** Verification stages: fast and full (re-exported from the canonical definition). */
|
|
635
|
+
export { VERIFICATION_STAGES };
|
|
636
|
+
export type VerificationStage = (typeof VERIFICATION_STAGES)[number];
|
|
637
|
+
/** Cost classes declared by the project, not measured by the package. */
|
|
638
|
+
export { VERIFICATION_COST_CLASSES };
|
|
639
|
+
export type VerificationCostClass = (typeof VERIFICATION_COST_CLASSES)[number];
|
|
640
|
+
/**
|
|
641
|
+
* D14 bounded usability — the published ceilings of the v1 contracts
|
|
642
|
+
* (re-exported from the canonical definition, which is where they are enforced).
|
|
643
|
+
*/
|
|
644
|
+
export { VERIFICATION_LIMITS };
|
|
645
|
+
/** Working directory policy derived from the canonical runtime vocabulary. */
|
|
646
|
+
export type WorkingDirectoryPolicy = (typeof WORKING_DIRECTORY_POLICIES)[number];
|
|
647
|
+
/**
|
|
648
|
+
* A single verification command within a plan.
|
|
649
|
+
*
|
|
650
|
+
* `executable` + `args` are represented separately (never a shell string);
|
|
651
|
+
* shell composition is reserved for a future versioned contract.
|
|
652
|
+
*/
|
|
653
|
+
export interface VerificationCommandV1 {
|
|
654
|
+
/** Stable, non-empty, unique within the plan. */
|
|
655
|
+
readonly id: string;
|
|
656
|
+
/** `fast` or `full` — which stage this command belongs to. */
|
|
657
|
+
readonly stage: VerificationStage;
|
|
658
|
+
/** Non-empty executable path; no NUL characters. Never a shell string. */
|
|
659
|
+
readonly executable: string;
|
|
660
|
+
/** Ordered arguments; each without NUL; may be empty. */
|
|
661
|
+
readonly args: readonly string[];
|
|
662
|
+
/** Whether the command runs at the candidate root or a relative subdirectory. */
|
|
663
|
+
readonly workingDirectoryPolicy: WorkingDirectoryPolicy;
|
|
664
|
+
/** `null` iff `candidate-root`; a validated relative path iff `relative-path`. */
|
|
665
|
+
readonly workingDirectory: string | null;
|
|
666
|
+
/** Positive integer timeout in milliseconds. */
|
|
667
|
+
readonly timeoutMs: number;
|
|
668
|
+
/** Whether to stop executing subsequent commands on failure. */
|
|
669
|
+
readonly stopOnFailure: boolean;
|
|
670
|
+
/** Project-declared cost class (not measured billing truth). */
|
|
671
|
+
readonly costClass: VerificationCostClass;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* An ordered, non-empty command list for staged verification.
|
|
675
|
+
*
|
|
676
|
+
* The package validates, canonicalizes, and digests the plan; it does NOT
|
|
677
|
+
* execute commands. The caller owns execution.
|
|
678
|
+
*/
|
|
679
|
+
export interface VerificationPlanV1 {
|
|
680
|
+
/** Must equal `VERIFICATION_PLAN_CONTRACT_ID`. */
|
|
681
|
+
readonly contract: typeof VERIFICATION_PLAN_CONTRACT_ID;
|
|
682
|
+
/** Non-empty command list in declared order. */
|
|
683
|
+
readonly commands: readonly VerificationCommandV1[];
|
|
684
|
+
}
|
|
685
|
+
export type VerificationPlanValidationResult = {
|
|
686
|
+
ok: true;
|
|
687
|
+
plan: VerificationPlanV1;
|
|
688
|
+
} | {
|
|
689
|
+
ok: false;
|
|
690
|
+
diagnostics: readonly VerificationDiagnosticV1[];
|
|
691
|
+
truncated: boolean;
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* D16 closed diagnostic result (re-exported from the canonical definition).
|
|
695
|
+
*
|
|
696
|
+
* A failure never carries a message or a submitted value — only the frozen code
|
|
697
|
+
* and the RFC 6901 pointer to the offending location, capped at
|
|
698
|
+
* `VERIFICATION_LIMITS.diagnostics` rows with `truncated` telling the consumer
|
|
699
|
+
* the list is not the whole story.
|
|
700
|
+
*/
|
|
701
|
+
export { VERIFICATION_DIAGNOSTIC_CODES };
|
|
702
|
+
export type VerificationDiagnosticCode = VerificationDiagnosticCodeV1;
|
|
703
|
+
export type { VerificationDiagnosticV1 };
|
|
704
|
+
/**
|
|
705
|
+
* The sole plan-validation authority (D12).
|
|
706
|
+
*
|
|
707
|
+
* Every structural rule comes from the canonical verification-contract
|
|
708
|
+
* definition: contract id, non-empty command list, unique non-empty ids,
|
|
709
|
+
* closed vocabularies, executable/args shapes, working-directory policy
|
|
710
|
+
* nullness and relative-path validation, positive-integer timeouts, and
|
|
711
|
+
* undeclared or inherited fields at every level.
|
|
712
|
+
*
|
|
713
|
+
* The input domain is JSON documents — values `JSON.parse` produces or
|
|
714
|
+
* equivalent literals. An input outside that domain (e.g. an object with a
|
|
715
|
+
* throwing live getter) cannot smuggle its exception past this entry: the
|
|
716
|
+
* walk failure is refused as a redacted `invalid-type` row, so callers
|
|
717
|
+
* always observe the D16 diagnostic contract (F92).
|
|
718
|
+
*
|
|
719
|
+
* On success it returns a normalized own-property DTO — never the submitted
|
|
720
|
+
* reference — so digests and downstream semantics see exactly the declared
|
|
721
|
+
* contract fields. On failure it returns at most
|
|
722
|
+
* `VERIFICATION_LIMITS.diagnostics` redacted code+path rows (D16).
|
|
723
|
+
*/
|
|
724
|
+
export declare function validateVerificationPlanV1(value: unknown): VerificationPlanValidationResult;
|
|
725
|
+
/** Contract identifier for VerificationReceipt v1 (re-exported from the canonical definition). */
|
|
726
|
+
export { VERIFICATION_RECEIPT_CONTRACT_ID };
|
|
727
|
+
/** Possible per-command result statuses (re-exported from the canonical definition). */
|
|
728
|
+
export { VERIFICATION_COMMAND_STATUSES };
|
|
729
|
+
export type VerificationCommandStatus = (typeof VERIFICATION_COMMAND_STATUSES)[number];
|
|
730
|
+
/** Verdict values derived from receipt content. */
|
|
731
|
+
export { VERIFICATION_VERDICTS };
|
|
732
|
+
export type VerificationVerdict = (typeof VERIFICATION_VERDICTS)[number];
|
|
733
|
+
/** Stage requested: fast or full — the same closed vocabulary as `stage`. */
|
|
734
|
+
export type VerificationStageRequest = VerificationStage;
|
|
735
|
+
/**
|
|
736
|
+
* Bounded reference to captured evidence (stdout/stderr output).
|
|
737
|
+
*
|
|
738
|
+
* Output contents stay outside the portable receipt; only the reference,
|
|
739
|
+
* size, and digest are carried.
|
|
740
|
+
*/
|
|
741
|
+
export interface EvidenceReferenceV1 {
|
|
742
|
+
/** Non-empty opaque pointer to stored evidence, ≤ 1024 chars, no NUL. */
|
|
743
|
+
readonly ref: string;
|
|
744
|
+
/** Size of the captured evidence in bytes (≥ 0). */
|
|
745
|
+
readonly bytes: number;
|
|
746
|
+
/** Lowercase 64-hex SHA-256 digest of the captured evidence. */
|
|
747
|
+
readonly sha256: string;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Per-command verification result.
|
|
751
|
+
*
|
|
752
|
+
* The D4 exit-code/signal matrix:
|
|
753
|
+
* - passed/failed: exactly one of exitCode (integer) / signal (non-empty string)
|
|
754
|
+
* - timed-out: exitCode null, signal nullable
|
|
755
|
+
* - infrastructure-error: both null
|
|
756
|
+
* - skipped: both null
|
|
757
|
+
*/
|
|
758
|
+
export interface VerificationResultV1 {
|
|
759
|
+
/** Must exist in the bound plan's commands. */
|
|
760
|
+
readonly commandId: string;
|
|
761
|
+
/** The terminal status of this command execution. */
|
|
762
|
+
readonly status: VerificationCommandStatus;
|
|
763
|
+
/** Integer exit code; per the D4 matrix (null for timed-out/infrastructure-error/skipped). */
|
|
764
|
+
readonly exitCode: number | null;
|
|
765
|
+
/** Kill signal; per the D4 matrix (nullable for timed-out, null otherwise). */
|
|
766
|
+
readonly signal: string | null;
|
|
767
|
+
/** ISO-8601 UTC start timestamp. */
|
|
768
|
+
readonly startedAt: string;
|
|
769
|
+
/** ISO-8601 UTC end timestamp, ≥ startedAt. */
|
|
770
|
+
readonly endedAt: string;
|
|
771
|
+
/** Bounded stdout evidence reference or null. */
|
|
772
|
+
readonly stdout: EvidenceReferenceV1 | null;
|
|
773
|
+
/** Bounded stderr evidence reference or null. */
|
|
774
|
+
readonly stderr: EvidenceReferenceV1 | null;
|
|
775
|
+
/** Skip reason: null on non-skipped rows; when skipped, a stable id ≤ 1024 chars.
|
|
776
|
+
* For fail-fast: MUST equal the stable id of an earlier-declared command
|
|
777
|
+
* whose result is non-passed and whose plan entry declares stopOnFailure: true.
|
|
778
|
+
* Any other non-null value makes the receipt invalid.
|
|
779
|
+
*/
|
|
780
|
+
readonly skipReason: string | null;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* A verification receipt bound to a plan, candidate snapshot, and acceptance
|
|
784
|
+
* fingerprint.
|
|
785
|
+
*
|
|
786
|
+
* The verdict field must equal deriveVerificationVerdict(receipt, plan)
|
|
787
|
+
* — a stored verdict that disagrees with the derived verdict makes the
|
|
788
|
+
* receipt invalid.
|
|
789
|
+
*/
|
|
790
|
+
export interface VerificationReceiptV1 {
|
|
791
|
+
/** Must equal `VERIFICATION_RECEIPT_CONTRACT_ID`. */
|
|
792
|
+
readonly contract: typeof VERIFICATION_RECEIPT_CONTRACT_ID;
|
|
793
|
+
/** Lowercase 64-hex SHA-256 of `digestVerificationPlan(plan)`. */
|
|
794
|
+
readonly planDigest: string;
|
|
795
|
+
/** Lowercase 64-hex SHA-256 from #138's candidate-snapshot digest. */
|
|
796
|
+
readonly candidateSnapshotDigest: string;
|
|
797
|
+
/** Lowercase 64-hex acceptance fingerprint from #138. */
|
|
798
|
+
readonly acceptanceFingerprint: string;
|
|
799
|
+
/** Which stage was requested: fast or full. */
|
|
800
|
+
readonly stageRequested: VerificationStageRequest;
|
|
801
|
+
/** Ordered per-command results. */
|
|
802
|
+
readonly results: readonly VerificationResultV1[];
|
|
803
|
+
/** Must equal `deriveVerificationVerdict(receipt, plan)`. */
|
|
804
|
+
readonly verdict: VerificationVerdict;
|
|
805
|
+
}
|
|
806
|
+
/** Result of the sole public receipt entry point (D12/D16). */
|
|
807
|
+
export type VerificationReceiptValidationResult = {
|
|
808
|
+
ok: true;
|
|
809
|
+
receipt: VerificationReceiptV1;
|
|
810
|
+
} | {
|
|
811
|
+
ok: false;
|
|
812
|
+
diagnostics: readonly VerificationDiagnosticV1[];
|
|
813
|
+
truncated: boolean;
|
|
814
|
+
};
|
|
815
|
+
/**
|
|
816
|
+
* The sole receipt-validation authority (D12): one call performs the
|
|
817
|
+
* VerificationReceipt v1 structural shape check, the VerificationPlan v1
|
|
818
|
+
* structural check, and every plan-bound rule — commandId existence, declared
|
|
819
|
+
* order, fast-stage subset, complete `stopOnFailure` sequencing and attribution
|
|
820
|
+
* (D3/S4), planDigest match and verdict consistency (D2).
|
|
821
|
+
*
|
|
822
|
+
* It accepts unknown input and returns a normalized own-property receipt DTO;
|
|
823
|
+
* no standalone structural receipt validator is exported, so a structural
|
|
824
|
+
* match alone can never claim runtime validity (D13). Async because the
|
|
825
|
+
* planDigest check composes the async digest. The input domain is JSON
|
|
826
|
+
* documents — like the plan entry, an out-of-domain object (a throwing live
|
|
827
|
+
* getter) is refused as a redacted `invalid-type` row rather than escaping an
|
|
828
|
+
* attacker-chosen exception (F92).
|
|
829
|
+
*/
|
|
830
|
+
export declare function validateVerificationReceiptAgainstPlan(receipt: unknown, plan: unknown): Promise<VerificationReceiptValidationResult>;
|
|
831
|
+
/**
|
|
832
|
+
* D2 — Verdict derivation: incomplete > fail > pass. Validating wrapper around
|
|
833
|
+
* {@link deriveVerdictUnchecked} — safe to call standalone on unvalidated inputs.
|
|
834
|
+
*/
|
|
835
|
+
export declare function deriveVerificationVerdict(receipt: VerificationReceiptV1, plan: VerificationPlanV1): VerificationVerdict;
|
|
836
|
+
/**
|
|
837
|
+
* D6 — Canonical serialization of a validated `VerificationPlan v1`. The
|
|
838
|
+
* input must first pass `validateVerificationPlanV1`; out-of-contract
|
|
839
|
+
* cardinality or byte budgets throw a named TypeError (F91).
|
|
840
|
+
*/
|
|
841
|
+
export declare function canonicalizeVerificationPlan(plan: VerificationPlanV1): string;
|
|
842
|
+
/**
|
|
843
|
+
* D6 — Canonical serialization of a validated `VerificationReceipt v1`. The
|
|
844
|
+
* input must first pass `validateVerificationReceiptAgainstPlan`;
|
|
845
|
+
* out-of-contract cardinality or byte budgets throw a named TypeError (F91).
|
|
846
|
+
*/
|
|
847
|
+
export declare function canonicalizeVerificationReceipt(receipt: VerificationReceiptV1): string;
|
|
848
|
+
/** D6 — Digest of a validated plan (inherits the F91 canonical-input guards). */
|
|
849
|
+
export declare function digestVerificationPlan(plan: VerificationPlanV1): Promise<string>;
|
|
850
|
+
/** D6 — Digest of a validated receipt (inherits the F91 canonical-input guards). */
|
|
851
|
+
export declare function digestVerificationReceipt(receipt: VerificationReceiptV1): Promise<string>;
|
|
852
|
+
/**
|
|
853
|
+
* D1 — Freshness predicate.
|
|
854
|
+
*
|
|
855
|
+
* Pure, async, deterministic and it throws nothing. Fixed check order (SPEC §
|
|
856
|
+
* Stage, verdict, and freshness semantics): plan digest → candidate-snapshot
|
|
857
|
+
* digest → acceptance fingerprint → a missing fast-stage result → an
|
|
858
|
+
* unjustified skip → a missing full-stage result → `{ fresh: true }`.
|
|
859
|
+
*
|
|
860
|
+
* The two coverage codes are partitioned by the STAGE OF THE MISSING COMMAND,
|
|
861
|
+
* which is what keeps them disjoint while `incomplete-missing-results` still
|
|
862
|
+
* answers a full receipt that skipped a fast command:
|
|
863
|
+
* `incomplete-stage-coverage` only fires on a `full` receipt whose declared
|
|
864
|
+
* full-stage commands are not covered.
|
|
865
|
+
*/
|
|
866
|
+
/** Verification-specific freshness reason codes (D1). */
|
|
867
|
+
export declare const VERIFICATION_FRESHNESS_CODES: readonly ["stale-plan", "stale-candidate-snapshot", "stale-acceptance-fingerprint", "incomplete-missing-results", "incomplete-unjustified-skip", "incomplete-stage-coverage"];
|
|
868
|
+
export type VerificationFreshnessReasonCode = (typeof VERIFICATION_FRESHNESS_CODES)[number];
|
|
869
|
+
export type VerificationFreshnessResult = {
|
|
870
|
+
fresh: true;
|
|
871
|
+
} | {
|
|
872
|
+
fresh: false;
|
|
873
|
+
reasonCode: VerificationFreshnessReasonCode;
|
|
874
|
+
};
|
|
875
|
+
export declare function compareVerificationReceiptToCurrent(receipt: VerificationReceiptV1, plan: VerificationPlanV1, candidateSnapshotDigest: string, acceptanceFingerprint: string): Promise<VerificationFreshnessResult>;
|
|
876
|
+
/**
|
|
877
|
+
* Published frozen canonical vectors for the verification contracts.
|
|
878
|
+
*
|
|
879
|
+
* Each vector is a minimal valid value whose canonical digest is deterministic
|
|
880
|
+
* and reproducible. These vectors lock the canonicalization rules (D6) in place.
|
|
881
|
+
* Changing any vector's expected digest would be a reviewed contract change.
|
|
882
|
+
*/
|
|
883
|
+
export declare const VERIFICATION_CANONICAL_VECTORS: ReadonlyArray<Readonly<CanonicalVectorV1>>;
|
|
884
|
+
/**
|
|
885
|
+
* Re-exported so a consumer imports ONE package root for every contract family.
|
|
886
|
+
* The implementation lives in `pre-execution.ts`; the structural definition stays
|
|
887
|
+
* package-internal, exactly as the verification family's does, and the generated
|
|
888
|
+
* Draft-07 files are projections of it, not a second authority.
|
|
889
|
+
*/
|
|
890
|
+
export { buildPreExecutionArtifactSnapshot, canonicalizePreExecutionArtifactSnapshot, canonicalizePreExecutionReviewReceipt, comparePreExecutionReceiptToSnapshot, digestPreExecutionArtifactSnapshot, digestPreExecutionReviewReceipt, selectSpecProduct, validatePreExecutionArtifactSnapshotV1, validatePreExecutionReceiptAgainstSnapshot, validatePreExecutionReviewReceiptV1, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CANONICAL_VECTORS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_DIAGNOSTIC_CODES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FRESHNESS_CODES, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_RUNTIME_RULES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_SNAPSHOT_SELECTOR, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, SPEC_PRODUCT_REQUIRED_HEADINGS, } from "./pre-execution.js";
|
|
891
|
+
export type { PreExecutionArtifactInput, PreExecutionArtifactKind, PreExecutionArtifactRow, PreExecutionArtifactSnapshotV1, PreExecutionAuthorExclusion, PreExecutionCanonicalVector, PreExecutionContextBinding, PreExecutionContextInput, PreExecutionContextKind, PreExecutionContextPresence, PreExecutionDiagnostic, PreExecutionDiagnosticCode, PreExecutionFinding, PreExecutionFindingClass, PreExecutionFindingResolution, PreExecutionFindingSeverity, PreExecutionFindingVerification, PreExecutionFreshnessCode, PreExecutionFreshnessResult, PreExecutionModelDiversity, PreExecutionParentReceipt, PreExecutionParentRole, PreExecutionReceiptValidationResult, PreExecutionReviewReceiptV1, PreExecutionReviewerRole, PreExecutionSelector, PreExecutionSnapshotBuildInput, PreExecutionSnapshotValidationResult, PreExecutionStage, PreExecutionUnitKind, PreExecutionVerdict, SpecProductSelection, SpecProductSelectorError, } from "./pre-execution.js";
|