use serde::{Deserialize, Serialize};
pub const SCHEMA: &str = "cordance-llm-candidate.v1";
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LlmCandidate {
pub schema: String,
pub candidate_id: String,
pub input_source_ids: Vec<String>,
pub claims: Vec<LlmClaim>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LlmClaim {
pub text: String,
pub claim_type: ClaimType,
pub source_ids: Vec<String>,
pub confidence: ClaimConfidence,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ClaimType {
WorkflowInstruction,
StrongPreference,
WeakPreference,
CandidateObservation,
RejectedApproach,
OpenUncertainty,
GeneratedSummary,
HardRule,
ProjectInvariant,
}
impl ClaimType {
#[must_use]
pub const fn allowed_from_llm(self) -> bool {
!matches!(self, Self::HardRule | Self::ProjectInvariant)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ClaimConfidence {
Candidate,
SchemaValidated,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn hard_rule_not_allowed_from_llm() {
assert!(!ClaimType::HardRule.allowed_from_llm());
assert!(!ClaimType::ProjectInvariant.allowed_from_llm());
}
#[test]
fn workflow_instruction_allowed() {
assert!(ClaimType::WorkflowInstruction.allowed_from_llm());
assert!(ClaimType::CandidateObservation.allowed_from_llm());
}
}