//! MemoryProfile — how the agent's execution memory is kept.
//!
//! Phase 41 decomposition: the Phase 19 playbook_memory + Phase 26
//! successful_playbooks + Phase 45 doc_refs all need per-profile
//! tuning. Rather than bolt those onto ExecutionProfile, they live
//! here so a "thin" execution profile can reuse a "fat" memory
//! profile and vice versa.

use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MemoryProfile {
    pub id: String,
    #[serde(default)]
    pub description: String,
    /// Phase 19: ceiling for playbook_memory boost on retrieval. 0
    /// disables the boost entirely.
    #[serde(default = "default_boost_ceiling")]
    pub playbook_boost_ceiling: f32,
    /// Phase 26: max history entries retained before rotation.
    #[serde(default = "default_history_cap")]
    pub history_cap: usize,
    /// Phase 45: stale threshold for doc_refs before drift check
    /// fires (hours).
    #[serde(default = "default_stale_hours")]
    pub doc_stale_hours: u32,
    /// Phase 28: auto-retire playbooks that fail 3+ consecutive runs.
    #[serde(default = "default_true")]
    pub auto_retire_on_failure: bool,
    pub created_at: chrono::DateTime<chrono::Utc>,
    #[serde(default)]
    pub created_by: String,
}

fn default_boost_ceiling() -> f32 { 0.35 }
fn default_history_cap() -> usize { 1000 }
fn default_stale_hours() -> u32 { 168 } // one week
fn default_true() -> bool { true }
