MCPcopy Create free account
hub / github.com/InfinitiBit/graphbit / insert_history

Method insert_history

core/src/memory/store.rs:213–232  ·  view source on GitHub ↗

Record a history entry for a memory mutation.

(&self, history: &MemoryHistory)

Source from the content-addressed store, hash-verified

211
212 /// Record a history entry for a memory mutation.
213 pub async fn insert_history(&self, history: &MemoryHistory) -> GraphBitResult<()> {
214 let memory_id = history.memory_id.to_string();
215 let old_content = history.old_content.clone();
216 let new_content = history.new_content.clone();
217 let action = history.action.to_string();
218 let timestamp = history.timestamp.to_rfc3339();
219 let conn_arc = Arc::clone(&self.conn);
220
221 tokio::task::spawn_blocking(move || -> GraphBitResult<()> {
222 let conn = conn_arc.blocking_lock();
223 conn.execute(
224 "INSERT INTO memory_history (memory_id, old_content, new_content, action, timestamp)
225 VALUES (?1, ?2, ?3, ?4, ?5)",
226 rusqlite::params![memory_id, old_content, new_content, action, timestamp],
227 )?;
228 Ok(())
229 })
230 .await
231 .map_err(|e| GraphBitError::memory(format!("Join error: {e}")))?
232 }
233
234 /// Get the full history for a specific memory.
235 pub async fn get_history(&self, memory_id: &MemoryId) -> GraphBitResult<Vec<MemoryHistory>> {

Callers 3

create_memoryMethod · 0.80

Calls 3

to_stringMethod · 0.80
cloneMethod · 0.80
executeMethod · 0.45

Tested by 1