idiolect-records 0.8.0

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

//! Observer-aggregated tally for a `dev.idiolect.deliberation`. Not a participant-authored record: produced by an observer fold over the vote stream and published from the observer's repo. Consumers reading a closed deliberation can fetch the outcome directly rather than re-folding every vote. Tallies are per-statement and per-stance, so consumers can render a Polis-style opinion map without further computation.

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

/// Aggregated outcome of a deliberation: per-statement vote counts grouped by stance, plus an optional list of statements the community treats as adopted. Multiple outcome records per deliberation are permitted (different observers, different cut-off times); consumers select among them by author or `computedAt`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DeliberationOutcome {
    /// Strong references to statements the community adopted as the deliberation's resolution. Empty when the deliberation closed without adoption.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub adopted: Option<Vec<crate::generated::dev::idiolect::defs::StrongRecordRef>>,
    /// When the observer computed this tally. Distinct from `occurredAt`; consumers comparing two outcomes for the same deliberation order them by `computedAt`.
    pub computed_at: idiolect_records::Datetime,
    /// Strong reference to the deliberation this outcome aggregates.
    pub deliberation: crate::generated::dev::idiolect::defs::StrongRecordRef,
    pub occurred_at: idiolect_records::Datetime,
    /// Vocabulary the per-tally stance slugs resolve against. The outcome MUST use a single vocabulary across all tallies; observers that see votes referencing different vocabularies must publish separate outcomes per vocab or first translate via a `mapEnum` lens.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub stance_vocab: Option<crate::generated::dev::idiolect::defs::VocabRef>,
    /// Per-statement vote counts. One entry per statement that received at least one vote.
    pub statement_tallies: Vec<StatementTally>,
    /// Identity and version of the observer/aggregator that produced this outcome. Useful when multiple aggregators publish outcomes for the same deliberation under different stance vocabularies or weighting schemes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub tool: Option<crate::generated::dev::idiolect::defs::Tool>,
}

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

/// A stance slug paired with its count.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StanceCount {
    /// Non-negative count. For `weightedCounts` entries, scaled by 1000 to encode 0.0-1.0 sums.
    pub count: i64,
    /// Stance slug, resolved through the outcome record's `stanceVocab`.
    pub stance: String,
}

/// Vote count for a single statement, broken down by stance. Stance keys are slugs in the vocabulary named at the record root; counts are non-negative integers. Statements with zero votes need not appear.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StatementTally {
    /// Per-stance vote count entries. Each entry pairs a stance slug with its count.
    pub counts: Vec<StanceCount>,
    /// Strong reference to the statement these counts aggregate.
    pub statement: crate::generated::dev::idiolect::defs::StrongRecordRef,
    /// Per-stance weighted vote counts when the underlying votes carried `weight`. Scaled by 1000 to match the vote-record weight convention. Optional; absent when no votes carried weights or when the aggregator is uniform.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub weighted_counts: Option<Vec<StanceCount>>,
}