//! Edge repository - trait-based interface use anyhow::Result; use async_trait::async_trait; use time::OffsetDateTime; use mem_core::edge::Edge; /// Edge operations trait #[async_trait] pub trait EdgeRepoOps: Send + Sync { async fn insert(&self, edge: &Edge) -> Result; async fn find_between_entities(&self, src_id: &str, tgt_id: &str) -> Result>; async fn find_valid_at(&self, proj_id: &str, at: OffsetDateTime, limit: i32) -> Result>; async fn mark_contradiction_candidate(&self, edge_id: &str, conflict_id: &str, conf: f32) -> Result<()>; async fn confirm_invalidation(&self, edge_id: &str, invalid_at: OffsetDateTime) -> Result<()>; async fn resolve_contradiction(&self, edge_id: &str, action: &str, reviewer: &str) -> Result<()>; async fn find_similar(&self, emb: &[f32], src: &str, tgt: &str, thresh: f32) -> Result>; async fn soft_delete(&self, id: &str) -> Result<()>; async fn record_access(&self, id: &str) -> Result<()>; async fn count_active(&self, proj_id: &str) -> Result; async fn find_pending_review(&self, limit: i32) -> Result>; } pub struct MockEdgeRepo; #[async_trait] impl EdgeRepoOps for MockEdgeRepo { async fn insert(&self, edge: &Edge) -> Result { Ok(edge.id.clone()) } async fn find_between_entities(&self, _s: &str, _t: &str) -> Result> { Ok(vec![]) } async fn find_valid_at(&self, _p: &str, _at: OffsetDateTime, _l: i32) -> Result> { Ok(vec![]) } async fn mark_contradiction_candidate(&self, _e: &str, _c: &str, _f: f32) -> Result<()> { Ok(()) } async fn confirm_invalidation(&self, _e: &str, _ia: OffsetDateTime) -> Result<()> { Ok(()) } async fn resolve_contradiction(&self, _e: &str, _a: &str, _r: &str) -> Result<()> { Ok(()) } async fn find_similar(&self, _e: &[f32], _s: &str, _t: &str, _th: f32) -> Result> { Ok(vec![]) } async fn soft_delete(&self, _id: &str) -> Result<()> { Ok(()) } async fn record_access(&self, _id: &str) -> Result<()> { Ok(()) } async fn count_active(&self, _p: &str) -> Result { Ok(0) } async fn find_pending_review(&self, _l: i32) -> Result> { Ok(vec![]) } } #[cfg(test)] mod tests { use super::*; #[tokio::test] async fn test_mock_edge_repo() { let repo = MockEdgeRepo; assert!(repo.count_active("test").await.is_ok()); } }