mnemo_core/model/embedding_baseline.rs
1use serde::{Deserialize, Serialize};
2
3/// Per-agent embedding-space summary used by the z-score outlier detector.
4///
5/// `mu` is the mean vector; `cov_diag` is the per-dimension variance (we
6/// store only the diagonal — a proxy for the full covariance matrix that
7/// keeps storage and scoring O(d) rather than O(d^2)). `n` is the sample
8/// count the baseline was trained on; scoring ignores a baseline with
9/// fewer than `MIN_BASELINE_SAMPLES` samples because variance estimates
10/// below that threshold are too noisy.
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
12pub struct EmbeddingBaseline {
13 pub agent_id: String,
14 pub mu: Vec<f32>,
15 pub cov_diag: Vec<f32>,
16 pub n: u64,
17 pub updated_at: String,
18}
19
20/// Samples below this count are considered too noisy to score against.
21pub const MIN_BASELINE_SAMPLES: u64 = 30;