made_core/value_objects/discrimination.rs
1//! [`Discrimination`] — whether a scoring policy re-ordered the winner.
2//!
3//! The signal behind the judge-discrimination metric: does the policy's
4//! ranking pick a *different* winner than a structural baseline would, or
5//! does it merely confirm it? A policy that almost never reranks is
6//! expensive dead weight; one that always reranks is doing real work.
7
8/// How a scoring policy's winner compares to the structural baseline.
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub enum Discrimination {
11 /// The policy picked a different winner than the baseline — it
12 /// changed the outcome.
13 Reranked,
14 /// The policy's winner is the same the baseline would pick.
15 Agreed,
16 /// The top score is shared by more than one proposal — the policy did
17 /// not separate the leaders.
18 Tie,
19}
20
21impl Discrimination {
22 /// Stable, low-cardinality label value for metrics exposition. Part
23 /// of the metric contract; dashboards match on it.
24 #[must_use]
25 pub const fn as_label(self) -> &'static str {
26 match self {
27 Self::Reranked => "reranked",
28 Self::Agreed => "agreed",
29 Self::Tie => "tie",
30 }
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37
38 #[test]
39 fn labels_are_distinct_and_stable() {
40 assert_eq!(Discrimination::Reranked.as_label(), "reranked");
41 assert_eq!(Discrimination::Agreed.as_label(), "agreed");
42 assert_eq!(Discrimination::Tie.as_label(), "tie");
43 }
44}