pub struct Kernel<P: Platform> { /* private fields */ }Expand description
The WeftOS kernel.
Wraps AppContext<P> in a managed boot sequence with process
tracking, service lifecycle, IPC, and health monitoring.
§Lifecycle
- Call
Kernel::bootto initialize all subsystems. - The kernel transitions from
Booting->Running. - Call
Kernel::shutdownto gracefully stop everything. - The kernel transitions from
Running->ShuttingDown->Halted.
Implementations§
Source§impl<P: Platform> Kernel<P>
impl<P: Platform> Kernel<P>
Sourcepub async fn boot(
config: Config,
kernel_config: KernelConfig,
platform: Arc<P>,
) -> KernelResult<Self>
pub async fn boot( config: Config, kernel_config: KernelConfig, platform: Arc<P>, ) -> KernelResult<Self>
Boot the kernel from configuration and platform.
This is the primary entry point. It:
- Creates subsystems (process table, service registry, IPC, health)
- Creates AppContext (reuses existing bootstrap)
- Registers the kernel process (PID 0)
- Starts all registered services
- Transitions to Running state
§Errors
Returns KernelError::Boot if any critical subsystem fails
to initialize.
Sourcepub async fn shutdown(&mut self) -> KernelResult<()>
pub async fn shutdown(&mut self) -> KernelResult<()>
Shut down the kernel gracefully.
Stops all services, cancels all processes, and transitions
to the Halted state.
Sourcepub fn state(&self) -> &KernelState
pub fn state(&self) -> &KernelState
Get the current kernel state.
Sourcepub fn kernel_config(&self) -> &KernelConfig
pub fn kernel_config(&self) -> &KernelConfig
Get the kernel configuration.
Sourcepub fn process_table(&self) -> &Arc<ProcessTable>
pub fn process_table(&self) -> &Arc<ProcessTable>
Get the process table.
Sourcepub fn services(&self) -> &Arc<ServiceRegistry>
pub fn services(&self) -> &Arc<ServiceRegistry>
Get the service registry.
Sourcepub fn bus(&self) -> &Arc<MessageBus>
pub fn bus(&self) -> &Arc<MessageBus>
Get the message bus.
Sourcepub fn a2a_router(&self) -> &Arc<A2ARouter>
pub fn a2a_router(&self) -> &Arc<A2ARouter>
Get the A2A router.
Sourcepub fn cron_service(&self) -> &Arc<CronService>
pub fn cron_service(&self) -> &Arc<CronService>
Get the cron service.
Sourcepub fn health(&self) -> &HealthSystem
pub fn health(&self) -> &HealthSystem
Get the health system.
Sourcepub fn supervisor(&self) -> &AgentSupervisor<P>
pub fn supervisor(&self) -> &AgentSupervisor<P>
Get the agent supervisor.
Sourcepub fn event_log(&self) -> &Arc<KernelEventLog>
pub fn event_log(&self) -> &Arc<KernelEventLog>
Get the runtime event log (ring buffer).
Sourcepub fn cluster_membership(&self) -> &Arc<ClusterMembership>
pub fn cluster_membership(&self) -> &Arc<ClusterMembership>
Get the cluster membership tracker.
Sourcepub fn chain_manager(&self) -> Option<&Arc<ChainManager>>
pub fn chain_manager(&self) -> Option<&Arc<ChainManager>>
Get the local chain manager (when exochain feature is enabled).
Sourcepub fn tree_manager(&self) -> Option<&Arc<TreeManager>>
pub fn tree_manager(&self) -> Option<&Arc<TreeManager>>
Get the tree manager (when exochain feature is enabled).
Sourcepub fn governance_gate(&self) -> Option<&Arc<dyn GateBackend>>
pub fn governance_gate(&self) -> Option<&Arc<dyn GateBackend>>
Get the governance gate backend (if configured).
Sourcepub fn ecc_hnsw(&self) -> Option<&Arc<HnswService>>
pub fn ecc_hnsw(&self) -> Option<&Arc<HnswService>>
Get the ECC HNSW service (if ecc feature enabled).
Sourcepub fn ecc_causal(&self) -> Option<&Arc<CausalGraph>>
pub fn ecc_causal(&self) -> Option<&Arc<CausalGraph>>
Get the ECC causal graph (if ecc feature enabled).
Sourcepub fn ecc_tick(&self) -> Option<&Arc<CognitiveTick>>
pub fn ecc_tick(&self) -> Option<&Arc<CognitiveTick>>
Get the ECC cognitive tick (if ecc feature enabled).
Sourcepub fn ecc_calibration(&self) -> Option<&EccCalibration>
pub fn ecc_calibration(&self) -> Option<&EccCalibration>
Get the ECC calibration results (if ecc feature enabled).
Sourcepub fn ecc_crossrefs(&self) -> Option<&Arc<CrossRefStore>>
pub fn ecc_crossrefs(&self) -> Option<&Arc<CrossRefStore>>
Get the ECC cross-reference store (if ecc feature enabled).
Sourcepub fn ecc_impulses(&self) -> Option<&Arc<ImpulseQueue>>
pub fn ecc_impulses(&self) -> Option<&Arc<ImpulseQueue>>
Get the ECC impulse queue (if ecc feature enabled).
Sourcepub fn take_app_context(&mut self) -> Option<AppContext<P>>
pub fn take_app_context(&mut self) -> Option<AppContext<P>>
Take ownership of the AppContext for agent loop consumption.
This is a one-shot operation: after calling this, the kernel
no longer holds the AppContext. Use this before calling
AppContext::into_agent_loop().
Auto Trait Implementations§
impl<P> Freeze for Kernel<P>
impl<P> !RefUnwindSafe for Kernel<P>
impl<P> Send for Kernel<P>
impl<P> Sync for Kernel<P>
impl<P> Unpin for Kernel<P>where
P: Unpin,
impl<P> UnsafeUnpin for Kernel<P>
impl<P> !UnwindSafe for Kernel<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more