use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::fs::{self, File};
use std::path::Path;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DriftEntry {
pub timestamp: DateTime<Utc>,
pub tone: String,
pub intent: String,
pub reem_code: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct DriftLog {
pub entries: Vec<DriftEntry>,
}
impl DriftLog {
pub fn load(path: &str) -> Self {
if Path::new(path).exists() {
let file = File::open(path).unwrap();
let reader = BufReader::new(file);
serde_json::from_reader(reader).unwrap_or_default()
} else {
DriftLog::default()
}
}
pub fn save(&self, path: &str) {
let file = File::create(path).unwrap();
serde_json::to_writer_pretty(writer, self).unwrap();
}
pub fn add_entry(&mut self, tone: &str, intent: &str, reem_code: &str) {
let entry = DriftEntry {
timestamp: Utc::now(),
tone: tone.to_string(),
intent: intent.to_string(),
reem_code: reem_code.to_string(),
};
self.entries.push(entry);
}
use crate::naorix::drift_tracker::DriftLog;
let mut drift_log = DriftLog::load("vaults/naorix_drift.json");
drift_log.add_entry(tone, intent, reem_code);
drift_log.save("vaults/naorix_drift.json");
drift_log.print_history();
pub fn print_history(&self) {
println!("📈 Emotional Drift Log:");
for entry in &self.entries {
println!(
"- [{}] Tone: {}, Intent: {}, REEM: {}",
entry.timestamp, entry.tone, entry.intent, entry.reem_code
);
}
}
}