liminal-protocol 0.14.1

Shared participant-lifecycle protocol types for liminal
Documentation
//! The observer-recovery aggregate's refusals, moved out of `observer_recovery.rs` unchanged so
//! that file stays within the 500-line bound.

use crate::wire::{ConversationId, DeliverySeq, ObserverEpoch};

/// Restore-time validation failure for the owned observer-recovery aggregate.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObserverRecoveryAggregateRestoreError {
    /// One conversation appears twice in the durable progress rows.
    DuplicateProgress {
        /// Duplicated conversation.
        conversation_id: ConversationId,
    },
    /// One conversation appears twice in the durable arm rows.
    DuplicateArm {
        /// Duplicated conversation.
        conversation_id: ConversationId,
    },
    /// A durable arm names a conversation with no durable progress row.
    ArmWithoutProgress {
        /// Conversation named by the orphaned arm.
        conversation_id: ConversationId,
    },
    /// A durable arm's epoch differs from its conversation's progress.
    ///
    /// An installed arm is always equal-epoch: it is installed at the exact
    /// read progress and fired (removed) by the same mutation that advances
    /// progress past it, so any durable disagreement is corruption.
    ArmEpochMismatch {
        /// Conversation whose arm disagrees.
        conversation_id: ConversationId,
        /// Epoch stored with the arm.
        armed_epoch: ObserverEpoch,
        /// Durable hard observer progress.
        current_observer_progress: DeliverySeq,
    },
}

/// Failure while registering a newly tracked conversation.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObserverProgressTrackError {
    /// The conversation already has an authoritative progress row.
    AlreadyTracked {
        /// Conversation presented twice.
        conversation_id: ConversationId,
    },
}

/// Failure while advancing hard observer progress.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ObserverProgressAdvanceError {
    /// The conversation has no authoritative progress row.
    ConversationUnknown {
        /// Unknown conversation.
        conversation_id: ConversationId,
    },
    /// The presented progress does not strictly advance the current value.
    NotAdvancing {
        /// Conversation whose progress was presented.
        conversation_id: ConversationId,
        /// Current hard observer progress.
        current_observer_progress: DeliverySeq,
        /// Non-advancing presented progress.
        presented_progress: DeliverySeq,
    },
}