Skip to main content

starweaver_session/
error.rs

1//! Session store errors.
2
3use thiserror::Error;
4
5/// Session store failure.
6#[derive(Debug, Error)]
7pub enum SessionStoreError {
8    /// Record was not found.
9    #[error("session record not found: {0}")]
10    NotFound(String),
11    /// Record already exists.
12    #[error("session record already exists: {0}")]
13    AlreadyExists(String),
14    /// Optimistic revision or lifecycle conflict.
15    #[error("session record conflict: {0}")]
16    Conflict(String),
17    /// The caller no longer owns the admission or fencing generation.
18    #[error("session stale fence: {0}")]
19    StaleFence(String),
20    /// One idempotency key was reused for a different normalized command.
21    #[error("session idempotency conflict: {0}")]
22    IdempotencyConflict(String),
23    /// A trusted host retention or admission quota was exceeded.
24    #[error("session quota exceeded: {0}")]
25    QuotaExceeded(String),
26    /// The session already owns a live run admission.
27    #[error("session run conflict: {0}")]
28    RunConflict(String),
29    /// Store operation failed transiently and may be retried with the same command identity.
30    #[error("session store temporarily unavailable: {0}")]
31    RetryableStorage(String),
32    /// Store failed.
33    #[error("session store failed: {0}")]
34    Failed(String),
35}
36
37/// Result alias for session store operations.
38pub type SessionStoreResult<T> = Result<T, SessionStoreError>;
39
40impl From<SessionStoreError> for starweaver_context::AgentExecutorError {
41    fn from(error: SessionStoreError) -> Self {
42        Self::Failed(error.to_string())
43    }
44}