Skip to main content

Module bus

Module bus 

Source
Expand description

The event bus (spec 3.2 §7.6).

Every state change in the kernel is a KernelEvent: process transitions from the worker’s S1 hooks (never polled), wakes, holds and decisions, rule hits, spend, governance and health. EventBus numbers each one with a cursor and delivers it to subscribers and EventSinks. The bus is bounded per sink; a slow sink drops Health first and never blocks a process. A reconnecting surface catches up by cursor (EventBus::subscribe_after) rather than by holding a subscription open.

The receivers are the control plane’s SSE stream (GET /kernel/events, a subscriber), the signed audit log (AuditSink) for the events that are audit records (§9.3), and outbound webhooks (WebhookSink, feature webhooks): each event an EventFilter selects, signed with Standard Webhooks signatures as the webhook ingress verifies them. Driver events come from the MCP manager’s status channel (spec 3.2 §10 T1), never polled. With a ledger (feature proc), the kernel’s ledger sink writes a content-free row for every event but Health (spec 3.2 §7.10).

Structs§

AuditSink
Writes the events that are audit records to the signed audit log (spec 3.2 §7.6, §9.3), kind Other(KERNEL_AUDIT_KIND) with the kernel.* actions of crate::audit.
EventBus
The kernel’s event bus (spec 3.2 §7.6).
EventFilter
Which KernelEvents a sink delivers, by kind (spec 3.2 §7.6).
EventRecord
A numbered KernelEvent as the bus delivers it (spec 3.2 §7.6).
EventSubscriber
A subscription to the EventBus (spec 3.2 §7.6).
SpendDelta
Usage a process committed (spec 3.2 §7.6): the cost in micro-USD as SpendLedger counts it, the model calls and tokens a run budget counts, and the usage per UsageUnit.
WebhookSink
Delivers the kernel’s events to an HTTP endpoint as signed webhooks (spec 3.2 §7.6).

Enums§

EventKind
The kind of a KernelEvent, named as its type field serializes it (spec 3.2 §7.6).
KernelEvent
A change in the kernel (spec 3.2 §7.6).

Constants§

DEFAULT_EVENT_CAPACITY
How many events a subscriber may fall behind before it skips ahead.

Traits§

EventSink
A destination for kernel events (spec 3.2 §7.6): the SSE stream, a channel notifier, an outbound webhook, the audit log.