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 boot_with_node_key(
config: Config,
kernel_config: KernelConfig,
platform: Arc<P>,
node_key_seed: Option<[u8; 32]>,
) -> KernelResult<Self>
pub async fn boot_with_node_key( config: Config, kernel_config: KernelConfig, platform: Arc<P>, node_key_seed: Option<[u8; 32]>, ) -> KernelResult<Self>
Boot the kernel with a persisted node identity.
node_key_seed is the 32-byte Ed25519 seed of this node’s key
(the daemon’s <runtime>/node.key). The mesh, cluster and status
node id is derived from it with
crate::node_id::node_id_from_pubkey, so the id is stable across
restarts. With None (tests, one-shot CLI boots) an ephemeral
key is generated and the id lasts for this process only.
§Errors
Same as Kernel::boot; additionally fails when mesh is enabled
and its listener cannot bind (ADR-103 D2).
Sourcepub async fn boot_in_service_mode(
config: Config,
kernel_config: KernelConfig,
platform: Arc<P>,
service_node_id: String,
) -> KernelResult<Self>
pub async fn boot_in_service_mode( config: Config, kernel_config: KernelConfig, platform: Arc<P>, service_node_id: String, ) -> KernelResult<Self>
Boot as a client of the machine mesh service (ADR-103 P3-U).
The node id is the service’s (hello_ack.node_id); this kernel holds
no node key, binds no mesh listener and starts no mesh runtime. There
is no ephemeral-identity fallback: a malformed id fails the boot.
§Errors
KernelError::Boot when service_node_id is not a node id, plus
everything Kernel::boot can return.
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 agent_registry(&self) -> &AgentRegistry
pub fn agent_registry(&self) -> &AgentRegistry
Get the agent identity registry.
External clients call agent.register to obtain an agent_id
bound to an Ed25519 public key. The registry is then consulted
when verifying signatures on ipc.publish and
ipc.subscribe_stream requests.
Sourcepub fn node_registry(&self) -> &NodeRegistry
pub fn node_registry(&self) -> &NodeRegistry
Get the node identity registry.
Maps node-ids to their ed25519 public keys. The daemon
registers its own node here at boot; remote nodes (ESP32
leaves, future kernel-class peers) register via a future
node.register RPC. Consulted by the substrate publish gate
to verify node signatures and by the Explorer’s tree to
resolve labels.
Sourcepub fn substrate_service(&self) -> &SubstrateService
pub fn substrate_service(&self) -> &SubstrateService
Get the substrate RPC service.
Backs the substrate.read, substrate.publish,
substrate.subscribe, and substrate.notify RPCs.
Sourcepub fn cron_service(&self) -> &Arc<CronService> ⓘ
pub fn cron_service(&self) -> &Arc<CronService> ⓘ
Get the cron service.
Sourcepub fn assessment_service(&self) -> &Arc<AssessmentService> ⓘ
pub fn assessment_service(&self) -> &Arc<AssessmentService> ⓘ
Get the assessment 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 app_manager(&self) -> &Arc<AppManager> ⓘ
pub fn app_manager(&self) -> &Arc<AppManager> ⓘ
Get the application manager (installed apps rehydrated from disk).
Sourcepub fn revocation_list(&self) -> &Arc<RevocationList> ⓘ
pub fn revocation_list(&self) -> &Arc<RevocationList> ⓘ
Get the host revocation list.
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 governance_overlay(&self) -> Option<&Arc<OverlayRuntime>>
pub fn governance_overlay(&self) -> Option<&Arc<OverlayRuntime>>
The project governance runtime (profile project only).
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 chain_anchor(&self) -> Option<&Arc<AnchoringController>>
pub fn chain_anchor(&self) -> Option<&Arc<AnchoringController>>
Get the external chain-head anchoring controller (WEFT-137), when 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_vector_backend(&self) -> Option<&Arc<dyn VectorBackend>>
pub fn ecc_vector_backend(&self) -> Option<&Arc<dyn VectorBackend>>
Get the ECC vector backend (if ecc feature enabled).
Returns the configured vector search backend (HNSW, DiskANN,
or Hybrid) based on the [kernel.vector] configuration.
Sourcepub fn ecc_spatial(&self) -> Option<&Arc<SpatialService>>
pub fn ecc_spatial(&self) -> Option<&Arc<SpatialService>>
Get the ECC spatial BVH service (if enabled via [kernel.spatial]).
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 ecc_eml_coherence(&self) -> Option<&Arc<Mutex<EmlCoherenceModel>>>
pub fn ecc_eml_coherence(&self) -> Option<&Arc<Mutex<EmlCoherenceModel>>>
Get the EML coherence model (if ecc feature enabled).
Sourcepub fn metrics_registry(&self) -> Option<&Arc<MetricsRegistry>>
pub fn metrics_registry(&self) -> Option<&Arc<MetricsRegistry>>
Get the os-patterns metrics registry (if os-patterns feature enabled).
Sourcepub fn log_service(&self) -> Option<&Arc<LogService>>
pub fn log_service(&self) -> Option<&Arc<LogService>>
Get the os-patterns log service (if os-patterns feature enabled).
Sourcepub fn timer_service(&self) -> Option<&Arc<TimerService>>
pub fn timer_service(&self) -> Option<&Arc<TimerService>>
Get the os-patterns timer service (if os-patterns feature enabled).
Sourcepub fn dead_letter_queue(&self) -> Option<&Arc<DeadLetterQueue>>
pub fn dead_letter_queue(&self) -> Option<&Arc<DeadLetterQueue>>
Get the os-patterns dead letter queue (if os-patterns 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> !RefUnwindSafe for Kernel<P>
impl<P> !UnwindSafe for Kernel<P>
impl<P> Freeze for Kernel<P>
impl<P> Send for Kernel<P>
impl<P> Sync for Kernel<P>
impl<P> Unpin for Kernel<P>
impl<P> UnsafeUnpin 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