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