Skip to main content

rustkernel_core/
lib.rs

1//! # RustKernel Core
2//!
3//! Core abstractions, traits, and registry for the RustKernels GPU kernel library.
4//!
5//! This crate provides:
6//! - Domain and kernel type definitions
7//! - Kernel metadata and configuration
8//! - Trait definitions for batch and ring kernels
9//! - Kernel registry with auto-discovery
10//! - Licensing and feature gating system
11//! - Actix actor integration for GPU-backed actors
12//! - Runtime lifecycle management
13//! - Enterprise security, observability, and resilience patterns
14//! - Deep integration with ringkernel-core 0.4.2 (domain conversion, K2K, enterprise re-exports)
15
16#![warn(missing_docs)]
17#![warn(clippy::all)]
18
19// Core modules
20pub mod domain;
21pub mod error;
22pub mod k2k;
23pub mod kernel;
24pub mod license;
25pub mod messages;
26pub mod registry;
27pub mod slo;
28pub mod test_kernels;
29pub mod traits;
30
31// Enterprise modules (with ringkernel-core 0.4.2 bridging)
32pub mod config;
33pub mod memory;
34pub mod observability;
35pub mod resilience;
36pub mod runtime;
37pub mod security;
38
39// Re-exports from ringkernel-core for convenience
40pub use ringkernel_core::{
41    HlcTimestamp, MessageHeader, MessageId, MessageQueue, RingContext, RingKernelError, RingMessage,
42};
43
44// Re-export types from specific modules
45pub use ringkernel_core::hlc::HlcClock;
46pub use ringkernel_core::k2k::{K2KBroker, K2KEndpoint, K2KMessage};
47pub use ringkernel_core::message::MessageEnvelope;
48pub use ringkernel_core::runtime::{
49    KernelHandle, KernelId, KernelState, LaunchOptions, RingKernelRuntime,
50};
51
52// New re-exports from ringkernel-core 0.4.2
53pub use ringkernel_core::control::ControlBlock;
54pub use ringkernel_core::k2k::{DeliveryStatus, K2KConfig};
55pub use ringkernel_core::message::{CorrelationId as RingCorrelationId, Priority};
56pub use ringkernel_core::runtime::{Backend, KernelStatus, RuntimeMetrics};
57
58// Re-export ringkernel-core submodules for advanced consumers
59pub use ringkernel_core::checkpoint;
60pub use ringkernel_core::dispatcher;
61pub use ringkernel_core::health;
62pub use ringkernel_core::pubsub;
63
64/// Direct access to the full RingKernel 0.4.2 API.
65///
66/// For advanced usage, you can access the complete ringkernel-core API through this module.
67pub mod ring {
68    pub use ringkernel_core::*;
69}
70
71/// Prelude module for convenient imports
72pub mod prelude {
73    pub use crate::domain::Domain;
74    pub use crate::error::{KernelError, Result};
75    pub use crate::k2k::{
76        FanOutTracker, IterativeConvergenceSummary, IterativeState, K2KControlMessage, K2KPriority,
77        K2KWorkerResult, PipelineTracker, ScatterGatherState, kernel_id_to_u64,
78    };
79    pub use crate::kernel::{KernelMetadata, KernelMode};
80    pub use crate::license::{DevelopmentLicense, License, LicenseError, LicenseValidator};
81    pub use crate::messages::{
82        BatchMessage, CorrelationId, KernelRequest, KernelResponse, KernelResult,
83    };
84    pub use crate::registry::{KernelRegistry, RegistryStats};
85    pub use crate::slo::{SLOResult, SLOValidator};
86    pub use crate::test_kernels::{EchoKernel, MatMul, ReduceSum, VectorAdd};
87    pub use crate::traits::{
88        BatchKernel, BatchKernelDyn, CheckpointableKernel, DegradableKernel, ExecutionContext,
89        GpuKernel, HealthStatus, IterativeKernel, KernelConfig, RingKernelDyn, RingKernelHandler,
90        SecureRingContext, TypeErasedBatchKernel, TypeErasedRingKernel,
91    };
92
93    // Runtime lifecycle
94    pub use crate::runtime::{
95        KernelRuntime, LifecycleState, RuntimeBuilder, RuntimeConfig, RuntimeHandle, RuntimePreset,
96        RuntimeStats,
97    };
98
99    // Resilience patterns
100    pub use crate::resilience::{
101        CircuitBreaker, CircuitBreakerConfig, CircuitState, DeadlineContext, HealthCheck,
102        HealthCheckResult, HealthProbe, RecoveryPolicy, ResilienceConfig, RetryConfig,
103        TimeoutConfig,
104    };
105
106    // Security
107    pub use crate::security::{
108        AuthConfig, KernelPermission, Permission, PermissionSet, Role, SecurityConfig,
109        SecurityContext, TenantId,
110    };
111
112    // Memory management
113    pub use crate::memory::{
114        AnalyticsContext, AnalyticsContextManager, InterPhaseReduction, KernelMemoryManager,
115        MemoryConfig, MemoryError, MemoryStats, PressureLevel, ReductionConfig, SyncMode,
116    };
117
118    // Production configuration
119    pub use crate::config::{ProductionConfig, ProductionConfigBuilder};
120
121    // Re-exports from ringkernel-core
122    pub use ringkernel_core::k2k::{K2KBroker, K2KEndpoint};
123    pub use ringkernel_core::runtime::{KernelHandle, KernelId, KernelState, LaunchOptions};
124    pub use ringkernel_core::{HlcTimestamp, MessageId, RingContext, RingMessage};
125
126    // New re-exports from ringkernel-core 0.4.2
127    pub use ringkernel_core::control::ControlBlock;
128    pub use ringkernel_core::k2k::K2KConfig;
129    pub use ringkernel_core::message::Priority;
130    pub use ringkernel_core::runtime::{Backend, KernelStatus, RuntimeMetrics};
131}