//! Checkpoint and resume support for the Common Agent Runtime.
//!
//! Allows saving full runtime state to a file and restoring it later.

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;

/// Serializable snapshot of full runtime state.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Checkpoint {
    pub checkpoint_id: String,
    pub created_at: DateTime<Utc>,
    /// State store snapshot (all key-value pairs).
    pub state: HashMap<String, Value>,
    /// Event log entries (serialized). For audit/export only — events are NOT
    /// restored into the runtime's EventLog on checkpoint restore, because the
    /// EventLog is append-only and replaying historical events would corrupt
    /// ordering and span state.
    pub events: Vec<Value>,
    /// Registered tool names.
    pub tools: Vec<String>,
    /// Metadata (arbitrary).
    pub metadata: HashMap<String, Value>,
}
