liminal_server/error.rs
1use std::net::SocketAddr;
2
3/// Error taxonomy for standalone liminal server deployment failures.
4#[derive(Debug, thiserror::Error)]
5pub enum ServerError {
6 /// The configuration file could not be read or parsed.
7 #[error("configuration load failed: {message}")]
8 ConfigLoad { message: String },
9
10 /// The configuration file was read but failed semantic validation.
11 #[error("configuration validation failed: {message}")]
12 ConfigValidation { message: String },
13
14 /// The server could not bind its configured listener address.
15 #[error("listener bind failed for {address}: {source}")]
16 ListenerBind {
17 /// Address the server attempted to bind.
18 address: SocketAddr,
19 /// Underlying operating-system bind failure.
20 #[source]
21 source: std::io::Error,
22 },
23
24 /// The server listener failed while accepting an inbound connection.
25 #[error("listener accept failed: {message}")]
26 ListenerAccept { message: String },
27
28 /// Durable participant-incarnation startup or allocation failed before its
29 /// result could be published.
30 #[error("participant incarnation {phase} failed: {message}")]
31 ParticipantIncarnation {
32 /// Exact server seam that failed.
33 phase: &'static str,
34 /// Underlying durable or bounded-bridge diagnostic.
35 message: String,
36 },
37
38 /// The durable server-incarnation namespace has no successor.
39 #[error("participant server-incarnation namespace is exhausted")]
40 ServerIncarnationExhausted,
41
42 /// Production participant startup restore failed: the durable
43 /// conversation streams could not be scanned or replayed, so the
44 /// server-scope capacity ledger cannot be made exact and the server
45 /// refuses to start over state it cannot account for.
46 #[error("participant startup restore failed: {message}")]
47 ParticipantStartupRestore {
48 /// Underlying durable, replay, or bridge diagnostic.
49 message: String,
50 },
51
52 /// The current durable server incarnation has no collision-free connection
53 /// ordinal left, so the accepted socket was not admitted.
54 #[error(
55 "connection incarnation exhausted for server incarnation {attempted_server_incarnation}"
56 )]
57 ConnectionIncarnationExhausted {
58 /// Server incarnation whose complete ordinal suffix was examined.
59 attempted_server_incarnation: u64,
60 },
61
62 /// A frame requested an operation the configured services profile does not
63 /// serve (e.g. ordinary publish/subscribe/conversation traffic against the
64 /// capability-scoped worker front door). Server-internal taxonomy, not wire
65 /// vocabulary: the connection process renders it as the operation's existing
66 /// typed error frame with this error's text as the message.
67 #[error("{operation} is not supported by the {profile} services profile")]
68 UnsupportedOperation {
69 /// Human-readable description of the refused operation.
70 operation: String,
71 /// The configured services profile that refused it.
72 profile: &'static str,
73 },
74
75 /// A server→client push reply slot was dropped before a correlated reply
76 /// arrived — the connection closed (the prompt worker-death signal). Distinct
77 /// from [`Self::PushReplyTimeout`] so consumers can tell a worker that DIED
78 /// (fast failover) from one that is merely SLOW, by type rather than message.
79 #[error(
80 "push correlation {correlation_id} did not complete: the connection closed before sending a correlated push reply"
81 )]
82 PushReplyDisconnected {
83 /// Correlation id of the push whose reply will never arrive.
84 correlation_id: u64,
85 },
86
87 /// A server→client push reply did not arrive within the awaiter's timeout —
88 /// the worker is still connected but did not reply in this wait quantum. This
89 /// is BENIGN: the reply slot survives untouched and the caller may re-arm
90 /// [`PushReplyAwaiter::receive`](crate::server::connection::PushReplyAwaiter::receive)
91 /// indefinitely. It is not a worker-death signal.
92 #[error(
93 "push correlation {correlation_id} did not complete: no correlated push reply arrived within the timeout"
94 )]
95 PushReplyTimeout {
96 /// Correlation id of the push whose wait quantum elapsed.
97 correlation_id: u64,
98 },
99
100 /// A server→client push carrying an explicit reply deadline (via
101 /// [`push_to_connection_with_deadline`](crate::server::connection::ConnectionSupervisor::push_to_connection_with_deadline))
102 /// reached that deadline before a correlated reply arrived. Unlike
103 /// [`Self::PushReplyTimeout`] this is TERMINAL: the reply slot has been
104 /// removed and its §5 `max_pending_pushes_per_connection` cap admission
105 /// released. Returned PROMPTLY once the deadline is due — a `receive` call
106 /// does not hold a due expiry until its caller's quantum ends, so the
107 /// terminal outcome is independent of how the caller polls. Distinct
108 /// variant so callers classify by type, not message.
109 #[error(
110 "push correlation {correlation_id} did not complete: its reply deadline passed before a correlated push reply arrived"
111 )]
112 PushReplyExpired {
113 /// Correlation id of the push whose reply deadline passed.
114 correlation_id: u64,
115 },
116
117 /// The server could not join the configured beamr distribution cluster.
118 #[error("cluster join failed: {message}")]
119 ClusterJoin { message: String },
120
121 /// Cluster state propagation through beamr distribution failed.
122 #[error("cluster sync failed: {message}")]
123 ClusterSync { message: String },
124
125 /// Graceful shutdown did not drain within the configured timeout.
126 #[error("shutdown timed out: {message}")]
127 ShutdownTimeout { message: String },
128
129 /// Durable state could not be flushed during graceful shutdown.
130 #[error("shutdown flush failed: {message}")]
131 ShutdownFlush { message: String },
132
133 /// The health endpoint failed to start or serve requests.
134 #[error("health endpoint failed: {message}")]
135 HealthEndpoint { message: String },
136
137 /// A new connection was refused because the configured `max_connections`
138 /// cap (§5) is already reached. The listener drops the freshly accepted
139 /// stream, refusing the connection, rather than admitting an unbounded fleet.
140 #[error(
141 "connection refused: the configured max_connections limit of {limit} live connections is reached"
142 )]
143 ConnectionLimitReached {
144 /// The configured `max_connections` cap that was hit.
145 limit: usize,
146 },
147
148 /// An admission-time per-connection cap (§5) refused an operation: too many
149 /// subscriptions, conversations, in-flight pushes, or pending conversation
150 /// replies on one connection. The connection process renders it as the
151 /// operation's existing typed error frame with this text as the message.
152 #[error("{operation} refused: the per-connection {cap} limit of {limit} is reached")]
153 ConnectionCapReached {
154 /// Human-readable description of the refused operation.
155 operation: String,
156 /// The name of the cap that refused it (a `limits.*` config key).
157 cap: &'static str,
158 /// The configured cap value that was hit.
159 limit: usize,
160 },
161}