1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// ============================================================================
// ScoreVelocity - Kaizen Continuous Improvement Tracking (NEW in v1.1)
// ============================================================================
/// Kaizen: Continuous improvement tracking
///
/// Tracks score changes over time to encourage incremental progress
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScoreVelocity {
/// Current score
pub current: f64,
/// Previous score (from baseline)
pub previous: f64,
/// Change in points
pub delta: f64,
/// Change as percentage
pub delta_percent: f64,
/// Days since baseline
pub days_elapsed: u64,
/// Points per day improvement rate
pub points_per_day: f64,
/// Most improved category
pub most_improved: Option<String>,
/// Projected days to next grade
pub days_to_next_grade: Option<u64>,
}
impl ScoreVelocity {
/// Calculate velocity from previous and current scores
///
/// # Arguments
/// * `previous` - Previous baseline score
/// * `current` - Current score
/// * `days` - Days elapsed since baseline
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn calculate(previous: f64, current: f64, days: u64) -> Self {
let delta = current - previous;
let delta_percent = if previous == 0.0 {
0.0
} else {
(delta / previous) * 100.0
};
let points_per_day = if days == 0 { 0.0 } else { delta / days as f64 };
Self {
current,
previous,
delta,
delta_percent,
days_elapsed: days,
points_per_day,
most_improved: None,
days_to_next_grade: None,
}
}
}
// ============================================================================
// Recommendation - Actionable Improvement Suggestions
// ============================================================================
/// Priority level for recommendations
///
/// Ordered from highest to lowest priority for sorting
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum RecommendationPriority {
Low,
Medium,
High,
Critical,
}
/// Actionable recommendation for improvement
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Recommendation {
/// Category this recommendation applies to
pub category: String,
/// Description of the recommendation
pub description: String,
/// Priority level
pub priority: RecommendationPriority,
/// Potential points to gain
pub potential_points: f64,
}
impl Recommendation {
/// Create a new recommendation
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(
category: String,
description: String,
priority: RecommendationPriority,
potential_points: f64,
) -> Self {
Self {
category,
description,
priority,
potential_points,
}
}
}
// ============================================================================
// ScoreMetadata - Project Information
// ============================================================================
/// Metadata about the scoring analysis
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScoreMetadata {
/// Timestamp of analysis
pub timestamp: String,
/// Project name
pub project_name: String,
/// Specification version
pub version: String,
}
impl ScoreMetadata {
/// Create new metadata
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new(project_name: String, version: String) -> Self {
Self {
timestamp: chrono::Utc::now().to_rfc3339(),
project_name,
version,
}
}
}