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 ↔ Attached ↔ Running ↔ Recovering → Stopped/Destroyed)
11//! - Retire/recycle/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_drain;
29pub mod completion;
30pub(crate) mod control_plane;
31pub mod detached_wake;
32pub mod driver;
33pub mod durability;
34pub mod identifiers;
35pub mod input;
36pub mod input_ledger;
37pub mod input_lifecycle_authority;
38pub mod input_scope;
39pub mod input_state;
40pub mod lifecycle_ops;
41pub mod mob_adapter;
42pub mod ops_lifecycle;
43pub(crate) mod ops_lifecycle_authority;
44pub mod peer_handling_mode;
45pub mod policy;
46pub mod policy_table;
47pub mod queue;
48pub mod runtime_control_authority;
49pub mod runtime_event;
50pub mod runtime_ingress_authority;
51pub(crate) mod runtime_loop;
52pub mod runtime_state;
53pub mod service_ext;
54pub mod session_adapter;
55pub mod silent_intent;
56pub mod store;
57pub mod traits;
58
59// Re-exports for convenience
60pub use accept::{AcceptOutcome, RejectReason};
61pub use coalescing::{
62    AggregateDescriptor, CoalescingResult, SupersessionScope, apply_coalescing, apply_supersession,
63    check_supersession, create_aggregate_input, is_coalescing_eligible,
64};
65pub use completion::{CompletionHandle, CompletionOutcome};
66pub use driver::{EphemeralRuntimeDriver, PersistentRuntimeDriver, PostAdmissionSignal};
67pub use durability::{DurabilityError, validate_durability};
68pub use identifiers::{
69    CausationId, ConversationId, CorrelationId, EventCodeId, IdempotencyKey, KindId,
70    LogicalRuntimeId, PolicyVersion, ProjectionRuleId, RuntimeEventId, SchemaId, SupersessionKey,
71};
72pub use input::{
73    ContinuationInput, ExternalEventInput, FlowStepInput, Input, InputDurability, InputHeader,
74    InputOrigin, InputVisibility, OperationInput, PeerConvention, PeerInput, PromptInput,
75    ResponseProgressPhase, ResponseTerminalStatus,
76};
77pub use input_ledger::InputLedger;
78pub use input_lifecycle_authority::{
79    InputLifecycleAuthority, InputLifecycleEffect, InputLifecycleError, InputLifecycleInput,
80    InputLifecycleMutator, InputLifecycleTransition,
81};
82pub use input_scope::InputScope;
83pub use input_state::{
84    InputAbandonReason, InputLifecycleState, InputState, InputStateEvent, InputStateHistoryEntry,
85    InputTerminalOutcome, PolicySnapshot, ReconstructionSource,
86};
87pub use lifecycle_ops::{abandon_non_terminal, would_abandon};
88pub use ops_lifecycle::{OpsLifecycleConfig, PersistedOpsSnapshot, RuntimeOpsLifecycleRegistry};
89pub use peer_handling_mode::{PeerHandlingModeError, validate_peer_handling_mode};
90pub use policy::{
91    ApplyMode, ConsumePoint, DrainPolicy, PolicyDecision, QueueMode, RoutingDisposition, WakeMode,
92};
93pub use policy_table::{DEFAULT_POLICY_VERSION, DefaultPolicyTable};
94pub use queue::InputQueue;
95pub use runtime_control_authority::{
96    HandlingMode, RuntimeControlAuthority, RuntimeControlEffect, RuntimeControlInput,
97    RuntimeControlMutator, RuntimeControlTransition,
98};
99pub use runtime_event::{
100    InputLifecycleEvent, RunLifecycleEvent, RuntimeEvent, RuntimeEventEnvelope,
101    RuntimeProjectionEvent, RuntimeStateChangeEvent, RuntimeTopologyEvent,
102};
103pub use runtime_ingress_authority::{
104    ContentShape, IngressPhase, RequestId, ReservationKey, RuntimeIngressAuthority,
105    RuntimeIngressEffect, RuntimeIngressError, RuntimeIngressInput, RuntimeIngressMutator,
106    RuntimeIngressTransition,
107};
108pub use runtime_state::{RuntimeState, RuntimeStateTransitionError};
109pub use service_ext::{RuntimeMode, SessionServiceRuntimeExt};
110pub use session_adapter::{RuntimeBindingsError, RuntimeSessionAdapter};
111pub use store::{InMemoryRuntimeStore, RuntimeStore, RuntimeStoreError, SessionDelta};
112pub use traits::{
113    DestroyReport, RecoveryReport, RecycleReport, ResetReport, RetireReport, RuntimeControlCommand,
114    RuntimeControlPlane, RuntimeControlPlaneError, RuntimeDriver, RuntimeDriverError,
115};