use crate::domain::{ConfidenceTier, MemoryLifecycleState, MemoryScope};
use serde::{Deserialize, Serialize};
use ts_rs::TS;

/// 检索排序管道里的 lifecycle 候选。与 `CandidateNote` 同级，
/// 代表一条被 scope/project 过滤后、按 memory_type 评分进入 top-N 的 ledger 记忆。
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, TS)]
#[ts(export, export_to = "../frontend/src/lib/types/generated/")]
pub struct LifecycleCandidate {
    pub record_id: String,
    pub title: String,
    pub summary: String,
    pub memory_type: String,
    pub scope: MemoryScope,
    pub state: MemoryLifecycleState,
    pub score: i32,
    pub reasons: Vec<String>,
    pub project_id: Option<String>,
    pub confidence: ConfidenceTier,
    /// Record IDs of existing memories that this candidate contradicts.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub contradicts: Vec<String>,
}
