Overview
OneClaw is a 6-layer trait-driven AI agent kernel built in Rust. Each layer is defined as a trait with both default and noop implementations, making the system modular, testable, and domain-agnostic.The 6-Layer Architecture
Layer Interactions
Message Flow
When a message arrives through a channel:- L5 (Channel) receives the message from external source
- L0 (Security) authorizes the action based on device pairing and action type
- L1 (Orchestrator) analyzes complexity and routes to appropriate LLM
- L2 (Memory) provides context via hybrid search (FTS5 + vector)
- L3 (Event Bus) processes any events generated during execution
- L4 (Tool) executes any tools requested by the LLM
- Response flows back through L5 (Channel) to the user
Runtime Integration
TheRuntime struct (defined in runtime.rs) orchestrates all layers:
runtime.rs:29 for the complete definition.
Design Principles
1. Trait-Driven Architecture
Every layer is defined as a trait, allowing:- Modularity: Swap implementations without changing other layers
- Testability: Use noop implementations for unit testing
- Extensibility: Custom implementations for domain-specific needs
security/traits.rs:75:
2. Deny-by-Default Security
Security is not an afterthought—it’s Layer 0. All actions require explicit authorization:- Unpaired devices are blocked
- Filesystem access is scoped to workspace
- Per-command authorization checks
- Rate limiting prevents DoS attacks
runtime.rs:263 for authorization implementation.
3. Graceful Degradation
The system continues operating even when components fail:- No LLM provider? Falls back to offline mode with memory search
- No vector embeddings? Uses FTS5 keyword search
- Event bus full? Continues processing with degraded event handling
runtime.rs:233:
4. Domain-Agnostic Core
The core kernel knows nothing about specific domains (elderly care, smart home, etc.). Domain logic lives in separate crates that compose the core traits. Core crate structure (fromONECLAW-BLUEPRINT.md:149):
5. Edge-Viable Performance
Binary Size
~3.4MB (target: under 5MB)
Boot Time
0.79µs (target: sub-10ms)
Memory Footprint
Under 5MB RAM typical
README.md:7:
| Metric | Target | Actual |
|---|---|---|
| Boot time | <10ms | 0.79µs |
| Binary size | <5MB | ~3.4MB |
| Message throughput | >1K/sec | 3.8M/sec |
| Event processing | >5K/sec | 443K/sec |
6. LLM Orchestration (Competitive Moat)
Unlike other edge AI frameworks, OneClaw treats LLMs as a team of specialists requiring coordination:- Smart Routing: Complexity analysis routes to appropriate model (from
orchestrator/router.rs:120) - Chain Execution: Multi-step reasoning with context passing
- Context Management: Memory retrieval and prompt enrichment
- Fallback Chains: Automatic provider failover
Configuration-Driven Assembly
Rather than hardcoding layer implementations, OneClaw uses a Registry pattern to resolve traits from configuration. Fromruntime.rs:112:
config/default.toml
Next Steps
Layer Details
Deep dive into each of the 6 layers
Trait Philosophy
Understanding trait-driven design
Security Model
Deny-by-default security architecture
Quick Start
Build and run OneClaw