aion_store/error.rs
1//! `StoreError` taxonomy.
2
3use aion_core::WorkflowId;
4
5/// Errors returned by [`crate::ReadableEventStore`] and [`crate::EventStore`] implementations.
6#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
7pub enum StoreError {
8 /// The workflow history head did not match the caller's optimistic-concurrency guard.
9 #[error(
10 "sequence conflict (double-writer bug indicator): expected workflow head {expected}, found {found}"
11 )]
12 SequenceConflict {
13 /// Sequence number the caller expected to be the current workflow head.
14 expected: u64,
15 /// Sequence number currently stored as the workflow head.
16 found: u64,
17 },
18
19 /// Reserved for operations that target a must-exist workflow; read and query methods return
20 /// empty results, not `NotFound`, for absent workflows.
21 #[error("workflow {workflow_id} was not found")]
22 NotFound {
23 /// Workflow identifier targeted by the must-exist operation.
24 workflow_id: WorkflowId,
25 },
26
27 /// The targeted shard is owned by a different node: a quorum write was fenced
28 /// because this node is not the current owner of the workflow's shard. Unlike
29 /// [`Self::Backend`] this is a typed, *retryable* routing signal — the caller
30 /// (or the request-routing edge) should re-resolve the shard's owner and retry
31 /// or forward, rather than treating it as an opaque internal failure. Emitted
32 /// only on the distributed (`[store.cluster]`) replication path.
33 #[error("shard {shard} is owned by another node (not owner)")]
34 NotOwner {
35 /// The distribution shard the fenced workflow's durable state lives on.
36 shard: usize,
37 },
38
39 /// Backend-specific failure mapped into the store contract's closed error surface.
40 #[error("store backend error: {0}")]
41 Backend(String),
42
43 /// Serialization or deserialization failure while crossing the store boundary.
44 #[error("store serialization error: {0}")]
45 Serialization(String),
46}