splice/proof/
data_structures.rs1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3use std::path::PathBuf;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct RefactoringProof {
11 pub metadata: ProofMetadata,
13 pub before: GraphSnapshot,
15 pub after: GraphSnapshot,
17 pub invariants: Vec<InvariantCheck>,
19 #[serde(skip_serializing_if = "Option::is_none")]
21 pub checksums: Option<ProofChecksums>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct ProofMetadata {
27 pub operation: String,
29 #[serde(skip_serializing_if = "Option::is_none")]
31 pub user: Option<String>,
32 pub timestamp: i64,
34 #[serde(skip_serializing_if = "Option::is_none")]
36 pub git_commit: Option<String>,
37 pub splice_version: String,
39 pub database_path: PathBuf,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize)]
45pub struct GraphSnapshot {
46 pub timestamp: i64,
48 pub symbols: HashMap<String, SymbolInfo>,
50 pub edges: HashMap<String, Vec<String>>,
52 pub entry_points: Vec<String>,
54 pub stats: GraphStats,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60pub struct SymbolInfo {
61 pub id: String,
63 pub name: String,
65 pub file_path: String,
67 pub kind: String,
69 pub byte_span: (usize, usize),
71 pub fan_in: usize,
73 pub fan_out: usize,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct GraphStats {
80 pub total_symbols: usize,
82 pub total_edges: usize,
84 pub entry_point_count: usize,
86 #[serde(skip_serializing_if = "Option::is_none")]
88 pub max_complexity: Option<usize>,
89}
90
91#[derive(Debug, Clone, Serialize, Deserialize)]
93pub struct InvariantCheck {
94 pub invariant_name: String,
96 pub passed: bool,
98 pub violations: Vec<InvariantViolation>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
104pub struct InvariantViolation {
105 pub severity: ViolationSeverity,
107 pub subject: String,
109 pub message: String,
111 #[serde(skip_serializing_if = "Option::is_none")]
113 pub suggestion: Option<String>,
114}
115
116#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
118pub enum ViolationSeverity {
119 Info,
121 Warning,
123 Error,
125 Critical,
127}
128
129#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct ProofChecksums {
132 pub before_hash: String,
134 pub after_hash: String,
136 pub proof_hash: String,
138}