//! Skeptic endpoint response DTOs for conflict analysis.

use serde::{Deserialize, Serialize};

use super::enums::{ObjectValueDto, ResolutionStatusDto};

/// Response from the skeptic endpoint.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SkepticResponse {
    /// The subject that was queried
    pub subject: String,

    /// The predicate that was queried
    pub predicate: String,

    /// Overall resolution status
    pub status: ResolutionStatusDto,

    /// Conflict score (0.0 = unanimous, 1.0 = chaos)
    pub conflict_score: f32,

    /// All distinct claims, ranked by weight_share descending
    pub claims: Vec<ClaimSummaryDto>,

    /// Total number of candidate assertions considered
    pub candidates_count: usize,

    /// Unix timestamp when this view was computed
    pub computed_at: u64,

    /// Which lens was used (always "Skeptic")
    pub lens_name: String,
}

/// Summary of a single claim in the conflict analysis.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClaimSummaryDto {
    /// The claimed value
    pub value: ObjectValueDto,

    /// Normalized weight (0.0 to 1.0) relative to all claims
    pub weight_share: f32,

    /// Number of assertions making this exact claim
    pub assertion_count: u32,

    /// Hash of the representative assertion (hex-encoded)
    pub representative_hash: String,

    /// Source provenance
    pub source: SourceSummaryDto,

    /// Agents supporting this claim
    pub supporting_agents: Vec<AgentSummaryDto>,
}

/// Source provenance summary.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SourceSummaryDto {
    /// Hash of the source document (hex-encoded)
    pub source_hash: String,

    /// Visual anchor hash (hex-encoded, optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub visual_hash: Option<String>,
}

/// Agent summary with trust score.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentSummaryDto {
    /// Agent's public key (hex-encoded)
    pub agent_id: String,

    /// Trust score at query time (0.0 to 1.0)
    pub trust_score: f32,
}
