Skip to main content

Kernel

Struct Kernel 

Source
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

  1. Call Kernel::boot to initialize all subsystems.
  2. The kernel transitions from Booting -> Running.
  3. Call Kernel::shutdown to gracefully stop everything.
  4. The kernel transitions from Running -> ShuttingDown -> Halted.

Implementations§

Source§

impl<P: Platform> Kernel<P>

Source

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:

  1. Creates subsystems (process table, service registry, IPC, health)
  2. Creates AppContext (reuses existing bootstrap)
  3. Registers the kernel process (PID 0)
  4. Starts all registered services
  5. Transitions to Running state
§Errors

Returns KernelError::Boot if any critical subsystem fails to initialize.

Source

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).

Source

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.

Source

pub async fn shutdown(&mut self) -> KernelResult<()>

Shut down the kernel gracefully.

Stops all services, cancels all processes, and transitions to the Halted state.

Source

pub fn state(&self) -> &KernelState

Get the current kernel state.

Source

pub fn kernel_config(&self) -> &KernelConfig

Get the kernel configuration.

Source

pub fn process_table(&self) -> &Arc<ProcessTable> ⓘ

Get the process table.

Source

pub fn services(&self) -> &Arc<ServiceRegistry> ⓘ

Get the service registry.

Source

pub fn ipc(&self) -> &Arc<KernelIpc> ⓘ

Get the IPC subsystem.

Source

pub fn bus(&self) -> &Arc<MessageBus> ⓘ

Get the message bus.

Source

pub fn a2a_router(&self) -> &Arc<A2ARouter> ⓘ

Get the A2A router.

Source

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.

Source

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.

Source

pub fn substrate_service(&self) -> &SubstrateService

Get the substrate RPC service.

Backs the substrate.read, substrate.publish, substrate.subscribe, and substrate.notify RPCs.

Source

pub fn cron_service(&self) -> &Arc<CronService> ⓘ

Get the cron service.

Source

pub fn assessment_service(&self) -> &Arc<AssessmentService> ⓘ

Get the assessment service.

Source

pub fn health(&self) -> &HealthSystem

Get the health system.

Source

pub fn supervisor(&self) -> &AgentSupervisor<P>

Get the agent supervisor.

Source

pub fn boot_log(&self) -> &BootLog

Get the boot log.

Source

pub fn event_log(&self) -> &Arc<KernelEventLog> ⓘ

Get the runtime event log (ring buffer).

Source

pub fn uptime(&self) -> Duration

Get kernel uptime.

Source

pub fn cluster_membership(&self) -> &Arc<ClusterMembership> ⓘ

Get the cluster membership tracker.

Source

pub fn app_manager(&self) -> &Arc<AppManager> ⓘ

Get the application manager (installed apps rehydrated from disk).

Source

pub fn revocation_list(&self) -> &Arc<RevocationList> ⓘ

Get the host revocation list.

Source

pub fn chain_manager(&self) -> Option<&Arc<ChainManager>>

Get the local chain manager (when exochain feature is enabled).

Source

pub fn governance_overlay(&self) -> Option<&Arc<OverlayRuntime>>

The project governance runtime (profile project only).

Source

pub fn tree_manager(&self) -> Option<&Arc<TreeManager>>

Get the tree manager (when exochain feature is enabled).

Source

pub fn governance_gate(&self) -> Option<&Arc<dyn GateBackend>>

Get the governance gate backend (if configured).

Source

pub fn chain_anchor(&self) -> Option<&Arc<AnchoringController>>

Get the external chain-head anchoring controller (WEFT-137), when configured.

Source

pub fn ecc_hnsw(&self) -> Option<&Arc<HnswService>>

Get the ECC HNSW service (if ecc feature enabled).

Source

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.

Source

pub fn ecc_spatial(&self) -> Option<&Arc<SpatialService>>

Get the ECC spatial BVH service (if enabled via [kernel.spatial]).

Source

pub fn ecc_causal(&self) -> Option<&Arc<CausalGraph>>

Get the ECC causal graph (if ecc feature enabled).

Source

pub fn ecc_tick(&self) -> Option<&Arc<CognitiveTick>>

Get the ECC cognitive tick (if ecc feature enabled).

Source

pub fn ecc_calibration(&self) -> Option<&EccCalibration>

Get the ECC calibration results (if ecc feature enabled).

Source

pub fn ecc_crossrefs(&self) -> Option<&Arc<CrossRefStore>>

Get the ECC cross-reference store (if ecc feature enabled).

Source

pub fn ecc_impulses(&self) -> Option<&Arc<ImpulseQueue>>

Get the ECC impulse queue (if ecc feature enabled).

Source

pub fn ecc_eml_coherence(&self) -> Option<&Arc<Mutex<EmlCoherenceModel>>>

Get the EML coherence model (if ecc feature enabled).

Source

pub fn metrics_registry(&self) -> Option<&Arc<MetricsRegistry>>

Get the os-patterns metrics registry (if os-patterns feature enabled).

Source

pub fn log_service(&self) -> Option<&Arc<LogService>>

Get the os-patterns log service (if os-patterns feature enabled).

Source

pub fn timer_service(&self) -> Option<&Arc<TimerService>>

Get the os-patterns timer service (if os-patterns feature enabled).

Source

pub fn dead_letter_queue(&self) -> Option<&Arc<DeadLetterQueue>>

Get the os-patterns dead letter queue (if os-patterns feature enabled).

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more