1use std::sync::Mutex;
6
7use aonyx_core::{MemoryStore, Result};
8use async_trait::async_trait;
9
10#[derive(Default)]
12pub struct InMemoryStore {
13 diary: Mutex<Vec<(String, String)>>,
14}
15
16impl InMemoryStore {
17 pub fn new() -> Self {
19 Self::default()
20 }
21}
22
23#[async_trait]
24impl MemoryStore for InMemoryStore {
25 async fn diary_append(&self, project: &str, content: &str) -> Result<()> {
26 self.diary
27 .lock()
28 .expect("diary mutex poisoned")
29 .push((project.to_string(), content.to_string()));
30 Ok(())
31 }
32
33 async fn hybrid_search(&self, _query: &str, _k: usize) -> Result<Vec<(String, f32)>> {
34 Ok(Vec::new())
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::*;
41
42 #[tokio::test]
43 async fn diary_append_persists_for_session() {
44 let store = InMemoryStore::new();
45 store.diary_append("demo", "first entry").await.unwrap();
46 assert_eq!(store.diary.lock().unwrap().len(), 1);
47 }
48}