// @generated — Generated by `cargo xtask machine-codegen --all`.
#![allow(
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::implicit_clone,
    clippy::unnecessary_cast,
    clippy::redundant_clone,
    clippy::zero_sized_map_values
)]

pub fn schema() -> meerkat_machine_schema::MachineSchema {
    meerkat_machine_schema::catalog::dsl::dsl_session_document_machine()
}

#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum LiveSessionAuthorityKind {
    #[default]
    #[serde(rename = "LiveAuthoritative")]
    LiveAuthoritative,
    #[serde(rename = "DurableAuthoritative")]
    DurableAuthoritative,
}
impl LiveSessionAuthorityKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::LiveAuthoritative => "LiveAuthoritative",
            Self::DurableAuthoritative => "DurableAuthoritative",
        }
    }
}
impl std::convert::TryFrom<&str> for LiveSessionAuthorityKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "LiveAuthoritative" => Ok(Self::LiveAuthoritative),
            "DurableAuthoritative" => Ok(Self::DurableAuthoritative),
            other => Err(format!("invalid LiveSessionAuthorityKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for LiveSessionAuthorityKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for LiveSessionAuthorityKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum LiveSessionAuthorityReason {
    #[default]
    #[serde(rename = "StoredArchived")]
    StoredArchived,
    #[serde(rename = "LiveUncommittedTranscript")]
    LiveUncommittedTranscript,
    #[serde(rename = "RuntimeSystemContextDiverged")]
    RuntimeSystemContextDiverged,
    #[serde(rename = "StoredTranscriptRevisionDiverged")]
    StoredTranscriptRevisionDiverged,
}
impl LiveSessionAuthorityReason {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::StoredArchived => "StoredArchived",
            Self::LiveUncommittedTranscript => "LiveUncommittedTranscript",
            Self::RuntimeSystemContextDiverged => "RuntimeSystemContextDiverged",
            Self::StoredTranscriptRevisionDiverged => "StoredTranscriptRevisionDiverged",
        }
    }
}
impl std::convert::TryFrom<&str> for LiveSessionAuthorityReason {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "StoredArchived" => Ok(Self::StoredArchived),
            "LiveUncommittedTranscript" => Ok(Self::LiveUncommittedTranscript),
            "RuntimeSystemContextDiverged" => Ok(Self::RuntimeSystemContextDiverged),
            "StoredTranscriptRevisionDiverged" => Ok(Self::StoredTranscriptRevisionDiverged),
            other => Err(format!(
                "invalid LiveSessionAuthorityReason value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for LiveSessionAuthorityReason {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for LiveSessionAuthorityReason {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum ObservedSessionTailKind {
    #[default]
    #[serde(rename = "Empty")]
    Empty,
    #[serde(rename = "System")]
    System,
    #[serde(rename = "SystemNotice")]
    SystemNotice,
    #[serde(rename = "User")]
    User,
    #[serde(rename = "BlockAssistant")]
    BlockAssistant,
    #[serde(rename = "ToolResults")]
    ToolResults,
}
impl ObservedSessionTailKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Empty => "Empty",
            Self::System => "System",
            Self::SystemNotice => "SystemNotice",
            Self::User => "User",
            Self::BlockAssistant => "BlockAssistant",
            Self::ToolResults => "ToolResults",
        }
    }
}
impl std::convert::TryFrom<&str> for ObservedSessionTailKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Empty" => Ok(Self::Empty),
            "System" => Ok(Self::System),
            "SystemNotice" => Ok(Self::SystemNotice),
            "User" => Ok(Self::User),
            "BlockAssistant" => Ok(Self::BlockAssistant),
            "ToolResults" => Ok(Self::ToolResults),
            other => Err(format!("invalid ObservedSessionTailKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for ObservedSessionTailKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for ObservedSessionTailKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum PendingContinuationDisposition {
    #[default]
    #[serde(rename = "RunPending")]
    RunPending,
    #[serde(rename = "NoPendingBoundary")]
    NoPendingBoundary,
}
impl PendingContinuationDisposition {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::RunPending => "RunPending",
            Self::NoPendingBoundary => "NoPendingBoundary",
        }
    }
}
impl std::convert::TryFrom<&str> for PendingContinuationDisposition {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "RunPending" => Ok(Self::RunPending),
            "NoPendingBoundary" => Ok(Self::NoPendingBoundary),
            other => Err(format!(
                "invalid PendingContinuationDisposition value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for PendingContinuationDisposition {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for PendingContinuationDisposition {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum PendingContinuationPublicTerminal {
    #[default]
    #[serde(rename = "NoPendingBoundary")]
    NoPendingBoundary,
}
impl PendingContinuationPublicTerminal {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::NoPendingBoundary => "NoPendingBoundary",
        }
    }
}
impl std::convert::TryFrom<&str> for PendingContinuationPublicTerminal {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "NoPendingBoundary" => Ok(Self::NoPendingBoundary),
            other => Err(format!(
                "invalid PendingContinuationPublicTerminal value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for PendingContinuationPublicTerminal {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for PendingContinuationPublicTerminal {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum RealtimeTranscriptLaneKind {
    #[default]
    #[serde(rename = "Display")]
    Display,
    #[serde(rename = "Spoken")]
    Spoken,
}
impl RealtimeTranscriptLaneKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Display => "Display",
            Self::Spoken => "Spoken",
        }
    }
}
impl std::convert::TryFrom<&str> for RealtimeTranscriptLaneKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Display" => Ok(Self::Display),
            "Spoken" => Ok(Self::Spoken),
            other => Err(format!(
                "invalid RealtimeTranscriptLaneKind value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for RealtimeTranscriptLaneKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for RealtimeTranscriptLaneKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum RealtimeTranscriptMaterializeDecision {
    #[default]
    #[serde(rename = "Wait")]
    Wait,
    #[serde(rename = "MarkSkipped")]
    MarkSkipped,
    #[serde(rename = "MaterializeUser")]
    MaterializeUser,
    #[serde(rename = "MaterializeAssistant")]
    MaterializeAssistant,
}
impl RealtimeTranscriptMaterializeDecision {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Wait => "Wait",
            Self::MarkSkipped => "MarkSkipped",
            Self::MaterializeUser => "MaterializeUser",
            Self::MaterializeAssistant => "MaterializeAssistant",
        }
    }
}
impl std::convert::TryFrom<&str> for RealtimeTranscriptMaterializeDecision {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Wait" => Ok(Self::Wait),
            "MarkSkipped" => Ok(Self::MarkSkipped),
            "MaterializeUser" => Ok(Self::MaterializeUser),
            "MaterializeAssistant" => Ok(Self::MaterializeAssistant),
            other => Err(format!(
                "invalid RealtimeTranscriptMaterializeDecision value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for RealtimeTranscriptMaterializeDecision {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for RealtimeTranscriptMaterializeDecision {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum RealtimeTranscriptRoleKind {
    #[default]
    #[serde(rename = "User")]
    User,
    #[serde(rename = "Assistant")]
    Assistant,
}
impl RealtimeTranscriptRoleKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::User => "User",
            Self::Assistant => "Assistant",
        }
    }
}
impl std::convert::TryFrom<&str> for RealtimeTranscriptRoleKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "User" => Ok(Self::User),
            "Assistant" => Ok(Self::Assistant),
            other => Err(format!(
                "invalid RealtimeTranscriptRoleKind value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for RealtimeTranscriptRoleKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for RealtimeTranscriptRoleKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum RealtimeTranscriptStopReasonKind {
    #[default]
    #[serde(rename = "Cancelled")]
    Cancelled,
    #[serde(rename = "ToolUse")]
    ToolUse,
    #[serde(rename = "Other")]
    Other,
}
impl RealtimeTranscriptStopReasonKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Cancelled => "Cancelled",
            Self::ToolUse => "ToolUse",
            Self::Other => "Other",
        }
    }
}
impl std::convert::TryFrom<&str> for RealtimeTranscriptStopReasonKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Cancelled" => Ok(Self::Cancelled),
            "ToolUse" => Ok(Self::ToolUse),
            "Other" => Ok(Self::Other),
            other => Err(format!(
                "invalid RealtimeTranscriptStopReasonKind value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for RealtimeTranscriptStopReasonKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for RealtimeTranscriptStopReasonKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum ResumeOverrideRejection {
    #[default]
    #[serde(rename = "ProviderRequiresModel")]
    ProviderRequiresModel,
    #[serde(rename = "BuildOnlyAfterFirstTurn")]
    BuildOnlyAfterFirstTurn,
}
impl ResumeOverrideRejection {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::ProviderRequiresModel => "ProviderRequiresModel",
            Self::BuildOnlyAfterFirstTurn => "BuildOnlyAfterFirstTurn",
        }
    }
}
impl std::convert::TryFrom<&str> for ResumeOverrideRejection {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "ProviderRequiresModel" => Ok(Self::ProviderRequiresModel),
            "BuildOnlyAfterFirstTurn" => Ok(Self::BuildOnlyAfterFirstTurn),
            other => Err(format!("invalid ResumeOverrideRejection value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for ResumeOverrideRejection {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for ResumeOverrideRejection {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum ResumeProviderSelection {
    #[default]
    #[serde(rename = "RecomputeFromModel")]
    RecomputeFromModel,
    #[serde(rename = "UseOverride")]
    UseOverride,
    #[serde(rename = "UseStored")]
    UseStored,
}
impl ResumeProviderSelection {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::RecomputeFromModel => "RecomputeFromModel",
            Self::UseOverride => "UseOverride",
            Self::UseStored => "UseStored",
        }
    }
}
impl std::convert::TryFrom<&str> for ResumeProviderSelection {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "RecomputeFromModel" => Ok(Self::RecomputeFromModel),
            "UseOverride" => Ok(Self::UseOverride),
            "UseStored" => Ok(Self::UseStored),
            other => Err(format!("invalid ResumeProviderSelection value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for ResumeProviderSelection {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for ResumeProviderSelection {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum ResumeSelfHostedSelection {
    #[default]
    #[serde(rename = "Clear")]
    Clear,
    #[serde(rename = "Retain")]
    Retain,
}
impl ResumeSelfHostedSelection {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Clear => "Clear",
            Self::Retain => "Retain",
        }
    }
}
impl std::convert::TryFrom<&str> for ResumeSelfHostedSelection {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Clear" => Ok(Self::Clear),
            "Retain" => Ok(Self::Retain),
            other => Err(format!("invalid ResumeSelfHostedSelection value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for ResumeSelfHostedSelection {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for ResumeSelfHostedSelection {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum RuntimeProjectionRollbackDisposition {
    #[default]
    #[serde(rename = "RejectDivergent")]
    RejectDivergent,
    #[serde(rename = "RebuildToAuthority")]
    RebuildToAuthority,
}
impl RuntimeProjectionRollbackDisposition {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::RejectDivergent => "RejectDivergent",
            Self::RebuildToAuthority => "RebuildToAuthority",
        }
    }
}
impl std::convert::TryFrom<&str> for RuntimeProjectionRollbackDisposition {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "RejectDivergent" => Ok(Self::RejectDivergent),
            "RebuildToAuthority" => Ok(Self::RebuildToAuthority),
            other => Err(format!(
                "invalid RuntimeProjectionRollbackDisposition value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for RuntimeProjectionRollbackDisposition {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for RuntimeProjectionRollbackDisposition {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SessionArchiveDisposition {
    #[default]
    #[serde(rename = "Archive")]
    Archive,
    #[serde(rename = "AlreadyArchived")]
    AlreadyArchived,
}
impl SessionArchiveDisposition {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Archive => "Archive",
            Self::AlreadyArchived => "AlreadyArchived",
        }
    }
}
impl std::convert::TryFrom<&str> for SessionArchiveDisposition {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Archive" => Ok(Self::Archive),
            "AlreadyArchived" => Ok(Self::AlreadyArchived),
            other => Err(format!("invalid SessionArchiveDisposition value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for SessionArchiveDisposition {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SessionArchiveDisposition {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SessionDocumentLifecycle {
    #[default]
    #[serde(rename = "Active")]
    Active,
    #[serde(rename = "Archived")]
    Archived,
}
impl SessionDocumentLifecycle {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Active => "Active",
            Self::Archived => "Archived",
        }
    }
}
impl std::convert::TryFrom<&str> for SessionDocumentLifecycle {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Active" => Ok(Self::Active),
            "Archived" => Ok(Self::Archived),
            other => Err(format!("invalid SessionDocumentLifecycle value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for SessionDocumentLifecycle {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SessionDocumentLifecycle {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SessionFirstTurnPhase {
    #[default]
    #[serde(rename = "Inactive")]
    Inactive,
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Consumed")]
    Consumed,
}
impl SessionFirstTurnPhase {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Inactive => "Inactive",
            Self::Pending => "Pending",
            Self::Consumed => "Consumed",
        }
    }
}
impl std::convert::TryFrom<&str> for SessionFirstTurnPhase {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Inactive" => Ok(Self::Inactive),
            "Pending" => Ok(Self::Pending),
            "Consumed" => Ok(Self::Consumed),
            other => Err(format!("invalid SessionFirstTurnPhase value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for SessionFirstTurnPhase {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SessionFirstTurnPhase {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct SessionId(pub String);
impl From<String> for SessionId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for SessionId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for SessionId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SessionInitialPromptStageDecision {
    #[default]
    #[serde(rename = "Clear")]
    Clear,
    #[serde(rename = "Store")]
    Store,
}
impl SessionInitialPromptStageDecision {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Clear => "Clear",
            Self::Store => "Store",
        }
    }
}
impl std::convert::TryFrom<&str> for SessionInitialPromptStageDecision {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Clear" => Ok(Self::Clear),
            "Store" => Ok(Self::Store),
            other => Err(format!(
                "invalid SessionInitialPromptStageDecision value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for SessionInitialPromptStageDecision {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SessionInitialPromptStageDecision {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SessionSystemPromptSource {
    #[default]
    #[serde(rename = "DirectMutation")]
    DirectMutation,
    #[serde(rename = "ExplicitBuild")]
    ExplicitBuild,
    #[serde(rename = "DefaultBuild")]
    DefaultBuild,
    #[serde(rename = "WasmDefaultBuild")]
    WasmDefaultBuild,
    #[serde(rename = "RuntimeContextAppend")]
    RuntimeContextAppend,
    #[serde(rename = "RuntimeSteerCleanup")]
    RuntimeSteerCleanup,
}
impl SessionSystemPromptSource {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::DirectMutation => "DirectMutation",
            Self::ExplicitBuild => "ExplicitBuild",
            Self::DefaultBuild => "DefaultBuild",
            Self::WasmDefaultBuild => "WasmDefaultBuild",
            Self::RuntimeContextAppend => "RuntimeContextAppend",
            Self::RuntimeSteerCleanup => "RuntimeSteerCleanup",
        }
    }
}
impl std::convert::TryFrom<&str> for SessionSystemPromptSource {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "DirectMutation" => Ok(Self::DirectMutation),
            "ExplicitBuild" => Ok(Self::ExplicitBuild),
            "DefaultBuild" => Ok(Self::DefaultBuild),
            "WasmDefaultBuild" => Ok(Self::WasmDefaultBuild),
            "RuntimeContextAppend" => Ok(Self::RuntimeContextAppend),
            "RuntimeSteerCleanup" => Ok(Self::RuntimeSteerCleanup),
            other => Err(format!("invalid SessionSystemPromptSource value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for SessionSystemPromptSource {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SessionSystemPromptSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SystemContextAppendDecision {
    #[default]
    #[serde(rename = "Staged")]
    Staged,
    #[serde(rename = "Duplicate")]
    Duplicate,
    #[serde(rename = "RejectEmpty")]
    RejectEmpty,
    #[serde(rename = "RejectConflict")]
    RejectConflict,
}
impl SystemContextAppendDecision {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Staged => "Staged",
            Self::Duplicate => "Duplicate",
            Self::RejectEmpty => "RejectEmpty",
            Self::RejectConflict => "RejectConflict",
        }
    }
}
impl std::convert::TryFrom<&str> for SystemContextAppendDecision {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Staged" => Ok(Self::Staged),
            "Duplicate" => Ok(Self::Duplicate),
            "RejectEmpty" => Ok(Self::RejectEmpty),
            "RejectConflict" => Ok(Self::RejectConflict),
            other => Err(format!(
                "invalid SystemContextAppendDecision value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for SystemContextAppendDecision {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SystemContextAppendDecision {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SystemContextPersistAppendAdmission {
    #[default]
    #[serde(rename = "Reject")]
    Reject,
    #[serde(rename = "Admit")]
    Admit,
}
impl SystemContextPersistAppendAdmission {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Reject => "Reject",
            Self::Admit => "Admit",
        }
    }
}
impl std::convert::TryFrom<&str> for SystemContextPersistAppendAdmission {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Reject" => Ok(Self::Reject),
            "Admit" => Ok(Self::Admit),
            other => Err(format!(
                "invalid SystemContextPersistAppendAdmission value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for SystemContextPersistAppendAdmission {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SystemContextPersistAppendAdmission {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum SystemContextSource {
    #[default]
    #[serde(rename = "Normal")]
    Normal,
    #[serde(rename = "RuntimeSteer")]
    RuntimeSteer,
}
impl SystemContextSource {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Normal => "Normal",
            Self::RuntimeSteer => "RuntimeSteer",
        }
    }
}
impl std::convert::TryFrom<&str> for SystemContextSource {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Normal" => Ok(Self::Normal),
            "RuntimeSteer" => Ok(Self::RuntimeSteer),
            other => Err(format!("invalid SystemContextSource value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for SystemContextSource {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for SystemContextSource {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum TranscriptEditKind {
    #[default]
    #[serde(rename = "Fork")]
    Fork,
    #[serde(rename = "Rewrite")]
    Rewrite,
}
impl TranscriptEditKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Fork => "Fork",
            Self::Rewrite => "Rewrite",
        }
    }
}
impl std::convert::TryFrom<&str> for TranscriptEditKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Fork" => Ok(Self::Fork),
            "Rewrite" => Ok(Self::Rewrite),
            other => Err(format!("invalid TranscriptEditKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for TranscriptEditKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for TranscriptEditKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

pub trait Context {}
pub struct EmptyContext;
impl Context for EmptyContext {}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Phase {
    Ready,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct State {
    pub phase: Phase,
    pub session_first_turn_phase: std::collections::BTreeMap<SessionId, SessionFirstTurnPhase>,
    pub session_pending_initial_prompt_present: std::collections::BTreeMap<SessionId, bool>,
    pub session_pending_tool_results_count: std::collections::BTreeMap<SessionId, u64>,
    pub session_lifecycle_terminal: std::collections::BTreeMap<SessionId, SessionDocumentLifecycle>,
}
impl Default for State {
    fn default() -> Self {
        initial_state()
    }
}

pub mod inputs {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MarkSessionInitialTurnPending {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StartSessionInitialTurn {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StageSessionInitialPrompt {
        pub session_id: SessionId,
        pub prompt_has_content: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StageSessionToolResults {
        pub session_id: SessionId,
        pub result_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ConsumeSessionDeferredInputs {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreSessionConsumedInputs {
        pub session_id: SessionId,
        pub restore_first_turn_pending: bool,
        pub pending_initial_prompt_present: bool,
        pub pending_tool_result_message_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecoverSessionFirstTurnPhase {
        pub session_id: SessionId,
        pub phase: SessionFirstTurnPhase,
        pub pending_initial_prompt_present: bool,
        pub pending_tool_result_message_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveSessionFirstTurnOverridesAllowed {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveSystemContextAppend {
        pub trimmed_text_byte_count: u64,
        pub idempotency_key_present: bool,
        pub existing_key_matches: bool,
        pub existing_key_conflicts: bool,
        pub active_turn_scoped: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveSystemContextPendingApplyItem {
        pub source_kind: SystemContextSource,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveSystemContextSteerCleanupItem {
        pub source_kind: SystemContextSource,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreSystemContextSnapshot {
        pub active_keys_have_known_pending_or_seen: bool,
        pub seen_keys_match_known_appends: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveSystemContextPersistAppendAdmission {
        pub has_previous: bool,
        pub content_identical: bool,
        pub content_extends_previous: bool,
        pub appended_starts_with_separator: bool,
        pub incoming_is_runtime_context_append: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeItemObserved {
        pub role: RealtimeTranscriptRoleKind,
        pub response_discarded: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeItemSkipped {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeUserTranscriptFinal {
        pub text_present: bool,
        pub segment_empty: bool,
        pub segment_matches: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeAssistantDelta {
        pub response_id_valid: bool,
        pub response_discarded: bool,
        pub delta_id_present: bool,
        pub delta_id_seen: bool,
        pub item_has_text: bool,
        pub current_lane: RealtimeTranscriptLaneKind,
        pub requested_lane: RealtimeTranscriptLaneKind,
        pub response_completed: bool,
        pub text_after_write_present: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeAssistantTextReplacement {
        pub response_id_valid: bool,
        pub response_discarded: bool,
        pub item_materialized: bool,
        pub item_has_text: bool,
        pub current_lane: RealtimeTranscriptLaneKind,
        pub requested_lane: RealtimeTranscriptLaneKind,
        pub response_completed: bool,
        pub text_after_replace_present: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeAssistantTurnCompleted {
        pub response_id_valid: bool,
        pub response_discarded: bool,
        pub stop_reason: RealtimeTranscriptStopReasonKind,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeAssistantTurnInterrupted {
        pub response_id_valid: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRealtimeMaterializeCandidate {
        pub item_materialized: bool,
        pub predecessor_materialized: bool,
        pub item_skipped: bool,
        pub item_ready: bool,
        pub item_text_present: bool,
        pub role: RealtimeTranscriptRoleKind,
        pub response_id_present: bool,
        pub completion_present: bool,
        pub completion_usage_consumed: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreRealtimeTranscriptState {
        pub item_count: u64,
        pub first_seen_count: u64,
        pub first_seen_unique_count: u64,
        pub every_item_has_order_entry: bool,
        pub every_order_entry_has_item: bool,
        pub all_identity_fields_valid: bool,
        pub all_delta_ids_valid: bool,
        pub all_completion_response_ids_valid: bool,
        pub all_discarded_response_ids_valid: bool,
        pub all_materialized_items_were_ready_or_skipped: bool,
        pub all_assistant_items_have_response_unless_skipped: bool,
        pub all_ready_assistant_items_have_completion_or_are_skipped: bool,
        pub all_materialized_assistant_completions_consumed: bool,
        pub all_completed_assistant_text_items_are_ready_or_materialized_or_skipped: bool,
        pub all_discarded_assistant_items_are_skipped_or_materialized: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeSessionMetadataPersist {
        pub schema_version: u64,
        pub model_present: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeSessionBuildStatePersist {
        pub mob_tool_authority_context_present: bool,
        pub mob_tool_authority_context_generated: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreSessionBuildState {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeSystemPromptMutation {
        pub source: SessionSystemPromptSource,
        pub prompt_present: bool,
        pub prompt_byte_count: u64,
        pub replacing_existing: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolvePendingContinuation {
        pub session_tail: ObservedSessionTailKind,
        pub staged_tool_result_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeSessionResumeOverrides {
        pub provider_override_present: bool,
        pub model_override_present: bool,
        pub has_build_only_overrides: bool,
        pub first_turn_phase: SessionFirstTurnPhase,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ClassifyLiveSessionAuthority {
        pub stored_transcript_diverged: bool,
        pub live_has_uncommitted_transcript: bool,
        pub runtime_system_context_diverged: bool,
        pub stored_is_archived: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecoverSessionFromStore {
        pub session_id: SessionId,
        pub has_metadata: bool,
        pub has_build_state: bool,
        pub runtime_projection_quarantined: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveRuntimeProjectionRollback {
        pub session_id: SessionId,
        pub row_continues_authority: bool,
        pub row_is_runtime_checkpoint: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ApplyPendingToolResults {
        pub session_id: SessionId,
        pub result_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct TranscriptEdit {
        pub session_id: SessionId,
        pub fork_or_rewrite_directive: TranscriptEditKind,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecoverSessionLifecycleTerminal {
        pub session_id: SessionId,
        pub terminal: SessionDocumentLifecycle,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ArchiveSessionDocument {
        pub session_id: SessionId,
        pub runtime_backed: bool,
        pub durable_snapshot_present: bool,
        pub runtime_session_registered: bool,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Input {
    MarkSessionInitialTurnPending(inputs::MarkSessionInitialTurnPending),
    StartSessionInitialTurn(inputs::StartSessionInitialTurn),
    StageSessionInitialPrompt(inputs::StageSessionInitialPrompt),
    StageSessionToolResults(inputs::StageSessionToolResults),
    ConsumeSessionDeferredInputs(inputs::ConsumeSessionDeferredInputs),
    RestoreSessionConsumedInputs(inputs::RestoreSessionConsumedInputs),
    RecoverSessionFirstTurnPhase(inputs::RecoverSessionFirstTurnPhase),
    ResolveSessionFirstTurnOverridesAllowed(inputs::ResolveSessionFirstTurnOverridesAllowed),
    ResolveSystemContextAppend(inputs::ResolveSystemContextAppend),
    ResolveSystemContextPendingApplyItem(inputs::ResolveSystemContextPendingApplyItem),
    ResolveSystemContextSteerCleanupItem(inputs::ResolveSystemContextSteerCleanupItem),
    RestoreSystemContextSnapshot(inputs::RestoreSystemContextSnapshot),
    ResolveSystemContextPersistAppendAdmission(inputs::ResolveSystemContextPersistAppendAdmission),
    ResolveRealtimeItemObserved(inputs::ResolveRealtimeItemObserved),
    ResolveRealtimeItemSkipped(inputs::ResolveRealtimeItemSkipped),
    ResolveRealtimeUserTranscriptFinal(inputs::ResolveRealtimeUserTranscriptFinal),
    ResolveRealtimeAssistantDelta(inputs::ResolveRealtimeAssistantDelta),
    ResolveRealtimeAssistantTextReplacement(inputs::ResolveRealtimeAssistantTextReplacement),
    ResolveRealtimeAssistantTurnCompleted(inputs::ResolveRealtimeAssistantTurnCompleted),
    ResolveRealtimeAssistantTurnInterrupted(inputs::ResolveRealtimeAssistantTurnInterrupted),
    ResolveRealtimeMaterializeCandidate(inputs::ResolveRealtimeMaterializeCandidate),
    RestoreRealtimeTranscriptState(inputs::RestoreRealtimeTranscriptState),
    AuthorizeSessionMetadataPersist(inputs::AuthorizeSessionMetadataPersist),
    AuthorizeSessionBuildStatePersist(inputs::AuthorizeSessionBuildStatePersist),
    RestoreSessionBuildState(inputs::RestoreSessionBuildState),
    AuthorizeSystemPromptMutation(inputs::AuthorizeSystemPromptMutation),
    ResolvePendingContinuation(inputs::ResolvePendingContinuation),
    AuthorizeSessionResumeOverrides(inputs::AuthorizeSessionResumeOverrides),
    ClassifyLiveSessionAuthority(inputs::ClassifyLiveSessionAuthority),
    RecoverSessionFromStore(inputs::RecoverSessionFromStore),
    ResolveRuntimeProjectionRollback(inputs::ResolveRuntimeProjectionRollback),
    ApplyPendingToolResults(inputs::ApplyPendingToolResults),
    TranscriptEdit(inputs::TranscriptEdit),
    RecoverSessionLifecycleTerminal(inputs::RecoverSessionLifecycleTerminal),
    ArchiveSessionDocument(inputs::ArchiveSessionDocument),
}
impl Input {
    pub fn kind(&self) -> InputKind {
        match self {
            Self::MarkSessionInitialTurnPending(_) => InputKind::MarkSessionInitialTurnPending,
            Self::StartSessionInitialTurn(_) => InputKind::StartSessionInitialTurn,
            Self::StageSessionInitialPrompt(_) => InputKind::StageSessionInitialPrompt,
            Self::StageSessionToolResults(_) => InputKind::StageSessionToolResults,
            Self::ConsumeSessionDeferredInputs(_) => InputKind::ConsumeSessionDeferredInputs,
            Self::RestoreSessionConsumedInputs(_) => InputKind::RestoreSessionConsumedInputs,
            Self::RecoverSessionFirstTurnPhase(_) => InputKind::RecoverSessionFirstTurnPhase,
            Self::ResolveSessionFirstTurnOverridesAllowed(_) => {
                InputKind::ResolveSessionFirstTurnOverridesAllowed
            }
            Self::ResolveSystemContextAppend(_) => InputKind::ResolveSystemContextAppend,
            Self::ResolveSystemContextPendingApplyItem(_) => {
                InputKind::ResolveSystemContextPendingApplyItem
            }
            Self::ResolveSystemContextSteerCleanupItem(_) => {
                InputKind::ResolveSystemContextSteerCleanupItem
            }
            Self::RestoreSystemContextSnapshot(_) => InputKind::RestoreSystemContextSnapshot,
            Self::ResolveSystemContextPersistAppendAdmission(_) => {
                InputKind::ResolveSystemContextPersistAppendAdmission
            }
            Self::ResolveRealtimeItemObserved(_) => InputKind::ResolveRealtimeItemObserved,
            Self::ResolveRealtimeItemSkipped(_) => InputKind::ResolveRealtimeItemSkipped,
            Self::ResolveRealtimeUserTranscriptFinal(_) => {
                InputKind::ResolveRealtimeUserTranscriptFinal
            }
            Self::ResolveRealtimeAssistantDelta(_) => InputKind::ResolveRealtimeAssistantDelta,
            Self::ResolveRealtimeAssistantTextReplacement(_) => {
                InputKind::ResolveRealtimeAssistantTextReplacement
            }
            Self::ResolveRealtimeAssistantTurnCompleted(_) => {
                InputKind::ResolveRealtimeAssistantTurnCompleted
            }
            Self::ResolveRealtimeAssistantTurnInterrupted(_) => {
                InputKind::ResolveRealtimeAssistantTurnInterrupted
            }
            Self::ResolveRealtimeMaterializeCandidate(_) => {
                InputKind::ResolveRealtimeMaterializeCandidate
            }
            Self::RestoreRealtimeTranscriptState(_) => InputKind::RestoreRealtimeTranscriptState,
            Self::AuthorizeSessionMetadataPersist(_) => InputKind::AuthorizeSessionMetadataPersist,
            Self::AuthorizeSessionBuildStatePersist(_) => {
                InputKind::AuthorizeSessionBuildStatePersist
            }
            Self::RestoreSessionBuildState(_) => InputKind::RestoreSessionBuildState,
            Self::AuthorizeSystemPromptMutation(_) => InputKind::AuthorizeSystemPromptMutation,
            Self::ResolvePendingContinuation(_) => InputKind::ResolvePendingContinuation,
            Self::AuthorizeSessionResumeOverrides(_) => InputKind::AuthorizeSessionResumeOverrides,
            Self::ClassifyLiveSessionAuthority(_) => InputKind::ClassifyLiveSessionAuthority,
            Self::RecoverSessionFromStore(_) => InputKind::RecoverSessionFromStore,
            Self::ResolveRuntimeProjectionRollback(_) => {
                InputKind::ResolveRuntimeProjectionRollback
            }
            Self::ApplyPendingToolResults(_) => InputKind::ApplyPendingToolResults,
            Self::TranscriptEdit(_) => InputKind::TranscriptEdit,
            Self::RecoverSessionLifecycleTerminal(_) => InputKind::RecoverSessionLifecycleTerminal,
            Self::ArchiveSessionDocument(_) => InputKind::ArchiveSessionDocument,
        }
    }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum InputKind {
    MarkSessionInitialTurnPending,
    StartSessionInitialTurn,
    StageSessionInitialPrompt,
    StageSessionToolResults,
    ConsumeSessionDeferredInputs,
    RestoreSessionConsumedInputs,
    RecoverSessionFirstTurnPhase,
    ResolveSessionFirstTurnOverridesAllowed,
    ResolveSystemContextAppend,
    ResolveSystemContextPendingApplyItem,
    ResolveSystemContextSteerCleanupItem,
    RestoreSystemContextSnapshot,
    ResolveSystemContextPersistAppendAdmission,
    ResolveRealtimeItemObserved,
    ResolveRealtimeItemSkipped,
    ResolveRealtimeUserTranscriptFinal,
    ResolveRealtimeAssistantDelta,
    ResolveRealtimeAssistantTextReplacement,
    ResolveRealtimeAssistantTurnCompleted,
    ResolveRealtimeAssistantTurnInterrupted,
    ResolveRealtimeMaterializeCandidate,
    RestoreRealtimeTranscriptState,
    AuthorizeSessionMetadataPersist,
    AuthorizeSessionBuildStatePersist,
    RestoreSessionBuildState,
    AuthorizeSystemPromptMutation,
    ResolvePendingContinuation,
    AuthorizeSessionResumeOverrides,
    ClassifyLiveSessionAuthority,
    RecoverSessionFromStore,
    ResolveRuntimeProjectionRollback,
    ApplyPendingToolResults,
    TranscriptEdit,
    RecoverSessionLifecycleTerminal,
    ArchiveSessionDocument,
}

pub mod effects {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionFirstTurnPhaseResolved {
        pub phase: SessionFirstTurnPhase,
        pub was_pending: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionFirstTurnOverridesResolved {
        pub allowed: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionInitialPromptStageResolved {
        pub decision: SessionInitialPromptStageDecision,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionToolResultsStageResolved {
        pub accepted_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionConsumedInputsRestoreResolved {
        pub restore_first_turn_pending: bool,
        pub restore_initial_prompt: bool,
        pub restore_tool_results: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionFirstTurnPhaseRecovered {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemContextAppendResolved {
        pub decision: SystemContextAppendDecision,
        pub active_turn_scoped: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemContextPendingApplyItemResolved {
        pub promote_to_applied: bool,
        pub mark_seen_applied: bool,
        pub remove_seen: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemContextSteerCleanupItemResolved {
        pub discard: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemContextSnapshotRestoreAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemContextPersistAppendAdmissionResolved {
        pub admission: SystemContextPersistAppendAdmission,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RealtimeTranscriptEventResolved {
        pub observe_item: bool,
        pub observe_skipped: bool,
        pub write_user_segment: bool,
        pub append_assistant_segment: bool,
        pub replace_assistant_segment: bool,
        pub promote_lane: bool,
        pub mark_item_ready: bool,
        pub record_delta_id: bool,
        pub remove_completion: bool,
        pub record_completion: bool,
        pub discard_response: bool,
        pub discard_response_by_lane: bool,
        pub mark_response_ready: bool,
        pub materialize_ready_items: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RealtimeMaterializeCandidateResolved {
        pub decision: RealtimeTranscriptMaterializeDecision,
        pub consume_usage: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RealtimeTranscriptSnapshotRestoreAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionMetadataPersistAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionBuildStatePersistAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionBuildStateRestoreAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SystemPromptMutationAuthorized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PendingContinuationResolved {
        pub disposition: PendingContinuationDisposition,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PendingContinuationPublicTerminalResolved {
        pub terminal: PendingContinuationPublicTerminal,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionResumeOverridesAuthorized {
        pub provider_selection: ResumeProviderSelection,
        pub self_hosted_selection: ResumeSelfHostedSelection,
        pub provider_overridden: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionResumeOverridesRejected {
        pub reason: ResumeOverrideRejection,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct LiveSessionAuthorityClassified {
        pub authority: LiveSessionAuthorityKind,
        pub reason: LiveSessionAuthorityReason,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionStoreRecoverySourceResolved {
        pub recoverable: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RuntimeProjectionRollbackResolved {
        pub disposition: RuntimeProjectionRollbackDisposition,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionToolResultsApplied {
        pub session_id: SessionId,
        pub applied_count: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct TranscriptRewriteCommitted {
        pub kind: TranscriptEditKind,
        pub success: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionLifecycleTerminalRecovered {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionArchiveResolved {
        pub disposition: SessionArchiveDisposition,
        pub write_document: bool,
        pub retire_runtime: bool,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Effect {
    SessionFirstTurnPhaseResolved(effects::SessionFirstTurnPhaseResolved),
    SessionFirstTurnOverridesResolved(effects::SessionFirstTurnOverridesResolved),
    SessionInitialPromptStageResolved(effects::SessionInitialPromptStageResolved),
    SessionToolResultsStageResolved(effects::SessionToolResultsStageResolved),
    SessionConsumedInputsRestoreResolved(effects::SessionConsumedInputsRestoreResolved),
    SessionFirstTurnPhaseRecovered(effects::SessionFirstTurnPhaseRecovered),
    SystemContextAppendResolved(effects::SystemContextAppendResolved),
    SystemContextPendingApplyItemResolved(effects::SystemContextPendingApplyItemResolved),
    SystemContextSteerCleanupItemResolved(effects::SystemContextSteerCleanupItemResolved),
    SystemContextSnapshotRestoreAuthorized(effects::SystemContextSnapshotRestoreAuthorized),
    SystemContextPersistAppendAdmissionResolved(
        effects::SystemContextPersistAppendAdmissionResolved,
    ),
    RealtimeTranscriptEventResolved(effects::RealtimeTranscriptEventResolved),
    RealtimeMaterializeCandidateResolved(effects::RealtimeMaterializeCandidateResolved),
    RealtimeTranscriptSnapshotRestoreAuthorized(
        effects::RealtimeTranscriptSnapshotRestoreAuthorized,
    ),
    SessionMetadataPersistAuthorized(effects::SessionMetadataPersistAuthorized),
    SessionBuildStatePersistAuthorized(effects::SessionBuildStatePersistAuthorized),
    SessionBuildStateRestoreAuthorized(effects::SessionBuildStateRestoreAuthorized),
    SystemPromptMutationAuthorized(effects::SystemPromptMutationAuthorized),
    PendingContinuationResolved(effects::PendingContinuationResolved),
    PendingContinuationPublicTerminalResolved(effects::PendingContinuationPublicTerminalResolved),
    SessionResumeOverridesAuthorized(effects::SessionResumeOverridesAuthorized),
    SessionResumeOverridesRejected(effects::SessionResumeOverridesRejected),
    LiveSessionAuthorityClassified(effects::LiveSessionAuthorityClassified),
    SessionStoreRecoverySourceResolved(effects::SessionStoreRecoverySourceResolved),
    RuntimeProjectionRollbackResolved(effects::RuntimeProjectionRollbackResolved),
    SessionToolResultsApplied(effects::SessionToolResultsApplied),
    TranscriptRewriteCommitted(effects::TranscriptRewriteCommitted),
    SessionLifecycleTerminalRecovered(effects::SessionLifecycleTerminalRecovered),
    SessionArchiveResolved(effects::SessionArchiveResolved),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum EffectKind {
    SessionFirstTurnPhaseResolved,
    SessionFirstTurnOverridesResolved,
    SessionInitialPromptStageResolved,
    SessionToolResultsStageResolved,
    SessionConsumedInputsRestoreResolved,
    SessionFirstTurnPhaseRecovered,
    SystemContextAppendResolved,
    SystemContextPendingApplyItemResolved,
    SystemContextSteerCleanupItemResolved,
    SystemContextSnapshotRestoreAuthorized,
    SystemContextPersistAppendAdmissionResolved,
    RealtimeTranscriptEventResolved,
    RealtimeMaterializeCandidateResolved,
    RealtimeTranscriptSnapshotRestoreAuthorized,
    SessionMetadataPersistAuthorized,
    SessionBuildStatePersistAuthorized,
    SessionBuildStateRestoreAuthorized,
    SystemPromptMutationAuthorized,
    PendingContinuationResolved,
    PendingContinuationPublicTerminalResolved,
    SessionResumeOverridesAuthorized,
    SessionResumeOverridesRejected,
    LiveSessionAuthorityClassified,
    SessionStoreRecoverySourceResolved,
    RuntimeProjectionRollbackResolved,
    SessionToolResultsApplied,
    TranscriptRewriteCommitted,
    SessionLifecycleTerminalRecovered,
    SessionArchiveResolved,
}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionId {
    MarkSessionInitialTurnPendingInactiveOrPending,
    MarkSessionInitialTurnPendingConsumed,
    StartSessionInitialTurnPending,
    StartSessionInitialTurnInactive,
    StartSessionInitialTurnConsumed,
    ResolveSessionFirstTurnOverridesAllowed,
    ResolveSessionFirstTurnOverridesDenied,
    StageSessionInitialPromptStore,
    StageSessionInitialPromptClear,
    StageSessionToolResults,
    ConsumeSessionDeferredInputsPending,
    ConsumeSessionDeferredInputsInactive,
    ConsumeSessionDeferredInputsConsumed,
    RestoreSessionConsumedInputs,
    RestoreSessionConsumedInputsNoPhaseRollback,
    RecoverSessionFirstTurnPhase,
    ResolveSystemContextAppendEmpty,
    ResolveSystemContextAppendConflict,
    ResolveSystemContextAppendDuplicate,
    ResolveSystemContextAppendNew,
    ResolveSystemContextPersistAppendAdmissionAdmit,
    ResolveSystemContextPersistAppendAdmissionReject,
    ResolveSystemContextPendingApplyItemRuntimeSteer,
    ResolveSystemContextPendingApplyItemNormal,
    ResolveSystemContextSteerCleanupItemRuntimeSteer,
    ResolveSystemContextSteerCleanupItemNormal,
    RestoreSystemContextSnapshot,
    ResolveRealtimeItemObservedDiscardedAssistant,
    ResolveRealtimeItemObservedPresent,
    ResolveRealtimeItemSkipped,
    ResolveRealtimeUserTranscriptFinalEmpty,
    ResolveRealtimeUserTranscriptFinalStore,
    ResolveRealtimeUserTranscriptFinalReplayOrConflict,
    ResolveRealtimeAssistantDeltaInvalidOrDuplicate,
    ResolveRealtimeAssistantDeltaDiscarded,
    ResolveRealtimeAssistantDeltaLaneConflict,
    ResolveRealtimeAssistantDeltaAccepted,
    ResolveRealtimeAssistantReplacementInvalid,
    ResolveRealtimeAssistantReplacementDiscarded,
    ResolveRealtimeAssistantReplacementLocked,
    ResolveRealtimeAssistantReplacementLaneConflict,
    ResolveRealtimeAssistantReplacementAccepted,
    ResolveRealtimeAssistantTurnCompletedInvalid,
    ResolveRealtimeAssistantTurnCompletedDiscard,
    ResolveRealtimeAssistantTurnCompletedToolUse,
    ResolveRealtimeAssistantTurnCompletedRecord,
    ResolveRealtimeAssistantTurnInterruptedInvalid,
    ResolveRealtimeAssistantTurnInterruptedValid,
    ResolveRealtimeMaterializeAlreadyDone,
    ResolveRealtimeMaterializeWaitForPredecessor,
    ResolveRealtimeMaterializeSkipped,
    ResolveRealtimeMaterializeWaitForReadyText,
    ResolveRealtimeMaterializeUser,
    ResolveRealtimeMaterializeAssistant,
    ResolveRealtimeMaterializeAssistantMissingCompletion,
    AuthorizeRestoreRealtimeTranscriptState,
    AuthorizeSessionMetadataPersist,
    AuthorizeSessionBuildStatePersist,
    RestoreSessionBuildState,
    AuthorizeSystemPromptMutation,
    ResolvePendingContinuationWithBoundary,
    ResolvePendingContinuationWithoutBoundary,
    AuthorizeSessionResumeOverridesRejectProviderRequiresModel,
    AuthorizeSessionResumeOverridesRejectBuildOnlyAfterFirstTurn,
    AuthorizeSessionResumeOverridesAcceptRecomputeProvider,
    AuthorizeSessionResumeOverridesAcceptUseOverride,
    AuthorizeSessionResumeOverridesAcceptRetainStored,
    ClassifyLiveSessionAuthorityLive,
    ClassifyLiveSessionAuthorityDurableArchived,
    ClassifyLiveSessionAuthorityDurableUncommitted,
    ClassifyLiveSessionAuthorityDurableSystemContext,
    ClassifyLiveSessionAuthorityDurableRevision,
    RecoverSessionFromStoreAuthorized,
    RecoverSessionFromStoreUnrecoverable,
    ResolveRuntimeProjectionRollbackRebuild,
    ResolveRuntimeProjectionRollbackReject,
    ApplyPendingToolResults,
    TranscriptEditFork,
    TranscriptEditRewrite,
    RecoverSessionLifecycleTerminal,
    ArchiveSessionDocumentActive,
    ArchiveSessionDocumentAlreadyArchived,
    ArchiveSessionDocumentCompleteRetire,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum GuardId {
    None,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum HelperId {
    None,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct GuardRejection {
    pub transition_id: TransitionId,
    pub guard_id: GuardId,
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TriggerDiscriminant {
    Input(InputKind),
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionRefusal {
    NoMatchingTransition {
        phase: Phase,
        trigger: TriggerDiscriminant,
    },
    GuardRejected {
        rejections: Vec<GuardRejection>,
    },
    AmbiguousTransition {
        transitions: Vec<TransitionId>,
    },
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum KernelError {
    ContextViolation {
        transition_id: TransitionId,
        detail: String,
    },
    HelperEvaluation {
        helper_id: HelperId,
        detail: String,
    },
    CodegenInvariant {
        detail: String,
    },
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionError {
    Refusal(TransitionRefusal),
    Kernel(KernelError),
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct Outcome {
    pub transition_id: TransitionId,
    pub next_state: State,
    pub effects: Vec<Effect>,
}

pub mod helpers {
    #[allow(unused_imports)]
    use super::*;
    pub fn none<C: Context>(_: &State, context: &C) -> Result<(), KernelError> {
        let _ = context;
        Ok(())
    }
}

pub fn initial_state() -> State {
    State {
        phase: Phase::Ready,
        session_first_turn_phase: Default::default(),
        session_pending_initial_prompt_present: Default::default(),
        session_pending_tool_results_count: Default::default(),
        session_lifecycle_terminal: Default::default(),
    }
}
