From e94563b0204033d35392cca7924ef0585d0df5f8 Mon Sep 17 00:00:00 2001 From: Weksa Date: Fri, 13 Nov 2026 14:53:32 +0000 Subject: [PATCH] calibrate: degraded lines built in the lib and pinned by the arm-and-language test Soul arms s1 re-check: CLI-only mutants M7 and M10 (offsets zipped against the wrong language or label) survived. Co-Authored-By: Claude Sonnet 5.5 --- crates/weksa/src/main.rs | 16 ++-------------- crates/weksa/src/run.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/crates/weksa/src/main.rs b/crates/weksa/src/main.rs index 2d85215..e6a6cbb 100644 --- a/crates/weksa/src/main.rs +++ b/crates/weksa/src/main.rs @@ -1299,20 +1299,8 @@ fn main() -> Result<()> { run.labelled(&format!("calibrate class={} prompted-{side} {}", c.name, k.line())) ); } - for ((label, d), offsets) in degraded.iter().zip(&t.degraded).zip(&t.degraded_offset) { - let offsets: String = c - .languages - .iter() - .zip(offsets) - .map(|(l, o)| format!(" offset {}={o:+.4}", l.language)) - .collect(); - println!( - "{}", - run.labelled(&format!( - "calibrate class={} degraded={label} trials={} regressed={}{offsets}", - c.name, d.trials, d.regressed - )) - ); + for line in c.degraded_lines(°raded) { + println!("{}", run.labelled(&format!("calibrate class={} {line}", c.name))); } println!( "{}", diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index 3e51faa..0620864 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -2044,6 +2044,25 @@ pub struct ClassTrials { pub trials: Trials, } +impl ClassTrials { + /// The text after `calibrate class=NAME ` of each degraded arm's line, one + /// per `labels` entry: its Regressed count and its composite offset from the + /// prompted mean in each language of the class. + pub fn degraded_lines(&self, labels: &[String]) -> Vec { + let t = &self.trials; + labels + .iter() + .zip(&t.degraded) + .zip(&t.degraded_offset) + .map(|((label, d), offsets)| { + let offsets: String = + self.languages.iter().zip(offsets).map(|(l, o)| format!(" offset {}={o:+.4}", l.language)).collect(); + format!("degraded={label} trials={} regressed={}{offsets}", d.trials, d.regressed) + }) + .collect() + } +} + #[derive(Debug)] pub enum CalibrateOutcome { /// Draw labels with the number of prompts each has no answer to. @@ -3145,6 +3164,15 @@ mod tests { assert_eq!(level.accepted, 0); assert_eq!(low.regressed, 60); assert_eq!(t.candidate, high.plus(level).plus(low)); + // The printed lines keep each arm with its label and each offset with its language. + let class = ClassTrials { + name: "all".into(), + languages: ["en-US", "ja-JP"].map(|l| ClassLanguage { language: l.into(), n: 8, skipped: 0 }).into(), + trials: t, + }; + let lines = class.degraded_lines(&["mild-1".to_string(), "mild-2".to_string()]); + assert_eq!(lines[0], "degraded=mild-1 trials=60 regressed=60 offset en-US=-0.1333 offset ja-JP=-0.4167"); + assert_eq!(lines[1], "degraded=mild-2 trials=60 regressed=60 offset en-US=-0.5333 offset ja-JP=-0.2167"); } #[test]