idiolect-records 0.2.0

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

//! A signed record of a post-translation edit. Corrections are the primary signal an observer uses to detect lens quality issues; the reason taxonomy decouples 'lens was wrong' from 'the world is complicated'.

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

/// A specific edit to the output of an encounter, attributed by reason.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Correction {
    /// Structured grounding for the edit. Useful when `holder` is a third party and the record must state on what basis the correction is being attributed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub basis: Option<super::defs::Basis>,
    /// The value after correction.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub corrected_value: Option<serde_json::Value>,
    /// The encounter whose output was edited.
    pub encounter: super::defs::EncounterRef,
    /// DID of the party the correction is attributed to. Omit for first-party records; set explicitly when a third party is recording someone else's edit (e.g. a reviewer transcribing an off-network correction).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holder: Option<String>,
    pub occurred_at: String,
    /// The value prior to correction. May be elided for visibility reasons.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub original_value: Option<serde_json::Value>,
    /// JSON Pointer or equivalent path into the produced output identifying the edited location.
    pub path: String,
    /// Optional human-readable justification for the correction.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub rationale: Option<String>,
    /// Fixed taxonomy at the Lexicon level. Aggregators filter or weight by reason; corrections of different reasons signal different things about a lens.
    pub reason: CorrectionReason,
    pub visibility: super::defs::Visibility,
}

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

/// CorrectionReason.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum CorrectionReason {
    LensError,
    DomainDifference,
    SourceError,
    DownstreamIdiosyncrasy,
    UserMistake,
    Retrospective,
}