Skip to main content

liminal_protocol/lifecycle/
observer_recovery_errors.rs

1//! The observer-recovery aggregate's refusals, moved out of `observer_recovery.rs` unchanged so
2//! that file stays within the 500-line bound.
3
4use crate::wire::{ConversationId, DeliverySeq, ObserverEpoch};
5
6/// Restore-time validation failure for the owned observer-recovery aggregate.
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum ObserverRecoveryAggregateRestoreError {
9    /// One conversation appears twice in the durable progress rows.
10    DuplicateProgress {
11        /// Duplicated conversation.
12        conversation_id: ConversationId,
13    },
14    /// One conversation appears twice in the durable arm rows.
15    DuplicateArm {
16        /// Duplicated conversation.
17        conversation_id: ConversationId,
18    },
19    /// A durable arm names a conversation with no durable progress row.
20    ArmWithoutProgress {
21        /// Conversation named by the orphaned arm.
22        conversation_id: ConversationId,
23    },
24    /// A durable arm's epoch differs from its conversation's progress.
25    ///
26    /// An installed arm is always equal-epoch: it is installed at the exact
27    /// read progress and fired (removed) by the same mutation that advances
28    /// progress past it, so any durable disagreement is corruption.
29    ArmEpochMismatch {
30        /// Conversation whose arm disagrees.
31        conversation_id: ConversationId,
32        /// Epoch stored with the arm.
33        armed_epoch: ObserverEpoch,
34        /// Durable hard observer progress.
35        current_observer_progress: DeliverySeq,
36    },
37}
38
39/// Failure while registering a newly tracked conversation.
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum ObserverProgressTrackError {
42    /// The conversation already has an authoritative progress row.
43    AlreadyTracked {
44        /// Conversation presented twice.
45        conversation_id: ConversationId,
46    },
47}
48
49/// Failure while advancing hard observer progress.
50#[derive(Clone, Copy, Debug, PartialEq, Eq)]
51pub enum ObserverProgressAdvanceError {
52    /// The conversation has no authoritative progress row.
53    ConversationUnknown {
54        /// Unknown conversation.
55        conversation_id: ConversationId,
56    },
57    /// The presented progress does not strictly advance the current value.
58    NotAdvancing {
59        /// Conversation whose progress was presented.
60        conversation_id: ConversationId,
61        /// Current hard observer progress.
62        current_observer_progress: DeliverySeq,
63        /// Non-advancing presented progress.
64        presented_progress: DeliverySeq,
65    },
66}