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