mhome-core-api 1.73.3

Shared wire types and service contracts for the mHome core
Documentation
// Generated from manifest/operation-timeouts.v1.json. DO NOT EDIT.

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Operation {
    CoreRequest,
    HubMigration,
    EventProcessing,
    EntityRefresh,
    HarnessSessionOpen,
    ScriptValidation,
    ScriptSave,
    CoreBridgeRequest,
    CoreBridgeInbound,
    NodeRequest,
    LionBridgeRequest,
    LlmCloudCall,
}

impl Operation {
    pub const fn id(self) -> &'static str {
        match self {
            Self::CoreRequest => "coreRequest",
            Self::HubMigration => "hubMigration",
            Self::EventProcessing => "eventProcessing",
            Self::EntityRefresh => "entityRefresh",
            Self::HarnessSessionOpen => "harnessSessionOpen",
            Self::ScriptValidation => "scriptValidation",
            Self::ScriptSave => "scriptSave",
            Self::CoreBridgeRequest => "coreBridgeRequest",
            Self::CoreBridgeInbound => "coreBridgeInbound",
            Self::NodeRequest => "nodeRequest",
            Self::LionBridgeRequest => "lionBridgeRequest",
            Self::LlmCloudCall => "llmCloudCall",
        }
    }

    pub const fn timeout(self) -> Duration {
        Duration::from_millis(match self {
            Self::CoreRequest => 60000,
            Self::HubMigration => 600000,
            Self::EventProcessing => 60000,
            Self::EntityRefresh => 85000,
            Self::HarnessSessionOpen => 150000,
            Self::ScriptValidation => 60000,
            Self::ScriptSave => 60000,
            Self::CoreBridgeRequest => 35000,
            Self::CoreBridgeInbound => 55000,
            Self::NodeRequest => 60000,
            Self::LionBridgeRequest => 60000,
            Self::LlmCloudCall => 180000,
        })
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WaitProfile {
    HostIpc,
    CoreBridge,
    Client,
    LionForward,
}

impl WaitProfile {
    pub const fn grace(self, operation: Operation) -> Duration {
        Duration::from_millis(match (self, operation) {
            (Self::HostIpc, _) => 5000,
            (Self::CoreBridge, _) => 10000,
            (Self::Client, _) => 35000,
            (Self::LionForward, Operation::EntityRefresh) => 5000,
            (Self::LionForward, Operation::ScriptValidation) => 25000,
            (Self::LionForward, Operation::ScriptSave) => 30000,
            (Self::LionForward, _) => 0,
        })
    }
}

const FORWARD_PREFIXES: &[&str] = &[
    "/invoke",
    "/dispatch/agent",
    "/dispatch",
];

const STORED_SCRIPT_SAVE: &[&str] = &[
    "/app/automation/snapshot/rollback",
    "/app/presentation/automation/overview/save",
    "/app/presentation/automation/copy",
    "/app/presentation/automation/enroll",
];

const SOURCE_SCRIPT_SAVE: &[&str] = &[
    "/app/automation/save",
];

const SOURCE_SCRIPT_VALIDATION: &[&str] = &[
    "/app/automation/verify",
    "/bridge/automation/parse",
    "/bridge/automation/format",
    "/bridge/automation/verify",
    "/bridge/automation/compile",
    "/bridge/agent/automation/compile",
];

const ORDINARY_OVERRIDES: &[(&str, Operation)] = &[
    ("/hub/revoke/start", Operation::HubMigration),
    ("/bridge/hub/revoke/dataUploaded", Operation::HubMigration),
    ("/app/integration/entity/refresh", Operation::EntityRefresh),
    ("/harness/test/session/open", Operation::HarnessSessionOpen),
];