Skip to main content

rvm_cap/
lib.rs

1//! Capability system for the RVM coherence-native microhypervisor.
2//!
3//! Implements the three-layer proof system specified in ADR-135:
4//!
5//! | Layer | Name | Budget | v1 Status |
6//! |-------|------|--------|-----------|
7//! | **P1** | Capability Check | < 1 us | Ship |
8//! | **P2** | Policy Validation | < 100 us | Ship |
9//! | **P3** | Deep Proof | < 10 ms | Deferred |
10//!
11//! # Core Concepts
12//!
13//! - **Capability**: Unforgeable kernel-managed token with rights bitmap.
14//! - **Derivation Tree**: Parent-child relationships with monotonic attenuation.
15//! - **Delegation Depth**: Max 8 levels to prevent unbounded chains.
16//! - **Epoch-based revocation**: Stale handles detected via epoch counter.
17//!
18//! # Design Principles (ADR-135)
19//!
20//! 1. A partition can only grant capabilities it holds
21//! 2. Granted rights must be equal or fewer than held rights
22//! 3. Revocation propagates through the derivation tree
23//! 4. `GRANT_ONCE` provides non-transitive delegation
24//! 5. Epoch-based invalidation detects stale handles
25
26#![no_std]
27#![forbid(unsafe_code)]
28#![deny(missing_docs)]
29#![deny(clippy::all)]
30#![warn(clippy::pedantic)]
31
32#[cfg(feature = "alloc")]
33extern crate alloc;
34
35#[cfg(feature = "std")]
36extern crate std;
37
38mod derivation;
39mod error;
40mod grant;
41mod manager;
42mod revoke;
43mod table;
44mod verify;
45
46pub use derivation::{DerivationNode, DerivationTree};
47pub use error::{CapError, CapResult, ProofError};
48pub use grant::GrantPolicy;
49pub use manager::{CapManagerConfig, CapabilityManager, ManagerStats};
50pub use revoke::{revoke_single, RevokeResult};
51pub use table::{CapSlot, CapabilityTable};
52pub use verify::ProofVerifier;
53
54// Re-export commonly used types from rvm-types.
55pub use rvm_types::{CapRights, CapToken, CapType};
56
57/// Default maximum delegation depth (ADR-135 Section: Capability Derivation Tree).
58pub const DEFAULT_MAX_DELEGATION_DEPTH: u8 = 8;
59
60/// Default capability table capacity per partition.
61pub const DEFAULT_CAP_TABLE_CAPACITY: usize = 256;