Skip to main content

car_engine/
checkpoint.rs

1//! Checkpoint and resume support for the Common Agent Runtime.
2//!
3//! Allows saving full runtime state to a file and restoring it later.
4
5use chrono::{DateTime, Utc};
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8use std::collections::HashMap;
9
10/// Serializable snapshot of full runtime state.
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Checkpoint {
13    pub checkpoint_id: String,
14    pub created_at: DateTime<Utc>,
15    /// State store snapshot (all key-value pairs).
16    pub state: HashMap<String, Value>,
17    /// Event log entries (serialized). For audit/export only — events are NOT
18    /// restored into the runtime's EventLog on checkpoint restore, because the
19    /// EventLog is append-only and replaying historical events would corrupt
20    /// ordering and span state.
21    pub events: Vec<Value>,
22    /// Registered tool names.
23    pub tools: Vec<String>,
24    /// Metadata (arbitrary).
25    pub metadata: HashMap<String, Value>,
26}