@fides-anima/fpp-protocol-core 1.0.2

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.
Files changed (101) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +41 -0
  3. package/SKILL.md +348 -0
  4. package/constitution.json +102 -0
  5. package/constitution.yaml +106 -0
  6. package/dist/adoption-disclosure.d.ts +35 -0
  7. package/dist/adoption-disclosure.d.ts.map +1 -0
  8. package/dist/adoption-disclosure.js +67 -0
  9. package/dist/adoption-disclosure.js.map +1 -0
  10. package/dist/adoption.d.ts +56 -0
  11. package/dist/adoption.d.ts.map +1 -0
  12. package/dist/adoption.js +97 -0
  13. package/dist/adoption.js.map +1 -0
  14. package/dist/canonical-json.d.ts +23 -0
  15. package/dist/canonical-json.d.ts.map +1 -0
  16. package/dist/canonical-json.js +60 -0
  17. package/dist/canonical-json.js.map +1 -0
  18. package/dist/capsules.d.ts +63 -0
  19. package/dist/capsules.d.ts.map +1 -0
  20. package/dist/capsules.js +94 -0
  21. package/dist/capsules.js.map +1 -0
  22. package/dist/claims.d.ts +62 -0
  23. package/dist/claims.d.ts.map +1 -0
  24. package/dist/claims.js +99 -0
  25. package/dist/claims.js.map +1 -0
  26. package/dist/digest.d.ts +38 -0
  27. package/dist/digest.d.ts.map +1 -0
  28. package/dist/digest.js +52 -0
  29. package/dist/digest.js.map +1 -0
  30. package/dist/disposition.d.ts +34 -0
  31. package/dist/disposition.d.ts.map +1 -0
  32. package/dist/disposition.js +51 -0
  33. package/dist/disposition.js.map +1 -0
  34. package/dist/emergency-override.d.ts +73 -0
  35. package/dist/emergency-override.d.ts.map +1 -0
  36. package/dist/emergency-override.js +102 -0
  37. package/dist/emergency-override.js.map +1 -0
  38. package/dist/evidence.d.ts +25 -0
  39. package/dist/evidence.d.ts.map +1 -0
  40. package/dist/evidence.js +30 -0
  41. package/dist/evidence.js.map +1 -0
  42. package/dist/freshness.d.ts +41 -0
  43. package/dist/freshness.d.ts.map +1 -0
  44. package/dist/freshness.js +66 -0
  45. package/dist/freshness.js.map +1 -0
  46. package/dist/governance.d.ts +87 -0
  47. package/dist/governance.d.ts.map +1 -0
  48. package/dist/governance.js +94 -0
  49. package/dist/governance.js.map +1 -0
  50. package/dist/identity.d.ts +43 -0
  51. package/dist/identity.d.ts.map +1 -0
  52. package/dist/identity.js +93 -0
  53. package/dist/identity.js.map +1 -0
  54. package/dist/index.d.ts +30 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +30 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/mandates.d.ts +80 -0
  59. package/dist/mandates.d.ts.map +1 -0
  60. package/dist/mandates.js +127 -0
  61. package/dist/mandates.js.map +1 -0
  62. package/dist/merkle.d.ts +31 -0
  63. package/dist/merkle.d.ts.map +1 -0
  64. package/dist/merkle.js +95 -0
  65. package/dist/merkle.js.map +1 -0
  66. package/dist/quorum.d.ts +133 -0
  67. package/dist/quorum.d.ts.map +1 -0
  68. package/dist/quorum.js +128 -0
  69. package/dist/quorum.js.map +1 -0
  70. package/dist/receipts.d.ts +77 -0
  71. package/dist/receipts.d.ts.map +1 -0
  72. package/dist/receipts.js +104 -0
  73. package/dist/receipts.js.map +1 -0
  74. package/dist/steward-authorization.d.ts +200 -0
  75. package/dist/steward-authorization.d.ts.map +1 -0
  76. package/dist/steward-authorization.js +483 -0
  77. package/dist/steward-authorization.js.map +1 -0
  78. package/dist/workspace-profile.d.ts +43 -0
  79. package/dist/workspace-profile.d.ts.map +1 -0
  80. package/dist/workspace-profile.js +91 -0
  81. package/dist/workspace-profile.js.map +1 -0
  82. package/package.json +56 -0
  83. package/src/adoption-disclosure.ts +120 -0
  84. package/src/adoption.ts +152 -0
  85. package/src/canonical-json.ts +70 -0
  86. package/src/capsules.ts +161 -0
  87. package/src/claims.ts +147 -0
  88. package/src/digest.ts +63 -0
  89. package/src/disposition.ts +74 -0
  90. package/src/emergency-override.ts +168 -0
  91. package/src/evidence.ts +48 -0
  92. package/src/freshness.ts +103 -0
  93. package/src/governance.ts +152 -0
  94. package/src/identity.ts +119 -0
  95. package/src/index.ts +270 -0
  96. package/src/mandates.ts +201 -0
  97. package/src/merkle.ts +138 -0
  98. package/src/quorum.ts +193 -0
  99. package/src/receipts.ts +150 -0
  100. package/src/steward-authorization.ts +657 -0
  101. package/src/workspace-profile.ts +134 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandates.d.ts","sourceRoot":"","sources":["../src/mandates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,sBAAsB,8EAKzB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;EAqCnC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEvE,yEAAyE;AACzE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,aAAa,EAAE,CAAC,CAAC;IACjB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GACxC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,MAAM,MAAM,qBAAqB,GAAG;IAClC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAYvE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,qBAAqB,GAC5B,eAAe,CAmBjB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiBzB;AA0BD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAW1E"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Standing mandate schema — signed or allowlist-backed authorization
3
+ * consumed by the unattended disposition engine.
4
+ */
5
+ import { Type } from "@sinclair/typebox";
6
+ import { Value } from "@sinclair/typebox/value";
7
+ import { canonicalizeV2 } from "./canonical-json.js";
8
+ import { verifySignature } from "./identity.js";
9
+ export const MANDATE_ISSUER_CLASSES = [
10
+ "operator",
11
+ "peer-quorum",
12
+ "steward-quorum",
13
+ "standing-allowlist",
14
+ ];
15
+ export const StandingMandateV1Schema = Type.Object({
16
+ schemaVersion: Type.Literal(1),
17
+ mandateId: Type.String({ minLength: 1 }),
18
+ issuerClass: Type.Union(MANDATE_ISSUER_CLASSES.map((c) => Type.Literal(c))),
19
+ issuerId: Type.String({ minLength: 1 }),
20
+ scope: Type.Object({
21
+ classifications: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
22
+ capabilities: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
23
+ }, { additionalProperties: false }),
24
+ budgets: Type.Object({
25
+ maxActions: Type.Optional(Type.Integer({ minimum: 0 })),
26
+ remainingActions: Type.Optional(Type.Integer({ minimum: 0 })),
27
+ }, { additionalProperties: false }),
28
+ validFrom: Type.String({ minLength: 1 }),
29
+ validTo: Type.String({ minLength: 1 }),
30
+ revocable: Type.Boolean(),
31
+ revoked: Type.Optional(Type.Boolean()),
32
+ evidenceRef: Type.String({ minLength: 1 }),
33
+ quorumRef: Type.Optional(Type.String({ minLength: 1 })),
34
+ publicKey: Type.Optional(Type.String({ minLength: 1 })),
35
+ signature: Type.Optional(Type.String({ minLength: 1 })),
36
+ }, { additionalProperties: false });
37
+ export function parseStandingMandate(input) {
38
+ if (!Value.Check(StandingMandateV1Schema, input)) {
39
+ const errors = [...Value.Errors(StandingMandateV1Schema, input)];
40
+ return {
41
+ ok: false,
42
+ error: errors[0] !== undefined
43
+ ? `${errors[0].path}: ${errors[0].message}`
44
+ : "invalid StandingMandateV1",
45
+ };
46
+ }
47
+ return { ok: true, mandate: input };
48
+ }
49
+ /**
50
+ * Temporal / revocation check for a schema-valid mandate.
51
+ * Budget debit and signature verification live in the plugin mandate store.
52
+ */
53
+ export function validateMandateValidity(mandate, policy) {
54
+ if (mandate.revoked === true) {
55
+ return { valid: false, reason: "mandate revoked" };
56
+ }
57
+ const from = Date.parse(mandate.validFrom);
58
+ const to = Date.parse(mandate.validTo);
59
+ if (Number.isNaN(from) || Number.isNaN(to)) {
60
+ return { valid: false, reason: "validFrom/validTo must be ISO-8601" };
61
+ }
62
+ if (to <= from) {
63
+ return { valid: false, reason: "validTo must be after validFrom" };
64
+ }
65
+ if (policy.nowMs < from) {
66
+ return { valid: false, reason: "mandate not yet valid (validFrom)" };
67
+ }
68
+ if (policy.nowMs > to) {
69
+ return { valid: false, reason: "mandate expired" };
70
+ }
71
+ return { valid: true, reason: "ok" };
72
+ }
73
+ /**
74
+ * Canonical unsigned payload for new mandate signatures.
75
+ * Excludes `signature`, `revoked`, and `budgets.remainingActions` so debit/revoke
76
+ * can mutate an unsigned ledger without invalidating the grant.
77
+ */
78
+ export function mandateSigningFields(mandate) {
79
+ const { signature: _signature, revoked: _revoked, budgets, ...rest } = mandate;
80
+ void _signature;
81
+ void _revoked;
82
+ const signingBudgets = {};
83
+ if (budgets.maxActions !== undefined) {
84
+ signingBudgets.maxActions = budgets.maxActions;
85
+ }
86
+ return {
87
+ ...rest,
88
+ budgets: signingBudgets,
89
+ };
90
+ }
91
+ function legacySigningFields(mandate) {
92
+ const { signature: _signature, ...unsigned } = mandate;
93
+ void _signature;
94
+ return unsigned;
95
+ }
96
+ function tryVerifyMandatePayload(mandate, payload) {
97
+ if (!mandate.publicKey || !mandate.signature) {
98
+ return false;
99
+ }
100
+ const message = Buffer.from(canonicalizeV2(payload), "utf8");
101
+ const sigBytes = Buffer.from(mandate.signature, "hex");
102
+ const pubBytes = Buffer.from(mandate.publicKey, "hex");
103
+ if (sigBytes.length !== 64 || pubBytes.length !== 32) {
104
+ return false;
105
+ }
106
+ return verifySignature(message, sigBytes, pubBytes);
107
+ }
108
+ /**
109
+ * Dual-verify mandate signatures:
110
+ * 1. New payload (`mandateSigningFields`) — preferred for newly issued grants.
111
+ * 2. Legacy payload (full object minus `signature`) — undebited historical files.
112
+ *
113
+ * Standing-allowlist mandates are unsigned by design.
114
+ */
115
+ export function verifyMandateSignature(mandate) {
116
+ if (mandate.issuerClass === "standing-allowlist") {
117
+ return true;
118
+ }
119
+ if (!mandate.publicKey || !mandate.signature) {
120
+ return false;
121
+ }
122
+ if (tryVerifyMandatePayload(mandate, mandateSigningFields(mandate))) {
123
+ return true;
124
+ }
125
+ return tryVerifyMandatePayload(mandate, legacySigningFields(mandate));
126
+ }
127
+ //# sourceMappingURL=mandates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandates.js","sourceRoot":"","sources":["../src/mandates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,E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KAAK,oBAAoB,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,uBAAuB,CAAC,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Versioned Merkle tree primitives.
3
+ *
4
+ * V1 preserves the historical SHA-256(utf8(left+right)) pairing used by
5
+ * audit proofs. V2 domain-separates leaf and internal-node hashes.
6
+ */
7
+ export type MerkleProofStep = {
8
+ hash: string;
9
+ position: "left" | "right";
10
+ };
11
+ export type MerkleProof = {
12
+ leaf: string;
13
+ index: number;
14
+ path: MerkleProofStep[];
15
+ root: string;
16
+ };
17
+ /** Legacy pair hash: SHA-256(utf8(a + b)) with no domain separator. */
18
+ export declare function hashPairV1(a: string, b: string): string;
19
+ /** V2 pair hash: domain-separated internal node. */
20
+ export declare function hashPairV2(a: string, b: string): string;
21
+ export declare function computeMerkleRootV1(leaves: string[]): string;
22
+ export declare function createMerkleProofV1(leaves: string[], index: number): MerkleProof | null;
23
+ export declare function verifyMerkleProofV1(proof: MerkleProof): boolean;
24
+ export declare function computeMerkleRootV2(leaves: string[]): string;
25
+ export declare function createMerkleProofV2(leaves: string[], index: number): MerkleProof | null;
26
+ export declare function verifyMerkleProofV2(proof: MerkleProof): boolean;
27
+ /** Compatibility aliases matching historical script/plugin names (v1). */
28
+ export declare const computeMerkleRoot: typeof computeMerkleRootV1;
29
+ export declare const createMerkleProof: typeof createMerkleProofV1;
30
+ export declare const verifyMerkleProof: typeof verifyMerkleProofV1;
31
+ //# sourceMappingURL=merkle.d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.js ADDED
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Versioned Merkle tree primitives.
3
+ *
4
+ * V1 preserves the historical SHA-256(utf8(left+right)) pairing used by
5
+ * audit proofs. V2 domain-separates leaf and internal-node hashes.
6
+ */
7
+ import { sha256 } from "@noble/hashes/sha256";
8
+ import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils";
9
+ import { DIGEST_DOMAINS } from "./digest.js";
10
+ function sha256Hex(data) {
11
+ return bytesToHex(sha256(utf8ToBytes(data)));
12
+ }
13
+ /** Legacy pair hash: SHA-256(utf8(a + b)) with no domain separator. */
14
+ export function hashPairV1(a, b) {
15
+ return sha256Hex(a + b);
16
+ }
17
+ /** V2 pair hash: domain-separated internal node. */
18
+ export function hashPairV2(a, b) {
19
+ return sha256Hex(DIGEST_DOMAINS.node + "\0" + a + "\0" + b);
20
+ }
21
+ function computeRoot(leaves, hashPair) {
22
+ if (leaves.length === 0)
23
+ return "0".repeat(64);
24
+ if (leaves.length === 1)
25
+ return leaves[0];
26
+ const level = [];
27
+ for (let i = 0; i < leaves.length; i += 2) {
28
+ const left = leaves[i];
29
+ const right = leaves[i + 1] ?? left;
30
+ level.push(hashPair(left, right));
31
+ }
32
+ return computeRoot(level, hashPair);
33
+ }
34
+ function createProof(leaves, index, hashPair) {
35
+ if (index < 0 || index >= leaves.length || leaves.length === 0)
36
+ return null;
37
+ const path = [];
38
+ let currentLevel = [...leaves];
39
+ let idx = index;
40
+ while (currentLevel.length > 1) {
41
+ if (currentLevel.length % 2 === 1) {
42
+ currentLevel.push(currentLevel[currentLevel.length - 1]);
43
+ }
44
+ const siblingIdx = idx % 2 === 0 ? idx + 1 : idx - 1;
45
+ path.push({
46
+ hash: currentLevel[siblingIdx],
47
+ position: idx % 2 === 0 ? "right" : "left",
48
+ });
49
+ const nextLevel = [];
50
+ for (let i = 0; i < currentLevel.length; i += 2) {
51
+ nextLevel.push(hashPair(currentLevel[i], currentLevel[i + 1]));
52
+ }
53
+ currentLevel = nextLevel;
54
+ idx = Math.floor(idx / 2);
55
+ }
56
+ return {
57
+ leaf: leaves[index],
58
+ index,
59
+ path,
60
+ root: currentLevel[0],
61
+ };
62
+ }
63
+ function verifyProof(proof, hashPair) {
64
+ let current = proof.leaf;
65
+ for (const step of proof.path) {
66
+ current =
67
+ step.position === "left"
68
+ ? hashPair(step.hash, current)
69
+ : hashPair(current, step.hash);
70
+ }
71
+ return current === proof.root;
72
+ }
73
+ export function computeMerkleRootV1(leaves) {
74
+ return computeRoot(leaves, hashPairV1);
75
+ }
76
+ export function createMerkleProofV1(leaves, index) {
77
+ return createProof(leaves, index, hashPairV1);
78
+ }
79
+ export function verifyMerkleProofV1(proof) {
80
+ return verifyProof(proof, hashPairV1);
81
+ }
82
+ export function computeMerkleRootV2(leaves) {
83
+ return computeRoot(leaves, hashPairV2);
84
+ }
85
+ export function createMerkleProofV2(leaves, index) {
86
+ return createProof(leaves, index, hashPairV2);
87
+ }
88
+ export function verifyMerkleProofV2(proof) {
89
+ return verifyProof(proof, hashPairV2);
90
+ }
91
+ /** Compatibility aliases matching historical script/plugin names (v1). */
92
+ export const computeMerkleRoot = computeMerkleRootV1;
93
+ export const createMerkleProof = createMerkleProofV1;
94
+ export const verifyMerkleProof = verifyMerkleProofV1;
95
+ //# sourceMappingURL=merkle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merkle.js","sourceRoot":"","sources":["../src/merkle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAc7C,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,UA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evidenceRef
4
+ * pointing at the evidence digest — not constitutional ratification.
5
+ */
6
+ import { type Static } from "@sinclair/typebox";
7
+ export declare const QUORUM_CLASSES: readonly ["peer-quorum", "steward-quorum"];
8
+ export type QuorumClass = (typeof QUORUM_CLASSES)[number];
9
+ export declare const QUORUM_VOTES: readonly ["aye", "nay", "abstain"];
10
+ export type QuorumVote = (typeof QUORUM_VOTES)[number];
11
+ export declare const QuorumProposalV1Schema: import("@sinclair/typebox").TObject<{
12
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
13
+ proposalId: import("@sinclair/typebox").TString;
14
+ quorumClass: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"peer-quorum">, import("@sinclair/typebox").TLiteral<"steward-quorum">]>;
15
+ proposerId: import("@sinclair/typebox").TString;
16
+ /** Digest of the intended unsigned mandate payload. */
17
+ mandateDigest: import("@sinclair/typebox").TString;
18
+ scope: import("@sinclair/typebox").TObject<{
19
+ classifications: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
20
+ capabilities: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
21
+ }>;
22
+ budgets: import("@sinclair/typebox").TObject<{
23
+ maxActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
24
+ remainingActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
25
+ }>;
26
+ mandateValidFrom: import("@sinclair/typebox").TString;
27
+ mandateValidTo: import("@sinclair/typebox").TString;
28
+ proposedAt: import("@sinclair/typebox").TString;
29
+ expiresAt: import("@sinclair/typebox").TString;
30
+ publicKey: import("@sinclair/typebox").TString;
31
+ signature: import("@sinclair/typebox").TString;
32
+ }>;
33
+ export type QuorumProposalV1 = Static<typeof QuorumProposalV1Schema>;
34
+ export declare const QuorumBallotV1Schema: import("@sinclair/typebox").TObject<{
35
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
36
+ ballotId: import("@sinclair/typebox").TString;
37
+ proposalId: import("@sinclair/typebox").TString;
38
+ voterId: import("@sinclair/typebox").TString;
39
+ vote: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"aye">, import("@sinclair/typebox").TLiteral<"nay">, import("@sinclair/typebox").TLiteral<"abstain">]>;
40
+ /** Must match the proposal's mandateDigest. */
41
+ mandateDigest: import("@sinclair/typebox").TString;
42
+ castAt: import("@sinclair/typebox").TString;
43
+ publicKey: import("@sinclair/typebox").TString;
44
+ signature: import("@sinclair/typebox").TString;
45
+ }>;
46
+ export type QuorumBallotV1 = Static<typeof QuorumBallotV1Schema>;
47
+ export declare const QuorumEvidencePackageV1Schema: import("@sinclair/typebox").TObject<{
48
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
49
+ proposal: import("@sinclair/typebox").TObject<{
50
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
51
+ proposalId: import("@sinclair/typebox").TString;
52
+ quorumClass: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"peer-quorum">, import("@sinclair/typebox").TLiteral<"steward-quorum">]>;
53
+ proposerId: import("@sinclair/typebox").TString;
54
+ /** Digest of the intended unsigned mandate payload. */
55
+ mandateDigest: import("@sinclair/typebox").TString;
56
+ scope: import("@sinclair/typebox").TObject<{
57
+ classifications: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
58
+ capabilities: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
59
+ }>;
60
+ budgets: import("@sinclair/typebox").TObject<{
61
+ maxActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
62
+ remainingActions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
63
+ }>;
64
+ mandateValidFrom: import("@sinclair/typebox").TString;
65
+ mandateValidTo: import("@sinclair/typebox").TString;
66
+ proposedAt: import("@sinclair/typebox").TString;
67
+ expiresAt: import("@sinclair/typebox").TString;
68
+ publicKey: import("@sinclair/typebox").TString;
69
+ signature: import("@sinclair/typebox").TString;
70
+ }>;
71
+ ballots: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
72
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
73
+ ballotId: import("@sinclair/typebox").TString;
74
+ proposalId: import("@sinclair/typebox").TString;
75
+ voterId: import("@sinclair/typebox").TString;
76
+ vote: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"aye">, import("@sinclair/typebox").TLiteral<"nay">, import("@sinclair/typebox").TLiteral<"abstain">]>;
77
+ /** Must match the proposal's mandateDigest. */
78
+ mandateDigest: import("@sinclair/typebox").TString;
79
+ castAt: import("@sinclair/typebox").TString;
80
+ publicKey: import("@sinclair/typebox").TString;
81
+ signature: import("@sinclair/typebox").TString;
82
+ }>>;
83
+ finalizedAt: import("@sinclair/typebox").TString;
84
+ }>;
85
+ export type QuorumEvidencePackageV1 = Static<typeof QuorumEvidencePackageV1Schema>;
86
+ export type QuorumParseResult<T> = {
87
+ ok: true;
88
+ value: T;
89
+ } | {
90
+ ok: false;
91
+ error: string;
92
+ };
93
+ export type QuorumProposalParseResult = {
94
+ ok: true;
95
+ proposal: QuorumProposalV1;
96
+ } | {
97
+ ok: false;
98
+ error: string;
99
+ };
100
+ export type QuorumBallotParseResult = {
101
+ ok: true;
102
+ ballot: QuorumBallotV1;
103
+ } | {
104
+ ok: false;
105
+ error: string;
106
+ };
107
+ export type QuorumEvidenceParseResult = {
108
+ ok: true;
109
+ package: QuorumEvidencePackageV1;
110
+ } | {
111
+ ok: false;
112
+ error: string;
113
+ };
114
+ export type BallotMatchResult = {
115
+ ok: true;
116
+ } | {
117
+ ok: false;
118
+ error: string;
119
+ };
120
+ export declare function parseQuorumProposal(input: unknown): QuorumProposalParseResult;
121
+ export declare function parseQuorumBallot(input: unknown): QuorumBallotParseResult;
122
+ export declare function parseQuorumEvidencePackage(input: unknown): QuorumEvidenceParseResult;
123
+ /**
124
+ * Ballot must reference the same proposal and mandateDigest.
125
+ * Signature cryptographic verification is left to the plugin layer.
126
+ */
127
+ export declare function validateBallotAgainstProposal(ballot: QuorumBallotV1, proposal: QuorumProposalV1): BallotMatchResult;
128
+ /**
129
+ * Stable digest of a quorum evidence package for StandingMandateV1.evidenceRef.
130
+ * Domain-separated so it cannot be confused with claim/receipt digests.
131
+ */
132
+ export declare function computeQuorumEvidenceDigest(pkg: QuorumEvidencePackageV1): string;
133
+ //# sourceMappingURL=quorum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quorum.d.ts","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAItD,eAAO,MAAM,cAAc,4CAA6C,CAAC;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,eAAO,MAAM,YAAY,oCAAqC,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAkBvD,eAAO,MAAM,sBAAsB;;;;;IAS/B,uDAAuD;;;;;;;;;;;;;;;;EAY1D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE,eAAO,MAAM,oBAAoB;;;;;;IAW7B,+CAA+C;;;;;EAOlD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEjE,eAAO,MAAM,6BAA6B;;;;;;;QAtCtC,uDAAuD;;;;;;;;;;;;;;;;;;;;;;;QA2BvD,+CAA+C;;;;;;;EAmBlD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,6BAA6B,CACrC,CAAC;AAEF,MAAM,MAAM,iBA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B,GAC3B,MAAM,CAWR"}
package/dist/quorum.js ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Quorum proposal, ballot, and evidence-package schemas.
3
+ * Quorum finalization produces StandingMandateV1 with evidenceRef
4
+ * pointing at the evidence digest — not constitutional ratification.
5
+ */
6
+ import { Type } from "@sinclair/typebox";
7
+ import { Value } from "@sinclair/typebox/value";
8
+ import { digest, DIGEST_DOMAINS } from "./digest.js";
9
+ export const QUORUM_CLASSES = ["peer-quorum", "steward-quorum"];
10
+ export const QUORUM_VOTES = ["aye", "nay", "abstain"];
11
+ const ScopeSchema = Type.Object({
12
+ classifications: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
13
+ capabilities: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
14
+ }, { additionalProperties: false });
15
+ const BudgetsSchema = Type.Object({
16
+ maxActions: Type.Optional(Type.Integer({ minimum: 0 })),
17
+ remainingActions: Type.Optional(Type.Integer({ minimum: 0 })),
18
+ }, { additionalProperties: false });
19
+ export const QuorumProposalV1Schema = Type.Object({
20
+ schemaVersion: Type.Literal(1),
21
+ proposalId: Type.String({ minLength: 1 }),
22
+ quorumClass: Type.Union([
23
+ Type.Literal("peer-quorum"),
24
+ Type.Literal("steward-quorum"),
25
+ ]),
26
+ proposerId: Type.String({ minLength: 1 }),
27
+ /** Digest of the intended unsigned mandate payload. */
28
+ mandateDigest: Type.String({ minLength: 1 }),
29
+ scope: ScopeSchema,
30
+ budgets: BudgetsSchema,
31
+ mandateValidFrom: Type.String({ minLength: 1 }),
32
+ mandateValidTo: Type.String({ minLength: 1 }),
33
+ proposedAt: Type.String({ minLength: 1 }),
34
+ expiresAt: Type.String({ minLength: 1 }),
35
+ publicKey: Type.String({ minLength: 1 }),
36
+ signature: Type.String({ minLength: 1 }),
37
+ }, { additionalProperties: false });
38
+ export const QuorumBallotV1Schema = Type.Object({
39
+ schemaVersion: Type.Literal(1),
40
+ ballotId: Type.String({ minLength: 1 }),
41
+ proposalId: Type.String({ minLength: 1 }),
42
+ voterId: Type.String({ minLength: 1 }),
43
+ vote: Type.Union([
44
+ Type.Literal("aye"),
45
+ Type.Literal("nay"),
46
+ Type.Literal("abstain"),
47
+ ]),
48
+ /** Must match the proposal's mandateDigest. */
49
+ mandateDigest: Type.String({ minLength: 1 }),
50
+ castAt: Type.String({ minLength: 1 }),
51
+ publicKey: Type.String({ minLength: 1 }),
52
+ signature: Type.String({ minLength: 1 }),
53
+ }, { additionalProperties: false });
54
+ export const QuorumEvidencePackageV1Schema = Type.Object({
55
+ schemaVersion: Type.Literal(1),
56
+ proposal: QuorumProposalV1Schema,
57
+ ballots: Type.Array(QuorumBallotV1Schema, { minItems: 1 }),
58
+ finalizedAt: Type.String({ minLength: 1 }),
59
+ }, { additionalProperties: false });
60
+ function firstSchemaError(schema, input) {
61
+ const errors = [...Value.Errors(schema, input)];
62
+ return errors[0] !== undefined
63
+ ? `${errors[0].path}: ${errors[0].message}`
64
+ : "invalid input";
65
+ }
66
+ export function parseQuorumProposal(input) {
67
+ if (!Value.Check(QuorumProposalV1Schema, input)) {
68
+ return {
69
+ ok: false,
70
+ error: firstSchemaError(QuorumProposalV1Schema, input),
71
+ };
72
+ }
73
+ return { ok: true, proposal: input };
74
+ }
75
+ export function parseQuorumBallot(input) {
76
+ if (!Value.Check(QuorumBallotV1Schema, input)) {
77
+ return {
78
+ ok: false,
79
+ error: firstSchemaError(QuorumBallotV1Schema, input),
80
+ };
81
+ }
82
+ return { ok: true, ballot: input };
83
+ }
84
+ export function parseQuorumEvidencePackage(input) {
85
+ if (!Value.Check(QuorumEvidencePackageV1Schema, input)) {
86
+ return {
87
+ ok: false,
88
+ error: firstSchemaError(QuorumEvidencePackageV1Schema, input),
89
+ };
90
+ }
91
+ return { ok: true, package: input };
92
+ }
93
+ /**
94
+ * Ballot must reference the same proposal and mandateDigest.
95
+ * Signature cryptographic verification is left to the plugin layer.
96
+ */
97
+ export function validateBallotAgainstProposal(ballot, proposal) {
98
+ if (ballot.proposalId !== proposal.proposalId) {
99
+ return {
100
+ ok: false,
101
+ error: `proposalId mismatch: ballot=${ballot.proposalId} proposal=${proposal.proposalId}`,
102
+ };
103
+ }
104
+ if (ballot.mandateDigest !== proposal.mandateDigest) {
105
+ return {
106
+ ok: false,
107
+ error: "mandateDigest mismatch between ballot and proposal",
108
+ };
109
+ }
110
+ return { ok: true };
111
+ }
112
+ /**
113
+ * Stable digest of a quorum evidence package for StandingMandateV1.evidenceRef.
114
+ * Domain-separated so it cannot be confused with claim/receipt digests.
115
+ */
116
+ export function computeQuorumEvidenceDigest(pkg) {
117
+ return digest({
118
+ version: 2,
119
+ domain: DIGEST_DOMAINS.quorum,
120
+ value: {
121
+ schemaVersion: pkg.schemaVersion,
122
+ proposal: pkg.proposal,
123
+ ballots: pkg.ballots,
124
+ finalizedAt: pkg.finalizedAt,
125
+ },
126
+ });
127
+ }
128
+ //# sourceMappingURL=quorum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quorum.js","sourceRoot":"","sources":["../src/quorum.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,aAAa,EAAE,gBAAgB,CAAU,CAAC;AAGzE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAU,CAAC;AAG/D,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAC7B;IACE,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,C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AW;SAC7B;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Conformance receipt schema (emission deferred to later plans).
3
+ */
4
+ import { type Static } from "@sinclair/typebox";
5
+ export declare const ReceiptInclusionEvidenceV1Schema: import("@sinclair/typebox").TObject<{
6
+ evidenceVersion: import("@sinclair/typebox").TLiteral<1>;
7
+ logKind: import("@sinclair/typebox").TLiteral<"conformance-receipt">;
8
+ entry: import("@sinclair/typebox").TObject<{
9
+ previousHash: import("@sinclair/typebox").TString;
10
+ timestamp: import("@sinclair/typebox").TString;
11
+ kind: import("@sinclair/typebox").TLiteral<"conformance-receipt">;
12
+ receipt: import("@sinclair/typebox").TUnknown;
13
+ hash: import("@sinclair/typebox").TString;
14
+ }>;
15
+ proof: import("@sinclair/typebox").TObject<{
16
+ leaf: import("@sinclair/typebox").TString;
17
+ index: import("@sinclair/typebox").TInteger;
18
+ path: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
19
+ hash: import("@sinclair/typebox").TString;
20
+ position: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"left">, import("@sinclair/typebox").TLiteral<"right">]>;
21
+ }>>;
22
+ root: import("@sinclair/typebox").TString;
23
+ }>;
24
+ }>;
25
+ export type ReceiptInclusionEvidenceV1 = Static<typeof ReceiptInclusionEvidenceV1Schema>;
26
+ export type ReceiptInclusionEvidenceParseResult = {
27
+ ok: true;
28
+ evidence: ReceiptInclusionEvidenceV1;
29
+ } | {
30
+ ok: false;
31
+ error: string;
32
+ };
33
+ export declare function parseReceiptInclusionEvidence(input: unknown): ReceiptInclusionEvidenceParseResult;
34
+ export declare const ConformanceReceiptV1Schema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
35
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
36
+ receiptClass: import("@sinclair/typebox").TLiteral<"conformance">;
37
+ actionDigest: import("@sinclair/typebox").TString;
38
+ policyId: import("@sinclair/typebox").TString;
39
+ policyVersion: import("@sinclair/typebox").TString;
40
+ implementationVersion: import("@sinclair/typebox").TString;
41
+ disposition: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"allow">, import("@sinclair/typebox").TLiteral<"deny">, import("@sinclair/typebox").TLiteral<"require_approval">, import("@sinclair/typebox").TLiteral<"abstain">, import("@sinclair/typebox").TLiteral<"allow_staged">, import("@sinclair/typebox").TLiteral<"allow_minimal">]>;
42
+ authorization: import("@sinclair/typebox").TString;
43
+ outcome: import("@sinclair/typebox").TString;
44
+ issuedAt: import("@sinclair/typebox").TString;
45
+ constitutionHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
46
+ classifierRulesetHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
47
+ effectiveConfigHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
48
+ governanceEpoch: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNever>;
49
+ governanceMode: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNever>;
50
+ }>, import("@sinclair/typebox").TObject<{
51
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
52
+ receiptClass: import("@sinclair/typebox").TLiteral<"conformance">;
53
+ actionDigest: import("@sinclair/typebox").TString;
54
+ policyId: import("@sinclair/typebox").TString;
55
+ policyVersion: import("@sinclair/typebox").TString;
56
+ implementationVersion: import("@sinclair/typebox").TString;
57
+ disposition: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"allow">, import("@sinclair/typebox").TLiteral<"deny">, import("@sinclair/typebox").TLiteral<"require_approval">, import("@sinclair/typebox").TLiteral<"abstain">, import("@sinclair/typebox").TLiteral<"allow_staged">, import("@sinclair/typebox").TLiteral<"allow_minimal">]>;
58
+ authorization: import("@sinclair/typebox").TString;
59
+ outcome: import("@sinclair/typebox").TString;
60
+ issuedAt: import("@sinclair/typebox").TString;
61
+ constitutionHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
62
+ classifierRulesetHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
63
+ effectiveConfigHash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
64
+ /** Gateway governance binding — both fields required together. */
65
+ governanceEpoch: import("@sinclair/typebox").TInteger;
66
+ governanceMode: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">, ...import("@sinclair/typebox").TLiteral<"enabled" | "draining" | "disabled">[]]>;
67
+ }>]>;
68
+ export type ConformanceReceiptV1 = Static<typeof ConformanceReceiptV1Schema>;
69
+ export type ReceiptParseResult = {
70
+ ok: true;
71
+ receipt: ConformanceReceiptV1;
72
+ } | {
73
+ ok: false;
74
+ error: string;
75
+ };
76
+ export declare function parseConformanceReceipt(input: unknown): ReceiptParseResult;
77
+ //# sourceMappingURL=receipts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipts.d.ts","sourceRoot":"","sources":["../src/receipts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAStD,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;EAoC5C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAC7C,OAAO,gCAAgC,CACxC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAC3C;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,0BAA0B,CAAA;CAAE,GAClD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,mCAAmC,CAKrC;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmDjC,kEAAkE;;;IAMtE,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE7E,MAAM,MAAM,kBAAkB,GAC1B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GAC3C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjC,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAgB1E"}