use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RefactoringProof {
pub metadata: ProofMetadata,
pub before: GraphSnapshot,
pub after: GraphSnapshot,
pub invariants: Vec<InvariantCheck>,
#[serde(skip_serializing_if = "Option::is_none")]
pub checksums: Option<ProofChecksums>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProofMetadata {
pub operation: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<String>,
pub timestamp: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub git_commit: Option<String>,
pub splice_version: String,
pub database_path: PathBuf,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphSnapshot {
pub timestamp: i64,
pub symbols: HashMap<String, SymbolInfo>,
pub edges: HashMap<String, Vec<String>>,
pub entry_points: Vec<String>,
pub stats: GraphStats,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SymbolInfo {
pub id: String,
pub name: String,
pub file_path: String,
pub kind: String,
pub byte_span: (usize, usize),
pub fan_in: usize,
pub fan_out: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GraphStats {
pub total_symbols: usize,
pub total_edges: usize,
pub entry_point_count: usize,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_complexity: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvariantCheck {
pub invariant_name: String,
pub passed: bool,
pub violations: Vec<InvariantViolation>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvariantViolation {
pub severity: ViolationSeverity,
pub subject: String,
pub message: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub suggestion: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum ViolationSeverity {
Info,
Warning,
Error,
Critical,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProofChecksums {
pub before_hash: String,
pub after_hash: String,
pub proof_hash: String,
}