@odingard/guardian-sdk 0.0.0-stage → 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 (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +302 -2
  3. package/dist/contracts.js +9865 -0
  4. package/dist/index.js +14437 -0
  5. package/dist/public-catalog.v1.json +6915 -0
  6. package/dist-dts/catalog.d.ts +14 -0
  7. package/dist-dts/client.d.ts +130 -0
  8. package/dist-dts/contracts/action-pack.d.ts +464 -0
  9. package/dist-dts/contracts/action-parameters.d.ts +34 -0
  10. package/dist-dts/contracts/action-registry.d.ts +287 -0
  11. package/dist-dts/contracts/action.d.ts +2358 -0
  12. package/dist-dts/contracts/agent-state.d.ts +386 -0
  13. package/dist-dts/contracts/api.d.ts +78 -0
  14. package/dist-dts/contracts/approval.d.ts +425 -0
  15. package/dist-dts/contracts/assurance.d.ts +60 -0
  16. package/dist-dts/contracts/authority-graph.d.ts +294 -0
  17. package/dist-dts/contracts/authority-state.d.ts +108 -0
  18. package/dist-dts/contracts/authority.d.ts +339 -0
  19. package/dist-dts/contracts/billing.d.ts +32 -0
  20. package/dist-dts/contracts/calendar.d.ts +146 -0
  21. package/dist-dts/contracts/canonical-json.d.ts +4 -0
  22. package/dist-dts/contracts/capability.d.ts +28 -0
  23. package/dist-dts/contracts/commerce.d.ts +133 -0
  24. package/dist-dts/contracts/denial.d.ts +648 -0
  25. package/dist-dts/contracts/digest.d.ts +2 -0
  26. package/dist-dts/contracts/email.d.ts +45 -0
  27. package/dist-dts/contracts/evidence.d.ts +1087 -0
  28. package/dist-dts/contracts/execution.d.ts +1732 -0
  29. package/dist-dts/contracts/files.d.ts +61 -0
  30. package/dist-dts/contracts/identifiers.d.ts +49 -0
  31. package/dist-dts/contracts/index.d.ts +41 -0
  32. package/dist-dts/contracts/intent.d.ts +335 -0
  33. package/dist-dts/contracts/lineage.d.ts +218 -0
  34. package/dist-dts/contracts/local.d.ts +101 -0
  35. package/dist-dts/contracts/multi-principal.d.ts +292 -0
  36. package/dist-dts/contracts/multiparty.d.ts +169 -0
  37. package/dist-dts/contracts/obligation.d.ts +196 -0
  38. package/dist-dts/contracts/plan.d.ts +67 -0
  39. package/dist-dts/contracts/policy-simulation.d.ts +681 -0
  40. package/dist-dts/contracts/prerequisite.d.ts +147 -0
  41. package/dist-dts/contracts/protected-data.d.ts +160 -0
  42. package/dist-dts/contracts/receipt.d.ts +3126 -0
  43. package/dist-dts/contracts/resource-claims.d.ts +146 -0
  44. package/dist-dts/contracts/runtime.d.ts +111 -0
  45. package/dist-dts/contracts/safety-envelope.d.ts +287 -0
  46. package/dist-dts/contracts/sequence.d.ts +132 -0
  47. package/dist-dts/contracts/sources.d.ts +191 -0
  48. package/dist-dts/contracts/tools.d.ts +232 -0
  49. package/dist-dts/contracts/transaction.d.ts +360 -0
  50. package/dist-dts/contracts-entry.d.ts +1 -0
  51. package/dist-dts/embedded.d.ts +58 -0
  52. package/dist-dts/evidence/evidence.d.ts +25 -0
  53. package/dist-dts/evidence/receipt.d.ts +61 -0
  54. package/dist-dts/index.d.ts +5 -0
  55. package/dist-dts/lifecycle.d.ts +25 -0
  56. package/dist-dts/proposal.d.ts +41 -0
  57. package/dist-dts/receipts.d.ts +37 -0
  58. package/package.json +56 -4
@@ -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;
@@ -0,0 +1,196 @@
1
+ import { z } from "zod";
2
+ import type { StepUpLevel } from "./multi-principal.js";
3
+ /**
4
+ * WO-023: guardian.obligation.v1 — declarative obligations.
5
+ *
6
+ * An obligation is a human-authored condition attached to an intent: "ALLOW,
7
+ * provided these conditions are satisfied." Obligations are declarative
8
+ * inputs to the ONE authority kernel (directive §89, K15): they never add a
9
+ * verdict (the triad stays ALLOW/ASK/DENY), never widen a grant, and never
10
+ * issue authority. This evaluator is pure and read-only — it may look at the
11
+ * context and return a state; it cannot broaden authority, mint
12
+ * capabilities, or bypass the existing ASK machinery.
13
+ *
14
+ * Evaluation phases (§11–12):
15
+ * - "decision" — mechanical verifiers settled deterministically at the
16
+ * decision point (satisfied | failed).
17
+ * - "human" — human-facing conditions that force the existing ASK
18
+ * machinery (step-up / second approver / quorum compose
19
+ * with the WO-019 approval chain).
20
+ * - "post_action" — recorded as pending and transitioned by evidence or
21
+ * the sweeper; unfulfilled ones surface as overdue, never
22
+ * silently dropped.
23
+ * - "time" — pending until a derived due instant elapses.
24
+ * - "unwired" — types with no verifier in this build: they evaluate
25
+ * `failed` with rule OBLIGATION_VERIFIER_UNAVAILABLE and
26
+ * therefore DENY (fail-closed).
27
+ */
28
+ export declare const OBLIGATION_CONTRACT_SCHEMA = "guardian.obligation.v1";
29
+ /** All 23 obligation types named by directive §12. */
30
+ export declare const ObligationTypeSchema: z.ZodEnum<{
31
+ log: "log";
32
+ retain_receipt: "retain_receipt";
33
+ notify: "notify";
34
+ delay: "delay";
35
+ cooling_period: "cooling_period";
36
+ delete_after_use: "delete_after_use";
37
+ redact: "redact";
38
+ encrypt: "encrypt";
39
+ tokenize: "tokenize";
40
+ minimize: "minimize";
41
+ verify_counterparty: "verify_counterparty";
42
+ verify_resource: "verify_resource";
43
+ verify_effect: "verify_effect";
44
+ attest_runtime: "attest_runtime";
45
+ require_consent: "require_consent";
46
+ require_location: "require_location";
47
+ require_device: "require_device";
48
+ require_network: "require_network";
49
+ require_contract: "require_contract";
50
+ step_up: "step_up";
51
+ second_approver: "second_approver";
52
+ quorum: "quorum";
53
+ authenticate: "authenticate";
54
+ }>;
55
+ export type ObligationType = z.infer<typeof ObligationTypeSchema>;
56
+ /** Bounded, deterministic per-type params (fields[], seconds, quorumSize, level...). */
57
+ export declare const ObligationParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>;
58
+ export type ObligationParams = z.infer<typeof ObligationParamsSchema>;
59
+ export declare const ObligationSchema: z.ZodObject<{
60
+ type: z.ZodEnum<{
61
+ log: "log";
62
+ retain_receipt: "retain_receipt";
63
+ notify: "notify";
64
+ delay: "delay";
65
+ cooling_period: "cooling_period";
66
+ delete_after_use: "delete_after_use";
67
+ redact: "redact";
68
+ encrypt: "encrypt";
69
+ tokenize: "tokenize";
70
+ minimize: "minimize";
71
+ verify_counterparty: "verify_counterparty";
72
+ verify_resource: "verify_resource";
73
+ verify_effect: "verify_effect";
74
+ attest_runtime: "attest_runtime";
75
+ require_consent: "require_consent";
76
+ require_location: "require_location";
77
+ require_device: "require_device";
78
+ require_network: "require_network";
79
+ require_contract: "require_contract";
80
+ step_up: "step_up";
81
+ second_approver: "second_approver";
82
+ quorum: "quorum";
83
+ authenticate: "authenticate";
84
+ }>;
85
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
86
+ }, z.core.$strict>;
87
+ export type Obligation = z.infer<typeof ObligationSchema>;
88
+ export declare const ObligationStateValueSchema: z.ZodEnum<{
89
+ satisfied: "satisfied";
90
+ pending: "pending";
91
+ failed: "failed";
92
+ not_applicable: "not_applicable";
93
+ }>;
94
+ export type ObligationStateValue = z.infer<typeof ObligationStateValueSchema>;
95
+ /** Outcome rules reported on each obligation state. */
96
+ export declare const ObligationRuleSchema: z.ZodEnum<{
97
+ OBLIGATION_SATISFIED: "OBLIGATION_SATISFIED";
98
+ PENDING_POST_ACTION: "PENDING_POST_ACTION";
99
+ PENDING_TIME: "PENDING_TIME";
100
+ PENDING_HUMAN: "PENDING_HUMAN";
101
+ OBLIGATION_PARAMS_INVALID: "OBLIGATION_PARAMS_INVALID";
102
+ COUNTERPARTY_UNVERIFIED: "COUNTERPARTY_UNVERIFIED";
103
+ RESOURCE_NOT_COVERED: "RESOURCE_NOT_COVERED";
104
+ OBLIGATION_VERIFIER_UNAVAILABLE: "OBLIGATION_VERIFIER_UNAVAILABLE";
105
+ }>;
106
+ export type ObligationRule = z.infer<typeof ObligationRuleSchema>;
107
+ export declare const ObligationStateSchema: z.ZodObject<{
108
+ obligationType: z.ZodEnum<{
109
+ log: "log";
110
+ retain_receipt: "retain_receipt";
111
+ notify: "notify";
112
+ delay: "delay";
113
+ cooling_period: "cooling_period";
114
+ delete_after_use: "delete_after_use";
115
+ redact: "redact";
116
+ encrypt: "encrypt";
117
+ tokenize: "tokenize";
118
+ minimize: "minimize";
119
+ verify_counterparty: "verify_counterparty";
120
+ verify_resource: "verify_resource";
121
+ verify_effect: "verify_effect";
122
+ attest_runtime: "attest_runtime";
123
+ require_consent: "require_consent";
124
+ require_location: "require_location";
125
+ require_device: "require_device";
126
+ require_network: "require_network";
127
+ require_contract: "require_contract";
128
+ step_up: "step_up";
129
+ second_approver: "second_approver";
130
+ quorum: "quorum";
131
+ authenticate: "authenticate";
132
+ }>;
133
+ state: z.ZodEnum<{
134
+ satisfied: "satisfied";
135
+ pending: "pending";
136
+ failed: "failed";
137
+ not_applicable: "not_applicable";
138
+ }>;
139
+ rule: z.ZodEnum<{
140
+ OBLIGATION_SATISFIED: "OBLIGATION_SATISFIED";
141
+ PENDING_POST_ACTION: "PENDING_POST_ACTION";
142
+ PENDING_TIME: "PENDING_TIME";
143
+ PENDING_HUMAN: "PENDING_HUMAN";
144
+ OBLIGATION_PARAMS_INVALID: "OBLIGATION_PARAMS_INVALID";
145
+ COUNTERPARTY_UNVERIFIED: "COUNTERPARTY_UNVERIFIED";
146
+ RESOURCE_NOT_COVERED: "RESOURCE_NOT_COVERED";
147
+ OBLIGATION_VERIFIER_UNAVAILABLE: "OBLIGATION_VERIFIER_UNAVAILABLE";
148
+ }>;
149
+ detail: z.ZodOptional<z.ZodString>;
150
+ dueEpochMs: z.ZodOptional<z.ZodNumber>;
151
+ }, z.core.$strict>;
152
+ export type ObligationState = z.infer<typeof ObligationStateSchema>;
153
+ export type ObligationPhase = "decision" | "human" | "post_action" | "time" | "unwired";
154
+ export declare function obligationPhase(type: ObligationType): ObligationPhase;
155
+ export declare function isHumanFacingObligation(type: ObligationType): boolean;
156
+ /** True for pending obligations the sweeper completes when due time passes. */
157
+ export declare function isTimeElapsedObligation(type: ObligationType): boolean;
158
+ /** True for obligations that run as recorded parameter transforms. */
159
+ export declare function isTransformObligation(type: ObligationType): boolean;
160
+ /** Read-only facts the evaluator may consult. It cannot mutate or mint. */
161
+ export type ObligationContext = Readonly<{
162
+ nowEpochMs: number;
163
+ /** The action's declared counterparty (merchant) label, if any. */
164
+ merchantId?: string | undefined;
165
+ /** The action's resource ref. */
166
+ resource: string;
167
+ /** Counterparties declared on the enclosing intent (absent = none declared). */
168
+ intentCounterparties?: readonly string[] | undefined;
169
+ /** Resources declared on the enclosing intent (absent = unconstrained). */
170
+ intentResources?: readonly string[] | undefined;
171
+ /** True when the narrowed authority chain still covers this action. */
172
+ chainCoversAction: boolean;
173
+ }>;
174
+ export declare function positiveIntParam(params: ObligationParams | undefined, key: string): number | null;
175
+ export declare function stringArrayParam(params: ObligationParams | undefined, key: string): readonly string[] | null;
176
+ export declare function stringParam(params: ObligationParams | undefined, key: string): string | null;
177
+ /**
178
+ * Pure obligation evaluation. Deterministic and read-only: identical inputs
179
+ * always produce identical states and the evaluator issues no authority.
180
+ */
181
+ export declare function evaluateObligation(obligation: Obligation, context: ObligationContext): ObligationState;
182
+ /**
183
+ * Deterministically evaluate every declared obligation, in declared order.
184
+ */
185
+ export declare function evaluateObligations(obligations: readonly Obligation[], context: ObligationContext): readonly ObligationState[];
186
+ /** First failed state, if any — a failed/unsettleable obligation denies. */
187
+ export declare function firstFailedObligation(states: readonly ObligationState[]): ObligationState | null;
188
+ /**
189
+ * Human-facing obligations raise the WO-019 approval requirement. This
190
+ * composes step_up → requiredFactor and second_approver/quorum →
191
+ * requiredApprovals; it never lowers an existing requirement.
192
+ */
193
+ export declare function obligationApprovalRequirement(obligations: readonly Obligation[]): {
194
+ requiredFactor?: StepUpLevel;
195
+ requiredApprovals?: number;
196
+ };
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import type { IntentContract } from "./intent.js";
3
+ /**
4
+ * WO-022: guardian.plan.v1 — Plan Authority.
5
+ *
6
+ * A plan is a PROPOSAL, never authority. It decomposes an intent into an
7
+ * ordered task graph; submitting one enlarges nothing. The gateway's
8
+ * intent pre-gate uses plan task membership only to bind taskId → plan →
9
+ * intent provenance. Scope validation (validatePlanAgainstIntent) runs at
10
+ * submission so a plan cannot even propose work outside its intent.
11
+ */
12
+ export declare const PLAN_CONTRACT_SCHEMA = "guardian.plan.v1";
13
+ export declare const PlanStatusSchema: z.ZodEnum<{
14
+ draft: "draft";
15
+ active: "active";
16
+ revoked: "revoked";
17
+ completed: "completed";
18
+ }>;
19
+ export type PlanStatus = z.infer<typeof PlanStatusSchema>;
20
+ export declare const PlanNodeSchema: z.ZodObject<{
21
+ taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
22
+ title: z.ZodString;
23
+ actionFamily: z.ZodOptional<z.ZodString>;
24
+ actionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ agentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
26
+ dependsOn: z.ZodArray<z.core.$ZodBranded<z.ZodString, "TaskId", "out">>;
27
+ }, z.core.$strict>;
28
+ export type PlanNode = z.infer<typeof PlanNodeSchema>;
29
+ export declare const PlanContractSchema: z.ZodObject<{
30
+ schema: z.ZodLiteral<"guardian.plan.v1">;
31
+ planId: z.core.$ZodBranded<z.ZodString, "PlanId", "out">;
32
+ intentId: z.core.$ZodBranded<z.ZodString, "IntentId", "out">;
33
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
34
+ principalId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
35
+ createdBy: z.ZodString;
36
+ title: z.ZodString;
37
+ nodes: z.ZodArray<z.ZodObject<{
38
+ taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
39
+ title: z.ZodString;
40
+ actionFamily: z.ZodOptional<z.ZodString>;
41
+ actionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
42
+ agentId: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
43
+ dependsOn: z.ZodArray<z.core.$ZodBranded<z.ZodString, "TaskId", "out">>;
44
+ }, z.core.$strict>>;
45
+ status: z.ZodEnum<{
46
+ draft: "draft";
47
+ active: "active";
48
+ revoked: "revoked";
49
+ completed: "completed";
50
+ }>;
51
+ version: z.ZodNumber;
52
+ createdAtEpochMs: z.ZodNumber;
53
+ }, z.core.$strict>;
54
+ export type PlanContract = z.infer<typeof PlanContractSchema>;
55
+ export type PlanValidationFailure = "PLAN_DUPLICATE_TASK" | "PLAN_UNKNOWN_DEPENDENCY" | "PLAN_FORWARD_DEPENDENCY" | "PLAN_CYCLE";
56
+ /** Structural DAG validation: unique taskIds, resolvable backward-only
57
+ * dependsOn references, acyclic. */
58
+ export declare function validatePlanDag(nodes: readonly PlanNode[]): PlanValidationFailure | null;
59
+ export type PlanScopeFailure = "PLAN_TASK_FAMILY_OUT_OF_SCOPE" | "PLAN_TASK_ACTIONS_OUT_OF_SCOPE" | "PLAN_TASK_AGENT_UNAUTHORIZED";
60
+ /**
61
+ * Every task a plan proposes must fit inside the intent: declared families
62
+ * must be in allowedActionFamilies (when the intent constrains them), and
63
+ * declared agents must be in authorizedAgents.
64
+ */
65
+ export declare function validatePlanAgainstIntent(plan: Pick<PlanContract, "nodes">, intent: Pick<IntentContract, "allowedActionFamilies" | "authorizedAgents">): PlanScopeFailure | null;
66
+ /** Whether any active plan contains the given taskId. */
67
+ export declare function planContainsTask(plan: Pick<PlanContract, "nodes" | "status">, taskId: string): boolean;