@agenticprimitives/contracts 1.0.0-alpha.48 → 1.0.0-alpha.49

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 (104) hide show
  1. package/AUDIT.md +36 -4
  2. package/dist/abi/AccountBootstrap.json +99 -0
  3. package/dist/abi/AgentAccount.json +95 -56
  4. package/dist/abi/AgentAccountFactory.json +189 -0
  5. package/dist/abi/AgentNameAttributeResolver.json +188 -0
  6. package/dist/abi/AgentNameRegistry.json +170 -0
  7. package/dist/abi/AgentNameUniversalResolver.json +188 -0
  8. package/dist/abi/AgentProfileResolver.json +188 -0
  9. package/dist/abi/AgentRegistryBase.json +193 -0
  10. package/dist/abi/AgentRelationship.json +193 -0
  11. package/dist/abi/AgenticGovernance.json +123 -0
  12. package/dist/abi/AgreementRegistry.json +193 -0
  13. package/dist/abi/AllowedMethodsEnforcer.json +193 -0
  14. package/dist/abi/AllowedTargetsEnforcer.json +193 -0
  15. package/dist/abi/ApprovedHashRegistry.json +220 -0
  16. package/dist/abi/AttestationRegistry.json +193 -0
  17. package/dist/abi/CallDataHashEnforcer.json +193 -0
  18. package/dist/abi/CustodyPolicy.json +195 -80
  19. package/dist/abi/DelegationManager.json +185 -0
  20. package/dist/abi/DigestBindingEnforcer.json +188 -0
  21. package/dist/abi/Eip7702.json +13 -0
  22. package/dist/abi/EstateProjectionRegistry.json +193 -0
  23. package/dist/abi/Generation5Bridge.json +355 -0
  24. package/dist/abi/GeoFeatureRegistry.json +193 -0
  25. package/dist/abi/ICustodyEpochView.json +28 -0
  26. package/dist/abi/IDelegationManager.json +18 -0
  27. package/dist/abi/IGeneration4Reads.json +143 -0
  28. package/dist/abi/IGeneration5Account.json +33 -0
  29. package/dist/abi/IGeneration5Voucher.json +26 -0
  30. package/dist/abi/IMoveAccountView.json +57 -0
  31. package/dist/abi/IMoveCustodyView.json +169 -0
  32. package/dist/abi/IMoveFactoryView.json +41 -0
  33. package/dist/abi/ITimelockVeto.json +93 -0
  34. package/dist/abi/OntologyTermRegistry.json +211 -0
  35. package/dist/abi/PayloadClassesEnforcer.json +193 -0
  36. package/dist/abi/PaymentEnforcer.json +188 -0
  37. package/dist/abi/PaymentEscrow.json +177 -0
  38. package/dist/abi/PaymentReceiptRegistry.json +206 -0
  39. package/dist/abi/PermissionlessSubregistry.json +188 -0
  40. package/dist/abi/PricedSubregistry.json +215 -0
  41. package/dist/abi/QuorumEnforcer.json +193 -0
  42. package/dist/abi/ReceiptAnchorRegistry.json +193 -0
  43. package/dist/abi/RelationshipTypeRegistry.json +211 -0
  44. package/dist/abi/ShapeRegistry.json +211 -0
  45. package/dist/abi/SignatureVerifier.json +196 -0
  46. package/dist/abi/SkillDefinitionRegistry.json +193 -0
  47. package/dist/abi/SmartAgentPaymaster.json +236 -1
  48. package/dist/abi/StableProxyGoverned.json +190 -0
  49. package/dist/abi/StableProxyGovernedOneShot.json +172 -0
  50. package/dist/abi/TimestampEnforcer.json +193 -0
  51. package/dist/abi/TreasurySpendPolicy.json +193 -0
  52. package/dist/abi/UpgradeVoucher.json +156 -4
  53. package/dist/abi/ValueEnforcer.json +193 -0
  54. package/dist/abi/index.d.ts +14 -0
  55. package/dist/abi/index.js +14 -0
  56. package/package.json +1 -1
  57. package/src/AccountBootstrap.sol +38 -0
  58. package/src/AgentAccount.sol +149 -41
  59. package/src/AgentAccountFactory.sol +52 -13
  60. package/src/ApprovedHashRegistry.sol +98 -9
  61. package/src/SmartAgentPaymaster.sol +96 -12
  62. package/src/UniversalSignatureValidator.sol +7 -0
  63. package/src/UpgradeVoucher.sol +16 -3
  64. package/src/agency/DelegationManager.sol +106 -32
  65. package/src/agency/IDelegationManager.sol +28 -0
  66. package/src/agreement/AgreementRegistry.sol +16 -15
  67. package/src/attestation/AttestationRegistry.sol +39 -16
  68. package/src/custody/CustodyPolicy.sol +36 -35
  69. package/src/custody/TreasurySpendPolicy.sol +10 -1
  70. package/src/enforcers/AllowedMethodsEnforcer.sol +7 -1
  71. package/src/enforcers/AllowedTargetsEnforcer.sol +7 -1
  72. package/src/enforcers/CallDataHashEnforcer.sol +7 -1
  73. package/src/enforcers/DigestBindingEnforcer.sol +5 -2
  74. package/src/enforcers/PayloadClassesEnforcer.sol +7 -1
  75. package/src/enforcers/PaymentEnforcer.sol +5 -2
  76. package/src/enforcers/QuorumEnforcer.sol +7 -1
  77. package/src/enforcers/TimestampEnforcer.sol +7 -1
  78. package/src/enforcers/ValueEnforcer.sol +7 -1
  79. package/src/geo/GeoFeatureRegistry.sol +15 -1
  80. package/src/governance/AgenticGovernance.sol +145 -0
  81. package/src/governance/GovernanceManaged.sol +2 -0
  82. package/src/governance/StableProxyGoverned.sol +79 -0
  83. package/src/governance/StableProxyGovernedOneShot.sol +93 -0
  84. package/src/identity/AgentProfileResolver.sol +11 -2
  85. package/src/libraries/Eip7702.sol +36 -0
  86. package/src/libraries/SignatureSlotRecovery.sol +4 -0
  87. package/src/libraries/SignatureVerifier.sol +52 -0
  88. package/src/libraries/WebAuthnLib.sol +3 -0
  89. package/src/migration/Generation5Bridge.sol +364 -0
  90. package/src/naming/AgentNameAttributeResolver.sol +12 -2
  91. package/src/naming/AgentNameRegistry.sol +84 -10
  92. package/src/naming/AgentNameUniversalResolver.sol +9 -2
  93. package/src/naming/PermissionlessSubregistry.sol +13 -2
  94. package/src/naming/PricedSubregistry.sol +59 -3
  95. package/src/ontology/OntologyTermRegistry.sol +30 -2
  96. package/src/ontology/ShapeRegistry.sol +30 -2
  97. package/src/payments/PaymentEscrow.sol +16 -1
  98. package/src/payments/PaymentReceiptRegistry.sol +28 -3
  99. package/src/provenance/ReceiptAnchorRegistry.sol +13 -1
  100. package/src/registry/AgentRegistryBase.sol +21 -1
  101. package/src/registry/EstateProjectionRegistry.sol +15 -1
  102. package/src/relationships/AgentRelationship.sol +17 -1
  103. package/src/relationships/RelationshipTypeRegistry.sol +30 -2
  104. package/src/skills/SkillDefinitionRegistry.sol +15 -1
@@ -3,6 +3,7 @@ pragma solidity ^0.8.28;
3
3
 
4
4
  import "./AgentNameRegistry.sol";
5
5
  import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
6
+ import "../governance/StableProxyGoverned.sol";
6
7
 
7
8
  /**
8
9
  * @title PermissionlessSubregistry
@@ -54,7 +55,7 @@ import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol
54
55
  /// could re-enter `register()` and pass the check a second time.
55
56
  /// The guard prevents any nested call into `register()`, closing
56
57
  /// the window. Recon doc § 4.1 / `docs/audits/r6-contracts-recon-2026-05-31.md`.
57
- contract PermissionlessSubregistry is ReentrancyGuard {
58
+ contract PermissionlessSubregistry is ReentrancyGuard, StableProxyGoverned {
58
59
  AgentNameRegistry public immutable REGISTRY;
59
60
  bytes32 public immutable PARENT_NODE;
60
61
  address public immutable DEFAULT_RESOLVER;
@@ -96,7 +97,14 @@ contract PermissionlessSubregistry is ReentrancyGuard {
96
97
 
97
98
  event Committed(bytes32 indexed commitment, address indexed by);
98
99
 
99
- constructor(AgentNameRegistry registry, bytes32 parentNode, address defaultResolver) {
100
+ /// @notice A DIRECT deployment, with no upgrade governance (frozen code, as before). Spec 447 — behind a stable
101
+ /// proxy, `initialize(governance_)` instead. The immutables stay: `REGISTRY` and `DEFAULT_RESOLVER` are
102
+ /// stable proxy addresses and `PARENT_NODE` is a constant of this instance (one subregistry serves one
103
+ /// parent), so a fix is a new implementation built with the same three values.
104
+ /// `ReentrancyGuard` (OZ 5.0.2, non-upgradeable) keeps `_status` in slot 0; behind a proxy it starts at 0,
105
+ /// which `_nonReentrantBefore` treats as not-entered (it reverts only on `ENTERED == 2`), and the first
106
+ /// guarded call leaves it at `NOT_ENTERED == 1`.
107
+ constructor(AgentNameRegistry registry, bytes32 parentNode, address defaultResolver) initializer {
100
108
  REGISTRY = registry;
101
109
  PARENT_NODE = parentNode;
102
110
  DEFAULT_RESOLVER = defaultResolver;
@@ -158,4 +166,7 @@ contract PermissionlessSubregistry is ReentrancyGuard {
158
166
  function hasClaimed(address caller) external view returns (bool) {
159
167
  return claimedBy[caller] != bytes32(0);
160
168
  }
169
+
170
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
171
+ uint256[46] private __gap;
161
172
  }
@@ -2,11 +2,13 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "./AgentNameRegistry.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
5
6
  import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
6
7
  import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
7
8
  import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
8
9
  import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
9
10
  import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
11
+ import "../governance/StableProxyGoverned.sol";
10
12
 
11
13
  /**
12
14
  * @title PricedSubregistry
@@ -33,7 +35,7 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
33
35
  * by `ticket.owner`, never by this contract. Governance (gates, fee treasury, the price table) is the governor's —
34
36
  * meant to be the root owner / the town's governor, and transferable.
35
37
  */
36
- contract PricedSubregistry is ReentrancyGuard, EIP712 {
38
+ contract PricedSubregistry is ReentrancyGuard, EIP712, StableProxyGoverned {
37
39
  using SafeERC20 for IERC20;
38
40
 
39
41
  AgentNameRegistry public immutable REGISTRY;
@@ -95,8 +97,11 @@ contract PricedSubregistry is ReentrancyGuard, EIP712 {
95
97
  error AlreadyClaimed(bytes32 existingNode);
96
98
  error LabelTooShort();
97
99
  error EmptyLabel();
100
+ /// @dev Spec 447 — `initialize(address)` alone would leave the governor, fee treasury and price table unset.
101
+ error GovernorRequired();
98
102
 
99
103
  modifier onlyGovernor() {
104
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
100
105
  if (msg.sender != governor) revert NotGovernor();
101
106
  _;
102
107
  }
@@ -111,12 +116,59 @@ contract PricedSubregistry is ReentrancyGuard, EIP712 {
111
116
  uint256 base_,
112
117
  uint16[5] memory multipliersX10_,
113
118
  uint256 cap_
114
- ) EIP712("PricedSubregistry", "1") {
115
- if (governor_ == address(0) || feeTreasury_ == address(0) || address(coin) == address(0)) revert ZeroAddress();
119
+ ) EIP712("PricedSubregistry", "1") initializer {
120
+ if (address(coin) == address(0)) revert ZeroAddress();
116
121
  REGISTRY = registry;
117
122
  PARENT_NODE = parentNode;
118
123
  DEFAULT_RESOLVER = defaultResolver;
119
124
  COIN = coin;
125
+ _initPricing(governor_, feeTreasury_, base_, multipliersX10_, cap_);
126
+ }
127
+
128
+ // ── spec 447: behind a stable proxy ─────────────────────────────────────────────────────────────────────
129
+ //
130
+ // A DIRECT deployment (above) has no upgrade governance: its code is frozen, as before. Behind a stable proxy
131
+ // the implementation is built with the same constructor arguments (its immutables are what the proxy runs
132
+ // with) and the proxy is initialized with `initialize(governance_, governor_, …)`, which sets the same storage
133
+ // the constructor sets. `governance` is the upgrade authority only; the `governor` runs the root as before.
134
+ //
135
+ // Immutables kept: `REGISTRY` and `DEFAULT_RESOLVER` are stable proxy addresses, `COIN` is a token address and
136
+ // `PARENT_NODE` a constant of this instance (one subregistry serves one root), so a fix is a new implementation
137
+ // built with the same four values.
138
+ //
139
+ // OZ `EIP712` (5.0.2) is proxy-safe: `_domainSeparatorV4()` returns the cached separator only when
140
+ // `address(this) == _cachedThis` (the implementation) and otherwise rebuilds it from `address(this)` — the
141
+ // proxy — so a gate signs tickets over the proxy's domain, and they stay valid across an upgrade that keeps
142
+ // the name and version. "PricedSubregistry" / "1" fit in a `ShortString`, so the name and version live in
143
+ // immutables, not in the `_nameFallback` / `_versionFallback` storage a proxy would see empty.
144
+ // `ReentrancyGuard` (5.0.2, non-upgradeable) starts at `_status == 0` behind a proxy, which it treats as
145
+ // not-entered (it reverts only on `ENTERED == 2`).
146
+
147
+ function initialize(
148
+ address governance_,
149
+ address governor_,
150
+ address feeTreasury_,
151
+ uint256 base_,
152
+ uint16[5] calldata multipliersX10_,
153
+ uint256 cap_
154
+ ) external initializer {
155
+ _initializeGovernance(governance_);
156
+ _initPricing(governor_, feeTreasury_, base_, multipliersX10_, cap_);
157
+ }
158
+
159
+ /// @dev The one-argument path would leave the governor, fee treasury and price table unset; refused.
160
+ function initialize(address) external pure override {
161
+ revert GovernorRequired();
162
+ }
163
+
164
+ function _initPricing(
165
+ address governor_,
166
+ address feeTreasury_,
167
+ uint256 base_,
168
+ uint16[5] memory multipliersX10_,
169
+ uint256 cap_
170
+ ) private {
171
+ if (governor_ == address(0) || feeTreasury_ == address(0)) revert ZeroAddress();
120
172
  governor = governor_;
121
173
  feeTreasury = feeTreasury_;
122
174
  base = base_;
@@ -229,9 +281,13 @@ contract PricedSubregistry is ReentrancyGuard, EIP712 {
229
281
 
230
282
  /// @notice Take the governor role. Only the proposed successor.
231
283
  function acceptGovernor() external {
284
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
232
285
  if (msg.sender != pendingGovernor || msg.sender == address(0)) revert NotPendingGovernor();
233
286
  emit GovernorTransferred(governor, msg.sender);
234
287
  governor = msg.sender;
235
288
  pendingGovernor = address(0);
236
289
  }
290
+
291
+ /// @dev Spec 447 — storage gap: the root may sit behind a stable proxy; layout gated by `check:storage-layouts`.
292
+ uint256[35] private __gap;
237
293
  }
@@ -1,5 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.28;
3
+ import "../governance/StableProxyGoverned.sol";
4
+ import {Eip7702} from "../libraries/Eip7702.sol";
3
5
 
4
6
  /**
5
7
  * @title OntologyTermRegistry
@@ -21,7 +23,7 @@ pragma solidity ^0.8.28;
21
23
  * structurally identical; copied here to keep the agenticprimitives
22
24
  * trust fabric self-contained.
23
25
  */
24
- contract OntologyTermRegistry {
26
+ contract OntologyTermRegistry is StableProxyGoverned {
25
27
  struct Term {
26
28
  bytes32 id; // keccak256("atl:displayName")
27
29
  string curie; // "atl:displayName"
@@ -45,13 +47,35 @@ contract OntologyTermRegistry {
45
47
  error TermExists();
46
48
  error TermNotFound();
47
49
  error ZeroGovernor();
50
+ /// @dev Spec 447 — `initialize(address)` alone would leave the governor unset.
51
+ error GovernorRequired();
48
52
 
49
53
  modifier onlyGovernor() {
54
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
50
55
  if (msg.sender != governor) revert NotGovernor();
51
56
  _;
52
57
  }
53
58
 
54
- constructor(address governor_) {
59
+ /// @notice A DIRECT deployment: `governor_` runs the registry, and there is no upgrade governance (the code is
60
+ /// frozen, as before). Spec 447 — behind a stable proxy, `initialize(governance_, governor_)` instead.
61
+ constructor(address governor_) initializer {
62
+ _initGovernor(governor_);
63
+ }
64
+
65
+ /// @notice Spec 447 — the proxy's initializer: `governance_` is the upgrade authority (only); `governor_` runs
66
+ /// the registry, exactly as the constructor's argument does. Once per proxy; never on the implementation.
67
+ function initialize(address governance_, address governor_) external initializer {
68
+ _initializeGovernance(governance_);
69
+ _initGovernor(governor_);
70
+ }
71
+
72
+ /// @dev Spec 447 — the one-argument path would leave `governor` unset (a registry nobody can run), so it is
73
+ /// refused: `initialize(governance_, governor_)` is this contract's only initializer.
74
+ function initialize(address) external pure override {
75
+ revert GovernorRequired();
76
+ }
77
+
78
+ function _initGovernor(address governor_) private {
55
79
  if (governor_ == address(0)) revert ZeroGovernor();
56
80
  governor = governor_;
57
81
  }
@@ -84,6 +108,7 @@ contract OntologyTermRegistry {
84
108
 
85
109
  /// @notice Take the governor role. Only the proposed successor.
86
110
  function acceptGovernor() external {
111
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
87
112
  if (msg.sender != pendingGovernor || msg.sender == address(0)) revert NotPendingGovernor();
88
113
  emit GovernorTransferred(governor, msg.sender);
89
114
  governor = msg.sender;
@@ -171,4 +196,7 @@ contract OntologyTermRegistry {
171
196
  function getAllTermIds() external view returns (bytes32[] memory) {
172
197
  return _termIds;
173
198
  }
199
+
200
+ /// @dev Spec 447 — storage gap: the registry may sit behind a stable proxy; layout gated by `check:storage-layouts`.
201
+ uint256[46] private __gap;
174
202
  }
@@ -2,6 +2,8 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "./AttributeStorage.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
6
+ import "../governance/StableProxyGoverned.sol";
5
7
 
6
8
  /**
7
9
  * @title ShapeRegistry
@@ -22,7 +24,7 @@ import "./AttributeStorage.sol";
22
24
  * (`packages/contracts/src/ShapeRegistry.sol`, 231 LOC) —
23
25
  * structurally identical.
24
26
  */
25
- contract ShapeRegistry {
27
+ contract ShapeRegistry is StableProxyGoverned {
26
28
  address public governor;
27
29
 
28
30
  enum Cardinality {
@@ -71,13 +73,35 @@ contract ShapeRegistry {
71
73
  error EnumValueNotAllowed(bytes32 predicate, bytes32 actualValue);
72
74
  error EnumSetEmpty();
73
75
  error ZeroGovernor();
76
+ /// @dev Spec 447 — `initialize(address)` alone would leave the governor unset.
77
+ error GovernorRequired();
74
78
 
75
79
  modifier onlyGovernor() {
80
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
76
81
  if (msg.sender != governor) revert NotGovernor();
77
82
  _;
78
83
  }
79
84
 
80
- constructor(address governor_) {
85
+ /// @notice A DIRECT deployment: `governor_` runs the registry, and there is no upgrade governance (the code is
86
+ /// frozen, as before). Spec 447 — behind a stable proxy, `initialize(governance_, governor_)` instead.
87
+ constructor(address governor_) initializer {
88
+ _initGovernor(governor_);
89
+ }
90
+
91
+ /// @notice Spec 447 — the proxy's initializer: `governance_` is the upgrade authority (only); `governor_` runs
92
+ /// the registry, exactly as the constructor's argument does. Once per proxy; never on the implementation.
93
+ function initialize(address governance_, address governor_) external initializer {
94
+ _initializeGovernance(governance_);
95
+ _initGovernor(governor_);
96
+ }
97
+
98
+ /// @dev Spec 447 — the one-argument path would leave `governor` unset (a registry nobody can run), so it is
99
+ /// refused: `initialize(governance_, governor_)` is this contract's only initializer.
100
+ function initialize(address) external pure override {
101
+ revert GovernorRequired();
102
+ }
103
+
104
+ function _initGovernor(address governor_) private {
81
105
  if (governor_ == address(0)) revert ZeroGovernor();
82
106
  governor = governor_;
83
107
  }
@@ -110,6 +134,7 @@ contract ShapeRegistry {
110
134
 
111
135
  /// @notice Take the governor role. Only the proposed successor.
112
136
  function acceptGovernor() external {
137
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
113
138
  if (msg.sender != pendingGovernor || msg.sender == address(0)) revert NotPendingGovernor();
114
139
  emit GovernorTransferred(governor, msg.sender);
115
140
  governor = msg.sender;
@@ -265,4 +290,7 @@ contract ShapeRegistry {
265
290
  function getClassIdAt(uint256 index) external view returns (bytes32) {
266
291
  return _classIds[index];
267
292
  }
293
+
294
+ /// @dev Spec 447 — storage gap: the registry may sit behind a stable proxy; layout gated by `check:storage-layouts`.
295
+ uint256[43] private __gap;
268
296
  }
@@ -2,8 +2,10 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
5
6
  import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
7
  import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
8
+ import "../governance/StableProxyGoverned.sol";
7
9
 
8
10
  /**
9
11
  * @title PaymentEscrow
@@ -20,7 +22,14 @@ import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol
20
22
  * Fail-closed: a hold moves Held → {Captured|Refunded|Reclaimed} once and never again
21
23
  * (checks-effects-interactions + ReentrancyGuard). Uses OZ SafeERC20 for fee/no-return tokens.
22
24
  */
23
- contract PaymentEscrow is ReentrancyGuard {
25
+ contract PaymentEscrow is ReentrancyGuard, StableProxyGoverned {
26
+ /// @notice Spec 447 — a DIRECT deployment, initialized here with no governance (its code is frozen, as
27
+ /// before). Behind a stable proxy, `initialize(governance_)` instead; the governance is then the only
28
+ /// upgrade authority. This contract has no admin of its own: governance can replace the code behind
29
+ /// the proxy and nothing else. `ReentrancyGuard` (OZ 5.0.2, non-upgradeable) keeps `_status` in slot 0;
30
+ /// behind a proxy it starts at 0, which it treats as not-entered (it reverts only on `ENTERED == 2`).
31
+ constructor() initializer {}
32
+
24
33
  using SafeERC20 for IERC20;
25
34
 
26
35
  enum Status {
@@ -128,6 +137,7 @@ contract PaymentEscrow is ReentrancyGuard {
128
137
  /// the payer's `reclaim` (removes the prior release/reclaim race; spec 243 §reclaim intent).
129
138
  function release(address payer, bytes32 orderHash) external nonReentrant {
130
139
  Hold storage h = _held(_key(payer, orderHash));
140
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
131
141
  if (msg.sender != h.payee && (h.releaser == address(0) || msg.sender != h.releaser)) revert NotAuthorized();
132
142
  if (block.timestamp >= h.expiry) revert Expired();
133
143
  h.status = Status.Captured;
@@ -138,6 +148,7 @@ contract PaymentEscrow is ReentrancyGuard {
138
148
  /// @notice Payee-consented refund of a held order to the payer (before capture). `payer` namespaces.
139
149
  function refund(address payer, bytes32 orderHash) external nonReentrant {
140
150
  Hold storage h = _held(_key(payer, orderHash));
151
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
141
152
  if (msg.sender != h.payee) revert NotAuthorized();
142
153
  h.status = Status.Refunded;
143
154
  emit EscrowRefunded(orderHash);
@@ -147,6 +158,7 @@ contract PaymentEscrow is ReentrancyGuard {
147
158
  /// @notice Payer reclaims a held order after expiry (never released). Payer-initiated → the hold is
148
159
  /// derived from `msg.sender`, so only the payer can reach their own hold.
149
160
  function reclaim(bytes32 orderHash) external nonReentrant {
161
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
150
162
  Hold storage h = _held(_key(msg.sender, orderHash));
151
163
  if (block.timestamp < h.expiry) revert NotYetExpired();
152
164
  h.status = Status.Reclaimed;
@@ -169,4 +181,7 @@ contract PaymentEscrow is ReentrancyGuard {
169
181
  if (h.status == Status.None) revert NoHold();
170
182
  if (h.status != Status.Held) revert NotHeld();
171
183
  }
184
+
185
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
186
+ uint256[48] private __gap;
172
187
  }
@@ -1,6 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.28;
3
3
 
4
+ import "../governance/StableProxyGoverned.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
6
+
4
7
  /**
5
8
  * @title PaymentReceiptRegistry
6
9
  * @notice Trustless, queryable settlement log for x402 pay-per-use (spec 272, PAY-CON-4 / X402-D9.3).
@@ -22,9 +25,12 @@ pragma solidity ^0.8.28;
22
25
  * that needs them to be true compares them with a record it trusts (the mandate it issued, the
23
26
  * resource it served); it never treats the row as that record.
24
27
  */
25
- contract PaymentReceiptRegistry {
28
+ contract PaymentReceiptRegistry is StableProxyGoverned {
26
29
  /// @notice The deployer who wires the sole authorized recorder once.
27
- address public immutable owner;
30
+ /// @dev Spec 447 — storage, no longer an immutable. An immutable `msg.sender` would be whoever deployed the
31
+ /// IMPLEMENTATION (behind a CREATE2 deploy, the singleton factory), and nobody could ever wire a proxy's
32
+ /// enforcer. The proxy's initializer names it explicitly.
33
+ address public owner;
28
34
  /// @notice The single PaymentEnforcer permitted to `record` (set once via {setEnforcer}).
29
35
  address public enforcer;
30
36
 
@@ -45,12 +51,28 @@ contract PaymentReceiptRegistry {
45
51
  error EnforcerAlreadySet();
46
52
  error ZeroAddress();
47
53
 
48
- constructor() {
54
+ /// @notice A DIRECT deployment: the deployer is the owner, and there is no upgrade governance (frozen code, as
55
+ /// before). Spec 447 — behind a stable proxy, `initialize(governance_, owner_)` instead.
56
+ constructor() initializer {
49
57
  owner = msg.sender;
50
58
  }
51
59
 
60
+ /// @notice Spec 447 — the proxy's initializer: `governance_` is the upgrade authority; `owner_` wires the
61
+ /// enforcer once, as the deployer does for a direct deployment. Once per proxy.
62
+ function initialize(address governance_, address owner_) external initializer {
63
+ if (owner_ == address(0)) revert ZeroAddress();
64
+ _initializeGovernance(governance_);
65
+ owner = owner_;
66
+ }
67
+
68
+ /// @dev The one-argument path would leave `owner` unset (nobody could ever wire the enforcer); refused.
69
+ function initialize(address) external pure override {
70
+ revert ZeroAddress();
71
+ }
72
+
52
73
  /// @notice One-time wiring: authorize the deployed {PaymentEnforcer} as the sole recorder.
53
74
  function setEnforcer(address enforcer_) external {
75
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
54
76
  if (msg.sender != owner) revert NotOwner();
55
77
  if (enforcer != address(0)) revert EnforcerAlreadySet();
56
78
  if (enforcer_ == address(0)) revert ZeroAddress();
@@ -72,4 +94,7 @@ contract PaymentReceiptRegistry {
72
94
  if (msg.sender != enforcer) revert NotEnforcer();
73
95
  emit PaymentSettled(mandateId, payer, payee, asset, amount, resourceHash, delegationHash, nonce);
74
96
  }
97
+
98
+ /// @dev Spec 447 — storage gap: the registry sits behind a stable proxy (the payment enforcer holds its address); layout gated by `check:storage-layouts`.
99
+ uint256[48] private __gap;
75
100
  }
@@ -1,5 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.28;
3
+ import "../governance/StableProxyGoverned.sol";
4
+ import {Eip7702} from "../libraries/Eip7702.sol";
3
5
 
4
6
  /**
5
7
  * @title ReceiptAnchorRegistry
@@ -17,7 +19,13 @@ pragma solidity ^0.8.28;
17
19
  * §1.5): rows are keyed by `(anchoredBy, receiptDigest)`, so a front-runner on a public mempool cannot
18
20
  * squat the digest ahead of the agent, and an anchor cannot be re-attributed after the fact.
19
21
  */
20
- contract ReceiptAnchorRegistry {
22
+ contract ReceiptAnchorRegistry is StableProxyGoverned {
23
+ /// @notice Spec 447 — a DIRECT deployment, initialized here with no governance (its code is frozen, as
24
+ /// before). Behind a stable proxy, `initialize(governance_)` instead; the governance is then the only
25
+ /// upgrade authority. This contract has no admin of its own: governance can replace the code behind
26
+ /// the proxy and nothing else.
27
+ constructor() initializer {}
28
+
21
29
  struct Anchor {
22
30
  address anchoredBy;
23
31
  uint64 at;
@@ -36,6 +44,7 @@ contract ReceiptAnchorRegistry {
36
44
 
37
45
  /// @notice Anchor a receipt digest, once per anchorer. `intentDigest` and `mandateRef` may be zero for a run under no mandate (a read).
38
46
  function anchor(bytes32 receiptDigest, bytes32 intentDigest, bytes32 mandateRef) external {
47
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
39
48
  if (receiptDigest == bytes32(0)) revert ZeroDigest();
40
49
  Anchor storage a = _anchors[msg.sender][receiptDigest];
41
50
  if (a.anchoredBy != address(0)) revert AlreadyAnchored(receiptDigest, a.anchoredBy);
@@ -52,4 +61,7 @@ contract ReceiptAnchorRegistry {
52
61
  function isAnchored(address anchoredBy, bytes32 receiptDigest) external view returns (bool) {
53
62
  return _anchors[anchoredBy][receiptDigest].anchoredBy != address(0);
54
63
  }
64
+
65
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
66
+ uint256[49] private __gap;
55
67
  }
@@ -2,6 +2,8 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import {IRegistryMembershipPolicy} from "./IRegistryMembershipPolicy.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
6
+ import "../governance/StableProxyGoverned.sol";
5
7
 
6
8
  /**
7
9
  * @title AgentRegistryBase
@@ -39,7 +41,13 @@ import {IRegistryMembershipPolicy} from "./IRegistryMembershipPolicy.sol";
39
41
  *
40
42
  * Spec 279 §4 + ADR-0010 / 0012 / 0013 / 0037 / 0038.
41
43
  */
42
- contract AgentRegistryBase {
44
+ contract AgentRegistryBase is StableProxyGoverned {
45
+ /// @notice Spec 447 — a DIRECT deployment, initialized here with no governance (its code is frozen, as
46
+ /// before). Behind a stable proxy, `initialize(governance_)` instead; the governance is then the only
47
+ /// upgrade authority. This contract has no admin of its own: governance can replace the code behind
48
+ /// the proxy and nothing else.
49
+ constructor() initializer {}
50
+
43
51
  // ─── Constants ──────────────────────────────────────────────────────
44
52
 
45
53
  /// @dev RB-07 — registration time is bucketed (provenance, not a precise clock). Mirrors AttestationRegistry.
@@ -135,6 +143,7 @@ contract AgentRegistryBase {
135
143
  /// concern (create the registry in the same flow that mints its urn), out of scope for this base.
136
144
  /// `policy == address(0)` ⇒ open registry: any SA may self-register, no admission gate.
137
145
  function createRegistry(bytes32 registryId, address policy) external {
146
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
138
147
  if (_registries[registryId].exists) revert RegistryExists();
139
148
  _registries[registryId] = Registry({controller: msg.sender, policy: policy, exists: true});
140
149
  emit RegistryCreated(registryId, msg.sender, policy);
@@ -146,6 +155,7 @@ contract AgentRegistryBase {
146
155
  function transferController(bytes32 registryId, address newController) external {
147
156
  Registry storage r = _registries[registryId];
148
157
  if (!r.exists) revert RegistryNotFound();
158
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
149
159
  if (msg.sender != r.controller) revert NotController();
150
160
  pendingControllerOf[registryId] = newController;
151
161
  emit RegistryControllerTransferStarted(registryId, msg.sender, newController);
@@ -155,6 +165,7 @@ contract AgentRegistryBase {
155
165
  function acceptController(bytes32 registryId) external {
156
166
  Registry storage r = _registries[registryId];
157
167
  if (!r.exists) revert RegistryNotFound();
168
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
158
169
  if (msg.sender != pendingControllerOf[registryId]) revert NotPendingController();
159
170
  emit RegistryControllerTransferred(registryId, r.controller, msg.sender);
160
171
  r.controller = msg.sender;
@@ -165,6 +176,7 @@ contract AgentRegistryBase {
165
176
  function setRegistryPolicy(bytes32 registryId, address policy) external {
166
177
  Registry storage r = _registries[registryId];
167
178
  if (!r.exists) revert RegistryNotFound();
179
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
168
180
  if (msg.sender != r.controller) revert NotController();
169
181
  r.policy = policy;
170
182
  emit RegistryPolicyUpdated(registryId, policy);
@@ -186,6 +198,7 @@ contract AgentRegistryBase {
186
198
  Registry storage r = _registries[registryId];
187
199
  if (!r.exists) revert RegistryNotFound();
188
200
  if (subjectAgent == address(0)) revert ZeroSubject();
201
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
189
202
  if (msg.sender != subjectAgent) revert SubjectMismatch(); // RB-01
190
203
  if (expiresAt != 0 && expiresAt <= block.timestamp) revert InvalidExpiry();
191
204
 
@@ -223,6 +236,7 @@ contract AgentRegistryBase {
223
236
  function renewEntry(bytes32 registryId, bytes32 entryId, uint64 expiresAt) external {
224
237
  Entry storage e = _entries[_entryKey(registryId, entryId)];
225
238
  if (e.status == EntryStatus.None) revert EntryNotFound();
239
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
226
240
  if (msg.sender != e.subjectAgent) revert SubjectMismatch(); // RB-01
227
241
  if (e.status != EntryStatus.Active) revert NotActive(); // RB-04 (Suspended/Revoked)
228
242
  if (expiresAt != 0 && expiresAt <= block.timestamp) revert InvalidExpiry();
@@ -246,6 +260,7 @@ contract AgentRegistryBase {
246
260
  ) external {
247
261
  Entry storage e = _entries[_entryKey(registryId, entryId)];
248
262
  if (e.status == EntryStatus.None) revert EntryNotFound();
263
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
249
264
  if (msg.sender != e.subjectAgent) revert SubjectMismatch(); // RB-01
250
265
  if (e.status != EntryStatus.Active) revert NotActive(); // RB-04 (Suspended/Revoked)
251
266
 
@@ -295,6 +310,7 @@ contract AgentRegistryBase {
295
310
  Entry storage e = _entries[key];
296
311
  if (e.status == EntryStatus.None) revert EntryNotFound();
297
312
  if (e.status == EntryStatus.Revoked) revert AlreadyRevoked(); // RB-04
313
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
298
314
  if (msg.sender != e.subjectAgent) _requireAdmin(registryId, entryId);
299
315
  _claims[key][claimSlotId] = claimHash;
300
316
  emit RegistryClaimUpdated(registryId, entryId, claimSlotId, claimHash);
@@ -338,6 +354,7 @@ contract AgentRegistryBase {
338
354
  /// no policy, a false return, or a revert all deny.
339
355
  function _requireAdmin(bytes32 registryId, bytes32 entryId) internal view {
340
356
  Registry storage r = _registries[registryId];
357
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
341
358
  if (msg.sender == r.controller) return;
342
359
  address policy = r.policy;
343
360
  if (policy != address(0)) {
@@ -349,4 +366,7 @@ contract AgentRegistryBase {
349
366
  }
350
367
  revert NotAuthorized();
351
368
  }
369
+
370
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
371
+ uint256[46] private __gap;
352
372
  }
@@ -1,5 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.28;
3
+ import "../governance/StableProxyGoverned.sol";
4
+ import {Eip7702} from "../libraries/Eip7702.sol";
3
5
 
4
6
  /**
5
7
  * @title EstateProjectionRegistry — an estate's authority, projected onto PUBLIC GROUND (spec 410 §4)
@@ -42,7 +44,13 @@ pragma solidity ^0.8.28;
42
44
  * WHAT THIS IS NOT: authority. A root proves what the estate vouches for at a moment; whether the
43
45
  * receiving estate lets an agent ACT is its own mandate, per step (ADR-0056 / ADR-0057).
44
46
  */
45
- contract EstateProjectionRegistry {
47
+ contract EstateProjectionRegistry is StableProxyGoverned {
48
+ /// @notice Spec 447 — a DIRECT deployment, initialized here with no governance (its code is frozen, as
49
+ /// before). Behind a stable proxy, `initialize(governance_)` instead; the governance is then the only
50
+ /// upgrade authority. This contract has no admin of its own: governance can replace the code behind
51
+ /// the proxy and nothing else.
52
+ constructor() initializer {}
53
+
46
54
  struct Roots {
47
55
  bytes32 liveGrantRoot;
48
56
  bytes32 membershipRoot;
@@ -79,6 +87,7 @@ contract EstateProjectionRegistry {
79
87
  /// by at most `MAX_SEQUENCE_STEP`). The first anchor opens the caller's row. Refreshed on every
80
88
  /// revocation and membership change; a verifier's freshness policy reads `anchoredAt`.
81
89
  function setRoots(bytes32 estateId, bytes32 liveGrantRoot, bytes32 membershipRoot, bytes32 charterHash, uint64 sequence) external {
90
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
82
91
  address successor = successorOf[estateId][msg.sender];
83
92
  if (successor != address(0)) revert SignerRetired(estateId, msg.sender, successor);
84
93
  Roots storage r = _roots[estateId][msg.sender];
@@ -101,6 +110,7 @@ contract EstateProjectionRegistry {
101
110
  /// for it) — the successor anchors for itself, and the estate's declaration is what makes a
102
111
  /// verifier read it.
103
112
  function rotateSigner(bytes32 estateId, address to) external {
113
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
104
114
  if (to == address(0) || to == msg.sender) revert ZeroAddress();
105
115
  // `anchoredAt == 0` is the "this signer never anchored" sentinel (storage default), not arithmetic.
106
116
  // slither-disable-next-line incorrect-equality
@@ -116,6 +126,7 @@ contract EstateProjectionRegistry {
116
126
  /// computed from `msg.sender` and `block.chainid`, so nobody can declare for another estate.
117
127
  /// Callable again to re-declare (rotation, or a lost key); zero clears the declaration.
118
128
  function declareSigner(address signer) external returns (bytes32 estateId) {
129
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
119
130
  estateId = estateIdOf(block.chainid, msg.sender);
120
131
  declaredSignerOf[estateId] = signer;
121
132
  emit EstateSignerDeclared(estateId, msg.sender, signer);
@@ -160,4 +171,7 @@ contract EstateProjectionRegistry {
160
171
  }
161
172
  return string(s);
162
173
  }
174
+
175
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
176
+ uint256[47] private __gap;
163
177
  }