@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
@@ -14,6 +14,14 @@ export declare const ConnectionIdSchema: z.core.$ZodBranded<z.ZodString, "Connec
14
14
  export declare const AttemptIdSchema: z.core.$ZodBranded<z.ZodString, "AttemptId", "out">;
15
15
  export declare const BudgetIdSchema: z.core.$ZodBranded<z.ZodString, "BudgetId", "out">;
16
16
  export declare const TaskIdSchema: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
17
+ export declare const PauseIdSchema: z.core.$ZodBranded<z.ZodString, "PauseId", "out">;
18
+ export declare const ScopeIdSchema: z.core.$ZodBranded<z.ZodString, "ScopeId", "out">;
19
+ export declare const MembershipIdSchema: z.core.$ZodBranded<z.ZodString, "MembershipId", "out">;
20
+ export declare const IntentIdSchema: z.core.$ZodBranded<z.ZodString, "IntentId", "out">;
21
+ export declare const PlanIdSchema: z.core.$ZodBranded<z.ZodString, "PlanId", "out">;
22
+ export declare const DataObjectIdSchema: z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">;
23
+ export declare const LineageEventIdSchema: z.core.$ZodBranded<z.ZodString, "LineageEventId", "out">;
24
+ export declare const TransactionIdSchema: z.core.$ZodBranded<z.ZodString, "TransactionId", "out">;
17
25
  export declare const NonceSchema: z.core.$ZodBranded<z.ZodString, "Nonce", "out">;
18
26
  export type TenantId = z.infer<typeof TenantIdSchema>;
19
27
  export type PrincipalId = z.infer<typeof PrincipalIdSchema>;
@@ -30,4 +38,12 @@ export type ConnectionId = z.infer<typeof ConnectionIdSchema>;
30
38
  export type AttemptId = z.infer<typeof AttemptIdSchema>;
31
39
  export type BudgetId = z.infer<typeof BudgetIdSchema>;
32
40
  export type TaskId = z.infer<typeof TaskIdSchema>;
41
+ export type PauseId = z.infer<typeof PauseIdSchema>;
42
+ export type ScopeId = z.infer<typeof ScopeIdSchema>;
43
+ export type MembershipId = z.infer<typeof MembershipIdSchema>;
44
+ export type IntentId = z.infer<typeof IntentIdSchema>;
45
+ export type PlanId = z.infer<typeof PlanIdSchema>;
46
+ export type DataObjectId = z.infer<typeof DataObjectIdSchema>;
47
+ export type LineageEventId = z.infer<typeof LineageEventIdSchema>;
48
+ export type TransactionId = z.infer<typeof TransactionIdSchema>;
33
49
  export type Nonce = z.infer<typeof NonceSchema>;
@@ -1,19 +1,41 @@
1
1
  export * from "./action.js";
2
+ export * from "./action-pack.js";
2
3
  export * from "./action-registry.js";
4
+ export * from "./agent-state.js";
3
5
  export * from "./api.js";
4
6
  export * from "./action-parameters.js";
7
+ export * from "./assurance.js";
5
8
  export * from "./approval.js";
6
9
  export * from "./authority.js";
7
10
  export * from "./authority-state.js";
11
+ export * from "./authority-graph.js";
12
+ export * from "./billing.js";
8
13
  export * from "./calendar.js";
9
14
  export * from "./canonical-json.js";
10
15
  export * from "./capability.js";
11
16
  export * from "./commerce.js";
17
+ export * from "./denial.js";
12
18
  export * from "./digest.js";
13
19
  export * from "./identifiers.js";
20
+ export * from "./intent.js";
21
+ export * from "./lineage.js";
14
22
  export * from "./evidence.js";
23
+ export * from "./plan.js";
24
+ export * from "./policy-simulation.js";
25
+ export * from "./receipt.js";
15
26
  export * from "./tools.js";
27
+ export * from "./transaction.js";
16
28
  export * from "./email.js";
17
29
  export * from "./execution.js";
18
30
  export * from "./files.js";
31
+ export * from "./local.js";
32
+ export * from "./multi-principal.js";
33
+ export * from "./multiparty.js";
34
+ export * from "./obligation.js";
35
+ export * from "./prerequisite.js";
19
36
  export * from "./protected-data.js";
37
+ export * from "./safety-envelope.js";
38
+ export * from "./sequence.js";
39
+ export * from "./sources.js";
40
+ export * from "./resource-claims.js";
41
+ export * from "./runtime.js";
@@ -0,0 +1,335 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * WO-022: guardian.intent.v1 — first-class Intent Authority.
4
+ *
5
+ * An intent is a human-authored container that NARROWS what an agent may do
6
+ * for a bounded objective: which agents may act, which action families,
7
+ * which resources and counterparties, and how much value/activity the
8
+ * container may commit. Intents never enlarge authority — the gateway
9
+ * pre-gate intersects the intent's allowlists with the agent's existing
10
+ * authority chain, so an empty intersection denies. An intent is a
11
+ * declarative input to the one authority kernel (directive §89, K15);
12
+ * it grants no authority of its own.
13
+ *
14
+ * `obligations` and `prerequisites` are WO-023 declarative inputs
15
+ * (guardian.obligation.v1 / guardian.prerequisite.v1): they are evaluated
16
+ * deterministically at the gateway pre-gate — a failed or unsettleable
17
+ * entry denies, human-facing entries route through the existing ASK
18
+ * machinery, and nothing here ever enlarges authority.
19
+ * `dataBudget`/`networkBudget` are tracked-only counters — they are
20
+ * recorded at capability issue but do not deny.
21
+ */
22
+ export declare const INTENT_CONTRACT_SCHEMA = "guardian.intent.v1";
23
+ export declare const IntentStatusSchema: z.ZodEnum<{
24
+ draft: "draft";
25
+ active: "active";
26
+ revoked: "revoked";
27
+ expired: "expired";
28
+ paused: "paused";
29
+ completed: "completed";
30
+ }>;
31
+ export type IntentStatus = z.infer<typeof IntentStatusSchema>;
32
+ export declare function canTransitionIntent(from: IntentStatus, to: IntentStatus): boolean;
33
+ /** Absolute denials match an action id exactly or `family:<name>`. */
34
+ export declare const AbsoluteDenialSchema: z.ZodString;
35
+ /** Per-kind protected_data caps inside an intent (subset of §7 protected_data_rules). */
36
+ export declare const IntentProtectedDataRuleSchema: z.ZodObject<{
37
+ kind: z.ZodEnum<{
38
+ view: "view";
39
+ use: "use";
40
+ disclose: "disclose";
41
+ persist: "persist";
42
+ }>;
43
+ maxCount: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strict>;
45
+ export type IntentProtectedDataRule = z.infer<typeof IntentProtectedDataRuleSchema>;
46
+ export declare const IntentContractSchema: z.ZodObject<{
47
+ schema: z.ZodLiteral<"guardian.intent.v1">;
48
+ intentId: z.core.$ZodBranded<z.ZodString, "IntentId", "out">;
49
+ tenantId: z.core.$ZodBranded<z.ZodString, "TenantId", "out">;
50
+ principal: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
51
+ title: z.ZodString;
52
+ purpose: z.ZodString;
53
+ desiredOutcome: z.ZodString;
54
+ start: z.ZodNumber;
55
+ expires: z.ZodNumber;
56
+ authorizedAgents: z.ZodArray<z.core.$ZodBranded<z.ZodString, "AgentId", "out">>;
57
+ allowedActionFamilies: z.ZodArray<z.ZodString>;
58
+ allowedResources: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "ResourceRef", "out">>>;
59
+ counterparties: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ moneyBudgetCents: z.ZodOptional<z.ZodNumber>;
61
+ toolBudget: z.ZodOptional<z.ZodNumber>;
62
+ timeBudgetMs: z.ZodOptional<z.ZodNumber>;
63
+ dataBudget: z.ZodOptional<z.ZodNumber>;
64
+ networkBudget: z.ZodOptional<z.ZodNumber>;
65
+ protectedDataRules: z.ZodOptional<z.ZodArray<z.ZodObject<{
66
+ kind: z.ZodEnum<{
67
+ view: "view";
68
+ use: "use";
69
+ disclose: "disclose";
70
+ persist: "persist";
71
+ }>;
72
+ maxCount: z.ZodOptional<z.ZodNumber>;
73
+ }, z.core.$strict>>>;
74
+ delegationDepth: z.ZodOptional<z.ZodNumber>;
75
+ obligations: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
76
+ type: z.ZodEnum<{
77
+ log: "log";
78
+ retain_receipt: "retain_receipt";
79
+ notify: "notify";
80
+ delay: "delay";
81
+ cooling_period: "cooling_period";
82
+ delete_after_use: "delete_after_use";
83
+ redact: "redact";
84
+ encrypt: "encrypt";
85
+ tokenize: "tokenize";
86
+ minimize: "minimize";
87
+ verify_counterparty: "verify_counterparty";
88
+ verify_resource: "verify_resource";
89
+ verify_effect: "verify_effect";
90
+ attest_runtime: "attest_runtime";
91
+ require_consent: "require_consent";
92
+ require_location: "require_location";
93
+ require_device: "require_device";
94
+ require_network: "require_network";
95
+ require_contract: "require_contract";
96
+ step_up: "step_up";
97
+ second_approver: "second_approver";
98
+ quorum: "quorum";
99
+ authenticate: "authenticate";
100
+ }>;
101
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
102
+ }, z.core.$strict>, z.ZodPipe<z.ZodEnum<{
103
+ log: "log";
104
+ retain_receipt: "retain_receipt";
105
+ notify: "notify";
106
+ delay: "delay";
107
+ cooling_period: "cooling_period";
108
+ delete_after_use: "delete_after_use";
109
+ redact: "redact";
110
+ encrypt: "encrypt";
111
+ tokenize: "tokenize";
112
+ minimize: "minimize";
113
+ verify_counterparty: "verify_counterparty";
114
+ verify_resource: "verify_resource";
115
+ verify_effect: "verify_effect";
116
+ attest_runtime: "attest_runtime";
117
+ require_consent: "require_consent";
118
+ require_location: "require_location";
119
+ require_device: "require_device";
120
+ require_network: "require_network";
121
+ require_contract: "require_contract";
122
+ step_up: "step_up";
123
+ second_approver: "second_approver";
124
+ quorum: "quorum";
125
+ authenticate: "authenticate";
126
+ }>, z.ZodTransform<{
127
+ type: "log" | "retain_receipt" | "notify" | "delay" | "cooling_period" | "delete_after_use" | "redact" | "encrypt" | "tokenize" | "minimize" | "verify_counterparty" | "verify_resource" | "verify_effect" | "attest_runtime" | "require_consent" | "require_location" | "require_device" | "require_network" | "require_contract" | "step_up" | "second_approver" | "quorum" | "authenticate";
128
+ }, "log" | "retain_receipt" | "notify" | "delay" | "cooling_period" | "delete_after_use" | "redact" | "encrypt" | "tokenize" | "minimize" | "verify_counterparty" | "verify_resource" | "verify_effect" | "attest_runtime" | "require_consent" | "require_location" | "require_device" | "require_network" | "require_contract" | "step_up" | "second_approver" | "quorum" | "authenticate">>]>>;
129
+ prerequisites: z.ZodOptional<z.ZodArray<z.ZodObject<{
130
+ id: z.ZodString;
131
+ type: z.ZodEnum<{
132
+ merchant_verified: "merchant_verified";
133
+ counterparty_verified: "counterparty_verified";
134
+ budget_available: "budget_available";
135
+ capability_present: "capability_present";
136
+ address_authority: "address_authority";
137
+ human_approval: "human_approval";
138
+ }>;
139
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
140
+ }, z.core.$strict>>>;
141
+ sequences: z.ZodOptional<z.ZodArray<z.ZodObject<{
142
+ id: z.ZodString;
143
+ a: z.ZodOptional<z.ZodObject<{
144
+ action: z.ZodOptional<z.ZodString>;
145
+ resource: z.ZodOptional<z.ZodString>;
146
+ counterparty: z.ZodOptional<z.ZodString>;
147
+ }, z.core.$strict>>;
148
+ b: z.ZodOptional<z.ZodObject<{
149
+ action: z.ZodOptional<z.ZodString>;
150
+ resource: z.ZodOptional<z.ZodString>;
151
+ counterparty: z.ZodOptional<z.ZodString>;
152
+ }, z.core.$strict>>;
153
+ combinator: z.ZodEnum<{
154
+ then: "then";
155
+ plus: "plus";
156
+ within_minutes: "within_minutes";
157
+ using_result_of: "using_result_of";
158
+ affecting_resource_of: "affecting_resource_of";
159
+ after_protected_data: "after_protected_data";
160
+ }>;
161
+ windowMinutes: z.ZodOptional<z.ZodNumber>;
162
+ effect: z.ZodEnum<{
163
+ deny: "deny";
164
+ require_approval: "require_approval";
165
+ }>;
166
+ }, z.core.$strict>>>;
167
+ lineage: z.ZodOptional<z.ZodObject<{
168
+ maxClassification: z.ZodOptional<z.ZodEnum<{
169
+ financial: "financial";
170
+ internal: "internal";
171
+ public: "public";
172
+ pii: "pii";
173
+ phi: "phi";
174
+ credential: "credential";
175
+ confidential: "confidential";
176
+ }>>;
177
+ requireApprovalAbove: z.ZodOptional<z.ZodEnum<{
178
+ financial: "financial";
179
+ internal: "internal";
180
+ public: "public";
181
+ pii: "pii";
182
+ phi: "phi";
183
+ credential: "credential";
184
+ confidential: "confidential";
185
+ }>>;
186
+ }, z.core.$strict>>;
187
+ runtime: z.ZodOptional<z.ZodObject<{
188
+ minLevel: z.ZodOptional<z.ZodEnum<{
189
+ T0_UNKNOWN: "T0_UNKNOWN";
190
+ T1_IDENTIFIED: "T1_IDENTIFIED";
191
+ T2_VERIFIED: "T2_VERIFIED";
192
+ T3_ATTESTED: "T3_ATTESTED";
193
+ T4_HARDWARE_BACKED: "T4_HARDWARE_BACKED";
194
+ }>>;
195
+ requireApprovalBelow: z.ZodOptional<z.ZodEnum<{
196
+ T0_UNKNOWN: "T0_UNKNOWN";
197
+ T1_IDENTIFIED: "T1_IDENTIFIED";
198
+ T2_VERIFIED: "T2_VERIFIED";
199
+ T3_ATTESTED: "T3_ATTESTED";
200
+ T4_HARDWARE_BACKED: "T4_HARDWARE_BACKED";
201
+ }>>;
202
+ }, z.core.$strict>>;
203
+ approvalStructure: z.ZodOptional<z.ZodObject<{
204
+ schema: z.ZodLiteral<"guardian.multiparty.v1">;
205
+ structureId: z.ZodString;
206
+ members: z.ZodArray<z.ZodObject<{
207
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
208
+ roles: z.ZodOptional<z.ZodArray<z.ZodString>>;
209
+ }, z.core.$strict>>;
210
+ requirement: z.ZodDiscriminatedUnion<[z.ZodObject<{
211
+ kind: z.ZodLiteral<"single">;
212
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
213
+ }, z.core.$strict>, z.ZodObject<{
214
+ kind: z.ZodLiteral<"nOfM">;
215
+ n: z.ZodNumber;
216
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ kind: z.ZodLiteral<"unanimous">;
219
+ members: z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>;
220
+ }, z.core.$strict>, z.ZodObject<{
221
+ kind: z.ZodLiteral<"roleQuorum">;
222
+ role: z.ZodString;
223
+ n: z.ZodNumber;
224
+ m: z.ZodNumber;
225
+ }, z.core.$strict>], "kind">;
226
+ specificRequired: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
227
+ veto: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
228
+ separationOfDuties: z.ZodOptional<z.ZodObject<{
229
+ mutuallyExclusive: z.ZodArray<z.ZodArray<z.ZodString>>;
230
+ }, z.core.$strict>>;
231
+ temporaryApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
232
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
233
+ expiresAtEpochMs: z.ZodNumber;
234
+ }, z.core.$strict>>>;
235
+ delegatedApprovers: z.ZodOptional<z.ZodArray<z.ZodObject<{
236
+ memberId: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
237
+ delegatedBy: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
238
+ }, z.core.$strict>>>;
239
+ emergencyApprovers: z.ZodOptional<z.ZodArray<z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">>>;
240
+ coolingPeriod: z.ZodOptional<z.ZodObject<{
241
+ seconds: z.ZodNumber;
242
+ }, z.core.$strict>>;
243
+ }, z.core.$strict>>;
244
+ authoritySources: z.ZodOptional<z.ZodArray<z.ZodString>>;
245
+ transaction: z.ZodOptional<z.ZodObject<{
246
+ schema: z.ZodLiteral<"guardian.transaction.v1">;
247
+ stages: z.ZodArray<z.ZodEnum<{
248
+ PROPOSE: "PROPOSE";
249
+ PREPARE: "PREPARE";
250
+ AUTHORIZE: "AUTHORIZE";
251
+ LOCK: "LOCK";
252
+ COMMIT: "COMMIT";
253
+ VERIFY: "VERIFY";
254
+ SETTLE: "SETTLE";
255
+ }>>;
256
+ deadlineMs: z.ZodOptional<z.ZodNumber>;
257
+ }, z.core.$strict>>;
258
+ safetyEnvelope: z.ZodOptional<z.ZodObject<{
259
+ schema: z.ZodLiteral<"guardian.safety_envelope.v1">;
260
+ allowedZone: z.ZodOptional<z.ZodArray<z.ZodString>>;
261
+ forbiddenZone: z.ZodOptional<z.ZodArray<z.ZodString>>;
262
+ maxSpeed: z.ZodOptional<z.ZodNumber>;
263
+ maxForce: z.ZodOptional<z.ZodNumber>;
264
+ maxPayload: z.ZodOptional<z.ZodNumber>;
265
+ timeWindow: z.ZodOptional<z.ZodObject<{
266
+ startMinutesOfDay: z.ZodNumber;
267
+ endMinutesOfDay: z.ZodNumber;
268
+ }, z.core.$strict>>;
269
+ proximityConstraints: z.ZodOptional<z.ZodObject<{
270
+ minHumanDistance: z.ZodNumber;
271
+ }, z.core.$strict>>;
272
+ environmentConditions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
273
+ supervisionRequired: z.ZodOptional<z.ZodBoolean>;
274
+ failSafeAction: z.ZodOptional<z.ZodString>;
275
+ emergencyStop: z.ZodOptional<z.ZodBoolean>;
276
+ }, z.core.$strict>>;
277
+ absoluteDenials: z.ZodArray<z.ZodString>;
278
+ approvalPolicy: z.ZodEnum<{
279
+ default: "default";
280
+ always_ask: "always_ask";
281
+ }>;
282
+ authorityVersion: z.ZodNumber;
283
+ status: z.ZodEnum<{
284
+ draft: "draft";
285
+ active: "active";
286
+ revoked: "revoked";
287
+ expired: "expired";
288
+ paused: "paused";
289
+ completed: "completed";
290
+ }>;
291
+ version: z.ZodNumber;
292
+ createdAtEpochMs: z.ZodNumber;
293
+ updatedAtEpochMs: z.ZodNumber;
294
+ }, z.core.$strict>;
295
+ export type IntentContract = z.infer<typeof IntentContractSchema>;
296
+ export declare const IntentTransitionRequestSchema: z.ZodObject<{
297
+ to: z.ZodEnum<{
298
+ draft: "draft";
299
+ active: "active";
300
+ revoked: "revoked";
301
+ expired: "expired";
302
+ paused: "paused";
303
+ completed: "completed";
304
+ }>;
305
+ }, z.core.$strict>;
306
+ export type IntentTransitionRequest = z.infer<typeof IntentTransitionRequestSchema>;
307
+ /** Pure transition: returns the next contract or a reason code. */
308
+ export declare function transitionIntent(intent: IntentContract, to: IntentStatus, nowEpochMs: number): {
309
+ ok: true;
310
+ intent: IntentContract;
311
+ } | {
312
+ ok: false;
313
+ reasonCode: string;
314
+ };
315
+ /** Deterministic expiry: an active/paused intent past its expiry reads as expired. */
316
+ export declare function effectiveIntentStatus(intent: IntentContract, nowEpochMs: number): IntentStatus;
317
+ export type IntentPreGateFailure = "INTENT_NOT_FOUND" | "INTENT_TENANT_MISMATCH" | "INTENT_PRINCIPAL_MISMATCH" | "INTENT_NOT_ACTIVE" | "INTENT_NOT_YET_STARTED" | "INTENT_EXPIRED" | "INTENT_TIME_BUDGET_EXCEEDED" | "INTENT_AGENT_NOT_AUTHORIZED" | "INTENT_ACTION_DENIED" | "INTENT_DELEGATION_DEPTH_EXCEEDED" | "INTENT_TASK_NOT_IN_PLAN" | "INTENT_PROTECTED_DATA_DENIED" | "INTENT_BUDGET_EXCEEDED";
318
+ export interface IntentPreGateInput {
319
+ readonly intent: IntentContract | null;
320
+ readonly tenantId: string;
321
+ readonly principalId: string;
322
+ readonly agentId: string;
323
+ readonly actionId: string;
324
+ readonly actionFamily: string | null;
325
+ readonly nowEpochMs: number;
326
+ /** Delegation depth of the acting agent (0 = no parent chain). */
327
+ readonly agentDelegationDepth: number;
328
+ /** Plan task membership: when the action carries taskId, whether a plan
329
+ * under this intent contains that task; undefined = no plans exist. */
330
+ readonly taskInPlan: boolean | undefined;
331
+ /** For protected_data.* actions: the kind suffix (use|view|disclose|persist). */
332
+ readonly protectedDataKind: IntentProtectedDataRule["kind"] | null;
333
+ }
334
+ /** Pure pre-gate evaluator. Returns the failed rule name or null (pass). */
335
+ export declare function evaluateIntentPreGate(input: IntentPreGateInput): IntentPreGateFailure | null;
@@ -0,0 +1,218 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * WO-025: guardian.lineage.v1 — derived-data lineage contract
4
+ * (GUA-AUTHORITY-OS-001 §17–20).
5
+ *
6
+ * Every data object records a human/policy-declared classification plus the
7
+ * lineage that produced it (sources, derivations, declared transformation
8
+ * records). Propagation is pure and deterministic:
9
+ *
10
+ * effectiveClassification(object) =
11
+ * the recorded resultClassification of the object's declared
12
+ * transformation, when one exists;
13
+ * otherwise the maximum of its own declared classification and the
14
+ * effective classification of every recorded source.
15
+ *
16
+ * A model/agent assertion NEVER changes classification — the only path to a
17
+ * narrower result is a declared transformation record bound into the stored
18
+ * object (and into the material digest of the action that registered it).
19
+ * Missing lineage for a classified source fails closed.
20
+ */
21
+ export declare const LINEAGE_CONTRACT_SCHEMA = "guardian.lineage.v1";
22
+ /** Ordered data classification lattice (lowest → highest). */
23
+ export declare const DataClassificationSchema: z.ZodEnum<{
24
+ financial: "financial";
25
+ internal: "internal";
26
+ public: "public";
27
+ pii: "pii";
28
+ phi: "phi";
29
+ credential: "credential";
30
+ confidential: "confidential";
31
+ }>;
32
+ export type DataClassification = z.infer<typeof DataClassificationSchema>;
33
+ export declare const CLASSIFICATION_RANK: Record<DataClassification, number>;
34
+ export declare function maxClassification(a: DataClassification, b: DataClassification): DataClassification;
35
+ export declare function classificationExceeds(value: DataClassification, ceiling: DataClassification): boolean;
36
+ export declare const DataSensitivitySchema: z.ZodEnum<{
37
+ low: "low";
38
+ moderate: "moderate";
39
+ high: "high";
40
+ }>;
41
+ export type DataSensitivity = z.infer<typeof DataSensitivitySchema>;
42
+ /** A declared, policy-defined transformation record (§19). */
43
+ export declare const DataTransformationSchema: z.ZodObject<{
44
+ type: z.ZodString;
45
+ resultClassification: z.ZodEnum<{
46
+ financial: "financial";
47
+ internal: "internal";
48
+ public: "public";
49
+ pii: "pii";
50
+ phi: "phi";
51
+ credential: "credential";
52
+ confidential: "confidential";
53
+ }>;
54
+ }, z.core.$strict>;
55
+ export type DataTransformation = z.infer<typeof DataTransformationSchema>;
56
+ /** Upstream reference: another data object or the action that produced it. */
57
+ export declare const DataSourceRefSchema: z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">, z.core.$ZodBranded<z.ZodString, "RequestId", "out">]>;
58
+ export type DataSourceRef = z.infer<typeof DataSourceRefSchema>;
59
+ export declare const DataObjectSchema: z.ZodObject<{
60
+ schema: z.ZodLiteral<"guardian.lineage.v1">;
61
+ dataObjectId: z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">;
62
+ owner: z.core.$ZodBranded<z.ZodString, "PrincipalId", "out">;
63
+ classification: z.ZodEnum<{
64
+ financial: "financial";
65
+ internal: "internal";
66
+ public: "public";
67
+ pii: "pii";
68
+ phi: "phi";
69
+ credential: "credential";
70
+ confidential: "confidential";
71
+ }>;
72
+ sources: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">, z.core.$ZodBranded<z.ZodString, "RequestId", "out">]>>>;
73
+ derivations: z.ZodDefault<z.ZodArray<z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">>>;
74
+ transformations: z.ZodDefault<z.ZodArray<z.ZodObject<{
75
+ type: z.ZodString;
76
+ resultClassification: z.ZodEnum<{
77
+ financial: "financial";
78
+ internal: "internal";
79
+ public: "public";
80
+ pii: "pii";
81
+ phi: "phi";
82
+ credential: "credential";
83
+ confidential: "confidential";
84
+ }>;
85
+ }, z.core.$strict>>>;
86
+ sensitivity: z.ZodEnum<{
87
+ low: "low";
88
+ moderate: "moderate";
89
+ high: "high";
90
+ }>;
91
+ authorizedUses: z.ZodDefault<z.ZodArray<z.ZodString>>;
92
+ authorizedDisclosures: z.ZodDefault<z.ZodArray<z.ZodString>>;
93
+ retentionSeconds: z.ZodOptional<z.ZodNumber>;
94
+ expiryEpochMs: z.ZodOptional<z.ZodNumber>;
95
+ createdAt: z.ZodNumber;
96
+ }, z.core.$strict>;
97
+ export type DataObject = z.infer<typeof DataObjectSchema>;
98
+ /** Lineage policy declared on guardian.intent.v1 (`lineage` field). */
99
+ export declare const LineagePolicySchema: z.ZodObject<{
100
+ maxClassification: z.ZodOptional<z.ZodEnum<{
101
+ financial: "financial";
102
+ internal: "internal";
103
+ public: "public";
104
+ pii: "pii";
105
+ phi: "phi";
106
+ credential: "credential";
107
+ confidential: "confidential";
108
+ }>>;
109
+ requireApprovalAbove: z.ZodOptional<z.ZodEnum<{
110
+ financial: "financial";
111
+ internal: "internal";
112
+ public: "public";
113
+ pii: "pii";
114
+ phi: "phi";
115
+ credential: "credential";
116
+ confidential: "confidential";
117
+ }>>;
118
+ }, z.core.$strict>;
119
+ export type LineagePolicy = z.infer<typeof LineagePolicySchema>;
120
+ export declare const LineageEventKindSchema: z.ZodEnum<{
121
+ transform: "transform";
122
+ derive: "derive";
123
+ export: "export";
124
+ share: "share";
125
+ violation: "violation";
126
+ }>;
127
+ export type LineageEventKind = z.infer<typeof LineageEventKindSchema>;
128
+ export declare const LineageEventSchema: z.ZodObject<{
129
+ lineageEventId: z.core.$ZodBranded<z.ZodString, "LineageEventId", "out">;
130
+ dataObjectId: z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">;
131
+ kind: z.ZodEnum<{
132
+ transform: "transform";
133
+ derive: "derive";
134
+ export: "export";
135
+ share: "share";
136
+ violation: "violation";
137
+ }>;
138
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
139
+ createdAt: z.ZodNumber;
140
+ }, z.core.$strict>;
141
+ export type LineageEvent = z.infer<typeof LineageEventSchema>;
142
+ export type LineageResolution = {
143
+ ok: true;
144
+ effectiveClassification: DataClassification;
145
+ sourceRefs: readonly DataSourceRef[];
146
+ expired: boolean;
147
+ } | {
148
+ ok: false;
149
+ reason: "missing";
150
+ dataObjectId: string;
151
+ } | {
152
+ ok: false;
153
+ reason: "cycle";
154
+ dataObjectId: string;
155
+ };
156
+ /**
157
+ * Resolve the effective classification of a data object over its recorded
158
+ * lineage. `resolve` is the read-only data-object port; it must return null
159
+ * for unrecorded ids so missing lineage fails closed.
160
+ */
161
+ export declare function effectiveClassification(object: DataObject, resolve: (dataObjectId: string) => DataObject | null | undefined, nowEpochMs: number): LineageResolution;
162
+ /**
163
+ * Async variant of `effectiveClassification` for the gateway: resolves the
164
+ * root object through the injected read-only port, then walks upstream.
165
+ * Missing lineage for a classified source fails closed ("missing").
166
+ */
167
+ export declare function resolveDataObjectLineage(dataObjectId: string, get: (id: string) => Promise<DataObject | null | undefined>, nowEpochMs: number): Promise<LineageResolution>;
168
+ export declare const LineageMatchOutcomeSchema: z.ZodObject<{
169
+ dataObjectId: z.core.$ZodBranded<z.ZodString, "DataObjectId", "out">;
170
+ effectiveClassification: z.ZodEnum<{
171
+ financial: "financial";
172
+ internal: "internal";
173
+ public: "public";
174
+ pii: "pii";
175
+ phi: "phi";
176
+ credential: "credential";
177
+ confidential: "confidential";
178
+ }>;
179
+ effect: z.ZodEnum<{
180
+ allowed: "allowed";
181
+ deny: "deny";
182
+ require_approval: "require_approval";
183
+ }>;
184
+ expired: z.ZodBoolean;
185
+ }, z.core.$strict>;
186
+ export type LineageMatchOutcome = z.infer<typeof LineageMatchOutcomeSchema>;
187
+ /**
188
+ * Evaluate a declared lineage policy over resolved objects. Pure: reports
189
+ * deny | require_approval | allowed with deterministic rule refs and never
190
+ * mutates authority.
191
+ */
192
+ export declare function evaluateLineagePolicy(policy: LineagePolicy | undefined, resolved: readonly {
193
+ dataObjectId: string;
194
+ resolution: LineageResolution;
195
+ }[]): {
196
+ verdict: "deny";
197
+ ruleId: string;
198
+ outcomes: LineageMatchOutcome[];
199
+ } | {
200
+ verdict: "require_approval";
201
+ ruleId: string;
202
+ outcomes: LineageMatchOutcome[];
203
+ } | {
204
+ verdict: "allowed";
205
+ outcomes: LineageMatchOutcome[];
206
+ };
207
+ /** Deterministic id for a data object registered by a derive/transform action. */
208
+ export declare function derivedDataObjectId(input: {
209
+ tenantId: string;
210
+ actionRef: string;
211
+ }): string;
212
+ /** Deterministic id for a recorded lineage event row. */
213
+ export declare function lineageEventId(input: {
214
+ tenantId: string;
215
+ actionRef: string;
216
+ dataObjectId: string;
217
+ kind: LineageEventKind;
218
+ }): string;