aion-core 0.29.0

Pure domain model and shared vocabulary for Aion durable workflows.
Documentation
//! What a read surface says about ITSELF alongside what it says about a run.
//!
//! ADR-016: the console never lies about its own provenance. A summary that
//! shows no worker for an attempt is UNATTRIBUTED, and that one word covers
//! two facts a reader must be able to tell apart — the run was recorded
//! before lease events existed, or THIS install knew the worker and failed
//! to record it. History cannot carry the second fact (an append that fails
//! cannot record its own failure), so every read surface carries the
//! install's count beside the data, and a reader compares the two.

use serde::{Deserialize, Serialize};

/// The serving install's own state at read time, stamped on every describe
/// and list response. A response that carries NONE is from a server that
/// predates the field; readers keep that distinct from a zero count.
#[derive(Serialize, Deserialize, ts_rs::TS, Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct ReadProvenance {
    /// Leases THIS install knew and failed to record since it booted
    /// (`aion_activity_lease_record_failures_total`, WA-010 R3).
    ///
    /// Read it against an unattributed attempt: `0` with a run that predates
    /// lease events means "never recorded here"; `N > 0` means "recorded
    /// here with N losses" and the attempt may be one of them. A client that
    /// reads an embedded engine with no dispatcher reports `0`, which is
    /// exact — nothing was leased there to lose.
    ///
    /// The count is the SHARED ledger every production dispatcher records
    /// through. A dispatcher mis-wired with a private default seam and never
    /// handed the shared one loses onto an orphan ledger — loud per dispatch
    /// in the server log, but invisible here and on the metric. That wiring
    /// is a bug, not a mode; this field cannot see it.
    pub lease_record_failures_total: u64,
}

impl ReadProvenance {
    /// Provenance for an install that has lost `lease_record_failures_total`
    /// lease records.
    #[must_use]
    pub const fn new(lease_record_failures_total: u64) -> Self {
        Self {
            lease_record_failures_total,
        }
    }
}