Skip to main content

meerkat_runtime/
lib.rs

1//! meerkat-runtime — v9 runtime control-plane for Meerkat agent lifecycle.
2//!
3//! This crate implements the runtime/control-plane layer of the v9 Canonical
4//! Lifecycle specification. It sits between surfaces (CLI, RPC, REST, MCP)
5//! and core (`meerkat-core`), managing:
6//!
7//! - Input acceptance, validation, and queueing
8//! - InputState lifecycle tracking
9//! - Policy resolution (what to do with each input)
10//! - Runtime state machine (Idle ↔ Running ↔ Recovering → Stopped/Destroyed)
11//! - Retire/respawn/reset lifecycle operations
12//! - RuntimeEvent observability
13//!
14//! Core-facing types (RunPrimitive, RunEvent, CoreExecutor, etc.) live in
15//! `meerkat-core::lifecycle`. This crate contains everything else.
16
17#[cfg(target_arch = "wasm32")]
18pub mod tokio {
19    pub use tokio_with_wasm::alias::*;
20}
21
22#[cfg(not(target_arch = "wasm32"))]
23pub use ::tokio;
24
25pub mod accept;
26pub mod coalescing;
27pub mod comms_bridge;
28pub mod comms_sink;
29pub mod completion;
30pub mod driver;
31pub mod durability;
32pub mod identifiers;
33pub mod input;
34pub mod input_ledger;
35pub mod input_machine;
36pub mod input_scope;
37pub mod input_state;
38pub mod lifecycle_ops;
39pub mod mob_adapter;
40pub mod policy;
41pub mod policy_table;
42pub mod queue;
43pub mod runtime_event;
44pub(crate) mod runtime_loop;
45pub mod runtime_state;
46pub mod service_ext;
47pub mod session_adapter;
48pub mod state_machine;
49pub mod store;
50pub mod traits;
51
52// Re-exports for convenience
53pub use accept::AcceptOutcome;
54pub use coalescing::{
55    AggregateDescriptor, CoalescingResult, SupersessionScope, apply_coalescing, apply_supersession,
56    check_supersession, create_aggregate_input, is_coalescing_eligible,
57};
58pub use completion::{CompletionHandle, CompletionOutcome, CompletionRegistry};
59pub use driver::{EphemeralRuntimeDriver, PersistentRuntimeDriver};
60pub use durability::{DurabilityError, validate_durability};
61pub use identifiers::{
62    CausationId, ConversationId, CorrelationId, EventCodeId, IdempotencyKey, KindId,
63    LogicalRuntimeId, PolicyVersion, ProjectionRuleId, RuntimeEventId, SchemaId, SupersessionKey,
64};
65pub use input::{
66    ExternalEventInput, FlowStepInput, Input, InputDurability, InputHeader, InputOrigin,
67    InputVisibility, PeerConvention, PeerInput, ProjectedInput, PromptInput, ResponseProgressPhase,
68    ResponseTerminalStatus, SystemGeneratedInput,
69};
70pub use input_ledger::InputLedger;
71pub use input_machine::{InputStateMachine, InputStateMachineError};
72pub use input_scope::InputScope;
73pub use input_state::{
74    InputAbandonReason, InputLifecycleState, InputState, InputStateEvent, InputStateHistoryEntry,
75    InputTerminalOutcome, PolicySnapshot, ReconstructionSource,
76};
77pub use lifecycle_ops::{abandon_non_terminal, would_abandon};
78pub use policy::{ApplyMode, ConsumePoint, PolicyDecision, QueueMode, WakeMode};
79pub use policy_table::{DEFAULT_POLICY_VERSION, DefaultPolicyTable};
80pub use queue::InputQueue;
81pub use runtime_event::{
82    InputLifecycleEvent, RunLifecycleEvent, RuntimeEvent, RuntimeEventEnvelope,
83    RuntimeProjectionEvent, RuntimeStateChangeEvent, RuntimeTopologyEvent,
84};
85pub use runtime_state::{RuntimeState, RuntimeStateTransitionError};
86pub use service_ext::{RuntimeMode, SessionServiceRuntimeExt};
87pub use session_adapter::RuntimeSessionAdapter;
88pub use state_machine::RuntimeStateMachine;
89pub use store::{InMemoryRuntimeStore, RuntimeStore, RuntimeStoreError, SessionDelta};
90pub use traits::{
91    DestroyReport, RecoveryReport, ResetReport, RespawnReport, RetireReport, RuntimeControlCommand,
92    RuntimeControlPlane, RuntimeControlPlaneError, RuntimeDriver, RuntimeDriverError,
93};