@odingard/guardian-sdk 0.1.0 → 0.2.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.
Files changed (50) hide show
  1. package/README.md +252 -17
  2. package/dist/contracts.js +9865 -0
  3. package/dist/index.js +12976 -1787
  4. package/dist/public-catalog.v1.json +6915 -0
  5. package/dist-dts/catalog.d.ts +14 -0
  6. package/dist-dts/client.d.ts +51 -1
  7. package/dist-dts/contracts/action-pack.d.ts +464 -0
  8. package/dist-dts/contracts/action-registry.d.ts +91 -1
  9. package/dist-dts/contracts/action.d.ts +1408 -17
  10. package/dist-dts/contracts/agent-state.d.ts +386 -0
  11. package/dist-dts/contracts/approval.d.ts +224 -5
  12. package/dist-dts/contracts/assurance.d.ts +60 -0
  13. package/dist-dts/contracts/authority-graph.d.ts +294 -0
  14. package/dist-dts/contracts/authority-state.d.ts +17 -2
  15. package/dist-dts/contracts/authority.d.ts +31 -5
  16. package/dist-dts/contracts/billing.d.ts +32 -0
  17. package/dist-dts/contracts/calendar.d.ts +6 -6
  18. package/dist-dts/contracts/denial.d.ts +648 -0
  19. package/dist-dts/contracts/evidence.d.ts +73 -16
  20. package/dist-dts/contracts/execution.d.ts +449 -55
  21. package/dist-dts/contracts/identifiers.d.ts +16 -0
  22. package/dist-dts/contracts/index.d.ts +22 -0
  23. package/dist-dts/contracts/intent.d.ts +335 -0
  24. package/dist-dts/contracts/lineage.d.ts +218 -0
  25. package/dist-dts/contracts/local.d.ts +101 -0
  26. package/dist-dts/contracts/multi-principal.d.ts +292 -0
  27. package/dist-dts/contracts/multiparty.d.ts +169 -0
  28. package/dist-dts/contracts/obligation.d.ts +196 -0
  29. package/dist-dts/contracts/plan.d.ts +67 -0
  30. package/dist-dts/contracts/policy-simulation.d.ts +681 -0
  31. package/dist-dts/contracts/prerequisite.d.ts +147 -0
  32. package/dist-dts/contracts/protected-data.d.ts +67 -0
  33. package/dist-dts/contracts/receipt.d.ts +3126 -0
  34. package/dist-dts/contracts/resource-claims.d.ts +146 -0
  35. package/dist-dts/contracts/runtime.d.ts +111 -0
  36. package/dist-dts/contracts/safety-envelope.d.ts +287 -0
  37. package/dist-dts/contracts/sequence.d.ts +132 -0
  38. package/dist-dts/contracts/sources.d.ts +191 -0
  39. package/dist-dts/contracts/tools.d.ts +50 -5
  40. package/dist-dts/contracts/transaction.d.ts +360 -0
  41. package/dist-dts/contracts-entry.d.ts +1 -0
  42. package/dist-dts/embedded.d.ts +58 -0
  43. package/dist-dts/evidence/evidence.d.ts +25 -0
  44. package/dist-dts/evidence/receipt.d.ts +61 -0
  45. package/dist-dts/index.d.ts +5 -1
  46. package/dist-dts/lifecycle.d.ts +25 -0
  47. package/dist-dts/proposal.d.ts +16 -0
  48. package/dist-dts/receipts.d.ts +37 -0
  49. package/package.json +12 -6
  50. package/dist-dts/__tests__/client.test.d.ts +0 -1
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ export declare const LOCAL_EXEC_PARAMETERS_SCHEMA_ID = "odingard.guardian.local.exec.v1";
3
+ export declare const LOCAL_EGRESS_PARAMETERS_SCHEMA_ID = "odingard.guardian.local.egress.v1";
4
+ export declare const LOCAL_BROWSE_PARAMETERS_SCHEMA_ID = "odingard.guardian.local.browse.v1";
5
+ export declare const LocalExecParametersV1Schema: z.ZodObject<{
6
+ schema: z.ZodLiteral<"odingard.guardian.local.exec.v1">;
7
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
8
+ command: z.ZodString;
9
+ cwd: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strict>;
11
+ export type LocalExecParametersV1 = z.infer<typeof LocalExecParametersV1Schema>;
12
+ export declare const LocalEgressParametersV1Schema: z.ZodObject<{
13
+ schema: z.ZodLiteral<"odingard.guardian.local.egress.v1">;
14
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
15
+ url: z.ZodString;
16
+ method: z.ZodDefault<z.ZodEnum<{
17
+ GET: "GET";
18
+ HEAD: "HEAD";
19
+ POST: "POST";
20
+ PUT: "PUT";
21
+ PATCH: "PATCH";
22
+ DELETE: "DELETE";
23
+ OPTIONS: "OPTIONS";
24
+ }>>;
25
+ }, z.core.$strict>;
26
+ export type LocalEgressParametersV1 = z.infer<typeof LocalEgressParametersV1Schema>;
27
+ export declare const LocalBrowseParametersV1Schema: z.ZodObject<{
28
+ schema: z.ZodLiteral<"odingard.guardian.local.browse.v1">;
29
+ connectionId: z.core.$ZodBranded<z.ZodString, "ConnectionId", "out">;
30
+ url: z.ZodString;
31
+ }, z.core.$strict>;
32
+ export type LocalBrowseParametersV1 = z.infer<typeof LocalBrowseParametersV1Schema>;
33
+ export declare const LocalCommandClassSchema: z.ZodEnum<{
34
+ routine: "routine";
35
+ publish: "publish";
36
+ destructive: "destructive";
37
+ }>;
38
+ export type LocalCommandClass = z.infer<typeof LocalCommandClassSchema>;
39
+ /**
40
+ * Deterministic shell command classifier for local.exec mediation.
41
+ *
42
+ * The mediator routes each intercepted command to the class-scoped action
43
+ * (local.exec / local.exec.publish / local.exec.destroy); the definition's
44
+ * validateBinding re-derives the class from the same function, so an agent
45
+ * cannot smuggle a destructive command through a lower-class action.
46
+ *
47
+ * Semantics (kept deliberately small and auditable):
48
+ * - The command is split on `&&`, `||`, `;`, `|`, and newlines; the result is
49
+ * the MOST restrictive class of any segment.
50
+ * - Leading `NAME=value` assignments and `sudo`/`doas`/`env`/`nice`/`ionice`/
51
+ * `nohup`/`timeout`/`time` wrappers (plus their flag arguments) are stripped
52
+ * so `sudo rm -rf /` still classifies on `rm`.
53
+ * - Anything the classifier cannot fully inspect fails conservative:
54
+ * a nested shell (`bash`, `sh -c`, `zsh`), `eval`, `exec`, `source`, inline
55
+ * interpreters (`python -c`, `node -e`, …) and `xargs` are destructive;
56
+ * command substitution `$(...)` / backticks and output redirections raise
57
+ * the floor to publish; unknown programs are publish.
58
+ * - `destructive` programs (rm, dd, mkfs, shred, kill*, shutdown, iptables,
59
+ * `terraform destroy|apply`, `kubectl delete`, `docker rm|prune`, …) and
60
+ * destructive git forms (`git reset`, `git clean`, `git push --force`,
61
+ * `git branch -D`) are destructive.
62
+ * - `publish` programs are outbound mutations: network tools (curl, wget,
63
+ * ssh, scp, rsync, gh, browsers), package installs (`npm install`), and
64
+ * git subcommands that mutate or reach a remote (push, commit, merge, …).
65
+ * - `routine` is a closed list of dev-toolchain and read-only utilities
66
+ * (build/test/lint commands, ls/cat/grep/find/ps, `npm test`, read-only
67
+ * git subcommands like status/log/diff).
68
+ */
69
+ export declare function classifyLocalCommand(command: string): LocalCommandClass;
70
+ type BindingResult = Readonly<{
71
+ ok: true;
72
+ }> | Readonly<{
73
+ ok: false;
74
+ reasonCode: string;
75
+ }>;
76
+ type LocalConnectionFacts = Readonly<{
77
+ provider: string;
78
+ endpointAllowlist?: readonly string[];
79
+ }>;
80
+ /**
81
+ * The class-scoped binding for local.exec*: the classified command must equal
82
+ * the action's declared class. Re-derived here so a misrouted action id (e.g.
83
+ * a destructive command proposed as `local.exec`) fails closed.
84
+ */
85
+ export declare function localExecBinding(expected: LocalCommandClass): (input: {
86
+ params: LocalExecParametersV1;
87
+ connection: LocalConnectionFacts;
88
+ }) => BindingResult;
89
+ export declare function localEndpointBinding(input: {
90
+ params: {
91
+ url: string;
92
+ };
93
+ connection: LocalConnectionFacts;
94
+ }): BindingResult;
95
+ export declare function localExecVerificationProjection(input: LocalExecParametersV1): unknown;
96
+ export declare function localExecEnvelopeProjection(input: LocalExecParametersV1): unknown;
97
+ export declare function localEgressVerificationProjection(input: LocalEgressParametersV1): unknown;
98
+ export declare function localEgressEnvelopeProjection(input: LocalEgressParametersV1): unknown;
99
+ export declare function localBrowseVerificationProjection(input: LocalBrowseParametersV1): unknown;
100
+ export declare function localBrowseEnvelopeProjection(input: LocalBrowseParametersV1): unknown;
101
+ export {};
@@ -0,0 +1,292 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * WO-019 — multi-principal authority relationships.
4
+ *
5
+ * A shared scope groups principals into a household or team. Memberships carry
6
+ * three independent axes, never blended:
7
+ * - principalClass: what authority the principal may hold (a child never
8
+ * holds adult-scope authority);
9
+ * - role: what the member may DO inside the scope (approve vs only view);
10
+ * - relationshipKind: descriptive family/workspace label carried for display
11
+ * and audit; it never confers authority by itself.
12
+ *
13
+ * Scope kinds are deliberately limited to household/team: organization-level
14
+ * directory management is enterprise IAM and out of scope (WO-019 stop
15
+ * condition).
16
+ */
17
+ export declare const PrincipalClassSchema: z.ZodEnum<{
18
+ adult: "adult";
19
+ child: "child";
20
+ }>;
21
+ export declare const ScopeKindSchema: z.ZodEnum<{
22
+ household: "household";
23
+ team: "team";
24
+ }>;
25
+ export declare const RelationshipKindSchema: z.ZodEnum<{
26
+ child: "child";
27
+ spouse: "spouse";
28
+ parent: "parent";
29
+ caregiver: "caregiver";
30
+ workspace: "workspace";
31
+ }>;
32
+ export declare const ScopeMemberRoleSchema: z.ZodEnum<{
33
+ owner: "owner";
34
+ approver: "approver";
35
+ viewer: "viewer";
36
+ }>;
37
+ /**
38
+ * Step-up levels a single human can present. "multi-approver" is a required
39
+ * level only — no single human can present it; it is satisfied by a quorum of
40
+ * distinct approvers (WO-019 step-up ladder).
41
+ */
42
+ export declare const StepUpLevelSchema: z.ZodEnum<{
43
+ tap: "tap";
44
+ passkey: "passkey";
45
+ biometric: "biometric";
46
+ "second-device": "second-device";
47
+ "multi-approver": "multi-approver";
48
+ }>;
49
+ /** The factor one human actually presents with a decision. */
50
+ export declare const ApprovalFactorSchema: z.ZodEnum<{
51
+ tap: "tap";
52
+ passkey: "passkey";
53
+ biometric: "biometric";
54
+ "second-device": "second-device";
55
+ }>;
56
+ /** Ordering of the single-human step-up levels, lowest first. */
57
+ export declare const APPROVAL_FACTOR_RANK: Record<z.infer<typeof ApprovalFactorSchema>, number>;
58
+ /**
59
+ * Ordering of the step-up levels an approval may require, lowest first;
60
+ * "multi-approver" sits above every single-human factor.
61
+ */
62
+ export declare const STEP_UP_LEVEL_RANK: Record<z.infer<typeof StepUpLevelSchema>, number>;
63
+ /** The stricter of two required step-up levels. */
64
+ export declare function strictestStepUpLevel(current: z.infer<typeof StepUpLevelSchema>, candidate: z.infer<typeof StepUpLevelSchema>): z.infer<typeof StepUpLevelSchema>;
65
+ /**
66
+ * True when the presented factor meets the required step-up level.
67
+ * "multi-approver" can never be met by one presented factor — it is satisfied
68
+ * by the endorsement quorum the approval service enforces.
69
+ */
70
+ export declare function approvalFactorSatisfies(presented: z.infer<typeof ApprovalFactorSchema>, required: z.infer<typeof StepUpLevelSchema>): boolean;
71
+ export declare const SharedScopeSchema: z.ZodObject<{
72
+ schemaVersion: z.ZodLiteral<1>;
73
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
74
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
75
+ kind: z.ZodEnum<{
76
+ household: "household";
77
+ team: "team";
78
+ }>;
79
+ label: z.ZodString;
80
+ status: z.ZodEnum<{
81
+ active: "active";
82
+ dissolved: "dissolved";
83
+ }>;
84
+ version: z.ZodNumber;
85
+ createdAtEpochMs: z.ZodNumber;
86
+ createdByPrincipalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
87
+ }, z.core.$strict>;
88
+ export declare const ScopeMembershipSchema: z.ZodObject<{
89
+ schemaVersion: z.ZodLiteral<1>;
90
+ membershipId: z.core.$ZodBranded<z.ZodString, "MembershipId", "out">;
91
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
92
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
93
+ principalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
94
+ principalClass: z.ZodEnum<{
95
+ adult: "adult";
96
+ child: "child";
97
+ }>;
98
+ role: z.ZodEnum<{
99
+ owner: "owner";
100
+ approver: "approver";
101
+ viewer: "viewer";
102
+ }>;
103
+ relationshipKind: z.ZodEnum<{
104
+ child: "child";
105
+ spouse: "spouse";
106
+ parent: "parent";
107
+ caregiver: "caregiver";
108
+ workspace: "workspace";
109
+ }>;
110
+ status: z.ZodEnum<{
111
+ active: "active";
112
+ removed: "removed";
113
+ }>;
114
+ version: z.ZodNumber;
115
+ addedAtEpochMs: z.ZodNumber;
116
+ addedByPrincipalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
117
+ }, z.core.$strict>;
118
+ /** Links one member's agent into the scope so co-principals can see/decide. */
119
+ export declare const ScopeAgentLinkSchema: z.ZodObject<{
120
+ schemaVersion: z.ZodLiteral<1>;
121
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
122
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
123
+ agentId: z.core.$ZodBranded<z.ZodString, "AgentId", "out">;
124
+ ownerPrincipalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
125
+ status: z.ZodEnum<{
126
+ active: "active";
127
+ unlinked: "unlinked";
128
+ }>;
129
+ version: z.ZodNumber;
130
+ linkedAtEpochMs: z.ZodNumber;
131
+ linkedByPrincipalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
132
+ }, z.core.$strict>;
133
+ /**
134
+ * Per-scope approval policy: the step-up level and approver quorum every new
135
+ * approval on a linked agent must satisfy. factorByRiskClass can raise (never
136
+ * lower) the level for higher-risk actions.
137
+ */
138
+ export declare const ScopeApprovalPolicySchema: z.ZodObject<{
139
+ schemaVersion: z.ZodLiteral<1>;
140
+ scopeId: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
141
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
142
+ requiredFactor: z.ZodEnum<{
143
+ tap: "tap";
144
+ passkey: "passkey";
145
+ biometric: "biometric";
146
+ "second-device": "second-device";
147
+ "multi-approver": "multi-approver";
148
+ }>;
149
+ requiredApprovals: z.ZodNumber;
150
+ factorByRiskClass: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
151
+ R0: "R0";
152
+ R1: "R1";
153
+ R2: "R2";
154
+ R3: "R3";
155
+ R4: "R4";
156
+ R5: "R5";
157
+ }>, z.ZodEnum<{
158
+ tap: "tap";
159
+ passkey: "passkey";
160
+ biometric: "biometric";
161
+ "second-device": "second-device";
162
+ "multi-approver": "multi-approver";
163
+ }>>>;
164
+ status: z.ZodEnum<{
165
+ active: "active";
166
+ }>;
167
+ version: z.ZodNumber;
168
+ updatedAtEpochMs: z.ZodNumber;
169
+ updatedByPrincipalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
170
+ approvalStructure: z.ZodOptional<z.ZodObject<{
171
+ schema: z.ZodLiteral<"guardian.multiparty.v1">;
172
+ structureId: z.ZodString;
173
+ members: z.ZodArray<z.ZodObject<{
174
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
175
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
176
+ }, z.core.$strict>>;
177
+ requirement: z.ZodDiscriminatedUnion<[z.ZodObject<{
178
+ kind: z.ZodLiteral<"single">;
179
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
180
+ }, z.core.$strict>, z.ZodObject<{
181
+ kind: z.ZodLiteral<"nOfM">;
182
+ n: z.ZodNumber;
183
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ kind: z.ZodLiteral<"unanimous">;
186
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
187
+ }, z.core.$strict>, z.ZodObject<{
188
+ kind: z.ZodLiteral<"roleQuorum">;
189
+ role: z.ZodString;
190
+ n: z.ZodNumber;
191
+ m: z.ZodNumber;
192
+ }, z.core.$strict>], "kind">;
193
+ specificRequired: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
194
+ veto: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
195
+ separationOfDuties: z.ZodOptional<z.ZodObject<{
196
+ mutuallyExclusive: z.ZodArray<z.ZodArray<z.ZodString>>;
197
+ }, z.core.$strict>>;
198
+ temporaryApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
199
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
200
+ expiresAtEpochMs: z.ZodNumber;
201
+ }, z.core.$strict>>>;
202
+ delegatedApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
203
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
204
+ delegatedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
205
+ }, z.core.$strict>>>;
206
+ emergencyApprovers: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
207
+ coolingPeriod: z.ZodOptional<z.ZodObject<{
208
+ seconds: z.ZodNumber;
209
+ }, z.core.$strict>>;
210
+ }, z.core.$strict>>;
211
+ }, z.core.$strict>;
212
+ /**
213
+ * The requirement resolved when an approval is opened on a scope-linked agent:
214
+ * the bound approver set, the required step-up level, and the quorum. It is
215
+ * frozen into the approval binding at creation so consent cannot widen later.
216
+ */
217
+ export declare const ApprovalRequirementSchema: z.ZodObject<{
218
+ scopeId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "ScopeId", "out">>;
219
+ eligiblePrincipalIds: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
220
+ requiredFactor: z.ZodEnum<{
221
+ tap: "tap";
222
+ passkey: "passkey";
223
+ biometric: "biometric";
224
+ "second-device": "second-device";
225
+ "multi-approver": "multi-approver";
226
+ }>;
227
+ requiredApprovals: z.ZodNumber;
228
+ structure: z.ZodOptional<z.ZodObject<{
229
+ schema: z.ZodLiteral<"guardian.multiparty.v1">;
230
+ structureId: z.ZodString;
231
+ members: z.ZodArray<z.ZodObject<{
232
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
233
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
234
+ }, z.core.$strict>>;
235
+ requirement: z.ZodDiscriminatedUnion<[z.ZodObject<{
236
+ kind: z.ZodLiteral<"single">;
237
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
238
+ }, z.core.$strict>, z.ZodObject<{
239
+ kind: z.ZodLiteral<"nOfM">;
240
+ n: z.ZodNumber;
241
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
242
+ }, z.core.$strict>, z.ZodObject<{
243
+ kind: z.ZodLiteral<"unanimous">;
244
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
245
+ }, z.core.$strict>, z.ZodObject<{
246
+ kind: z.ZodLiteral<"roleQuorum">;
247
+ role: z.ZodString;
248
+ n: z.ZodNumber;
249
+ m: z.ZodNumber;
250
+ }, z.core.$strict>], "kind">;
251
+ specificRequired: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
252
+ veto: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
253
+ separationOfDuties: z.ZodOptional<z.ZodObject<{
254
+ mutuallyExclusive: z.ZodArray<z.ZodArray<z.ZodString>>;
255
+ }, z.core.$strict>>;
256
+ temporaryApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
257
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
258
+ expiresAtEpochMs: z.ZodNumber;
259
+ }, z.core.$strict>>>;
260
+ delegatedApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
261
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
262
+ delegatedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
263
+ }, z.core.$strict>>>;
264
+ emergencyApprovers: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
265
+ coolingPeriod: z.ZodOptional<z.ZodObject<{
266
+ seconds: z.ZodNumber;
267
+ }, z.core.$strict>>;
268
+ }, z.core.$strict>>;
269
+ }, z.core.$strict>;
270
+ /** One approver's recorded assent toward a multi-approver quorum. */
271
+ export declare const ApprovalEndorsementSchema: z.ZodObject<{
272
+ principalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
273
+ factor: z.ZodEnum<{
274
+ tap: "tap";
275
+ passkey: "passkey";
276
+ biometric: "biometric";
277
+ "second-device": "second-device";
278
+ }>;
279
+ atEpochMs: z.ZodNumber;
280
+ }, z.core.$strict>;
281
+ export type PrincipalClass = z.infer<typeof PrincipalClassSchema>;
282
+ export type ScopeKind = z.infer<typeof ScopeKindSchema>;
283
+ export type RelationshipKind = z.infer<typeof RelationshipKindSchema>;
284
+ export type ScopeMemberRole = z.infer<typeof ScopeMemberRoleSchema>;
285
+ export type StepUpLevel = z.infer<typeof StepUpLevelSchema>;
286
+ export type ApprovalFactor = z.infer<typeof ApprovalFactorSchema>;
287
+ export type SharedScope = z.infer<typeof SharedScopeSchema>;
288
+ export type ScopeMembership = z.infer<typeof ScopeMembershipSchema>;
289
+ export type ScopeAgentLink = z.infer<typeof ScopeAgentLinkSchema>;
290
+ export type ScopeApprovalPolicy = z.infer<typeof ScopeApprovalPolicySchema>;
291
+ export type ApprovalRequirement = z.infer<typeof ApprovalRequirementSchema>;
292
+ export type ApprovalEndorsement = z.infer<typeof ApprovalEndorsementSchema>;
@@ -0,0 +1,169 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * WO-027: guardian.multiparty.v1 — declarative multi-party approval
4
+ * structures (GUA-AUTHORITY-OS-001 §28–30).
5
+ *
6
+ * An approval structure declares WHICH human approvals must be recorded
7
+ * before consent can resolve: a single approver, an n-of-m quorum, a
8
+ * unanimous set, a role quorum, composable required members, vetoes,
9
+ * separation of duties, and temporary / delegated / emergency approvers.
10
+ * It is a pure declarative input: the approval service freezes the
11
+ * resolved structure into the approval binding at creation (consent can
12
+ * never widen), records each member's decision, and evaluates the
13
+ * structure deterministically. Nothing here enlarges authority — an
14
+ * unsatisfiable structure fails closed, a veto terminates as denied, and
15
+ * a declared cooling period keeps authority pending for its window.
16
+ */
17
+ export declare const MULTIPARTY_CONTRACT_SCHEMA = "guardian.multiparty.v1";
18
+ /** One roster entry: a member plus the role labels they hold under this structure. */
19
+ export declare const StructureMemberSchema: z.ZodObject<{
20
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
21
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
+ }, z.core.$strict>;
23
+ export type StructureMember = z.infer<typeof StructureMemberSchema>;
24
+ /** The primary approval requirement — exactly one of four shapes. */
25
+ export declare const StructureRequirementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ kind: z.ZodLiteral<"single">;
27
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
28
+ }, z.core.$strict>, z.ZodObject<{
29
+ kind: z.ZodLiteral<"nOfM">;
30
+ n: z.ZodNumber;
31
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
32
+ }, z.core.$strict>, z.ZodObject<{
33
+ kind: z.ZodLiteral<"unanimous">;
34
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
35
+ }, z.core.$strict>, z.ZodObject<{
36
+ kind: z.ZodLiteral<"roleQuorum">;
37
+ role: z.ZodString;
38
+ n: z.ZodNumber;
39
+ m: z.ZodNumber;
40
+ }, z.core.$strict>], "kind">;
41
+ export type StructureRequirement = z.infer<typeof StructureRequirementSchema>;
42
+ /** §30 — a declared delay between satisfaction and resolved consent. */
43
+ export declare const CoolingPeriodSchema: z.ZodObject<{
44
+ seconds: z.ZodNumber;
45
+ }, z.core.$strict>;
46
+ export type CoolingPeriod = z.infer<typeof CoolingPeriodSchema>;
47
+ /** A member whose recorded approvals count only while unexpired. */
48
+ export declare const TemporaryApproverSchema: z.ZodObject<{
49
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
50
+ expiresAtEpochMs: z.ZodNumber;
51
+ }, z.core.$strict>;
52
+ export type TemporaryApprover = z.infer<typeof TemporaryApproverSchema>;
53
+ /**
54
+ * A member who may act on behalf of a delegator. The delegate's authority can
55
+ * only narrow the delegator's — the delegator must itself be a structure
56
+ * member, so a delegate can never act for an authority the delegator lacks.
57
+ */
58
+ export declare const DelegatedApproverSchema: z.ZodObject<{
59
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
60
+ delegatedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
61
+ }, z.core.$strict>;
62
+ export type DelegatedApprover = z.infer<typeof DelegatedApproverSchema>;
63
+ /**
64
+ * §28–29 — one declarative approval structure. `members` is the roster of
65
+ * principals the structure recognizes and the roles each holds (frozen into
66
+ * the binding, so a later roster edit cannot retroactively alter consent).
67
+ */
68
+ export declare const ApprovalStructureSchema: z.ZodObject<{
69
+ schema: z.ZodLiteral<"guardian.multiparty.v1">;
70
+ structureId: z.ZodString;
71
+ members: z.ZodArray<z.ZodObject<{
72
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
73
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
74
+ }, z.core.$strict>>;
75
+ requirement: z.ZodDiscriminatedUnion<[z.ZodObject<{
76
+ kind: z.ZodLiteral<"single">;
77
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
78
+ }, z.core.$strict>, z.ZodObject<{
79
+ kind: z.ZodLiteral<"nOfM">;
80
+ n: z.ZodNumber;
81
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
82
+ }, z.core.$strict>, z.ZodObject<{
83
+ kind: z.ZodLiteral<"unanimous">;
84
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
85
+ }, z.core.$strict>, z.ZodObject<{
86
+ kind: z.ZodLiteral<"roleQuorum">;
87
+ role: z.ZodString;
88
+ n: z.ZodNumber;
89
+ m: z.ZodNumber;
90
+ }, z.core.$strict>], "kind">;
91
+ specificRequired: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
92
+ veto: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
93
+ separationOfDuties: z.ZodOptional<z.ZodObject<{
94
+ mutuallyExclusive: z.ZodArray<z.ZodArray<z.ZodString>>;
95
+ }, z.core.$strict>>;
96
+ temporaryApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
97
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
98
+ expiresAtEpochMs: z.ZodNumber;
99
+ }, z.core.$strict>>>;
100
+ delegatedApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
101
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
102
+ delegatedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
103
+ }, z.core.$strict>>>;
104
+ emergencyApprovers: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
105
+ coolingPeriod: z.ZodOptional<z.ZodObject<{
106
+ seconds: z.ZodNumber;
107
+ }, z.core.$strict>>;
108
+ }, z.core.$strict>;
109
+ export type ApprovalStructure = z.infer<typeof ApprovalStructureSchema>;
110
+ /** Every principal a structure recognizes as a potential decision actor. */
111
+ export declare function structureMemberIds(structure: ApprovalStructure): readonly string[];
112
+ /** The approvals a structure's primary requirement calls for (for display). */
113
+ export declare function structureRequiredCount(structure: ApprovalStructure): number;
114
+ /** One member's recorded decision under a structure (append-only). */
115
+ export declare const RecordedStructureApprovalSchema: z.ZodObject<{
116
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
117
+ decision: z.ZodEnum<{
118
+ veto: "veto";
119
+ approve: "approve";
120
+ deny: "deny";
121
+ }>;
122
+ atEpochMs: z.ZodNumber;
123
+ via: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
124
+ emergency: z.ZodOptional<z.ZodLiteral<true>>;
125
+ }, z.core.$strict>;
126
+ export type RecordedStructureApproval = z.infer<typeof RecordedStructureApprovalSchema>;
127
+ export declare const CoolingWindowSchema: z.ZodObject<{
128
+ startedAtEpochMs: z.ZodNumber;
129
+ endsAtEpochMs: z.ZodNumber;
130
+ }, z.core.$strict>;
131
+ export type CoolingWindow = z.infer<typeof CoolingWindowSchema>;
132
+ export type ApprovalStructureEvaluation = Readonly<{
133
+ status: "satisfied";
134
+ approvedBy: readonly string[];
135
+ }> | Readonly<{
136
+ status: "pending";
137
+ recordedCount: number;
138
+ requiredCount: number;
139
+ missing: readonly string[];
140
+ cooling?: Readonly<{
141
+ startedAtEpochMs: number;
142
+ endsAtEpochMs: number;
143
+ remainingMs: number;
144
+ }>;
145
+ }> | Readonly<{
146
+ status: "vetoed";
147
+ by: string;
148
+ }> | Readonly<{
149
+ status: "impossible";
150
+ reason: string;
151
+ }>;
152
+ /**
153
+ * Pure evaluator (§29): every recorded decision is replayed against the
154
+ * declared structure. First-recorded decision per member wins (append-only);
155
+ * a recorded veto by a veto-listed member terminates as vetoed; a recorded
156
+ * deny removes that member's ability to approve and can make the structure
157
+ * impossible; temporary approvals void once expired; delegated approvals count
158
+ * only under a declared delegation whose delegator is a roster member; a
159
+ * separation-of-duties violation is impossible; an emergency approval
160
+ * satisfies the requirement only when the context declares the emergency.
161
+ * The result only ever holds authority pending or closes it — never widens it.
162
+ */
163
+ export declare function evaluateApprovalStructure(structure: ApprovalStructure, recorded: readonly RecordedStructureApproval[], ctx: {
164
+ nowEpochMs: number;
165
+ emergency?: boolean;
166
+ /** When the requirements were first satisfied (recorded by the caller). */
167
+ satisfiedAtEpochMs?: number;
168
+ }): ApprovalStructureEvaluation;
169
+ export declare function approvalStructureDigest(structure: ApprovalStructure): string;