@agenticprimitives/delegation 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (84) hide show
  1. package/README.md +19 -2
  2. package/dist/authority-chain.d.ts +59 -0
  3. package/dist/authority-chain.d.ts.map +1 -0
  4. package/dist/authority-chain.js +70 -0
  5. package/dist/authority-chain.js.map +1 -0
  6. package/dist/caveats.d.ts +196 -1
  7. package/dist/caveats.d.ts.map +1 -1
  8. package/dist/caveats.js +374 -2
  9. package/dist/caveats.js.map +1 -1
  10. package/dist/client.d.ts +1 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +2 -2
  13. package/dist/client.js.map +1 -1
  14. package/dist/es256-evidence-minter.d.ts +28 -0
  15. package/dist/es256-evidence-minter.d.ts.map +1 -0
  16. package/dist/es256-evidence-minter.js +48 -0
  17. package/dist/es256-evidence-minter.js.map +1 -0
  18. package/dist/evaluator.d.ts +1 -1
  19. package/dist/evaluator.d.ts.map +1 -1
  20. package/dist/evaluator.js +102 -2
  21. package/dist/evaluator.js.map +1 -1
  22. package/dist/hash.d.ts +1 -1
  23. package/dist/hash.d.ts.map +1 -1
  24. package/dist/index.d.ts +40 -11
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +45 -8
  27. package/dist/index.js.map +1 -1
  28. package/dist/invocation-proof.d.ts +133 -0
  29. package/dist/invocation-proof.d.ts.map +1 -0
  30. package/dist/invocation-proof.js +157 -0
  31. package/dist/invocation-proof.js.map +1 -0
  32. package/dist/lineage.d.ts +70 -0
  33. package/dist/lineage.d.ts.map +1 -0
  34. package/dist/lineage.js +65 -0
  35. package/dist/lineage.js.map +1 -0
  36. package/dist/mandate-handlers.d.ts +15 -0
  37. package/dist/mandate-handlers.d.ts.map +1 -0
  38. package/dist/mandate-handlers.js +279 -0
  39. package/dist/mandate-handlers.js.map +1 -0
  40. package/dist/mandate.d.ts +265 -0
  41. package/dist/mandate.d.ts.map +1 -0
  42. package/dist/mandate.js +275 -0
  43. package/dist/mandate.js.map +1 -0
  44. package/dist/method-authorization.d.ts +120 -0
  45. package/dist/method-authorization.d.ts.map +1 -0
  46. package/dist/method-authorization.js +173 -0
  47. package/dist/method-authorization.js.map +1 -0
  48. package/dist/onchain.d.ts +40 -4
  49. package/dist/onchain.d.ts.map +1 -1
  50. package/dist/onchain.js +140 -6
  51. package/dist/onchain.js.map +1 -1
  52. package/dist/presentation-release.d.ts +94 -0
  53. package/dist/presentation-release.d.ts.map +1 -0
  54. package/dist/presentation-release.js +93 -0
  55. package/dist/presentation-release.js.map +1 -0
  56. package/dist/quorum.d.ts +26 -0
  57. package/dist/quorum.d.ts.map +1 -0
  58. package/dist/quorum.js +80 -0
  59. package/dist/quorum.js.map +1 -0
  60. package/dist/session-delegation.d.ts +34 -0
  61. package/dist/session-delegation.d.ts.map +1 -0
  62. package/dist/session-delegation.js +33 -0
  63. package/dist/session-delegation.js.map +1 -0
  64. package/dist/session-manager.d.ts +1 -2
  65. package/dist/session-manager.d.ts.map +1 -1
  66. package/dist/session-manager.js +15 -6
  67. package/dist/session-manager.js.map +1 -1
  68. package/dist/standing.d.ts +101 -0
  69. package/dist/standing.d.ts.map +1 -0
  70. package/dist/standing.js +132 -0
  71. package/dist/standing.js.map +1 -0
  72. package/dist/token.d.ts +89 -1
  73. package/dist/token.d.ts.map +1 -1
  74. package/dist/token.js +485 -123
  75. package/dist/token.js.map +1 -1
  76. package/dist/types.d.ts +141 -0
  77. package/dist/types.d.ts.map +1 -1
  78. package/dist/types.js +7 -1
  79. package/dist/types.js.map +1 -1
  80. package/dist/verify-authorization.d.ts +28 -0
  81. package/dist/verify-authorization.d.ts.map +1 -0
  82. package/dist/verify-authorization.js +73 -0
  83. package/dist/verify-authorization.js.map +1 -0
  84. package/package.json +25 -16
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandate-handlers.js","sourceRoot":"","sources":["../src/mandate-handlers.ts"],"names":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,CAAC,EAAE,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,EAAE;YAC5L,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF,CAAC;AAEF;2FAC2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAA8C,IAAI,GAAG,CAAC;IACxF,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC;IAC3C,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC;IACrC,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC;CAChD,CAAC,CAAC;AAEH,iGAAiG;AACjG,IAAI,UAAU,GAAG,KAAK,CAAC;AACvB,MAAM,UAAU,6BAA6B;IAC3C,IAAI,UAAU;QAAE,OAAO;IACvB,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACzC,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACtC,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;IAC3C,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC;AACD,qDAAqD;AACrD,MAAM,UAAU,yBAAyB,KAAW,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,265 @@
1
+ import { type Hex } from 'viem';
2
+ import type { Address, Caveat, Delegation, EnforcerAddressMap } from './types.js';
3
+ import { type MethodAuthorizationChecks } from './method-authorization.js';
4
+ import { type DigestBindingKind } from './caveats.js';
5
+ import { ROOT_AUTHORITY } from './types.js';
6
+ /**
7
+ * What authority a step NEEDS, in RFC 9396 `authorization_details` shape. A proposal: it grants nothing.
8
+ * `type` is collision-resistant and owns its own subset semantics via a registered handler.
9
+ */
10
+ export interface MandateRequirementV1 {
11
+ /** e.g. `urn:ap:rar:treasury.payment.execute`. Chooses the subset handler. */
12
+ type: string;
13
+ /** Capability-level actions, e.g. `['execute']`, `['add','remove']`. */
14
+ actions: string[];
15
+ /** Resources, as URNs / CAIP-10 — the treasury, the org, the team. */
16
+ locations?: string[];
17
+ /** Type-specific ceilings: `{ maxAmount: '500', currency: 'USDC' }`. Interpreted by the handler. */
18
+ limits?: Record<string, string | number>;
19
+ /** THE REASON. Digest of the canonical intent (§ intentDigest). Required — without it this is a capability. */
20
+ intentDigest: Hex;
21
+ /** What was disclosed to the grantee (spec 336 §4), when the mandate followed a projection. */
22
+ projectionDigest?: Hex;
23
+ /** The accepted offer (spec 336 §5), when the mandate followed an engagement. */
24
+ offerDigest?: Hex;
25
+ /** Spec 408 §2.3 — THE ADMITTED PLAN (`orchestration.planDigest`): the steps as written, tool ids and
26
+ * arguments with `$ref`s unresolved. Bound so a session holder cannot present a signed mandate for the
27
+ * same goal with a different plan, and so every step's arguments are a function of the plan the person
28
+ * saw and the results before it. Set whenever a requirement is raised from a parked run. */
29
+ planDigest?: Hex;
30
+ /** Spec 410 §7 — the information-flow caveat: what a write under this mandate may carry, as ontology classes.
31
+ * Raised from the tool contract's `carries` over the arguments the step presents; pinned into the signed wire. */
32
+ payloadClasses?: string[];
33
+ /** Unix seconds. */
34
+ validAfter?: number;
35
+ validUntil: number;
36
+ /**
37
+ * THE ON-CHAIN CALLS THIS AUTHORITY MAKES — real 4-byte EVM selectors, when the capability is exercised
38
+ * by redeeming this mandate against a contract.
39
+ *
40
+ * `actions` are CAPABILITY ids, and `methodSelector` turns each into a synthetic selector the OFF-CHAIN
41
+ * verifier compares. The `AllowedMethodsEnforcer` sees the actual transaction, so a mandate carrying
42
+ * only capability selectors reverts every real call with `MethodNotAllowed` — which is exactly what
43
+ * happened to `treasury.fund` through the Ask: the mandate verified, the person signed, and the chain
44
+ * refused a call the caveat had never been told to expect.
45
+ *
46
+ * WHO SAYS WHICH SELECTORS: the app that owns the call, never a planner and never the person — the
47
+ * bytes are a deployment fact. Listing them NARROWS nothing on its own (`allowedTargets` still bounds
48
+ * WHERE) but it is what makes the authority honest about WHAT it does, and the card can name it.
49
+ */
50
+ methods?: Hex[];
51
+ }
52
+ /** RFC 8785 JCS → keccak256. The ONE way an intent digest is computed, so grantor, verifier and receipt
53
+ * cannot disagree about which bytes were bound. */
54
+ export declare function intentDigest(intent: unknown): Hex;
55
+ /** The versions an intent was approved under. `ontologyManifestDigest` = `ONTOLOGY_MANIFEST_DIGEST` from
56
+ * `@agenticprimitives/ontology` (the T-box manifest, spec 410 §5); `semanticsDigest` = the `definitionDigest`
57
+ * of the compiled `AgentHarnessDefinitionV1` the act runs under (spec 354), which pins every tool contract
58
+ * and adapter declaration — or `NO_SEMANTICS_DIGEST` for the bare harness, which has no compiled definition. */
59
+ export interface VersionBindingV1 {
60
+ ontologyManifestDigest: Hex;
61
+ semanticsDigest: Hex;
62
+ /** Spec 410 §10 — the LOCAL MEANINGS the acting organization declared for common terms this intent uses
63
+ * (`ontology.meaningRef`: `meaning:<org>:<termIri>`), so a third party reading the receipt sees which meaning the
64
+ * grant used. Stated by the intent, bound by the digest; a verifier never substitutes them. */
65
+ meaningRefs?: string[];
66
+ }
67
+ /** The bare harness: no compiled definition to bind. Stated, never omitted, so the preimage shape is one. */
68
+ export declare const NO_SEMANTICS_DIGEST: Hex;
69
+ /** The intent with its versions folded in — what a Home mints a mandate over and what a verifier recomputes. */
70
+ export declare function withVersions<T extends object>(intent: T, versions: VersionBindingV1): T & {
71
+ versions: VersionBindingV1;
72
+ };
73
+ /** The versions an intent states, or null when it states none (a pre-spec-410 intent). */
74
+ export declare function versionsOf(intent: unknown): VersionBindingV1 | null;
75
+ /** The enforcer addresses a handler may encode caveats against. */
76
+ export type EnforcerAddresses = EnforcerAddressMap & {
77
+ digestBinding: Address;
78
+ };
79
+ /**
80
+ * One per `type`. RFC 9396: "there is no universal way to determine whether one authorization_details
81
+ * object is a subset of another" — so every type says for itself.
82
+ */
83
+ export interface MandateSubsetHandler {
84
+ type: string;
85
+ /** Is `child` ⊆ `parent`? Pure; deterministic. Must be conservative: unsure ⇒ false. */
86
+ isSubset(child: MandateRequirementV1, parent: MandateRequirementV1): boolean;
87
+ /** The caveats that ENFORCE the requirement on chain (not counting the digest bindings, added generically). */
88
+ toCaveats(req: MandateRequirementV1, enforcers: EnforcerAddresses): Caveat[];
89
+ /** Read the requirement back out of a delegation's caveats — for verification and for display. */
90
+ fromCaveats(caveats: readonly Caveat[], enforcers: EnforcerAddresses): Omit<MandateRequirementV1, 'intentDigest' | 'projectionDigest' | 'offerDigest'> | null;
91
+ /** The LIMITS a mandate would need to carry for this step to be within it — the type's own quantities,
92
+ * read off the step. Payment turns `{payee, asset, amount}` into a ceiling; the generic capability type
93
+ * bounds nothing beyond its actions and locations. Used when ASKING for authority (§3.6): a person
94
+ * granting a payment is granting an amount, and a requirement that omits it cannot be minted. */
95
+ stepLimits?(step: MandateStep): Record<string, string | number>;
96
+ /** What a step's ACTIONS are, in this type's vocabulary. A step carries both a capability id
97
+ * (`organization.team.create`) and a verb (`create`); which of them a mandate's `actions` name is the
98
+ * type's convention — the generic capability type grants capability IDS, the payment type grants the
99
+ * verb `execute`. Default: the verb. A type that grants ids overrides. */
100
+ stepActions?(step: MandateStep): string[];
101
+ /** Spec 408 §2.2 (R917-P-1) — THE ENFORCERS THIS HANDLER JUDGES ITSELF. `verifyMandateForStep` runs the
102
+ * caveat evaluator STRICTLY for a step that does not redeem on chain, so a caveat with no off-chain judge
103
+ * denies (`context-required`) — unless the handler declares that it compares that caveat's terms in
104
+ * `isSubset` (the payment handler bounds the PaymentEnforcer's payee/asset/amount itself). Those are
105
+ * recorded `judged-by-handler`, never `enforced-on-chain`. Default: none. */
106
+ judgesEnforcers?(enforcers: EnforcerAddresses): Address[];
107
+ }
108
+ /** The handlers a verification consults. Passed EXPLICITLY (`SubsetHandlers`) wherever possible: the
109
+ * ambient registry below is module-level state, and a bundle that ends up with two copies of this
110
+ * module has two registries — one that was registered into and one that is consulted. That is how a
111
+ * live verifier once answered "no handler" for a type its process had registered. */
112
+ export type SubsetHandlers = ReadonlyMap<string, MandateSubsetHandler>;
113
+ export declare function registerSubsetHandler(h: MandateSubsetHandler): void;
114
+ export declare function subsetHandlerFor(type: string, from?: SubsetHandlers): MandateSubsetHandler | null;
115
+ /** Test seam. */
116
+ export declare function _resetSubsetHandlers(): void;
117
+ /**
118
+ * The base rule every handler can build on: actions ⊆, locations ⊆ (when the parent names any),
119
+ * window ⊆, and the intent must be the SAME — a mandate for one intent never derives one for another.
120
+ */
121
+ export declare function baseIsSubset(child: MandateRequirementV1, parent: MandateRequirementV1): boolean;
122
+ export interface DeriveMandateInput {
123
+ /** The standing authority. Its hash becomes the child's `authority`, which is what makes it a CHAIN. */
124
+ parent: Delegation;
125
+ /** What the parent allows, as read by its handler. Supplied by the caller who resolved it (or read
126
+ * it with `readMandate`). */
127
+ parentRequirement: MandateRequirementV1;
128
+ /** What the child asks for. Must be ⊆ parent, per the handler, or this refuses. */
129
+ requirement: MandateRequirementV1;
130
+ grantee: Address;
131
+ enforcers: EnforcerAddresses;
132
+ chainId: number;
133
+ delegationManager: Address;
134
+ /** Random 128-bit salt; injected so a test can be deterministic. */
135
+ salt: bigint;
136
+ /** The handler set to consult. Defaults to the ambient registry. */
137
+ handlers?: SubsetHandlers;
138
+ }
139
+ export type DeriveMandateResult = {
140
+ ok: true;
141
+ delegation: Delegation;
142
+ digest: Hex;
143
+ } | {
144
+ ok: false;
145
+ reason: string;
146
+ };
147
+ /**
148
+ * A child mandate from a standing delegation. Unsigned: the caller signs `digest` with the parent's
149
+ * DELEGATE's credential (the party attenuating its own authority onward).
150
+ */
151
+ export declare function deriveMandate(input: DeriveMandateInput): DeriveMandateResult;
152
+ /** Read a mandate's requirement back out of a delegation, or null when it carries no intent binding —
153
+ * in which case it is a standing capability, not a mandate. */
154
+ export declare function readMandate(d: Delegation, type: string, enforcers: EnforcerAddresses, from?: SubsetHandlers): MandateRequirementV1 | null;
155
+ /** The step, as the verifier sees it. */
156
+ export interface MandateStep {
157
+ /** ADR-0051 capability id the step exercises, e.g. `treasury.payment.execute`. Its selector is what
158
+ * `allowedMethods` is checked against. */
159
+ capability: string;
160
+ action: string;
161
+ resource?: string;
162
+ /** The intent THIS RUN is acting under. Compared to the mandate's binding — this is the reason check. */
163
+ intent: unknown;
164
+ /** Optional: the projection / offer digests when the run followed an engagement. */
165
+ projectionDigest?: Hex;
166
+ offerDigest?: Hex;
167
+ /** Spec 408 §2.3 — the digest of the plan THIS RUN is executing (`orchestration.planDigest`). A mandate
168
+ * that binds a plan is refused for a step that presents none or another. */
169
+ planDigest?: Hex;
170
+ /** Spec 410 §7 — the ontology classes this step's write carries (the tool's `carries` over the args present). */
171
+ payloadClasses?: readonly string[];
172
+ /** Type-specific arguments the handler may bound (amount, payee…). */
173
+ args?: Record<string, unknown>;
174
+ /** For the `value` caveat. The ETH value this step sends; a step that sends none is judged at 0 — a known
175
+ * fact about the step, not an assumption about the caveat. */
176
+ value?: bigint;
177
+ /** Spec 408 §2.2 (R917-P-1) — does this step REDEEM the mandate on chain, where every enforcer fires?
178
+ * Only then may a caveat with no off-chain judge be recorded `enforced-on-chain`; every other step is
179
+ * judged strictly. Declared by the tool (`ToolSpec.capability.redeemsOnChain`), never by the planner. */
180
+ redeemsOnChain?: boolean;
181
+ }
182
+ export interface VerifyMandateInput {
183
+ /** The wire the caller presented. */
184
+ presented: Delegation;
185
+ /** The RAR type the step requires — selects the handler that judges type-specific limits. */
186
+ requirementType: string;
187
+ /** The party acting. MUST be the delegate. */
188
+ actor: Address;
189
+ step: MandateStep;
190
+ enforcers: EnforcerAddresses;
191
+ checks: MethodAuthorizationChecks;
192
+ /** Unix seconds; injected. */
193
+ now: number;
194
+ /** The handler set to consult. Defaults to the ambient registry — pass it explicitly in a bundle. */
195
+ handlers?: SubsetHandlers;
196
+ /** Spec 410 §5 — the versions THIS verifier runs with. When given, the intent digest is recomputed with
197
+ * these substituted for whatever the intent states, so a mandate approved under a moved T-box or a moved
198
+ * compiled definition is refused (`version-moved`, naming which). Absent ⇒ the intent is digested as
199
+ * presented (a runtime that has not adopted version binding). */
200
+ currentVersions?: VersionBindingV1;
201
+ }
202
+ export interface DecisionReason {
203
+ code: string;
204
+ message: string;
205
+ }
206
+ /** An UNSATISFIED condition attached to the authority. Not a UI prompt: a fact the mandate carries. */
207
+ export interface Obligation {
208
+ kind: 'second-party-approval' | 'quorum' | 'fresh-authorization' | 'disclosure' | (string & {});
209
+ dischargeableBy: {
210
+ role?: string;
211
+ agents?: Address[];
212
+ threshold?: number;
213
+ };
214
+ /** The policy or caveat that imposed it, by reference — so the record of discharge can name it. */
215
+ imposedBy: string;
216
+ }
217
+ export interface DecisionEvidence {
218
+ mandateRef: Hex;
219
+ intentDigest: Hex;
220
+ evaluatedAt: number;
221
+ /** Every caveat verdict, so a denial names the caveat and a permit is inspectable. */
222
+ verdicts: Array<{
223
+ enforcer: Address;
224
+ allowed: boolean;
225
+ reason?: string;
226
+ }>;
227
+ /** Spec 383 — THE CHAIN the leaf descends from, verified whole: every link by digest, the accountability
228
+ * root (the root delegator) and the acting agent (the leaf delegate). A root mandate is a chain of one. */
229
+ chain?: import('./authority-chain.js').AuthorityChainV1;
230
+ }
231
+ export type MandateDecision = {
232
+ decision: 'allow';
233
+ obligations: Obligation[];
234
+ evidence: DecisionEvidence;
235
+ } | {
236
+ decision: 'approval-required';
237
+ obligations: Obligation[];
238
+ evidence: DecisionEvidence;
239
+ } | {
240
+ decision: 'deny';
241
+ reasons: DecisionReason[];
242
+ evidence: DecisionEvidence;
243
+ };
244
+ /**
245
+ * Is THIS step covered by the presented mandate, RIGHT NOW?
246
+ *
247
+ * Order — and every stage fails closed:
248
+ * 1. the actor is the delegate;
249
+ * 2. the delegation is live: signed by its delegator, unrevoked, in window (verifyLiveDelegation);
250
+ * 3. it IS a mandate: it carries an intent binding, and that binding equals the digest computed from
251
+ * the step's intent — the reason check (evaluateCaveats with `digests`, strict); a plan binding, when
252
+ * the mandate carries one, must equal the plan this run is executing (spec 408 §2.3);
253
+ * 4. the step's capability selector satisfies allowedMethods, and its value the value cap — STRICTLY
254
+ * (spec 408 §2.2): a caveat no off-chain judge can answer denies, unless the step redeems on chain
255
+ * (`redeemsOnChain`, where the enforcer fires) or the type handler declares it judges that caveat;
256
+ * 5. the handler's type-specific limits admit the step's args.
257
+ *
258
+ * Obligations are NOT decided here — they come from policy (spec 350 §3.4) and are attached by the
259
+ * `MandateVerifier` port implementation that composes this with a `PolicyEvaluator`. This function
260
+ * answers one question: is the authority present and does it cover the step.
261
+ */
262
+ export declare function verifyMandateForStep(input: VerifyMandateInput): Promise<MandateDecision>;
263
+ export { ROOT_AUTHORITY };
264
+ export type { DigestBindingKind };
265
+ //# sourceMappingURL=mandate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandate.d.ts","sourceRoot":"","sources":["../src/mandate.ts"],"names":[],"mappings":"AAoBA,OAAO,EAA4B,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElF,OAAO,EAAwC,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEjH,OAAO,EAAgD,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACzC,+GAA+G;IAC/G,YAAY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,GACvB;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,GAC5E;IAAE,QAAQ,EAAE,mBAAmB,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,GACxF;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAIhF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAyG9F;AAsBD,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,275 @@
1
+ // Mandates — spec 350 §2 / spec 336 §8.3 + E4.
2
+ //
3
+ // A MANDATE IS A DELEGATION WITH A REASON. Not a new authority mechanism, not a token format, not a
4
+ // package of its own: a standing `Delegation` (EIP-712, ERC-1271-verified, on-chain revocable) whose
5
+ // caveats ALSO bind it to the digest of the intent it serves. `allowedMethods` + a window says WHAT the
6
+ // delegate may call; the intent binding says WHY, and a step whose intent differs is refused even though
7
+ // the method is identical. That is the whole difference between a standing capability and a mandate.
8
+ //
9
+ // This module is the missing half of spec 336 wave E4:
10
+ // • `MandateRequirementV1` — the RAR-shaped (RFC 9396) PROPOSAL a mandate is derived from. It grants
11
+ // nothing; it is what an offer can state openly and what a grantor approves.
12
+ // • the subset-handler registry — RFC 9396 is explicit that NO universal "narrower-than" exists across
13
+ // authorization-detail types, so each `type` registers its own `isSubset` / `toCaveats` / `fromCaveats`.
14
+ // • `deriveMandate` — a child delegation from a standing one. It refuses EARLY (via the handler) so a
15
+ // doomed child is never signed; the chain would refuse it anyway, because the child's `authority` is
16
+ // the parent's hash and DelegationManager evaluates the whole chain at redemption. Attenuation is a
17
+ // property of the representation, not a policy this file remembers to enforce.
18
+ // • `verifyMandateForStep` — THE per-step check. Called before every consequential step of a run, never
19
+ // once at admission, so a revocation between step 2 and step 3 stops step 3. Returns a decision with
20
+ // reasons; it never falls back to a weaker check (ADR-0013).
21
+ import { keccak256, stringToBytes } from 'viem';
22
+ import { jcsCanonicalize } from '@agenticprimitives/types';
23
+ import { hashDelegation } from './hash.js';
24
+ import { verifyLiveDelegation, methodSelector } from './method-authorization.js';
25
+ import { evaluateCaveats } from './evaluator.js';
26
+ import { buildDigestBindingCaveat, readDigestBindings } from './caveats.js';
27
+ import { ROOT_AUTHORITY } from './types.js';
28
+ /** RFC 8785 JCS → keccak256. The ONE way an intent digest is computed, so grantor, verifier and receipt
29
+ * cannot disagree about which bytes were bound. */
30
+ export function intentDigest(intent) {
31
+ return keccak256(stringToBytes(jcsCanonicalize(intent)));
32
+ }
33
+ /** The bare harness: no compiled definition to bind. Stated, never omitted, so the preimage shape is one. */
34
+ export const NO_SEMANTICS_DIGEST = `0x${'00'.repeat(32)}`;
35
+ /** The intent with its versions folded in — what a Home mints a mandate over and what a verifier recomputes. */
36
+ export function withVersions(intent, versions) {
37
+ const prior = intent.versions?.meaningRefs;
38
+ const meaningRefs = versions.meaningRefs ?? prior;
39
+ return { ...intent, versions: { ontologyManifestDigest: versions.ontologyManifestDigest, semanticsDigest: versions.semanticsDigest, ...(meaningRefs?.length ? { meaningRefs: [...meaningRefs].sort() } : {}) } };
40
+ }
41
+ /** The versions an intent states, or null when it states none (a pre-spec-410 intent). */
42
+ export function versionsOf(intent) {
43
+ const v = intent?.versions;
44
+ if (!v || typeof v !== 'object')
45
+ return null;
46
+ const ok = (x) => typeof x === 'string' && /^0x[0-9a-fA-F]{64}$/.test(x);
47
+ return ok(v.ontologyManifestDigest) && ok(v.semanticsDigest) ? { ontologyManifestDigest: v.ontologyManifestDigest, semanticsDigest: v.semanticsDigest, ...(Array.isArray(v.meaningRefs) && v.meaningRefs.length ? { meaningRefs: [...v.meaningRefs] } : {}) } : null;
48
+ }
49
+ const handlers = new Map();
50
+ export function registerSubsetHandler(h) {
51
+ if (handlers.has(h.type))
52
+ throw new Error(`registerSubsetHandler: a handler for ${h.type} is already registered`);
53
+ handlers.set(h.type, h);
54
+ }
55
+ export function subsetHandlerFor(type, from = handlers) {
56
+ return from.get(type) ?? null;
57
+ }
58
+ /** Test seam. */
59
+ export function _resetSubsetHandlers() { handlers.clear(); }
60
+ /**
61
+ * The base rule every handler can build on: actions ⊆, locations ⊆ (when the parent names any),
62
+ * window ⊆, and the intent must be the SAME — a mandate for one intent never derives one for another.
63
+ */
64
+ export function baseIsSubset(child, parent) {
65
+ if (child.type !== parent.type)
66
+ return false;
67
+ if (child.intentDigest.toLowerCase() !== parent.intentDigest.toLowerCase())
68
+ return false;
69
+ if (!child.actions.every((a) => parent.actions.includes(a)))
70
+ return false;
71
+ if (parent.locations?.length) {
72
+ // Locations are addresses / CAIP-10 accounts; viem checksums on decode, callers pass lowercase.
73
+ // Case is not identity.
74
+ const p = parent.locations.map((l) => l.toLowerCase());
75
+ if (!child.locations?.length)
76
+ return false;
77
+ if (!child.locations.every((l) => p.includes(l.toLowerCase())))
78
+ return false;
79
+ }
80
+ if ((child.validAfter ?? 0) < (parent.validAfter ?? 0))
81
+ return false;
82
+ if (child.validUntil > parent.validUntil)
83
+ return false;
84
+ return true;
85
+ }
86
+ /**
87
+ * A child mandate from a standing delegation. Unsigned: the caller signs `digest` with the parent's
88
+ * DELEGATE's credential (the party attenuating its own authority onward).
89
+ */
90
+ export function deriveMandate(input) {
91
+ const h = subsetHandlerFor(input.requirement.type, input.handlers);
92
+ if (!h)
93
+ return { ok: false, reason: `no subset handler registered for ${input.requirement.type} — refusing to derive an authority nobody can bound` };
94
+ if (input.requirement.type !== input.parentRequirement.type)
95
+ return { ok: false, reason: 'child and parent requirement types differ' };
96
+ if (!h.isSubset(input.requirement, input.parentRequirement)) {
97
+ return { ok: false, reason: `requested authority is not a subset of the parent's (${h.type})` };
98
+ }
99
+ const caveats = [
100
+ ...h.toCaveats(input.requirement, input.enforcers),
101
+ buildDigestBindingCaveat(input.enforcers.digestBinding, 'intent', input.requirement.intentDigest),
102
+ ...(input.requirement.projectionDigest ? [buildDigestBindingCaveat(input.enforcers.digestBinding, 'projection', input.requirement.projectionDigest)] : []),
103
+ ...(input.requirement.offerDigest ? [buildDigestBindingCaveat(input.enforcers.digestBinding, 'offer', input.requirement.offerDigest)] : []),
104
+ ...(input.requirement.planDigest ? [buildDigestBindingCaveat(input.enforcers.digestBinding, 'plan', input.requirement.planDigest)] : []),
105
+ ];
106
+ const delegation = {
107
+ delegator: input.parent.delegate, // the party attenuating ITS authority onward
108
+ delegate: input.grantee,
109
+ authority: hashDelegation(input.parent, input.chainId, input.delegationManager), // the chain link
110
+ caveats,
111
+ salt: input.salt,
112
+ signature: '0x',
113
+ };
114
+ return { ok: true, delegation, digest: hashDelegation(delegation, input.chainId, input.delegationManager) };
115
+ }
116
+ /** Read a mandate's requirement back out of a delegation, or null when it carries no intent binding —
117
+ * in which case it is a standing capability, not a mandate. */
118
+ export function readMandate(d, type, enforcers, from) {
119
+ const h = subsetHandlerFor(type, from);
120
+ if (!h)
121
+ return null;
122
+ const bindings = readDigestBindings(d.caveats, enforcers.digestBinding);
123
+ if (!bindings.intent)
124
+ return null;
125
+ const base = h.fromCaveats(d.caveats, enforcers);
126
+ if (!base)
127
+ return null;
128
+ return { ...base, intentDigest: bindings.intent, ...(bindings.projection ? { projectionDigest: bindings.projection } : {}), ...(bindings.offer ? { offerDigest: bindings.offer } : {}), ...(bindings.plan ? { planDigest: bindings.plan } : {}) };
129
+ }
130
+ const lc = (s) => s.toLowerCase();
131
+ /**
132
+ * Is THIS step covered by the presented mandate, RIGHT NOW?
133
+ *
134
+ * Order — and every stage fails closed:
135
+ * 1. the actor is the delegate;
136
+ * 2. the delegation is live: signed by its delegator, unrevoked, in window (verifyLiveDelegation);
137
+ * 3. it IS a mandate: it carries an intent binding, and that binding equals the digest computed from
138
+ * the step's intent — the reason check (evaluateCaveats with `digests`, strict); a plan binding, when
139
+ * the mandate carries one, must equal the plan this run is executing (spec 408 §2.3);
140
+ * 4. the step's capability selector satisfies allowedMethods, and its value the value cap — STRICTLY
141
+ * (spec 408 §2.2): a caveat no off-chain judge can answer denies, unless the step redeems on chain
142
+ * (`redeemsOnChain`, where the enforcer fires) or the type handler declares it judges that caveat;
143
+ * 5. the handler's type-specific limits admit the step's args.
144
+ *
145
+ * Obligations are NOT decided here — they come from policy (spec 350 §3.4) and are attached by the
146
+ * `MandateVerifier` port implementation that composes this with a `PolicyEvaluator`. This function
147
+ * answers one question: is the authority present and does it cover the step.
148
+ */
149
+ export async function verifyMandateForStep(input) {
150
+ const d = input.presented;
151
+ // Spec 410 §5 — recompute under the versions this verifier RUNS WITH, never the ones the intent states.
152
+ const cur = input.currentVersions;
153
+ const digestOfIntent = intentDigest(cur && input.step.intent && typeof input.step.intent === 'object' ? withVersions(input.step.intent, cur) : input.step.intent);
154
+ const evidence = {
155
+ mandateRef: input.checks.delegationDigest(d),
156
+ intentDigest: digestOfIntent,
157
+ evaluatedAt: input.now,
158
+ verdicts: [],
159
+ };
160
+ const deny = (code, message) => ({ decision: 'deny', reasons: [{ code, message }], evidence });
161
+ // 1. actor
162
+ if (lc(d.delegate) !== lc(input.actor))
163
+ return deny('actor-not-delegate', 'the acting party is not the mandate\'s delegate');
164
+ // 2. live
165
+ const live = await verifyLiveDelegation({ delegation: d, expectedDelegate: input.actor, enforcers: input.enforcers, checks: input.checks, now: input.now });
166
+ if (!live.ok)
167
+ return deny('not-live', live.reason);
168
+ // 3. it is a mandate, and the reason matches
169
+ const bindings = readDigestBindings(d.caveats, input.enforcers.digestBinding);
170
+ if (!bindings.intent)
171
+ return deny('not-a-mandate', 'the presented delegation carries no intent binding — it is a standing capability, and a step needs a mandate');
172
+ // Spec 410 §5 — A MOVED VERSION IS NAMED, not left as a bare digest mismatch. The intent states the versions it
173
+ // was approved under; if they differ from the ones this verifier runs with, the recomputed digest cannot
174
+ // match the binding, and the person is told which world moved so the re-approval is an informed one.
175
+ if (cur) {
176
+ const stated = versionsOf(input.step.intent);
177
+ const moved = [];
178
+ if (stated && lc(stated.ontologyManifestDigest) !== lc(cur.ontologyManifestDigest))
179
+ moved.push(`the ontology manifest (approved under ${stated.ontologyManifestDigest.slice(0, 12)}…, this runtime binds ${cur.ontologyManifestDigest.slice(0, 12)}…)`);
180
+ if (stated && lc(stated.semanticsDigest) !== lc(cur.semanticsDigest))
181
+ moved.push(`the compiled definition (approved under ${stated.semanticsDigest.slice(0, 12)}…, this runtime runs ${cur.semanticsDigest.slice(0, 12)}…)`);
182
+ if (moved.length)
183
+ return deny('version-moved', `the intent was approved under a version that has since moved: ${moved.join('; ')} — re-approve the same intent under the current versions`);
184
+ if (!stated)
185
+ return deny('version-unbound', 'this runtime binds the ontology and definition versions into every mandate, and the presented intent states none — re-approve the intent under the current versions');
186
+ }
187
+ // Spec 384 (336 §3.8) — A STEP THAT FULFILS AN ACCEPTED OFFER runs only under a mandate that NAMES that offer.
188
+ // The digest-binding caveat compares an `offer` binding when the mandate carries one; a mandate that
189
+ // carries none would pass the comparison by default, and that is exactly how an offer would become a
190
+ // commitment without the signature that accepted it. Required here, before the caveats are read.
191
+ if (input.step.offerDigest && !bindings.offer)
192
+ return deny('offer-not-bound', 'this step fulfils an accepted offer, and the presented mandate names no offer — an offer becomes a commitment only under the mandate that binds it');
193
+ if (input.step.projectionDigest && bindings.projection && lc(bindings.projection) !== lc(input.step.projectionDigest))
194
+ return deny('projection-mismatch', 'the mandate was granted over another projection of the intent');
195
+ // Spec 408 §2.3 — THE PLAN. A mandate that binds one was signed over THAT plan; a step from another plan
196
+ // (or from no plan the verifier was told of) is not what the person authorized, whatever its goal says.
197
+ if (bindings.plan && (!input.step.planDigest || lc(bindings.plan) !== lc(input.step.planDigest))) {
198
+ return deny('plan-mismatch', input.step.planDigest ? 'the mandate was granted over a different plan for this intent' : 'the mandate binds a plan and this step presents none');
199
+ }
200
+ // The handler first: it decides the type-specific limits (5) AND which caveats it judges itself (4).
201
+ const h = subsetHandlerFor(input.requirementType, input.handlers);
202
+ if (!h)
203
+ return deny('no-handler', `no subset handler for ${input.requirementType} — an authority nobody can bound is not verified`);
204
+ const selector = methodSelector(input.step.capability);
205
+ const verdicts = evaluateCaveats(d.caveats, {
206
+ timestamp: input.now,
207
+ // The call TARGET is the step's resource: the agent being acted for (a membership add on an org),
208
+ // or the asset contract (a payment). Both are what `allowedTargets` was encoded against.
209
+ target: (input.step.resource ?? d.delegator),
210
+ selector,
211
+ // The ETH value the step sends — 0 when it sends none. A fact about the step (spec 408 §2.2).
212
+ value: input.step.value ?? 0n,
213
+ digests: {
214
+ intent: digestOfIntent,
215
+ ...(input.step.projectionDigest ? { projection: input.step.projectionDigest } : {}),
216
+ ...(input.step.offerDigest ? { offer: input.step.offerDigest } : {}),
217
+ ...(input.step.planDigest ? { plan: input.step.planDigest } : {}),
218
+ },
219
+ ...(input.step.payloadClasses ? { payloadClasses: input.step.payloadClasses } : {}),
220
+ }, input.enforcers, {
221
+ // R917-P-1 (spec 408 §2.2): STRICT unless this step redeems on chain, where every enforcer fires. The
222
+ // previous `enforceOnChain: true` on every step let a caveat nobody judged off chain pass as
223
+ // "enforced-on-chain" for steps that never reached the chain — the evaluator's own contract forbids
224
+ // that for an off-chain gate, and this IS one.
225
+ enforceOnChain: input.step.redeemsOnChain === true,
226
+ judgedElsewhere: new Set((h.judgesEnforcers?.(input.enforcers) ?? []).map(lc)),
227
+ });
228
+ evidence.verdicts = verdicts.map((v) => ({ enforcer: v.enforcer, allowed: v.allowed, ...(v.reason ? { reason: v.reason } : {}) }));
229
+ const denied = verdicts.find((v) => !v.allowed);
230
+ if (denied) {
231
+ const isReason = /digest mismatch|binding present/.test(denied.reason ?? '');
232
+ return deny(isReason ? 'intent-mismatch' : 'caveat-denied', denied.reason ?? 'caveat denied');
233
+ }
234
+ // 5. type-specific limits
235
+ const req = readMandate(d, input.requirementType, input.enforcers, input.handlers);
236
+ if (!req)
237
+ return deny('not-a-mandate', `the presented delegation does not decode as a ${input.requirementType} mandate`);
238
+ // Actions, resources and limits are ALL the handler's to judge — a read-back capability mandate
239
+ // carries `sel:<hex>` actions while a step carries the id, and only the handler knows they are the
240
+ // same. Asking it "would a requirement shaped like this step be a subset?" gives every type-specific
241
+ // comparison exactly one definition. The reason names what failed so a denial is actionable.
242
+ const shaped = stepAsRequirement(req, input.step, h);
243
+ if (!h.isSubset(shaped, req)) {
244
+ if (!h.isSubset({ ...shaped, locations: req.locations, limits: req.limits }, req)) {
245
+ return deny('action-not-granted', `${shaped.actions.map((a) => `"${a}"`).join(', ')} is not among the mandate's actions`);
246
+ }
247
+ if (input.step.resource && !h.isSubset({ ...shaped, limits: req.limits }, req)) {
248
+ return deny('resource-not-granted', `resource ${input.step.resource} is not among the mandate's locations`);
249
+ }
250
+ return deny('limit-exceeded', `step exceeds the mandate's ${h.type} limits`);
251
+ }
252
+ return { decision: 'allow', obligations: [], evidence };
253
+ }
254
+ /** The step, re-expressed as a requirement, so the handler can compare like with like. */
255
+ function stepAsRequirement(req, step, h) {
256
+ return {
257
+ ...req,
258
+ actions: h.stepActions ? h.stepActions(step) : [step.action],
259
+ ...(step.resource ? { locations: [step.resource] } : {}),
260
+ limits: stepLimits(step),
261
+ };
262
+ }
263
+ /** The step's bounded quantities as `limits`, so the handler compares like with like. */
264
+ function stepLimits(step) {
265
+ const out = {};
266
+ for (const [k, v] of Object.entries(step.args ?? {})) {
267
+ if (typeof v === 'string' || typeof v === 'number')
268
+ out[k] = v;
269
+ else if (typeof v === 'bigint')
270
+ out[k] = v.toString();
271
+ }
272
+ return out;
273
+ }
274
+ export { ROOT_AUTHORITY };
275
+ //# sourceMappingURL=mandate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mandate.js","sourceRoot":"","sources":["../src/mandate.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,EAAE;A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