Skip to main content

muse_code_sdk/msp/error/
registry.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::ErrorKind;
4use super::definition::ErrorCodeDefinition;
5use super::definition::drains;
6use super::definition::fatal;
7use super::definition::preempted;
8
9/// The session-lifecycle wire code for [`ErrorKind::SessionNotLoaded`]: one
10/// shared symbol so producers and test assertions cannot drift on the literal.
11pub const SESSION_NOT_LOADED_CODE: i64 = -32024;
12
13/// The session-lifecycle wire code for [`ErrorKind::SessionStreamMismatch`]:
14/// the resolved store's own stream id is not the requested session, so every
15/// write lane refuses before it can append a fabricated history.
16pub const SESSION_STREAM_MISMATCH_CODE: i64 = -32025;
17
18/// The session-lifecycle wire code for [`ErrorKind::LimitsAboveMax`]: one
19/// shared symbol so the `session/start` producer and test assertions cannot
20/// drift on the literal.
21pub const LIMITS_ABOVE_MAX_CODE: i64 = -32028;
22
23/// The wire code for [`ErrorKind::DaemonDraining`]: the command-plane block's
24/// free tail — the session block is full (`-32026`/`-32027` are the spool
25/// rows). One shared symbol so the draining-daemon refusal producer and test
26/// assertions cannot drift on the literal.
27pub const DAEMON_DRAINING_CODE: i64 = -32039;
28
29/// The v1 error codes enrolled in the public bundle.
30///
31/// Enrolment tracks what the BINARY can emit, not what the bundle's method
32/// index has reached: the export is exact for the binary that produced it, so a
33/// code a v1 host puts on the wire is enrolled here even while its method's
34/// params/result types are still pending. Of the `-32060…-32069` raw-log block,
35/// only the five experimental rows are enrolled; the rest stays out because a
36/// v1 host never emits it.
37#[derive(Debug, Clone, Copy, PartialEq, Eq)]
38#[non_exhaustive]
39pub enum ErrorCode {
40    /// `-32700` — unparseable line.
41    ParseError,
42    /// `-32600` — invalid frame or handshake ordering.
43    InvalidRequest,
44    /// `-32601` — unknown or ungated-experimental method.
45    MethodNotFound,
46    /// `-32602` — malformed params or ungated-experimental field/variant.
47    InvalidParams,
48    /// `-32603` — unexpected server failure.
49    Internal,
50    /// `-32001` — ingress saturated.
51    Overloaded,
52    /// `-32002` — frame or params over the limit.
53    InputTooLarge,
54    /// `-32010` — missing capability grant.
55    CapabilityRequired,
56    /// `-32011` — run/item/subscription/cursor anchor missing.
57    NotFound,
58    /// `-32013` — user interrupt pre-empted the request.
59    Interrupted,
60    /// `-32014` — cancellation pre-empted the request.
61    Cancelled,
62    /// `-32020` — no log resolves for `sessionId`.
63    SessionNotFound,
64    /// `-32021` — writer lease held by another process.
65    SessionInUse,
66    /// `-32022` — multiple canonical logs for the id.
67    SessionAmbiguous,
68    /// `-32023` — `cutPoint.lastTurnId` unknown or in-progress.
69    ForkBoundaryInvalid,
70    /// `-32024` — log exists but the session is not loaded on this host.
71    SessionNotLoaded,
72    /// `-32025` — the store's own stream id is not the requested session
73    /// (a moved or renamed session directory).
74    SessionStreamMismatch,
75    /// `-32039` — a drive-taking verb refused because this daemon is draining
76    /// on the binary-change upgrade path; `data.paths` names the canonical
77    /// socket to retry against.
78    DaemonDraining,
79    /// `-32028` — a `session/start` choice is wider than the host ceiling on at
80    /// least one axis.
81    LimitsAboveMax,
82    /// `-32029` — a worktree action names an untrusted repository.
83    WorkspaceNotTrusted,
84    /// `-32030` — durable runtime rejection; `data.reason` is snake_case.
85    CommandRejected,
86    /// `-32031` — command-admission queue full; `data.capacity` present.
87    Backpressured,
88    /// `-32032` — the skill selector names no user-invocable skill in this
89    /// session's catalog.
90    SkillNotFound,
91    /// `-32033` — computer use is unavailable on this host.
92    ComputerUseUnavailable,
93    /// `-32034` — the plugin verb names no configured marketplace.
94    MarketplaceNotFound,
95    /// `-32035` — the install arm names no plugin in the named store.
96    PluginNotFound,
97    /// `-32036` — marketplace add over an already-configured name.
98    MarketplaceAlreadyExists,
99    /// `-32037` — the managed policy disables plugin mutation.
100    PluginMutationsDisabled,
101    /// `-32038` — a `video` input part names an upload id with no completed
102    /// upload.
103    UploadNotFound,
104    /// `-32040` — requested range predates the retained view.
105    ViewTruncated,
106    /// `-32041` — an `item/readOutput` ref exists but its bytes are not
107    /// servable; `data.availability` carries the durable
108    /// `ToolOutputAvailability`.
109    OutputUnavailable,
110    /// `-32042` — installed boundary pruned, unusable, or absent.
111    Boundary,
112    /// `-32050` — `approvalId` names no approval record in this session.
113    ApprovalNotFound,
114    /// `-32051` — decide after the durable terminal.
115    ApprovalAlreadyResolved,
116    /// `-32052` — `choiceId` is not among the current `availableChoices`.
117    ApprovalChoiceInvalid,
118    /// `-32053` — `requirementId` is not the current requirement.
119    ApprovalRequirementStale,
120    /// `-32054` — protected-write decision with no live reviewer.
121    ApprovalReviewerUnavailable,
122    /// `-32055` — `userInputId` names no prompt in this session.
123    UserInputNotFound,
124    /// `-32056` — answer/cancel/clarify after settlement.
125    UserInputAlreadySettled,
126    /// `-32057` — answers do not match the prompt's questions or bounds.
127    UserInputAnswerInvalid,
128    /// `-32060` — cursor anchor names no position of the requested stream.
129    MissingAnchor,
130    /// `-32061` — anchor (or origin) falls in a retention-pruned prefix.
131    PrunedPrefix,
132    /// `-32062` — anchor id belongs to a different stream of the session.
133    WrongStream,
134    /// `-32063` — stream not present in the session.
135    UnknownStream,
136    /// `-32064` — projection name not registered.
137    UnknownProjection,
138    /// `-32070` — `admissionId` names no admission record in this session.
139    AdmissionNotFound,
140    /// `-32071` — decide after the durable terminal.
141    AdmissionAlreadyResolved,
142    /// `-32072` — `choiceId` is not among the current `availableChoices`.
143    AdmissionChoiceInvalid,
144    /// `-32080` — a `usage/refresh` inside the per-host window.
145    UsageRefreshRateLimited,
146    /// `-32081` — a `usage/refresh` with no Meta-account login.
147    UsageRefreshUnavailable,
148    /// `-32082` — a `usage/refresh` whose mint failed.
149    UsageRefreshFailed,
150}
151
152impl ErrorCode {
153    /// Every code enrolled in the public bundle, in registry order: the 37
154    /// stable rows plus 14 experimental rows (5 raw-log, 1 workspace-trust, 1
155    /// limits, 1 draining-daemon refusal, 3 admission, 3 usage-refresh), which
156    /// render only in the experimental bundle.
157    pub const ALL: [Self; 51] = [
158        Self::ParseError,
159        Self::InvalidRequest,
160        Self::MethodNotFound,
161        Self::InvalidParams,
162        Self::Internal,
163        Self::Overloaded,
164        Self::InputTooLarge,
165        Self::CapabilityRequired,
166        Self::NotFound,
167        Self::Interrupted,
168        Self::Cancelled,
169        Self::SessionNotFound,
170        Self::SessionInUse,
171        Self::SessionAmbiguous,
172        Self::ForkBoundaryInvalid,
173        Self::SessionNotLoaded,
174        Self::SessionStreamMismatch,
175        Self::DaemonDraining,
176        Self::LimitsAboveMax,
177        Self::WorkspaceNotTrusted,
178        Self::CommandRejected,
179        Self::Backpressured,
180        Self::SkillNotFound,
181        Self::ComputerUseUnavailable,
182        Self::MarketplaceNotFound,
183        Self::PluginNotFound,
184        Self::MarketplaceAlreadyExists,
185        Self::PluginMutationsDisabled,
186        Self::UploadNotFound,
187        Self::ViewTruncated,
188        Self::OutputUnavailable,
189        Self::Boundary,
190        Self::ApprovalNotFound,
191        Self::ApprovalAlreadyResolved,
192        Self::ApprovalChoiceInvalid,
193        Self::ApprovalRequirementStale,
194        Self::ApprovalReviewerUnavailable,
195        Self::UserInputNotFound,
196        Self::UserInputAlreadySettled,
197        Self::UserInputAnswerInvalid,
198        Self::MissingAnchor,
199        Self::PrunedPrefix,
200        Self::WrongStream,
201        Self::UnknownStream,
202        Self::UnknownProjection,
203        Self::AdmissionNotFound,
204        Self::AdmissionAlreadyResolved,
205        Self::AdmissionChoiceInvalid,
206        Self::UsageRefreshRateLimited,
207        Self::UsageRefreshUnavailable,
208        Self::UsageRefreshFailed,
209    ];
210
211    /// This code's complete registry row. Keeping the row together prevents
212    /// the generated bundle columns from drifting across separate matches, so
213    /// this stays ONE wildcard-free match over every variant: a new code fails
214    /// to compile until its row exists. The three shape helpers below carry the
215    /// `retryable` column's vocabulary — a shared name per column value, not a
216    /// default anyone can inherit by omission.
217    const fn definition(self) -> ErrorCodeDefinition {
218        match self {
219            Self::ParseError => fatal(-32700, ErrorKind::ParseError),
220            Self::InvalidRequest => ErrorCodeDefinition::new(
221                -32600,
222                ErrorKind::InvalidRequest,
223                &[ErrorKind::NotInitialized, ErrorKind::AlreadyInitialized],
224                Some(false),
225            ),
226            Self::MethodNotFound => ErrorCodeDefinition::new(
227                -32601,
228                ErrorKind::MethodNotFound,
229                &[ErrorKind::ExperimentalRequired],
230                Some(false),
231            ),
232            Self::InvalidParams => ErrorCodeDefinition::new(
233                -32602,
234                ErrorKind::InvalidParams,
235                &[ErrorKind::ExperimentalRequired],
236                Some(false),
237            ),
238            Self::Internal => ErrorCodeDefinition::new(
239                -32603,
240                ErrorKind::Internal,
241                &[
242                    ErrorKind::PageEventTooLarge,
243                    ErrorKind::OutputResultTooLarge,
244                ],
245                Some(false),
246            ),
247            Self::Overloaded => drains(-32001, ErrorKind::Overloaded),
248            Self::InputTooLarge => fatal(-32002, ErrorKind::InputTooLarge),
249            Self::CapabilityRequired => fatal(-32010, ErrorKind::CapabilityRequired),
250            Self::NotFound => fatal(-32011, ErrorKind::NotFound),
251            Self::Interrupted => preempted(-32013, ErrorKind::Interrupted),
252            Self::Cancelled => preempted(-32014, ErrorKind::Cancelled),
253            Self::SessionNotFound => fatal(-32020, ErrorKind::SessionNotFound),
254            Self::SessionInUse => fatal(-32021, ErrorKind::SessionInUse),
255            Self::SessionAmbiguous => fatal(-32022, ErrorKind::SessionAmbiguous),
256            Self::ForkBoundaryInvalid => fatal(-32023, ErrorKind::ForkBoundaryInvalid),
257            Self::SessionNotLoaded => fatal(SESSION_NOT_LOADED_CODE, ErrorKind::SessionNotLoaded),
258            Self::SessionStreamMismatch => fatal(
259                SESSION_STREAM_MISMATCH_CODE,
260                ErrorKind::SessionStreamMismatch,
261            ),
262            Self::DaemonDraining => ErrorCodeDefinition::experimental_with_retry(
263                DAEMON_DRAINING_CODE,
264                ErrorKind::DaemonDraining,
265                Some(true),
266            ),
267            Self::LimitsAboveMax => {
268                ErrorCodeDefinition::experimental(LIMITS_ABOVE_MAX_CODE, ErrorKind::LimitsAboveMax)
269            }
270            Self::WorkspaceNotTrusted => {
271                ErrorCodeDefinition::experimental(-32029, ErrorKind::WorkspaceNotTrusted)
272            }
273            Self::CommandRejected => fatal(-32030, ErrorKind::CommandRejected),
274            Self::Backpressured => drains(-32031, ErrorKind::Backpressured),
275            Self::SkillNotFound => fatal(-32032, ErrorKind::SkillNotFound),
276            Self::ComputerUseUnavailable => fatal(-32033, ErrorKind::ComputerUseUnavailable),
277            Self::MarketplaceNotFound => fatal(-32034, ErrorKind::MarketplaceNotFound),
278            Self::PluginNotFound => fatal(-32035, ErrorKind::PluginNotFound),
279            Self::MarketplaceAlreadyExists => fatal(-32036, ErrorKind::MarketplaceAlreadyExists),
280            Self::PluginMutationsDisabled => fatal(-32037, ErrorKind::PluginMutationsDisabled),
281            Self::UploadNotFound => fatal(-32038, ErrorKind::UploadNotFound),
282            Self::ViewTruncated => fatal(-32040, ErrorKind::ViewTruncated),
283            Self::OutputUnavailable => fatal(-32041, ErrorKind::OutputUnavailable),
284            Self::Boundary => ErrorCodeDefinition::new(
285                -32042,
286                ErrorKind::BoundaryPruned,
287                &[ErrorKind::BoundaryUnusable, ErrorKind::NoBoundary],
288                Some(false),
289            ),
290            Self::ApprovalNotFound => fatal(-32050, ErrorKind::ApprovalNotFound),
291            Self::ApprovalAlreadyResolved => fatal(-32051, ErrorKind::ApprovalAlreadyResolved),
292            Self::ApprovalChoiceInvalid => fatal(-32052, ErrorKind::ApprovalChoiceInvalid),
293            Self::ApprovalRequirementStale => fatal(-32053, ErrorKind::ApprovalRequirementStale),
294            Self::ApprovalReviewerUnavailable => {
295                fatal(-32054, ErrorKind::ApprovalReviewerUnavailable)
296            }
297            Self::UserInputNotFound => fatal(-32055, ErrorKind::UserInputNotFound),
298            Self::UserInputAlreadySettled => fatal(-32056, ErrorKind::UserInputAlreadySettled),
299            Self::UserInputAnswerInvalid => fatal(-32057, ErrorKind::UserInputAnswerInvalid),
300            Self::MissingAnchor => {
301                ErrorCodeDefinition::experimental(-32060, ErrorKind::MissingAnchor)
302            }
303            Self::PrunedPrefix => {
304                ErrorCodeDefinition::experimental(-32061, ErrorKind::PrunedPrefix)
305            }
306            Self::WrongStream => ErrorCodeDefinition::experimental(-32062, ErrorKind::WrongStream),
307            Self::UnknownStream => {
308                ErrorCodeDefinition::experimental(-32063, ErrorKind::UnknownStream)
309            }
310            Self::UnknownProjection => {
311                ErrorCodeDefinition::experimental(-32064, ErrorKind::UnknownProjection)
312            }
313            Self::AdmissionNotFound => {
314                ErrorCodeDefinition::experimental(-32070, ErrorKind::AdmissionNotFound)
315            }
316            Self::AdmissionAlreadyResolved => {
317                ErrorCodeDefinition::experimental(-32071, ErrorKind::AdmissionAlreadyResolved)
318            }
319            Self::AdmissionChoiceInvalid => {
320                ErrorCodeDefinition::experimental(-32072, ErrorKind::AdmissionChoiceInvalid)
321            }
322            Self::UsageRefreshRateLimited => ErrorCodeDefinition::experimental_with_retry(
323                -32080,
324                ErrorKind::UsageRefreshRateLimited,
325                Some(true),
326            ),
327            Self::UsageRefreshUnavailable => {
328                ErrorCodeDefinition::experimental(-32081, ErrorKind::UsageRefreshUnavailable)
329            }
330            Self::UsageRefreshFailed => {
331                ErrorCodeDefinition::experimental(-32082, ErrorKind::UsageRefreshFailed)
332            }
333        }
334    }
335
336    /// The wire integer.
337    #[must_use]
338    pub const fn code(self) -> i64 {
339        self.definition().code
340    }
341
342    /// The primary `data.kind` for this code.
343    #[must_use]
344    pub const fn kind(self) -> ErrorKind {
345        self.definition().kind
346    }
347
348    /// Kinds that override the primary on this code: handshake-ordering
349    /// overrides on `-32600`, the experimental gate on `-32601`/`-32602`, the
350    /// permanent page/output budget residuals on `-32603`, and the
351    /// unusable/absent boundary arms on `-32042`.
352    #[must_use]
353    pub const fn override_kinds(self) -> &'static [ErrorKind] {
354        self.definition().override_kinds
355    }
356
357    /// Whether a retry can succeed. `None` for the pre-emption codes, where
358    /// retry is not applicable — the outcome arrives on the view stream.
359    #[must_use]
360    pub const fn retryable(self) -> Option<bool> {
361        self.definition().retryable
362    }
363
364    /// Whether this row renders only in the experimental bundle.
365    #[must_use]
366    pub const fn is_experimental(self) -> bool {
367        self.definition().experimental
368    }
369}