idiolect-records 0.1.0

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

//! A signed record of a single lens invocation. Encounters are the emergent-channel primitive: they record that a translation occurred, with enough context for aggregators (observations) and correctors to reason about it.

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

/// One invocation of a lens on a source, producing an output. Kind declares the encounter's context so observers can weight correctly.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Encounter {
    /// Narrative notes from the invoking party.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<String>,
    /// Outcome as assessed by the invoking party at record time. 'corrected' signals a follow-up correction record is expected or exists.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub downstream_result: Option<EncounterDownstreamResult>,
    /// Fixed taxonomy at the Lexicon level. Observers declare how they weight each kind.
    pub kind: EncounterKind,
    /// The lens that was invoked.
    pub lens: super::defs::LensRef,
    /// When the lens invocation occurred. Distinct from the record's createdAt, which may be later.
    pub occurred_at: String,
    /// Optional content-addressed reference to the produced output.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub produced_output: Option<String>,
    /// Free-text statement of why this translation was performed.
    pub purpose: String,
    /// Optional content-addressed reference to the source instance, when the publisher is willing to include it. Omit when visibility restricts publication of source data.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub source_instance: Option<String>,
    /// The source schema the lens translated from.
    pub source_schema: super::defs::SchemaRef,
    /// The target schema produced by the lens. Often implied by the lens; may be elided when unambiguous.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub target_schema: Option<super::defs::SchemaRef>,
    pub visibility: super::defs::Visibility,
}

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

/// EncounterDownstreamResult.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum EncounterDownstreamResult {
    Success,
    Corrected,
    Rejected,
    Unknown,
}

/// EncounterKind.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum EncounterKind {
    InvocationLog,
    Curated,
    RoundtripVerified,
    Production,
    Adversarial,
}