ruvix-cap
seL4-inspired capability management for the RuVix Cognition Kernel (ADR-087).
Overview
This crate provides the capability manager that enforces all access control in RuVix. Every kernel object is accessed exclusively through capabilities, following the principle: "No syscall succeeds without an appropriate capability handle."
Core Concepts
| Concept | Description |
|---|---|
| Capability | Unforgeable kernel-managed token: object ID, type, rights, badge, epoch |
| Derivation Tree | Capabilities can be derived with equal or fewer rights |
| Delegation Depth | Maximum depth of 8 to prevent unbounded chains |
| Epoch-based Invalidation | Detects stale handles automatically |
Design Principles (ADR-087 Section 6)
- A task can only grant capabilities it holds
- Granted rights must be equal or fewer than held rights
- Revocation propagates through the derivation tree
GRANT_ONCEprovides non-transitive delegation- Epoch-based invalidation detects stale handles
Components
CapabilityManager
Central capability management:
use ;
use ;
let config = default;
let mut manager: = new;
// Create a root capability for a new vector store
let task = new;
let cap_handle = manager.create_root_capability?;
Capability Granting
Delegate capabilities with restricted rights:
// Grant a read-only derived capability
let derived = manager.grant?;
Capability Revocation
Revoke capabilities and all derivatives:
// Revoke cascades through derivation tree
manager.revoke?;
DerivationTree
Track capability relationships:
use DerivationTree;
let tree = manager.derivation_tree;
let children = tree.children_of;
let depth = tree.depth;
Rights Bitmap
use CapRights;
// Available rights
let read = READ; // Read access
let write = WRITE; // Write access
let grant = GRANT; // Can grant to others
let revoke = REVOKE; // Can revoke grants
let prove = PROVE; // Can create proofs
let grant_once = GRANT_ONCE; // Single-use grant
// Combine rights
let read_write = READ | WRITE;
Security Features
Boot Signature Verification (SEC-001)
use ;
// PANICS on failure - no fallback boot path
verify_boot_signature_or_panic;
Audit System
use ;
let config = AuditConfig ;
let auditor = new;
// Audit operations are automatically logged
let result = auditor.audit_grant?;
Constants
use ;
assert_eq!; // Section 20.2
assert_eq!; // Per-task capacity
assert_eq!; // Audit warning level
Features
std(default): Enable standard library supportalloc: Enable alloc crate supportaudit-log: Enable audit logging for all capability operations
Integration with RuVix
This crate integrates with:
ruvix-types: Core type definitions (CapHandle,CapRights,Capability)ruvix-boot: Boot capability distribution and root task setupruvix-proof: PROVE rights checking for proof generation
License
MIT OR Apache-2.0