Skip to main content

ruvix_types/
lib.rs

1//! # RuVix Kernel Interface Types
2//!
3//! This crate provides all kernel interface types for the RuVix Cognition Kernel
4//! as specified in ADR-087. It is designed to be `no_std` compatible with zero
5//! external dependencies, ensuring it can be used in both kernel code and RVF
6//! component code.
7//!
8//! ## Core Primitives
9//!
10//! RuVix has exactly six kernel primitives:
11//!
12//! | Primitive | Purpose | Analog |
13//! |-----------|---------|--------|
14//! | **Task** | Unit of concurrent execution with capability set | seL4 TCB |
15//! | **Capability** | Unforgeable typed token granting access to a resource | seL4 capability |
16//! | **Region** | Contiguous memory with access policy | seL4 Untyped + frame |
17//! | **Queue** | Typed ring buffer for inter-task communication | io_uring SQ/CQ |
18//! | **Timer** | Deadline-driven scheduling primitive | POSIX timer_create |
19//! | **Proof** | Cryptographic attestation gating state mutation | Novel (ADR-047) |
20//!
21//! ## Features
22//!
23//! - `std`: Enable standard library support
24//! - `alloc`: Enable alloc crate support for heap allocation
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 capability;
39mod error;
40mod graph;
41mod handle;
42mod object;
43mod proof;
44mod proof_cache;
45mod proof_cache_optimized;
46mod queue;
47mod region;
48mod rvf;
49mod scheduler;
50mod sensor;
51mod task;
52mod timer;
53mod vector;
54
55pub use capability::{CapHandle, CapRights, Capability};
56pub use error::KernelError;
57pub use graph::{GraphHandle, GraphMutation, GraphMutationKind};
58pub use handle::Handle;
59pub use object::ObjectType;
60pub use proof::{ProofAttestation, ProofPayload, ProofTier, ProofToken};
61pub use proof_cache::{CacheError, ProofCache, ProofCacheEntry, ProofCacheStats};
62pub use proof_cache_optimized::{OptimizedProofCache, OptimizedProofEntry};
63pub use queue::{MsgPriority, QueueConfig, QueueHandle};
64pub use region::{RegionHandle, RegionPolicy};
65pub use rvf::{RvfComponentId, RvfMountHandle, RvfVerifyStatus, WitTypeId};
66pub use scheduler::{SchedulerPartition, SchedulerScore};
67pub use sensor::{SensorDescriptor, SensorType, SubscriptionHandle};
68pub use task::{TaskHandle, TaskPriority};
69pub use timer::TimerSpec;
70pub use vector::{CoherenceMeta, VectorKey, VectorStoreConfig, VectorStoreHandle};
71
72/// Re-export proof cache module for direct access.
73pub mod proof_cache_mod {
74    pub use crate::proof_cache::*;
75}
76
77/// The witness size in bytes for proof attestations (ADR-047 compatible).
78pub const ATTESTATION_SIZE: usize = 82;
79
80/// Maximum capability delegation depth (Section 20.2).
81pub const MAX_DELEGATION_DEPTH: u8 = 8;
82
83/// Default Reflex proof cache TTL in milliseconds (Section 20.4).
84/// See `proof_cache::PROOF_CACHE_TTL_MS` for the canonical value.
85pub const REFLEX_CACHE_TTL_MS: u32 = proof_cache::PROOF_CACHE_TTL_MS;
86
87/// Default Reflex proof cache size (Section 20.4).
88/// See `proof_cache::PROOF_CACHE_MAX_ENTRIES` for the canonical value.
89pub const REFLEX_CACHE_SIZE: usize = proof_cache::PROOF_CACHE_MAX_ENTRIES;