@agenticprimitives/contracts 1.0.0-alpha.47 → 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 (110) hide show
  1. package/AUDIT.md +36 -4
  2. package/deployments-faithchain.json +94 -68
  3. package/deployments-hopechain.json +71 -52
  4. package/dist/abi/AccountBootstrap.json +99 -0
  5. package/dist/abi/AgentAccount.json +95 -56
  6. package/dist/abi/AgentAccountFactory.json +189 -0
  7. package/dist/abi/AgentNameAttributeResolver.json +188 -0
  8. package/dist/abi/AgentNameRegistry.json +170 -0
  9. package/dist/abi/AgentNameUniversalResolver.json +188 -0
  10. package/dist/abi/AgentProfileResolver.json +188 -0
  11. package/dist/abi/AgentRegistryBase.json +193 -0
  12. package/dist/abi/AgentRelationship.json +193 -0
  13. package/dist/abi/AgenticGovernance.json +123 -0
  14. package/dist/abi/AgreementRegistry.json +193 -0
  15. package/dist/abi/AllowedMethodsEnforcer.json +193 -0
  16. package/dist/abi/AllowedTargetsEnforcer.json +193 -0
  17. package/dist/abi/ApprovedHashRegistry.json +220 -0
  18. package/dist/abi/AttestationRegistry.json +193 -0
  19. package/dist/abi/CallDataHashEnforcer.json +193 -0
  20. package/dist/abi/CustodyPolicy.json +195 -80
  21. package/dist/abi/DelegationManager.json +185 -0
  22. package/dist/abi/DigestBindingEnforcer.json +188 -0
  23. package/dist/abi/Eip7702.json +13 -0
  24. package/dist/abi/EstateProjectionRegistry.json +193 -0
  25. package/dist/abi/Generation5Bridge.json +355 -0
  26. package/dist/abi/GeoFeatureRegistry.json +193 -0
  27. package/dist/abi/ICustodyEpochView.json +28 -0
  28. package/dist/abi/IDelegationManager.json +18 -0
  29. package/dist/abi/IGeneration4Reads.json +143 -0
  30. package/dist/abi/IGeneration5Account.json +33 -0
  31. package/dist/abi/IGeneration5Voucher.json +26 -0
  32. package/dist/abi/IMoveAccountView.json +57 -0
  33. package/dist/abi/IMoveCustodyView.json +169 -0
  34. package/dist/abi/IMoveFactoryView.json +41 -0
  35. package/dist/abi/ITimelockVeto.json +93 -0
  36. package/dist/abi/OntologyTermRegistry.json +211 -0
  37. package/dist/abi/PayloadClassesEnforcer.json +193 -0
  38. package/dist/abi/PaymentEnforcer.json +188 -0
  39. package/dist/abi/PaymentEscrow.json +177 -0
  40. package/dist/abi/PaymentReceiptRegistry.json +206 -0
  41. package/dist/abi/PermissionlessSubregistry.json +188 -0
  42. package/dist/abi/PricedSubregistry.json +215 -0
  43. package/dist/abi/QuorumEnforcer.json +193 -0
  44. package/dist/abi/ReceiptAnchorRegistry.json +193 -0
  45. package/dist/abi/RelationshipTypeRegistry.json +211 -0
  46. package/dist/abi/ShapeRegistry.json +211 -0
  47. package/dist/abi/SignatureVerifier.json +196 -0
  48. package/dist/abi/SkillDefinitionRegistry.json +193 -0
  49. package/dist/abi/SmartAgentPaymaster.json +236 -1
  50. package/dist/abi/StableProxyGoverned.json +190 -0
  51. package/dist/abi/StableProxyGovernedOneShot.json +172 -0
  52. package/dist/abi/TimestampEnforcer.json +193 -0
  53. package/dist/abi/TreasurySpendPolicy.json +193 -0
  54. package/dist/abi/UpgradeVoucher.json +156 -4
  55. package/dist/abi/ValueEnforcer.json +193 -0
  56. package/dist/abi/index.d.ts +14 -0
  57. package/dist/abi/index.js +14 -0
  58. package/dist/deployments/faithchain.d.ts +34 -14
  59. package/dist/deployments/faithchain.js +93 -69
  60. package/dist/deployments/hopechain.d.ts +20 -7
  61. package/dist/deployments/hopechain.js +72 -55
  62. package/package.json +1 -1
  63. package/src/AccountBootstrap.sol +38 -0
  64. package/src/AgentAccount.sol +149 -41
  65. package/src/AgentAccountFactory.sol +52 -13
  66. package/src/ApprovedHashRegistry.sol +98 -9
  67. package/src/SmartAgentPaymaster.sol +96 -12
  68. package/src/UniversalSignatureValidator.sol +7 -0
  69. package/src/UpgradeVoucher.sol +16 -3
  70. package/src/agency/DelegationManager.sol +106 -32
  71. package/src/agency/IDelegationManager.sol +28 -0
  72. package/src/agreement/AgreementRegistry.sol +16 -15
  73. package/src/attestation/AttestationRegistry.sol +39 -16
  74. package/src/custody/CustodyPolicy.sol +36 -35
  75. package/src/custody/TreasurySpendPolicy.sol +10 -1
  76. package/src/enforcers/AllowedMethodsEnforcer.sol +7 -1
  77. package/src/enforcers/AllowedTargetsEnforcer.sol +7 -1
  78. package/src/enforcers/CallDataHashEnforcer.sol +7 -1
  79. package/src/enforcers/DigestBindingEnforcer.sol +5 -2
  80. package/src/enforcers/PayloadClassesEnforcer.sol +7 -1
  81. package/src/enforcers/PaymentEnforcer.sol +5 -2
  82. package/src/enforcers/QuorumEnforcer.sol +7 -1
  83. package/src/enforcers/TimestampEnforcer.sol +7 -1
  84. package/src/enforcers/ValueEnforcer.sol +7 -1
  85. package/src/geo/GeoFeatureRegistry.sol +15 -1
  86. package/src/governance/AgenticGovernance.sol +145 -0
  87. package/src/governance/GovernanceManaged.sol +2 -0
  88. package/src/governance/StableProxyGoverned.sol +79 -0
  89. package/src/governance/StableProxyGovernedOneShot.sol +93 -0
  90. package/src/identity/AgentProfileResolver.sol +11 -2
  91. package/src/libraries/Eip7702.sol +36 -0
  92. package/src/libraries/SignatureSlotRecovery.sol +4 -0
  93. package/src/libraries/SignatureVerifier.sol +52 -0
  94. package/src/libraries/WebAuthnLib.sol +3 -0
  95. package/src/migration/Generation5Bridge.sol +364 -0
  96. package/src/naming/AgentNameAttributeResolver.sol +12 -2
  97. package/src/naming/AgentNameRegistry.sol +84 -10
  98. package/src/naming/AgentNameUniversalResolver.sol +9 -2
  99. package/src/naming/PermissionlessSubregistry.sol +13 -2
  100. package/src/naming/PricedSubregistry.sol +59 -3
  101. package/src/ontology/OntologyTermRegistry.sol +30 -2
  102. package/src/ontology/ShapeRegistry.sol +30 -2
  103. package/src/payments/PaymentEscrow.sol +16 -1
  104. package/src/payments/PaymentReceiptRegistry.sol +28 -3
  105. package/src/provenance/ReceiptAnchorRegistry.sol +13 -1
  106. package/src/registry/AgentRegistryBase.sol +21 -1
  107. package/src/registry/EstateProjectionRegistry.sol +15 -1
  108. package/src/relationships/AgentRelationship.sol +17 -1
  109. package/src/relationships/RelationshipTypeRegistry.sol +30 -2
  110. package/src/skills/SkillDefinitionRegistry.sol +15 -1
@@ -2,7 +2,9 @@
2
2
  pragma solidity ^0.8.28;
3
3
 
4
4
  import "./AgentNameRegistry.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
5
6
  import "../ontology/AttributeStorage.sol";
7
+ import "../governance/StableProxyGoverned.sol";
6
8
 
7
9
  /**
8
10
  * @title AgentNameAttributeResolver
@@ -29,13 +31,17 @@ import "../ontology/AttributeStorage.sol";
29
31
  * the same predicate ids and routes encode / decode through the typed
30
32
  * setters here. See `AgentNamePredicates.sol` for the canonical set.
31
33
  */
32
- contract AgentNameAttributeResolver is AttributeStorage {
34
+ contract AgentNameAttributeResolver is AttributeStorage, StableProxyGoverned {
33
35
  AgentNameRegistry public immutable REGISTRY;
34
36
 
35
37
  error NotAuthorized();
36
38
  error NodeNotFound();
37
39
 
38
- constructor(AgentNameRegistry registry, address ontology) AttributeStorage(ontology) {
40
+ /// @notice A DIRECT deployment, with no upgrade governance (frozen code, as before). Spec 447 — behind a stable
41
+ /// proxy, `initialize(governance_)` instead. `REGISTRY` and `ONTOLOGY` stay immutables: they are the
42
+ /// addresses of other stable proxies, which never change, so a fix is a new implementation built with
43
+ /// the same two addresses.
44
+ constructor(AgentNameRegistry registry, address ontology) AttributeStorage(ontology) initializer {
39
45
  REGISTRY = registry;
40
46
  }
41
47
 
@@ -105,6 +111,10 @@ contract AgentNameAttributeResolver is AttributeStorage {
105
111
 
106
112
  function _requireAuth(bytes32 node) internal view {
107
113
  if (!REGISTRY.recordExists(node)) revert NodeNotFound();
114
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
108
115
  if (msg.sender != REGISTRY.owner(node)) revert NotAuthorized();
109
116
  }
117
+
118
+ /// @dev Spec 447 — storage gap: the contract may sit behind a stable proxy; layout gated by `check:storage-layouts`.
119
+ uint256[35] private __gap;
110
120
  }
@@ -1,7 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.28;
3
3
 
4
- import "../governance/GovernanceManaged.sol";
4
+ import "../governance/StableProxyGovernedOneShot.sol";
5
+ import {Eip7702} from "../libraries/Eip7702.sol";
6
+ import "../governance/IGovernance.sol";
5
7
 
6
8
  /**
7
9
  * @title AgentNameRegistry
@@ -38,11 +40,21 @@ import "../governance/GovernanceManaged.sol";
38
40
  * discipline (a primary name only counts when the forward record
39
41
  * agrees).
40
42
  */
41
- /// @dev R6.8 — inherits `GovernanceManaged` to gain the
42
- /// `whenNotPaused` modifier on its mutating surface. The registry
43
- /// still owns its own per-node auth (`_requireParentAuth` /
44
- /// `msg.sender == owner`); governance only owns the pause flag.
45
- contract AgentNameRegistry is GovernanceManaged {
43
+ /// @dev R6.8 — `governance` gates the `whenNotPaused` modifier on the mutating surface. The registry
44
+ /// still owns its own per-node auth (`_requireParentAuth` / `msg.sender == owner`); governance owns
45
+ /// the pause flag, naming administration (with the initializer) and — spec 447 — the upgrade.
46
+ ///
47
+ /// Spec 447 (generation 5): deployable behind an ERC-1967 UUPS proxy at an address that never changes.
48
+ /// Before 447 this inherited `GovernanceManaged` (governance an IMMUTABLE); it now sits on
49
+ /// `StableProxyGovernedOneShot` (governance in an ERC-7201 slot, the sole upgrade authority) and keeps
50
+ /// `GovernanceManaged`'s surface here: the same `whenNotPaused` / `paused()` semantics and the same
51
+ /// error names (`NotGovernance`, `SystemPaused`, `ZeroGovernance`), so selectors are unchanged.
52
+ /// It cannot inherit OpenZeppelin's `Initializable`: the published `initializer()` role getter collides
53
+ /// with its `initializer` modifier; the base's one-shot guard in `Initializable`'s own ERC-7201 slot
54
+ /// stands in (`_initOnce`, same `InvalidInitialization` error). A direct deployment is initialized in the
55
+ /// constructor and can never be upgraded (`onlyProxy`); behind a proxy, `initialize(governance_,
56
+ /// initializer_)` is the only initializer.
57
+ contract AgentNameRegistry is StableProxyGovernedOneShot {
46
58
  // ─── H7-C.4 / CON-NAMING-001 — root-initializer gate ───────────────
47
59
  //
48
60
  // `initializeRoot` was permissionless: any mempool observer could
@@ -86,6 +98,9 @@ contract AgentNameRegistry is GovernanceManaged {
86
98
  // ─── Errors ─────────────────────────────────────────────────────
87
99
 
88
100
  error NotAuthorized();
101
+ /// @dev The `GovernanceManaged` errors this registry kept (same selectors as before spec 447).
102
+ error SystemPaused();
103
+ error ZeroGovernance();
89
104
  error NodeAlreadyExists();
90
105
  error NodeNotFound();
91
106
  error ParentNotFound();
@@ -202,7 +217,49 @@ contract AgentNameRegistry is GovernanceManaged {
202
217
  /// can't be frontrun. R6.8 added `governance_` so the
203
218
  /// registry can read the system pause flag through
204
219
  /// `GovernanceManaged._pausedSafe()`.
205
- constructor(address initializer_, address governance_) GovernanceManaged(governance_) {
220
+ constructor(address initializer_, address governance_) {
221
+ _initOnce();
222
+ _initializeGovernance(governance_);
223
+ _initNaming(initializer_);
224
+ }
225
+
226
+ /// @notice Spec 447 — the proxy's initializer: what the constructor sets, once per proxy. The
227
+ /// implementation itself can never be initialized (its constructor already was).
228
+ function initialize(address governance_, address initializer_) external {
229
+ _initOnce();
230
+ _initializeGovernance(governance_);
231
+ _initNaming(initializer_);
232
+ }
233
+
234
+ // ─── Spec 447 — initialization guard + governance (the kept `GovernanceManaged` surface) ─────
235
+
236
+ /// @dev As `GovernanceManaged`'s constructor: a registry needs a governance (pause + admin + upgrade).
237
+ function _initializeGovernance(address governance_) internal override {
238
+ if (governance_ == address(0)) revert ZeroGovernance();
239
+ super._initializeGovernance(governance_);
240
+ }
241
+
242
+ /// @dev Reverts when the governance pause flag is set (as `GovernanceManaged.whenNotPaused`).
243
+ modifier whenNotPaused() {
244
+ if (_pausedSafe()) revert SystemPaused();
245
+ _;
246
+ }
247
+
248
+ /// @notice Read the global pause flag. Returns false when governance is non-conforming.
249
+ function paused() external view returns (bool) {
250
+ return _pausedSafe();
251
+ }
252
+
253
+ /// @dev As `GovernanceManaged._pausedSafe`: an EOA / non-conforming governance is "not paused".
254
+ function _pausedSafe() internal view returns (bool) {
255
+ address gov = governance();
256
+ if (gov.code.length == 0) return false;
257
+ (bool ok, bytes memory data) = gov.staticcall(abi.encodeWithSelector(IGovernanceView.isPaused.selector));
258
+ if (!ok || data.length < 32) return false;
259
+ return abi.decode(data, (bool));
260
+ }
261
+
262
+ function _initNaming(address initializer_) private {
206
263
  if (initializer_ == address(0)) revert ZeroOwner();
207
264
  initializer = initializer_;
208
265
  // The fixed infrastructure hosts (agent-naming `RESERVED_LABELS` minus the type words, which
@@ -221,6 +278,7 @@ contract AgentNameRegistry is GovernanceManaged {
221
278
  /// this call (it can neither initialize a root nor name another successor afterwards), and
222
279
  /// nobody holds it until `to` accepts.
223
280
  function transferInitializer(address to) external {
281
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
224
282
  if (msg.sender != initializer) revert NotInitializer(msg.sender, initializer);
225
283
  if (initializerHandedOver) revert InitializerAlreadyHandedOver();
226
284
  if (to == address(0)) revert ZeroOwner();
@@ -233,6 +291,7 @@ contract AgentNameRegistry is GovernanceManaged {
233
291
  /// @notice Take the initializer role. Only the successor named by `transferInitializer`.
234
292
  function acceptInitializer() external {
235
293
  address to = pendingInitializer;
294
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
236
295
  if (to == address(0) || msg.sender != to) revert NotPendingInitializer(msg.sender);
237
296
  pendingInitializer = address(0);
238
297
  initializer = to;
@@ -244,7 +303,8 @@ contract AgentNameRegistry is GovernanceManaged {
244
303
  /// @dev Governance (the timelocked system authority) or the current initializer (the only account
245
304
  /// that may create a root, so strictly the stronger role during bootstrap).
246
305
  function _requireNamingAdmin() internal view {
247
- if (msg.sender != governance && (msg.sender != initializer || initializer == address(0))) revert NotAuthorized();
306
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
307
+ if (msg.sender != governance() && (msg.sender != initializer || initializer == address(0))) revert NotAuthorized();
248
308
  }
249
309
 
250
310
  /// @notice Reserve or release labels, by labelhash. Affects FUTURE registrations only.
@@ -323,6 +383,7 @@ contract AgentNameRegistry is GovernanceManaged {
323
383
  // frontrun window exists.
324
384
  // Spec 445: `initializer` is zero between `transferInitializer` and `acceptInitializer`, and
325
385
  // msg.sender is never zero, so nobody initializes during a hand-over.
386
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
326
387
  if (msg.sender != initializer) revert NotInitializer(msg.sender, initializer);
327
388
  // AN-1-ONCHAIN: canonical charset on chain. NAME-8: a root label carries no hyphen, so the
328
389
  // typed host `<label>-<type>` splits one way only (the suffix is the segment after the LAST `-`).
@@ -454,7 +515,14 @@ contract AgentNameRegistry is GovernanceManaged {
454
515
  // REG-4: records are the previous owner's statements (`atl:addr`, `atl:agentType`,
455
516
  // endpoints). They stop resolving here; the new owner writes its own. The `resolver` and
456
517
  // `subregistry` POINTERS are registry fields the new owner can read in one call and are
457
- // left as they are (a root hand-over keeps its subregistry) — a receiver checks them.
518
+ // left as they are (a root hand-over keeps a subregistry CONTRACT) — a receiver checks them.
519
+ // Audit 2026-12-02 C4-3 — with one exception: a subregistry pointer that names the OUTGOING
520
+ // owner (how every root is born) is that owner's own authority to issue names under the node.
521
+ // It leaves with the owner; the pointer follows the node to the new one.
522
+ if (r.subregistry == r.owner) {
523
+ r.subregistry = newOwner;
524
+ emit SubregistryChanged(node, newOwner);
525
+ }
458
526
  r.owner = newOwner;
459
527
  uint64 epoch = r.epoch + 1;
460
528
  r.epoch = epoch;
@@ -507,6 +575,7 @@ contract AgentNameRegistry is GovernanceManaged {
507
575
  // Storage default IS exactly 0; not a numeric precision concern.
508
576
  // slither-disable-next-line incorrect-equality
509
577
  if (node != bytes32(0) && _records[node].registeredAt == 0) revert NodeNotFound();
578
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
510
579
  _primaryName[msg.sender] = node;
511
580
  if (node == bytes32(0)) emit PrimaryNameCleared(msg.sender);
512
581
  else emit PrimaryNameSet(msg.sender, node);
@@ -583,6 +652,7 @@ contract AgentNameRegistry is GovernanceManaged {
583
652
  function _requireNodeAuth(bytes32 node) internal view {
584
653
  NameRecord storage r = _records[node];
585
654
  if (r.registeredAt == 0) revert NodeNotFound();
655
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
586
656
  if (msg.sender != r.owner) revert NotAuthorized();
587
657
  // REG-6: an expired name is nobody's — its former owner cannot move it, re-point it or
588
658
  // delegate under it while it waits to be reclaimed.
@@ -592,6 +662,7 @@ contract AgentNameRegistry is GovernanceManaged {
592
662
  function _requireParentAuth(bytes32 parentNode) internal view {
593
663
  NameRecord storage r = _records[parentNode];
594
664
  if (r.registeredAt == 0) revert ParentNotFound();
665
+ Eip7702.refuseDelegatedEOA(msg.sender); // spec 448 §0 (EIP-7702)
595
666
  if (msg.sender == r.owner) return;
596
667
  if (r.subregistry != address(0) && msg.sender == r.subregistry) return;
597
668
  revert NotAuthorized();
@@ -600,5 +671,8 @@ contract AgentNameRegistry is GovernanceManaged {
600
671
  function _requireNotExpired(bytes32 node) internal view {
601
672
  if (isExpired(node)) revert NameExpired();
602
673
  }
603
- }
604
674
 
675
+ /// @dev Spec 447 — storage gap: the registry may sit behind a stable proxy; layout gated by
676
+ /// `check:storage-layouts`.
677
+ uint256[36] private __gap;
678
+ }
@@ -4,6 +4,7 @@ pragma solidity ^0.8.28;
4
4
  import "./AgentNameRegistry.sol";
5
5
  import "./AgentNameAttributeResolver.sol";
6
6
  import "./AgentNamePredicates.sol";
7
+ import "../governance/StableProxyGoverned.sol";
7
8
 
8
9
  /**
9
10
  * @title AgentNameUniversalResolver
@@ -21,10 +22,13 @@ import "./AgentNamePredicates.sol";
21
22
  * permissive so callers can sequence forward + reverse writes
22
23
  * independently.
23
24
  */
24
- contract AgentNameUniversalResolver {
25
+ contract AgentNameUniversalResolver is StableProxyGoverned {
25
26
  AgentNameRegistry public immutable REGISTRY;
26
27
 
27
- constructor(AgentNameRegistry registry) {
28
+ /// @notice A DIRECT deployment, with no upgrade governance (frozen code, as before). Spec 447 — behind a stable
29
+ /// proxy, `initialize(governance_)` instead. `REGISTRY` stays an immutable: it is the name registry's
30
+ /// stable proxy address, which never changes. Stateless, so no storage gap.
31
+ constructor(AgentNameRegistry registry) initializer {
28
32
  REGISTRY = registry;
29
33
  }
30
34
 
@@ -175,6 +179,9 @@ contract AgentNameUniversalResolver {
175
179
  unchecked { depth++; }
176
180
  }
177
181
  if (depth == 0) return "";
182
+ // Audit 2026-12-02 C4-1: the walk stopped at the depth bound with ancestors left. The labels collected so
183
+ // far are NOT the name — joined, they read as a name under a different root. No name is the answer.
184
+ if (cur != bytes32(0)) return "";
178
185
 
179
186
  // Concatenate labels[0..depth-1] with '.' separators.
180
187
  uint256 totalLen = depth - 1; // for the dots
@@ -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
  }