neomemx 0.1.2

A high-performance memory library for AI agents with semantic search
Documentation
//! History tracking for fact changes

use crate::core::ChangeLog;
use crate::error::Result;
use serde::{Deserialize, Serialize};

/// Record of a historical change
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HistoryRecord {
    pub id: String,
    pub memory_id: String,
    pub old_memory: Option<String>,
    pub new_memory: Option<String>,
    pub event: String,
    pub created_at: Option<String>,
    pub updated_at: Option<String>,
    pub is_deleted: bool,
    pub actor_id: Option<String>,
    pub role: Option<String>,
    pub user_id: Option<String>,
    pub agent_id: Option<String>,
    pub session_id: Option<String>,
}

/// Trait for history storage
#[async_trait::async_trait]
pub trait HistoryStore: Send + Sync {
    /// Record a change to a fact
    async fn record_change(&self, change: ChangeLog) -> Result<()>;

    /// Get history for a specific fact
    async fn get_history(&self, fact_id: &crate::core::FactId) -> Result<Vec<ChangeLog>>;

    /// Delete history for a specific fact
    async fn delete_history(&self, fact_id: &crate::core::FactId) -> Result<()>;

    /// Clear all history
    async fn clear_all(&self) -> Result<()>;
}