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.community

//! A group of DIDs that declare shared conventions. Self-constituted per P4: no central roll, no grading of legitimacy. Communities may be small and many.

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

/// A community is a self-constituted group declaring shared schemas, lenses, and conventions. Membership may be listed inline for small communities, or referenced for larger ones.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Community {
    /// Structured community conventions the decidable subset. Review cadence, verification requirements, deprecation policies. Style/tone norms live in `conventionsText`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conventions: Option<Vec<CommunityConventions>>,
    /// Narrative conventions: style guides, tone, conventions not expressible as a structured predicate. Companion to `conventions`.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conventions_text: Option<String>,
    /// Lenses the community treats as canonical.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub core_lenses: Option<Vec<crate::generated::dev::idiolect::defs::LensRef>>,
    /// Schemas the community treats as canonical for its purposes.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub core_schemas: Option<Vec<crate::generated::dev::idiolect::defs::SchemaRef>>,
    pub created_at: idiolect_records::Datetime,
    /// Purpose, norms, and scope of the community. Narrative, not machine-interpreted.
    pub description: String,
    /// Other communities this community recognises as legitimate interlocutors. Endorsement is not transitive.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub endorsed_communities: Option<Vec<idiolect_records::AtUri>>,
    /// Inline list of member DIDs, for small communities. Use membershipRoll instead for communities above ~200 members.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub members: Option<Vec<idiolect_records::Did>>,
    /// AT-URI pointing to an externally maintained membership record for larger communities.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub membership_roll: Option<idiolect_records::AtUri>,
    /// Human-readable community name.
    pub name: String,
}

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

/// How the community handles deprecation: minimum notice, replacement requirements.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConventionDeprecationPolicy {
    /// Minimum days of advance notice before a deprecated lens is removed.
    pub notice_period_days: i64,
    /// Whether deprecations must point at a replacement lens before publication.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub replacement_required: Option<bool>,
}

/// Expected turnaround for community review of proposed lenses/verifications.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConventionReviewCadence {
    /// Maximum business-days expected before a review is posted.
    pub max_days: i64,
    /// Optional narrowing (e.g. 'lens-review', 'verification-review', 'all').
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub scope: Option<String>,
}

/// A verification the community requires before endorsing a lens.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConventionVerificationReq {
    pub kind: ConventionVerificationReqKind,
    /// Optional specific property required.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub property: Option<crate::generated::dev::idiolect::defs::LensProperty>,
}

/// ConventionVerificationReqKind.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ConventionVerificationReqKind {
    RoundtripTest,
    PropertyTest,
    FormalProof,
    ConformanceTest,
    StaticCheck,
    ConvergencePreserving,
}

/// CommunityConventions tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum CommunityConventions {
    #[serde(rename = "dev.idiolect.community#conventionReviewCadence")]
    ConventionReviewCadence(ConventionReviewCadence),
    #[serde(rename = "dev.idiolect.community#conventionVerificationReq")]
    ConventionVerificationReq(ConventionVerificationReq),
    #[serde(rename = "dev.idiolect.community#conventionDeprecationPolicy")]
    ConventionDeprecationPolicy(ConventionDeprecationPolicy),
}