muse_code_sdk/msp/error/data.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use super::AdmissionResolutionSummary;
4use super::ApprovalRequirementRef;
5use super::ApprovalResolutionSummary;
6use super::ErrorKind;
7use super::UserInputSettlementSummary;
8use crate::msp::capability::CapabilityName;
9use crate::msp::envelope::JsonObject;
10use serde::Deserialize;
11use serde::Serialize;
12
13/// Deserialize a PRESENT member into the presence-tracking double-`Option`:
14/// serde only calls this when the key exists, so an explicit JSON null becomes
15/// `Some(None)` while an absent key stays `None` via `#[serde(default)]`.
16/// Serialization is symmetric — `Some(None)` emits the explicit null, `None`
17/// skips the key.
18fn present_member<'de, D, T>(deserializer: D) -> Result<Option<Option<T>>, D::Error>
19where
20 D: serde::Deserializer<'de>,
21 T: Deserialize<'de>,
22{
23 Option::<T>::deserialize(deserializer).map(Some)
24}
25
26/// The optional `error.data` object. All members additive-optional; `kind` is
27/// always present when `data` is.
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
29#[serde(rename_all = "camelCase")]
30#[non_exhaustive]
31pub struct ErrorData {
32 /// The stable camelCase category clients branch on.
33 pub kind: ErrorKind,
34 /// Whether retrying can succeed (e.g. `overloaded`). When present,
35 /// overrides the error table row's `retryable` default for this code.
36 #[serde(skip_serializing_if = "Option::is_none")]
37 pub retryable: Option<bool>,
38 /// On `experimentalRequired` errors, the name of the experimental method,
39 /// field or variant the request used, for example
40 /// `turn/start.providerRequestOptions`.
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub descriptor: Option<String>,
43 /// The missing capability, on `capabilityRequired` errors. Typed on the
44 /// grantable registry, so the experimental-only `rawLog` joins the stable
45 /// domain as an additive open-enum extension when it graduates.
46 #[serde(skip_serializing_if = "Option::is_none")]
47 pub capability: Option<CapabilityName>,
48 /// The rejected command's identifier, on `commandRejected` errors. The
49 /// ratified v1 contract pairs it with `reason`, so a client can settle the
50 /// exact command it sent without parsing the message string.
51 #[serde(skip_serializing_if = "Option::is_none")]
52 pub command_id: Option<String>,
53 /// Failure detail vocabulary (e.g. `"missingAnchor"` on `notFound` for a
54 /// missing view-cursor anchor).
55 #[serde(skip_serializing_if = "Option::is_none")]
56 pub reason: Option<String>,
57 /// The stop's refusal kind on a `workflow/cancel` `commandRejected` whose
58 /// stop was refused or whose settlement read failed: `stale_revision`,
59 /// `policy_rejected`, `actor_authority_mismatch`,
60 /// `authority_index_conflict`, `admission_failed`, `persistence_failed`,
61 /// `control_not_signalled`, `post_marker_not_cancellable`,
62 /// `control_outcome_uncertain`, `adapter_contract_violation`,
63 /// `transport_lost` or `reply_lost`.
64 #[serde(skip_serializing_if = "Option::is_none")]
65 pub stop_refusal: Option<String>,
66 /// The exceeded byte limit, on `inputTooLarge` errors.
67 #[serde(skip_serializing_if = "Option::is_none")]
68 pub limit_bytes: Option<u64>,
69 /// The blocked view position on `pageEventTooLarge` errors.
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub view_cursor: Option<String>,
72 /// The item whose stored output was requested, on the `item/readOutput`
73 /// arms (`notFound`, `outputUnavailable`, and the misaligned-offset
74 /// `invalidParams`).
75 #[serde(skip_serializing_if = "Option::is_none")]
76 pub item_id: Option<String>,
77 /// The requested `outputRef.id`, on the same `item/readOutput` arms.
78 #[serde(skip_serializing_if = "Option::is_none")]
79 pub output_ref: Option<String>,
80 /// The stored output's availability on `outputUnavailable` — the durable
81 /// `ToolOutputAvailability` value, read-time-derived when the durable
82 /// record still says `available`.
83 #[serde(skip_serializing_if = "Option::is_none")]
84 pub availability: Option<String>,
85 /// The next provable UTF-8 boundary on a misaligned text-media
86 /// `item/readOutput` read: absent when no boundary is provable from the
87 /// stored bytes ahead.
88 #[serde(skip_serializing_if = "Option::is_none")]
89 pub aligned_next_offset: Option<u64>,
90 /// The configured command-admission bound, on `backpressured` errors.
91 #[serde(skip_serializing_if = "Option::is_none")]
92 pub capacity: Option<u64>,
93 /// Free-form additive detail.
94 #[serde(skip_serializing_if = "Option::is_none")]
95 pub details: Option<JsonObject>,
96 /// Session identity on errors whose lookup is session-scoped.
97 #[serde(skip_serializing_if = "Option::is_none")]
98 pub session_id: Option<String>,
99 /// The original recovery-dependent construction's coherent observation.
100 /// An absent or unusable observation establishes no supported recovery.
101 #[serde(
102 default,
103 deserialize_with = "crate::msp::method::lifecycle::deserialize_optional_recovery_observation",
104 skip_serializing_if = "Option::is_none"
105 )]
106 pub recovery_observation: Option<crate::msp::method::lifecycle::RecoveryObservation>,
107 /// The rejected skill selector on `skillNotFound`.
108 #[serde(skip_serializing_if = "Option::is_none")]
109 pub selector: Option<String>,
110 /// The rejected marketplace name on `marketplaceNotFound` and
111 /// `marketplaceAlreadyExists`; the rejected plugin name on
112 /// `pluginNotFound`.
113 #[serde(skip_serializing_if = "Option::is_none")]
114 pub name: Option<String>,
115 /// The store on `pluginNotFound`.
116 #[serde(skip_serializing_if = "Option::is_none")]
117 pub marketplace: Option<String>,
118 /// The rejected upload id on `uploadNotFound`.
119 #[serde(skip_serializing_if = "Option::is_none")]
120 pub upload_id: Option<String>,
121 /// The oldest servable view position on `viewTruncated`; served as an
122 /// explicit `null` when nothing before the head is servable — the null is
123 /// present on the wire, never a dropped key.
124 #[serde(
125 default,
126 skip_serializing_if = "Option::is_none",
127 deserialize_with = "present_member"
128 )]
129 pub earliest_cursor: Option<Option<String>>,
130 /// The rejected anchor value on `notFound`/`missingAnchor` and the `-32042`
131 /// boundary arms; on `-32042` it is served as an explicit `null` when the
132 /// request named no concrete anchor.
133 #[serde(
134 default,
135 skip_serializing_if = "Option::is_none",
136 deserialize_with = "present_member"
137 )]
138 pub anchor: Option<Option<String>>,
139 /// The latest installed boundary's view cursor on the `-32042` arms —
140 /// always present in the `-32042` JSON and explicitly `null` when no
141 /// boundary exists.
142 #[serde(
143 default,
144 skip_serializing_if = "Option::is_none",
145 deserialize_with = "present_member"
146 )]
147 pub latest_boundary_cursor: Option<Option<String>>,
148 /// Rejected inclusive fork boundary on `forkBoundaryInvalid`.
149 #[serde(skip_serializing_if = "Option::is_none")]
150 pub last_turn_id: Option<String>,
151 /// The branch-seed path the host read before rejecting, on
152 /// branch-validation rejections: one of `runtime_checkpoint_tail`,
153 /// `runtime_full_replay`, `legacy_session_data` — the durable branch-seed
154 /// vocabulary, so the client cites the real seed decision instead of
155 /// guessing at a stale binary.
156 #[serde(skip_serializing_if = "Option::is_none")]
157 pub seed_path: Option<String>,
158 /// Why the branch seed did not use a checkpoint, on the same arms:
159 /// one of `no_usable_checkpoint`, `unsupported_checkpoint_shape`,
160 /// `checkpoint_has_model_visible_tail`, `checkpoint_missing_suffix`;
161 /// absent when the seed used a checkpoint or no fallback was recorded.
162 #[serde(skip_serializing_if = "Option::is_none")]
163 pub seed_fallback_reason: Option<String>,
164 /// Candidate retained paths on `sessionAmbiguous`.
165 #[serde(skip_serializing_if = "Option::is_none")]
166 pub paths: Option<Vec<String>>,
167 /// Approval id on approval errors.
168 #[serde(skip_serializing_if = "Option::is_none")]
169 pub approval_id: Option<String>,
170 /// Winning resolution on `approvalAlreadyResolved`.
171 #[serde(skip_serializing_if = "Option::is_none")]
172 pub resolution: Option<ApprovalResolutionSummary>,
173 /// Current stage token on `approvalRequirementStale`.
174 #[serde(skip_serializing_if = "Option::is_none")]
175 pub current_requirement_id: Option<ApprovalRequirementRef>,
176 /// Rejected server-minted choice on `approvalChoiceInvalid`.
177 #[serde(skip_serializing_if = "Option::is_none")]
178 pub choice_id: Option<String>,
179 /// Prompt identity on user-input errors.
180 #[serde(skip_serializing_if = "Option::is_none")]
181 pub user_input_id: Option<String>,
182 /// Winning settlement on `userInputAlreadySettled`.
183 #[serde(skip_serializing_if = "Option::is_none")]
184 pub settlement: Option<UserInputSettlementSummary>,
185 /// Admission identity on admission errors.
186 #[serde(skip_serializing_if = "Option::is_none")]
187 pub admission_id: Option<String>,
188 /// Winning resolution on `admissionAlreadyResolved`.
189 #[serde(skip_serializing_if = "Option::is_none")]
190 pub admission_resolution: Option<AdmissionResolutionSummary>,
191 /// The rejected raw-log stream, on the anchor arms (`missingAnchor`,
192 /// `prunedPrefix`, `unknownStream`).
193 #[serde(skip_serializing_if = "Option::is_none")]
194 pub stream: Option<crate::msp::view::StreamRef>,
195 /// The rejected raw-log anchor, on `missingAnchor`, `prunedPrefix`,
196 /// and `wrongStream`.
197 #[serde(skip_serializing_if = "Option::is_none")]
198 pub after: Option<crate::msp::view::RecordPosition>,
199 /// The earliest readable position, on `prunedPrefix`.
200 #[serde(skip_serializing_if = "Option::is_none")]
201 pub next_available: Option<crate::msp::view::RecordPosition>,
202 /// The requested stream, on `wrongStream`.
203 #[serde(skip_serializing_if = "Option::is_none")]
204 pub requested_stream: Option<crate::msp::view::StreamRef>,
205 /// The stream the anchor's id actually belongs to, on `wrongStream`.
206 #[serde(skip_serializing_if = "Option::is_none")]
207 pub cursor_stream: Option<crate::msp::view::StreamRef>,
208 /// The unregistered projection name, on `unknownProjection`.
209 #[serde(skip_serializing_if = "Option::is_none")]
210 pub projection: Option<String>,
211 /// The subject repository path, on `workspaceNotTrusted`.
212 #[serde(skip_serializing_if = "Option::is_none")]
213 pub path: Option<String>,
214 /// The rejected settings key path, on the `settings/writeValue` and
215 /// `settings/writeMany` arms: the structural `-32602 invalidParams` shape
216 /// and the `-32030` managed-denial block. File spelling verbatim, like the
217 /// request's `keyPath`.
218 #[serde(skip_serializing_if = "Option::is_none")]
219 pub key_path: Option<String>,
220 /// The rejected edit's index into the `settings/writeMany` `edits`
221 /// array, on the same arms; absent on `settings/writeValue`, which
222 /// carries no edit list.
223 #[serde(skip_serializing_if = "Option::is_none")]
224 pub index: Option<u64>,
225 /// Every too-wide axis with its requested and ceiling values, on
226 /// `limitsAboveMax`.
227 #[serde(skip_serializing_if = "Option::is_none")]
228 pub axes: Option<Vec<crate::msp::method::limits::LimitsAboveMaxAxis>>,
229 /// How long until the next refresh may mint, on `usageRefreshRateLimited`.
230 #[serde(skip_serializing_if = "Option::is_none")]
231 pub retry_after_ms: Option<u64>,
232 /// The mint failure class, on `usageRefreshFailed`: `terminal`, `transient`
233 /// (a 5xx, 429 or network failure; the only class with `retryable: true`),
234 /// `onboarding`, `age_requirement`, `payment_subscription_required` or
235 /// `credential_rejected`. Never credential material.
236 #[serde(skip_serializing_if = "Option::is_none")]
237 pub failure_kind: Option<String>,
238}
239
240impl ErrorData {
241 /// A `kind`-only payload with every optional field `None` — the one
242 /// constructor call sites extend with struct-update syntax, so an
243 /// additive SS field touches this file alone, never every literal.
244 #[must_use]
245 pub const fn new(kind: ErrorKind) -> Self {
246 Self {
247 kind,
248 retryable: None,
249 descriptor: None,
250 capability: None,
251 command_id: None,
252 reason: None,
253 stop_refusal: None,
254 limit_bytes: None,
255 view_cursor: None,
256 item_id: None,
257 output_ref: None,
258 availability: None,
259 aligned_next_offset: None,
260 capacity: None,
261 details: None,
262 session_id: None,
263 recovery_observation: None,
264 selector: None,
265 name: None,
266 marketplace: None,
267 upload_id: None,
268 earliest_cursor: None,
269 anchor: None,
270 latest_boundary_cursor: None,
271 last_turn_id: None,
272 seed_path: None,
273 seed_fallback_reason: None,
274 paths: None,
275 approval_id: None,
276 resolution: None,
277 current_requirement_id: None,
278 choice_id: None,
279 user_input_id: None,
280 settlement: None,
281 admission_id: None,
282 admission_resolution: None,
283 stream: None,
284 after: None,
285 next_available: None,
286 requested_stream: None,
287 cursor_stream: None,
288 projection: None,
289 path: None,
290 key_path: None,
291 index: None,
292 axes: None,
293 retry_after_ms: None,
294 failure_kind: None,
295 }
296 }
297}