// @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
)]

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

#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct AgentIdentity(pub String);
impl From<String> for AgentIdentity {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for AgentIdentity {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for AgentIdentity {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct AgentRuntimeId(pub String);
impl From<String> for AgentRuntimeId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for AgentRuntimeId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for AgentRuntimeId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct BranchId(pub String);
impl From<String> for BranchId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for BranchId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for BranchId {
    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 CollectionPolicyKind {
    #[default]
    #[serde(rename = "All")]
    All,
    #[serde(rename = "Any")]
    Any,
    #[serde(rename = "Quorum")]
    Quorum,
}
impl CollectionPolicyKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::All => "All",
            Self::Any => "Any",
            Self::Quorum => "Quorum",
        }
    }
}
impl std::convert::TryFrom<&str> for CollectionPolicyKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "All" => Ok(Self::All),
            "Any" => Ok(Self::Any),
            "Quorum" => Ok(Self::Quorum),
            other => Err(format!("invalid CollectionPolicyKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for CollectionPolicyKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for CollectionPolicyKind {
    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 DependencyMode {
    #[default]
    #[serde(rename = "All")]
    All,
    #[serde(rename = "Any")]
    Any,
}
impl DependencyMode {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::All => "All",
            Self::Any => "Any",
        }
    }
}
impl std::convert::TryFrom<&str> for DependencyMode {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "All" => Ok(Self::All),
            "Any" => Ok(Self::Any),
            other => Err(format!("invalid DependencyMode value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for DependencyMode {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for DependencyMode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
pub type ExternalPeerEdge = meerkat_machine_schema::catalog::dsl::mob_machine::ExternalPeerEdge;
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct FenceToken(pub u64);
impl From<u64> for FenceToken {
    fn from(value: u64) -> Self {
        Self(value)
    }
}
impl std::fmt::Display for FenceToken {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum FlowFrameReducerCommandKind {
    #[default]
    #[serde(rename = "StartRootFrame")]
    StartRootFrame,
    #[serde(rename = "StartBodyFrame")]
    StartBodyFrame,
    #[serde(rename = "AdmitNextReadyNode")]
    AdmitNextReadyNode,
    #[serde(rename = "CompleteNode")]
    CompleteNode,
    #[serde(rename = "RecordNodeOutput")]
    RecordNodeOutput,
    #[serde(rename = "FailNode")]
    FailNode,
    #[serde(rename = "SkipNode")]
    SkipNode,
    #[serde(rename = "CancelNode")]
    CancelNode,
    #[serde(rename = "SealFrame")]
    SealFrame,
}
impl FlowFrameReducerCommandKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::StartRootFrame => "StartRootFrame",
            Self::StartBodyFrame => "StartBodyFrame",
            Self::AdmitNextReadyNode => "AdmitNextReadyNode",
            Self::CompleteNode => "CompleteNode",
            Self::RecordNodeOutput => "RecordNodeOutput",
            Self::FailNode => "FailNode",
            Self::SkipNode => "SkipNode",
            Self::CancelNode => "CancelNode",
            Self::SealFrame => "SealFrame",
        }
    }
}
impl std::convert::TryFrom<&str> for FlowFrameReducerCommandKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "StartRootFrame" => Ok(Self::StartRootFrame),
            "StartBodyFrame" => Ok(Self::StartBodyFrame),
            "AdmitNextReadyNode" => Ok(Self::AdmitNextReadyNode),
            "CompleteNode" => Ok(Self::CompleteNode),
            "RecordNodeOutput" => Ok(Self::RecordNodeOutput),
            "FailNode" => Ok(Self::FailNode),
            "SkipNode" => Ok(Self::SkipNode),
            "CancelNode" => Ok(Self::CancelNode),
            "SealFrame" => Ok(Self::SealFrame),
            other => Err(format!(
                "invalid FlowFrameReducerCommandKind value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for FlowFrameReducerCommandKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FlowFrameReducerCommandKind {
    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 FlowNodeId(pub String);
impl From<String> for FlowNodeId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for FlowNodeId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for FlowNodeId {
    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 FlowNodeKind {
    #[default]
    #[serde(rename = "Step")]
    Step,
    #[serde(rename = "Loop")]
    Loop,
}
impl FlowNodeKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Step => "Step",
            Self::Loop => "Loop",
        }
    }
}
impl std::convert::TryFrom<&str> for FlowNodeKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Step" => Ok(Self::Step),
            "Loop" => Ok(Self::Loop),
            other => Err(format!("invalid FlowNodeKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for FlowNodeKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FlowNodeKind {
    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 FlowRunReducerCommandKind {
    #[default]
    #[serde(rename = "CreateRun")]
    CreateRun,
    #[serde(rename = "StartRun")]
    StartRun,
    #[serde(rename = "DispatchStep")]
    DispatchStep,
    #[serde(rename = "CompleteStep")]
    CompleteStep,
    #[serde(rename = "RecordStepOutput")]
    RecordStepOutput,
    #[serde(rename = "ConditionPassed")]
    ConditionPassed,
    #[serde(rename = "ConditionRejected")]
    ConditionRejected,
    #[serde(rename = "FailStep")]
    FailStep,
    #[serde(rename = "SkipStep")]
    SkipStep,
    #[serde(rename = "ProjectFrameStepStatus")]
    ProjectFrameStepStatus,
    #[serde(rename = "CancelStep")]
    CancelStep,
    #[serde(rename = "RegisterTargets")]
    RegisterTargets,
    #[serde(rename = "RecordTargetSuccess")]
    RecordTargetSuccess,
    #[serde(rename = "RecordTargetTerminalFailure")]
    RecordTargetTerminalFailure,
    #[serde(rename = "RecordTargetCanceled")]
    RecordTargetCanceled,
    #[serde(rename = "RecordTargetFailure")]
    RecordTargetFailure,
    #[serde(rename = "RegisterReadyFrame")]
    RegisterReadyFrame,
    #[serde(rename = "PumpNodeScheduler")]
    PumpNodeScheduler,
    #[serde(rename = "RegisterPendingBodyFrame")]
    RegisterPendingBodyFrame,
    #[serde(rename = "PumpFrameScheduler")]
    PumpFrameScheduler,
    #[serde(rename = "NodeExecutionReleased")]
    NodeExecutionReleased,
    #[serde(rename = "FrameTerminated")]
    FrameTerminated,
    #[serde(rename = "TerminalizeCompleted")]
    TerminalizeCompleted,
    #[serde(rename = "TerminalizeFailed")]
    TerminalizeFailed,
    #[serde(rename = "TerminalizeCanceled")]
    TerminalizeCanceled,
}
impl FlowRunReducerCommandKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::CreateRun => "CreateRun",
            Self::StartRun => "StartRun",
            Self::DispatchStep => "DispatchStep",
            Self::CompleteStep => "CompleteStep",
            Self::RecordStepOutput => "RecordStepOutput",
            Self::ConditionPassed => "ConditionPassed",
            Self::ConditionRejected => "ConditionRejected",
            Self::FailStep => "FailStep",
            Self::SkipStep => "SkipStep",
            Self::ProjectFrameStepStatus => "ProjectFrameStepStatus",
            Self::CancelStep => "CancelStep",
            Self::RegisterTargets => "RegisterTargets",
            Self::RecordTargetSuccess => "RecordTargetSuccess",
            Self::RecordTargetTerminalFailure => "RecordTargetTerminalFailure",
            Self::RecordTargetCanceled => "RecordTargetCanceled",
            Self::RecordTargetFailure => "RecordTargetFailure",
            Self::RegisterReadyFrame => "RegisterReadyFrame",
            Self::PumpNodeScheduler => "PumpNodeScheduler",
            Self::RegisterPendingBodyFrame => "RegisterPendingBodyFrame",
            Self::PumpFrameScheduler => "PumpFrameScheduler",
            Self::NodeExecutionReleased => "NodeExecutionReleased",
            Self::FrameTerminated => "FrameTerminated",
            Self::TerminalizeCompleted => "TerminalizeCompleted",
            Self::TerminalizeFailed => "TerminalizeFailed",
            Self::TerminalizeCanceled => "TerminalizeCanceled",
        }
    }
}
impl std::convert::TryFrom<&str> for FlowRunReducerCommandKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "CreateRun" => Ok(Self::CreateRun),
            "StartRun" => Ok(Self::StartRun),
            "DispatchStep" => Ok(Self::DispatchStep),
            "CompleteStep" => Ok(Self::CompleteStep),
            "RecordStepOutput" => Ok(Self::RecordStepOutput),
            "ConditionPassed" => Ok(Self::ConditionPassed),
            "ConditionRejected" => Ok(Self::ConditionRejected),
            "FailStep" => Ok(Self::FailStep),
            "SkipStep" => Ok(Self::SkipStep),
            "ProjectFrameStepStatus" => Ok(Self::ProjectFrameStepStatus),
            "CancelStep" => Ok(Self::CancelStep),
            "RegisterTargets" => Ok(Self::RegisterTargets),
            "RecordTargetSuccess" => Ok(Self::RecordTargetSuccess),
            "RecordTargetTerminalFailure" => Ok(Self::RecordTargetTerminalFailure),
            "RecordTargetCanceled" => Ok(Self::RecordTargetCanceled),
            "RecordTargetFailure" => Ok(Self::RecordTargetFailure),
            "RegisterReadyFrame" => Ok(Self::RegisterReadyFrame),
            "PumpNodeScheduler" => Ok(Self::PumpNodeScheduler),
            "RegisterPendingBodyFrame" => Ok(Self::RegisterPendingBodyFrame),
            "PumpFrameScheduler" => Ok(Self::PumpFrameScheduler),
            "NodeExecutionReleased" => Ok(Self::NodeExecutionReleased),
            "FrameTerminated" => Ok(Self::FrameTerminated),
            "TerminalizeCompleted" => Ok(Self::TerminalizeCompleted),
            "TerminalizeFailed" => Ok(Self::TerminalizeFailed),
            "TerminalizeCanceled" => Ok(Self::TerminalizeCanceled),
            other => Err(format!("invalid FlowRunReducerCommandKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for FlowRunReducerCommandKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FlowRunReducerCommandKind {
    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 FlowRunStatus {
    #[default]
    #[serde(rename = "Absent")]
    Absent,
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Running")]
    Running,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Canceled")]
    Canceled,
}
impl FlowRunStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Absent => "Absent",
            Self::Pending => "Pending",
            Self::Running => "Running",
            Self::Completed => "Completed",
            Self::Failed => "Failed",
            Self::Canceled => "Canceled",
        }
    }
}
impl std::convert::TryFrom<&str> for FlowRunStatus {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Absent" => Ok(Self::Absent),
            "Pending" => Ok(Self::Pending),
            "Running" => Ok(Self::Running),
            "Completed" => Ok(Self::Completed),
            "Failed" => Ok(Self::Failed),
            "Canceled" => Ok(Self::Canceled),
            other => Err(format!("invalid FlowRunStatus value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for FlowRunStatus {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FlowRunStatus {
    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 FrameId(pub String);
impl From<String> for FrameId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for FrameId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for FrameId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct FrameNodeKey(pub String);
impl From<String> for FrameNodeKey {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for FrameNodeKey {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for FrameNodeKey {
    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 FrameScope {
    #[default]
    #[serde(rename = "Root")]
    Root,
    #[serde(rename = "Body")]
    Body,
}
impl FrameScope {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Root => "Root",
            Self::Body => "Body",
        }
    }
}
impl std::convert::TryFrom<&str> for FrameScope {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Root" => Ok(Self::Root),
            "Body" => Ok(Self::Body),
            other => Err(format!("invalid FrameScope value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for FrameScope {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FrameScope {
    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 FrameStatus {
    #[default]
    #[serde(rename = "Running")]
    Running,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Canceled")]
    Canceled,
}
impl FrameStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Running => "Running",
            Self::Completed => "Completed",
            Self::Failed => "Failed",
            Self::Canceled => "Canceled",
        }
    }
}
impl std::convert::TryFrom<&str> for FrameStatus {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Running" => Ok(Self::Running),
            "Completed" => Ok(Self::Completed),
            "Failed" => Ok(Self::Failed),
            "Canceled" => Ok(Self::Canceled),
            other => Err(format!("invalid FrameStatus value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for FrameStatus {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for FrameStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct Generation(pub u64);
impl From<u64> for Generation {
    fn from(value: u64) -> Self {
        Self(value)
    }
}
impl std::fmt::Display for Generation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum KickoffIntent {
    #[default]
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Starting")]
    Starting,
    #[serde(rename = "Started")]
    Started,
    #[serde(rename = "CallbackPending")]
    CallbackPending,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Cancelled")]
    Cancelled,
}
impl KickoffIntent {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Pending => "Pending",
            Self::Starting => "Starting",
            Self::Started => "Started",
            Self::CallbackPending => "CallbackPending",
            Self::Failed => "Failed",
            Self::Cancelled => "Cancelled",
        }
    }
}
impl std::convert::TryFrom<&str> for KickoffIntent {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Pending" => Ok(Self::Pending),
            "Starting" => Ok(Self::Starting),
            "Started" => Ok(Self::Started),
            "CallbackPending" => Ok(Self::CallbackPending),
            "Failed" => Ok(Self::Failed),
            "Cancelled" => Ok(Self::Cancelled),
            other => Err(format!("invalid KickoffIntent value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for KickoffIntent {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for KickoffIntent {
    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 KickoffPhase {
    #[default]
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Starting")]
    Starting,
    #[serde(rename = "CallbackPending")]
    CallbackPending,
    #[serde(rename = "Started")]
    Started,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Cancelled")]
    Cancelled,
}
impl KickoffPhase {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Pending => "Pending",
            Self::Starting => "Starting",
            Self::CallbackPending => "CallbackPending",
            Self::Started => "Started",
            Self::Failed => "Failed",
            Self::Cancelled => "Cancelled",
        }
    }
}
impl std::convert::TryFrom<&str> for KickoffPhase {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Pending" => Ok(Self::Pending),
            "Starting" => Ok(Self::Starting),
            "CallbackPending" => Ok(Self::CallbackPending),
            "Started" => Ok(Self::Started),
            "Failed" => Ok(Self::Failed),
            "Cancelled" => Ok(Self::Cancelled),
            other => Err(format!("invalid KickoffPhase value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for KickoffPhase {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for KickoffPhase {
    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 LoopId(pub String);
impl From<String> for LoopId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for LoopId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for LoopId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct LoopInstanceId(pub String);
impl From<String> for LoopInstanceId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for LoopInstanceId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for LoopInstanceId {
    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 LoopIterationReducerCommandKind {
    #[default]
    #[serde(rename = "StartLoop")]
    StartLoop,
    #[serde(rename = "BodyFrameStarted")]
    BodyFrameStarted,
    #[serde(rename = "BodyFrameCompleted")]
    BodyFrameCompleted,
    #[serde(rename = "BodyFrameFailed")]
    BodyFrameFailed,
    #[serde(rename = "BodyFrameCanceled")]
    BodyFrameCanceled,
    #[serde(rename = "UntilConditionMet")]
    UntilConditionMet,
    #[serde(rename = "UntilConditionFailed")]
    UntilConditionFailed,
    #[serde(rename = "CancelLoop")]
    CancelLoop,
}
impl LoopIterationReducerCommandKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::StartLoop => "StartLoop",
            Self::BodyFrameStarted => "BodyFrameStarted",
            Self::BodyFrameCompleted => "BodyFrameCompleted",
            Self::BodyFrameFailed => "BodyFrameFailed",
            Self::BodyFrameCanceled => "BodyFrameCanceled",
            Self::UntilConditionMet => "UntilConditionMet",
            Self::UntilConditionFailed => "UntilConditionFailed",
            Self::CancelLoop => "CancelLoop",
        }
    }
}
impl std::convert::TryFrom<&str> for LoopIterationReducerCommandKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "StartLoop" => Ok(Self::StartLoop),
            "BodyFrameStarted" => Ok(Self::BodyFrameStarted),
            "BodyFrameCompleted" => Ok(Self::BodyFrameCompleted),
            "BodyFrameFailed" => Ok(Self::BodyFrameFailed),
            "BodyFrameCanceled" => Ok(Self::BodyFrameCanceled),
            "UntilConditionMet" => Ok(Self::UntilConditionMet),
            "UntilConditionFailed" => Ok(Self::UntilConditionFailed),
            "CancelLoop" => Ok(Self::CancelLoop),
            other => Err(format!(
                "invalid LoopIterationReducerCommandKind value `{other}`"
            )),
        }
    }
}
impl std::convert::TryFrom<String> for LoopIterationReducerCommandKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for LoopIterationReducerCommandKind {
    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 LoopIterationStage {
    #[default]
    #[serde(rename = "AwaitingBodyFrame")]
    AwaitingBodyFrame,
    #[serde(rename = "BodyFrameActive")]
    BodyFrameActive,
    #[serde(rename = "AwaitingUntilEvaluation")]
    AwaitingUntilEvaluation,
}
impl LoopIterationStage {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::AwaitingBodyFrame => "AwaitingBodyFrame",
            Self::BodyFrameActive => "BodyFrameActive",
            Self::AwaitingUntilEvaluation => "AwaitingUntilEvaluation",
        }
    }
}
impl std::convert::TryFrom<&str> for LoopIterationStage {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "AwaitingBodyFrame" => Ok(Self::AwaitingBodyFrame),
            "BodyFrameActive" => Ok(Self::BodyFrameActive),
            "AwaitingUntilEvaluation" => Ok(Self::AwaitingUntilEvaluation),
            other => Err(format!("invalid LoopIterationStage value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for LoopIterationStage {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for LoopIterationStage {
    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 LoopStatus {
    #[default]
    #[serde(rename = "Running")]
    Running,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Exhausted")]
    Exhausted,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Canceled")]
    Canceled,
}
impl LoopStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Running => "Running",
            Self::Completed => "Completed",
            Self::Exhausted => "Exhausted",
            Self::Failed => "Failed",
            Self::Canceled => "Canceled",
        }
    }
}
impl std::convert::TryFrom<&str> for LoopStatus {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Running" => Ok(Self::Running),
            "Completed" => Ok(Self::Completed),
            "Exhausted" => Ok(Self::Exhausted),
            "Failed" => Ok(Self::Failed),
            "Canceled" => Ok(Self::Canceled),
            other => Err(format!("invalid LoopStatus value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for LoopStatus {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for LoopStatus {
    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 MemberLifecycleKind {
    #[default]
    #[serde(rename = "Spawned")]
    Spawned,
    #[serde(rename = "Retiring")]
    Retiring,
    #[serde(rename = "Retired")]
    Retired,
    #[serde(rename = "Reset")]
    Reset,
    #[serde(rename = "Respawned")]
    Respawned,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Destroyed")]
    Destroyed,
}
impl MemberLifecycleKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Spawned => "Spawned",
            Self::Retiring => "Retiring",
            Self::Retired => "Retired",
            Self::Reset => "Reset",
            Self::Respawned => "Respawned",
            Self::Completed => "Completed",
            Self::Destroyed => "Destroyed",
        }
    }
}
impl std::convert::TryFrom<&str> for MemberLifecycleKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Spawned" => Ok(Self::Spawned),
            "Retiring" => Ok(Self::Retiring),
            "Retired" => Ok(Self::Retired),
            "Reset" => Ok(Self::Reset),
            "Respawned" => Ok(Self::Respawned),
            "Completed" => Ok(Self::Completed),
            "Destroyed" => Ok(Self::Destroyed),
            other => Err(format!("invalid MemberLifecycleKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for MemberLifecycleKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for MemberLifecycleKind {
    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 MobId(pub String);
impl From<String> for MobId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for MobId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for MobId {
    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 MobMemberState {
    #[default]
    #[serde(rename = "Active")]
    Active,
    #[serde(rename = "Retiring")]
    Retiring,
}
impl MobMemberState {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Active => "Active",
            Self::Retiring => "Retiring",
        }
    }
}
impl std::convert::TryFrom<&str> for MobMemberState {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Active" => Ok(Self::Active),
            "Retiring" => Ok(Self::Retiring),
            other => Err(format!("invalid MobMemberState value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for MobMemberState {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for MobMemberState {
    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 NodeRunStatus {
    #[default]
    #[serde(rename = "Pending")]
    Pending,
    #[serde(rename = "Ready")]
    Ready,
    #[serde(rename = "Running")]
    Running,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Skipped")]
    Skipped,
    #[serde(rename = "Canceled")]
    Canceled,
}
impl NodeRunStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Pending => "Pending",
            Self::Ready => "Ready",
            Self::Running => "Running",
            Self::Completed => "Completed",
            Self::Failed => "Failed",
            Self::Skipped => "Skipped",
            Self::Canceled => "Canceled",
        }
    }
}
impl std::convert::TryFrom<&str> for NodeRunStatus {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Pending" => Ok(Self::Pending),
            "Ready" => Ok(Self::Ready),
            "Running" => Ok(Self::Running),
            "Completed" => Ok(Self::Completed),
            "Failed" => Ok(Self::Failed),
            "Skipped" => Ok(Self::Skipped),
            "Canceled" => Ok(Self::Canceled),
            other => Err(format!("invalid NodeRunStatus value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for NodeRunStatus {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for NodeRunStatus {
    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 RunId(pub String);
impl From<String> for RunId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for RunId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for RunId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct RunStepKey(pub String);
impl From<String> for RunStepKey {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for RunStepKey {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for RunStepKey {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.0)
    }
}
#[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)
    }
}
#[derive(
    Debug,
    Clone,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub struct StepId(pub String);
impl From<String> for StepId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for StepId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for StepId {
    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 StepRunStatus {
    #[default]
    #[serde(rename = "Dispatched")]
    Dispatched,
    #[serde(rename = "Completed")]
    Completed,
    #[serde(rename = "Failed")]
    Failed,
    #[serde(rename = "Skipped")]
    Skipped,
    #[serde(rename = "Canceled")]
    Canceled,
}
impl StepRunStatus {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Dispatched => "Dispatched",
            Self::Completed => "Completed",
            Self::Failed => "Failed",
            Self::Skipped => "Skipped",
            Self::Canceled => "Canceled",
        }
    }
}
impl std::convert::TryFrom<&str> for StepRunStatus {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Dispatched" => Ok(Self::Dispatched),
            "Completed" => Ok(Self::Completed),
            "Failed" => Ok(Self::Failed),
            "Skipped" => Ok(Self::Skipped),
            "Canceled" => Ok(Self::Canceled),
            other => Err(format!("invalid StepRunStatus value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for StepRunStatus {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for StepRunStatus {
    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 WiringEdge(pub String);
impl From<String> for WiringEdge {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for WiringEdge {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for WiringEdge {
    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 WiringLifecycleKind {
    #[default]
    #[serde(rename = "Wired")]
    Wired,
    #[serde(rename = "Unwired")]
    Unwired,
}
impl WiringLifecycleKind {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Wired => "Wired",
            Self::Unwired => "Unwired",
        }
    }
}
impl std::convert::TryFrom<&str> for WiringLifecycleKind {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Wired" => Ok(Self::Wired),
            "Unwired" => Ok(Self::Unwired),
            other => Err(format!("invalid WiringLifecycleKind value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for WiringLifecycleKind {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for WiringLifecycleKind {
    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 WorkId(pub String);
impl From<String> for WorkId {
    fn from(value: String) -> Self {
        Self(value)
    }
}
impl From<&str> for WorkId {
    fn from(value: &str) -> Self {
        Self(value.to_owned())
    }
}
impl std::fmt::Display for WorkId {
    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 WorkOrigin {
    #[default]
    #[serde(rename = "External")]
    External,
    #[serde(rename = "Internal")]
    Internal,
    #[serde(rename = "Ingest")]
    Ingest,
}
impl WorkOrigin {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::External => "External",
            Self::Internal => "Internal",
            Self::Ingest => "Ingest",
        }
    }
}
impl std::convert::TryFrom<&str> for WorkOrigin {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "External" => Ok(Self::External),
            "Internal" => Ok(Self::Internal),
            "Ingest" => Ok(Self::Ingest),
            other => Err(format!("invalid WorkOrigin value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for WorkOrigin {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for WorkOrigin {
    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 {
    Running,
    Stopped,
    Completed,
    Destroyed,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct State {
    pub phase: Phase,
    pub live_runtime_ids: std::collections::BTreeSet<AgentRuntimeId>,
    pub externally_addressable_runtime_ids: std::collections::BTreeSet<AgentRuntimeId>,
    pub runtime_fence_tokens: std::collections::BTreeMap<AgentRuntimeId, FenceToken>,
    pub active_run_count: u64,
    pub run_status: std::collections::BTreeMap<RunId, FlowRunStatus>,
    pub run_ordered_steps: std::collections::BTreeMap<RunId, Vec<StepId>>,
    pub run_tracked_steps: std::collections::BTreeMap<RunId, std::collections::BTreeSet<StepId>>,
    pub run_step_status: std::collections::BTreeMap<
        RunId,
        std::collections::BTreeMap<StepId, Option<StepRunStatus>>,
    >,
    pub run_step_status_flat: std::collections::BTreeMap<RunStepKey, StepRunStatus>,
    pub run_output_recorded:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, bool>>,
    pub run_step_condition_results_flat: std::collections::BTreeMap<RunStepKey, Option<bool>>,
    pub run_step_condition_results:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, Option<bool>>>,
    pub run_step_has_conditions:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, bool>>,
    pub run_step_dependencies:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, Vec<StepId>>>,
    pub run_step_dependency_modes:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, DependencyMode>>,
    pub run_step_branches:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, Option<BranchId>>>,
    pub run_step_collection_policies:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, CollectionPolicyKind>>,
    pub run_step_quorum_thresholds:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, u32>>,
    pub run_step_target_counts:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, u64>>,
    pub run_step_target_success_counts:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, u64>>,
    pub run_step_target_terminal_failure_counts:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<StepId, u64>>,
    pub run_output_recorded_flat: std::collections::BTreeMap<RunStepKey, bool>,
    pub run_step_target_counts_flat: std::collections::BTreeMap<RunStepKey, u64>,
    pub run_step_target_success_counts_flat: std::collections::BTreeMap<RunStepKey, u64>,
    pub run_step_target_terminal_failure_counts_flat: std::collections::BTreeMap<RunStepKey, u64>,
    pub run_target_retry_counts:
        std::collections::BTreeMap<RunId, std::collections::BTreeMap<String, u64>>,
    pub run_target_retry_counts_flat: std::collections::BTreeMap<RunStepKey, u64>,
    pub run_failure_count: std::collections::BTreeMap<RunId, u64>,
    pub run_consecutive_failure_count: std::collections::BTreeMap<RunId, u64>,
    pub run_escalation_threshold: std::collections::BTreeMap<RunId, u32>,
    pub run_max_step_retries: std::collections::BTreeMap<RunId, u32>,
    pub run_ready_frames: std::collections::BTreeMap<RunId, Vec<FrameId>>,
    pub run_ready_frame_membership:
        std::collections::BTreeMap<RunId, std::collections::BTreeSet<FrameId>>,
    pub run_ready_frame_membership_flat: std::collections::BTreeSet<FrameId>,
    pub run_pending_body_frame_loops: std::collections::BTreeMap<RunId, Vec<LoopInstanceId>>,
    pub run_pending_body_frame_loop_membership:
        std::collections::BTreeMap<RunId, std::collections::BTreeSet<LoopInstanceId>>,
    pub run_pending_body_frame_loop_membership_flat: std::collections::BTreeSet<LoopInstanceId>,
    pub run_active_node_count: std::collections::BTreeMap<RunId, u64>,
    pub run_active_frame_count: std::collections::BTreeMap<RunId, u64>,
    pub run_last_granted_frame: std::collections::BTreeMap<RunId, FrameId>,
    pub run_last_granted_loop: std::collections::BTreeMap<RunId, LoopInstanceId>,
    pub run_max_active_nodes: std::collections::BTreeMap<RunId, u64>,
    pub run_max_active_frames: std::collections::BTreeMap<RunId, u64>,
    pub run_max_frame_depth: std::collections::BTreeMap<RunId, u64>,
    pub frame_scope: std::collections::BTreeMap<FrameId, FrameScope>,
    pub frame_phase: std::collections::BTreeMap<FrameId, FrameStatus>,
    pub frame_run: std::collections::BTreeMap<FrameId, RunId>,
    pub frame_parent_loop: std::collections::BTreeMap<FrameId, Option<LoopInstanceId>>,
    pub frame_iteration: std::collections::BTreeMap<FrameId, u32>,
    pub frame_tracked_nodes:
        std::collections::BTreeMap<FrameId, std::collections::BTreeSet<FlowNodeId>>,
    pub frame_ordered_nodes: std::collections::BTreeMap<FrameId, Vec<FlowNodeId>>,
    pub frame_node_kind:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, FlowNodeKind>>,
    pub frame_node_dependencies: std::collections::BTreeMap<
        FrameId,
        std::collections::BTreeMap<FlowNodeId, Vec<FlowNodeId>>,
    >,
    pub frame_node_dependency_modes:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, DependencyMode>>,
    pub frame_node_step_ids:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, StepId>>,
    pub frame_node_loop_ids:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, LoopId>>,
    pub frame_node_status:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, NodeRunStatus>>,
    pub frame_ready_queue: std::collections::BTreeMap<FrameId, Vec<FlowNodeId>>,
    pub frame_output_recorded:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, bool>>,
    pub frame_output_recorded_flat: std::collections::BTreeMap<FrameNodeKey, bool>,
    pub frame_last_admitted_node: std::collections::BTreeMap<FrameId, FlowNodeId>,
    pub frame_node_condition_results:
        std::collections::BTreeMap<FrameId, std::collections::BTreeMap<FlowNodeId, Option<bool>>>,
    pub frame_node_branches: std::collections::BTreeMap<
        FrameId,
        std::collections::BTreeMap<FlowNodeId, Option<BranchId>>,
    >,
    pub loop_phase: std::collections::BTreeMap<LoopInstanceId, LoopStatus>,
    pub loop_parent_frame: std::collections::BTreeMap<LoopInstanceId, FrameId>,
    pub loop_parent_node: std::collections::BTreeMap<LoopInstanceId, FlowNodeId>,
    pub loop_definition: std::collections::BTreeMap<LoopInstanceId, LoopId>,
    pub loop_depth: std::collections::BTreeMap<LoopInstanceId, u32>,
    pub loop_stage: std::collections::BTreeMap<LoopInstanceId, LoopIterationStage>,
    pub loop_current_iteration: std::collections::BTreeMap<LoopInstanceId, u64>,
    pub loop_last_completed_iteration: std::collections::BTreeMap<LoopInstanceId, u64>,
    pub loop_max_iterations: std::collections::BTreeMap<LoopInstanceId, u64>,
    pub loop_active_body_frame: std::collections::BTreeMap<LoopInstanceId, Option<FrameId>>,
    pub pending_spawn_count: u64,
    pub pending_spawn_sessions: std::collections::BTreeMap<AgentIdentity, SessionId>,
    pub coordinator_bound: bool,
    pub member_startup_binding_requested: std::collections::BTreeSet<AgentRuntimeId>,
    pub member_startup_runtime_ready: std::collections::BTreeSet<AgentRuntimeId>,
    pub member_startup_ready: std::collections::BTreeSet<AgentRuntimeId>,
    pub member_kickoff_pending: std::collections::BTreeSet<String>,
    pub member_kickoff_starting: std::collections::BTreeSet<String>,
    pub member_kickoff_callback_pending: std::collections::BTreeSet<String>,
    pub member_kickoff_started: std::collections::BTreeSet<String>,
    pub member_kickoff_failed: std::collections::BTreeSet<String>,
    pub member_kickoff_cancelled: std::collections::BTreeSet<String>,
    pub member_kickoff_error: std::collections::BTreeMap<String, String>,
    pub member_restore_failures: std::collections::BTreeMap<AgentIdentity, String>,
    pub member_state_markers: std::collections::BTreeMap<AgentRuntimeId, MobMemberState>,
    pub wiring_edges: std::collections::BTreeSet<WiringEdge>,
    pub external_peer_edges: std::collections::BTreeSet<ExternalPeerEdge>,
    pub identity_to_runtime: std::collections::BTreeMap<AgentIdentity, AgentRuntimeId>,
    pub member_session_bindings: std::collections::BTreeMap<AgentIdentity, SessionId>,
    pub pending_session_ingress_detach_runtime_ids: std::collections::BTreeSet<AgentRuntimeId>,
    pub topology_epoch: u64,
}
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 RunFlow {
        pub run_id: RunId,
        pub step_ids: std::collections::BTreeSet<StepId>,
        pub ordered_steps: Vec<StepId>,
        pub step_has_conditions: std::collections::BTreeMap<StepId, bool>,
        pub step_dependencies: std::collections::BTreeMap<StepId, Vec<StepId>>,
        pub step_dependency_modes: std::collections::BTreeMap<StepId, DependencyMode>,
        pub step_branches: std::collections::BTreeMap<StepId, Option<BranchId>>,
        pub step_collection_policies: std::collections::BTreeMap<StepId, CollectionPolicyKind>,
        pub step_quorum_thresholds: std::collections::BTreeMap<StepId, u32>,
        pub escalation_threshold: u32,
        pub max_step_retries: u32,
        pub max_active_nodes: u64,
        pub max_active_frames: u64,
        pub max_frame_depth: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CreateRunSeed {
        pub run_id: RunId,
        pub step_ids: std::collections::BTreeSet<StepId>,
        pub ordered_steps: Vec<StepId>,
        pub step_has_conditions: std::collections::BTreeMap<StepId, bool>,
        pub step_dependencies: std::collections::BTreeMap<StepId, Vec<StepId>>,
        pub step_dependency_modes: std::collections::BTreeMap<StepId, DependencyMode>,
        pub step_branches: std::collections::BTreeMap<StepId, Option<BranchId>>,
        pub step_collection_policies: std::collections::BTreeMap<StepId, CollectionPolicyKind>,
        pub step_quorum_thresholds: std::collections::BTreeMap<StepId, u32>,
        pub escalation_threshold: u32,
        pub max_step_retries: u32,
        pub max_active_nodes: u64,
        pub max_active_frames: u64,
        pub max_frame_depth: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CreateFrameSeed {
        pub run_id: RunId,
        pub frame_id: FrameId,
        pub frame_scope: FrameScope,
        pub loop_instance_id: Option<LoopInstanceId>,
        pub iteration: u32,
        pub tracked_nodes: std::collections::BTreeSet<FlowNodeId>,
        pub ordered_nodes: Vec<FlowNodeId>,
        pub node_kind: std::collections::BTreeMap<FlowNodeId, FlowNodeKind>,
        pub node_dependencies: std::collections::BTreeMap<FlowNodeId, Vec<FlowNodeId>>,
        pub node_dependency_modes: std::collections::BTreeMap<FlowNodeId, DependencyMode>,
        pub node_branches: std::collections::BTreeMap<FlowNodeId, Option<BranchId>>,
        pub node_step_ids: std::collections::BTreeMap<FlowNodeId, StepId>,
        pub node_loop_ids: std::collections::BTreeMap<FlowNodeId, LoopId>,
        pub node_status: std::collections::BTreeMap<FlowNodeId, NodeRunStatus>,
        pub ready_queue: Vec<FlowNodeId>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CreateLoopSeed {
        pub loop_instance_id: LoopInstanceId,
        pub parent_frame_id: FrameId,
        pub parent_node_id: FlowNodeId,
        pub loop_id: LoopId,
        pub depth: u32,
        pub max_iterations: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecordLoopBodyFrameCompleted {
        pub loop_instance_id: LoopInstanceId,
        pub iteration: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecordLoopUntilConditionMet {
        pub loop_instance_id: LoopInstanceId,
        pub iteration: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecordLoopUntilConditionFailed {
        pub loop_instance_id: LoopInstanceId,
        pub iteration: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeFlowRunReducerCommand {
        pub run_id: RunId,
        pub command: FlowRunReducerCommandKind,
        pub step_id: Option<StepId>,
        pub run_step_key: Option<RunStepKey>,
        pub step_status: Option<StepRunStatus>,
        pub target_count: Option<u64>,
        pub frame_id: Option<FrameId>,
        pub node_id: Option<FlowNodeId>,
        pub loop_instance_id: Option<LoopInstanceId>,
        pub retry_key: Option<String>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeFlowFrameReducerCommand {
        pub frame_id: FrameId,
        pub command: FlowFrameReducerCommandKind,
        pub node_id: Option<FlowNodeId>,
        pub frame_node_key: Option<FrameNodeKey>,
        pub node_status: Option<NodeRunStatus>,
        pub terminal_status: Option<FrameStatus>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AuthorizeLoopIterationReducerCommand {
        pub loop_instance_id: LoopInstanceId,
        pub command: LoopIterationReducerCommandKind,
        pub body_frame_id: Option<FrameId>,
        pub body_frame_iteration: Option<u64>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CancelFlow {
        pub run_id: RunId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct FlowStatus {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Spawn {
        pub agent_identity: AgentIdentity,
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub generation: Generation,
        pub external_addressable: bool,
        pub bridge_session_id: SessionId,
        pub replacing: Option<SessionId>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EnsureMember {
        pub agent_identity: AgentIdentity,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Reconcile {
        pub desired: std::collections::BTreeSet<AgentIdentity>,
        pub retire_stale: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Retire {
        pub mob_id: MobId,
        pub agent_runtime_id: AgentRuntimeId,
        pub agent_identity: AgentIdentity,
        pub releasing: Option<SessionId>,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Respawn {
        pub agent_runtime_id: AgentRuntimeId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RetireAll {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct WireMembers {
        pub edge: WiringEdge,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct UnwireMembers {
        pub edge: WiringEdge,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct WireExternalPeer {
        pub edge: ExternalPeerEdge,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct UnwireExternalPeer {
        pub edge: ExternalPeerEdge,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionIngressDetachedForMobDestroy {
        pub mob_id: MobId,
        pub agent_runtime_id: AgentRuntimeId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SessionIngressDetachFailedForMobDestroy {
        pub mob_id: MobId,
        pub agent_runtime_id: AgentRuntimeId,
        pub reason: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SubmitWork {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub work_id: WorkId,
        pub origin: WorkOrigin,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CancelWork {
        pub work_id: WorkId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CancelAllWork {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Stop {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Resume {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Complete {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Reset {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Destroy {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RosterSnapshot {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ListMembers {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ListMembersIncludingRetiring {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ListAllMembers {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MemberStatus {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SubscribeAgentEvents {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SubscribeAllAgentEvents {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SubscribeMobEvents {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PollEvents {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ReplayAllEvents {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RecordOperatorActionProvenance {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct GetMember {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct SetSpawnPolicy {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Shutdown {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ForceCancel {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffMarkPending {
        pub member_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffMarkStarting {
        pub member_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StartupMarkReady {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffResolveStarted {
        pub member_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffResolveCallbackPending {
        pub member_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffResolveFailed {
        pub member_id: String,
        pub error: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffCancelRequested {
        pub member_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct KickoffClear {
        pub member_id: String,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Input {
    RunFlow(inputs::RunFlow),
    CreateRunSeed(inputs::CreateRunSeed),
    CreateFrameSeed(inputs::CreateFrameSeed),
    CreateLoopSeed(inputs::CreateLoopSeed),
    RecordLoopBodyFrameCompleted(inputs::RecordLoopBodyFrameCompleted),
    RecordLoopUntilConditionMet(inputs::RecordLoopUntilConditionMet),
    RecordLoopUntilConditionFailed(inputs::RecordLoopUntilConditionFailed),
    AuthorizeFlowRunReducerCommand(inputs::AuthorizeFlowRunReducerCommand),
    AuthorizeFlowFrameReducerCommand(inputs::AuthorizeFlowFrameReducerCommand),
    AuthorizeLoopIterationReducerCommand(inputs::AuthorizeLoopIterationReducerCommand),
    CancelFlow(inputs::CancelFlow),
    FlowStatus(inputs::FlowStatus),
    Spawn(inputs::Spawn),
    EnsureMember(inputs::EnsureMember),
    Reconcile(inputs::Reconcile),
    Retire(inputs::Retire),
    Respawn(inputs::Respawn),
    RetireAll(inputs::RetireAll),
    WireMembers(inputs::WireMembers),
    UnwireMembers(inputs::UnwireMembers),
    WireExternalPeer(inputs::WireExternalPeer),
    UnwireExternalPeer(inputs::UnwireExternalPeer),
    SessionIngressDetachedForMobDestroy(inputs::SessionIngressDetachedForMobDestroy),
    SessionIngressDetachFailedForMobDestroy(inputs::SessionIngressDetachFailedForMobDestroy),
    SubmitWork(inputs::SubmitWork),
    CancelWork(inputs::CancelWork),
    CancelAllWork(inputs::CancelAllWork),
    Stop(inputs::Stop),
    Resume(inputs::Resume),
    Complete(inputs::Complete),
    Reset(inputs::Reset),
    Destroy(inputs::Destroy),
    RosterSnapshot(inputs::RosterSnapshot),
    ListMembers(inputs::ListMembers),
    ListMembersIncludingRetiring(inputs::ListMembersIncludingRetiring),
    ListAllMembers(inputs::ListAllMembers),
    MemberStatus(inputs::MemberStatus),
    SubscribeAgentEvents(inputs::SubscribeAgentEvents),
    SubscribeAllAgentEvents(inputs::SubscribeAllAgentEvents),
    SubscribeMobEvents(inputs::SubscribeMobEvents),
    PollEvents(inputs::PollEvents),
    ReplayAllEvents(inputs::ReplayAllEvents),
    RecordOperatorActionProvenance(inputs::RecordOperatorActionProvenance),
    GetMember(inputs::GetMember),
    SetSpawnPolicy(inputs::SetSpawnPolicy),
    Shutdown(inputs::Shutdown),
    ForceCancel(inputs::ForceCancel),
    KickoffMarkPending(inputs::KickoffMarkPending),
    KickoffMarkStarting(inputs::KickoffMarkStarting),
    StartupMarkReady(inputs::StartupMarkReady),
    KickoffResolveStarted(inputs::KickoffResolveStarted),
    KickoffResolveCallbackPending(inputs::KickoffResolveCallbackPending),
    KickoffResolveFailed(inputs::KickoffResolveFailed),
    KickoffCancelRequested(inputs::KickoffCancelRequested),
    KickoffClear(inputs::KickoffClear),
}
impl Input {
    pub fn kind(&self) -> InputKind {
        match self {
            Self::RunFlow(_) => InputKind::RunFlow,
            Self::CreateRunSeed(_) => InputKind::CreateRunSeed,
            Self::CreateFrameSeed(_) => InputKind::CreateFrameSeed,
            Self::CreateLoopSeed(_) => InputKind::CreateLoopSeed,
            Self::RecordLoopBodyFrameCompleted(_) => InputKind::RecordLoopBodyFrameCompleted,
            Self::RecordLoopUntilConditionMet(_) => InputKind::RecordLoopUntilConditionMet,
            Self::RecordLoopUntilConditionFailed(_) => InputKind::RecordLoopUntilConditionFailed,
            Self::AuthorizeFlowRunReducerCommand(_) => InputKind::AuthorizeFlowRunReducerCommand,
            Self::AuthorizeFlowFrameReducerCommand(_) => {
                InputKind::AuthorizeFlowFrameReducerCommand
            }
            Self::AuthorizeLoopIterationReducerCommand(_) => {
                InputKind::AuthorizeLoopIterationReducerCommand
            }
            Self::CancelFlow(_) => InputKind::CancelFlow,
            Self::FlowStatus(_) => InputKind::FlowStatus,
            Self::Spawn(_) => InputKind::Spawn,
            Self::EnsureMember(_) => InputKind::EnsureMember,
            Self::Reconcile(_) => InputKind::Reconcile,
            Self::Retire(_) => InputKind::Retire,
            Self::Respawn(_) => InputKind::Respawn,
            Self::RetireAll(_) => InputKind::RetireAll,
            Self::WireMembers(_) => InputKind::WireMembers,
            Self::UnwireMembers(_) => InputKind::UnwireMembers,
            Self::WireExternalPeer(_) => InputKind::WireExternalPeer,
            Self::UnwireExternalPeer(_) => InputKind::UnwireExternalPeer,
            Self::SessionIngressDetachedForMobDestroy(_) => {
                InputKind::SessionIngressDetachedForMobDestroy
            }
            Self::SessionIngressDetachFailedForMobDestroy(_) => {
                InputKind::SessionIngressDetachFailedForMobDestroy
            }
            Self::SubmitWork(_) => InputKind::SubmitWork,
            Self::CancelWork(_) => InputKind::CancelWork,
            Self::CancelAllWork(_) => InputKind::CancelAllWork,
            Self::Stop(_) => InputKind::Stop,
            Self::Resume(_) => InputKind::Resume,
            Self::Complete(_) => InputKind::Complete,
            Self::Reset(_) => InputKind::Reset,
            Self::Destroy(_) => InputKind::Destroy,
            Self::RosterSnapshot(_) => InputKind::RosterSnapshot,
            Self::ListMembers(_) => InputKind::ListMembers,
            Self::ListMembersIncludingRetiring(_) => InputKind::ListMembersIncludingRetiring,
            Self::ListAllMembers(_) => InputKind::ListAllMembers,
            Self::MemberStatus(_) => InputKind::MemberStatus,
            Self::SubscribeAgentEvents(_) => InputKind::SubscribeAgentEvents,
            Self::SubscribeAllAgentEvents(_) => InputKind::SubscribeAllAgentEvents,
            Self::SubscribeMobEvents(_) => InputKind::SubscribeMobEvents,
            Self::PollEvents(_) => InputKind::PollEvents,
            Self::ReplayAllEvents(_) => InputKind::ReplayAllEvents,
            Self::RecordOperatorActionProvenance(_) => InputKind::RecordOperatorActionProvenance,
            Self::GetMember(_) => InputKind::GetMember,
            Self::SetSpawnPolicy(_) => InputKind::SetSpawnPolicy,
            Self::Shutdown(_) => InputKind::Shutdown,
            Self::ForceCancel(_) => InputKind::ForceCancel,
            Self::KickoffMarkPending(_) => InputKind::KickoffMarkPending,
            Self::KickoffMarkStarting(_) => InputKind::KickoffMarkStarting,
            Self::StartupMarkReady(_) => InputKind::StartupMarkReady,
            Self::KickoffResolveStarted(_) => InputKind::KickoffResolveStarted,
            Self::KickoffResolveCallbackPending(_) => InputKind::KickoffResolveCallbackPending,
            Self::KickoffResolveFailed(_) => InputKind::KickoffResolveFailed,
            Self::KickoffCancelRequested(_) => InputKind::KickoffCancelRequested,
            Self::KickoffClear(_) => InputKind::KickoffClear,
        }
    }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum InputKind {
    RunFlow,
    CreateRunSeed,
    CreateFrameSeed,
    CreateLoopSeed,
    RecordLoopBodyFrameCompleted,
    RecordLoopUntilConditionMet,
    RecordLoopUntilConditionFailed,
    AuthorizeFlowRunReducerCommand,
    AuthorizeFlowFrameReducerCommand,
    AuthorizeLoopIterationReducerCommand,
    CancelFlow,
    FlowStatus,
    Spawn,
    EnsureMember,
    Reconcile,
    Retire,
    Respawn,
    RetireAll,
    WireMembers,
    UnwireMembers,
    WireExternalPeer,
    UnwireExternalPeer,
    SessionIngressDetachedForMobDestroy,
    SessionIngressDetachFailedForMobDestroy,
    SubmitWork,
    CancelWork,
    CancelAllWork,
    Stop,
    Resume,
    Complete,
    Reset,
    Destroy,
    RosterSnapshot,
    ListMembers,
    ListMembersIncludingRetiring,
    ListAllMembers,
    MemberStatus,
    SubscribeAgentEvents,
    SubscribeAllAgentEvents,
    SubscribeMobEvents,
    PollEvents,
    ReplayAllEvents,
    RecordOperatorActionProvenance,
    GetMember,
    SetSpawnPolicy,
    Shutdown,
    ForceCancel,
    KickoffMarkPending,
    KickoffMarkStarting,
    StartupMarkReady,
    KickoffResolveStarted,
    KickoffResolveCallbackPending,
    KickoffResolveFailed,
    KickoffCancelRequested,
    KickoffClear,
}

pub mod signals {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ObserveRuntimeReady {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RetireMember {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ObserveRuntimeRetired {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResetMember {
        pub agent_identity: AgentIdentity,
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub generation: Generation,
        pub external_addressable: bool,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RespawnMember {
        pub agent_identity: AgentIdentity,
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub generation: Generation,
        pub external_addressable: bool,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct DestroyMob {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ObserveRuntimeDestroyed {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MarkCompleted {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StartRun {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct FinishRun {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct BeginCleanup {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct FinishCleanup {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct InitializeOrchestrator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct BindCoordinator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct UnbindCoordinator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StageSpawn {
        pub agent_identity: AgentIdentity,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CompleteSpawn {
        pub agent_identity: AgentIdentity,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StartFlow {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CompleteFlow {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct StopOrchestrator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResumeOrchestrator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct DestroyOrchestrator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ForceCancelMember {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MemberPeerExposed {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MemberTerminalized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct OperationPeerTrusted {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PeerInputAdmitted {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CreateRun {}
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Signal {
    ObserveRuntimeReady(signals::ObserveRuntimeReady),
    RetireMember(signals::RetireMember),
    ObserveRuntimeRetired(signals::ObserveRuntimeRetired),
    ResetMember(signals::ResetMember),
    RespawnMember(signals::RespawnMember),
    DestroyMob(signals::DestroyMob),
    ObserveRuntimeDestroyed(signals::ObserveRuntimeDestroyed),
    MarkCompleted(signals::MarkCompleted),
    StartRun(signals::StartRun),
    FinishRun(signals::FinishRun),
    BeginCleanup(signals::BeginCleanup),
    FinishCleanup(signals::FinishCleanup),
    InitializeOrchestrator(signals::InitializeOrchestrator),
    BindCoordinator(signals::BindCoordinator),
    UnbindCoordinator(signals::UnbindCoordinator),
    StageSpawn(signals::StageSpawn),
    CompleteSpawn(signals::CompleteSpawn),
    StartFlow(signals::StartFlow),
    CompleteFlow(signals::CompleteFlow),
    StopOrchestrator(signals::StopOrchestrator),
    ResumeOrchestrator(signals::ResumeOrchestrator),
    DestroyOrchestrator(signals::DestroyOrchestrator),
    ForceCancelMember(signals::ForceCancelMember),
    MemberPeerExposed(signals::MemberPeerExposed),
    MemberTerminalized(signals::MemberTerminalized),
    OperationPeerTrusted(signals::OperationPeerTrusted),
    PeerInputAdmitted(signals::PeerInputAdmitted),
    CreateRun(signals::CreateRun),
}
impl Signal {
    pub fn kind(&self) -> SignalKind {
        match self {
            Self::ObserveRuntimeReady(_) => SignalKind::ObserveRuntimeReady,
            Self::RetireMember(_) => SignalKind::RetireMember,
            Self::ObserveRuntimeRetired(_) => SignalKind::ObserveRuntimeRetired,
            Self::ResetMember(_) => SignalKind::ResetMember,
            Self::RespawnMember(_) => SignalKind::RespawnMember,
            Self::DestroyMob(_) => SignalKind::DestroyMob,
            Self::ObserveRuntimeDestroyed(_) => SignalKind::ObserveRuntimeDestroyed,
            Self::MarkCompleted(_) => SignalKind::MarkCompleted,
            Self::StartRun(_) => SignalKind::StartRun,
            Self::FinishRun(_) => SignalKind::FinishRun,
            Self::BeginCleanup(_) => SignalKind::BeginCleanup,
            Self::FinishCleanup(_) => SignalKind::FinishCleanup,
            Self::InitializeOrchestrator(_) => SignalKind::InitializeOrchestrator,
            Self::BindCoordinator(_) => SignalKind::BindCoordinator,
            Self::UnbindCoordinator(_) => SignalKind::UnbindCoordinator,
            Self::StageSpawn(_) => SignalKind::StageSpawn,
            Self::CompleteSpawn(_) => SignalKind::CompleteSpawn,
            Self::StartFlow(_) => SignalKind::StartFlow,
            Self::CompleteFlow(_) => SignalKind::CompleteFlow,
            Self::StopOrchestrator(_) => SignalKind::StopOrchestrator,
            Self::ResumeOrchestrator(_) => SignalKind::ResumeOrchestrator,
            Self::DestroyOrchestrator(_) => SignalKind::DestroyOrchestrator,
            Self::ForceCancelMember(_) => SignalKind::ForceCancelMember,
            Self::MemberPeerExposed(_) => SignalKind::MemberPeerExposed,
            Self::MemberTerminalized(_) => SignalKind::MemberTerminalized,
            Self::OperationPeerTrusted(_) => SignalKind::OperationPeerTrusted,
            Self::PeerInputAdmitted(_) => SignalKind::PeerInputAdmitted,
            Self::CreateRun(_) => SignalKind::CreateRun,
        }
    }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum SignalKind {
    ObserveRuntimeReady,
    RetireMember,
    ObserveRuntimeRetired,
    ResetMember,
    RespawnMember,
    DestroyMob,
    ObserveRuntimeDestroyed,
    MarkCompleted,
    StartRun,
    FinishRun,
    BeginCleanup,
    FinishCleanup,
    InitializeOrchestrator,
    BindCoordinator,
    UnbindCoordinator,
    StageSpawn,
    CompleteSpawn,
    StartFlow,
    CompleteFlow,
    StopOrchestrator,
    ResumeOrchestrator,
    DestroyOrchestrator,
    ForceCancelMember,
    MemberPeerExposed,
    MemberTerminalized,
    OperationPeerTrusted,
    PeerInputAdmitted,
    CreateRun,
}

pub mod effects {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RequestRuntimeBinding {
        pub agent_identity: AgentIdentity,
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub generation: Generation,
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RequestRuntimeIngress {
        pub agent_runtime_id: AgentRuntimeId,
        pub fence_token: FenceToken,
        pub work_id: WorkId,
        pub origin: WorkOrigin,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RequestRuntimeRetire {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RequestRuntimeDestroy {
        pub session_id: SessionId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RequestSessionIngressDetachForMobDestroy {
        pub mob_id: MobId,
        pub agent_runtime_id: AgentRuntimeId,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitMemberLifecycleNotice {
        pub kind: MemberLifecycleKind,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitRunLifecycleNotice {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitFlowRunNotice {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AppendFailureLedger {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct FlowTerminalized {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EscalateSupervisor {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct NotifyCoordinator {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ExposePendingSpawn {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitMemberTerminalNotice {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AdmitPeerInput {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitProgressNote {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PersistKickoffUpdate {
        pub member_id: String,
        pub phase: KickoffPhase,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct PersistKickoffFailureUpdate {
        pub member_id: String,
        pub phase: KickoffPhase,
        pub error: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitKickoffLifecycleNotice {
        pub member_id: String,
        pub intent: KickoffIntent,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct WiringGraphChanged {
        pub epoch: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MemberSessionBindingChanged {
        pub epoch: u64,
        pub agent_identity: AgentIdentity,
        pub old_session_id: Option<SessionId>,
        pub new_session_id: Option<SessionId>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitWiringLifecycleNotice {
        pub kind: WiringLifecycleKind,
        pub edge: WiringEdge,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitExternalPeerWiringLifecycleNotice {
        pub kind: WiringLifecycleKind,
        pub edge: ExternalPeerEdge,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Effect {
    RequestRuntimeBinding(effects::RequestRuntimeBinding),
    RequestRuntimeIngress(effects::RequestRuntimeIngress),
    RequestRuntimeRetire(effects::RequestRuntimeRetire),
    RequestRuntimeDestroy(effects::RequestRuntimeDestroy),
    RequestSessionIngressDetachForMobDestroy(effects::RequestSessionIngressDetachForMobDestroy),
    EmitMemberLifecycleNotice(effects::EmitMemberLifecycleNotice),
    EmitRunLifecycleNotice(effects::EmitRunLifecycleNotice),
    EmitFlowRunNotice(effects::EmitFlowRunNotice),
    AppendFailureLedger(effects::AppendFailureLedger),
    FlowTerminalized(effects::FlowTerminalized),
    EscalateSupervisor(effects::EscalateSupervisor),
    NotifyCoordinator(effects::NotifyCoordinator),
    ExposePendingSpawn(effects::ExposePendingSpawn),
    EmitMemberTerminalNotice(effects::EmitMemberTerminalNotice),
    AdmitPeerInput(effects::AdmitPeerInput),
    EmitProgressNote(effects::EmitProgressNote),
    PersistKickoffUpdate(effects::PersistKickoffUpdate),
    PersistKickoffFailureUpdate(effects::PersistKickoffFailureUpdate),
    EmitKickoffLifecycleNotice(effects::EmitKickoffLifecycleNotice),
    WiringGraphChanged(effects::WiringGraphChanged),
    MemberSessionBindingChanged(effects::MemberSessionBindingChanged),
    EmitWiringLifecycleNotice(effects::EmitWiringLifecycleNotice),
    EmitExternalPeerWiringLifecycleNotice(effects::EmitExternalPeerWiringLifecycleNotice),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum EffectKind {
    RequestRuntimeBinding,
    RequestRuntimeIngress,
    RequestRuntimeRetire,
    RequestRuntimeDestroy,
    RequestSessionIngressDetachForMobDestroy,
    EmitMemberLifecycleNotice,
    EmitRunLifecycleNotice,
    EmitFlowRunNotice,
    AppendFailureLedger,
    FlowTerminalized,
    EscalateSupervisor,
    NotifyCoordinator,
    ExposePendingSpawn,
    EmitMemberTerminalNotice,
    AdmitPeerInput,
    EmitProgressNote,
    PersistKickoffUpdate,
    PersistKickoffFailureUpdate,
    EmitKickoffLifecycleNotice,
    WiringGraphChanged,
    MemberSessionBindingChanged,
    EmitWiringLifecycleNotice,
    EmitExternalPeerWiringLifecycleNotice,
}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionId {
    SpawnRunningFresh,
    SpawnRunningReplacing,
    EnsureMemberRunningExisting,
    EnsureMemberRunningMissing,
    ReconcileRunning,
    ReconcileStopped,
    ReconcileCompleted,
    ObserveRuntimeReady,
    StartupMarkReadyRunning,
    StartupMarkReadyStopped,
    StartupMarkReadyCompleted,
    KickoffMarkPendingRunning,
    KickoffMarkPendingStopped,
    KickoffMarkPendingCompleted,
    KickoffMarkStartingRunning,
    KickoffMarkStartingStopped,
    KickoffMarkStartingCompleted,
    KickoffResolveStartedRunning,
    KickoffResolveStartedStopped,
    KickoffResolveStartedCompleted,
    KickoffResolveCallbackPendingRunning,
    KickoffResolveCallbackPendingStopped,
    KickoffResolveCallbackPendingCompleted,
    KickoffResolveFailedFromStartingRunning,
    KickoffResolveFailedFromStartingStopped,
    KickoffResolveFailedFromStartingCompleted,
    KickoffCancelRequestedRunning,
    KickoffCancelRequestedStopped,
    KickoffCancelRequestedCompleted,
    KickoffClearRunning,
    KickoffClearStopped,
    KickoffClearCompleted,
    SubmitWorkRunningExternal,
    SubmitWorkRunningInternal,
    RetireMember,
    ObserveRuntimeRetired,
    ResetMember,
    RespawnMember,
    MarkCompleted,
    DestroyMob,
    ObserveRuntimeDestroyed,
    RecordOperatorActionProvenanceRunning,
    RecordOperatorActionProvenanceStopped,
    RecordOperatorActionProvenanceCompleted,
    RecordOperatorActionProvenanceDestroyed,
    SetSpawnPolicyRunning,
    SetSpawnPolicyStopped,
    SetSpawnPolicyCompleted,
    SetSpawnPolicyDestroyed,
    StopRunning,
    ResumeStopped,
    CompleteRunning,
    ResetToRunning,
    WireMembersRunning,
    UnwireMembersRunning,
    WireExternalPeerRunning,
    UnwireExternalPeerRunning,
    ForceCancelRunning,
    SubscribeAgentEventsRunning,
    SubscribeAgentEventsStopped,
    SubscribeAgentEventsCompleted,
    SubscribeAgentEventsDestroyed,
    SubscribeAllAgentEventsRunning,
    SubscribeAllAgentEventsStopped,
    SubscribeAllAgentEventsCompleted,
    SubscribeAllAgentEventsDestroyed,
    SubscribeMobEventsRunning,
    SubscribeMobEventsStopped,
    SubscribeMobEventsCompleted,
    SubscribeMobEventsDestroyed,
    ShutdownRunning,
    ShutdownStopped,
    ShutdownCompleted,
    CancelFlowRunning,
    InitializeOrchestratorRunning,
    BindCoordinatorRunning,
    UnbindCoordinatorRunning,
    StageSpawnRunning,
    StopOrchestratorRunning,
    StopOrchestratorStopped,
    StopOrchestratorCompleted,
    ResumeOrchestratorRunning,
    ResumeOrchestratorStopped,
    ResumeOrchestratorCompleted,
    DestroyOrchestratorRunning,
    DestroyOrchestratorStopped,
    DestroyOrchestratorCompleted,
    ForceCancelMemberRunning,
    MemberPeerExposedRunning,
    MemberTerminalizedRunning,
    OperationPeerTrustedRunning,
    PeerInputAdmittedRunning,
    BeginCleanupStopped,
    BeginCleanupCompleted,
    FinishCleanupStopped,
    FinishCleanupCompleted,
    RunFlowRunning,
    CreateRunSeedRunning,
    CreateFrameSeedRunning,
    CreateLoopSeedRunning,
    RecordLoopBodyFrameCompletedRunning,
    RecordLoopUntilConditionMetRunning,
    RecordLoopUntilConditionFailedRunning,
    RecordLoopUntilConditionFailedExhausted,
    AuthorizeFlowRunReducerCommandStartRun,
    AuthorizeFlowRunReducerCommandDispatchStep,
    AuthorizeFlowRunReducerCommandCompleteStep,
    AuthorizeFlowRunReducerCommandRecordStepOutput,
    AuthorizeFlowRunReducerCommandConditionPassed,
    AuthorizeFlowRunReducerCommandConditionRejected,
    AuthorizeFlowRunReducerCommandFailStep,
    AuthorizeFlowRunReducerCommandSkipStep,
    AuthorizeFlowRunReducerCommandProjectFrameStepStatus,
    AuthorizeFlowRunReducerCommandCancelStep,
    AuthorizeFlowRunReducerCommandRegisterTargets,
    AuthorizeFlowRunReducerCommandRecordTargetSuccess,
    AuthorizeFlowRunReducerCommandRecordTargetTerminalFailure,
    AuthorizeFlowRunReducerCommandRecordTargetCanceled,
    AuthorizeFlowRunReducerCommandRecordTargetFailure,
    AuthorizeFlowRunReducerCommandRegisterReadyFrame,
    AuthorizeFlowRunReducerCommandRegisterReadyFrameAlreadyReady,
    AuthorizeFlowRunReducerCommandPumpNodeScheduler,
    AuthorizeFlowRunReducerCommandRegisterPendingBodyFrame,
    AuthorizeFlowRunReducerCommandPumpFrameScheduler,
    AuthorizeFlowRunReducerCommandNodeExecutionReleased,
    AuthorizeFlowRunReducerCommandFrameTerminated,
    AuthorizeFlowRunReducerCommandFrameTerminatedNoActiveFrame,
    AuthorizeFlowRunReducerCommandTerminalCompleted,
    AuthorizeFlowRunReducerCommandTerminalFailed,
    AuthorizeFlowRunReducerCommandTerminalCanceled,
    AuthorizeFlowFrameReducerCommandAdmitNextReadyNode,
    AuthorizeFlowFrameReducerCommandCompleteNode,
    AuthorizeFlowFrameReducerCommandRecordNodeOutput,
    AuthorizeFlowFrameReducerCommandFailNode,
    AuthorizeFlowFrameReducerCommandSkipNode,
    AuthorizeFlowFrameReducerCommandCancelNode,
    AuthorizeFlowFrameReducerCommandSealFrame,
    AuthorizeLoopIterationReducerCommandBodyFrameStarted,
    AuthorizeLoopIterationReducerCommandBodyFrameCompleted,
    AuthorizeLoopIterationReducerCommandBodyFrameFailed,
    AuthorizeLoopIterationReducerCommandBodyFrameCanceled,
    AuthorizeLoopIterationReducerCommandUntilFeedback,
    AuthorizeLoopIterationReducerCommandCancelLoop,
    StartFlowRunning,
    CreateRunRunning,
    StartRunRunning,
    CompleteFlowRunning,
    CompleteFlowRunningZero,
    FinishRunRunning,
    FinishRunRunningZero,
    RetireRunningReleasing,
    RetireRunningPreservingBinding,
    RetireRunningNoBinding,
    RetireStoppedReleasing,
    SessionIngressDetachedForMobDestroyRunning,
    SessionIngressDetachedForMobDestroyStopped,
    SessionIngressDetachFailedForMobDestroyRunning,
    SessionIngressDetachFailedForMobDestroyStopped,
    RetireStoppedPreservingBinding,
    RetireStoppedNoBinding,
    RetireAllRunning,
    RetireAllStopped,
    CompleteSpawnRunning,
    DestroyFromAny,
    RespawnRunning,
    CancelAllWorkRunning,
}
#[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),
    Signal(SignalKind),
}
#[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::Running,
        live_runtime_ids: Default::default(),
        externally_addressable_runtime_ids: Default::default(),
        runtime_fence_tokens: Default::default(),
        active_run_count: 0,
        run_status: Default::default(),
        run_ordered_steps: Default::default(),
        run_tracked_steps: Default::default(),
        run_step_status: Default::default(),
        run_step_status_flat: Default::default(),
        run_output_recorded: Default::default(),
        run_step_condition_results_flat: Default::default(),
        run_step_condition_results: Default::default(),
        run_step_has_conditions: Default::default(),
        run_step_dependencies: Default::default(),
        run_step_dependency_modes: Default::default(),
        run_step_branches: Default::default(),
        run_step_collection_policies: Default::default(),
        run_step_quorum_thresholds: Default::default(),
        run_step_target_counts: Default::default(),
        run_step_target_success_counts: Default::default(),
        run_step_target_terminal_failure_counts: Default::default(),
        run_output_recorded_flat: Default::default(),
        run_step_target_counts_flat: Default::default(),
        run_step_target_success_counts_flat: Default::default(),
        run_step_target_terminal_failure_counts_flat: Default::default(),
        run_target_retry_counts: Default::default(),
        run_target_retry_counts_flat: Default::default(),
        run_failure_count: Default::default(),
        run_consecutive_failure_count: Default::default(),
        run_escalation_threshold: Default::default(),
        run_max_step_retries: Default::default(),
        run_ready_frames: Default::default(),
        run_ready_frame_membership: Default::default(),
        run_ready_frame_membership_flat: Default::default(),
        run_pending_body_frame_loops: Default::default(),
        run_pending_body_frame_loop_membership: Default::default(),
        run_pending_body_frame_loop_membership_flat: Default::default(),
        run_active_node_count: Default::default(),
        run_active_frame_count: Default::default(),
        run_last_granted_frame: Default::default(),
        run_last_granted_loop: Default::default(),
        run_max_active_nodes: Default::default(),
        run_max_active_frames: Default::default(),
        run_max_frame_depth: Default::default(),
        frame_scope: Default::default(),
        frame_phase: Default::default(),
        frame_run: Default::default(),
        frame_parent_loop: Default::default(),
        frame_iteration: Default::default(),
        frame_tracked_nodes: Default::default(),
        frame_ordered_nodes: Default::default(),
        frame_node_kind: Default::default(),
        frame_node_dependencies: Default::default(),
        frame_node_dependency_modes: Default::default(),
        frame_node_step_ids: Default::default(),
        frame_node_loop_ids: Default::default(),
        frame_node_status: Default::default(),
        frame_ready_queue: Default::default(),
        frame_output_recorded: Default::default(),
        frame_output_recorded_flat: Default::default(),
        frame_last_admitted_node: Default::default(),
        frame_node_condition_results: Default::default(),
        frame_node_branches: Default::default(),
        loop_phase: Default::default(),
        loop_parent_frame: Default::default(),
        loop_parent_node: Default::default(),
        loop_definition: Default::default(),
        loop_depth: Default::default(),
        loop_stage: Default::default(),
        loop_current_iteration: Default::default(),
        loop_last_completed_iteration: Default::default(),
        loop_max_iterations: Default::default(),
        loop_active_body_frame: Default::default(),
        pending_spawn_count: 0,
        pending_spawn_sessions: Default::default(),
        coordinator_bound: false,
        member_startup_binding_requested: Default::default(),
        member_startup_runtime_ready: Default::default(),
        member_startup_ready: Default::default(),
        member_kickoff_pending: Default::default(),
        member_kickoff_starting: Default::default(),
        member_kickoff_callback_pending: Default::default(),
        member_kickoff_started: Default::default(),
        member_kickoff_failed: Default::default(),
        member_kickoff_cancelled: Default::default(),
        member_kickoff_error: Default::default(),
        member_restore_failures: Default::default(),
        member_state_markers: Default::default(),
        wiring_edges: Default::default(),
        external_peer_edges: Default::default(),
        identity_to_runtime: Default::default(),
        member_session_bindings: Default::default(),
        pending_session_ingress_detach_runtime_ids: Default::default(),
        topology_epoch: 0,
    }
}
