@agenticprimitives/contracts 1.0.0-alpha.5 → 1.0.0-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUDIT.md +119 -27
- package/README.md +47 -12
- package/deployments-base-sepolia.json +52 -1
- package/deployments-faithchain.json +103 -0
- package/deployments-hopechain.json +78 -0
- package/deployments-paymaster-anvil.json +1 -0
- package/deployments-registries-base-sepolia.json +1 -0
- package/deployments-registries-hopechain.json +1 -0
- package/dist/abi/AccountBootstrap.json +99 -0
- package/dist/abi/AgentAccount.json +461 -67
- package/dist/abi/AgentAccountFactory.json +309 -0
- package/dist/abi/AgentNameAttributeResolver.json +212 -0
- package/dist/abi/AgentNameRegistry.json +544 -0
- package/dist/abi/AgentNameUniversalResolver.json +222 -0
- package/dist/abi/AgentProfileResolver.json +236 -0
- package/dist/abi/AgentRegistryBase.json +1003 -0
- package/dist/abi/AgentRelationship.json +405 -0
- package/dist/abi/AgenticGovernance.json +155 -0
- package/dist/abi/AgreementRegistry.json +203 -5
- package/dist/abi/AllowedMethodsEnforcer.json +193 -0
- package/dist/abi/AllowedTargetsEnforcer.json +193 -0
- package/dist/abi/ApprovedHashRegistry.json +267 -2
- package/dist/abi/AttestationRegistry.json +242 -0
- package/dist/abi/AttributeStorage.json +24 -0
- package/dist/abi/CallDataHashEnforcer.json +193 -0
- package/dist/abi/CustodyPolicy.json +422 -55
- package/dist/abi/DelegationManager.json +292 -0
- package/dist/abi/DigestBindingEnforcer.json +541 -0
- package/dist/abi/Eip7702.json +13 -0
- package/dist/abi/EstateProjectionRegistry.json +599 -0
- package/dist/abi/Generation5Bridge.json +355 -0
- package/dist/abi/GeoFeatureRegistry.json +235 -0
- package/dist/abi/IAgentAccountFactoryView.json +26 -0
- package/dist/abi/IAgentAccountGovernanceTimelockView.json +15 -0
- package/dist/abi/IApprovedHashRegistryWrite.json +35 -0
- package/dist/abi/ICustodyEpochView.json +28 -0
- package/dist/abi/ICustodyPolicyAccountModuleView.json +31 -0
- package/dist/abi/ICustodyPolicyFactoryView.json +13 -0
- package/dist/abi/ICustodyPolicyPasskeyView.json +50 -0
- package/dist/abi/IDelegationManager.json +18 -0
- package/dist/abi/IGeneration4Reads.json +143 -0
- package/dist/abi/IGeneration5Account.json +33 -0
- package/dist/abi/IGeneration5Voucher.json +26 -0
- package/dist/abi/IMoveAccountView.json +57 -0
- package/dist/abi/IMoveCustodyView.json +169 -0
- package/dist/abi/IMoveFactoryView.json +41 -0
- package/dist/abi/IPaymentReceiptRegistry.json +50 -0
- package/dist/abi/IRedemptionContext.json +15 -0
- package/dist/abi/IRegistryMembershipPolicy.json +70 -0
- package/dist/abi/ITimelockVeto.json +93 -0
- package/dist/abi/ITreasurySpendPolicyAccountView.json +44 -0
- package/dist/abi/IUpgradeVoucherView.json +26 -0
- package/dist/abi/MockUSDC.json +621 -0
- package/dist/abi/OntologyTermRegistry.json +268 -0
- package/dist/abi/PayloadClassesEnforcer.json +310 -0
- package/dist/abi/PaymentEnforcer.json +639 -0
- package/dist/abi/PaymentEscrow.json +501 -0
- package/dist/abi/PaymentReceiptRegistry.json +388 -0
- package/dist/abi/PermissionlessSubregistry.json +353 -0
- package/dist/abi/PricedSubregistry.json +1141 -0
- package/dist/abi/QuorumEnforcer.json +209 -0
- package/dist/abi/ReceiptAnchorRegistry.json +346 -0
- package/dist/abi/RelationshipTypeRegistry.json +268 -0
- package/dist/abi/ShapeRegistry.json +268 -0
- package/dist/abi/SignatureVerifier.json +196 -0
- package/dist/abi/SkillDefinitionRegistry.json +235 -0
- package/dist/abi/SmartAgentPaymaster.json +445 -1
- package/dist/abi/StableProxyGoverned.json +190 -0
- package/dist/abi/StableProxyGovernedOneShot.json +172 -0
- package/dist/abi/TimestampEnforcer.json +193 -0
- package/dist/abi/TreasurySpendPolicy.json +667 -0
- package/dist/abi/UpgradeVoucher.json +328 -0
- package/dist/abi/ValueEnforcer.json +193 -0
- package/dist/abi/index.d.ts +35 -0
- package/dist/abi/index.js +35 -0
- package/dist/deployments/base-sepolia.d.ts +11 -0
- package/dist/deployments/base-sepolia.js +51 -28
- package/dist/deployments/faithchain.d.ts +77 -0
- package/dist/deployments/faithchain.js +107 -0
- package/dist/deployments/hopechain.d.ts +68 -0
- package/dist/deployments/hopechain.js +82 -0
- package/dist/deployments/index.d.ts +7 -2
- package/dist/deployments/index.js +15 -0
- package/dist/deployments/paymaster-anvil.d.ts +11 -0
- package/dist/deployments/paymaster-anvil.js +9 -0
- package/dist/deployments/registries-base-sepolia.d.ts +10 -0
- package/dist/deployments/registries-base-sepolia.js +8 -0
- package/dist/deployments/registries-hopechain.d.ts +10 -0
- package/dist/deployments/registries-hopechain.js +8 -0
- package/package.json +37 -7
- package/src/AccountBootstrap.sol +38 -0
- package/src/AgentAccount.sol +1091 -134
- package/src/AgentAccountFactory.sol +198 -21
- package/src/ApprovedHashRegistry.sol +134 -10
- package/src/IAgentAccount.sol +37 -0
- package/src/SmartAgentPaymaster.sol +275 -22
- package/src/UniversalSignatureValidator.sol +7 -0
- package/src/UpgradeVoucher.sol +87 -0
- package/src/agency/DelegationManager.sol +299 -76
- package/src/agency/ICaveatEnforcer.sol +10 -0
- package/src/agency/IDelegationManager.sol +37 -5
- package/src/agreement/AgreementRegistry.sol +105 -35
- package/src/attestation/AttestationRegistry.sol +220 -40
- package/src/custody/CustodyPolicy.sol +588 -70
- package/src/custody/TreasurySpendPolicy.sol +338 -0
- package/src/enforcers/AllowedMethodsEnforcer.sol +13 -2
- package/src/enforcers/AllowedTargetsEnforcer.sol +13 -2
- package/src/enforcers/CallDataHashEnforcer.sol +7 -1
- package/src/enforcers/DigestBindingEnforcer.sol +182 -0
- package/src/enforcers/PayloadClassesEnforcer.sol +36 -0
- package/src/enforcers/PaymentEnforcer.sol +291 -0
- package/src/enforcers/QuorumEnforcer.sol +24 -3
- package/src/enforcers/TimestampEnforcer.sol +7 -1
- package/src/enforcers/ValueEnforcer.sol +13 -2
- package/src/geo/GeoFeatureRegistry.sol +67 -22
- package/src/governance/AgenticGovernance.sol +187 -4
- package/src/governance/GovernanceManaged.sol +2 -0
- package/src/governance/StableProxyGoverned.sol +79 -0
- package/src/governance/StableProxyGovernedOneShot.sol +93 -0
- package/src/identity/AgentProfilePredicates.sol +23 -0
- package/src/identity/AgentProfileResolver.sol +22 -2
- package/src/libraries/Eip7702.sol +36 -0
- package/src/libraries/SignatureSlotRecovery.sol +28 -7
- package/src/libraries/SignatureVerifier.sol +52 -0
- package/src/libraries/WebAuthnLib.sol +16 -0
- package/src/migration/Generation5Bridge.sol +364 -0
- package/src/mocks/MockUSDC.sol +152 -0
- package/src/naming/AgentNameAttributeResolver.sol +29 -4
- package/src/naming/AgentNamePredicates.sol +89 -0
- package/src/naming/AgentNameRegistry.sol +324 -20
- package/src/naming/AgentNameUniversalResolver.sol +35 -2
- package/src/naming/PermissionlessSubregistry.sol +82 -25
- package/src/naming/PricedSubregistry.sol +293 -0
- package/src/ontology/AttributeStorage.sol +93 -80
- package/src/ontology/OntologyTermRegistry.sol +58 -2
- package/src/ontology/ShapeRegistry.sol +58 -2
- package/src/payments/PaymentEscrow.sol +187 -0
- package/src/payments/PaymentReceiptRegistry.sol +100 -0
- package/src/provenance/ReceiptAnchorRegistry.sol +67 -0
- package/src/registry/AgentRegistryBase.sol +372 -0
- package/src/registry/EstateProjectionRegistry.sol +177 -0
- package/src/registry/IRegistryMembershipPolicy.sol +30 -0
- package/src/relationships/AgentRelationship.sol +129 -8
- package/src/relationships/RelationshipTypeRegistry.sol +58 -2
- package/src/skills/SkillDefinitionRegistry.sol +61 -17
package/AUDIT.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
**Prior refresh:** 2026-06-01 (R6 contracts hardening wave landed)
|
|
6
6
|
**Owners:** contracts package CODEOWNERS
|
|
7
7
|
**System audit cross-reference:** [`docs/architecture/product-readiness-audit.md`](../../docs/architecture/product-readiness-audit.md)
|
|
8
|
-
**Prior dossier:** [`docs/audits/2026-05-packages-contracts-production-readiness.md`](../../docs/audits/2026-05-packages-contracts-production-readiness.md) (per-contract findings table)
|
|
9
|
-
**Recon doc:** [`docs/audits/r6-contracts-recon-2026-05-31.md`](../../docs/audits/r6-contracts-recon-2026-05-31.md) (R6 wave triage)
|
|
8
|
+
**Prior dossier:** [`docs/audits/archive/2026-05/2026-05-packages-contracts-production-readiness.md`](../../docs/audits/archive/2026-05/2026-05-packages-contracts-production-readiness.md) (per-contract findings table)
|
|
9
|
+
**Recon doc:** [`docs/audits/archive/2026-05/r6-contracts-recon-2026-05-31.md`](../../docs/audits/archive/2026-05/r6-contracts-recon-2026-05-31.md) (R6 wave triage)
|
|
10
10
|
|
|
11
|
-
> **Reader's note for external auditors.** This dossier is the AUDIT-ready summary of the security posture of every contract under `src/`. It pairs with `specs/214-production-audit-dossier.md` (the target shape we're auditing toward), the [`docs/audits/`](../../docs/audits) folder (threat model, architecture diagram, evidence checklist), and the **R10 internal readiness assessment** at [`docs/audits/2026-06-01-r10-internal-readiness-assessment.md`](../../docs/audits/2026-06-01-r10-internal-readiness-assessment.md) (active P0/P1/P2/P3 backlog). For finding-level detail use the cross-references at the bottom of each section.
|
|
11
|
+
> **Reader's note for external auditors.** This dossier is the AUDIT-ready summary of the security posture of every contract under `src/`. It pairs with `specs/214-production-audit-dossier.md` (the target shape we're auditing toward), the [`docs/audits/`](../../docs/audits) folder (threat model, architecture diagram, evidence checklist), and the **R10 internal readiness assessment** at [`docs/audits/archive/2026-06-01/2026-06-01-r10-internal-readiness-assessment.md`](../../docs/audits/archive/2026-06-01/2026-06-01-r10-internal-readiness-assessment.md) (active P0/P1/P2/P3 backlog). For finding-level detail use the cross-references at the bottom of each section.
|
|
12
12
|
>
|
|
13
|
-
> **Coverage stack
|
|
13
|
+
> **Coverage stack (counts corrected 2026-11-10, audit ARCH-8; taken from source, not from a run):** ~1,000 Foundry `test*` functions in 75 `.t.sol` files + 15 stateful invariants (3 suites, all structural) + 7 Halmos symbolic proofs (written 2026-06-01 against generation-1 code; nothing symbolic covers generations 2–4) + 4 Echidna nightly properties + 4 Medusa weekend properties (one target, `CustodyPolicy`, the same four in each). PR-blocking: Halmos (pinned 0.3.3), Solhint, CodeQL, and Slither on any High and on any Medium not in the per-finding baseline (`scripts/slither-triage-baseline.json`, 24 entries; `docs/audits/r9-static-analysis-triage.md`). Aderyn is advisory (not triaged at the version CI pins). Echidna and Medusa are scheduled, not PR checks, and a falsified property fails their job (it did not before 2026-11-10). The Foundry `nightly` profile (10,000 fuzz runs; invariants 1024 × 250) is scheduled in `.github/workflows/nightly.yml` (no workflow ran it before 2026-11-10). `lib/` is plain clones at the commits in `lib.lock.json` (`setup.sh`, `pnpm check:contracts-lib-lock`), not submodules. pnpm-audit + gitleaks + SBOM run in the security workflow. Generation-2/3/4 properties with no invariant or proof: `docs/audits/external-audit-readiness.md` §4.1.
|
|
14
14
|
|
|
15
15
|
## 1. Charter
|
|
16
16
|
|
|
@@ -18,12 +18,12 @@ This package ships the **on-chain enforcement layer** for the agenticprimitives
|
|
|
18
18
|
|
|
19
19
|
| File | Role |
|
|
20
20
|
|---|---|
|
|
21
|
-
| `AgentAccount.sol` | ERC-4337 v0.
|
|
21
|
+
| `AgentAccount.sol` | ERC-4337 v0.9 SA (`lib/account-abstraction` pinned in `lib.lock.json`; UUPS-upgradeable, ERC-7579 module-host, ERC-1271 verifier, WebAuthn-supporting) |
|
|
22
22
|
| `AgentAccountFactory.sol` | CREATE2 deterministic deployer; salt derives from auth methods + scope (NEVER from a name, per ADR-0010) |
|
|
23
23
|
| `agency/DelegationManager.sol` + `enforcers/*` | Scoped ERC-7710 delegation with on-chain caveat enforcement (AllowedTargets, AllowedMethods, Timestamp, Value, Quorum) |
|
|
24
24
|
| `custody/CustodyPolicy.sol` | Multi-sig custodian / trustee quorum + scheduled-action machinery (spec 213 carve-out, ERC-7579 module) |
|
|
25
25
|
| `SmartAgentPaymaster.sol` | ERC-4337 paymaster — three validation modes (dev / allowlist / verifying-paymaster) |
|
|
26
|
-
| `naming/{AgentNameRegistry, PermissionlessSubregistry, AgentNameUniversalResolver}.sol` | `.agent` + `.
|
|
26
|
+
| `naming/{AgentNameRegistry, PermissionlessSubregistry, AgentNameUniversalResolver}.sol` | `.agent` + the nine typed roots (`.me .org .team .svc .workspace .treasury .registry .church .circle`) + hierarchical registry + resolver. The impact root was retired 2026-11-10: never provisioned again; existing on-chain instances are recorded as `_retiredRoots` history in the manifests |
|
|
27
27
|
| `identity/AgentProfileResolver.sol` | ERC-1056-style profile / AgentCard facet resolver |
|
|
28
28
|
| `ontology/{OntologyTermRegistry, ShapeRegistry, AttributeStorage}.sol` | SHACL shape + JSON-LD predicate registries |
|
|
29
29
|
| `relationships/AgentRelationship.sol` | Public on-chain edge model (⚠ Privacy Fork — see EXT-019; remains *experimental* surface) |
|
|
@@ -43,7 +43,7 @@ This package ships the **on-chain enforcement layer** for the agenticprimitives
|
|
|
43
43
|
| 2.3 | **WebAuthn assertion verification pins RP-ID + UP flag.** | ✅ CLOSED H7-C.1 / CON-WEBAUTHN-001 | `_setupInitialPasskey` rejects zero rpIdHash (`AgentAccount.sol:354-356`); R6.10 added `_validateUserOp` happy-path test pack |
|
|
44
44
|
| 2.4 | **P256Verifier dispatcher rejects silent Daimo fallback.** | ✅ CLOSED H7-C.2 / CON-P256-001 | `P256Verifier.sol` |
|
|
45
45
|
| 2.5 | **`SignatureSlotRecovery` bounds-checks `v=0` + `v=2` slots.** | ✅ CLOSED H7-C.3 / CON-SIG-SLOT-001/-002 | `libraries/SignatureSlotRecovery.sol` |
|
|
46
|
-
| 2.6 | **`AgentNameRegistry.initializeRoot` cannot be frontrun.** | ✅ CLOSED H7-C.4 / CON-NAMING-001 | `AgentNameRegistry.sol:
|
|
46
|
+
| 2.6 | **`AgentNameRegistry.initializeRoot` cannot be frontrun, and at most one address may ever initialize.** The initializer is the constructor's, or the ONE successor it named: `transferInitializer(to)` is one-shot and RELINQUISHING (the caller holds nothing from that call; `initializer` reads zero until `acceptInitializer()` by `to`). `Deploy.s.sol` initializes every root as the broadcaster (each owned by the naming authority), hands over, and emits one pending `acceptInitializer`; the production end-state accepts only `initializer == authority` or `initializer == 0 && pendingInitializer == authority`. | ✅ CLOSED H7-C.4 / CON-NAMING-001; hand-over spec 445 B2 item 8 — generation 4, source only until deployed | `AgentNameRegistry.sol:transferInitializer` / `acceptInitializer`; `test/naming/Naming445B2.t.sol::test_initializer_*`; `test/DeployProduction445.t.sol` (`…pendingGovernanceCalls…`, `…NamingInitializerIsPendingToAnotherAddress`) |
|
|
47
47
|
| 2.7 | **`DelegationManager.redeemDelegation` is `nonReentrant`.** | ✅ CLOSED SC5 §6.2 | OpenZeppelin `ReentrancyGuard` mixin on `redeemDelegation` |
|
|
48
48
|
| 2.8 | **Factory + Paymaster governance is timelock + multisig, not a deployer EOA.** | ⏳ OPEN — N1 (operator-deferred) | Testnet currently uses the disclosed demo deployer; production rotation runbook is § 4 below |
|
|
49
49
|
| 2.9 | **Pause surfaces wired on critical paths.** | ✅ CLOSED R6.5 / R6.6 / R6.8 — pause matrix in § 3.4 | See § 3.4 |
|
|
@@ -52,46 +52,85 @@ This package ships the **on-chain enforcement layer** for the agenticprimitives
|
|
|
52
52
|
| 2.12 | **CustodyPolicy reinstall is permanently forbidden.** | ✅ CLOSED audit C-11 | `CustodyPolicy.sol:onUninstall` + `onInstall` reinstall gate; tested in `CustodyPolicyWave2C.t.sol` |
|
|
53
53
|
| 2.13 | **`SmartAgentPaymaster.getHash` binds `address(entryPoint)` + chainId.** | ✅ CLOSED H7-C.7 / CON-PAYMASTER-004 | `SmartAgentPaymaster.sol:206-222`; tested in `SmartAgentPaymasterValidateR610.t.sol` |
|
|
54
54
|
| 2.14 | **`SmartAgentPaymaster` constructor takes EXPLICIT `devMode` (no implicit fail-open).** | ✅ CLOSED R5.7 / PKG-PAYMASTER-002 / external audit P0-2 | `SmartAgentPaymaster.sol:126-141`; tested in `SmartAgentPaymaster.t.sol::test_R5_7_*` |
|
|
55
|
+
| 2.15 | **The account's `execute` never reaches its own custody-tier contracts from below the custody tier.** `CustodyPolicy.onUninstall` reverts `StillInstalledOn` unless `uninstallModule` already dropped the module; a delegation stack (`_delegationExecCtx`) may not target `custodyPolicy` or `approvedHashRegistry` at all. | ✅ CLOSED R917-C-1 (spec 408 §1.1) | `CustodyPolicy.sol:onUninstall`, `AgentAccount.sol:_isAccountTrustedTarget`; `test/HardeningR917.t.sol` |
|
|
56
|
+
| 2.16 | **An approved hash dies with the custody set that approved it.** The `0x03` sentinel consults `isApproved(this, keccak256(hash ‖ custodyEpoch))`; `custodyEpoch` bumps on every credential retirement (`removeCustodian` / `removePasskey`); `ApprovedHashRegistry.revokeAll()` voids per signer. | ✅ CLOSED R917-C-2 (spec 408 §1.2) | `AgentAccount.sol:approvedHashKey`, `ApprovedHashRegistry.sol`; `test/HardeningR917.t.sol`, `test/ApprovedHashIsValidSignature.t.sol` |
|
|
57
|
+
| 2.17 | **Digest binding is counted from the signed terms.** A mandate redeems at most the number of times its signed terms state — `abi.encode(kind, digest)` ⇒ exactly one, `abi.encode(kind, digest, maxUses)` ⇒ at most `maxUses ≥ 1` — counted per `(delegator, delegationHash, kind)` with nothing from `args`; a replayed step nonce is refused (recorded per redeemer, so one party cannot burn another's step on an open grant). A reverted call burns nothing. Stateful + DM-only. | ✅ CLOSED R917-C-4 (spec 408 §1.4), re-closed audit 2026-11-10 DLG-3 (spec 445 B1) — generation 4, source only until deployed | `enforcers/DigestBindingEnforcer.sol`; `test/DigestBindingEnforcer.t.sol`, `test/DlgDigestBinding445B1.t.sol` |
|
|
58
|
+
| 2.18 | **Network posture is a constructor fact, never a chain-id list.** `AgentAccountFactory.relaxedT4Floor` (immutable) is the only way to lift the 1 h T4 floor; recorded in the deployments JSON; refused by `check:production-deploy` off anvil. | ✅ CLOSED R917-C-5 (spec 408 §1.3) | `AgentAccountFactory.sol:_custodyInitData`; `test/AgentAccountFactoryMode.t.sol` |
|
|
59
|
+
| 2.19 | **Receipt anchors are keyed by who anchored.** `(anchoredBy, receiptDigest)` — no squat on a public mempool. | ✅ CLOSED R917-C-3 (spec 408 §1.5) | `provenance/ReceiptAnchorRegistry.sol`; `test/provenance/ReceiptAnchorRegistry.t.sol` |
|
|
60
|
+
| 2.20 | **A delegation chain has exactly one root, and it is the last link.** Every non-terminal link must name its parent by hash (`authority == hashDelegation(next)`); `ROOT_AUTHORITY` in a non-terminal position and a terminal link that is not root both revert `InvalidAuthority` — in `redeemDelegation` and identically in the `verifyAuthorization*` views. | ✅ CLOSED audit 2026-11-10 H-1 / DLG-1 (spec 445 §1.1) — generation 4, source only until deployed | `agency/DelegationManager.sol:_validateDelegation` + `_validateDelegationView`; `test/DelegationManagerChainShape445.t.sol` |
|
|
61
|
+
| 2.21 | **A pause is always liftable, and the exempt targets are exactly these.** Under a pause `AgentAccount.execute` (single call) still accepts a VALIDATED USER OPERATION (`msg.sender` = the immutable EntryPoint) whose target is (1) the factory's governance contract, (2) that governance's own `timelock()`, or (3) the account itself with a selector on the recovery allow-list (§3.4). Both addresses are read `_factory → governance() → timelock()` (an immutable getter and an immutable) — nothing an account can write selects them. `executeBatch` has no exemption; `executeFromModule` only for the canonical custody policy dispatching an allow-listed self-call. The exemption grants nothing at the target: timelock roles and `NotTimelock` / `NotGuardian` still decide. The door is the same in every custody mode — one custodian's user operation (see the open risk, 2.27). | ✅ CLOSED audit 2026-11-10 H-3 / CUST-1 / ACCT-2 (spec 445 §1.2) — generation 4, source only until deployed | `AgentAccount.sol:_requireExecutableUnderPause` + `_isPauseRecoverySelector`, `CustodyPolicy.sol:_isPauseExemptAction`; `test/governance/PauseIsLiftable445.t.sol` (every account mode × role topology, through signed user operations), `test/AgentAccountPauseR65.t.sol::AgentAccountPauseRecovery445Test`, `test/DeployProduction445.t.sol::test_H3_*`; `Deploy.s.sol:_assertPauseLiftable` |
|
|
62
|
+
| 2.22 | **What a retired credential installed is retired with it.** An EXECUTOR (or validator) module and a non-canonical delegation manager are stamped with the custody epoch they were installed / set / re-affirmed under and are honoured only while `stamp == custodyEpoch + 1`; every retirement (`removeCustodian`, `removePasskey`) bumps the epoch and clears the upgrade queue. Exempt: the factory's canonical `custodyPolicy()` and `delegationManager()`. A HOOK is never stamped and never lapses (a protection, not a power). An unstamped module (installed before generation 4) is not honoured until re-affirmed. **Rotation re-affirms what the owner lists, atomically (`add → retire → approveDigest×N → reaffirm×M`); recovery re-affirms nothing.** `reaffirmModule` / `reaffirmDelegationManager` are gated exactly like `installModule` / `setDelegationManager`. | ✅ CLOSED audit 2026-11-10 H-2 / ACCT-1 (spec 445 §1.3 (ii)) — generation 4, source only until deployed | `AgentAccount.sol:_moduleEpochStamp`, `_delegationManagerEpochStamp`, `executeFromModule`, `_requireForExecute`, `_bumpCustodyEpoch`; `CustodyPolicy.sol:_applyRotateCredential`; `test/RetirementExpels445.t.sol` |
|
|
63
|
+
| 2.23 | **Every upgrade is vouched — implementation AND migration data — at the moment it executes.** `upgradeToAndCall(newImpl, data)` requires `UpgradeVoucher.isVouched(newImpl, keccak256(data))` on every path (self-governed, custody `ApplySystemUpdate`, the matured queue — which is bound to empty data), after every pre-existing gate. The voucher is an IMMUTABLE of the implementation (not a factory view), governance-managed through the timelock; unset / codeless / reverting / non-`true` ⇒ refused. **Migration caveat:** a generation ≤ 3 account makes its last upgrade under its old rules — nothing here constrains that step, and an account compromised BEFORE it migrates is not made clean by migrating (a hidden custodian, planted approvals or a swapped implementation survive). An in-place-upgraded account also keeps its ORIGINAL factory, so its canonical custody policy and delegation manager stay generation ≤ 3. Governance must never vouch an implementation that carries no voucher. | ✅ CLOSED audit 2026-11-10 H-2 / ACCT-1 (spec 445 §1.3 (i), with the 2026-11-10 correction: the voucher travels with the implementation) — generation 4, source only until deployed | `src/UpgradeVoucher.sol`, `AgentAccount.sol:upgradeToAndCall` + `_requireVouchedUpgrade`; `test/RetirementExpels445.t.sol` (`test_H2_plantedFutureEpochApproval_*`, `test_H2_twin_unvouchedData_*`, `test_H2_voucherUnsetOrBroken_failsClosed`, `test_H2_custodyPath_*`, `test_H2_queuedUpgrade_*`, `UpgradeVoucher445Test`); `Deploy.s.sol:_assertProductionEndState` (`UpgradeVoucherNotGoverned`) |
|
|
64
|
+
| 2.24 | **The treasury ceiling counts what a call can commit, fails closed, and is not reachable from below the custody tier.** `TreasurySpendPolicy` counts `transfer` / `transferFrom` / `approve` / `increaseAllowance` on the budgeted token (an unlimited approval exceeds any ceiling; `approve(…,0)` / `decreaseAllowance` add nothing and credit nothing back), native value and EntryPoint `withdrawTo` for a native budget; any other selector on the budgeted token and any undecodable payload are REFUSED. An installed module is never an `execute` / `executeBatch` target from a delegation (any mode), from a non-canonical executor, or — on a custody-governed account — from a single custodian's user operation (the canonical custody policy excepted: its entry points are signature-authorized or self-defending). Hooks also run on a non-canonical executor's `executeFromModule`. `onInstall` / `onUninstall` of `TreasurySpendPolicy` and `CustodyPolicy.onInstall` verify the account's installed flag. On a governed treasury install / uninstall / raise are T5 custody actions and lower is T4. **Not bounded (stated in the contract notice):** other assets, pre-existing allowances, signature-based transfers (`permit`, EIP-3009, Permit2), gas prefund, non-standard tokens; allowances make the bound cumulative, not per-window. **A mode-0 treasury's ceiling bounds delegates only — its one key (and that key's executor modules) can remove it.** | ✅ CLOSED audit 2026-11-10 CUST-2 / CUST-3 / ACCT-3 (+ ACCT-11, ACCT-13) (spec 445 §1.5) — generation 4, source only until deployed | `custody/TreasurySpendPolicy.sol`, `AgentAccount.sol:_rejectModuleTarget` + `_isAccountTrustedTarget` + `executeFromModule`, `CustodyPolicy.sol` actions 17–20; `test/TreasuryCeilingAndModules445.t.sol` |
|
|
65
|
+
| 2.25 | **Modules are never execute targets — and the DelegationManager is not a module.** An installed module (any type) is refused as an `execute` / `executeBatch` target from a delegation, from a non-canonical executor, and on a custody-governed account from a single custodian (canonical custody policy excepted — invariant 2.24). The delegation manager is wired as `_delegationManager`, never installed, so a governed account still reaches it as a target: the ap-home revoke-through-mandate flow and a custodian's own revoke both land. | ✅ CLOSED audit 2026-11-10 ACCT-3 (spec 445 §1.5); interaction pinned at the B1 merge — generation 4, source only until deployed | `AgentAccount.sol:_rejectModuleTarget`, `_isAccountTrustedTarget`; `test/TreasuryCeilingAndModules445.t.sol`, `test/MergeInteractions445.t.sol` |
|
|
66
|
+
| 2.26 | **No self-targeted redemption.** `redeemDelegation` reverts `SelfTargetedRedemption` when the target is the ROOT delegator (the account the manager executes through); `verifyAuthorizationForCall` returns `(false, "self-target")`. Closes `execute(self, executeBatch(…))` — a batch the caveats never saw. An intermediate link's delegator stays an ordinary target. The account's own DM-3 nest guards remain as defence in depth; no legitimate flow is blocked twice (an ordinary target passes both; the self-target is refused by the manager first). | ✅ CLOSED audit 2026-11-10 DLG-2 (spec 445 B1) — generation 4, source only until deployed | `agency/DelegationManager.sol:redeemDelegation`; `test/DlgSelfTarget445B1.t.sol`, `test/MergeInteractions445.t.sol` |
|
|
67
|
+
| 2.27 | **A timelock seat is never a key one custodian can drive (spec 448 rule 10; audit 2026-11-10 H-5, 2026-12-02 H-3 / C2-1).** `AgentAccount.execute` validates one custodian signature in every custody mode — the M-of-N of a custody-governed account governs its custody changes only — so a timelock role held by an AgentAccount is exercised by any one of its credentials, live and under a pause (the H-3 exemption, 2.21, is that same door). Routing an account's governance calls through its custody quorum does not fit `AgentAccount`'s remaining code size (EIP-170), so the seat is REFUSED instead: the production deploy reverts `SingleKeyGovernanceRole` for a proposer / executor that is an EOA, an EIP-7702-delegated EOA, or any ERC-4337 smart account (it names an EntryPoint). It also leaves NO standing timelock admin (`StandingTimelockAdmin`: only the timelock itself holds `DEFAULT_ADMIN`), proves the delay is ≥ 24 h, and proves the guardian's veto (`UpgradeVetoNotInstalled`). **What this does not give:** the script cannot measure the quorum of the non-account contract that holds a seat — the operator declares it, `verify-governance-shape` reports a holder whose threshold it cannot read. **Development labels** (anvil, test networks, faithchain, hopechain) run none of this and may put one key in every seat (owner decision, spec 448 §0); the deploy prints that. | ✓ at the production deploy; development labels accepted | `Deploy.s.sol:_refuseSingleKeyRoleHolder`, `_releaseTimelockAdmin`, `_refuseStandingAdmin`, `_assertUpgradeVeto`, `_logDevelopmentGovernance`; `test/DeployProduction445.t.sol::test_H3_twin_*`, `test_H5_endState_refusesAnEoaRoleHolder`; still true of the account itself: `test/governance/PauseIsLiftable445.t.sol::test_H3_openRisk_oneCustodianOfARoleHoldingAccount_makesTheCallAlone` |
|
|
68
|
+
| 2.36 | **System upgrades pass one door with three limits (spec 448 rule 10; audit 2026-12-02 H-3, C5-6).** From generation 5 every system contract is a proxy whose only upgrade authority is `AgenticGovernance`, so every system upgrade is `timelock → AgenticGovernance.execute(proxy, upgradeToAndCall(...))`. There: (1) an upgrade is refused while the system is paused (`UpgradeWhilePaused`); (2) the guardian can cancel a scheduled operation that contains a system upgrade or a call to the timelock itself (`vetoOperation` / `vetoBatch`; governance holds the timelock's `CANCELLER`) — and nothing else, so it cannot cancel its own replacement or an unpause; (3) an upgrade that changes what the proxy answers for `governance()`, `custodyPolicy()`, `delegationManager()`, `approvedHashRegistry()`, `upgradeVoucher()` or `entryPoint()` is reverted whole (`UpgradeChangesSystemWiring`). **THE TRUST THIS GENERATION ADDS, STATED (spec 447 §4.3):** after the delay, governance can replace the code behind the delegation manager, the custody policy and the factory, and so ACT AS EVERY ACCOUNT of the deployment. A pause does not open an exit for accounts (a paused account executes only governance calls and removals); an unpause and an upgrade may execute in one timelock batch. The veto buys time, not immunity: a proposer and executor together can replace the guardian (one delay) and then upgrade (a second). | ✓ | `AgenticGovernance.sol:execute`, `_systemWiring`, `vetoOperation`, `vetoBatch`; `test/governance/UpgradeGuards448.t.sol` |
|
|
69
|
+
| 2.37 | **The generation-5 move runs from generation-4 bytecode, has one route, and leaves nothing approvable for a later epoch (spec 448 rule 9 and §0; audit 2026-12-02 H-1, H-2, C1-4; corrected after the second review).** One route, every account: `Generation5Bridge` (a plain vouched upgrade, then `completeMove`). The generation-5 implementation's `proxiableUUID` answers only an account already running code with its voucher, so a generation-4 account cannot upgrade to it directly — `(gen5Impl, keccak256(""))` vouched on the generation-4 voucher by mistake is still no route. The bridge refuses ENTRY to an account whose custody the stable policy cannot install or that is not of its generation-4 factory; a governed account on the bridge leaves under its own quorum (`ApplySystemUpdate(gen4Impl)` on the generation-4 policy). `migrateFactory` revokes every digest approved for the account in the generation-5 registry; that registry derives every key from the caller's CURRENT `custodyEpoch()`, so no code — including the generation-4 frame still running after the move — can approve for a later epoch (THESIS-1a). A custody-governed account completes only with a configuration vouched for THAT account; the bridge reverts unless the installed custody is the generation-4 one or stricter (same mode, trustees and T3 ceiling; every `Config` field accounted for in the bridge's header). An account on the bridge executes nothing, validates no signature and answers no epoch. The factory's install exception exists only in the transaction that initialized the account (C1-4). Tests deploy generation 4 from `test/fixtures/Gen4Bytecode.sol`. No approval is made after a custody-epoch bump in the same transaction on a custody-governed account except by the custody policy itself (`approveDigest` → `ApprovalAfterCustodyChange`; `RotateCredential`'s re-approval list still runs, and a mode-0 account still rotates in its own batch): a user operation validates before it executes, so without this the custodian being expelled could wrap the trustees' recovery or the quorum's rotation in her own batch — or a later operation of the same bundle — and approve under the NEW epoch after she is out (second review of R0-contracts). The move's own transaction is covered the same way (third review): a generation-4 custody change (rotation, trustee recovery) runs generation-4 code and sets no generation-5 flag, so `Generation5Bridge.completeMove` sets it after the move, and `ApprovedHashRegistry.approveHash` asks every account signer `approvalRefused()` (the same three-part condition `approveDigest` checks) and refuses when the answer is true or missing. Both approval routes after `[gen-4 retirement, move]` in one batch or bundle are refused: `approveDigest`, and a direct `approveHash` from the still-running generation-4 frame (`test_H2_r3_twin_*`). Generation-4 code cannot approve in the generation-5 registry at all (it does not answer). Cost: a governed account approves nothing in its move transaction except through its custody policy; it approves in the next one. **Remaining:** one custodian of a governed account can approve a digest for the CURRENT epoch (as `approveDigest` allows); it dies when the epoch moves, and a recovery also revokes it. On GENERATION 4 (deployed bytecode, pre-existing since spec 410) the wrap is still open until the account moves: `test_H2_r2_gen4_OPEN_DEFECT_expelledCustodianWrap_isLiveOnGeneration4`. | ✓ (not deployed) | `AgentAccount.sol:migrateFactory`, `proxiableUUID`, `onlySelfOrFactoryInit`, `approveDigest` (`_epochBumpedThisTx`), `approvalRefused`; `ApprovedHashRegistry.sol:_keyOf`, `approveHash`; `Generation5Bridge.completeMove`; `src/migration/Generation5Bridge.sol`; `test/Generation5Move448.t.sol`, `test/Generation5MoveFixup448.t.sol`, `test/Migration447.t.sol`, `test/Rehearsal447.t.sol` |
|
|
70
|
+
| 2.38 | **Signature arithmetic lives in a verifier each implementation creates for itself (spec 449).** `AgentAccount` and `CustodyPolicy` each create a stateless `SignatureVerifier` in their constructor (CREATE, nonce 1) and hold its address as an immutable, so it is part of the vouched implementation code and cannot be re-pointed. The account's WebAuthn check (decode, authenticator and client data, low-s, P-256) and the policy's quorum slot recovery (`SignatureSlotRecovery.recoverFromSlot`, unchanged; its errors revert through) run there by STATICCALL. Nothing that writes state or decides custody moved: key lookup, rp-ID pinning, custodian/trustee membership and every threshold stay in the callers. A revert in the verifier is "invalid" on the account path (never a revert out of validation). C1-8: an index past the client-data buffer answers false, never `Panic(0x11)`. Room after: `AgentAccount` ≥ 1,500 B, `CustodyPolicy` ≥ 1,000 B (`check:contract-size-floors`). Changed caller: a quorum slot's ERC-1271 `isValidSignature` is now called by the verifier, not the policy. | ✓ (not deployed) | `src/libraries/SignatureVerifier.sol`; `AgentAccount._verifyWebAuthn`; `CustodyPolicy._verifyQuorum`; `WebAuthnLib._checkClientData`; `test/Headroom449.t.sol`, `test/SignatureVerifier449.t.sol`, `test/ValidationGas449.t.sol` |
|
|
71
|
+
| 2.28 | **Reserved labels and host injectivity are enforced on chain.** `AgentNameRegistry.register` (every path: root owner, `PermissionlessSubregistry`, `PricedSubregistry`) refuses `ws www mtls edge api well-known` and every initialized typed root's label under ANY parent (`ReservedLabel`), and under a bare-host root a label whose segment after the last `-` is a typed root's label (`LabelReadsAsTypedName`). A root label carries no `-`. | ✅ CLOSED spec 445 NAME-8 (B2 item 7) — generation 4, source only until deployed | `naming/AgentNameRegistry.sol:register`; `test/naming/Naming445B2.t.sol::test_NAME8_*` |
|
|
72
|
+
| 2.29 | **Records belong to an owner epoch.** A change of owner (and the reclaim of an expired name) bumps `recordEpoch(node)`; `AgentNameAttributeResolver` keys every record by `(node, epoch)` and answers empty for a non-live node — the previous owner's records stop resolving in the same transaction for every reader, and transferring back resurrects nothing. Expired ⇒ empty for every record type; only the parent may renew, extension only. | ✅ CLOSED audit 2026-11-10 REG-4 / REG-6 (NAMING-RECLAIM-STALE-RESOLVER-1) — generation 4, source only until deployed | `AgentNameRegistry.sol` (`epoch`, `recordState`), `AttributeStorage._storageKey`, `AgentNameAttributeResolver`; `test/naming/Naming445B2.t.sol::test_REG4_*`, `test_REG6_*` |
|
|
73
|
+
| 2.30 | **Permissionless claims are commit-reveal.** `commit(keccak256(abi.encode(subregistry, chainId, labelhash, newOwner, secret)))`, then `register(label, newOwner, secret)` between 10 s and 1 day later; the commitment binds the OWNER, is single-use and cannot be re-committed while live. The one-claim-per-caller cap is a courtesy, not sybil resistance; production estates use `PricedSubregistry`. | ✅ CLOSED audit 2026-11-10 REG-5 (SUB-1 / SUB-2) — generation 4, source only until deployed | `naming/PermissionlessSubregistry.sol`; `test/naming/Naming445B2.t.sol::test_REG5_*` |
|
|
74
|
+
| 2.31 | **Estate roots are keyed by signer.** `EstateProjectionRegistry` rows are `(estateId, signer)`; there is no registration and no first-come id. A verifier reads `roots(estateId, <the signer the estate declares>)` — a stranger's row is never read; `rotateSigner` retires only the caller's row; `MAX_SEQUENCE_STEP` bounds a jump. | ✅ CLOSED audit 2026-11-10 REG-2 — generation 4, source only until deployed | `registry/EstateProjectionRegistry.sol`; `test/EstateProjectionRegistry410.t.sol`, `test/Registries445B2.t.sol::test_REG2_*` |
|
|
75
|
+
| 2.32 | **The paymaster signs the gas limits it sponsors, and a pushed pause survives sync.** `getHash` binds `paymasterAndData[20:52]` (verification ‖ postOp gas limits) — a sender cannot raise them after the sponsor signed; `syncPauseFromGovernance` cannot undo governance's explicit `setPauseMirror(true)` (`_pausePushed`, packed into the mirror's slot). | ✅ CLOSED audit 2026-11-10 DLG-4 / DLG-13a (spec 445 B1) — generation 4, source only until deployed | `SmartAgentPaymaster.sol:getHash`, `_pausePushed`; `test/DlgLows445B1.t.sol::test_DLG4_*`, `test_DLG13_*`; storage snapshot `SmartAgentPaymaster.snap.json` (slot 3, offset 21) |
|
|
76
|
+
| 2.33 | **A retired credential holds no trustee seat.** Every retirement the custody policy performs — `RemoveCustodian`, `RemovePasskeyCredential`, `RotateCredential`, `RotateAllCustodians`, `RecoverAccount` — vacates that credential's trustee seat (a passkey's seat is its per-account PIA, read before the key is deleted) in the same applied change; on a custody-governed account these are the only retirement paths (`_requireCustodyGoverned`). An approval the credential signed earlier stops counting, because every apply / cancel verifies its signers against the trustee set as it is then. If the recovery quorum would exceed the remaining trustees it is CLAMPED to them (0 = recovery disabled when none remain; `RecoveryThresholdChanged`) — refusing would stop an owner retiring a lost device that is also her only trustee. A quorum of zero is no quorum: `_verifyQuorum` refuses `reqThreshold == 0` (`RecoveryRequiresGuardianQuorum`), so a recovery scheduled before the clamp is dead. **Accepted consequence:** a clamp lowers the recovery quorum among the remaining trustees (e.g. {own passkey, Bob} 2-of-2 → {Bob} 1-of-1) — no new power, since a T4 quorum can already `SetRecoveryApprovals`. | ✅ CLOSED audit 2026-11-10 CUST-4 (spec 445 §1.5 / §9) — generation 4, source only until deployed | `CustodyPolicy.sol:_retireCustodian`, `_retirePasskey`, `_vacateTrusteeSeat`, `_verifyQuorum`; `test/CustodyMediums445.t.sol::test_CUST4_*` (real P-256 assertions + ECDSA quorums) |
|
|
77
|
+
| 2.34 | **Every tier stays reachable.** After every applied custody change: `approvalsRequired(t) ≤ custodianCount` for T1..T5, and in org mode `2 × T4/T5 ≤ custodianCount` with `custodianCount ≥ 2` (`ThresholdUnreachable(tier, required, bound)` / `InfeasibleOrgConfig`). A removal that would strand a tier carries its own lowering: `RemoveCustodian` / `RemovePasskeyCredential` args are `abi.encode(subject)` (unchanged) or `abi.encode(subject, uint8 newT4, uint8 newT5)` (0 = keep; lower-or-equal only; any decrease makes the action T5, audit C-8); other lengths `MalformedRemovalArgs` at schedule. `RotateAllCustodians` that strands is refused (lower first). A RECOVERY clamps instead of refusing (`ThresholdChanged` per tier) — the lifeline never strands the owner it returns the account to; org mode left with < 2 custodians is refused. | ✅ CLOSED audit 2026-11-10 CUST-5 (completes `ACCT-M1`, `acct-mode3-sod-cap-runtime` on the removal direction) — generation 4, source only until deployed | `CustodyPolicy.sol:_requireThresholdsReachable`, `_applyRemovalLowering`, `_clampThresholdsToCustodians`, `_effectiveTierFor`; `test/CustodyMediums445.t.sol::test_CUST5_*`; `test/invariant/CustodyThresholdsReachable445.invariant.t.sol` (INV-445-1..4 over real quorum-signed action sequences) |
|
|
78
|
+
| 2.35 | **A scheduled change lapses.** It applies from `eta` to `expiresAt = eta + APPLY_WINDOW` (7 days, every tier, recovery included) inclusive; after that `ProposalExpired(changeId, expiresAt)`, checked before any signature is read. `expiresAt` is a pure function of `eta`, so an apply approval (which signs `eta`) signs the expiry — no typehash change; the policy is not upgradeable, so the window cannot move under a signature. Recovery cancel rule unchanged: custodians (T4) within the first 24 h, the trustee quorum after; past the window a recovery is dead and a new one restarts both the 48 h and the owner's 24 h. View `scheduledChangeExpiry(account, id)`; `getScheduledChange` keeps its shape. | ✅ CLOSED audit 2026-11-10 CUST-6 — generation 4, source only until deployed | `CustodyPolicy.sol:APPLY_WINDOW`, `ScheduledChange.expiresAt` (appended; packs into the `proposer` slot), `applyCustodyChange`; `test/CustodyMediums445.t.sol::test_CUST6_*` |
|
|
79
|
+
| 2.36 | **A post-deploy install meets the factory's bounds.** Beyond the caller check and delay floors (2.24), `onInstall` for mode ≥ 1 requires trustees ≥ mode (1 / 2 / 3), ≤ 32 (`MAX_INITIAL_TRUSTEES`) and `recoveryApprovals ≥ 1` (`TrusteesOutsideModeBounds`); defaulted T4 / T5 in mode 3 get the factory's `floor(n/2)` cap; every tier must be reachable (2.34) — an explicit over-cap or above-count value is refused, not rewritten. | ✅ CLOSED audit 2026-11-10 ACCT-11 (remainder) — generation 4, source only until deployed | `CustodyPolicy.sol:onInstall`; `test/CustodyMediums445.t.sol::test_ACCT11_*` (signed user operations, spec-422 shape) |
|
|
55
80
|
|
|
56
81
|
## 3. Per-contract notes for the external review
|
|
57
82
|
|
|
58
83
|
### 3.1 `AgentAccount.sol` + `AgentAccountFactory.sol`
|
|
59
84
|
|
|
60
|
-
- **ERC-4337 v0.
|
|
85
|
+
- **ERC-4337 v0.9 + ERC-7579.** AgentAccount is a thin core (custody / threshold / spend / sessions live in modules, NOT inlined) — see spec 209 + `feedback_erc7579_module_architecture`.
|
|
61
86
|
- **UUPS upgradeable** with `_authorizeUpgrade` gated by `onlySelf` (modifier requires `msg.sender == address(this)`). The ONLY path is a re-entrant call from `upgradeToWithAuthorization` — that function is **explicitly disabled (`LegacyUpgradePathDisabled()`)** per H7-A.5 / audit C-3 closure. Per-account upgrades route through `CustodyPolicy.ApplySystemUpdate` (T5 / 24h timelock by default).
|
|
62
|
-
- **Pause coverage (R6.5):**
|
|
87
|
+
- **Pause coverage (R6.5, corrected in generation 4 — audit 2026-11-10 ACCT-2 / H-3):** pause-gated: `execute`, `executeBatch`, `executeFromModule`, `installModule`, `reaffirmModule`, `executePendingUpgrade`, `addCustodian`. Incident response must remain functional under pause, and until generation 4 it did not: the recovery functions carried no modifier but are `onlySelf`, and every door to a self-call was paused (the R6.5 tests pranked as the account). The doors are now open for exactly the cases in §3.4 — a signed user operation's `execute` to self with a recovery selector, or to the governance / its timelock; and the canonical custody policy's `executeFromModule` for the removal actions. Test packs: `test/AgentAccountPauseR65.t.sol` (pause gates + `AgentAccountPauseRecovery445Test`, through real user operations and quorum signatures), `test/governance/PauseIsLiftable445.t.sol`.
|
|
88
|
+
- **Governance-read failure = not paused (decision, audit DLG-7 as it concerns the account).** `_pauseState` treats a failed `factory.governance()` / `isPaused()` read as "not paused". Kept deliberately: failing closed would turn a broken or non-conforming governance into a permanent freeze nobody can lift (the only unpause authority is that same governance, and the factory's pointer is immutable); a caller cannot induce the failure (immutable getter + one storage read; gas starvation leaves too little for the gated call); and which governance a factory points at is asserted at deploy (`_assertProductionEndState`). An account with no factory, or whose factory's governance is an EOA, is outside the kill switch by construction.
|
|
89
|
+
- **Upgrades are vouched (generation 4, invariant 2.23).** `upgradeToAndCall` is overridden; see the NatSpec there for the migration statement.
|
|
90
|
+
- **Epoch stamps (generation 4, invariant 2.22).** Two slots taken from the gap (`_moduleEpochStamp`, `_delegationManagerEpochStamp`; 47 remain); the layout is append-only relative to generation 3.
|
|
91
|
+
- **Bytecode size:** `AgentAccount` is 23,092 B of the 24,576 B limit after generation 4 (1,484 B margin; was ~19.4 KB at generation 3). The next addition must move something out first — candidates: `executeFromBundler` (a view that executes nothing), the disabled `upgradeToWithAuthorization` stub, the inert `acceptSessionDelegation` set, or WebAuthn verification behind an external library.
|
|
63
92
|
- **`isValidSignature` dispatch:** type byte 0x01 → WebAuthn, type byte 0x02 → ECDSA, raw fallback → custodian sig. WebAuthn path pins per-credential rpIdHash + requires UP flag.
|
|
64
93
|
- **CREATE2 salt invariant.** Salt MUST derive from auth methods + scope, NEVER from a name (ADR-0010 + spec 220). Credential rotation does NOT change the SA address (ADR-0011 + spec 221).
|
|
65
94
|
|
|
66
95
|
### 3.2 `agency/DelegationManager.sol` + `enforcers/*`
|
|
67
96
|
|
|
68
|
-
- **5 enforcers.** AllowedMethods, AllowedTargets, Timestamp, Value, Quorum. All five are **stateless validators**: `beforeHook` / `afterHook` are pure / view, no SSTORE, no events. Invariant locked in `test/EnforcerPauseInvariantR67.t.sol` (R6.7) — see § 3.3.
|
|
97
|
+
- **5 stateless enforcers.** AllowedMethods, AllowedTargets, Timestamp, Value, Quorum. All five are **stateless validators**: `beforeHook` / `afterHook` are pure / view, no SSTORE, no events — safe to call externally. Invariant locked in `test/EnforcerPauseInvariantR67.t.sol` (R6.7) — see § 3.3.
|
|
98
|
+
- **PaymentEnforcer is the STATEFUL exception (EXT-PMT-1, was C-NEW-1).** It SSTOREs budget/nonce and writes a settlement receipt, so it is explicitly NOT safe to call externally. It is bound to an immutable `delegationManager` at construction and both hooks carry `onlyDelegationManager`; a direct caller reverts `NotDelegationManager` and can neither forge a `PaymentSettled` receipt nor grief the victim's budget/nonce. Fail-closed regression: `test/PaymentEnforcer.t.sol::test_EXTPMT1_*`. (Pre-fix, the unbound `beforeHook` let any EOA forge receipts + burn nonces — see `docs/audits/findings.yaml` EXT-PMT-1.)
|
|
69
99
|
- **EIP-712 Caveat typehash** = `keccak256("Caveat(address enforcer,bytes terms)")` — EXCLUDES `args` (audit F-1 — the inclusion bug caused every caveat-carrying delegation to fail on-chain ERC-1271 redeem AND let a redeemer's chosen args ride inside the delegator's signature). `packages/delegation/src/hash.ts` mirrors this.
|
|
70
100
|
- **Test posture:** DelegationManager 95.8% lines / 88.2% branches (post-R6 aggregator).
|
|
101
|
+
- **Generation 4 (spec 445 B1).** H-1 one root, last (2.20); DLG-2 no self-target (2.26); DLG-3 counted digest binding (2.17); DLG-7 the manager's pause read fails CLOSED when governance is configured (a codeless non-zero governance is refused at construction; a reverting / malformed `isPaused()` reverts `GovernanceReadFailed`) — unlike the account's read (§3.1), because the manager is a re-deploy-on-bug singleton; DLG-9 the delegator revokes without a verifying signature, `revokeDelegationAsUpstream` for hash-linked upstreams; DLG-10 the domain separator follows a chain split.
|
|
102
|
+
- **Generation coupling — a generation-4 `PaymentEnforcer` needs a generation-4 `DelegationManager`.** The enforcer reads the payer from `DelegationManager.redemptionRootDelegator()` (transient, set for one redemption; DLG-8c); pointed at an older manager every charge reverts. `DeployPayments.s.sol` binds an EXISTING manager by env — deploy both as one generation.
|
|
103
|
+
- **Chain depth for enforcers — `redemptionDepth()` (spec 450 §6, generation 5, source only until deployed).** While one of the manager's own hooks runs, `redemptionDepth()` returns `(links, position)`: the length of the chain being redeemed and the root-first index of the link whose caveat is checked. Two transient slots (appended after `_redemptionRoot`; the DM transient layout is now gated), set per redemption and per link's hook loop, saved and restored around a redemption (nesting is already unreachable — `nonReentrant`). Outside a hook — no redemption, chain validation, the executed call — it reverts `NotInCaveatHook()`, so no value can be read as "depth 0"; a depth-reading caveat therefore makes `verifyAuthorizationForCall` answer `(false, "caveat-failed")`. While a hook runs, both view verifiers return `(false, "in-redemption")` without evaluating, so they never judge a chain by the outer redemption's numbers (independent review, follow-up 5). An observation, never authority; existing hooks are called exactly as before. **Enforcer rule:** `maxBelow` from the signed `terms` (never `args`); revert unless `links − 1 − position ≤ maxBelow`; every carrying link is checked, so the strictest ancestor wins. The total-length fixture in the tests (`TotalLengthCapFixture450DoNotDeploy`) is NOT that rule. Pinned by `test/DelegationDepthView450.t.sol`.
|
|
71
104
|
- **QuorumEnforcer:** payload-hash binding closed in H7 (`QuorumEnforcer.sol` checks `keccak256(args) == decoded_payload_hash`). R6.9 aggregator confirms 95.5% lines / 100% branches.
|
|
72
105
|
|
|
73
106
|
### 3.3 Pause invariant for enforcers (R6.7)
|
|
74
107
|
|
|
75
108
|
All five enforcer `beforeHook` / `afterHook` functions are `external view` AND read no storage. Pause is not applicable because there is no state to mutate. The invariant is documented in source and **test-locked**: `test/EnforcerPauseInvariantR67.t.sol::SideEffectfulEnforcer` mock proves any future enforcer that writes state would fail the test.
|
|
76
109
|
|
|
77
|
-
### 3.4 Pause matrix (R6.5 / R6.6 / R6.8)
|
|
110
|
+
### 3.4 Pause matrix (R6.5 / R6.6 / R6.8 — corrected for generation 4, spec 445 §1.2)
|
|
78
111
|
|
|
79
|
-
Pause is system-wide
|
|
112
|
+
Pause is system-wide: `AgenticGovernance.pause()` by the guardian (immediate), `unpause()` by the timelock. Each consumer reads the flag via a fail-soft staticcall (governance == EOA / non-conforming contract → treated as "not paused" — see §3.1 for why that is a decision, not an accident) per `_pausedSafe()` in `GovernanceManaged.sol`.
|
|
80
113
|
|
|
81
|
-
|
|
114
|
+
**The correction (audit 2026-11-10 ACCT-2 / H-3).** The previous matrix listed `uninstallModule`, `cancelPendingUpgrade`, `removeCustodian` as "unguarded (recovery primitives)". They were un-gated and unreachable: all but `cancelPendingUpgrade` are `onlySelf`, and `execute` / `executeBatch` / `executeFromModule` — the only ways an account calls itself — were paused, as were the custody policy's schedule / apply. This matrix lists what a real caller can do under a pause.
|
|
115
|
+
|
|
116
|
+
| Contract | Frozen under pause | Reachable under pause — and through which door | Closure |
|
|
82
117
|
|---|---|---|---|
|
|
83
|
-
| `AgentAccount` | execute
|
|
84
|
-
| `CustodyPolicy` | scheduleCustodyChange
|
|
118
|
+
| `AgentAccount` | `executeBatch` (no exemption); every `execute` and `executeFromModule` not listed to the right; `installModule`, `reaffirmModule`, `executePendingUpgrade`, `addCustodian` (own modifier); and therefore every self-call that adds or changes authority: `addPasskey`, `setDelegationManager`, `reaffirmDelegationManager`, `setUpgradeTimelock`, `scheduleUpgrade`, `upgradeToAndCall`, `acceptSessionDelegation`, `approveDigest` | **`execute` from a validated user operation** to: the factory's governance; that governance's `timelock()`; or SELF with a recovery selector — `removeCustodian`, `removePasskey`, `uninstallModule`, `cancelPendingUpgrade`, `revokeDigest`, `revokeAllApprovedDigests`. **`executeFromModule` from the canonical custody policy** with a recovery selector on self. The user-operation door to the governance / timelock is the same in every custody mode (one custodian — open risk, invariant 2.27). `cancelPendingUpgrade` called directly with the owner's signed grant (mode 0). Each function keeps its own gates (`onlySelf`, the custody quorum on a governed account). Still live and NOT pause-gated: `validateUserOp`, `isValidSignature` (incl. the `0x03` sentinel) — a pause does not stop signature-authorized outflows (`permit`, EIP-3009, Permit2); it lets the owner retire the credential that signs them. | R6.5 → spec 445 §1.2 |
|
|
119
|
+
| `CustodyPolicy` | `scheduleCustodyChange` + `applyCustodyChange` for every action except the three to the right | `scheduleCustodyChange` + `applyCustodyChange` for `RemoveCustodian`, `RemovePasskeyCredential`, `UninstallModule` (same quorum, same safety delay; a removal may carry its CUST-5 T4/T5 lowering); `cancelScheduledChange`; `onUninstall` | R6.6 → spec 445 §1.2 |
|
|
85
120
|
| `AgentNameRegistry` | register, backfillLabel, setOwner, setResolver, setSubregistry, renew, setPrimaryName (7 functions) | initializeRoot (deployer init, runs ONCE per TLD anyway) | R6.8 |
|
|
86
121
|
| `PermissionlessSubregistry` | (no own guard — inherits via inner `REGISTRY.register` call) | — | Transitive R6.8 coverage; proven by `test_R6_8_subregistryRegister_pausedRevertsTransitively` |
|
|
87
|
-
| `SmartAgentPaymaster` | `_validatePaymasterUserOp` (early reverts on governance.isPaused()) | — | H7-C.10 / EXT3-010 |
|
|
122
|
+
| `SmartAgentPaymaster` | `_validatePaymasterUserOp` (early reverts on governance.isPaused()) — so an account acting under a pause pays its own gas | — | H7-C.10 / EXT3-010 |
|
|
123
|
+
| `UpgradeVoucher` | — (`vouch` / `unvouch` are governance-only and move no value) | all | spec 445 §1.3 |
|
|
124
|
+
|
|
125
|
+
Operational consequences: (1) role-holding accounts need an EntryPoint deposit or native balance to lift a pause (no sponsorship); (2) `AgentAccount.execute` validates ONE custodian signature on every custody mode — so a governance role held by any AgentAccount is one custodian's (open risk, invariant 2.27; ledger `acct-validator-modules-inert-1ofn`); the custody quorum for governance calls is deferred by owner decision 2026-11-10; (3) rotation, recovery, re-affirmation and upgrades are not available under a pause — only removal is.
|
|
88
126
|
|
|
89
127
|
### 3.5 `custody/CustodyPolicy.sol`
|
|
90
128
|
|
|
91
129
|
- **One ERC-7579 module per AgentAccount,** factory-immutable per spec 213 § 2.4. Per-account install via `onInstall(initData)` with ABI: `(uint8 mode, uint8 recoveryApprovals, address[] trustees, uint8[7] thresholds, uint32[7] timelocks, uint256 t3Ceiling, address approvedHashReg)`.
|
|
92
|
-
- **
|
|
130
|
+
- **21 CustodyAction enum cases** (0–16 unchanged; generation 4 appends `InstallModule` (17, T5), `UninstallModule` (18, T5), `LowerSpendCeiling` (19, T4), `SetSpendCeiling` (20, T5) — audit CUST-3 / ACCT-5; `RotateCredential`'s payload gains `reaffirmModules` + `reaffirmDelegationManager`; per § `_applyCustodyChange` dispatcher).
|
|
131
|
+
- **`onInstall` is reached only through `installModule` and applies the factory's delay floors (ACCT-11 / CUST-8):** the caller must list the policy as an installed EXECUTOR; for mode ≥ 1, T5 ≥ 24 h, T6 ≥ 48 h when recovery is enabled, T4 ≥ 1 h unless the account's factory declares `relaxedT4Floor`. Generation 4 (ACCT-11 remainder): the per-mode trustee bounds and the mode-3 cap are applied too, and every tier must be reachable (invariants 2.34, 2.36). Coverage by branch family in R6.10b + R6.10c — final state: **81.4% lines / 53% branches** (R6.10b) → after R6.10c **92.4% lines / 68% branches**.
|
|
93
132
|
- **Audit C-6..C-11 closures:** zero `credentialIdDigest` rejected, RotateAllCustodians wire shape add+remove, CustodyPolicy reinstall permanently forbidden, etc. See `test/CustodyPolicyWave2C.t.sol`.
|
|
94
|
-
- **Pause coverage (R6.6):** `scheduleCustodyChange` + `applyCustodyChange`
|
|
133
|
+
- **Pause coverage (R6.6, corrected in generation 4):** `scheduleCustodyChange` + `applyCustodyChange` are pause-gated for every action except `RemoveCustodian`, `RemovePasskeyCredential`, `UninstallModule` (§3.4); `cancelScheduledChange` UNGUARDED intentionally (recovery cancel during incident). A removal's three-word form (CUST-5, invariant 2.34) lowers T4 / T5 under a pause too — deliberately: under the 3-of-3 default, expelling a compromised custodian during an incident is impossible without it; it is still a full T5 quorum and the T5 delay.
|
|
95
134
|
- **Threshold defaults (spec § 5.1):** T4 default = max(N − 2, 1); T5 default = max(N − 1, 1); T6 default = `recoveryApprovals`. Factory derives `recoveryApprovals = trustees/2 + 1` if not overridden.
|
|
96
135
|
|
|
97
136
|
### 3.6 `SmartAgentPaymaster.sol` — economics + paymaster modes
|
|
@@ -130,6 +169,7 @@ Binds `address(entryPoint())` so a long-lived signed envelope CANNOT survive an
|
|
|
130
169
|
Per spec 214 SB-4. **One library function consumers call (`validateSig(signer, hash, sig)`)** that internally:
|
|
131
170
|
|
|
132
171
|
1. If `sig` looks like ERC-6492 (`0x6492...` magic suffix): execute the prefix calldata at the magic-named factory, then re-evaluate.
|
|
172
|
+
0. If `signer` is a 7702-delegated EOA: ECDSA only, before any of the below (§3.10).
|
|
133
173
|
2. If `signer` has code: call `signer.isValidSignature(hash, sig)` (ERC-1271) and check magic value.
|
|
134
174
|
3. Otherwise: ECDSA `ecrecover` against `signer`.
|
|
135
175
|
|
|
@@ -139,8 +179,9 @@ Per spec 214 SB-4. **One library function consumers call (`validateSig(signer, h
|
|
|
139
179
|
|
|
140
180
|
### 3.8 `naming/*`
|
|
141
181
|
|
|
142
|
-
- **Multi-root registry.** `.agent`
|
|
143
|
-
- **PermissionlessSubregistry per
|
|
182
|
+
- **Multi-root registry.** `.agent` + the nine typed roots, all initialized by `Deploy.s.sol` in its bootstrap phase; the initializer is then relinquished to the naming authority (invariant 2.6). The impact root (2026-06-01 → retired 2026-11-10) is no longer provisioned and its script is deleted; deployed instances remain on chain as manifest history (`_retiredRoots`) and are closed by `AddPricedSubregistries.s.sol` with `LEGACY_ROOTS`.
|
|
183
|
+
- **PermissionlessSubregistry per root (testnet posture only)** — commit-reveal (2.30), one reveal per caller as a courtesy cap. Production roots are fronted by `PricedSubregistry`, chosen by the naming authority after the deploy.
|
|
184
|
+
- **Generation 4 (spec 445 B2):** reserved labels on chain (2.28), owner-epoch records + parent-only renewal (2.29), `setOwner` single-step (ENS-like; the scripted root hand-over relies on it). Rule for scripts: never write resolver records on a node before handing it over — the epoch bump drops them.
|
|
144
185
|
- **`reverseResolveString` (spec/222)** is the canonical reverse path — NO `eth_getLogs` walker fallback (ADR-0012, ADR-0013).
|
|
145
186
|
- **Pause coverage (R6.8):** all mutating functions guarded; `initializeRoot` exempt because it runs ONCE per TLD ever.
|
|
146
187
|
|
|
@@ -148,6 +189,33 @@ Per spec 214 SB-4. **One library function consumers call (`validateSig(signer, h
|
|
|
148
189
|
|
|
149
190
|
EXT-019 status: **experimental** — public on-chain edges leak the social graph. Production deployments where membership / participation is sensitive should NOT register relationships on this contract; the package's `AUDIT.md` makes this explicit. A future spec covers an encrypted-edge variant.
|
|
150
191
|
|
|
192
|
+
### 3.10 EIP-7702 — a delegated EOA is an EOA (spec 448 §0, 2026-12-02)
|
|
193
|
+
|
|
194
|
+
**Rule: an address whose code is a 7702 delegation designator (`0xef0100 ‖ delegate`) is an EOA for every authority
|
|
195
|
+
purpose — it signs by ECDSA or it has no voice.** Its attached code was chosen by whoever obtained ONE authorization
|
|
196
|
+
signature from the key, and anyone can make it CALL or answer calls. So it is never asked "is this signature yours?"
|
|
197
|
+
(ERC-1271), and it is never trusted as `msg.sender` where a role is decided. One check, `libraries/Eip7702.sol`
|
|
198
|
+
(`isDelegatedEOA`, `refuseDelegatedEOA` → `DelegatedEOA(address)`); EIP-3541 means no deployed contract can match it.
|
|
199
|
+
Twins: `test/Eip7702Signatures448.t.sol`, `test/Eip7702Roles448.t.sol`, and `test_7702_*` in the fixture files.
|
|
200
|
+
|
|
201
|
+
| Path | Rule now |
|
|
202
|
+
| --- | --- |
|
|
203
|
+
| `SignatureSlotRecovery` v=0 (CustodyPolicy via `SignatureVerifier`; `QuorumEnforcer`) | delegated signer refused; its vote is v=27/28 only |
|
|
204
|
+
| `SignatureSlotRecovery` v=1 / `ApprovedHashRegistry.approveHash` | delegated caller refused; keyed raw, so `revokeHash` of its pre-delegation approvals works |
|
|
205
|
+
| `DelegationManager` delegator / delegate-revocation signatures | ECDSA (EIP-191) only for a delegated EOA |
|
|
206
|
+
| `DelegationManager` redemption, named delegate == `msg.sender` | delegated EOA refused (view: `delegated-eoa-redeemer`) |
|
|
207
|
+
| `UniversalSignatureValidator` (incl. ERC-6492 wrapper) | ECDSA only for a delegated EOA |
|
|
208
|
+
| `AttestationRegistry` / `AgreementRegistry` signatures (REG-16 reversed) | ECDSA only for a delegated EOA |
|
|
209
|
+
| Governance seats: `StableProxyGoverned(OneShot)` `onlyGovernance` + `_authorizeUpgrade`, `GovernanceManaged`, `DelegationManager`/`ApprovedHashRegistry` upgrade, `SmartAgentPaymaster`, `AgenticGovernance` guardian/timelock | delegated caller refused; `setGuardian` and the DM/AHR initializers refuse a delegated address |
|
|
210
|
+
| Governors + `acceptGovernor` (Shape, OntologyTerm, RelationshipType, PricedSubregistry), `PaymentReceiptRegistry` owner, `AgentNameRegistry` initializer/admin/owner/parent, `AgentNameAttributeResolver` owner | delegated caller refused |
|
|
211
|
+
| Parties: `AgentRegistryBase` controller/admin/subject, `AgentRelationship` propose/confirm/activate/addRole/metadata, `AttestationRegistry.assertAssociation` subject, `AgentProfileResolver` agent, Geo/Skill steward, `EstateProjectionRegistry`, `ReceiptAnchorRegistry`, `PaymentEscrow` release/refund/reclaim | delegated caller refused |
|
|
212
|
+
| **Left open, by design:** revocations of the caller's own grants (`revokeDelegationByOwner`/`AsUpstream`, `revokeHash`/`revokeAll`, `revokeOwn*`, `revokeEdge`/`removeRole`, subject `revokeEntry`); spending the caller's own assets (`PaymentEscrow.deposit`, `PricedSubregistry.claim`); its own namespace (`PermissionlessSubregistry.register` quota, `TreasurySpendPolicy`) | a removal grants nothing, and attached code can already move the EOA's own assets |
|
|
213
|
+
| `AgentAccount` (custodians by ecrecover/WebAuthn only), contract-only callers (EntryPoint, factory, DelegationManager, executor) | unchanged — never exposed |
|
|
214
|
+
|
|
215
|
+
Not enforceable on chain: a role or delegate key that is an EOA can still be phished into an authorization. The
|
|
216
|
+
off-chain half is that no KMS or runtime key holding a role may sign a raw 32-byte digest or an
|
|
217
|
+
`EIP7702_AUTHORIZATION` (key-custody purposes; fix report `EIP-7702.md`).
|
|
218
|
+
|
|
151
219
|
## 4. Upgrade & governance — production posture
|
|
152
220
|
|
|
153
221
|
### 4.1 The production gate (open audit item N1)
|
|
@@ -167,13 +235,15 @@ EXT-019 status: **experimental** — public on-chain edges leak the social graph
|
|
|
167
235
|
|
|
168
236
|
### 4.2 Upgrade pattern
|
|
169
237
|
|
|
170
|
-
- AgentAccount: UUPSUpgradeable. `_authorizeUpgrade` gated by `onlySelf`. Per-account upgrades routed through `CustodyPolicy.ApplySystemUpdate` (T5 / 24h timelock by default).
|
|
238
|
+
- AgentAccount: UUPSUpgradeable. `_authorizeUpgrade` gated by `onlySelf`. Per-account upgrades routed through `CustodyPolicy.ApplySystemUpdate` (T5 / 24h timelock by default). **Generation 4:** every upgrade — on every path — must also be vouched by the implementation's `UpgradeVoucher` (governance through the timelock) for the exact `(implementation, keccak256(migration data))`; invariant 2.23.
|
|
239
|
+
- UpgradeVoucher: generations ≤ 4 NOT upgradeable; from generation 5 a governance-upgradeable proxy (2.36). No setter for its governance. To change who vouches, deploy a new voucher and a new account implementation built around it (reaching that implementation is an upgrade the OLD voucher must vouch for).
|
|
240
|
+
- **Migrating a generation ≤ 3 account** (runbook input): (1) governance cannot constrain the account's last old-rules upgrade — review the target implementation address off-chain; (2) after the upgrade, every pre-existing non-canonical executor module and a non-canonical delegation manager are unstamped and NOT honoured until the owner re-affirms them (`reaffirmModule` / `reaffirmDelegationManager`); hooks keep working; (3) the account's factory pointer does not change, so its canonical custody policy and delegation manager remain the generation ≤ 3 ones — moving to the generation-4 DelegationManager is a `setDelegationManager` that must then be re-affirmed in every rotation, and a governed account keeps the old custody action set (no actions 17–20, no re-affirmation in `RotateCredential`); (4) migration does not clean an account that was compromised before it.
|
|
171
241
|
- AgenticGovernance: NOT upgradeable. Operator deploys a new governance instance to migrate.
|
|
172
|
-
- AgentAccountFactory + SmartAgentPaymaster + DelegationManager + CustodyPolicy + naming/* + enforcers: NOT upgradeable
|
|
242
|
+
- AgentAccountFactory + SmartAgentPaymaster + DelegationManager + CustodyPolicy + naming/* + enforcers: generations ≤ 4 NOT upgradeable (redeploy + migrate-by-naming-handle). **Generation 5: each is a UUPS proxy upgraded by `AgenticGovernance` through the timelock — invariant 2.36 states the limits and the trust.** The 2026-06-01 R6 redeploy + root re-init demonstrates the runbook.
|
|
173
243
|
|
|
174
244
|
### 4.3 TimelockController
|
|
175
245
|
|
|
176
|
-
`Deploy.s.sol` deploys an OpenZeppelin TimelockController with a 24h minimum delay.
|
|
246
|
+
`Deploy.s.sol` deploys an OpenZeppelin TimelockController with a 24h minimum delay. On a production label it has NO standing admin (the timelock administers itself; role changes take the delay), its proposer / executor are refused when one key can drive them (2.27), and `AgenticGovernance` holds its `CANCELLER` role for the guardian's veto (2.36). Production governance flows queue → wait 24h → execute.
|
|
177
247
|
|
|
178
248
|
## 5. Test posture
|
|
179
249
|
|
|
@@ -219,9 +289,9 @@ Each proof: caller address symbolic, all args symbolic, only constraint is `call
|
|
|
219
289
|
| `DelegationManager.invariant.t.sol` | revocation irreversible • hash deterministic • domain separator immutable • root/open constants unchanged • revoked-set monotonic |
|
|
220
290
|
| `SmartAgentPaymaster.invariant.t.sol` | devMode locked • governance immutable • verifyingSigner locked • arbitrary-sender not accepted • governance gate holds for fresh caller |
|
|
221
291
|
|
|
222
|
-
**Echidna nightly fuzz (R9.4):** `test/echidna/CustodyPolicyEchidna.t.sol` — 4 properties × 50,000 sequences × 4 parallel workers, runs nightly at 02:17 UTC via `.github/workflows/contracts-echidna-nightly.yml`.
|
|
292
|
+
**Echidna nightly fuzz (R9.4):** `test/echidna/CustodyPolicyEchidna.t.sol` — 4 properties × 50,000 sequences × 4 parallel workers, runs nightly at 02:17 UTC via `.github/workflows/contracts-echidna-nightly.yml`. A falsified property fails the job (since 2026-11-10; before that it was `continue-on-error: true`); corpus uploaded as a 30-day-retained artifact. Smoke run: 1.3M calls / 4524 unique instructions / all 4 properties PASS in 26 seconds.
|
|
223
293
|
|
|
224
|
-
**Medusa weekend fuzz (R9.5):** `test/medusa/CustodyPolicyMedusa.t.sol` — 4 properties × 4-hour budget × 4 parallel workers, runs Saturday 03:17 UTC via `.github/workflows/contracts-medusa-weekend.yml`. Different EVM engine (go-ethereum vs Echidna's HEVM) — independent coverage graphs.
|
|
294
|
+
**Medusa weekend fuzz (R9.5):** `test/medusa/CustodyPolicyMedusa.t.sol` — 4 properties × 4-hour budget × 4 parallel workers, runs Saturday 03:17 UTC via `.github/workflows/contracts-medusa-weekend.yml`. Different EVM engine (go-ethereum vs Echidna's HEVM) — independent coverage graphs. A falsified property fails the job (since 2026-11-10); 60-day corpus retention; corpora are artifacts, not committed.
|
|
225
295
|
|
|
226
296
|
**Stack mix rationale.** Each tool has a different blind spot:
|
|
227
297
|
- Foundry invariants — stateful random + seeded shrinking; PR-blocking; catches per-PR regressions.
|
|
@@ -239,7 +309,27 @@ The `dist/deployments/` subpath (R7.3) exposes per-network contract addresses to
|
|
|
239
309
|
|
|
240
310
|
## 7. Known findings (cross-reference)
|
|
241
311
|
|
|
242
|
-
|
|
312
|
+
Canonical cross-cutting status: [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml) (CI-enforced).
|
|
313
|
+
Historical detail: [`docs/audits/archive/2026-05/2026-05-packages-contracts-production-readiness.md`](../../docs/audits/archive/2026-05/2026-05-packages-contracts-production-readiness.md) § 3–4.
|
|
314
|
+
|
|
315
|
+
**Closed (2026-06-09 independent contracts audit — SC-1..SC-5):**
|
|
316
|
+
|
|
317
|
+
- **SC-1** (critical) — agreement issuer signature now bound to contents: `AgreementRegistry.register()` recomputes the digest over `agreementCommitment, schemaHash, issuer, chainId, address(this)` (`AGREEMENT_ISSUER_TYPEHASH`).
|
|
318
|
+
- **SC-2** (high) — attestation subject-spoofing closed: `assertAssociation()` binds `subject, issuer, schemaId, credentialType, credentialHash, chainId, address(this)` (`ASSOCIATION_ATTESTATION_TYPEHASH`); joint path requires both party co-signatures.
|
|
319
|
+
- **SC-3** (medium) — `DelegationManager.verifyAuthorizationForCall()` returns `(false,"no-code-enforcer")` instead of failing open on a no-code enforcer.
|
|
320
|
+
- **SC-4** (medium) — the then-user-facing root handed to `roles.namingRootOwner` (governance) at deploy, with a post-deploy assertion. Moot since 2026-11-10: that root is retired and not provisioned; every provisioned root is asserted owned by the naming authority in `_assertProductionEndState`.
|
|
321
|
+
- **SC-5** (medium) — paymaster deploy `require`-rejects deployer-as-governance/owner in production mode.
|
|
322
|
+
|
|
323
|
+
**Open — contract deep audit 2026-06-10** (full detail: [`docs/audits/2026-06-10-contract-by-contract-audit.md`](../../docs/audits/2026-06-10-contract-by-contract-audit.md); status in `findings.yaml`):
|
|
324
|
+
|
|
325
|
+
| Finding | Severity | One-line |
|
|
326
|
+
|---|---|---|
|
|
327
|
+
| **CA-F1** | High | Factory counterfactual address omits mode/trustees/timelocks → pre-deploy custody hijack of the canonical identity. **Mainnet blocker.** |
|
|
328
|
+
| **CP-1** | High | Custody tier thresholds default to 1-of-n → one custodian key can rotate the set / upgrade impl. **Mainnet blocker.** |
|
|
329
|
+
| **AN-1-ONCHAIN** | High | On-chain name registry enforces no label normalization (the SDK fix is bypassable by direct callers). |
|
|
330
|
+
| **SUB-1 / SUB-2** | High | Subregistry name front-running (no commit-reveal) + sybil/homoglyph mass-squatting. |
|
|
331
|
+
| **ATT-1** | High | `assertJointAgreement` issuer signature over a bare `credentialHash` (the SC-2 bug class, issuer side). |
|
|
332
|
+
| **AGR-1, ATT-2, CA-1, CA-2, CP-2, DM-1/2, EN-11/13/22, PM-1/2, GOV-1, WA-1/2, AN-2, RES-1, ONT-4/7** | Medium | See the report + `findings.yaml`. |
|
|
243
333
|
|
|
244
334
|
**Open at 2026-06-01:**
|
|
245
335
|
|
|
@@ -305,7 +395,9 @@ For the full threat model see [`docs/audits/threat-model.md`](../../docs/audits/
|
|
|
305
395
|
| **Cross-EntryPoint replay** | Reuses a paymaster envelope against a redeployed EntryPoint | `getHash` binds `address(entryPoint())` — H7-C.7 / CON-PAYMASTER-004 |
|
|
306
396
|
| **Caveat author** | Picks `args` to slip a redeem through a delegator's signature | Caveat typehash EXCLUDES `args` — audit F-1 closure |
|
|
307
397
|
| **Reentrant subregistry caller** | Mock registry re-enters during inner `register` call | `nonReentrant` on `PermissionlessSubregistry.register` — R6.2 |
|
|
308
|
-
| **Governance pause bypass** | Calls during incident |
|
|
398
|
+
| **Governance pause bypass** | Calls during incident | Pause gate on all write surfaces; exempt only: a user operation's `execute` to governance / its timelock / an allow-listed removal on self, and the custody quorum's removal actions (§3.4) |
|
|
399
|
+
| **Retired credential** | Installed a module / delegation manager / queued an upgrade / tried to run code as the account before it was retired | Epoch-stamped modules + delegation manager, queue cleared at retirement, vouched upgrades (invariants 2.22, 2.23). NOT covered: what it did before the account reached generation 4 |
|
|
400
|
+
| **Treasury custodian or delegate** | `approve` + external pull, an unpriced token call, speaking to the hook as the treasury | `TreasurySpendPolicy` counts allowances and fails closed; modules are not execute targets (invariant 2.24). A mode-0 treasury's own key is not bounded |
|
|
309
401
|
| **WebAuthn rp-id swap** | Registers passkey for one origin, signs for another | `_setupInitialPasskey` rejects zero `rpIdHash`; per-credential rpIdHash stored + checked at verify time |
|
|
310
402
|
|
|
311
403
|
## 10. Audit engagement targets
|
package/README.md
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agenticprimitives/contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Part of **[Agentic Primitives](https://agenticprimitives.dev)** — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. [Developer kit](https://github.com/agentictrustlabs/agentic-primitives) · [All packages](https://agenticprimitives.dev/developers)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Contracts and SDK are one artifact.**
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
This is the on-chain enforcement layer of the agenticprimitives substrate — 42 Solidity sources, all present and audited under `src/`, none of them stubs. ERC-4337 v0.7 Smart Agent core, ERC-7710-style delegation manager with caveat enforcers, an ERC-7579 modular CustodyPolicy, a three-mode paymaster, `.agent` TLD naming with hierarchical subregistries, ontology and profile resolvers, identity facets, and an ERC-6492-aware UniversalSignatureValidator. The package publishes ABI subpaths, per-network deployment JSON, flattened sources, and the Solidity itself — so a TypeScript consumer pulls addresses and ABIs from the same artifact the auditors read.
|
|
8
|
+
|
|
9
|
+
"One artifact" is CI-enforced, not aspirational: TypeScript typehashes are locked to the Solidity constants (`pnpm check:eip712-typehash-equality`), ABIs are sync-gated, and storage layouts are snapshot-gated (`pnpm check:storage-layouts`). You cannot drift the client from the chain.
|
|
10
|
+
|
|
11
|
+
> Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
|
|
12
|
+
|
|
13
|
+
## What's in `src/`
|
|
14
|
+
|
|
15
|
+
- `AgentAccount.sol` — UUPSUpgradeable + ERC-7579 + ERC-1271 + WebAuthn-supporting Smart Agent; a thin modular core where custody, threshold, and session machinery are modules, not inlined features
|
|
9
16
|
- `AgentAccountFactory.sol` — CREATE2 deterministic deploys; salt from auth methods + scope (NEVER from a name)
|
|
10
17
|
- `SmartAgentPaymaster.sol` — verifying-paymaster + allowlist + devMode (testnet only) modes
|
|
11
|
-
- `agency/DelegationManager.sol` + `enforcers/{AllowedMethods,AllowedTargets,Timestamp,Value,Quorum}Enforcer.sol`
|
|
18
|
+
- `agency/DelegationManager.sol` + `enforcers/{AllowedMethods,AllowedTargets,Timestamp,Value,Quorum,CallDataHash}Enforcer.sol` — scoped delegation with on-chain caveat enforcement
|
|
12
19
|
- `custody/CustodyPolicy.sol` — 16-action ERC-7579 module, T4/T5/T6 quorum tiers + 24h default T5 timelock
|
|
13
20
|
- `naming/{AgentNameRegistry,AgentNameUniversalResolver,AgentNameAttributeResolver,PermissionlessSubregistry}.sol`
|
|
14
21
|
- `identity/AgentProfileResolver.sol` + `ontology/{OntologyTermRegistry,ShapeRegistry,AttributeStorage}.sol`
|
|
15
|
-
- `relationships/{AgentRelationship,RelationshipTypeRegistry}.sol` (⚠ Privacy Fork — see AUDIT.md § 3.9)
|
|
22
|
+
- `relationships/{AgentRelationship,RelationshipTypeRegistry}.sol` (⚠ Privacy Fork — experimental surface; see AUDIT.md § 3.9)
|
|
16
23
|
- `governance/{AgenticGovernance,GovernanceManaged}.sol` — system pause + governance base
|
|
17
|
-
- `libraries/{WebAuthnLib,P256Verifier,SignatureSlotRecovery,MultiSendCallOnly}.sol`
|
|
24
|
+
- `libraries/{WebAuthnLib,P256Verifier,SignatureSlotRecovery,MultiSendCallOnly}.sol` — security-critical primitives
|
|
18
25
|
- `UniversalSignatureValidator.sol` — single signature entrypoint (ERC-6492 + ERC-1271 + raw ECDSA fanout per spec 214 SB-4)
|
|
19
26
|
- `ApprovedHashRegistry.sol` — v=1 pre-approved hash signature path
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
Behind it: 774 Foundry tests including invariant suites, plus Halmos symbolic proofs, Echidna and Medusa fuzzing campaigns, and PR-blocking static analysis (Slither, Aderyn, CodeQL, Solhint).
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
Deployed addresses (Base Sepolia testnet): [`deployments-base-sepolia.json`](./deployments-base-sepolia.json) — committed, public, and surfaced to TypeScript consumers via the generated `@agenticprimitives/contracts/deployments/base-sepolia` subpath.
|
|
31
|
+
|
|
32
|
+
## How it's different
|
|
33
|
+
|
|
34
|
+
Compared to Safe, ZeroDev, or Alchemy's contract stacks, the difference is scope and coupling. Those projects ship an account (and ship it well); the rest of the trust chain — who the account is, what it may delegate, how custody recovers it — is left to integrations with other vendors' contracts. Here the account, delegation manager, caveat enforcers, custody module, naming registry, and signature validator are designed and audited as one system, sharing one identity anchor. There is no third-party multi-sig dependency: custody quorums are our own ERC-7579 module, with Safe-style signature packing ported as a pattern rather than inherited as a runtime dependency. And the consumption model is different — most contract suites hand you addresses and a block explorer link; this package hands you versioned ABIs, deployments, and flattened sources as npm subpaths, CI-locked to the TypeScript SDK that consumes them.
|
|
24
35
|
|
|
25
36
|
## Setup
|
|
26
37
|
|
|
@@ -43,7 +54,7 @@ anvil
|
|
|
43
54
|
pnpm deploy:anvil
|
|
44
55
|
```
|
|
45
56
|
|
|
46
|
-
Writes deployed addresses to `deployments-anvil.json`. The
|
|
57
|
+
Writes deployed addresses to `deployments-anvil.json`. The demo apps (`apps/demo-web`, `apps/demo-a2a`, `apps/demo-mcp`) read this file on startup.
|
|
47
58
|
|
|
48
59
|
## Deploy to Base Sepolia
|
|
49
60
|
|
|
@@ -53,4 +64,28 @@ export PRIVATE_KEY=0x... # funded deployer
|
|
|
53
64
|
pnpm deploy:base-sepolia
|
|
54
65
|
```
|
|
55
66
|
|
|
56
|
-
Writes to `deployments-base-sepolia.json`.
|
|
67
|
+
Writes to `deployments-base-sepolia.json`. CI and hosted deploys read this. Demo idle cost: ~$0.
|
|
68
|
+
|
|
69
|
+
## Audit posture
|
|
70
|
+
|
|
71
|
+
Trust infrastructure should be the most transparent code you depend on, so the audit trail is public by default:
|
|
72
|
+
|
|
73
|
+
- [`AUDIT.md`](./AUDIT.md) — the security and invariant dossier for every contract under `src/`, including the production key-rotation runbook (§ 4.1).
|
|
74
|
+
- [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml) — the live, CI-gated findings ledger; a "closed" finding must anchor to real source or the build fails.
|
|
75
|
+
- [`docs/audits/2026-05-packages-contracts-production-readiness.md`](../../docs/audits/2026-05-packages-contracts-production-readiness.md) — the per-contract findings dossier.
|
|
76
|
+
- [`CLAUDE.md`](./CLAUDE.md) — architecture rationale and per-file roles.
|
|
77
|
+
|
|
78
|
+
## Status
|
|
79
|
+
|
|
80
|
+
Testnet/pilot-ready. Production launch is gated on the public checklist in the root README — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
|
|
81
|
+
|
|
82
|
+
**Production deployment is deliberately deferred:** the testnet uses a publicly disclosed deployer EOA on purpose (it keeps the demo reproducible). The production rotation runbook is [`AUDIT.md` § 4.1](./AUDIT.md#41-the-production-gate-open-audit-item-n1).
|
|
83
|
+
|
|
84
|
+
## Incremental ontology scripts
|
|
85
|
+
|
|
86
|
+
| Script | Adds | Notes |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| `script/AddAgentTypeRoots.s.sol` | typed roots + `atl:AgentTypeEnum` members (spec 346) | one `PermissionlessSubregistry` per root |
|
|
89
|
+
| `script/AddVerticalRoots.s.sol` | app-registered vertical roots + `atl:agentSubtype` (spec 346 §2.4) | vocabulary is the app's |
|
|
90
|
+
| `script/AddDistributionPredicate.s.sol` | `atl:distribution` (string JSON per `AgentDistributionV1`, spec 347 §8.5) | idempotent; run 2026-08-30 on faithchain (34348) + Base Sepolia |
|
|
91
|
+
| `script/AddCardPredicates.s.sol` | `atl:cardDigest` (bytes32) + `atl:cardUri` (string) (spec 347 §8.3); `UPDATE_SHAPE=true` refreshes `atl:AgentName` to shape v2 (14 props) | idempotent; run 2026-08-30 on faithchain (34348) + Base Sepolia |
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"agentAccountFactory": "0xA9B6e53FcD8DA3658DeD09f4e37b22baA25De715",
|
|
3
|
+
"agentAccountImplementation": "0x97DAC0cC056093B7DBFb4183804EA72f8d89972F",
|
|
4
|
+
"agentNameRegistry": "0x6629Cca40B008C0984a1Ca266Ca10A344420cac3",
|
|
5
|
+
"agentNameResolver": "0xA15B0703716DC8634B74F97723618f74Af3AaA73",
|
|
6
|
+
"agentNameUniversalResolver": "0xB890060dE1B3Fd2C78e1f0859da3883743eAD452",
|
|
7
|
+
"agentProfileResolver": "0xfcd37F8dca26ead889922b22C169c21370bd352a",
|
|
8
|
+
"agentRelationship": "0x0AF2455e3f76594E81d9042aD5FE22A5A35dc57f",
|
|
9
|
+
"agreementRegistry": "0xa62c888595Cd3A645e340EA7768B53b4fC257DF5",
|
|
10
|
+
"allowedMethodsEnforcer": "0xa076b759D6785bA5E67016e399Af651fC2ABC811",
|
|
11
|
+
"allowedTargetsEnforcer": "0xb06252FaD1D41B9943c73ec696Af70F268581625",
|
|
12
|
+
"approvedHashRegistry": "0x465f8DCE65aB51A1562CC60E6bc046ca8734D537",
|
|
13
|
+
"attestationRegistry": "0xD57f2e52395b9C99fAE8Abf823578faFe038f5B7",
|
|
14
|
+
"callDataHashEnforcer": "0xA614d6E5ECebc308b4e0bABDC7c832da059bb132",
|
|
15
|
+
"chainId": 84532,
|
|
16
|
+
"custodyPolicy": "0x5DB542eeBa652372afE6B4b0Cd40D999e65846de",
|
|
17
|
+
"delegationManager": "0x9eD1dC0FD2284fcd4967beeF3317129fee7a92e5",
|
|
18
|
+
"deployer": "0x31ed17fb99e82E02085Ab4B3cbdaB05489098b44",
|
|
19
|
+
"entryPoint": "0x96E37dD695840AF7781E669bdca9d79E4d7d8040",
|
|
20
|
+
"geoFeatureRegistry": "0x7D4F6F5cca1cDb1c72b25c50aB80Fb9629BA800B",
|
|
21
|
+
"mockUsdc": "0x6cfF706bA1461a9ef9F5aaf8f1581301805FbF92",
|
|
22
|
+
"ontologyTermRegistry": "0xC03a64e1492021fEc27f31F066f09Abe28F73e00",
|
|
23
|
+
"paymentEnforcer": "0x4DAc5F8891112D0C34d207FcE5ED78f13cD2b7d8",
|
|
24
|
+
"paymentReceiptRegistry": "0xF659091DDB30D3A608d6f96fAEDB41e966B72433",
|
|
25
|
+
"permissionlessSubregistry": "0x598C7bbAf25f5246BE3D5A75FdEDC180D67D8026",
|
|
26
|
+
"_permissionlessSubregistryRetired": "retired 2026-11-10 (owner's decision): the subregistry of the impact root, which remains on chain as recorded history — not resolved or claimed through the SDK, never written by Deploy.s.sol again. Read permissionlessSubregistries.<tld> (a person claims under .me).",
|
|
27
|
+
"_retiredRoots": ["impact"],
|
|
28
|
+
"permissionlessSubregistryDemoAgent": "0x571f9F2e12939F2fEDFC431aD6d7323d7483e02B",
|
|
29
|
+
"quorumEnforcer": "0xA4b148EfF1Ff1c116849F6e9D9c0059bC644873F",
|
|
30
|
+
"relationshipTypeRegistry": "0x8991a3ECf1DD41064Aa48DaF15a24B3d6a2811C5",
|
|
31
|
+
"shapeRegistry": "0xdE375012B37820C23272e2A2c9de2A8F6328aFA3",
|
|
32
|
+
"skillDefinitionRegistry": "0x167c8a31d5Fc36558A4eAD0CA96AcA7936a8e5e7",
|
|
33
|
+
"smartAgentPaymaster": "0x3444160e79C463B8F1e10f86Eae4047E22256aD0",
|
|
34
|
+
"timestampEnforcer": "0xBb8fF9c82417189c6EfeBbB369e9dd9d651aa0f3",
|
|
35
|
+
"universalSignatureValidator": "0x3bc65655d4b6fb57731A256fcd47Db2F8Fe36907",
|
|
36
|
+
"valueEnforcer": "0x3D2abD6c7C1319f2bbA96B3b76A7e0d92C620A39",
|
|
37
|
+
"agentRegistryBase": "0xB18534CA9c679968132ca2a43E454f5fA341030D",
|
|
38
|
+
"agenticGovernance": "0x27c1F21ffA275e61Fe152Edd4f2676fD6a816dDa",
|
|
39
|
+
"timelockController": "0xeB66E0B92287E53BB5A80bD2a01002150249DC94",
|
|
40
|
+
"governanceGuardian": "0x31ed17fb99e82E02085Ab4B3cbdaB05489098b44",
|
|
41
|
+
"permissionlessSubregistries": {
|
|
42
|
+
"me": "0xDEABb2Ed8382775a01752f171bC4c625AcD15A71",
|
|
43
|
+
"org": "0x13D2cabD890C93eF24937cc19dcDdc2a4d914418",
|
|
44
|
+
"team": "0xC80e6B102721F6D0b158124E0095D3B12d941126",
|
|
45
|
+
"svc": "0xcf6d51c105E83621FcFA58D89a3846B8090352b4",
|
|
46
|
+
"workspace": "0x9f8b948a9a18C68dBF862cE61444112A93d9A491",
|
|
47
|
+
"treasury": "0xDFA05aa99B1C5dA606a438eaF7eD3b52a231E385",
|
|
48
|
+
"registry": "0x32d3a37f44614959049b9f19D610554e8D4aBD6C",
|
|
49
|
+
"church": "0x97402E5A152670f356Eab9fD4270e1c8888ffc87",
|
|
50
|
+
"circle": "0xE194187c64c45803eda55BC399A4e7d39C1449A6"
|
|
51
|
+
}
|
|
52
|
+
}
|