idiolect-records 0.4.1

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

//! A declaration that a translation, verification, or adapter is wanted, with terms. `constraints` is a structured ThConstraint tagged-union set and `eligibility` is a ThEligibility combinator tree; reward.summary stays narrative, externalRef stays the machine-actionable hook. Per P5, the project does not intermediate fulfillment: payment, review, and acceptance happen on external rails referenced here.

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

/// A request primitive. Someone states what they want (a lens, a verification, an adapter) and the structured constraints + eligibility they require; fulfillment is resolved off-substrate.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Bounty {
    /// Grounding for the bouletic attitude. Omit when the repo owner is the requester (self-asserted). Set explicitly when a third party is attributing the wanting to another party — the basis records on what grounds the attribution is made (community policy, an off-atproto signal, or derivation from another record).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub basis: Option<crate::generated::dev::idiolect::defs::Basis>,
    /// Structured constraints the deliverable must satisfy. Matching is structural: consumers dispatch on the tagged variant.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub constraints: Option<Vec<BountyConstraints>>,
    /// Structured eligibility predicate in postfix-operator form: each item is either an atomic predicate or a combinator (and/or/not) that pops its operands from the running stack. An empty array means 'no eligibility restriction'. A single atomic item is the lone predicate.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub eligibility: Option<Vec<BountyEligibility>>,
    /// Once fulfilled, points to the deliverable record (lens, verification, or adapter).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub fulfillment: Option<idiolect_records::AtUri>,
    pub occurred_at: idiolect_records::Datetime,
    pub requester: idiolect_records::Did,
    /// Reward terms. The bounty record does not transact; `externalRef` is the machine-actionable hook; `summary` is narrative.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub reward: Option<BountyReward>,
    /// Current lifecycle state as declared by the requester.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub status: Option<BountyStatus>,
    /// What is being requested. Exactly one of: a lens between two schemas, a verification of a lens, or an adapter for a framework.
    pub wants: BountyWants,
}

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

/// A verification kind (and optionally a specific property) the deliverable must pass.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintConformance {
    pub kind: ConstraintConformanceKind,
    /// Optional specific property the verification must establish.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub property: Option<crate::generated::dev::idiolect::defs::LensProperty>,
}

/// Datetime deadline with optional grace window.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintDeadline {
    pub deadline: idiolect_records::Datetime,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub grace_seconds: Option<i64>,
}

/// Another bounty this one waits on. Claims are ineligible until the dependency's status is `fulfilled`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintDependency {
    pub bounty: idiolect_records::AtUri,
}

/// License requirement expressed as an SPDX expression plus optional allow/deny lists.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintLicense {
    /// Explicit allowlist of SPDX identifiers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub allow: Option<Vec<String>>,
    /// Explicit denylist of SPDX identifiers.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub deny: Option<Vec<String>>,
    /// SPDX expression the deliverable must satisfy (e.g. 'MIT OR Apache-2.0').
    pub spdx: String,
}

/// Quantitative performance bound (latency, throughput, error rate) the deliverable must meet.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConstraintPerformance {
    /// How `metric` relates to `threshold`. Default 'le' if omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cmp: Option<ConstraintPerformanceCmp>,
    /// Metric identifier (e.g. 'p99-latency-ms', 'throughput-rps', 'error-rate').
    pub metric: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sample_size: Option<i64>,
    /// Numeric threshold. Comparison direction is carried by `cmp`.
    pub threshold: f64,
}

/// Combinator: conjoin the top two predicates on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityAnd {}

/// Atomic predicate: claimer's DID matches exactly.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityDid {
    pub did: idiolect_records::Did,
}

/// Atomic predicate: claimer is a member of the named community.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityMember {
    pub community: idiolect_records::AtUri,
}

/// Combinator: negate the top predicate on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityNot {}

/// Combinator: disjoin the top two predicates on the evaluation stack.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityOr {}

/// Atomic predicate: claimer has published a verification for the named lens property.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EligibilityVerificationFor {
    pub property: crate::generated::dev::idiolect::defs::LensProperty,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantAdapter {
    pub framework: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub version_range: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantLens {
    /// Whether the requested lens must be invertible.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub bidirectional: Option<bool>,
    pub source: crate::generated::dev::idiolect::defs::SchemaRef,
    pub target: crate::generated::dev::idiolect::defs::SchemaRef,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WantVerification {
    pub kind: WantVerificationKind,
    pub lens: crate::generated::dev::idiolect::defs::LensRef,
}

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

/// ConstraintPerformanceCmp.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ConstraintPerformanceCmp {
    Lt,
    Le,
    Eq,
    Ge,
    Gt,
}

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

/// BountyConstraints tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyConstraints {
    #[serde(rename = "dev.idiolect.bounty#constraintPerformance")]
    ConstraintPerformance(ConstraintPerformance),
    #[serde(rename = "dev.idiolect.bounty#constraintConformance")]
    ConstraintConformance(ConstraintConformance),
    #[serde(rename = "dev.idiolect.bounty#constraintLicense")]
    ConstraintLicense(ConstraintLicense),
    #[serde(rename = "dev.idiolect.bounty#constraintDeadline")]
    ConstraintDeadline(ConstraintDeadline),
    #[serde(rename = "dev.idiolect.bounty#constraintDependency")]
    ConstraintDependency(ConstraintDependency),
}

/// BountyEligibility tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyEligibility {
    #[serde(rename = "dev.idiolect.bounty#eligibilityMember")]
    EligibilityMember(EligibilityMember),
    #[serde(rename = "dev.idiolect.bounty#eligibilityVerificationFor")]
    EligibilityVerificationFor(EligibilityVerificationFor),
    #[serde(rename = "dev.idiolect.bounty#eligibilityDid")]
    EligibilityDid(EligibilityDid),
    #[serde(rename = "dev.idiolect.bounty#eligibilityAnd")]
    EligibilityAnd(EligibilityAnd),
    #[serde(rename = "dev.idiolect.bounty#eligibilityOr")]
    EligibilityOr(EligibilityOr),
    #[serde(rename = "dev.idiolect.bounty#eligibilityNot")]
    EligibilityNot(EligibilityNot),
}

/// BountyWants tagged union.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "$type")]
pub enum BountyWants {
    #[serde(rename = "dev.idiolect.bounty#wantLens")]
    WantLens(WantLens),
    #[serde(rename = "dev.idiolect.bounty#wantVerification")]
    WantVerification(WantVerification),
    #[serde(rename = "dev.idiolect.bounty#wantAdapter")]
    WantAdapter(WantAdapter),
}

/// BountyStatus.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum BountyStatus {
    Open,
    Claimed,
    Fulfilled,
    Withdrawn,
}

/// Reward terms. The bounty record does not transact; `externalRef` is the machine-actionable hook; `summary` is narrative.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BountyReward {
    /// URL pointing to the rail that handles actual reward (grant portal, payment platform, attestation service).
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub external_ref: Option<idiolect_records::Uri>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub summary: Option<String>,
}