Skip to main content

lion_core/
lib.rs

1// Copyright (C) 2026 HaiyangLi
2// SPDX-License-Identifier: AGPL-3.0-or-later
3//! Lion Core -- production microkernel types, state machine, and kernel API.
4//!
5//! This crate provides the canonical Rust implementation of the Lion microkernel.
6//!
7//! # Features
8//!
9//! - `serde` -- Enable serde Serialize/Deserialize on all types
10
11#![deny(unsafe_code)]
12#![warn(missing_docs)]
13#![allow(clippy::all)]
14
15pub(crate) mod crypto;
16pub mod error;
17pub mod kernel;
18pub mod state;
19pub mod step;
20pub mod types;
21
22// Extraction anchor module — only compiled when extracting to Lean via styx-rustc.
23// This module defines what types get translated via reachability from the anchor function.
24#[cfg(extract)]
25pub mod extract_anchor;
26
27// Re-export unified Error and Kernel at crate root
28pub use error::Error;
29pub use kernel::Kernel;
30
31// Re-export commonly used types at crate root
32pub use types::{
33    // Policy
34    Action,
35    // Identifiers
36    ActorId,
37    // Capability/Crypto
38    Blake3Hash,
39    CapId,
40    CapPayload,
41    Capability,
42    CapabilityError,
43    DomainId,
44    Hash32,
45    Key,
46    LogEvent,
47    MemAddr,
48    // Runtime
49    MemRegion,
50    MsgId,
51    MsgState,
52    // Parse errors
53    ParseMemRegionError,
54    ParseMsgStateError,
55    ParsePolicyDecisionError,
56    ParseRightError,
57    ParseSecurityLevelError,
58    PluginId,
59    PolicyContext,
60    PolicyDecision,
61    PolicyDecisionFn,
62    PolicyError,
63    PolicyState,
64    ResourceId,
65    // Rights
66    Right,
67    Rights,
68    RightsError,
69    RuntimeTag,
70    SealedTag,
71    // Security
72    SecurityLevel,
73    Size,
74    SymbolicTag,
75    // Thread / Scheduler
76    ThreadId,
77    Time,
78    WorkflowId,
79};
80
81// Re-export step module types
82pub use step::{
83    AuthorizationError,
84    // Authorization
85    Authorized,
86    // Host calls
87    HostCall,
88    HostCallPrecondition,
89    HostFunction,
90    HostResult,
91    // Step enum and error
92    InvalidTransitionReason,
93    // Kernel operations
94    KernelOp,
95    KernelOpError,
96    // Plugin internal
97    PluginInternal,
98    PluginPrecondition,
99    Step,
100    StepError,
101};