| 952 | |
| 953 | #[test] |
| 954 | fn vault_manifest_json_roundtrip() { |
| 955 | let mut manifest = VaultManifest::new("2025-01-15T12:00:00Z".to_string()); |
| 956 | manifest.goals.insert( |
| 957 | "abc123".to_string(), |
| 958 | GoalSummary { |
| 959 | developer: "alice".to_string(), |
| 960 | intent: Some("fix bug".to_string()), |
| 961 | status: "complete".to_string(), |
| 962 | started_at: "2025-01-15T12:00:00Z".to_string(), |
| 963 | turns: 5, |
| 964 | tokens: TokenCounts { |
| 965 | fresh: 1000, |
| 966 | cached: 500, |
| 967 | output: 200, |
| 968 | }, |
| 969 | tool_results: vec!["result1.md".to_string()], |
| 970 | findings_hash: None, |
| 971 | bytes: 4096, |
| 972 | }, |
| 973 | ); |
| 974 | manifest.memory.insert( |
| 975 | "project.md".to_string(), |
| 976 | MemorySummary { |
| 977 | hash: "deadbeef".to_string(), |
| 978 | bytes: 1024, |
| 979 | updated_at: "2025-01-15T12:00:00Z".to_string(), |
| 980 | }, |
| 981 | ); |
| 982 | manifest.total_bytes = 5120; |
| 983 | manifest.file_count = 3; |
| 984 | |
| 985 | let json = serde_json::to_string(&manifest).expect("serialize"); |
| 986 | let decoded: VaultManifest = serde_json::from_str(&json).expect("deserialize"); |
| 987 | |
| 988 | assert_eq!(decoded.version, 1); |
| 989 | assert_eq!(decoded.updated_at, "2025-01-15T12:00:00Z"); |
| 990 | assert_eq!(decoded.goals.len(), 1); |
| 991 | assert_eq!(decoded.memory.len(), 1); |
| 992 | assert_eq!(decoded.total_bytes, 5120); |
| 993 | assert_eq!(decoded.file_count, 3); |
| 994 | |
| 995 | let goal = decoded.goals.get("abc123").unwrap(); |
| 996 | assert_eq!(goal.developer, "alice"); |
| 997 | assert_eq!(goal.intent.as_deref(), Some("fix bug")); |
| 998 | assert_eq!(goal.turns, 5); |
| 999 | assert_eq!(goal.tokens.fresh, 1000); |
| 1000 | } |
| 1001 | |
| 1002 | #[test] |
| 1003 | fn vault_manifest_stored_as_json_roundtrip() { |