use anyhow::Result;
use crate::spec_ai_knowledge_graph::{EdgeType, NodeType};
use crate::spec_ai_graph_sync::types::{ChangelogEntry, SyncedEdgeRecord, SyncedNodeRecord};
pub trait SyncPersistence: Send + Sync {
fn instance_id(&self) -> &str;
fn graph_sync_state_get(
&self,
instance_id: &str,
session_id: &str,
graph_name: &str,
) -> Result<Option<String>>;
fn graph_sync_state_update(
&self,
instance_id: &str,
session_id: &str,
graph_name: &str,
vector_clock: &str,
) -> Result<()>;
fn count_graph_nodes(&self, session_id: &str) -> Result<i64>;
#[allow(clippy::too_many_arguments)]
fn graph_changelog_append(
&self,
session_id: &str,
instance_id: &str,
entity_type: &str,
entity_id: i64,
operation: &str,
vector_clock: &str,
data: Option<&str>,
) -> Result<i64>;
fn graph_changelog_get_since(
&self,
session_id: &str,
since_timestamp: &str,
) -> Result<Vec<ChangelogEntry>>;
fn graph_get_node_with_sync(&self, node_id: i64) -> Result<Option<SyncedNodeRecord>>;
fn graph_list_nodes_with_sync(
&self,
session_id: &str,
sync_enabled_only: bool,
include_deleted: bool,
) -> Result<Vec<SyncedNodeRecord>>;
fn graph_update_node_sync_metadata(
&self,
node_id: i64,
vector_clock: &str,
last_modified_by: &str,
sync_enabled: bool,
) -> Result<()>;
fn graph_mark_node_deleted(
&self,
node_id: i64,
vector_clock: &str,
deleted_by: &str,
) -> Result<()>;
fn graph_get_edge_with_sync(&self, edge_id: i64) -> Result<Option<SyncedEdgeRecord>>;
fn graph_list_edges_with_sync(
&self,
session_id: &str,
sync_enabled_only: bool,
include_deleted: bool,
) -> Result<Vec<SyncedEdgeRecord>>;
fn graph_update_edge_sync_metadata(
&self,
edge_id: i64,
vector_clock: &str,
last_modified_by: &str,
sync_enabled: bool,
) -> Result<()>;
fn graph_mark_edge_deleted(
&self,
edge_id: i64,
vector_clock: &str,
deleted_by: &str,
) -> Result<()>;
fn insert_graph_node(
&self,
session_id: &str,
node_type: NodeType,
label: &str,
properties: &serde_json::Value,
embedding_id: Option<i64>,
) -> Result<i64>;
fn update_graph_node(&self, node_id: i64, properties: &serde_json::Value) -> Result<()>;
#[allow(clippy::too_many_arguments)]
fn insert_graph_edge(
&self,
session_id: &str,
source_id: i64,
target_id: i64,
edge_type: EdgeType,
predicate: Option<&str>,
properties: Option<&serde_json::Value>,
weight: f32,
) -> Result<i64>;
}