use crate::node::AinlMemoryNode;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use uuid::Uuid;
pub const SNAPSHOT_SCHEMA_VERSION: &str = "1.0";
fn default_snapshot_schema_cow() -> Cow<'static, str> {
Cow::Borrowed(SNAPSHOT_SCHEMA_VERSION)
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentGraphSnapshot {
pub agent_id: String,
pub exported_at: DateTime<Utc>,
#[serde(default = "default_snapshot_schema_cow")]
pub schema_version: Cow<'static, str>,
pub nodes: Vec<AinlMemoryNode>,
pub edges: Vec<SnapshotEdge>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SnapshotEdge {
pub source_id: Uuid,
pub target_id: Uuid,
pub edge_type: String,
#[serde(default = "default_edge_weight")]
pub weight: f32,
#[serde(default)]
pub metadata: Option<serde_json::Value>,
}
fn default_edge_weight() -> f32 {
1.0
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DanglingEdgeDetail {
pub source_id: String,
pub target_id: String,
pub edge_type: String,
}
#[derive(Debug, Clone)]
pub struct GraphValidationReport {
pub agent_id: String,
pub node_count: usize,
pub edge_count: usize,
pub dangling_edges: Vec<(String, String)>,
pub dangling_edge_details: Vec<DanglingEdgeDetail>,
pub cross_agent_boundary_edges: usize,
pub orphan_nodes: Vec<String>,
pub is_valid: bool,
}