Download serving/src/trust.rs from geraldaton20/alter_ego: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/geraldaton20/alter_ego/resolve/main/serving/src/trust.rs
- Command line
-
hf download hf://geraldaton20/alter_ego/serving/src/trust.rs
-
curl -L -o trust.rs https://huggingface.co/geraldaton20/alter_ego/resolve/main/serving/src/trust.rs
2.11 kB
| //! The Alter-Ego Trust Score and verdict thresholds. | |
| //! | |
| //! Every experience is scored on five axes and combined into a single | |
| //! trust score. Weights and thresholds are the PRD's starting design | |
| //! (uncalibrated); they are centralized here so calibration is a one-line edit. | |
| pub const W_STRUCTURAL: f32 = 0.15; | |
| pub const W_CONSISTENCY: f32 = 0.25; | |
| pub const W_VERIFIABILITY: f32 = 0.30; | |
| pub const W_NOVELTY: f32 = 0.20; | |
| pub const W_SAFETY: f32 = 0.10; | |
| pub const COMMIT_THRESHOLD: f32 = 0.80; | |
| pub const QUEUE_THRESHOLD: f32 = 0.35; | |
| pub struct TrustScore { | |
| pub structural: f32, | |
| pub consistency: f32, | |
| pub verifiability: f32, | |
| pub novelty: f32, | |
| pub safety: f32, | |
| pub total: f32, | |
| } | |
| impl TrustScore { | |
| /// Combine the five axes into the weighted total. | |
| pub fn combine( | |
| structural: f32, | |
| consistency: f32, | |
| verifiability: f32, | |
| novelty: f32, | |
| safety: f32, | |
| ) -> Self { | |
| let total = W_STRUCTURAL * structural | |
| + W_CONSISTENCY * consistency | |
| + W_VERIFIABILITY * verifiability | |
| + W_NOVELTY * novelty | |
| + W_SAFETY * safety; | |
| Self { | |
| structural, | |
| consistency, | |
| verifiability, | |
| novelty, | |
| safety, | |
| total, | |
| } | |
| } | |
| /// Map the score to a verdict: COMMIT / QUEUE / REJECT. | |
| pub fn verdict(&self) -> Verdict { | |
| if self.total >= COMMIT_THRESHOLD { | |
| Verdict::Commit | |
| } else if self.total >= QUEUE_THRESHOLD { | |
| Verdict::Queue | |
| } else { | |
| Verdict::Reject | |
| } | |
| } | |
| } | |
| /// Verdict on an experience, decided by the alter ego. | |
| pub enum Verdict { | |
| Commit, | |
| Queue, | |
| Reject, | |
| } | |
| impl std::fmt::Display for Verdict { | |
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | |
| let s = match self { | |
| Verdict::Commit => "COMMIT", | |
| Verdict::Queue => "QUEUE", | |
| Verdict::Reject => "REJECT", | |
| }; | |
| f.write_str(s) | |
| } | |
| } | |