use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Clone)]
pub enum BackendType {
#[serde(rename = "openai-compat")]
OpenAiCompat,
#[serde(rename = "ollama-native")]
OllamaNative,
#[serde(rename = "local-embedded")]
LocalEmbedded,
#[serde(rename = "anthropic")]
Anthropic,
}
#[derive(Debug, Deserialize, Clone, Default)]
pub enum VerifyMode {
#[serde(rename = "deterministic")]
#[default]
Deterministic,
#[serde(rename = "llm")]
Llm,
#[serde(rename = "reconcile")]
Reconcile,
#[serde(rename = "none")]
None,
}
#[derive(Debug, Deserialize, Clone)]
pub struct Config {
pub backend: BackendType,
pub endpoint: String,
pub model_name: String,
pub soul_path: String,
pub api_key: Option<String>,
pub verify_mode: VerifyMode,
pub timeout_secs: u64,
pub dump_prompt: bool,
pub dump_raw: bool,
pub memory_path: Option<String>,
pub audit_path: Option<String>,
pub serve_key: Option<String>,
pub serve_rate_limit: u32,
pub serve_max_body_bytes: usize,
pub session_log_path: Option<String>,
pub context_path: Option<String>,
}
impl std::fmt::Display for BackendType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BackendType::OpenAiCompat => write!(f, "openai-compat"),
BackendType::OllamaNative => write!(f, "ollama-native"),
BackendType::LocalEmbedded => write!(f, "local-embedded"),
BackendType::Anthropic => write!(f, "anthropic"),
}
}
}
impl std::fmt::Display for VerifyMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
VerifyMode::Deterministic => write!(f, "deterministic"),
VerifyMode::Llm => write!(f, "llm"),
VerifyMode::Reconcile => write!(f, "reconcile"),
VerifyMode::None => write!(f, "none"),
}
}
}
#[derive(Debug, Clone)]
pub struct Soul {
pub logic_system_prompt: String,
pub creative_system_prompt: String,
pub verifier_system_prompt: String,
pub code_gen_system_prompt: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct AfferentTelemetry {
pub primary_emotion: String,
pub emotional_intensity: f32,
pub structural_tone: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct IntentMatrix {
pub stated_objective: String,
pub subtextual_motive: String,
pub manipulation_risk: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(deny_unknown_fields)]
pub struct CognitiveState {
pub urgency_vector: f32,
pub coherence_rating: f32,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TelemetryResult {
pub affective_telemetry: AfferentTelemetry,
pub intent_matrix: IntentMatrix,
pub cognitive_state: CognitiveState,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TraceEntry {
pub stage: String,
pub claim: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub evidence: Option<String>,
pub passed: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub note: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct DisagreementScore {
pub flag_count: usize,
pub flag_density: f32,
pub dimension_spread: usize,
pub injection_fingerprint: bool,
pub adjusted_confidence: f32,
#[serde(skip_serializing_if = "Option::is_none")]
pub reconcile_verdict: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct VerificationReport {
pub passed: bool,
pub consistency_flags: Vec<String>,
pub unsupported_claims: Vec<String>,
pub assumptions: Vec<String>,
pub unresolved: Vec<String>,
pub confidence: f32,
pub disagreement: DisagreementScore,
pub stop_and_ask: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
pub struct ObfuscationReport {
pub score: f32,
pub detections: Vec<String>,
pub normalized_input: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct HarnessResult {
pub telemetry: TelemetryResult,
pub verification: VerificationReport,
pub trace: Vec<TraceEntry>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub capability_request: Option<crate::capability::CapabilityRequest>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub obfuscation: Option<ObfuscationReport>,
}