idiolect-records 0.4.1

Rust record types mirroring the dev.idiolect.* Lexicon family.
Documentation
// @generated by idiolect-codegen. do not edit.
// source: dev.idiolect.retrospection

//! A signed annotation of a prior encounter with a delayed finding. Retrospections address silent-error latency: merges, migrations, and bitemporal reconciliations often surface failures only after long delay.

#![allow(
    missing_docs,
    clippy::doc_markdown,
    clippy::struct_excessive_bools,
    clippy::derive_partial_eq_without_eq
)]
use serde::{Deserialize, Serialize};

/// Attribution and detection of a latent issue in a prior encounter. Causal claims are the publisher's judgment; disputes are themselves first-class records.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Retrospection {
    /// Grounding for the finding. Omit when self-asserted by the detecting party; set explicitly when a third party is attributing the detection or when the finding rests on an external analysis.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub basis: Option<crate::generated::dev::idiolect::defs::Basis>,
    /// Optional confidence score in [0, 1]. Omit when the finding is unambiguous.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub confidence: Option<f64>,
    pub detected_at: idiolect_records::Datetime,
    /// DID of the party that detected the issue.
    pub detecting_party: idiolect_records::Did,
    /// True if the detecting party anticipates the causal attribution will be contested. A hint, not a fact; contest records are separate.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub disputed_attribution: Option<bool>,
    pub encounter: crate::generated::dev::idiolect::defs::EncounterRef,
    /// Finding kind plus structured evidence and narrative detail. For kind=merge-divergence/data-loss/reconciliation-mismatch, `evidence` is the structured witness consumers can match on; for kind=other, evidence is optional and `detail` carries the whole finding.
    pub finding: RetrospectionFinding,
    /// Detection latency in seconds (detectedAt - encounter.occurredAt). Precomputed for easy aggregation; may be omitted for 'other' findings where latency is not meaningful.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub latency: Option<i64>,
    /// When this retrospection record was published.
    pub occurred_at: idiolect_records::Datetime,
}

impl crate::Record for Retrospection {
    const NSID: &'static str = "dev.idiolect.retrospection";
}

/// Finding kind plus structured evidence and narrative detail. For kind=merge-divergence/data-loss/reconciliation-mismatch, `evidence` is the structured witness consumers can match on; for kind=other, evidence is optional and `detail` carries the whole finding.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RetrospectionFinding {
    /// Narrative detail. Human commentary; complements structured `evidence`.
    pub detail: String,
    /// Structured witness for the finding. See dev.idiolect.theory.finding.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub evidence: Option<RetrospectionFindingEvidence>,
    pub kind: RetrospectionFindingKind,
}
/// RetrospectionFindingEvidence tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum RetrospectionFindingEvidence {
    #[serde(rename = "dev.idiolect.defs#evidenceDivergence")]
    EvidenceDivergence(crate::generated::dev::idiolect::defs::EvidenceDivergence),
    #[serde(rename = "dev.idiolect.defs#evidenceLoss")]
    EvidenceLoss(crate::generated::dev::idiolect::defs::EvidenceLoss),
    #[serde(rename = "dev.idiolect.defs#evidenceMismatch")]
    EvidenceMismatch(crate::generated::dev::idiolect::defs::EvidenceMismatch),
}
/// RetrospectionFindingKind.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum RetrospectionFindingKind {
    MergeDivergence,
    DataLoss,
    ReconciliationMismatch,
    Other,
}