pub struct Kernel {Show 16 fields
pub session_id: SessionId,
pub event_bus: Arc<EventBus>,
pub capsules: Arc<RwLock<CapsuleRegistry>>,
pub mcp: SecureMcpClient,
pub capabilities: Arc<CapabilityStore>,
pub vfs: Arc<dyn Vfs>,
pub overlay_vfs: Arc<OverlayVfs>,
pub vfs_root_handle: DirHandle,
pub workspace_root: PathBuf,
pub global_root: Option<PathBuf>,
pub cli_socket_listener: Option<Arc<Mutex<UnixListener>>>,
pub kv: Arc<SurrealKvStore>,
pub audit_log: Arc<AuditLog>,
pub active_connections: AtomicUsize,
pub session_token: Arc<SessionToken>,
pub allowance_store: Arc<AllowanceStore>,
/* private fields */
}Expand description
The core Operating System Kernel.
Fields§
§session_id: SessionIdThe unique identifier for this kernel session.
event_bus: Arc<EventBus>The global IPC message bus.
capsules: Arc<RwLock<CapsuleRegistry>>The process manager (loaded WASM capsules).
mcp: SecureMcpClientThe secure MCP client with capability-based authorization and audit logging.
capabilities: Arc<CapabilityStore>The capability store for this session.
vfs: Arc<dyn Vfs>The global Virtual File System mount.
overlay_vfs: Arc<OverlayVfs>Concrete reference to the OverlayVfs for commit/rollback operations.
vfs_root_handle: DirHandleThe global physical root handle (cap-std) for the VFS.
workspace_root: PathBufThe physical path the VFS is mounted to.
global_root: Option<PathBuf>The global shared resources directory (~/.astrid/shared/). Capsules
declaring fs_read = ["global://"] can read files under this root.
Scoped to shared/ so that keys, databases, and capsule .env files in
~/.astrid/ are NOT accessible. Write access is intentionally not
granted to any shipped capsule.
Always Some in production (boot requires AstridHome). Remains
Option for compatibility with CapsuleContext and test fixtures.
cli_socket_listener: Option<Arc<Mutex<UnixListener>>>The natively bound Unix Socket for the CLI proxy.
kv: Arc<SurrealKvStore>Shared KV store backing all capsule-scoped stores and kernel state.
audit_log: Arc<AuditLog>Chain-linked cryptographic audit log with persistent storage.
active_connections: AtomicUsizeNumber of active client connections (CLI sessions).
session_token: Arc<SessionToken>Session token for socket authentication. Generated at boot, written to
~/.astrid/sessions/system.token. CLI sends this as its first message.
allowance_store: Arc<AllowanceStore>Shared allowance store for capsule-level approval decisions.
Capsules can check existing allowances and create new ones when users approve actions with session/always scope.
Implementations§
Source§impl Kernel
impl Kernel
Sourcepub async fn new(
session_id: SessionId,
workspace_root: PathBuf,
) -> Result<Arc<Self>, Error>
pub async fn new( session_id: SessionId, workspace_root: PathBuf, ) -> Result<Arc<Self>, Error>
Sourcepub async fn load_all_capsules(&self)
pub async fn load_all_capsules(&self)
Auto-discover and load all capsules from the standard directories (~/.astrid/capsules and .astrid/capsules).
Capsules are loaded in dependency order (topological sort) with uplink/daemon capsules loaded first. Each uplink must signal readiness before non-uplink capsules are loaded.
After all capsules are loaded, tool schemas are injected into every
capsule’s KV namespace and the astrid.v1.capsules_loaded event is published.
Sourcepub fn connection_opened(&self)
pub fn connection_opened(&self)
Record that a new client connection has been established.
Sourcepub fn connection_closed(&self)
pub fn connection_closed(&self)
Record that a client connection has been closed.
Uses fetch_update for atomic saturating decrement - avoids the TOCTOU
window where fetch_sub wraps to usize::MAX before a corrective store.
When the last connection closes (counter reaches 0), clears all session-scoped allowances so they don’t leak into the next CLI session.
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Number of active client connections.
Auto Trait Implementations§
impl !Freeze for Kernel
impl !RefUnwindSafe for Kernel
impl Send for Kernel
impl Sync for Kernel
impl Unpin for Kernel
impl UnsafeUnpin for Kernel
impl !UnwindSafe for Kernel
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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