muse_code_sdk/msp/method/lifecycle/session_resume_members.rs
1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::view::event::TurnError;
4use crate::msp::view::event::TurnTerminal;
5use serde::Deserialize;
6use serde::Serialize;
7
8mod catch_all;
9
10/// A late-joiner pointer at an unsettled server-initiated request. The full
11/// payloads arrive as re-issued server-to-client requests right after a
12/// `session/resume` response; `session/read` never re-issues them.
13///
14/// The protocol defines two kind-discriminated entry shapes (`{kind:
15/// "approval", approvalId, viewCursor}` / `{kind: "userInput", userInputId,
16/// viewCursor}`). This type is one flat object with both ids optional, as for
17/// `ApprovalSubject` and `TurnInputPart`, because the v1 model names no
18/// object-variant union; the serialized JSON is the same, but the published
19/// schema also accepts `{"kind":"approval","userInputId":…}` and an entry
20/// carrying no id at all. Unlike `TurnInputPart.type`, `kind` here is an OPEN
21/// enum.
22#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24#[non_exhaustive]
25pub struct PendingRequestPointer {
26 /// The discriminator; v1 values `approval` and `userInput`.
27 pub kind: PendingRequestKind,
28 /// Present on an `approval` entry.
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub approval_id: Option<String>,
31 /// Present on a `userInput` entry.
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub user_input_id: Option<String>,
34 /// The cursor the request opened at.
35 pub view_cursor: String,
36}
37
38/// The `pendingRequests` discriminator. Open enum, v1 values `approval` and
39/// `userInput`.
40#[derive(Debug, Clone, PartialEq, Eq)]
41#[non_exhaustive]
42pub enum PendingRequestKind {
43 /// An unsettled approval.
44 Approval,
45 /// An unsettled user-input prompt.
46 UserInput,
47 /// A value from a newer host, kept verbatim so an older client decodes the
48 /// rest of the message. Never construct it with a known word.
49 Unknown(String),
50}
51
52/// `abnormalEnd` on `session/resume`: the load found the session's latest serve
53/// segment without a clean end and recorded (or had already recorded) the
54/// `crash_inferred` backstop.
55#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
56#[serde(rename_all = "camelCase")]
57#[non_exhaustive]
58pub struct AbnormalEnd {
59 /// RFC 3339 time of the session's latest serve activity (the time the
60 /// gate-off notice shows); absent when the log has none.
61 #[serde(default, skip_serializing_if = "Option::is_none")]
62 pub last_activity_at: Option<String>,
63}
64
65/// `cronQuarantine` on `session/resume`: this resume's own load opened the
66/// session cron store and quarantined a corrupt database.
67#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
68#[serde(rename_all = "camelCase")]
69#[non_exhaustive]
70pub struct CronQuarantine {
71 /// Host-local path the corrupt database was moved to; the path the
72 /// gate-off warning shows.
73 pub quarantine_path: String,
74}
75
76/// `missingPredecessor` on `session/resume`: this resume's own load found the
77/// session's committed `SessionStarted` naming a predecessor whose retained log
78/// is not in the session store.
79#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
80#[serde(rename_all = "camelCase")]
81#[non_exhaustive]
82pub struct MissingPredecessor {
83 /// The missing predecessor's session id, the one the gate-off notice
84 /// names.
85 pub session_id: String,
86}
87
88/// `modelIdRefusal` on `session/resume`: the host refused this resume's
89/// `modelId`, so the session opened on its recorded model.
90#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
91#[serde(rename_all = "camelCase")]
92#[non_exhaustive]
93pub struct ModelIdRefusal {
94 /// The `modelId` the resume carried, verbatim.
95 pub model_id: String,
96 /// The host's reason, display text a client shows as is.
97 pub reason: String,
98}
99
100/// `autoRecovery` on `session/resume` (amendment 26387/68619, owner decision
101/// G-23): the outcome of this resume's own load when it ran with the
102/// `resume_auto_recover` gate on (G-37: whatever the session's
103/// `recoveryMode`). A resume's `autoRecover: false` is reported here as
104/// `refused` with reason `optedOut`.
105#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
106#[serde(rename_all = "camelCase")]
107#[non_exhaustive]
108pub struct AutoRecovery {
109 /// What the load did.
110 pub outcome: AutoRecoveryOutcome,
111 /// Present only when `outcome` is `refused`.
112 #[serde(default, skip_serializing_if = "Option::is_none")]
113 pub reason: Option<AutoRecoveryReason>,
114 /// The recovery turn's id (the `turnId` of its `turn/started`); present
115 /// only when `outcome` is `continued`.
116 #[serde(default, skip_serializing_if = "Option::is_none")]
117 pub turn_id: Option<String>,
118}
119
120/// The `autoRecovery` outcome (the amendment's decision table). Open enum.
121#[derive(Debug, Clone, PartialEq, Eq)]
122#[non_exhaustive]
123pub enum AutoRecoveryOutcome {
124 /// The recovery turn re-made the interrupted request.
125 Continued,
126 /// The previous run ended cleanly, or the session was live here.
127 NotCrashed,
128 /// Nothing was in flight and no Goal was Active; the hold is released.
129 NothingToContinue,
130 /// A Goal was Active between turns and continues.
131 GoalResumed,
132 /// An answerable question is pending and keeps waiting.
133 AwaitingUser,
134 /// Auto-recover did not proceed (it failed, or the resume opted out); the
135 /// governing rules hold applies.
136 Refused,
137 /// A value introduced by a newer server, kept verbatim so an older
138 /// client can report it without failing the parse.
139 Unknown(String),
140}
141
142impl AutoRecoveryOutcome {
143 /// The exact wire spelling, including a value this build does not know.
144 #[must_use]
145 pub fn as_str(&self) -> &str {
146 match self {
147 Self::Continued => "continued",
148 Self::NotCrashed => "notCrashed",
149 Self::NothingToContinue => "nothingToContinue",
150 Self::GoalResumed => "goalResumed",
151 Self::AwaitingUser => "awaitingUser",
152 Self::Refused => "refused",
153 Self::Unknown(value) => value,
154 }
155 }
156}
157
158impl Serialize for AutoRecoveryOutcome {
159 fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
160 serializer.serialize_str(self.as_str())
161 }
162}
163
164impl<'de> Deserialize<'de> for AutoRecoveryOutcome {
165 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
166 let value = String::deserialize(deserializer)?;
167 Ok(match value.as_str() {
168 "continued" => Self::Continued,
169 "notCrashed" => Self::NotCrashed,
170 "nothingToContinue" => Self::NothingToContinue,
171 "goalResumed" => Self::GoalResumed,
172 "awaitingUser" => Self::AwaitingUser,
173 "refused" => Self::Refused,
174 _ => Self::Unknown(value),
175 })
176 }
177}
178
179/// Why `autoRecovery` was `refused`. Open enum.
180#[derive(Debug, Clone, PartialEq, Eq)]
181#[non_exhaustive]
182pub enum AutoRecoveryReason {
183 /// A run was interrupted under an Active Goal whose crash pause this
184 /// host could not hold back.
185 ContinuationUnavailable,
186 /// A Goal was Active between turns and this host could not hold back
187 /// its crash pause.
188 GoalResumeUnavailable,
189 /// The Goal store could not be read.
190 GoalUnavailable,
191 /// The open reopened from a resume-fallback recovery checkpoint, whose
192 /// history no longer holds the interrupted work.
193 ResumeFallback,
194 /// A recovery steer a crash left undelivered could not be withdrawn.
195 StaleSteerNotWithdrawn,
196 /// The recovery steer could not be saved.
197 SteerNotSaved,
198 /// The resume asked for no automatic recovery (`autoRecover: false`,
199 /// owner decision G-37); nothing failed.
200 OptedOut,
201 /// A value introduced by a newer server, kept verbatim so an older
202 /// client can report it without failing the parse.
203 Unknown(String),
204}
205
206impl AutoRecoveryReason {
207 /// The exact wire spelling, including a value this build does not know.
208 #[must_use]
209 pub fn as_str(&self) -> &str {
210 match self {
211 Self::ContinuationUnavailable => "continuationUnavailable",
212 Self::GoalResumeUnavailable => "goalResumeUnavailable",
213 Self::GoalUnavailable => "goalUnavailable",
214 Self::ResumeFallback => "resumeFallback",
215 Self::StaleSteerNotWithdrawn => "staleSteerNotWithdrawn",
216 Self::SteerNotSaved => "steerNotSaved",
217 Self::OptedOut => "optedOut",
218 Self::Unknown(value) => value,
219 }
220 }
221}
222
223impl Serialize for AutoRecoveryReason {
224 fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
225 serializer.serialize_str(self.as_str())
226 }
227}
228
229impl<'de> Deserialize<'de> for AutoRecoveryReason {
230 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
231 let value = String::deserialize(deserializer)?;
232 Ok(match value.as_str() {
233 "continuationUnavailable" => Self::ContinuationUnavailable,
234 "goalResumeUnavailable" => Self::GoalResumeUnavailable,
235 "goalUnavailable" => Self::GoalUnavailable,
236 "resumeFallback" => Self::ResumeFallback,
237 "staleSteerNotWithdrawn" => Self::StaleSteerNotWithdrawn,
238 "steerNotSaved" => Self::SteerNotSaved,
239 "optedOut" => Self::OptedOut,
240 _ => Self::Unknown(value),
241 })
242 }
243}
244
245/// The cold recall seed on `session/resume` and `session/read` results: at most
246/// one, the latest blocked Main prompt — exactly the host's mirror of
247/// `prompt_recovery::replay::ReplayInput`'s choice.
248#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
249#[serde(rename_all = "camelCase")]
250#[non_exhaustive]
251pub struct BlockedPrompt {
252 /// The exact submitted prompt, verbatim — no truncation, no
253 /// normalization; recall fidelity requires exactness.
254 pub text: String,
255}
256
257/// The last `turn/completed` the session-view fold applied, restated on
258/// `session/resume` and `session/read` so a reopened session can report a
259/// failed last turn.
260#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
261#[serde(rename_all = "camelCase")]
262#[non_exhaustive]
263pub struct LastTurn {
264 /// The turn's id, as on its `turn/completed`; clients deduplicate a live
265 /// `turn/completed` against this member by it.
266 pub turn_id: String,
267 /// The turn's terminal.
268 pub terminal: TurnTerminal,
269 /// Copied when the `turn/completed` carried it; a synthesized host-death
270 /// `failed` terminal carries only this (`crash`, `crash_inferred`, or
271 /// `incomplete`). Free display text: clients never branch on it.
272 #[serde(default, skip_serializing_if = "Option::is_none")]
273 pub reason: Option<String>,
274 /// Copied when the `turn/completed` carried it: runtime `failed` terminals
275 /// do, host-death `failed` terminals do not.
276 #[serde(default, skip_serializing_if = "Option::is_none")]
277 pub error: Option<TurnError>,
278}