@agenticprimitives/contracts 1.0.0-alpha.12 → 1.0.0-alpha.13

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.
@@ -5,6 +5,7 @@
5
5
  "agentNameResolver": "0xcC9855A23C7a4D4592E68Fe47E195C2f9D832473",
6
6
  "agentNameUniversalResolver": "0x7d777d2d0bbc1806B9Cc779121C27fbaAaFDb60b",
7
7
  "agentProfileResolver": "0xc448EB159B2a35F07f6E1814CC8d125244d7384B",
8
+ "agentRegistryBase": "0xe320947b18D3C71710DCB75D4bf200147ded18Df",
8
9
  "agentRelationship": "0xE6B8F6C7F1c9857013dA356DF08D0384334A9607",
9
10
  "agreementRegistry": "0x7f4d6A74eda1D6ce251D371566f1c6639F9B0DDa",
10
11
  "allowedMethodsEnforcer": "0xf77cf06aCd8b9e2f3204fe4bE16449B3594c9633",
@@ -0,0 +1,588 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "EPOCH_SECONDS",
5
+ "inputs": [],
6
+ "outputs": [
7
+ {
8
+ "name": "",
9
+ "type": "uint64",
10
+ "internalType": "uint64"
11
+ }
12
+ ],
13
+ "stateMutability": "view"
14
+ },
15
+ {
16
+ "type": "function",
17
+ "name": "createRegistry",
18
+ "inputs": [
19
+ {
20
+ "name": "registryId",
21
+ "type": "bytes32",
22
+ "internalType": "bytes32"
23
+ },
24
+ {
25
+ "name": "policy",
26
+ "type": "address",
27
+ "internalType": "address"
28
+ }
29
+ ],
30
+ "outputs": [],
31
+ "stateMutability": "nonpayable"
32
+ },
33
+ {
34
+ "type": "function",
35
+ "name": "getClaim",
36
+ "inputs": [
37
+ {
38
+ "name": "registryId",
39
+ "type": "bytes32",
40
+ "internalType": "bytes32"
41
+ },
42
+ {
43
+ "name": "entryId",
44
+ "type": "bytes32",
45
+ "internalType": "bytes32"
46
+ },
47
+ {
48
+ "name": "claimSlotId",
49
+ "type": "bytes32",
50
+ "internalType": "bytes32"
51
+ }
52
+ ],
53
+ "outputs": [
54
+ {
55
+ "name": "",
56
+ "type": "bytes32",
57
+ "internalType": "bytes32"
58
+ }
59
+ ],
60
+ "stateMutability": "view"
61
+ },
62
+ {
63
+ "type": "function",
64
+ "name": "getEntry",
65
+ "inputs": [
66
+ {
67
+ "name": "registryId",
68
+ "type": "bytes32",
69
+ "internalType": "bytes32"
70
+ },
71
+ {
72
+ "name": "entryId",
73
+ "type": "bytes32",
74
+ "internalType": "bytes32"
75
+ }
76
+ ],
77
+ "outputs": [
78
+ {
79
+ "name": "",
80
+ "type": "tuple",
81
+ "internalType": "struct AgentRegistryBase.Entry",
82
+ "components": [
83
+ {
84
+ "name": "subjectAgent",
85
+ "type": "address",
86
+ "internalType": "address"
87
+ },
88
+ {
89
+ "name": "cardHash",
90
+ "type": "bytes32",
91
+ "internalType": "bytes32"
92
+ },
93
+ {
94
+ "name": "bindingProofHash",
95
+ "type": "bytes32",
96
+ "internalType": "bytes32"
97
+ },
98
+ {
99
+ "name": "claimsRoot",
100
+ "type": "bytes32",
101
+ "internalType": "bytes32"
102
+ },
103
+ {
104
+ "name": "status",
105
+ "type": "uint8",
106
+ "internalType": "enum AgentRegistryBase.EntryStatus"
107
+ },
108
+ {
109
+ "name": "registeredAtBucket",
110
+ "type": "uint64",
111
+ "internalType": "uint64"
112
+ },
113
+ {
114
+ "name": "expiresAt",
115
+ "type": "uint64",
116
+ "internalType": "uint64"
117
+ }
118
+ ]
119
+ }
120
+ ],
121
+ "stateMutability": "view"
122
+ },
123
+ {
124
+ "type": "function",
125
+ "name": "getRegistry",
126
+ "inputs": [
127
+ {
128
+ "name": "registryId",
129
+ "type": "bytes32",
130
+ "internalType": "bytes32"
131
+ }
132
+ ],
133
+ "outputs": [
134
+ {
135
+ "name": "",
136
+ "type": "tuple",
137
+ "internalType": "struct AgentRegistryBase.Registry",
138
+ "components": [
139
+ {
140
+ "name": "controller",
141
+ "type": "address",
142
+ "internalType": "address"
143
+ },
144
+ {
145
+ "name": "policy",
146
+ "type": "address",
147
+ "internalType": "address"
148
+ },
149
+ {
150
+ "name": "exists",
151
+ "type": "bool",
152
+ "internalType": "bool"
153
+ }
154
+ ]
155
+ }
156
+ ],
157
+ "stateMutability": "view"
158
+ },
159
+ {
160
+ "type": "function",
161
+ "name": "isActive",
162
+ "inputs": [
163
+ {
164
+ "name": "registryId",
165
+ "type": "bytes32",
166
+ "internalType": "bytes32"
167
+ },
168
+ {
169
+ "name": "entryId",
170
+ "type": "bytes32",
171
+ "internalType": "bytes32"
172
+ }
173
+ ],
174
+ "outputs": [
175
+ {
176
+ "name": "",
177
+ "type": "bool",
178
+ "internalType": "bool"
179
+ }
180
+ ],
181
+ "stateMutability": "view"
182
+ },
183
+ {
184
+ "type": "function",
185
+ "name": "registerEntry",
186
+ "inputs": [
187
+ {
188
+ "name": "registryId",
189
+ "type": "bytes32",
190
+ "internalType": "bytes32"
191
+ },
192
+ {
193
+ "name": "entryId",
194
+ "type": "bytes32",
195
+ "internalType": "bytes32"
196
+ },
197
+ {
198
+ "name": "subjectAgent",
199
+ "type": "address",
200
+ "internalType": "address"
201
+ },
202
+ {
203
+ "name": "cardHash",
204
+ "type": "bytes32",
205
+ "internalType": "bytes32"
206
+ },
207
+ {
208
+ "name": "bindingProofHash",
209
+ "type": "bytes32",
210
+ "internalType": "bytes32"
211
+ },
212
+ {
213
+ "name": "claimHashes",
214
+ "type": "bytes32[]",
215
+ "internalType": "bytes32[]"
216
+ },
217
+ {
218
+ "name": "expiresAt",
219
+ "type": "uint64",
220
+ "internalType": "uint64"
221
+ }
222
+ ],
223
+ "outputs": [],
224
+ "stateMutability": "nonpayable"
225
+ },
226
+ {
227
+ "type": "function",
228
+ "name": "renewEntry",
229
+ "inputs": [
230
+ {
231
+ "name": "registryId",
232
+ "type": "bytes32",
233
+ "internalType": "bytes32"
234
+ },
235
+ {
236
+ "name": "entryId",
237
+ "type": "bytes32",
238
+ "internalType": "bytes32"
239
+ },
240
+ {
241
+ "name": "expiresAt",
242
+ "type": "uint64",
243
+ "internalType": "uint64"
244
+ }
245
+ ],
246
+ "outputs": [],
247
+ "stateMutability": "nonpayable"
248
+ },
249
+ {
250
+ "type": "function",
251
+ "name": "revokeEntry",
252
+ "inputs": [
253
+ {
254
+ "name": "registryId",
255
+ "type": "bytes32",
256
+ "internalType": "bytes32"
257
+ },
258
+ {
259
+ "name": "entryId",
260
+ "type": "bytes32",
261
+ "internalType": "bytes32"
262
+ },
263
+ {
264
+ "name": "reasonHash",
265
+ "type": "bytes32",
266
+ "internalType": "bytes32"
267
+ }
268
+ ],
269
+ "outputs": [],
270
+ "stateMutability": "nonpayable"
271
+ },
272
+ {
273
+ "type": "function",
274
+ "name": "setRegistryPolicy",
275
+ "inputs": [
276
+ {
277
+ "name": "registryId",
278
+ "type": "bytes32",
279
+ "internalType": "bytes32"
280
+ },
281
+ {
282
+ "name": "policy",
283
+ "type": "address",
284
+ "internalType": "address"
285
+ }
286
+ ],
287
+ "outputs": [],
288
+ "stateMutability": "nonpayable"
289
+ },
290
+ {
291
+ "type": "function",
292
+ "name": "suspendEntry",
293
+ "inputs": [
294
+ {
295
+ "name": "registryId",
296
+ "type": "bytes32",
297
+ "internalType": "bytes32"
298
+ },
299
+ {
300
+ "name": "entryId",
301
+ "type": "bytes32",
302
+ "internalType": "bytes32"
303
+ },
304
+ {
305
+ "name": "reasonHash",
306
+ "type": "bytes32",
307
+ "internalType": "bytes32"
308
+ }
309
+ ],
310
+ "outputs": [],
311
+ "stateMutability": "nonpayable"
312
+ },
313
+ {
314
+ "type": "function",
315
+ "name": "updateClaim",
316
+ "inputs": [
317
+ {
318
+ "name": "registryId",
319
+ "type": "bytes32",
320
+ "internalType": "bytes32"
321
+ },
322
+ {
323
+ "name": "entryId",
324
+ "type": "bytes32",
325
+ "internalType": "bytes32"
326
+ },
327
+ {
328
+ "name": "claimSlotId",
329
+ "type": "bytes32",
330
+ "internalType": "bytes32"
331
+ },
332
+ {
333
+ "name": "claimHash",
334
+ "type": "bytes32",
335
+ "internalType": "bytes32"
336
+ }
337
+ ],
338
+ "outputs": [],
339
+ "stateMutability": "nonpayable"
340
+ },
341
+ {
342
+ "type": "event",
343
+ "name": "RegistryClaimUpdated",
344
+ "inputs": [
345
+ {
346
+ "name": "registryId",
347
+ "type": "bytes32",
348
+ "indexed": true,
349
+ "internalType": "bytes32"
350
+ },
351
+ {
352
+ "name": "entryId",
353
+ "type": "bytes32",
354
+ "indexed": true,
355
+ "internalType": "bytes32"
356
+ },
357
+ {
358
+ "name": "claimSlotId",
359
+ "type": "bytes32",
360
+ "indexed": true,
361
+ "internalType": "bytes32"
362
+ },
363
+ {
364
+ "name": "claimHash",
365
+ "type": "bytes32",
366
+ "indexed": false,
367
+ "internalType": "bytes32"
368
+ }
369
+ ],
370
+ "anonymous": false
371
+ },
372
+ {
373
+ "type": "event",
374
+ "name": "RegistryCreated",
375
+ "inputs": [
376
+ {
377
+ "name": "registryId",
378
+ "type": "bytes32",
379
+ "indexed": true,
380
+ "internalType": "bytes32"
381
+ },
382
+ {
383
+ "name": "controller",
384
+ "type": "address",
385
+ "indexed": true,
386
+ "internalType": "address"
387
+ },
388
+ {
389
+ "name": "policy",
390
+ "type": "address",
391
+ "indexed": false,
392
+ "internalType": "address"
393
+ }
394
+ ],
395
+ "anonymous": false
396
+ },
397
+ {
398
+ "type": "event",
399
+ "name": "RegistryEntryRegistered",
400
+ "inputs": [
401
+ {
402
+ "name": "registryId",
403
+ "type": "bytes32",
404
+ "indexed": true,
405
+ "internalType": "bytes32"
406
+ },
407
+ {
408
+ "name": "entryId",
409
+ "type": "bytes32",
410
+ "indexed": true,
411
+ "internalType": "bytes32"
412
+ },
413
+ {
414
+ "name": "subjectAgent",
415
+ "type": "address",
416
+ "indexed": true,
417
+ "internalType": "address"
418
+ },
419
+ {
420
+ "name": "cardHash",
421
+ "type": "bytes32",
422
+ "indexed": false,
423
+ "internalType": "bytes32"
424
+ },
425
+ {
426
+ "name": "bindingProofHash",
427
+ "type": "bytes32",
428
+ "indexed": false,
429
+ "internalType": "bytes32"
430
+ }
431
+ ],
432
+ "anonymous": false
433
+ },
434
+ {
435
+ "type": "event",
436
+ "name": "RegistryEntryRenewed",
437
+ "inputs": [
438
+ {
439
+ "name": "registryId",
440
+ "type": "bytes32",
441
+ "indexed": true,
442
+ "internalType": "bytes32"
443
+ },
444
+ {
445
+ "name": "entryId",
446
+ "type": "bytes32",
447
+ "indexed": true,
448
+ "internalType": "bytes32"
449
+ },
450
+ {
451
+ "name": "expiresAt",
452
+ "type": "uint64",
453
+ "indexed": false,
454
+ "internalType": "uint64"
455
+ }
456
+ ],
457
+ "anonymous": false
458
+ },
459
+ {
460
+ "type": "event",
461
+ "name": "RegistryEntryRevoked",
462
+ "inputs": [
463
+ {
464
+ "name": "registryId",
465
+ "type": "bytes32",
466
+ "indexed": true,
467
+ "internalType": "bytes32"
468
+ },
469
+ {
470
+ "name": "entryId",
471
+ "type": "bytes32",
472
+ "indexed": true,
473
+ "internalType": "bytes32"
474
+ },
475
+ {
476
+ "name": "reasonHash",
477
+ "type": "bytes32",
478
+ "indexed": false,
479
+ "internalType": "bytes32"
480
+ }
481
+ ],
482
+ "anonymous": false
483
+ },
484
+ {
485
+ "type": "event",
486
+ "name": "RegistryEntrySuspended",
487
+ "inputs": [
488
+ {
489
+ "name": "registryId",
490
+ "type": "bytes32",
491
+ "indexed": true,
492
+ "internalType": "bytes32"
493
+ },
494
+ {
495
+ "name": "entryId",
496
+ "type": "bytes32",
497
+ "indexed": true,
498
+ "internalType": "bytes32"
499
+ },
500
+ {
501
+ "name": "reasonHash",
502
+ "type": "bytes32",
503
+ "indexed": false,
504
+ "internalType": "bytes32"
505
+ }
506
+ ],
507
+ "anonymous": false
508
+ },
509
+ {
510
+ "type": "event",
511
+ "name": "RegistryPolicyUpdated",
512
+ "inputs": [
513
+ {
514
+ "name": "registryId",
515
+ "type": "bytes32",
516
+ "indexed": true,
517
+ "internalType": "bytes32"
518
+ },
519
+ {
520
+ "name": "policy",
521
+ "type": "address",
522
+ "indexed": false,
523
+ "internalType": "address"
524
+ }
525
+ ],
526
+ "anonymous": false
527
+ },
528
+ {
529
+ "type": "error",
530
+ "name": "AlreadyRevoked",
531
+ "inputs": []
532
+ },
533
+ {
534
+ "type": "error",
535
+ "name": "EntryExists",
536
+ "inputs": []
537
+ },
538
+ {
539
+ "type": "error",
540
+ "name": "EntryNotFound",
541
+ "inputs": []
542
+ },
543
+ {
544
+ "type": "error",
545
+ "name": "InvalidExpiry",
546
+ "inputs": []
547
+ },
548
+ {
549
+ "type": "error",
550
+ "name": "MembershipDenied",
551
+ "inputs": []
552
+ },
553
+ {
554
+ "type": "error",
555
+ "name": "NotActive",
556
+ "inputs": []
557
+ },
558
+ {
559
+ "type": "error",
560
+ "name": "NotAuthorized",
561
+ "inputs": []
562
+ },
563
+ {
564
+ "type": "error",
565
+ "name": "NotController",
566
+ "inputs": []
567
+ },
568
+ {
569
+ "type": "error",
570
+ "name": "RegistryExists",
571
+ "inputs": []
572
+ },
573
+ {
574
+ "type": "error",
575
+ "name": "RegistryNotFound",
576
+ "inputs": []
577
+ },
578
+ {
579
+ "type": "error",
580
+ "name": "SubjectMismatch",
581
+ "inputs": []
582
+ },
583
+ {
584
+ "type": "error",
585
+ "name": "ZeroSubject",
586
+ "inputs": []
587
+ }
588
+ ]
@@ -0,0 +1,70 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "canAdminister",
5
+ "inputs": [
6
+ {
7
+ "name": "registryId",
8
+ "type": "bytes32",
9
+ "internalType": "bytes32"
10
+ },
11
+ {
12
+ "name": "entryId",
13
+ "type": "bytes32",
14
+ "internalType": "bytes32"
15
+ },
16
+ {
17
+ "name": "actor",
18
+ "type": "address",
19
+ "internalType": "address"
20
+ }
21
+ ],
22
+ "outputs": [
23
+ {
24
+ "name": "ok",
25
+ "type": "bool",
26
+ "internalType": "bool"
27
+ }
28
+ ],
29
+ "stateMutability": "view"
30
+ },
31
+ {
32
+ "type": "function",
33
+ "name": "canRegister",
34
+ "inputs": [
35
+ {
36
+ "name": "registryId",
37
+ "type": "bytes32",
38
+ "internalType": "bytes32"
39
+ },
40
+ {
41
+ "name": "entryId",
42
+ "type": "bytes32",
43
+ "internalType": "bytes32"
44
+ },
45
+ {
46
+ "name": "subjectAgent",
47
+ "type": "address",
48
+ "internalType": "address"
49
+ },
50
+ {
51
+ "name": "cardHash",
52
+ "type": "bytes32",
53
+ "internalType": "bytes32"
54
+ },
55
+ {
56
+ "name": "claimHashes",
57
+ "type": "bytes32[]",
58
+ "internalType": "bytes32[]"
59
+ }
60
+ ],
61
+ "outputs": [
62
+ {
63
+ "name": "ok",
64
+ "type": "bool",
65
+ "internalType": "bool"
66
+ }
67
+ ],
68
+ "stateMutability": "view"
69
+ }
70
+ ]
@@ -10,6 +10,7 @@ export declare const AgentNameRegistry: Abi;
10
10
  export declare const AgentNameUniversalResolver: Abi;
11
11
  export declare const AgentProfilePredicates: Abi;
12
12
  export declare const AgentProfileResolver: Abi;
13
+ export declare const AgentRegistryBase: Abi;
13
14
  export declare const AgentRelationship: Abi;
14
15
  export declare const AgentRelationshipPredicates: Abi;
15
16
  export declare const AgreementRegistry: Abi;
@@ -41,6 +42,7 @@ export declare const IERC7579ModuleLifecycle: Abi;
41
42
  export declare const IERC7579ModuleLike: Abi;
42
43
  export declare const IGovernanceView: Abi;
43
44
  export declare const IPaymentReceiptRegistry: Abi;
45
+ export declare const IRegistryMembershipPolicy: Abi;
44
46
  export declare const MockUSDC: Abi;
45
47
  export declare const MultiSendCallOnly: Abi;
46
48
  export declare const MultiSendCallOnlyHarness: Abi;
package/dist/abi/index.js CHANGED
@@ -10,6 +10,7 @@ export { default as AgentNameRegistry } from './AgentNameRegistry.json' with { t
10
10
  export { default as AgentNameUniversalResolver } from './AgentNameUniversalResolver.json' with { type: 'json' };
11
11
  export { default as AgentProfilePredicates } from './AgentProfilePredicates.json' with { type: 'json' };
12
12
  export { default as AgentProfileResolver } from './AgentProfileResolver.json' with { type: 'json' };
13
+ export { default as AgentRegistryBase } from './AgentRegistryBase.json' with { type: 'json' };
13
14
  export { default as AgentRelationship } from './AgentRelationship.json' with { type: 'json' };
14
15
  export { default as AgentRelationshipPredicates } from './AgentRelationshipPredicates.json' with { type: 'json' };
15
16
  export { default as AgreementRegistry } from './AgreementRegistry.json' with { type: 'json' };
@@ -41,6 +42,7 @@ export { default as IERC7579ModuleLifecycle } from './IERC7579ModuleLifecycle.js
41
42
  export { default as IERC7579ModuleLike } from './IERC7579ModuleLike.json' with { type: 'json' };
42
43
  export { default as IGovernanceView } from './IGovernanceView.json' with { type: 'json' };
43
44
  export { default as IPaymentReceiptRegistry } from './IPaymentReceiptRegistry.json' with { type: 'json' };
45
+ export { default as IRegistryMembershipPolicy } from './IRegistryMembershipPolicy.json' with { type: 'json' };
44
46
  export { default as MockUSDC } from './MockUSDC.json' with { type: 'json' };
45
47
  export { default as MultiSendCallOnly } from './MultiSendCallOnly.json' with { type: 'json' };
46
48
  export { default as MultiSendCallOnlyHarness } from './MultiSendCallOnlyHarness.json' with { type: 'json' };
@@ -8,6 +8,7 @@ export interface Deployments {
8
8
  readonly "agentNameResolver": Address;
9
9
  readonly "agentNameUniversalResolver": Address;
10
10
  readonly "agentProfileResolver": Address;
11
+ readonly "agentRegistryBase": Address;
11
12
  readonly "agentRelationship": Address;
12
13
  readonly "agreementRegistry": Address;
13
14
  readonly "allowedMethodsEnforcer": Address;
@@ -7,6 +7,7 @@ export const CONTRACTS = {
7
7
  "agentNameResolver": "0xcC9855A23C7a4D4592E68Fe47E195C2f9D832473",
8
8
  "agentNameUniversalResolver": "0x7d777d2d0bbc1806B9Cc779121C27fbaAaFDb60b",
9
9
  "agentProfileResolver": "0xc448EB159B2a35F07f6E1814CC8d125244d7384B",
10
+ "agentRegistryBase": "0xe320947b18D3C71710DCB75D4bf200147ded18Df",
10
11
  "agentRelationship": "0xE6B8F6C7F1c9857013dA356DF08D0384334A9607",
11
12
  "agreementRegistry": "0x7f4d6A74eda1D6ce251D371566f1c6639F9B0DDa",
12
13
  "allowedMethodsEnforcer": "0xf77cf06aCd8b9e2f3204fe4bE16449B3594c9633",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticprimitives/contracts",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Solidity contracts + ABIs + flattened sources + per-network deployment addresses for the agenticprimitives stack.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,281 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.28;
3
+
4
+ import {IRegistryMembershipPolicy} from "./IRegistryMembershipPolicy.sol";
5
+
6
+ /**
7
+ * @title AgentRegistryBase
8
+ * @notice The generic, SA-anchored registry base that vertical registries are built FROM (spec 279 §4,
9
+ * ADR-0038 "many-registries"). It is a MEMBERSHIP LEDGER of facets — entries that point AT a
10
+ * Smart Agent address — not an account. It holds no funds, signs nothing, executes nothing, and
11
+ * grants NO authority to act: an entry is evidence ("this SA is a member of registry R, here is
12
+ * its card hash + binding-proof hash + claims"), never a delegation. Authority lives in the
13
+ * AgentAccount + DelegationManager; this contract only records and gates membership.
14
+ *
15
+ * ─── How it differs from AgentAccount ───
16
+ * AgentAccount IS the agent (ERC-4337/7579 custody + execution + ERC-1271). AgentRegistryBase is
17
+ * a directory of MANY entries pointing at MANY agents, one instance per registry. The subject SA
18
+ * controls its own entry because it must be the caller (RB-01); the registry's controller / policy
19
+ * hook gates admission + ejection (RB-02/03). The binding proof referenced by `bindingProofHash`
20
+ * is verified OFF-CHAIN by a verifier (registry-kit `verifyEntryBindingProof`) against the
21
+ * subject SA's ERC-1271 — this contract stores the hash as a pointer, it does not re-verify it.
22
+ *
23
+ * ─── Key invariants (RB-*) ───
24
+ * RB-01 entry control follows the subject SA custody policy — register / renew / self-revoke /
25
+ * self-update require `msg.sender == subjectAgent` (so the SA's own custody produced the
26
+ * call); the contract never re-implements custody.
27
+ * RB-02 admission is gated by the registry's pluggable membership hook (or open if unset); a
28
+ * policy returning false OR reverting fails closed (ADR-0013) — no second path.
29
+ * RB-03 suspension / revocation / claim-update by a non-subject require the registry controller
30
+ * OR a policy-authorized actor (`canAdminister`); never an arbitrary caller.
31
+ * RB-04 revocation is terminal; a revoked entry cannot be renewed, re-registered, suspended, or
32
+ * claim-updated.
33
+ * RB-05 NO external-registry-protocol fields in storage (no ENS/8004/HCS/OASF) — those are
34
+ * external projections (ADR-0037), not AP state.
35
+ * RB-06 reads are storage views only — discovery never scans chain logs (ADR-0012); the indexer
36
+ * consumes the events below.
37
+ * RB-07 epoch-bucket registration timestamps (raw block.timestamp never stored); `expiresAt` is a
38
+ * caller-supplied absolute unix-seconds bound compared against block.timestamp for liveness.
39
+ *
40
+ * Spec 279 §4 + ADR-0010 / 0012 / 0013 / 0037 / 0038.
41
+ */
42
+ contract AgentRegistryBase {
43
+ // ─── Constants ──────────────────────────────────────────────────────
44
+
45
+ /// @dev RB-07 — registration time is bucketed (provenance, not a precise clock). Mirrors AttestationRegistry.
46
+ uint64 public constant EPOCH_SECONDS = 3600;
47
+
48
+ // ─── Types ──────────────────────────────────────────────────────────
49
+
50
+ /// @dev Stored status. `Expired` is NOT stored (no keeper to flip it) — it is DERIVED from `expiresAt`
51
+ /// by {isActive}; storage only tracks the explicit lifecycle transitions.
52
+ enum EntryStatus {
53
+ None,
54
+ Active,
55
+ Suspended,
56
+ Revoked
57
+ }
58
+
59
+ struct Registry {
60
+ address controller; // the governing SA (set on create); address(0) iff !exists
61
+ address policy; // pluggable membership hook; address(0) = open registry (subject self-service only)
62
+ bool exists;
63
+ }
64
+
65
+ struct Entry {
66
+ address subjectAgent; // the canonical SA this entry is a facet of
67
+ bytes32 cardHash; // sha256 of the agent-profile signed card bundle
68
+ bytes32 bindingProofHash; // sha256 of the off-chain binding proof (verified off-chain, not here)
69
+ bytes32 claimsRoot; // keccak of the registration-time claimHashes[] (the set the binding proof signed)
70
+ EntryStatus status;
71
+ uint64 registeredAtBucket; // block.timestamp / EPOCH_SECONDS at registration
72
+ uint64 expiresAt; // absolute unix seconds; 0 = non-expiring
73
+ }
74
+
75
+ // ─── Storage ────────────────────────────────────────────────────────
76
+
77
+ mapping(bytes32 => Registry) private _registries; // registryId => Registry
78
+ mapping(bytes32 => Entry) private _entries; // entryKey => Entry
79
+ mapping(bytes32 => mapping(bytes32 => bytes32)) private _claims; // entryKey => claimSlotId => claimHash
80
+
81
+ // ─── Errors ─────────────────────────────────────────────────────────
82
+
83
+ error RegistryExists();
84
+ error RegistryNotFound();
85
+ error NotController();
86
+ error EntryExists();
87
+ error EntryNotFound();
88
+ error ZeroSubject();
89
+ error SubjectMismatch(); // msg.sender is not the entry's subject SA (RB-01)
90
+ error NotAuthorized(); // msg.sender is neither controller nor a policy-authorized admin (RB-03)
91
+ error NotActive();
92
+ error AlreadyRevoked();
93
+ error InvalidExpiry();
94
+ error MembershipDenied(); // RB-02 fail-closed admission denial
95
+
96
+ // ─── Events ─────────────────────────────────────────────────────────
97
+
98
+ // Registry provisioning (not part of the registry-kit lifecycle ABI).
99
+ event RegistryCreated(bytes32 indexed registryId, address indexed controller, address policy);
100
+ event RegistryPolicyUpdated(bytes32 indexed registryId, address policy);
101
+
102
+ // Entry lifecycle — MUST match registry-kit `AGENT_REGISTRY_BASE_ABI` + spec 279 §4.1 EXACTLY
103
+ // (the SDK encodes calls against / decodes logs from these signatures).
104
+ event RegistryEntryRegistered(
105
+ bytes32 indexed registryId,
106
+ bytes32 indexed entryId,
107
+ address indexed subjectAgent,
108
+ bytes32 cardHash,
109
+ bytes32 bindingProofHash
110
+ );
111
+ event RegistryEntryRenewed(bytes32 indexed registryId, bytes32 indexed entryId, uint64 expiresAt);
112
+ event RegistryEntrySuspended(bytes32 indexed registryId, bytes32 indexed entryId, bytes32 reasonHash);
113
+ event RegistryEntryRevoked(bytes32 indexed registryId, bytes32 indexed entryId, bytes32 reasonHash);
114
+ event RegistryClaimUpdated(
115
+ bytes32 indexed registryId, bytes32 indexed entryId, bytes32 indexed claimSlotId, bytes32 claimHash
116
+ );
117
+
118
+ // ─── Registry provisioning ──────────────────────────────────────────
119
+
120
+ /// @notice Create a registry. Permissionless + first-create-wins: `msg.sender` becomes the controller.
121
+ /// @dev `registryId` is `keccak256(urn:ap:registry:…)` off-chain; squatting on an id is a PROVISIONING
122
+ /// concern (create the registry in the same flow that mints its urn), out of scope for this base.
123
+ /// `policy == address(0)` ⇒ open registry: any SA may self-register, no admission gate.
124
+ function createRegistry(bytes32 registryId, address policy) external {
125
+ if (_registries[registryId].exists) revert RegistryExists();
126
+ _registries[registryId] = Registry({controller: msg.sender, policy: policy, exists: true});
127
+ emit RegistryCreated(registryId, msg.sender, policy);
128
+ }
129
+
130
+ /// @notice Swap the pluggable membership hook. Controller only.
131
+ function setRegistryPolicy(bytes32 registryId, address policy) external {
132
+ Registry storage r = _registries[registryId];
133
+ if (!r.exists) revert RegistryNotFound();
134
+ if (msg.sender != r.controller) revert NotController();
135
+ r.policy = policy;
136
+ emit RegistryPolicyUpdated(registryId, policy);
137
+ }
138
+
139
+ // ─── Entry lifecycle ────────────────────────────────────────────────
140
+
141
+ /// @notice Register a facet of `subjectAgent`. RB-01: the subject SA must be the caller. RB-02: the
142
+ /// registry's membership hook (if any) must admit. Signature ABI matches registry-kit.
143
+ function registerEntry(
144
+ bytes32 registryId,
145
+ bytes32 entryId,
146
+ address subjectAgent,
147
+ bytes32 cardHash,
148
+ bytes32 bindingProofHash,
149
+ bytes32[] calldata claimHashes,
150
+ uint64 expiresAt
151
+ ) external {
152
+ Registry storage r = _registries[registryId];
153
+ if (!r.exists) revert RegistryNotFound();
154
+ if (subjectAgent == address(0)) revert ZeroSubject();
155
+ if (msg.sender != subjectAgent) revert SubjectMismatch(); // RB-01
156
+ if (expiresAt != 0 && expiresAt <= block.timestamp) revert InvalidExpiry();
157
+
158
+ bytes32 key = _entryKey(registryId, entryId);
159
+ if (_entries[key].status != EntryStatus.None) revert EntryExists();
160
+
161
+ // RB-02 — admission gate, fail-closed: a false return OR a revert blocks registration.
162
+ address policy = r.policy;
163
+ if (policy != address(0)) {
164
+ try IRegistryMembershipPolicy(policy)
165
+ .canRegister(registryId, entryId, subjectAgent, cardHash, claimHashes) returns (
166
+ bool ok
167
+ ) {
168
+ if (!ok) revert MembershipDenied();
169
+ } catch {
170
+ revert MembershipDenied();
171
+ }
172
+ }
173
+
174
+ _entries[key] = Entry({
175
+ subjectAgent: subjectAgent,
176
+ cardHash: cardHash,
177
+ bindingProofHash: bindingProofHash,
178
+ claimsRoot: keccak256(abi.encode(claimHashes)),
179
+ status: EntryStatus.Active,
180
+ registeredAtBucket: uint64(block.timestamp) / EPOCH_SECONDS,
181
+ expiresAt: expiresAt
182
+ });
183
+
184
+ emit RegistryEntryRegistered(registryId, entryId, subjectAgent, cardHash, bindingProofHash);
185
+ }
186
+
187
+ /// @notice Extend an active entry's expiry. RB-01: subject SA only. RB-04: a revoked/suspended entry
188
+ /// cannot be renewed.
189
+ function renewEntry(bytes32 registryId, bytes32 entryId, uint64 expiresAt) external {
190
+ Entry storage e = _entries[_entryKey(registryId, entryId)];
191
+ if (e.status == EntryStatus.None) revert EntryNotFound();
192
+ if (msg.sender != e.subjectAgent) revert SubjectMismatch(); // RB-01
193
+ if (e.status != EntryStatus.Active) revert NotActive(); // RB-04 (Suspended/Revoked)
194
+ if (expiresAt != 0 && expiresAt <= block.timestamp) revert InvalidExpiry();
195
+ e.expiresAt = expiresAt;
196
+ emit RegistryEntryRenewed(registryId, entryId, expiresAt);
197
+ }
198
+
199
+ /// @notice Suspend an active entry. RB-03: admin action (controller or policy-authorized) — NOT subject.
200
+ function suspendEntry(bytes32 registryId, bytes32 entryId, bytes32 reasonHash) external {
201
+ Entry storage e = _entries[_entryKey(registryId, entryId)];
202
+ if (e.status == EntryStatus.None) revert EntryNotFound();
203
+ _requireAdmin(registryId, entryId); // RB-03
204
+ if (e.status != EntryStatus.Active) revert NotActive();
205
+ e.status = EntryStatus.Suspended;
206
+ emit RegistryEntrySuspended(registryId, entryId, reasonHash);
207
+ }
208
+
209
+ /// @notice Revoke an entry (terminal). The subject SA may leave; the controller / policy-admin may eject.
210
+ function revokeEntry(bytes32 registryId, bytes32 entryId, bytes32 reasonHash) external {
211
+ Entry storage e = _entries[_entryKey(registryId, entryId)];
212
+ if (e.status == EntryStatus.None) revert EntryNotFound();
213
+ if (msg.sender != e.subjectAgent) _requireAdmin(registryId, entryId); // subject (leave) or admin (eject)
214
+ if (e.status == EntryStatus.Revoked) revert AlreadyRevoked(); // RB-04
215
+ e.status = EntryStatus.Revoked;
216
+ emit RegistryEntryRevoked(registryId, entryId, reasonHash);
217
+ }
218
+
219
+ /// @notice Set a per-slot claim hash. Subject self-service OR admin (issuer/registry-managed claims).
220
+ /// @dev Distinct from `claimsRoot` (the immutable snapshot the binding proof signed at registration):
221
+ /// this is the mutable, slot-keyed projection the indexer reads for discovery.
222
+ function updateClaim(bytes32 registryId, bytes32 entryId, bytes32 claimSlotId, bytes32 claimHash) external {
223
+ bytes32 key = _entryKey(registryId, entryId);
224
+ Entry storage e = _entries[key];
225
+ if (e.status == EntryStatus.None) revert EntryNotFound();
226
+ if (e.status == EntryStatus.Revoked) revert AlreadyRevoked(); // RB-04
227
+ if (msg.sender != e.subjectAgent) _requireAdmin(registryId, entryId);
228
+ _claims[key][claimSlotId] = claimHash;
229
+ emit RegistryClaimUpdated(registryId, entryId, claimSlotId, claimHash);
230
+ }
231
+
232
+ // ─── Views (RB-06: discovery reads use these, never log scans) ──────
233
+
234
+ function getRegistry(bytes32 registryId) external view returns (Registry memory) {
235
+ Registry memory r = _registries[registryId];
236
+ if (!r.exists) revert RegistryNotFound();
237
+ return r;
238
+ }
239
+
240
+ function getEntry(bytes32 registryId, bytes32 entryId) external view returns (Entry memory) {
241
+ Entry memory e = _entries[_entryKey(registryId, entryId)];
242
+ if (e.status == EntryStatus.None) revert EntryNotFound();
243
+ return e;
244
+ }
245
+
246
+ /// @notice Effective liveness: stored-Active AND not past `expiresAt`. A missing entry returns false
247
+ /// (empty is an answer, ADR-0013 — not a trigger for a fallback lookup).
248
+ function isActive(bytes32 registryId, bytes32 entryId) external view returns (bool) {
249
+ Entry memory e = _entries[_entryKey(registryId, entryId)];
250
+ if (e.status != EntryStatus.Active) return false;
251
+ if (e.expiresAt != 0 && block.timestamp > e.expiresAt) return false;
252
+ return true;
253
+ }
254
+
255
+ /// @notice The current hash for a claim slot (0 if unset). Slot semantics are defined by the registry.
256
+ function getClaim(bytes32 registryId, bytes32 entryId, bytes32 claimSlotId) external view returns (bytes32) {
257
+ return _claims[_entryKey(registryId, entryId)][claimSlotId];
258
+ }
259
+
260
+ // ─── Internal ───────────────────────────────────────────────────────
261
+
262
+ function _entryKey(bytes32 registryId, bytes32 entryId) internal pure returns (bytes32) {
263
+ return keccak256(abi.encodePacked(registryId, entryId));
264
+ }
265
+
266
+ /// @dev RB-03 — controller passes; otherwise the pluggable policy may authorize the actor. Fail-closed:
267
+ /// no policy, a false return, or a revert all deny.
268
+ function _requireAdmin(bytes32 registryId, bytes32 entryId) internal view {
269
+ Registry storage r = _registries[registryId];
270
+ if (msg.sender == r.controller) return;
271
+ address policy = r.policy;
272
+ if (policy != address(0)) {
273
+ try IRegistryMembershipPolicy(policy).canAdminister(registryId, entryId, msg.sender) returns (bool ok) {
274
+ if (ok) return;
275
+ } catch {
276
+ // fail-closed: treat a reverting policy as denial
277
+ }
278
+ }
279
+ revert NotAuthorized();
280
+ }
281
+ }
@@ -0,0 +1,30 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.28;
3
+
4
+ /**
5
+ * @title IRegistryMembershipPolicy
6
+ * @notice Pluggable membership/validation hook for {AgentRegistryBase} (spec 279 §4.2). It answers two
7
+ * yes/no questions and NOTHING else:
8
+ *
9
+ * - `canRegister` — may `subjectAgent` create `entryId` in `registryId` with these claims?
10
+ * - `canAdminister` — may a NON-subject `actor` suspend / revoke / update `entryId`?
11
+ *
12
+ * Implementations live OUTSIDE Ring 0 (issuer-attested, stake/bond, quorum-approved,
13
+ * domain-control-proof, skill-claim-proof, …) — they MUST NOT push vertical business logic into
14
+ * the registry base. Both methods are `view`, so {AgentRegistryBase} reaches them via STATICCALL
15
+ * (no state mutation, no reentrancy). A policy that returns `false` OR reverts is treated as a
16
+ * denial: the base fails closed (ADR-0013) — there is no second, weaker authorization path.
17
+ */
18
+ interface IRegistryMembershipPolicy {
19
+ /// @return ok whether `subjectAgent` may register `entryId` in `registryId` with `cardHash`/`claimHashes`.
20
+ function canRegister(
21
+ bytes32 registryId,
22
+ bytes32 entryId,
23
+ address subjectAgent,
24
+ bytes32 cardHash,
25
+ bytes32[] calldata claimHashes
26
+ ) external view returns (bool ok);
27
+
28
+ /// @return ok whether `actor` (not the entry's subject) may administer (suspend / revoke / update) the entry.
29
+ function canAdminister(bytes32 registryId, bytes32 entryId, address actor) external view returns (bool ok);
30
+ }