Skip to main content

rightkit_agent_engine_protocol/event/
durability.rs

1use super::ProtocolEvent;
2
3/// Whether an event is canonical replay truth or an ephemeral live projection.
4/// Durable facts belong in SQLite and must survive reconnect/replay. Live
5/// projections may be dropped/reordered without changing settled session truth.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum EventDurability {
8    DurableFact,
9    LiveProjection,
10}
11
12impl ProtocolEvent {
13    /// Conservative classification: only events that are unambiguously
14    /// presentation/control projections are non-durable. New variants default
15    /// to durable by virtue of the explicit catch-all arm.
16    pub fn durability(&self) -> EventDurability {
17        match self {
18            Self::AssistantDelta { .. }
19            | Self::ToolOutputDelta { .. }
20            | Self::StreamResyncRequired { .. }
21            | Self::PersistenceFailed { .. } => EventDurability::LiveProjection,
22            _ => EventDurability::DurableFact,
23        }
24    }
25
26    pub fn is_durable_fact(&self) -> bool {
27        self.durability() == EventDurability::DurableFact
28    }
29}