Skip to content

feat: Permissionless Agent Registry & Vault Factory#22

Merged
Mehd1b merged 2 commits into
mainfrom
dev
Feb 1, 2026
Merged

feat: Permissionless Agent Registry & Vault Factory#22
Mehd1b merged 2 commits into
mainfrom
dev

Conversation

@Mehd1b

@Mehd1b Mehd1b commented Feb 1, 2026

Copy link
Copy Markdown
Member

Summary

This PR transforms the on-chain system from owner-controlled to fully permissionless:

  • AgentRegistry: Permissionless agent registration with deterministic IDs (keccak256(author, salt))
  • VaultFactory: CREATE2 vault deployment with imageId pinning at deployment time
  • KernelVault: Now pins trustedImageId as immutable - registry updates don't affect existing vaults
  • KernelExecutionVerifier: Replaced owner-controlled verifyAndParse with permissionless verifyAndParseWithImageId

Key Changes

New Contracts:

  • AgentRegistry.sol - Permissionless agent registration
  • VaultFactory.sol - CREATE2 vault deployment with author-only restriction
  • IAgentRegistry.sol / IVaultFactory.sol - Interfaces

Modified Contracts:

  • KernelVault.sol - Added trustedImageId immutable, updated constructor and execute()
  • KernelExecutionVerifier.sol - Removed owner pattern, simplified to stateless verification

Removed:

  • Owner-controlled flow (allowedImageIds, agentImageIds, registerAgent)
  • verifyAndParse function (replaced by verifyAndParseWithImageId)

Security Model

  • Registry updates do NOT affect existing vaults
  • Each vault pins its imageId at deployment time
  • Only agent author can deploy vaults for their agent
  • Proofs verified against the originally trusted code version

Test plan

  • All 136 Solidity tests pass
  • AgentRegistry tests (21 tests)
  • VaultFactory tests (20 tests)
  • PermissionlessIntegration tests (8 tests)
  • KernelVault tests updated for new constructor
  • KernelExecutionVerifier tests rewritten for new API

…ctory

Transforms the on-chain system from owner-controlled to fully permissionless:

- Add AgentRegistry for permissionless agent registration with deterministic
  IDs (keccak256(author, salt))
- Add VaultFactory for CREATE2 vault deployment with imageId pinning
- Update KernelVault to pin trustedImageId at deployment (immutable)
- Replace verifyAndParse with verifyAndParseWithImageId (caller-provided imageId)
- Remove owner-controlled flow (allowedImageIds, agentImageIds, registerAgent)
- Add author-only restriction for deployVault

Security model: Registry updates do NOT affect existing vaults. Each vault
pins its imageId at deployment time, ensuring proofs are verified against
the originally trusted code version.
Add `agent-pack scaffold` command that generates a complete, ready-to-build
agent project structure. This reduces time-to-first-agent from days of
manual setup to under 1 minute.

Features:
- Generate complete workspace with agent, wrapper, and test crates
- Two templates: minimal (no-op) and yield (yield farming example)
- Auto-compute AGENT_CODE_HASH via generated build.rs
- Pre-populated agent-pack.json manifest
- Optional git initialization
- Customizable agent ID

Usage:
  agent-pack scaffold my-agent
  agent-pack scaffold my-yield-agent --template yield
  agent-pack scaffold my-agent --agent-id 0x42...
@claude

claude Bot commented Feb 1, 2026

Copy link
Copy Markdown

Claude finished @Mehd1b's task —— View job


PR Review - Permissionless Agent Registry & Vault Factory

Todo List

  • Read repository guidelines (CLAUDE.md)
  • Review new AgentRegistry contract
  • Review new VaultFactory contract
  • Review KernelVault modifications
  • Review KernelExecutionVerifier changes
  • Analyze test coverage
  • Security analysis
  • Performance considerations
  • Provide final recommendations

🎯 Overall Assessment

Excellent work! This PR successfully transforms the system from owner-controlled to permissionless with strong architectural design, comprehensive security measures, and robust test coverage.

✅ Strengths

Clean Architecture

  • Separation of concerns: AgentRegistry handles registration, VaultFactory handles deployment
  • Immutable imageId pinning: Each vault locks its trusted imageId at deployment, preventing registry updates from affecting existing vaults
  • Deterministic addressing: Both agent IDs and vault addresses are predictable using CREATE2

Strong Security Model

  • Author-only vault deployment: VaultFactory.deployVault enforces msg.sender == agentInfo.author at VaultFactory.sol:92-94
  • Permissionless verification: KernelExecutionVerifier.verifyAndParseWithImageId accepts caller-provided imageId for trustless operation at KernelExecutionVerifier.sol:78-94
  • Comprehensive input validation: All contracts validate zero values, existence checks, and authorization
  • Nonce gap protection: KernelVault prevents unbounded nonce skipping with MAX_NONCE_GAP = 100 at KernelVault.sol:306-308

Robust Test Coverage

  • 132 test functions across 7 test files covering all new contracts
  • Integration tests: PermissionlessIntegration.t.sol tests full end-to-end flows
  • Edge case coverage: Tests include error conditions, boundary values, and access control

🔧 Code Quality

Best Practices Followed

  • Consistent error handling with custom errors and descriptive messages
  • Comprehensive natspec documentation
  • Gas-efficient CREATE2 deployment pattern
  • Proper event emission for observability

Interface Design

  • Clean, minimal interfaces (IAgentRegistry, IVaultFactory)
  • Backward compatibility maintained in IKernelExecutionVerifier

⚡ Performance Considerations

Efficient Operations

  • Single SLOAD for agent lookup: VaultFactory.deployVault reads registry once at VaultFactory.sol:86
  • CREATE2 optimization: Deterministic addressing reduces deployment gas
  • Minimal storage: Only essential state stored in contracts

Potential Optimizations (Minor)

  • Consider packing AgentInfo struct fields to reduce storage slots
  • VaultFactory._computeSalt could be made external pure for off-chain computation

🛡️ Security Analysis

Access Controls

  • Registry updates properly restricted to agent authors
  • Vault deployment restricted to agent authors
  • No privileged admin functions (fully permissionless)

Validation

  • Zero value checks for critical parameters (imageId, agentCodeHash)
  • Agent existence verification before vault deployment
  • Journal format validation with strict length requirements (209 bytes)

Potential Issues ⚠️

  1. Salt collision risk: Authors could accidentally reuse salts. Consider adding salt validation or documentation
  2. Registry spam: No economic cost for agent registration. Consider adding a small fee or deposit requirement
  3. Metadata trust: metadataURI is user-provided and could point to malicious content

📋 Recommendations

Documentation

  • Add deployment guide for the permissionless flow
  • Document salt generation best practices to prevent collisions
  • Add sequence diagrams for the full registration → deployment → execution flow

Future Enhancements

  • Consider implementing agent reputation or staking mechanisms
  • Add metadata validation standards
  • Consider vault upgrade mechanisms for critical security fixes

✅ Final Verdict

Approve with confidence. This PR delivers a well-architected permissionless system with:

  • Strong security guarantees
  • Comprehensive test coverage
  • Clean, maintainable code
  • Proper gas optimization
  • Excellent documentation

The transformation maintains backward compatibility while enabling trustless operation. The immutable imageId design is particularly clever - it ensures deployed vaults remain secure even if registry entries are later compromised.


@Mehd1b
Mehd1b merged commit 330d35b into main Feb 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant