use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;

#[derive(Debug, Clone, FromRow, Serialize, Deserialize)]
pub struct StrategyRow {
    pub id: Uuid,
    /// SHA-256 hex digest of the normalized (key-sorted, sizing-stripped) strategy JSON.
    pub hash: String,
    /// Full strategy config as submitted (includes candle_interval, order sizes, etc.).
    pub config: serde_json::Value,
    /// The normalized JSON that was hashed (excludes candle_interval, sizing fields).
    /// Stored for transparency and verification.
    pub hash_input: serde_json::Value,
    pub created_at: DateTime<Utc>,
    /// Human-readable strategy name. Together with `version` forms a stable lineage key.
    /// NULL for strategies created anonymously via the API without a name.
    pub name: Option<String>,
    /// Version within the named lineage (default 1). Increment when mutating a named strategy.
    pub version: i32,
    /// Markdown description of the strategy's intent, concept, and limitations.
    pub description: Option<String>,
}
