coven_replication/sync/store/device_join/
error.rs1#[derive(Debug, thiserror::Error)]
2pub enum DeviceJoinError {
3 #[error("device join signature is invalid")]
4 InvalidSignature,
5 #[error("device join offer does not name one active Store/member/provider authority")]
6 OfferMismatch,
7 #[error(
8 "device provider admission approval differs from its request or activated access grant"
9 )]
10 ApprovalMismatch,
11 #[error("device registration request differs from its offer, approval, or reserved slots")]
12 RegistrationRequestMismatch,
13 #[error("device join attempt differs from its signed exchange")]
14 AttemptMismatch,
15 #[error("device join cleanup does not contain the unconditional canonical slot set")]
16 CleanupMismatch,
17 #[error("device join journal transition is not the declared adjacent transition")]
18 NonAdjacentJournalTransition,
19 #[error("device join journal has a different durable value for this role and attempt")]
20 JournalConflict,
21 #[error("device join reserved slots are not pairwise distinct")]
22 DuplicateReservedSlot,
23 #[error("device join requires an existing Member identity")]
24 MemberNotEligible,
25 #[error("provider operation failed: {0}")]
26 Provider(String),
27 #[error("provider storage failed: {0}")]
28 ProviderStorage(#[source] coven_protocol::objects::StorageError),
29 #[error("provider capability proof failed: {0}")]
30 ProviderProbe(#[source] coven_protocol::provider::ProviderProbeError),
31 #[error("Store device join state: {0}")]
32 Store(String),
33 #[error("device join readiness task failed: {0}")]
34 JoinTask(#[from] tokio::task::JoinError),
35 #[error("Store device join writer authorization: {0}")]
36 WriterAuthorization(#[source] Box<crate::sync::store::StoreWriterAuthorizationError>),
37 #[error("Store device join membership chain: {0}")]
38 MembershipChain(#[source] Box<crate::sync::store::AnchoredChainError>),
39 #[error("Store device join database state: {0}")]
40 Database(#[from] coven_database::DbError),
41 #[error("device join requires an activated local Store device")]
42 ActiveDeviceRequired,
43 #[error("device join requires the active local Owner authority")]
44 OwnerAuthorityRequired,
45 #[error("device join requires the selected effective provider administrator")]
46 ProviderAdministratorRequired,
47 #[error("device join attempt cut does not include its provider-access activation")]
48 ApprovalActivationMissing,
49 #[error("device join activation is not materialized in the installed Store database")]
50 ActivationNotMaterialized,
51 #[error(transparent)]
52 Object(#[from] coven_protocol::objects::StoreObjectError),
53 #[error(transparent)]
54 Registration(#[from] crate::sync::store::StoreRegistrationError),
55 #[error(transparent)]
56 Pull(#[from] crate::sync::store::pull::StorePullError),
57 #[error(transparent)]
58 Outbound(#[from] crate::sync::store::StoreError),
59 #[error(transparent)]
60 Protocol(#[from] coven_protocol::store_commit::StoreProtocolError),
61 #[error(transparent)]
62 Storage(#[from] coven_protocol::objects::StorageError),
63 #[error(transparent)]
64 Serialization(#[from] serde_json::Error),
65}
66
67impl From<crate::sync::store::StoreWriterAuthorizationError> for DeviceJoinError {
68 fn from(error: crate::sync::store::StoreWriterAuthorizationError) -> Self {
69 Self::WriterAuthorization(Box::new(error))
70 }
71}
72
73impl From<crate::sync::store::AnchoredChainError> for DeviceJoinError {
74 fn from(error: crate::sync::store::AnchoredChainError) -> Self {
75 Self::MembershipChain(Box::new(error))
76 }
77}
78
79impl From<coven_protocol::store_commit::device_join_exchange::DeviceJoinExchangeError>
80 for DeviceJoinError
81{
82 fn from(
83 error: coven_protocol::store_commit::device_join_exchange::DeviceJoinExchangeError,
84 ) -> Self {
85 use coven_protocol::store_commit::device_join_exchange::DeviceJoinExchangeError as E;
86 match error {
87 E::InvalidSignature => DeviceJoinError::InvalidSignature,
88 E::OfferMismatch => DeviceJoinError::OfferMismatch,
89 E::ApprovalMismatch => DeviceJoinError::ApprovalMismatch,
90 E::RegistrationRequestMismatch => DeviceJoinError::RegistrationRequestMismatch,
91 E::AttemptMismatch => DeviceJoinError::AttemptMismatch,
92 E::CleanupMismatch => DeviceJoinError::CleanupMismatch,
93 E::DuplicateReservedSlot => DeviceJoinError::DuplicateReservedSlot,
94 E::Provider(error) => DeviceJoinError::ProviderProbe(error),
95 E::Storage(error) => DeviceJoinError::Storage(error),
96 E::Protocol(error) => DeviceJoinError::Protocol(error),
97 }
98 }
99}
100
101impl From<coven_database::DeviceJoinJournalError> for DeviceJoinError {
102 fn from(error: coven_database::DeviceJoinJournalError) -> Self {
103 use coven_database::DeviceJoinJournalError as E;
104 match error {
105 E::NonAdjacentJournalTransition => DeviceJoinError::NonAdjacentJournalTransition,
106 E::JournalConflict => DeviceJoinError::JournalConflict,
107 E::Serialization(error) => DeviceJoinError::Serialization(error),
108 E::Database(error) => DeviceJoinError::Database(error),
109 }
110 }
111}