@agenticprimitives/contracts 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (145) hide show
  1. package/AUDIT.md +119 -27
  2. package/README.md +47 -12
  3. package/deployments-base-sepolia.json +52 -1
  4. package/deployments-faithchain.json +103 -0
  5. package/deployments-hopechain.json +78 -0
  6. package/deployments-paymaster-anvil.json +1 -0
  7. package/deployments-registries-base-sepolia.json +1 -0
  8. package/deployments-registries-hopechain.json +1 -0
  9. package/dist/abi/AccountBootstrap.json +99 -0
  10. package/dist/abi/AgentAccount.json +461 -67
  11. package/dist/abi/AgentAccountFactory.json +309 -0
  12. package/dist/abi/AgentNameAttributeResolver.json +212 -0
  13. package/dist/abi/AgentNameRegistry.json +544 -0
  14. package/dist/abi/AgentNameUniversalResolver.json +222 -0
  15. package/dist/abi/AgentProfileResolver.json +236 -0
  16. package/dist/abi/AgentRegistryBase.json +1003 -0
  17. package/dist/abi/AgentRelationship.json +405 -0
  18. package/dist/abi/AgenticGovernance.json +155 -0
  19. package/dist/abi/AgreementRegistry.json +203 -5
  20. package/dist/abi/AllowedMethodsEnforcer.json +193 -0
  21. package/dist/abi/AllowedTargetsEnforcer.json +193 -0
  22. package/dist/abi/ApprovedHashRegistry.json +267 -2
  23. package/dist/abi/AttestationRegistry.json +242 -0
  24. package/dist/abi/AttributeStorage.json +24 -0
  25. package/dist/abi/CallDataHashEnforcer.json +193 -0
  26. package/dist/abi/CustodyPolicy.json +422 -55
  27. package/dist/abi/DelegationManager.json +292 -0
  28. package/dist/abi/DigestBindingEnforcer.json +541 -0
  29. package/dist/abi/Eip7702.json +13 -0
  30. package/dist/abi/EstateProjectionRegistry.json +599 -0
  31. package/dist/abi/Generation5Bridge.json +355 -0
  32. package/dist/abi/GeoFeatureRegistry.json +235 -0
  33. package/dist/abi/IAgentAccountFactoryView.json +26 -0
  34. package/dist/abi/IAgentAccountGovernanceTimelockView.json +15 -0
  35. package/dist/abi/IApprovedHashRegistryWrite.json +35 -0
  36. package/dist/abi/ICustodyEpochView.json +28 -0
  37. package/dist/abi/ICustodyPolicyAccountModuleView.json +31 -0
  38. package/dist/abi/ICustodyPolicyFactoryView.json +13 -0
  39. package/dist/abi/ICustodyPolicyPasskeyView.json +50 -0
  40. package/dist/abi/IDelegationManager.json +18 -0
  41. package/dist/abi/IGeneration4Reads.json +143 -0
  42. package/dist/abi/IGeneration5Account.json +33 -0
  43. package/dist/abi/IGeneration5Voucher.json +26 -0
  44. package/dist/abi/IMoveAccountView.json +57 -0
  45. package/dist/abi/IMoveCustodyView.json +169 -0
  46. package/dist/abi/IMoveFactoryView.json +41 -0
  47. package/dist/abi/IPaymentReceiptRegistry.json +50 -0
  48. package/dist/abi/IRedemptionContext.json +15 -0
  49. package/dist/abi/IRegistryMembershipPolicy.json +70 -0
  50. package/dist/abi/ITimelockVeto.json +93 -0
  51. package/dist/abi/ITreasurySpendPolicyAccountView.json +44 -0
  52. package/dist/abi/IUpgradeVoucherView.json +26 -0
  53. package/dist/abi/MockUSDC.json +621 -0
  54. package/dist/abi/OntologyTermRegistry.json +268 -0
  55. package/dist/abi/PayloadClassesEnforcer.json +310 -0
  56. package/dist/abi/PaymentEnforcer.json +639 -0
  57. package/dist/abi/PaymentEscrow.json +501 -0
  58. package/dist/abi/PaymentReceiptRegistry.json +388 -0
  59. package/dist/abi/PermissionlessSubregistry.json +353 -0
  60. package/dist/abi/PricedSubregistry.json +1141 -0
  61. package/dist/abi/QuorumEnforcer.json +209 -0
  62. package/dist/abi/ReceiptAnchorRegistry.json +346 -0
  63. package/dist/abi/RelationshipTypeRegistry.json +268 -0
  64. package/dist/abi/ShapeRegistry.json +268 -0
  65. package/dist/abi/SignatureVerifier.json +196 -0
  66. package/dist/abi/SkillDefinitionRegistry.json +235 -0
  67. package/dist/abi/SmartAgentPaymaster.json +445 -1
  68. package/dist/abi/StableProxyGoverned.json +190 -0
  69. package/dist/abi/StableProxyGovernedOneShot.json +172 -0
  70. package/dist/abi/TimestampEnforcer.json +193 -0
  71. package/dist/abi/TreasurySpendPolicy.json +667 -0
  72. package/dist/abi/UpgradeVoucher.json +328 -0
  73. package/dist/abi/ValueEnforcer.json +193 -0
  74. package/dist/abi/index.d.ts +35 -0
  75. package/dist/abi/index.js +35 -0
  76. package/dist/deployments/base-sepolia.d.ts +11 -0
  77. package/dist/deployments/base-sepolia.js +51 -28
  78. package/dist/deployments/faithchain.d.ts +77 -0
  79. package/dist/deployments/faithchain.js +107 -0
  80. package/dist/deployments/hopechain.d.ts +68 -0
  81. package/dist/deployments/hopechain.js +82 -0
  82. package/dist/deployments/index.d.ts +7 -2
  83. package/dist/deployments/index.js +15 -0
  84. package/dist/deployments/paymaster-anvil.d.ts +11 -0
  85. package/dist/deployments/paymaster-anvil.js +9 -0
  86. package/dist/deployments/registries-base-sepolia.d.ts +10 -0
  87. package/dist/deployments/registries-base-sepolia.js +8 -0
  88. package/dist/deployments/registries-hopechain.d.ts +10 -0
  89. package/dist/deployments/registries-hopechain.js +8 -0
  90. package/package.json +37 -7
  91. package/src/AccountBootstrap.sol +38 -0
  92. package/src/AgentAccount.sol +1091 -134
  93. package/src/AgentAccountFactory.sol +198 -21
  94. package/src/ApprovedHashRegistry.sol +134 -10
  95. package/src/IAgentAccount.sol +37 -0
  96. package/src/SmartAgentPaymaster.sol +275 -22
  97. package/src/UniversalSignatureValidator.sol +7 -0
  98. package/src/UpgradeVoucher.sol +87 -0
  99. package/src/agency/DelegationManager.sol +299 -76
  100. package/src/agency/ICaveatEnforcer.sol +10 -0
  101. package/src/agency/IDelegationManager.sol +37 -5
  102. package/src/agreement/AgreementRegistry.sol +105 -35
  103. package/src/attestation/AttestationRegistry.sol +220 -40
  104. package/src/custody/CustodyPolicy.sol +588 -70
  105. package/src/custody/TreasurySpendPolicy.sol +338 -0
  106. package/src/enforcers/AllowedMethodsEnforcer.sol +13 -2
  107. package/src/enforcers/AllowedTargetsEnforcer.sol +13 -2
  108. package/src/enforcers/CallDataHashEnforcer.sol +7 -1
  109. package/src/enforcers/DigestBindingEnforcer.sol +182 -0
  110. package/src/enforcers/PayloadClassesEnforcer.sol +36 -0
  111. package/src/enforcers/PaymentEnforcer.sol +291 -0
  112. package/src/enforcers/QuorumEnforcer.sol +24 -3
  113. package/src/enforcers/TimestampEnforcer.sol +7 -1
  114. package/src/enforcers/ValueEnforcer.sol +13 -2
  115. package/src/geo/GeoFeatureRegistry.sol +67 -22
  116. package/src/governance/AgenticGovernance.sol +187 -4
  117. package/src/governance/GovernanceManaged.sol +2 -0
  118. package/src/governance/StableProxyGoverned.sol +79 -0
  119. package/src/governance/StableProxyGovernedOneShot.sol +93 -0
  120. package/src/identity/AgentProfilePredicates.sol +23 -0
  121. package/src/identity/AgentProfileResolver.sol +22 -2
  122. package/src/libraries/Eip7702.sol +36 -0
  123. package/src/libraries/SignatureSlotRecovery.sol +28 -7
  124. package/src/libraries/SignatureVerifier.sol +52 -0
  125. package/src/libraries/WebAuthnLib.sol +16 -0
  126. package/src/migration/Generation5Bridge.sol +364 -0
  127. package/src/mocks/MockUSDC.sol +152 -0
  128. package/src/naming/AgentNameAttributeResolver.sol +29 -4
  129. package/src/naming/AgentNamePredicates.sol +89 -0
  130. package/src/naming/AgentNameRegistry.sol +324 -20
  131. package/src/naming/AgentNameUniversalResolver.sol +35 -2
  132. package/src/naming/PermissionlessSubregistry.sol +82 -25
  133. package/src/naming/PricedSubregistry.sol +293 -0
  134. package/src/ontology/AttributeStorage.sol +93 -80
  135. package/src/ontology/OntologyTermRegistry.sol +58 -2
  136. package/src/ontology/ShapeRegistry.sol +58 -2
  137. package/src/payments/PaymentEscrow.sol +187 -0
  138. package/src/payments/PaymentReceiptRegistry.sol +100 -0
  139. package/src/provenance/ReceiptAnchorRegistry.sol +67 -0
  140. package/src/registry/AgentRegistryBase.sol +372 -0
  141. package/src/registry/EstateProjectionRegistry.sol +177 -0
  142. package/src/registry/IRegistryMembershipPolicy.sol +30 -0
  143. package/src/relationships/AgentRelationship.sol +129 -8
  144. package/src/relationships/RelationshipTypeRegistry.sol +58 -2
  145. package/src/skills/SkillDefinitionRegistry.sol +61 -17
@@ -0,0 +1,338 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.28;
3
+
4
+ import {StableProxyGoverned} from "../governance/StableProxyGoverned.sol";
5
+
6
+ /**
7
+ * @title TreasurySpendPolicy — an aggregate ceiling AT THE RESOURCE (spec 410 §7, THESIS-6)
8
+ * @notice Every caveat enforcer bounds ONE delegation: `ValueEnforcer` a call's value, `PaymentEnforcer` a
9
+ * mandate's budget under (delegator, delegationHash). None of them can see the treasury's other
10
+ * delegates, so two delegates each under their own ceiling can jointly exceed the principal's
11
+ * budget. This module is the ceiling that belongs to the TREASURY: an ERC-7579 HOOK the account
12
+ * installs, consulted on every `execute` / `executeBatch` — a custodian's own userOp and a delegated
13
+ * redemption alike, because the account runs its hooks on both — that adds the value each call moves
14
+ * to the current window and refuses the one that would pass the ceiling.
15
+ *
16
+ * WHAT IT COUNTS (generation 4 — spec 445 §1.5, audit CUST-2). The hook sees calldata BEFORE the call,
17
+ * so it counts what a call can COMMIT the treasury to, not what later settles:
18
+ * native budget (`asset == address(0)`):
19
+ * - the `value` of every call, and of the batch frame;
20
+ * - `withdrawTo(address,uint256)` on the account's EntryPoint (its deposit there is its own
21
+ * native balance; the call carries `value == 0`).
22
+ * ERC-20 budget, calls whose target is `asset`:
23
+ * - `transfer(to, amount)`, `transferFrom(from, to, amount)` → `amount`;
24
+ * - `approve(spender, amount)`, `increaseAllowance(spender, added)` → the amount GRANTED. An
25
+ * allowance is a promise to pay: the spender's later `transferFrom` goes straight to the token
26
+ * and no hook ever sees it, so the only place it can be counted is where it is made. An
27
+ * unlimited approval exceeds any finite ceiling and is refused;
28
+ * - `approve(spender, 0)`, `decreaseAllowance(…)` → 0. Tightening is never spend. It is also
29
+ * never CREDITED BACK: the hook cannot see how much of the old allowance was already drawn,
30
+ * so a credit would let approve → pull → approve(0) repeat without limit;
31
+ * - ANY OTHER SELECTOR on the tracked token, or calldata too short for the selector it names →
32
+ * REFUSED (`UnrecognizedTokenCall`). Fail closed: `permit` routed through the account,
33
+ * `transferAndCall`, a token-specific mover — the hook cannot price what it does not
34
+ * understand, so a budgeted treasury does not make the call.
35
+ * A batch is one call: its inner calls are summed. A payload the hook cannot decode is refused, never
36
+ * counted as zero.
37
+ *
38
+ * WHAT THE CEILING DOES NOT BOUND — stated so nobody relies on more than the code does:
39
+ * - any asset other than the ONE budgeted here (one budget per account per module instance; an
40
+ * ERC-20 budget does not count native value, and the reverse);
41
+ * - allowances that already existed when the hook was installed;
42
+ * - anything the token accepts on a SIGNATURE instead of a call from the account: EIP-2612 `permit`,
43
+ * EIP-3009 `transferWithAuthorization`, Permit2. Those are submitted by a third party and
44
+ * validated through the account's ERC-1271 — no `execute`, no hook;
45
+ * - gas: the ERC-4337 prefund the EntryPoint takes in `validateUserOp`;
46
+ * - the timing of an allowance: one granted in window 1 can be drawn in window 2, so with
47
+ * allowances the bound is CUMULATIVE (outflow through window n ≤ n × ceiling), not per window;
48
+ * - non-standard tokens whose `transfer` / `approve` do not mean what ERC-20 says (rebasing,
49
+ * fee-on-transfer, hooks), and any call the account makes through an upgrade.
50
+ *
51
+ * WINDOWS are fixed-length epochs from `windowStart` — never sliding — so the check is O(1) and the
52
+ * refusal is reproducible off chain from the receipt and the block time.
53
+ *
54
+ * WHO SETS IT, AND WHICH TREASURIES IT ACTUALLY PROTECTS (spec 445 §1.5, audit CUST-3 / ACCT-3).
55
+ * The budget is the install data: `installModule(4, this, abi.encode(asset, ceiling, windowSeconds))`.
56
+ * `lowerCeiling` / `setCeiling` change the ceiling in place — the window and what was spent in it are
57
+ * kept (an uninstall + reinstall would reset `spent`, handing out a second ceiling in one window).
58
+ * - CUSTODY-GOVERNED treasury (mode > 0): install, uninstall and `setCeiling` are `CustodyPolicy`
59
+ * actions at T5 (critical quorum + the 24 h floor); `lowerCeiling` at T4. No single custodian,
60
+ * delegate or module can reach any of them: on a governed account an installed module is never
61
+ * an `execute` target (`AgentAccount._rejectModuleTarget`), and a non-canonical executor module
62
+ * runs its calls through this hook and cannot dispatch account governance. HERE the ceiling
63
+ * bounds every custodian key, every delegate and every other module — everything short of the
64
+ * T5 quorum.
65
+ * - SELF-GOVERNED treasury (mode 0): the account's one credential IS its custody tier. It can
66
+ * `uninstallModule` this hook, or call `setCeiling`, in one user operation with no delay — and so
67
+ * can any EXECUTOR module that credential installed (on a mode-0 account an executor may make
68
+ * every self-call the credential can; it is that credential's equal, which is why it is retired
69
+ * with it). The ceiling there bounds DELEGATES — never the custodian key, never its executor
70
+ * modules. A mode-0 treasury's ceiling is exactly as strong as its single key. (Spec 420: assets
71
+ * live only in treasuries — a treasury that must be bounded against its own keys must be
72
+ * custody-governed.)
73
+ * On every mode a delegation stack is refused this module as a target, and `onInstall` /
74
+ * `onUninstall` verify the account's own installed flag, so `execute(this, onUninstall())` cannot
75
+ * drop the budget while the account still lists the hook.
76
+ * Per-delegation ceilings are untouched: the tighter of the two refuses.
77
+ *
78
+ * WHAT IT IS NOT: a policy of who may spend (that is the mandate), a rate limit on calls, or anything
79
+ * a planner consults — the harness may READ `budget()` to say "this would exceed the treasury's
80
+ * shared budget" before a signature (honesty); the hook is the authority.
81
+ */
82
+ /// @dev The account's ERC-7579 module view + its EntryPoint (the native-deposit exit).
83
+ interface ITreasurySpendPolicyAccountView {
84
+ function isModuleInstalled(uint256 moduleTypeId, address module, bytes calldata additionalContext) external view returns (bool);
85
+ function entryPoint() external view returns (address);
86
+ }
87
+
88
+ contract TreasurySpendPolicy is StableProxyGoverned {
89
+ /// @notice A direct deployment, initialized here (no governance: never upgradeable). Behind a stable proxy
90
+ /// (spec 447), `initialize(governance_)` instead — a treasury holds this hook's address in its module
91
+ /// list, so a fix must keep the address (and every installed budget with it).
92
+ constructor() initializer {}
93
+
94
+ struct Budget {
95
+ address asset; // address(0) = native value
96
+ uint256 ceiling; // per window, in the asset's base units
97
+ uint64 windowSeconds; // fixed epochs from windowStart
98
+ uint64 windowStart;
99
+ uint64 windowIndex; // the epoch `spent` belongs to
100
+ uint256 spent;
101
+ bool installed;
102
+ }
103
+
104
+ /// account => budget
105
+ mapping(address => Budget) private _budgets;
106
+ /// @dev Storage gap (spec 447; layout gated by `check:storage-layouts`).
107
+ uint256[49] private __gap;
108
+
109
+ event BudgetInstalled(address indexed account, address indexed asset, uint256 ceiling, uint64 windowSeconds, uint64 windowStart);
110
+ event BudgetUninstalled(address indexed account);
111
+ event Spent(address indexed account, uint64 indexed windowIndex, uint256 amount, uint256 spentInWindow);
112
+
113
+ error BudgetExceeded(uint256 ceiling, uint256 spentInWindow, uint256 amount);
114
+ error NotInstalledOn(address account);
115
+ error AlreadyInstalledOn(address account);
116
+ error BadBudget();
117
+ /// @dev ACCT-3: `onInstall` by an account that does not list this hook as installed (a direct
118
+ /// `execute(hook, onInstall)`), or `onUninstall` by one that still does.
119
+ error NotInstalledAsHookOn(address account);
120
+ error StillInstalledOn(address account);
121
+ /// @dev CUST-2: calldata to the budgeted token that the hook cannot price. Fail closed.
122
+ error UnrecognizedTokenCall(bytes4 selector);
123
+ /// @dev CUST-2: the hook payload did not decode as either encoding the account produces. Fail closed.
124
+ error UndecodableCall();
125
+ /// @dev `lowerCeiling` with a value that is not strictly lower.
126
+ error NotLower(uint256 current, uint256 requested);
127
+
128
+ event CeilingChanged(address indexed account, uint256 oldCeiling, uint256 newCeiling);
129
+
130
+ uint256 private constant MODULE_TYPE_HOOK = 4;
131
+
132
+ bytes4 private constant TRANSFER = bytes4(keccak256("transfer(address,uint256)"));
133
+ bytes4 private constant TRANSFER_FROM = bytes4(keccak256("transferFrom(address,address,uint256)"));
134
+ bytes4 private constant APPROVE = bytes4(keccak256("approve(address,uint256)"));
135
+ bytes4 private constant INCREASE_ALLOWANCE = bytes4(keccak256("increaseAllowance(address,uint256)"));
136
+ bytes4 private constant DECREASE_ALLOWANCE = bytes4(keccak256("decreaseAllowance(address,uint256)"));
137
+ /// @dev `IStakeManager.withdrawTo(address payable, uint256)` — the account's EntryPoint deposit leaving.
138
+ bytes4 private constant WITHDRAW_TO = bytes4(keccak256("withdrawTo(address,uint256)"));
139
+
140
+ // ─── ERC-7579 module surface ───────────────────────────────────────
141
+
142
+ function isModuleType(uint256 moduleTypeId) external pure returns (bool) { return moduleTypeId == 4; }
143
+ function moduleId() external pure returns (string memory) { return "agenticprimitives-treasury-spend-policy-1"; }
144
+
145
+ /// @notice Called by the account from `installModule` (governance-gated there): the budget is the install data.
146
+ /// @dev ACCT-3: the caller must be an account that is INSTALLING this hook — `installModule` sets its
147
+ /// installed flag before calling here. A caller that cannot answer the view reverts (fail closed).
148
+ function onInstall(bytes calldata initData) external {
149
+ Budget storage b = _budgets[msg.sender];
150
+ if (b.installed) revert AlreadyInstalledOn(msg.sender);
151
+ if (!ITreasurySpendPolicyAccountView(msg.sender).isModuleInstalled(MODULE_TYPE_HOOK, address(this), "")) {
152
+ revert NotInstalledAsHookOn(msg.sender);
153
+ }
154
+ (address asset, uint256 ceiling, uint64 windowSeconds) = abi.decode(initData, (address, uint256, uint64));
155
+ if (windowSeconds == 0) revert BadBudget();
156
+ b.asset = asset;
157
+ b.ceiling = ceiling;
158
+ b.windowSeconds = windowSeconds;
159
+ b.windowStart = uint64(block.timestamp);
160
+ b.windowIndex = 0;
161
+ b.spent = 0;
162
+ b.installed = true;
163
+ emit BudgetInstalled(msg.sender, asset, ceiling, windowSeconds, b.windowStart);
164
+ }
165
+
166
+ /// @dev ACCT-3 (the R917-C-1 pattern `CustodyPolicy.onUninstall` uses): the account must have ALREADY
167
+ /// dropped this hook. `AgentAccount.uninstallModule` clears its flag before calling here; any other
168
+ /// caller that is the account — a custodian's `execute(hook, onUninstall())`, a delegation, another
169
+ /// module — still lists the hook and is refused, so the budget cannot be deleted while the account
170
+ /// keeps calling `preCheck` on a hook that no longer counts.
171
+ function onUninstall(bytes calldata) external {
172
+ if (!_budgets[msg.sender].installed) revert NotInstalledOn(msg.sender);
173
+ if (ITreasurySpendPolicyAccountView(msg.sender).isModuleInstalled(MODULE_TYPE_HOOK, address(this), "")) {
174
+ revert StillInstalledOn(msg.sender);
175
+ }
176
+ delete _budgets[msg.sender];
177
+ emit BudgetUninstalled(msg.sender);
178
+ }
179
+
180
+ // ─── Changing the ceiling in place (spec 445 §1.5, CUST-3) ─────────
181
+
182
+ /// @notice Tighten the ceiling. `msg.sender` is the account. Reverts unless `newCeiling` is strictly
183
+ /// lower — which is why a custody quorum may reach it at T4 (`CustodyAction.LowerSpendCeiling`).
184
+ /// The window and the amount already spent in it are kept; if `spent` is already above the new
185
+ /// ceiling, nothing more is spendable until the window rolls.
186
+ function lowerCeiling(uint256 newCeiling) external {
187
+ Budget storage b = _budgets[msg.sender];
188
+ if (!b.installed) revert NotInstalledOn(msg.sender);
189
+ if (newCeiling >= b.ceiling) revert NotLower(b.ceiling, newCeiling);
190
+ emit CeilingChanged(msg.sender, b.ceiling, newCeiling);
191
+ b.ceiling = newCeiling;
192
+ }
193
+
194
+ /// @notice Set the ceiling to any value — this is the call that can RAISE it. `msg.sender` is the account;
195
+ /// on a custody-governed treasury the only route is `CustodyAction.SetSpendCeiling` (T5). On a
196
+ /// self-governed treasury the one credential reaches it directly (see the contract notice).
197
+ function setCeiling(uint256 newCeiling) external {
198
+ Budget storage b = _budgets[msg.sender];
199
+ if (!b.installed) revert NotInstalledOn(msg.sender);
200
+ emit CeilingChanged(msg.sender, b.ceiling, newCeiling);
201
+ b.ceiling = newCeiling;
202
+ }
203
+
204
+ // ─── The hook ──────────────────────────────────────────────────────
205
+
206
+ /// @notice `preCheck` from the account: `msgData` is `abi.encode(target, value, data)` for `execute` and
207
+ /// `abi.encode(Call[])` for `executeBatch`. Sums the value this call moves in the budget's asset and
208
+ /// refuses when the window's total would pass the ceiling.
209
+ function preCheck(address, uint256 value, bytes calldata msgData) external returns (bytes memory) {
210
+ Budget storage b = _budgets[msg.sender];
211
+ if (!b.installed) return hex"";
212
+ uint256 amount = _valueMoved(b.asset, value, msgData);
213
+ if (amount == 0) return hex"";
214
+ uint64 idx = uint64((block.timestamp - b.windowStart) / b.windowSeconds);
215
+ if (idx != b.windowIndex) { b.windowIndex = idx; b.spent = 0; }
216
+ // Compared without adding first: `amount` may be type(uint256).max (an unlimited approval), and
217
+ // `spent` may sit above a ceiling that was lowered mid-window.
218
+ if (b.spent > b.ceiling || amount > b.ceiling - b.spent) revert BudgetExceeded(b.ceiling, b.spent, amount);
219
+ uint256 next = b.spent + amount;
220
+ b.spent = next;
221
+ emit Spent(msg.sender, idx, amount, next);
222
+ return hex"";
223
+ }
224
+
225
+ function postCheck(bytes calldata) external {}
226
+
227
+ // ─── Reads (the harness's honesty, never its authority) ────────────
228
+
229
+ function budget(address account) external view returns (address asset, uint256 ceiling, uint64 windowSeconds, uint64 windowStart, uint64 windowIndex, uint256 spent, bool installed) {
230
+ Budget storage b = _budgets[account];
231
+ return (b.asset, b.ceiling, b.windowSeconds, b.windowStart, b.windowIndex, b.spent, b.installed);
232
+ }
233
+
234
+ /// @notice What the account has spent in the CURRENT window (0 once the window rolled), and the ceiling.
235
+ function remaining(address account) external view returns (uint256 left, uint256 ceiling) {
236
+ Budget storage b = _budgets[account];
237
+ if (!b.installed) return (type(uint256).max, 0);
238
+ uint64 idx = uint64((block.timestamp - b.windowStart) / b.windowSeconds);
239
+ uint256 spent = idx == b.windowIndex ? b.spent : 0;
240
+ return (b.ceiling > spent ? b.ceiling - spent : 0, b.ceiling);
241
+ }
242
+
243
+ // ─── Internals ─────────────────────────────────────────────────────
244
+
245
+ /// @dev Both encodings the account uses, told apart by the first word: `abi.encode(Call[])` opens with the
246
+ /// array's offset (exactly 0x20), `abi.encode(target, value, data)` with the target address.
247
+ ///
248
+ /// FAIL CLOSED (CUST-2). Before generation 4 a payload that did not decode was counted as ZERO —
249
+ /// a fail-open on the one input the ceiling depends on. It is now refused (`UndecodableCall`). The
250
+ /// decode runs through an external self-call only so the failure can be turned into that error.
251
+ ///
252
+ /// The 0x20 ambiguity: a SINGLE call whose target is the address 0x20 also opens with 0x20, and its
253
+ /// remaining words can be shaped to decode as a harmless batch. For a native budget that would have
254
+ /// let the call's real value go uncounted, so in the batch branch the frame's own `value` (what the
255
+ /// account says it is sending: the real value for `execute`, 0 for `executeBatch`) is added. For an
256
+ /// ERC-20 budget the real call goes to 0x20, which is not the token: nothing to count.
257
+ function _valueMoved(address asset, uint256 frameValue, bytes calldata msgData) internal view returns (uint256 total) {
258
+ if (msgData.length < 32) revert UndecodableCall();
259
+ address ep = asset == address(0) ? _entryPointOf(msg.sender) : address(0);
260
+ if (uint256(bytes32(msgData[0:32])) == 0x20) {
261
+ try this.decodeBatch(msgData) returns (Call[] memory calls) {
262
+ if (asset == address(0)) total = frameValue;
263
+ for (uint256 i = 0; i < calls.length; i++) {
264
+ total = _satAdd(total, _amountOf(asset, ep, calls[i].target, calls[i].value, calls[i].data));
265
+ }
266
+ return total;
267
+ } catch { revert UndecodableCall(); }
268
+ }
269
+ try this.decodeSingle(msgData) returns (address target, uint256 value, bytes memory data) {
270
+ return _amountOf(asset, ep, target, value, data);
271
+ } catch { revert UndecodableCall(); }
272
+ }
273
+
274
+ function _satAdd(uint256 a, uint256 b) private pure returns (uint256) {
275
+ unchecked {
276
+ uint256 c = a + b;
277
+ return c < a ? type(uint256).max : c;
278
+ }
279
+ }
280
+
281
+ /// @dev The account's EntryPoint, for the native-deposit exit. An account that cannot answer has none
282
+ /// this hook can name; its native budget then counts call value only.
283
+ function _entryPointOf(address account) private view returns (address) {
284
+ (bool ok, bytes memory ret) = account.staticcall(
285
+ abi.encodeWithSelector(ITreasurySpendPolicyAccountView.entryPoint.selector)
286
+ );
287
+ if (!ok || ret.length < 32) return address(0);
288
+ return abi.decode(ret, (address));
289
+ }
290
+
291
+ struct Call { address target; uint256 value; bytes data; }
292
+
293
+ function decodeSingle(bytes calldata msgData) external pure returns (address, uint256, bytes memory) {
294
+ return abi.decode(msgData, (address, uint256, bytes));
295
+ }
296
+ function decodeBatch(bytes calldata msgData) external pure returns (Call[] memory) {
297
+ return abi.decode(msgData, (Call[]));
298
+ }
299
+
300
+ /// @dev What ONE call commits the treasury to, in the budgeted asset. See the contract notice for the
301
+ /// rule and for what it does not cover.
302
+ function _amountOf(address asset, address ep, address target, uint256 value, bytes memory data)
303
+ internal
304
+ pure
305
+ returns (uint256)
306
+ {
307
+ bytes4 sel;
308
+ if (data.length >= 4) {
309
+ assembly { sel := mload(add(data, 32)) }
310
+ }
311
+ if (asset == address(0)) {
312
+ // Native: the value sent, plus a withdrawal of the account's EntryPoint deposit.
313
+ if (ep != address(0) && target == ep && sel == WITHDRAW_TO) {
314
+ if (data.length < 68) revert UnrecognizedTokenCall(sel);
315
+ uint256 withdrawn;
316
+ assembly { withdrawn := mload(add(data, 68)) }
317
+ return _satAdd(value, withdrawn);
318
+ }
319
+ return value;
320
+ }
321
+ if (target != asset) return 0;
322
+ // The budgeted token. Every selector is either priced or refused.
323
+ if (sel == TRANSFER || sel == APPROVE || sel == INCREASE_ALLOWANCE) {
324
+ if (data.length < 68) revert UnrecognizedTokenCall(sel);
325
+ uint256 amount;
326
+ assembly { amount := mload(add(data, 68)) }
327
+ return amount; // approve(…, 0) → 0: a revocation is not spend (and is never credited back)
328
+ }
329
+ if (sel == TRANSFER_FROM) {
330
+ if (data.length < 100) revert UnrecognizedTokenCall(sel);
331
+ uint256 amount;
332
+ assembly { amount := mload(add(data, 100)) }
333
+ return amount;
334
+ }
335
+ if (sel == DECREASE_ALLOWANCE && data.length >= 68) return 0;
336
+ revert UnrecognizedTokenCall(sel);
337
+ }
338
+ }
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "../agency/ICaveatEnforcer.sol";
5
+ import "../governance/StableProxyGoverned.sol";
5
6
 
6
7
  /**
7
8
  * @title AllowedMethodsEnforcer
@@ -13,9 +14,19 @@ import "../agency/ICaveatEnforcer.sol";
13
14
  * (hooks are `pure`, contract has zero storage). The DM-side pause
14
15
  * check in `DelegationManager.redeemDelegation` gates all
15
16
  * reachable enforcer dispatch. See `docs/audits/r6-contracts-recon-2026-05-31.md`
16
- * § 4.4 + `test/EnforcerPauseInvariantR67.t.sol`.
17
+ * § 4.4 + `test/EnforcerPauseInvariantR67.t.sol`. *
18
+ * Spec 445 / audit DLG-2 — SCOPE. This enforcer judges the ONE `(target, value, callData)` the
19
+ * DelegationManager was asked to execute, nothing nested inside it. That is the whole call a
20
+ * delegation can cause only because the manager refuses a redemption whose target is the
21
+ * executing account itself (`SelfTargetedRedemption`) — the route by which a self-`executeBatch`
22
+ * once ran inner calls no enforcer saw. Do not reuse this enforcer under a manager without that rule.
17
23
  */
18
- contract AllowedMethodsEnforcer is ICaveatEnforcer {
24
+ contract AllowedMethodsEnforcer is ICaveatEnforcer, StableProxyGoverned {
25
+ /// @notice A direct deployment, initialized here (no governance: never upgradeable). Behind a stable proxy
26
+ /// (spec 447), `initialize(governance_)` instead — an enforcer's address is in every delegation that
27
+ /// names it, so a fix must keep the address.
28
+ constructor() initializer {}
29
+
19
30
  error MethodNotAllowed();
20
31
  error CalldataTooShort();
21
32
 
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "../agency/ICaveatEnforcer.sol";
5
+ import "../governance/StableProxyGoverned.sol";
5
6
 
6
7
  /**
7
8
  * @title AllowedTargetsEnforcer
@@ -13,9 +14,19 @@ import "../agency/ICaveatEnforcer.sol";
13
14
  * (hooks are `pure`, contract has zero storage). The DM-side pause
14
15
  * check in `DelegationManager.redeemDelegation` gates all
15
16
  * reachable enforcer dispatch. See `docs/audits/r6-contracts-recon-2026-05-31.md`
16
- * § 4.4 + `test/EnforcerPauseInvariantR67.t.sol`.
17
+ * § 4.4 + `test/EnforcerPauseInvariantR67.t.sol`. *
18
+ * Spec 445 / audit DLG-2 — SCOPE. This enforcer judges the ONE `(target, value, callData)` the
19
+ * DelegationManager was asked to execute, nothing nested inside it. That is the whole call a
20
+ * delegation can cause only because the manager refuses a redemption whose target is the
21
+ * executing account itself (`SelfTargetedRedemption`) — the route by which a self-`executeBatch`
22
+ * once ran inner calls no enforcer saw. Do not reuse this enforcer under a manager without that rule.
17
23
  */
18
- contract AllowedTargetsEnforcer is ICaveatEnforcer {
24
+ contract AllowedTargetsEnforcer is ICaveatEnforcer, StableProxyGoverned {
25
+ /// @notice A direct deployment, initialized here (no governance: never upgradeable). Behind a stable proxy
26
+ /// (spec 447), `initialize(governance_)` instead — an enforcer's address is in every delegation that
27
+ /// names it, so a fix must keep the address.
28
+ constructor() initializer {}
29
+
19
30
  error TargetNotAllowed();
20
31
 
21
32
  function beforeHook(
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "../agency/ICaveatEnforcer.sol";
5
+ import "../governance/StableProxyGoverned.sol";
5
6
 
6
7
  /**
7
8
  * @title CallDataHashEnforcer
@@ -26,7 +27,12 @@ import "../agency/ICaveatEnforcer.sol";
26
27
  * dispatch, and the read-only `verifyAuthorizationForCall` evaluates it
27
28
  * via `staticcall`.
28
29
  */
29
- contract CallDataHashEnforcer is ICaveatEnforcer {
30
+ contract CallDataHashEnforcer is ICaveatEnforcer, StableProxyGoverned {
31
+ /// @notice A direct deployment, initialized here (no governance: never upgradeable). Behind a stable proxy
32
+ /// (spec 447), `initialize(governance_)` instead — an enforcer's address is in every delegation that
33
+ /// names it, so a fix must keep the address.
34
+ constructor() initializer {}
35
+
30
36
  error BadTermsLength();
31
37
  error CallDataMismatch(bytes32 expected, bytes32 actual);
32
38
 
@@ -0,0 +1,182 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.28;
3
+
4
+ import "../agency/ICaveatEnforcer.sol";
5
+ import "../governance/StableProxyGoverned.sol";
6
+
7
+ /**
8
+ * @title DigestBindingEnforcer
9
+ * @notice Binds a delegation to a 32-byte digest of an OFF-CHAIN artifact — an intent, a disclosure
10
+ * projection, an accepted offer — so that the delegation is a MANDATE (spec 336 §8.3, spec 350
11
+ * §2): authority *for a reason*, not authority for any purpose until revoked.
12
+ *
13
+ * @dev terms = abi.encode(bytes32 kind, bytes32 digest[, uint256 maxUses]) — signed by the delegator
14
+ * args = abi.encode(bytes32 presented, bytes32 stepNonce) — supplied by the redeemer at redemption
15
+ *
16
+ * `kind` names WHICH artifact the digest is of, so an off-chain reader can tell an intent binding
17
+ * from a projection binding without guessing:
18
+ * keccak256("ap:intent") — the canonical intent (RFC 8785 JCS bytes)
19
+ * keccak256("ap:projection") — what was disclosed to the grantee (spec 336 §4)
20
+ * keccak256("ap:offer") — the accepted offer (spec 336 §5)
21
+ * keccak256("ap:plan") — the admitted plan (spec 408 §2.3)
22
+ * One enforcer serves all four: the mechanics are identical and the kind belongs in the terms,
23
+ * where it is signed, rather than in which contract address was chosen.
24
+ *
25
+ * WHAT THIS ENFORCES, HONESTLY. The chain cannot know what an intent *means*; it can only hold
26
+ * the redeemer to a commitment. `beforeHook` requires the redeemer to PRESENT the digest it is
27
+ * acting under, and reverts if that is not the bound one. Two things follow:
28
+ * 1. the binding is part of the SIGNED delegation — immutable, inspectable, and what the
29
+ * off-chain per-step verifier (`delegation.verifyMandateForStep`) compares a step's
30
+ * intent digest against. That verifier is where "does this step belong to this intent" is
31
+ * actually decided; this contract makes the answer un-forgeable rather than deciding it;
32
+ * 2. the presented digest lands in the transaction, so the receipt's `intentDigest` and the
33
+ * chain's record of what the redeemer claimed to be doing are the same bytes — evidence a
34
+ * third party can check without trusting either side.
35
+ * A redeemer that copies `terms` into `args` satisfies the digest check; that is the point — it has
36
+ * now committed, on chain, to that intent, and a step whose real intent differs is caught by the
37
+ * verifier that computed the digest from the step rather than from the caveat.
38
+ *
39
+ * SINGLE USE IS WHAT THE DELEGATOR SIGNED (spec 445 / audit DLG-3; supersedes R917-C-4's rule).
40
+ * Generation 2–3 consumed a redemption under `(delegator, delegationHash, kind, stepNonce)` with
41
+ * `stepNonce` read from `args`. `args` are outside the signed delegation hash by design, so the
42
+ * party the caveat constrains chose the key: one mandate was redeemed five times with five fresh
43
+ * nonces. The bound now lives in the SIGNED `terms`:
44
+ *
45
+ * terms = abi.encode(bytes32 kind, bytes32 digest) — 64 bytes: ONE redemption
46
+ * terms = abi.encode(bytes32 kind, bytes32 digest, uint256 maxUses) — 96 bytes: at most
47
+ * `maxUses` (>= 1)
48
+ * args = abi.encode(bytes32 presented, bytes32 stepNonce) — unchanged
49
+ *
50
+ * A counter keyed `(delegator, delegationHash, kind)` — nothing the redeemer supplies — is
51
+ * incremented in `beforeHook` and may not pass the signed bound (`UsesExhausted`). A mandate that
52
+ * legitimately covers N on-chain steps says N in its terms; the (N+1)-th redemption reverts
53
+ * whatever nonce it brings. The 64-byte form is the strict reading of "single use": a mandate
54
+ * built by a mirror that has not learned the count redeems once and then fails closed.
55
+ *
56
+ * `stepNonce` keeps its job as the step's on-chain IDENTITY (the harness derives it from the
57
+ * intent digest and the step's operation id, the same derivation as `PaymentEnforcer`'s nonce):
58
+ * a replay of one step reverts `StepNonceReused` even while uses remain, and `isUsed` answers
59
+ * "did this step redeem?" for resume-with-recheck. It is recorded per REDEEMER, so where a
60
+ * delegation is open, or a grant has been re-delegated to several parties, one party cannot
61
+ * mark another's step as done by redeeming under the same nonce. The COUNT is deliberately not
62
+ * per redeemer — the delegator signed a total, and a per-redeemer count on an open delegation
63
+ * would be no bound at all. Consequence, stated: on an OPEN delegation any redeemer can spend
64
+ * the signed uses (each spend still has to pass every other caveat and execute the call). A
65
+ * mandate that must not be raced names its delegate; then the manager admits nobody else.
66
+ *
67
+ * A use is spent only by a redemption that completes: the write happens in `beforeHook`, inside
68
+ * `DelegationManager.redeemDelegation`'s single transaction with no try/catch around hooks or
69
+ * execution, so a later caveat, the executed call, or an after-hook reverting rolls the use and
70
+ * the nonce back with everything else.
71
+ *
72
+ * The hooks mutate state and are `onlyDelegationManager` (EXT-PMT-1's rule for stateful
73
+ * enforcers): a stranger cannot spend a use or a nonce outside a valid redemption.
74
+ */
75
+ contract DigestBindingEnforcer is ICaveatEnforcer, StableProxyGoverned {
76
+ error BadTermsLength();
77
+ error BadArgsLength();
78
+ error ZeroMaxUses();
79
+ error DigestMismatch(bytes32 kind, bytes32 bound, bytes32 presented);
80
+ error StepNonceReused(bytes32 kind, bytes32 stepNonce);
81
+ /// @notice The signed bound is spent: `maxUses` redemptions of this binding have already happened.
82
+ error UsesExhausted(bytes32 kind, uint256 maxUses);
83
+ error NotDelegationManager(address caller);
84
+
85
+ /// @notice The ONLY authorized caller of `beforeHook` — it consumes a use.
86
+ address public immutable delegationManager;
87
+
88
+ /// delegator => delegationHash => kind => redemptions so far (bounded by the SIGNED terms)
89
+ mapping(address => mapping(bytes32 => mapping(bytes32 => uint256))) private _uses;
90
+ /// delegator => delegationHash => keccak256(kind, redeemer, stepNonce) => consumed
91
+ mapping(address => mapping(bytes32 => mapping(bytes32 => bool))) private _used;
92
+ /// @dev Storage gap (spec 447: behind a stable proxy; layout gated by `check:storage-layouts`).
93
+ uint256[48] private __gap;
94
+
95
+ event DigestBindingRedeemed(
96
+ address indexed delegator,
97
+ bytes32 indexed delegationHash,
98
+ bytes32 indexed kind,
99
+ bytes32 presented,
100
+ bytes32 stepNonce,
101
+ address redeemer,
102
+ uint256 use,
103
+ uint256 maxUses
104
+ );
105
+
106
+ constructor(address delegationManager_) initializer {
107
+ require(delegationManager_ != address(0), "DigestBindingEnforcer: zero DelegationManager");
108
+ delegationManager = delegationManager_;
109
+ }
110
+
111
+ modifier onlyDelegationManager() {
112
+ if (msg.sender != delegationManager) revert NotDelegationManager(msg.sender);
113
+ _;
114
+ }
115
+
116
+ /// @notice Whether `redeemer` already redeemed `stepNonce` under this binding (a step's
117
+ /// "did it happen" check — recorded per redeemer, see the contract note).
118
+ function isUsed(address delegator, bytes32 delegationHash, bytes32 kind, address redeemer, bytes32 stepNonce)
119
+ external
120
+ view
121
+ returns (bool)
122
+ {
123
+ return _used[delegator][delegationHash][keccak256(abi.encode(kind, redeemer, stepNonce))];
124
+ }
125
+
126
+ /// @notice How many redemptions this binding has spent (compare with the `maxUses` in its terms).
127
+ function usesOf(address delegator, bytes32 delegationHash, bytes32 kind) external view returns (uint256) {
128
+ return _uses[delegator][delegationHash][kind];
129
+ }
130
+
131
+ /// @notice Decode a binding's signed terms. 64 bytes ⇒ `maxUses == 1`.
132
+ function decodeTerms(bytes calldata terms) public pure returns (bytes32 kind, bytes32 digest, uint256 maxUses) {
133
+ if (terms.length == 64) {
134
+ (kind, digest) = abi.decode(terms, (bytes32, bytes32));
135
+ maxUses = 1;
136
+ } else if (terms.length == 96) {
137
+ (kind, digest, maxUses) = abi.decode(terms, (bytes32, bytes32, uint256));
138
+ if (maxUses == 0) revert ZeroMaxUses();
139
+ } else {
140
+ revert BadTermsLength();
141
+ }
142
+ }
143
+
144
+ function beforeHook(
145
+ bytes calldata terms,
146
+ bytes calldata args,
147
+ bytes32 delegationHash,
148
+ address delegator,
149
+ address redeemer,
150
+ address,
151
+ uint256,
152
+ bytes calldata
153
+ ) external override onlyDelegationManager {
154
+ (bytes32 kind, bytes32 bound, uint256 maxUses) = decodeTerms(terms);
155
+ if (args.length != 64) revert BadArgsLength();
156
+ (bytes32 presented, bytes32 stepNonce) = abi.decode(args, (bytes32, bytes32));
157
+ if (presented != bound) revert DigestMismatch(kind, bound, presented);
158
+
159
+ // The step's identity, per redeemer: a replay of one step is refused even while uses remain.
160
+ bytes32 slot = keccak256(abi.encode(kind, redeemer, stepNonce));
161
+ if (_used[delegator][delegationHash][slot]) revert StepNonceReused(kind, stepNonce);
162
+ _used[delegator][delegationHash][slot] = true;
163
+
164
+ // The bound the delegator signed: keyed by nothing the redeemer supplies.
165
+ uint256 use = _uses[delegator][delegationHash][kind] + 1;
166
+ if (use > maxUses) revert UsesExhausted(kind, maxUses);
167
+ _uses[delegator][delegationHash][kind] = use;
168
+
169
+ emit DigestBindingRedeemed(delegator, delegationHash, kind, presented, stepNonce, redeemer, use, maxUses);
170
+ }
171
+
172
+ function afterHook(
173
+ bytes calldata,
174
+ bytes calldata,
175
+ bytes32,
176
+ address,
177
+ address,
178
+ address,
179
+ uint256,
180
+ bytes calldata
181
+ ) external pure override {}
182
+ }
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.28;
3
+
4
+ import "../agency/ICaveatEnforcer.sol";
5
+ import "../governance/StableProxyGoverned.sol";
6
+
7
+ /**
8
+ * @title PayloadClassesEnforcer — the INFORMATION-FLOW caveat (spec 410 §7)
9
+ * @notice Where a read precedes a write in one plan — read a member's record, then send a message — the
10
+ * mandate names, as ontology classes, what the write MAY CARRY: `apvault:ContactEmail`, never
11
+ * `apvault:GivingHistory`. terms = abi.encode(string[] classIris).
12
+ *
13
+ * THE CHAIN CANNOT READ A PAYLOAD, and this enforcer does not pretend to: its hooks are pure no-ops.
14
+ * What it does is pin the terms INTO THE SIGNED DELEGATION — the caveat is part of the EIP-712 hash
15
+ * the person approved — so the off-chain per-step verifier (`delegation.evaluateCaveats`, strict)
16
+ * judges the write's declared payload classes (the tool contract's `carries`, per argument) against
17
+ * exactly what was signed, and nobody can widen the list without a new signature. An enforcer that
18
+ * judged nothing and pinned nothing would be a comment; this one pins.
19
+ *
20
+ * What it is NOT: authority over the read (the read has its own mandate and scope), a content
21
+ * filter, or a substitute for the vault's per-record scope — those are enforced where the data is.
22
+ */
23
+ contract PayloadClassesEnforcer is ICaveatEnforcer, StableProxyGoverned {
24
+ /// @notice A direct deployment, initialized here (no governance: never upgradeable). Behind a stable proxy
25
+ /// (spec 447), `initialize(governance_)` instead — an enforcer's address is in every delegation that
26
+ /// names it, so a fix must keep the address.
27
+ constructor() initializer {}
28
+
29
+ function beforeHook(bytes calldata, bytes calldata, bytes32, address, address, address, uint256, bytes calldata) external pure override {}
30
+ function afterHook(bytes calldata, bytes calldata, bytes32, address, address, address, uint256, bytes calldata) external pure override {}
31
+
32
+ /// @notice The classes a wire's terms name — for a reader with the wire and no SDK.
33
+ function classesOf(bytes calldata terms) external pure returns (string[] memory) {
34
+ return abi.decode(terms, (string[]));
35
+ }
36
+ }