mnemo_core/model/
checkpoint.rs1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5pub struct Checkpoint {
6 pub id: Uuid,
7 pub thread_id: String,
8 pub agent_id: String,
9 pub parent_id: Option<Uuid>,
10 pub branch_name: String,
11 pub state_snapshot: serde_json::Value,
12 pub state_diff: Option<serde_json::Value>,
13 pub memory_refs: Vec<Uuid>,
14 pub event_cursor: Option<Uuid>,
15 pub label: Option<String>,
16 pub created_at: String,
17 pub metadata: serde_json::Value,
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn test_checkpoint_serde() {
26 let cp = Checkpoint {
27 id: Uuid::now_v7(),
28 thread_id: "thread-1".to_string(),
29 agent_id: "agent-1".to_string(),
30 parent_id: None,
31 branch_name: "main".to_string(),
32 state_snapshot: serde_json::json!({"step": 1}),
33 state_diff: None,
34 memory_refs: vec![Uuid::now_v7()],
35 event_cursor: None,
36 label: Some("initial".to_string()),
37 created_at: "2025-01-01T00:00:00Z".to_string(),
38 metadata: serde_json::json!({}),
39 };
40 let json = serde_json::to_string(&cp).unwrap();
41 let deserialized: Checkpoint = serde_json::from_str(&json).unwrap();
42 assert_eq!(cp, deserialized);
43 }
44}