// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.gainforest.evaluator.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

pub mod evaluation;
pub mod service;
pub mod subscription;


#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_gainforest::evaluator;
/// A candidate taxon identification with confidence score and rank.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CandidateTaxon<'a> {
    ///Confidence score (0-1000, where 1000 = 100.0%).
    pub confidence: i64,
    ///Family of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub family: Option<CowStr<'a>>,
    ///GBIF backbone taxonomy key for the candidate.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub gbif_taxon_key: Option<CowStr<'a>>,
    ///Genus of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub genus: Option<CowStr<'a>>,
    ///Kingdom of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub kingdom: Option<CowStr<'a>>,
    ///Rank position among candidates (1 = best match).
    pub rank: i64,
    ///Full scientific name of the candidate taxon.
    #[serde(borrow)]
    pub scientific_name: CowStr<'a>,
}

/// Generic categorical classification result (e.g., conservation priority, habitat type).

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ClassificationResult<'a> {
    ///The classification category (e.g., 'conservation-priority', 'habitat-type').
    #[serde(borrow)]
    pub category: CowStr<'a>,
    ///Additional notes about the classification.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub remarks: Option<CowStr<'a>>,
    ///The assigned classification value (e.g., 'critical', 'tropical-rainforest').
    #[serde(borrow)]
    pub value: CowStr<'a>,
}

/// Data quality assessment result with per-field quality flags.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct DataQualityResult<'a> {
    ///Overall completeness score (0-1000, where 1000 = 100.0%).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub completeness_score: Option<i64>,
    ///List of quality issues found in the record.
    #[serde(borrow)]
    pub flags: Vec<evaluator::QualityFlag<'a>>,
    ///Additional notes about the quality assessment.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub remarks: Option<CowStr<'a>>,
}

/// A single measurement derived by an evaluator from source data.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct DerivedMeasurement<'a> {
    ///Description of the method used to obtain the measurement.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_method: Option<CowStr<'a>>,
    ///The nature of the measurement (e.g., 'canopy cover', 'NDVI', 'tree height').
    #[serde(borrow)]
    pub measurement_type: CowStr<'a>,
    ///The units for the measurement value (e.g., '%', 'm', 'kg').
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measurement_unit: Option<CowStr<'a>>,
    ///The value of the measurement.
    #[serde(borrow)]
    pub measurement_value: CowStr<'a>,
}

/// Derived measurements produced by an evaluator from source data (e.g., remote sensing metrics).

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MeasurementResult<'a> {
    ///List of derived measurements.
    #[serde(borrow)]
    pub measurements: Vec<evaluator::DerivedMeasurement<'a>>,
    ///Additional notes about the measurements.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub remarks: Option<CowStr<'a>>,
}

/// Provenance metadata describing the method used to produce an evaluation.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct MethodInfo<'a> {
    ///Identifier for the specific model checkpoint used (e.g., date or hash).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub model_checkpoint: Option<CowStr<'a>>,
    ///Human-readable name of the method or model (e.g., 'GainForest BioClassifier').
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///URIs to papers, documentation, or repositories describing this method.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub references: Option<Vec<UriValue<'a>>>,
    ///Version string of the method or model (e.g., '2.1.0').
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub version: Option<CowStr<'a>>,
}

/// A single data quality flag indicating an issue with a specific field.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct QualityFlag<'a> {
    ///The field name that has the quality issue.
    #[serde(borrow)]
    pub field: CowStr<'a>,
    ///Description of the quality issue.
    #[serde(borrow)]
    pub issue: CowStr<'a>,
    ///Severity level of the quality issue.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub severity: Option<QualityFlagSeverity<'a>>,
}

/// Severity level of the quality issue.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum QualityFlagSeverity<'a> {
    Error,
    Warning,
    Info,
    Other(CowStr<'a>),
}

impl<'a> QualityFlagSeverity<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Error => "error",
            Self::Warning => "warning",
            Self::Info => "info",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for QualityFlagSeverity<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "error" => Self::Error,
            "warning" => Self::Warning,
            "info" => Self::Info,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for QualityFlagSeverity<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "error" => Self::Error,
            "warning" => Self::Warning,
            "info" => Self::Info,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for QualityFlagSeverity<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for QualityFlagSeverity<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for QualityFlagSeverity<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for QualityFlagSeverity<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for QualityFlagSeverity<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for QualityFlagSeverity<'_> {
    type Output = QualityFlagSeverity<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            QualityFlagSeverity::Error => QualityFlagSeverity::Error,
            QualityFlagSeverity::Warning => QualityFlagSeverity::Warning,
            QualityFlagSeverity::Info => QualityFlagSeverity::Info,
            QualityFlagSeverity::Other(v) => QualityFlagSeverity::Other(v.into_static()),
        }
    }
}

/// AI or human species recognition result with ranked candidate identifications.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SpeciesIdResult<'a> {
    ///Ranked list of candidate species identifications.
    #[serde(borrow)]
    pub candidates: Vec<evaluator::CandidateTaxon<'a>>,
    ///Which feature of the subject record was used as input (e.g., 'mediaEvidence').
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub input_feature: Option<CowStr<'a>>,
    ///Additional notes about the species identification.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub remarks: Option<CowStr<'a>>,
}

/// Reference to a target record that is being evaluated.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SubjectRef<'a> {
    ///CID pinning the exact version of the target record.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    ///AT-URI of the target record.
    #[serde(borrow)]
    pub uri: AtUri<'a>,
}

/// Expert verification result for a previous identification or evaluation.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct VerificationResult<'a> {
    ///Notes about the verification decision.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub remarks: Option<CowStr<'a>>,
    ///Verification status: confirmed, rejected, or uncertain.
    #[serde(borrow)]
    pub status: VerificationResultStatus<'a>,
    ///Suggested corrections if the original identification was rejected or uncertain.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub suggested_corrections: Option<CowStr<'a>>,
    ///Name of the person who performed the verification.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub verified_by: Option<CowStr<'a>>,
    ///Persistent identifier (e.g., ORCID) of the verifier.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub verified_by_id: Option<CowStr<'a>>,
}

/// Verification status: confirmed, rejected, or uncertain.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VerificationResultStatus<'a> {
    Confirmed,
    Rejected,
    Uncertain,
    Other(CowStr<'a>),
}

impl<'a> VerificationResultStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Confirmed => "confirmed",
            Self::Rejected => "rejected",
            Self::Uncertain => "uncertain",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VerificationResultStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "confirmed" => Self::Confirmed,
            "rejected" => Self::Rejected,
            "uncertain" => Self::Uncertain,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VerificationResultStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "confirmed" => Self::Confirmed,
            "rejected" => Self::Rejected,
            "uncertain" => Self::Uncertain,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for VerificationResultStatus<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for VerificationResultStatus<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for VerificationResultStatus<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VerificationResultStatus<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VerificationResultStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for VerificationResultStatus<'_> {
    type Output = VerificationResultStatus<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            VerificationResultStatus::Confirmed => VerificationResultStatus::Confirmed,
            VerificationResultStatus::Rejected => VerificationResultStatus::Rejected,
            VerificationResultStatus::Uncertain => VerificationResultStatus::Uncertain,
            VerificationResultStatus::Other(v) => {
                VerificationResultStatus::Other(v.into_static())
            }
        }
    }
}

impl<'a> LexiconSchema for CandidateTaxon<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "candidateTaxon"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.confidence;
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("confidence"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.confidence;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("confidence"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.family {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("family"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.gbif_taxon_key {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("gbif_taxon_key"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.genus {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("genus"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.kingdom {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("kingdom"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.rank;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rank"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.scientific_name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("scientific_name"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for ClassificationResult<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "classificationResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.category;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("category"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.value;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("value"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for DataQualityResult<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "dataQualityResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.completeness_score {
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("completeness_score"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.completeness_score {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("completeness_score"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.flags;
            #[allow(unused_comparisons)]
            if value.len() > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("flags"),
                    max: 50usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for DerivedMeasurement<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "derivedMeasurement"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.measurement_method {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_method"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_type;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_type"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_unit {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_unit"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_value;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_value"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for MeasurementResult<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "measurementResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.measurements;
            #[allow(unused_comparisons)]
            if value.len() > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("measurements"),
                    max: 20usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for MethodInfo<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "methodInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.model_checkpoint {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("model_checkpoint"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.references {
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("references"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.version {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("version"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for QualityFlag<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "qualityFlag"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.field;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("field"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.issue;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("issue"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.severity {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("severity"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for SpeciesIdResult<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "speciesIdResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.candidates;
            #[allow(unused_comparisons)]
            if value.len() > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("candidates"),
                    max: 20usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.input_feature {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("input_feature"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for SubjectRef<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "subjectRef"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for VerificationResult<'a> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "verificationResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.status;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("status"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.suggested_corrections {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 5000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("suggested_corrections"),
                        max: 5000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.verified_by {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("verified_by"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.verified_by_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("verified_by_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod candidate_taxon_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Rank;
        type ScientificName;
        type Confidence;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Rank = Unset;
        type ScientificName = Unset;
        type Confidence = Unset;
    }
    ///State transition - sets the `rank` field to Set
    pub struct SetRank<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRank<S> {}
    impl<S: State> State for SetRank<S> {
        type Rank = Set<members::rank>;
        type ScientificName = S::ScientificName;
        type Confidence = S::Confidence;
    }
    ///State transition - sets the `scientific_name` field to Set
    pub struct SetScientificName<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetScientificName<S> {}
    impl<S: State> State for SetScientificName<S> {
        type Rank = S::Rank;
        type ScientificName = Set<members::scientific_name>;
        type Confidence = S::Confidence;
    }
    ///State transition - sets the `confidence` field to Set
    pub struct SetConfidence<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetConfidence<S> {}
    impl<S: State> State for SetConfidence<S> {
        type Rank = S::Rank;
        type ScientificName = S::ScientificName;
        type Confidence = Set<members::confidence>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `rank` field
        pub struct rank(());
        ///Marker type for the `scientific_name` field
        pub struct scientific_name(());
        ///Marker type for the `confidence` field
        pub struct confidence(());
    }
}

/// Builder for constructing an instance of this type
pub struct CandidateTaxonBuilder<'a, S: candidate_taxon_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<i64>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> CandidateTaxon<'a> {
    /// Create a new builder for this type
    pub fn new() -> CandidateTaxonBuilder<'a, candidate_taxon_state::Empty> {
        CandidateTaxonBuilder::new()
    }
}

impl<'a> CandidateTaxonBuilder<'a, candidate_taxon_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        CandidateTaxonBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CandidateTaxonBuilder<'a, S>
where
    S: candidate_taxon_state::State,
    S::Confidence: candidate_taxon_state::IsUnset,
{
    /// Set the `confidence` field (required)
    pub fn confidence(
        mut self,
        value: impl Into<i64>,
    ) -> CandidateTaxonBuilder<'a, candidate_taxon_state::SetConfidence<S>> {
        self._fields.0 = Option::Some(value.into());
        CandidateTaxonBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: candidate_taxon_state::State> CandidateTaxonBuilder<'a, S> {
    /// Set the `family` field (optional)
    pub fn family(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `family` field to an Option value (optional)
    pub fn maybe_family(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: candidate_taxon_state::State> CandidateTaxonBuilder<'a, S> {
    /// Set the `gbifTaxonKey` field (optional)
    pub fn gbif_taxon_key(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `gbifTaxonKey` field to an Option value (optional)
    pub fn maybe_gbif_taxon_key(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: candidate_taxon_state::State> CandidateTaxonBuilder<'a, S> {
    /// Set the `genus` field (optional)
    pub fn genus(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `genus` field to an Option value (optional)
    pub fn maybe_genus(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: candidate_taxon_state::State> CandidateTaxonBuilder<'a, S> {
    /// Set the `kingdom` field (optional)
    pub fn kingdom(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `kingdom` field to an Option value (optional)
    pub fn maybe_kingdom(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> CandidateTaxonBuilder<'a, S>
where
    S: candidate_taxon_state::State,
    S::Rank: candidate_taxon_state::IsUnset,
{
    /// Set the `rank` field (required)
    pub fn rank(
        mut self,
        value: impl Into<i64>,
    ) -> CandidateTaxonBuilder<'a, candidate_taxon_state::SetRank<S>> {
        self._fields.5 = Option::Some(value.into());
        CandidateTaxonBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CandidateTaxonBuilder<'a, S>
where
    S: candidate_taxon_state::State,
    S::ScientificName: candidate_taxon_state::IsUnset,
{
    /// Set the `scientificName` field (required)
    pub fn scientific_name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> CandidateTaxonBuilder<'a, candidate_taxon_state::SetScientificName<S>> {
        self._fields.6 = Option::Some(value.into());
        CandidateTaxonBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CandidateTaxonBuilder<'a, S>
where
    S: candidate_taxon_state::State,
    S::Rank: candidate_taxon_state::IsSet,
    S::ScientificName: candidate_taxon_state::IsSet,
    S::Confidence: candidate_taxon_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CandidateTaxon<'a> {
        CandidateTaxon {
            confidence: self._fields.0.unwrap(),
            family: self._fields.1,
            gbif_taxon_key: self._fields.2,
            genus: self._fields.3,
            kingdom: self._fields.4,
            rank: self._fields.5.unwrap(),
            scientific_name: self._fields.6.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> CandidateTaxon<'a> {
        CandidateTaxon {
            confidence: self._fields.0.unwrap(),
            family: self._fields.1,
            gbif_taxon_key: self._fields.2,
            genus: self._fields.3,
            kingdom: self._fields.4,
            rank: self._fields.5.unwrap(),
            scientific_name: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_gainforest_evaluator_defs() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.gainforest.evaluator.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("candidateTaxon"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A candidate taxon identification with confidence score and rank.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("scientificName"),
                            SmolStr::new_static("confidence"),
                            SmolStr::new_static("rank")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("confidence"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(1000i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("family"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Family of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("gbifTaxonKey"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "GBIF backbone taxonomy key for the candidate.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("genus"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Genus of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("kingdom"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Kingdom of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rank"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("scientificName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Full scientific name of the candidate taxon.",
                                    ),
                                ),
                                max_graphemes: Some(512usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("classificationResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Generic categorical classification result (e.g., conservation priority, habitat type).",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("category"), SmolStr::new_static("value")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("category"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The classification category (e.g., 'conservation-priority', 'habitat-type').",
                                    ),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the classification.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The assigned classification value (e.g., 'critical', 'tropical-rainforest').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("dataQualityResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Data quality assessment result with per-field quality flags.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("flags")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("completenessScore"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(1000i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("flags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of quality issues found in the record.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#qualityFlag"),
                                    ..Default::default()
                                }),
                                max_length: Some(50usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the quality assessment.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("derivedMeasurement"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single measurement derived by an evaluator from source data.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("measurementType"),
                            SmolStr::new_static("measurementValue")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("measurementMethod"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Description of the method used to obtain the measurement.",
                                    ),
                                ),
                                max_graphemes: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementType"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The nature of the measurement (e.g., 'canopy cover', 'NDVI', 'tree height').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementUnit"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The units for the measurement value (e.g., '%', 'm', 'kg').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementValue"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The value of the measurement."),
                                ),
                                max_graphemes: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("measurementResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Derived measurements produced by an evaluator from source data (e.g., remote sensing metrics).",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("measurements")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("measurements"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("List of derived measurements."),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#derivedMeasurement"),
                                    ..Default::default()
                                }),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the measurements.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("methodInfo"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Provenance metadata describing the method used to produce an evaluation.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("name")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("modelCheckpoint"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Identifier for the specific model checkpoint used (e.g., date or hash).",
                                    ),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Human-readable name of the method or model (e.g., 'GainForest BioClassifier').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("references"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "URIs to papers, documentation, or repositories describing this method.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                                max_length: Some(10usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("version"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Version string of the method or model (e.g., '2.1.0').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("qualityFlag"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single data quality flag indicating an issue with a specific field.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("field"), SmolStr::new_static("issue")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("field"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The field name that has the quality issue.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("issue"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Description of the quality issue."),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("severity"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Severity level of the quality issue."),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("speciesIdResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "AI or human species recognition result with ranked candidate identifications.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("candidates")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("candidates"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Ranked list of candidate species identifications.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#candidateTaxon"),
                                    ..Default::default()
                                }),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inputFeature"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Which feature of the subject record was used as input (e.g., 'mediaEvidence').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the species identification.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("subjectRef"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Reference to a target record that is being evaluated.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "CID pinning the exact version of the target record.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("AT-URI of the target record."),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("verificationResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Expert verification result for a previous identification or evaluation.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("status")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Notes about the verification decision."),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Verification status: confirmed, rejected, or uncertain.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("suggestedCorrections"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Suggested corrections if the original identification was rejected or uncertain.",
                                    ),
                                ),
                                max_graphemes: Some(5000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("verifiedBy"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Name of the person who performed the verification.",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("verifiedByID"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Persistent identifier (e.g., ORCID) of the verifier.",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod data_quality_result_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Flags;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Flags = Unset;
    }
    ///State transition - sets the `flags` field to Set
    pub struct SetFlags<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFlags<S> {}
    impl<S: State> State for SetFlags<S> {
        type Flags = Set<members::flags>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `flags` field
        pub struct flags(());
    }
}

/// Builder for constructing an instance of this type
pub struct DataQualityResultBuilder<'a, S: data_quality_result_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<Vec<evaluator::QualityFlag<'a>>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> DataQualityResult<'a> {
    /// Create a new builder for this type
    pub fn new() -> DataQualityResultBuilder<'a, data_quality_result_state::Empty> {
        DataQualityResultBuilder::new()
    }
}

impl<'a> DataQualityResultBuilder<'a, data_quality_result_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        DataQualityResultBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: data_quality_result_state::State> DataQualityResultBuilder<'a, S> {
    /// Set the `completenessScore` field (optional)
    pub fn completeness_score(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `completenessScore` field to an Option value (optional)
    pub fn maybe_completeness_score(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> DataQualityResultBuilder<'a, S>
where
    S: data_quality_result_state::State,
    S::Flags: data_quality_result_state::IsUnset,
{
    /// Set the `flags` field (required)
    pub fn flags(
        mut self,
        value: impl Into<Vec<evaluator::QualityFlag<'a>>>,
    ) -> DataQualityResultBuilder<'a, data_quality_result_state::SetFlags<S>> {
        self._fields.1 = Option::Some(value.into());
        DataQualityResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: data_quality_result_state::State> DataQualityResultBuilder<'a, S> {
    /// Set the `remarks` field (optional)
    pub fn remarks(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `remarks` field to an Option value (optional)
    pub fn maybe_remarks(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> DataQualityResultBuilder<'a, S>
where
    S: data_quality_result_state::State,
    S::Flags: data_quality_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> DataQualityResult<'a> {
        DataQualityResult {
            completeness_score: self._fields.0,
            flags: self._fields.1.unwrap(),
            remarks: self._fields.2,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> DataQualityResult<'a> {
        DataQualityResult {
            completeness_score: self._fields.0,
            flags: self._fields.1.unwrap(),
            remarks: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}

pub mod measurement_result_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Measurements;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Measurements = Unset;
    }
    ///State transition - sets the `measurements` field to Set
    pub struct SetMeasurements<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMeasurements<S> {}
    impl<S: State> State for SetMeasurements<S> {
        type Measurements = Set<members::measurements>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `measurements` field
        pub struct measurements(());
    }
}

/// Builder for constructing an instance of this type
pub struct MeasurementResultBuilder<'a, S: measurement_result_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Vec<evaluator::DerivedMeasurement<'a>>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> MeasurementResult<'a> {
    /// Create a new builder for this type
    pub fn new() -> MeasurementResultBuilder<'a, measurement_result_state::Empty> {
        MeasurementResultBuilder::new()
    }
}

impl<'a> MeasurementResultBuilder<'a, measurement_result_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        MeasurementResultBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MeasurementResultBuilder<'a, S>
where
    S: measurement_result_state::State,
    S::Measurements: measurement_result_state::IsUnset,
{
    /// Set the `measurements` field (required)
    pub fn measurements(
        mut self,
        value: impl Into<Vec<evaluator::DerivedMeasurement<'a>>>,
    ) -> MeasurementResultBuilder<'a, measurement_result_state::SetMeasurements<S>> {
        self._fields.0 = Option::Some(value.into());
        MeasurementResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: measurement_result_state::State> MeasurementResultBuilder<'a, S> {
    /// Set the `remarks` field (optional)
    pub fn remarks(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `remarks` field to an Option value (optional)
    pub fn maybe_remarks(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> MeasurementResultBuilder<'a, S>
where
    S: measurement_result_state::State,
    S::Measurements: measurement_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> MeasurementResult<'a> {
        MeasurementResult {
            measurements: self._fields.0.unwrap(),
            remarks: self._fields.1,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> MeasurementResult<'a> {
        MeasurementResult {
            measurements: self._fields.0.unwrap(),
            remarks: self._fields.1,
            extra_data: Some(extra_data),
        }
    }
}

pub mod species_id_result_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Candidates;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Candidates = Unset;
    }
    ///State transition - sets the `candidates` field to Set
    pub struct SetCandidates<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCandidates<S> {}
    impl<S: State> State for SetCandidates<S> {
        type Candidates = Set<members::candidates>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `candidates` field
        pub struct candidates(());
    }
}

/// Builder for constructing an instance of this type
pub struct SpeciesIdResultBuilder<'a, S: species_id_result_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<evaluator::CandidateTaxon<'a>>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SpeciesIdResult<'a> {
    /// Create a new builder for this type
    pub fn new() -> SpeciesIdResultBuilder<'a, species_id_result_state::Empty> {
        SpeciesIdResultBuilder::new()
    }
}

impl<'a> SpeciesIdResultBuilder<'a, species_id_result_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SpeciesIdResultBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SpeciesIdResultBuilder<'a, S>
where
    S: species_id_result_state::State,
    S::Candidates: species_id_result_state::IsUnset,
{
    /// Set the `candidates` field (required)
    pub fn candidates(
        mut self,
        value: impl Into<Vec<evaluator::CandidateTaxon<'a>>>,
    ) -> SpeciesIdResultBuilder<'a, species_id_result_state::SetCandidates<S>> {
        self._fields.0 = Option::Some(value.into());
        SpeciesIdResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: species_id_result_state::State> SpeciesIdResultBuilder<'a, S> {
    /// Set the `inputFeature` field (optional)
    pub fn input_feature(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `inputFeature` field to an Option value (optional)
    pub fn maybe_input_feature(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: species_id_result_state::State> SpeciesIdResultBuilder<'a, S> {
    /// Set the `remarks` field (optional)
    pub fn remarks(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `remarks` field to an Option value (optional)
    pub fn maybe_remarks(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> SpeciesIdResultBuilder<'a, S>
where
    S: species_id_result_state::State,
    S::Candidates: species_id_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SpeciesIdResult<'a> {
        SpeciesIdResult {
            candidates: self._fields.0.unwrap(),
            input_feature: self._fields.1,
            remarks: self._fields.2,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SpeciesIdResult<'a> {
        SpeciesIdResult {
            candidates: self._fields.0.unwrap(),
            input_feature: self._fields.1,
            remarks: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}

pub mod subject_ref_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Uri;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Uri = Unset;
    }
    ///State transition - sets the `uri` field to Set
    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUri<S> {}
    impl<S: State> State for SetUri<S> {
        type Uri = Set<members::uri>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `uri` field
        pub struct uri(());
    }
}

/// Builder for constructing an instance of this type
pub struct SubjectRefBuilder<'a, S: subject_ref_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<Cid<'a>>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SubjectRef<'a> {
    /// Create a new builder for this type
    pub fn new() -> SubjectRefBuilder<'a, subject_ref_state::Empty> {
        SubjectRefBuilder::new()
    }
}

impl<'a> SubjectRefBuilder<'a, subject_ref_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        SubjectRefBuilder {
            _state: PhantomData,
            _fields: (None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: subject_ref_state::State> SubjectRefBuilder<'a, S> {
    /// Set the `cid` field (optional)
    pub fn cid(mut self, value: impl Into<Option<Cid<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cid` field to an Option value (optional)
    pub fn maybe_cid(mut self, value: Option<Cid<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> SubjectRefBuilder<'a, S>
where
    S: subject_ref_state::State,
    S::Uri: subject_ref_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> SubjectRefBuilder<'a, subject_ref_state::SetUri<S>> {
        self._fields.1 = Option::Some(value.into());
        SubjectRefBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SubjectRefBuilder<'a, S>
where
    S: subject_ref_state::State,
    S::Uri: subject_ref_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SubjectRef<'a> {
        SubjectRef {
            cid: self._fields.0,
            uri: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SubjectRef<'a> {
        SubjectRef {
            cid: self._fields.0,
            uri: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}