alloy-assurance 0.3.0

Shared assurance facade for the Alloy workspace
Documentation
use serde::{Deserialize, Serialize};

/// Describes the current Sprint 3 scope for this crate.
#[must_use]
pub const fn scope() -> &'static str {
    "phase-1-v0.1"
}

/// Canonical on-disk replay bundle schema version for generalized Phase 1 artifacts.
#[must_use]
pub const fn canonical_replay_schema_version() -> &'static str {
    "phase-1-v0.1"
}

/// Stable schema identifier for the restart/re-query replay payload.
#[must_use]
pub const fn restart_requery_schema_id() -> &'static str {
    "sr.iridium.restart-requery.v1"
}

/// Result class for evidence consumers.
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum ScenarioOutcome {
    /// All checks passed.
    Pass,
    /// One or more checks failed.
    Fail,
    /// Mixed outcome across sub-checks.
    Mixed,
}

impl ScenarioOutcome {
    /// Returns the stable wire spelling for the outcome.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Pass => "pass",
            Self::Fail => "fail",
            Self::Mixed => "mixed",
        }
    }
}

/// Failure taxonomy for replayable evidence.
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum FailureClassification {
    /// No failure was observed.
    None,
    /// Capability gap or unsupported plan shape.
    CapabilityMismatch,
    /// Failure across restart and re-query consistency.
    RestartConsistency,
    /// Recovery regression observed during restart or recovery.
    RecoveryRegression,
    /// Cache-transition issue.
    CacheTransition,
    /// Transport or orchestration issue.
    TransportFault,
}

impl FailureClassification {
    /// Returns the stable wire spelling for the failure class.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::None => "none",
            Self::CapabilityMismatch => "capability-mismatch",
            Self::RestartConsistency => "restart-consistency",
            Self::RecoveryRegression => "recovery-regression",
            Self::CacheTransition => "cache-transition",
            Self::TransportFault => "transport-fault",
        }
    }
}

/// Evidence severity and gating level.
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum EvidenceLevel {
    /// Informational only.
    Informational,
    /// Intended to catch regressions before release.
    RegressionProtecting,
    /// Blocks release claims on failure.
    ReleaseBlocking,
}

/// Phase 1 scenario classes supported by the replay schema.
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum ScenarioClass {
    /// Restart and recovery path.
    RestartRecovery,
    /// Capability rejection path.
    CapabilityRejection,
    /// Cache-mode transition path.
    CacheTransition,
    /// Transport fault path.
    TransportFault,
}

impl ScenarioClass {
    /// Returns the stable wire spelling for the scenario class.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::RestartRecovery => "restart-recovery",
            Self::CapabilityRejection => "capability-rejection",
            Self::CacheTransition => "cache-transition",
            Self::TransportFault => "transport-fault",
        }
    }
}