idiolect-records 0.6.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. `use` is a structured ThUse (see dev.idiolect.theory.use) covering action/material/purpose/actor; narrative commentary lives in `annotations`.

#![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. The invoker asserts a purposeful invocation: structured `purpose` records the decision-relevant action/material/actor triple, resolvable against a community vocabulary.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Encounter {
    /// Narrative notes from the invoking party. Human commentary; not consumed by machine matchers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<String>,
    /// Structured grounding for the assertion. Useful when `holder` is a third party and the record must state on what basis the invocation is being attributed.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub basis: Option<crate::generated::dev::idiolect::defs::Basis>,
    /// 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>,
    /// DID of the party the encounter is attributed to. Omit for first-party records (holder is implicit in the repo owner); set explicitly for third-party attestations such as a labeler recording someone else's invocation.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub holder: Option<idiolect_records::Did>,
    /// Fixed taxonomy at the Lexicon level. Observers declare how they weight each kind.
    pub kind: EncounterKind,
    /// The lens that was invoked.
    pub lens: crate::generated::dev::idiolect::defs::LensRef,
    /// When the lens invocation occurred. Distinct from the record's createdAt, which may be later.
    pub occurred_at: idiolect_records::Datetime,
    /// Optional content-addressed reference to the produced output.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub produced_output: Option<idiolect_records::Cid>,
    /// 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<idiolect_records::Cid>,
    /// The source schema the lens translated from.
    pub source_schema: crate::generated::dev::idiolect::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<crate::generated::dev::idiolect::defs::SchemaRef>,
    /// Structured record of the action performed, its material, its purpose, and its actor. Consumers match on action subsumption against the referenced vocabularies, not substring.
    pub r#use: crate::generated::dev::idiolect::defs::Use,
    pub visibility: crate::generated::dev::idiolect::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,
}