Skip to main content

Crate astrid_events

Crate astrid_events 

Source
Expand description

Astrid Events - Event bus and types for the Astrid secure agent runtime.

This crate provides:

  • IPC payload types and LLM message schemas (re-exported from astrid-types)
  • Broadcast-based event bus for async subscribers
  • Subscriber registry for synchronous handlers

Re-exports§

pub use ipc::IpcRateLimiter;

Modules§

ipc
IPC types — re-exported from astrid-types with runtime additions.
kernel_api
Kernel management API request and response types.
llm
LLM types for messages, tools, and streaming.
prelude
Prelude module - commonly used types for convenient import.
rate_limiter
IPC rate limiter for publish events.

Structs§

EventBus
Event bus for broadcasting events to all subscribers.
EventMetadata
Metadata attached to every event.
EventReceiver
Receiver for events from the event bus.
IpcMessage
A cross-boundary message sent over the event bus between WASM guests and the host.
RouteKey
Composite identity of a single routed subscription on the bus.
RoutedEventReceiver
Receiver-side handle returned by EventBus::subscribe_topic_routed.
TopicMatcher
Compiled topic-pattern matcher. Mirrors the segment-aware matching semantics of EventReceiver::matches so the broadcast and routed paths agree on what each pattern means.

Enums§

AstridEvent
All events that can occur in the Astrid runtime.
IpcPayload
Standardized cross-boundary payload schemas.

Constants§

DRR_QUANTUM_MIN_BYTES
Per-round DRR floor. 5000 active principals × 4 KiB = 20 MiB of theoretical per-round throughput, well above the 1 MiB total budget, so a round always serves something for every principal in the rotation rather than starving the long tail.
MAX_SUBSCRIPTION_BUDGET_BYTES
Maximum bytes a single subscription will hold across all its per-principal sub-queues before publish-side head-eviction kicks in. Matches the per-call IPC payload ceiling so any single message still fits within one budget.
METRIC_ROUTE_ACTIVE_PRINCIPALS
Gauge: number of active principal sub-queues currently held by a route. Labelled by capsule.
METRIC_ROUTE_BUDGET_BYTES_IN_USE
Gauge: bytes currently held by a route across all its sub-queues. Labelled by capsule.
METRIC_ROUTE_BYTE_EVICTIONS_TOTAL
Counter: head messages evicted from a per-principal sub-queue because the route’s global byte budget would otherwise be exceeded. Labelled by capsule (the subscribing capsule) and bounded principal_class.
METRIC_ROUTE_QUANTUM_STARVED_TOTAL
Counter: rounds in which a principal’s deficit-round-robin quantum could not cover its queue head message (sustained back pressure). Diagnostic — not a drop signal.

Functions§

ipc_size_of
Approximate the byte cost of an event for budget bookkeeping. The Arc<AstridEvent> size in memory dwarfs the IpcPayload content for small messages; we charge the payload’s JSON length so a flood of 1-byte payloads doesn’t masquerade as a 0-byte stream. Non-IPC events fall back to a flat constant since they don’t route through here in practice.
principal_class_label
Label for telemetry classification. Identical mapping to astrid_capsule::principal_class::PrincipalClass::as_label so principal_class labels collide across both crates.
topic_pattern_matches
True iff topic matches pattern using trailing-*-is-subtree semantics: a trailing * matches one OR MORE remaining segments at any depth, a mid-segment * matches exactly one segment, otherwise segment counts must be equal. Allocation-free — iterates the segment splits directly.

Type Aliases§

PrincipalKey
Principal identity key for a fan-out bucket. None = system (kernel) principal; Some(s) = user/agent principal string.