Skip to main content

muse_code_sdk/msp/method/lifecycle/
runtime_worktree.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// The runtime-owned git worktree a child session runs in, mirrored from the
7/// `subagent.worktree.*` records on its parent's log. The four enums are open:
8/// clients treat an unknown value as unknown.
9#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11#[non_exhaustive]
12pub struct RuntimeWorktree {
13    /// The recorded worktree root, verbatim (recorded history; serving it
14    /// never probes the path).
15    pub worktree_root: String,
16    /// The commit the worktree was created from.
17    pub base_commit: String,
18    /// The head commit the active lease recorded.
19    pub head_commit: String,
20    /// Who owns the worktree.
21    pub ownership: RuntimeWorktreeOwnership,
22    /// How the worktree is cleaned up.
23    pub cleanup_policy: RuntimeWorktreeCleanupPolicy,
24    /// Where the worktree's cleanup stands.
25    pub cleanup_state: RuntimeWorktreeCleanupState,
26    /// True exactly when the parent's uncommitted changes were recorded as
27    /// excluded from the checkout.
28    pub parent_dirty_excluded: bool,
29    /// Why cleanup kept the worktree or failed, as the cleanup outcome recorded
30    /// it; absent when the outcome records no reason.
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub cleanup_reason: Option<RuntimeWorktreeCleanupReason>,
33    /// The cleanup outcome's recorded diagnostic, verbatim; absent when the
34    /// outcome records none.
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub cleanup_diagnostic: Option<String>,
37}
38
39/// Who owns a session's worktree. The set is open, so newer hosts may send
40/// other values.
41#[derive(Debug, Clone, PartialEq, Eq)]
42#[non_exhaustive]
43pub enum RuntimeWorktreeOwnership {
44    /// `runtimeOwned`: the runtime created the worktree and owns its cleanup.
45    RuntimeOwned,
46    /// A value from a newer host, kept verbatim so an older client decodes the
47    /// rest of the message. Excluded from the generated schema while the enum
48    /// stays declared open; never construct it with a known word.
49    Unknown(String),
50}
51
52/// How a session's worktree is cleaned up. The set is open, so newer hosts
53/// may send other values.
54#[derive(Debug, Clone, PartialEq, Eq)]
55#[non_exhaustive]
56pub enum RuntimeWorktreeCleanupPolicy {
57    /// `removeIfClean`: the runtime removes the worktree when it has no
58    /// uncommitted changes, and keeps it otherwise.
59    RemoveIfClean,
60    /// A value from a newer host, kept verbatim so an older client decodes the
61    /// rest of the message. Excluded from the generated schema while the enum
62    /// stays declared open; never construct it with a known word.
63    Unknown(String),
64}
65
66/// Where a session's worktree cleanup stands. The set is open, so newer
67/// hosts may send other values.
68#[derive(Debug, Clone, PartialEq, Eq)]
69#[non_exhaustive]
70pub enum RuntimeWorktreeCleanupState {
71    /// `active`: no cleanup outcome is recorded yet.
72    Active,
73    /// `cleaned`: the runtime removed the worktree.
74    Cleaned,
75    /// `retained`: the runtime kept the worktree.
76    Retained,
77    /// `cleanupFailed`: the runtime tried to remove the worktree and failed.
78    CleanupFailed,
79    /// A value from a newer host, kept verbatim so an older client decodes the
80    /// rest of the message. Excluded from the generated schema while the enum
81    /// stays declared open; never construct it with a known word.
82    Unknown(String),
83}
84
85/// Why a session's worktree cleanup kept the worktree or failed. The set is
86/// open, so newer hosts may send other values.
87#[derive(Debug, Clone, PartialEq, Eq)]
88#[non_exhaustive]
89pub enum RuntimeWorktreeCleanupReason {
90    /// `dirtyWorktree`: the worktree had uncommitted changes, so cleanup kept
91    /// it.
92    DirtyWorktree,
93    /// `headChanged`: the worktree's head moved off the recorded head, so
94    /// cleanup kept it.
95    HeadChanged,
96    /// `pathEscape`: the recorded worktree path's identity changed, so
97    /// cleanup kept it.
98    PathEscape,
99    /// `cleanupFailed`: removing the worktree failed.
100    CleanupFailed,
101    /// `uncertainLeaseState`: reconciliation could not prove the lease
102    /// state, so cleanup failed.
103    UncertainLeaseState,
104    /// A value from a newer host, kept verbatim so an older client decodes the
105    /// rest of the message. Excluded from the generated schema while the enum
106    /// stays declared open; never construct it with a known word.
107    Unknown(String),
108}