Skip to main content

assay_core/calibration/
model.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct CalibrationReport {
5    pub schema_version: u32,
6    pub source: String,
7    pub generated_at: String,
8    pub metrics: Vec<MetricSummary>,
9    pub notes: Vec<String>,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
13pub struct MetricKey {
14    pub metric: String,
15    /// Optional granularity: if set, these stats apply only to this specific test_id.
16    /// If None, stats are aggregated across all tests (global metric performance).
17    pub test_id: Option<String>,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct MetricSummary {
22    pub key: MetricKey,
23    /// Number of data points (runs) included
24    pub n: u32,
25    pub min: f64,
26    pub max: f64,
27    pub mean: f64,
28    pub std: f64,
29    pub p10: f64,
30    pub p50: f64,
31    pub p90: f64,
32
33    /// The recommended threshold for "pass" (usually p10 or target_tail)
34    pub recommended_min_score: f64,
35
36    /// For relative gating: maximum allowed drop from baseline (p50 - p10 logic)
37    pub recommended_max_drop: f64,
38}