@gtrabanco/agentic-workflow-schema 3.3.0 → 3.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/README.es.md +255 -3
- package/README.md +249 -3
- package/dist/index.d.ts +253 -0
- package/dist/index.js +557 -16
- package/dist/verification-contract.d.ts +227 -0
- package/dist/verification-contract.js +1111 -0
- package/package.json +12 -3
- package/verification-plan.schema.json +197 -0
- package/verification-receipt.schema.json +309 -0
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. */
|
|
@@ -628,3 +629,255 @@ 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>>;
|