Cut: Checkpoint has no public constructor; instruction text is consts

Checkpoint::declare becomes cfg(test) for_test; Checkpoint-using tests move
into src unit tests over split::fixture; Prompt::mint and encode lose the
instructions parameter (MINT_INSTRUCTIONS, ENCODE_INSTRUCTIONS in context.rs).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-10 02:42:02 +00:00
commit 469e46cbc5
5 changed files with 237 additions and 145 deletions

View file

@ -2,15 +2,22 @@
//! model call only as a [`Prompt`], and a `Prompt` is made only by minting from
//! [`TrainItems`] or by encoding one item an [`EncoderOffer`] holds: Train-only
//! minting and per-item encoding (leak-owned-by-flow-and-scorer-3,
//! loop-context-builder-2). Instruction wording is not written here; a caller
//! passes `&'static str`, so the templates are fixed at compile time and hence
//! within a run.
//! loop-context-builder-2). Instruction text is [`MINT_INSTRUCTIONS`] and
//! [`ENCODE_INSTRUCTIONS`], consts in this module, and nothing else: `mint` and
//! `encode` take none, so no run-time text can become instructions.
use crate::corpus::CorpusItem;
use crate::packet::EntityId;
use crate::split::{Checkpoint, Split, SplitScheme};
use crate::store::{CorpusStore, normalized};
/// The instructions a mint prompt starts with. golf-loop-en edits the wording
/// here.
pub const MINT_INSTRUCTIONS: &str = "Mint glosses from the lines below.";
/// The instructions an encode prompt starts with.
pub const ENCODE_INSTRUCTIONS: &str = "Encode the line below.";
/// The live Train items of a corpus, in key order. The only input minting
/// reads; it cannot be built from a slice, and no accessor returns text or an
/// item.
@ -145,17 +152,17 @@ impl EncoderOffer {
/// let dir = tempfile::tempdir().unwrap();
/// let store = weksa::CorpusStore::open(&dir.path().join("c.cc")).unwrap();
/// let t = weksa::context::TrainItems::from_corpus(&store).unwrap();
/// let p = weksa::context::Prompt::mint("Mint.", &t);
/// assert_eq!(p.text(), "Mint.");
/// let p = weksa::context::Prompt::mint(&t);
/// assert_eq!(p.text(), weksa::context::MINT_INSTRUCTIONS);
/// ```
///
/// Instructions are compile-time text:
/// Instructions are not a parameter:
///
/// ```compile_fail
/// let dir = tempfile::tempdir().unwrap();
/// let store = weksa::CorpusStore::open(&dir.path().join("c.cc")).unwrap();
/// let t = weksa::context::TrainItems::from_corpus(&store).unwrap();
/// let p = weksa::context::Prompt::mint(&String::from("x"), &t);
/// let p = weksa::context::Prompt::mint("x", &t);
/// ```
///
/// ```compile_fail
@ -163,7 +170,7 @@ impl EncoderOffer {
/// let dir = tempfile::tempdir().unwrap();
/// let store = weksa::CorpusStore::open(&dir.path().join("c.cc")).unwrap();
/// let t = weksa::context::TrainItems::from_corpus(&store).unwrap();
/// let p = weksa::context::Prompt::mint("x", &t);
/// let p = weksa::context::Prompt::mint(&t);
/// s(&p);
/// ```
pub struct Prompt {
@ -197,9 +204,9 @@ fn block(item: &CorpusItem, prior: Option<&TrainItems>) -> String {
const ELIDED: &str = "[elided]";
impl Prompt {
/// Instructions, then every Train item in key order.
pub fn mint(instructions: &'static str, train: &TrainItems) -> Prompt {
let mut parts = vec![instructions.to_string()];
/// [`MINT_INSTRUCTIONS`], then every Train item in key order.
pub fn mint(train: &TrainItems) -> Prompt {
let mut parts = vec![MINT_INSTRUCTIONS.to_string()];
parts.extend(train.items.iter().map(|item| block(item, None)));
Prompt {
text: parts.join("\n\n"),
@ -207,13 +214,13 @@ impl Prompt {
}
}
/// Instructions, the one offered item with its prior turns resolved
/// [`ENCODE_INSTRUCTIONS`], the one offered item with its prior turns resolved
/// against `train`, and the entities a packet for it may cite.
pub fn encode(instructions: &'static str, offer: &EncoderOffer, train: &TrainItems) -> Prompt {
pub fn encode(offer: &EncoderOffer, train: &TrainItems) -> Prompt {
let ids: Vec<&str> = offer.entities.iter().map(EntityId::as_str).collect();
Prompt {
text: format!(
"{instructions}\n\n{}\n\nentities: {}",
"{ENCODE_INSTRUCTIONS}\n\n{}\n\nentities: {}",
block(&offer.item, Some(train)),
ids.join(", ")
),
@ -230,3 +237,30 @@ impl Prompt {
&self.items
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::split::fixture::{group_in, item};
#[test]
fn checkpoint_offer_gate() {
let cp = Checkpoint::for_test(1);
let check = |i: &CorpusItem| EncoderOffer::for_checkpoint(i, &cp).err();
let train = item("item:a:1", "t", &group_in(Split::Train), false);
let validation = item("item:b:1", "v", &group_in(Split::Validation), false);
let test = item("item:c:1", "x", &group_in(Split::Test), false);
let no_split = item("item:c:2", "m", &group_in(Split::Test), true);
let mut withdrawn = item("item:a:2", "w", &group_in(Split::Train), false);
withdrawn.withdrawn = true;
assert_eq!(check(&train), None);
assert_eq!(check(&validation), None);
assert_eq!(check(&test), None);
assert_eq!(check(&no_split), Some(OfferRefusal::NoSplit));
assert_eq!(check(&withdrawn), Some(OfferRefusal::Withdrawn));
// Withdrawn wins over NoSplit.
let mut both = no_split.clone();
both.withdrawn = true;
assert_eq!(check(&both), Some(OfferRefusal::Withdrawn));
}
}

View file

@ -158,37 +158,27 @@ pub fn aggregate(scored: &[(&CorpusItem, ItemScore)]) -> Aggregate {
/// The Test split's readings, scalars only: no item key, no minted string, no
/// pair. The checkpoint decision (convergence-test) needs numbers; a key beside
/// a minted string is the handle an edit step would act on. The only producer
/// is `at_checkpoint`, which consumes a `Checkpoint`.
/// is `at_checkpoint`, which consumes a `Checkpoint`, which only the lib can make.
///
/// ```
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// fn f(t: TestReadings) -> usize { t.count() }
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// fn f(t: TestReadings) { let _u = t.clone(); }
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// fn f(t: TestReadings) { let _ = format!("{t:?}"); }
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// fn s<T: serde::Serialize>(_: &T) {}
/// let t = TestReadings::at_checkpoint(Checkpoint::declare(1), &[], &[], &[]);
/// assert_eq!(t.count(), 0);
/// s(&0u8);
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// let t = TestReadings::at_checkpoint(Checkpoint::declare(1), &[], &[], &[]);
/// let _u = t.clone();
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// let t = TestReadings::at_checkpoint(Checkpoint::declare(1), &[], &[], &[]);
/// let _ = format!("{t:?}");
/// ```
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// fn s<T: serde::Serialize>(_: &T) {}
/// let t = TestReadings::at_checkpoint(Checkpoint::declare(1), &[], &[], &[]);
/// s(&t);
/// fn f(t: TestReadings) { s(&t); }
/// ```
pub struct TestReadings {
mean: SplitMean,
@ -240,3 +230,96 @@ impl TestReadings {
&self.leak.coverage_by_n
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::split::fixture::{group_in, item};
const HELD_OUT: &str = "extraordinary lighthouse keepers whispered unforgettable stories throughout midnight thunderstorms before surrendering peacefully";
const UNRELATED: &str = "harbor ledgers record ordinary tides";
fn score(chrf: f64, meaning: Option<f64>) -> ItemScore {
ItemScore { chrf, meaning }
}
fn in_split(key: &str, text: &str, split: Split, model: bool) -> CorpusItem {
item(key, text, &group_in(split), model)
}
#[test]
fn test_readings_at_checkpoint() {
let train_item = in_split("item:t:1", UNRELATED, Split::Train, false);
let test = in_split("item:c:1", HELD_OUT, Split::Test, false);
let test_model = in_split("item:c:2", "model words here", Split::Test, true);
let mut gone = in_split("item:c:3", "withdrawn words", Split::Test, false);
gone.withdrawn = true;
let val = in_split(
"item:v:1",
"gardening is quiet work",
Split::Validation,
false,
);
let items = [
train_item.clone(),
test.clone(),
test_model.clone(),
gone.clone(),
val.clone(),
];
let scored = [
(&train_item, score(10.0, Some(0.5))),
(&val, score(40.0, Some(0.8))),
(&test, score(60.0, Some(0.6))),
(&test_model, score(100.0, Some(1.0))),
(&gone, score(90.0, Some(0.9))),
];
let t = TestReadings::at_checkpoint(Checkpoint::for_test(2), &scored, &[HELD_OUT], &items);
assert_eq!(
(t.count(), t.chrf(), t.meaning()),
(1, Some(60.0), Some(0.6))
);
assert_eq!(
t.items(),
1,
"model-written and withdrawn Test items are excluded"
);
assert!(t.max_chrf().unwrap() > 99.0);
assert_eq!(t.coverage_by_n()[2].share, Some(1.0));
// A minted string that is not the Test text reads low.
let t = TestReadings::at_checkpoint(Checkpoint::for_test(2), &scored, &["zzz"], &items);
assert!(t.max_chrf().unwrap() < 20.0);
assert_eq!(t.coverage_by_n()[2].share, Some(0.0));
let empty = TestReadings::at_checkpoint(Checkpoint::for_test(2), &[], &[HELD_OUT], &[]);
assert_eq!(
(empty.count(), empty.chrf(), empty.meaning()),
(0, None, None)
);
assert_eq!((empty.items(), empty.max_chrf()), (0, None));
}
#[test]
fn validation_and_test_leak_agree_in_method() {
// The same text and minted strings, once in Validation and once in
// Test, read the same numbers.
let words: Vec<&str> = HELD_OUT.split(' ').collect();
let chunks: Vec<String> = words.chunks(3).map(|c| c.join(" ")).collect();
let minted: Vec<&str> = chunks.iter().map(String::as_str).collect();
let train_item = in_split("item:t:1", UNRELATED, Split::Train, false);
let v = leak_diagnostic(
&minted,
&[
in_split("item:v:1", HELD_OUT, Split::Validation, false),
train_item.clone(),
],
);
let test = in_split("item:c:1", HELD_OUT, Split::Test, false);
let t =
TestReadings::at_checkpoint(Checkpoint::for_test(1), &[], &minted, &[test, train_item]);
assert_eq!(t.items(), v.items);
assert_eq!(t.max_chrf(), v.max_chrf.as_ref().map(|p| p.chrf));
assert_eq!(t.coverage_by_n(), v.coverage_by_n.as_slice());
}
}

View file

@ -1,6 +1,7 @@
//! The train/validation/test split is derived from an item's group and nothing
//! else. No stored assignment exists, so no writer can reassign one. An item is
//! read in its live split; Test is read only under a Checkpoint.
//! read in its live split; Test is read only under a Checkpoint, and only the
//! lib can make one (convergence-freeze adds the door).
use crate::corpus::{CorpusItem, Source};
@ -63,40 +64,51 @@ impl SplitScheme {
}
}
/// Permission to read Test once. The loop declares one at a convergence
/// checkpoint (convergence-test); `TestReadings::at_checkpoint` consumes it, so
/// one declaration buys one Test reading, and `EncoderOffer::for_checkpoint`
/// borrows it first.
/// Permission to read Test once. Only the weksa lib can make one: there is no
/// public constructor, so nothing outside it (the binary, a driver crate, a
/// doctest, an integration test) can read Test. The one door is added by
/// convergence-freeze, which builds a `Checkpoint` from the convergence window
/// over the run's persisted round records (convergence-test).
/// `TestReadings::at_checkpoint` consumes it, so one `Checkpoint` buys one Test
/// reading.
///
/// ```
/// fn f(c: &weksa::split::Checkpoint) -> u32 { c.round() }
/// ```
///
/// No public constructor:
///
/// ```compile_fail
/// let _ = weksa::split::Checkpoint::declare(1);
/// ```
///
/// One reading per checkpoint:
///
/// ```
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// let c = Checkpoint::declare(3);
/// assert_eq!(c.round(), 3);
/// let _ = TestReadings::at_checkpoint(c, &[], &[], &[]);
/// fn f(c: Checkpoint) { let _ = TestReadings::at_checkpoint(c, &[], &[], &[]); }
/// ```
///
/// One declaration, one reading:
///
/// ```compile_fail
/// use weksa::score::TestReadings;
/// use weksa::split::Checkpoint;
/// let c = Checkpoint::declare(3);
/// let _ = TestReadings::at_checkpoint(c, &[], &[], &[]);
/// let _ = TestReadings::at_checkpoint(c, &[], &[], &[]);
/// fn f(c: Checkpoint) {
/// let _ = TestReadings::at_checkpoint(c, &[], &[], &[]);
/// let _ = TestReadings::at_checkpoint(c, &[], &[], &[]);
/// }
/// ```
///
/// ```compile_fail
/// use weksa::split::Checkpoint;
/// let c = Checkpoint::declare(3);
/// let _again = c.clone();
/// fn f(c: weksa::split::Checkpoint) { let _ = c.clone(); }
/// ```
pub struct Checkpoint {
round: u32,
}
impl Checkpoint {
pub fn declare(round: u32) -> Self {
#[cfg(test)]
pub(crate) fn for_test(round: u32) -> Self {
Self { round }
}
@ -104,3 +116,49 @@ impl Checkpoint {
self.round
}
}
/// Item builders for the unit tests that live in `src`: the twins of
/// `tests/common`'s `group_in_bucket`, `item_in`, `cast` and `model`.
#[cfg(test)]
pub(crate) mod fixture {
use super::{Split, SplitScheme};
use crate::corpus::{CorpusItem, ModelFamily, Source};
use crate::packet::EntityId;
/// The first group `g<i>` whose V1 bucket is in `split`.
pub(crate) fn group_in(split: Split) -> String {
(0..100_000)
.map(|i| format!("g{i}"))
.find(|g| SplitScheme::V1.of_bucket(SplitScheme::V1.bucket(g)) == split)
.unwrap()
}
pub(crate) fn item(key: &str, text: &str, group: &str, model_written: bool) -> CorpusItem {
let source = if model_written {
Source::ModelWritten {
family: ModelFamily::Unrecorded,
generator: None,
prompt_digest: None,
}
} else {
Source::CastAuthored {
persona: "nibu".into(),
fixture: "f.yaml".into(),
author: "Ada Writer".into(),
}
};
CorpusItem {
id: key.into(),
text: text.into(),
language: "en-US".into(),
speaker: EntityId::parse("entity:nibu").unwrap(),
names: vec![],
group: group.into(),
prior_turns: vec![],
source,
admitted_on: "2026-10-29".into(),
supersedes: None,
withdrawn: false,
}
}
}

View file

@ -1,16 +1,15 @@
mod common;
use common::{cast, ent, entities_in, group_in_bucket, item_in, model, world};
use weksa::context::{EncoderOffer, OfferRefusal, Prompt, TrainItems};
use weksa::split::Checkpoint;
use weksa::context::{
ENCODE_INSTRUCTIONS as ENCODE, EncoderOffer, MINT_INSTRUCTIONS as MINT, OfferRefusal, Prompt,
TrainItems,
};
use weksa::{
CorpusItem, CorpusItemId, CorpusStore, NameSpan, PacketId, PacketStore, StoreError,
StoreRefusal, Turn,
};
const MINT: &str = "Mint glosses from the lines below.";
const ENCODE: &str = "Encode the line below.";
struct Corpus {
_dir: tempfile::TempDir,
store: CorpusStore,
@ -109,15 +108,15 @@ fn train_items_are_in_key_order() {
let none = CorpusStore::open(&dir.path().join("c.cc")).unwrap();
let none = TrainItems::from_corpus(&none).unwrap();
assert_eq!((none.len(), none.is_empty()), (0, true));
assert_eq!(Prompt::mint(MINT, &none).text(), MINT);
assert!(Prompt::mint(MINT, &none).item_keys().is_empty());
assert_eq!(Prompt::mint(&none).text(), MINT);
assert!(Prompt::mint(&none).item_keys().is_empty());
}
#[test]
fn mint_prompt_holds_train_text_only() {
let c = corpus();
let t = TrainItems::from_corpus(&c.store).unwrap();
let p = Prompt::mint(MINT, &t);
let p = Prompt::mint(&t);
assert!(p.text().starts_with(MINT));
assert!(p.text().contains("alphamarker"));
for other in ["betamarker", "gammamarker", "deltamarker", "epsilonmarker"] {
@ -145,25 +144,24 @@ fn prompts_render_deterministically() {
.unwrap();
let t = TrainItems::from_corpus(&store).unwrap();
assert_eq!(
Prompt::mint(MINT, &t).text(),
Prompt::mint(&t).text(),
format!(
"{MINT}\n\n[item:a:1] entity:nibu: Hello there.\n\n[item:a:2] entity:nibu: Second line."
)
);
assert_eq!(Prompt::mint(MINT, &t).item_keys(), ["item:a:1", "item:a:2"]);
assert_eq!(Prompt::mint(&t).item_keys(), ["item:a:1", "item:a:2"]);
let offer = EncoderOffer::for_round(&store.get("item:a:2").unwrap().unwrap()).unwrap();
assert_eq!(
Prompt::encode(ENCODE, &offer, &t).text(),
Prompt::encode(&offer, &t).text(),
format!("{ENCODE}\n\n[item:a:2] entity:nibu: Second line.\n\nentities: entity:nibu")
);
assert_eq!(Prompt::encode(ENCODE, &offer, &t).item_keys(), ["item:a:2"]);
assert_eq!(Prompt::encode(&offer, &t).item_keys(), ["item:a:2"]);
}
#[test]
fn encoder_offer_split_gate() {
let c = corpus();
let cp = Checkpoint::declare(1);
let train = get(&c, "item:a:1");
let validation = get(&c, "item:b:1");
let test = get(&c, "item:c:1");
@ -171,7 +169,6 @@ fn encoder_offer_split_gate() {
let withdrawn = get(&c, "item:a:2");
assert!(withdrawn.withdrawn);
let round = |i: &CorpusItem| EncoderOffer::for_round(i).err();
let check = |i: &CorpusItem| EncoderOffer::for_checkpoint(i, &cp).err();
assert_eq!(round(&train), None);
assert_eq!(round(&validation), None);
@ -179,17 +176,10 @@ fn encoder_offer_split_gate() {
assert_eq!(round(&no_split), Some(OfferRefusal::NoSplit));
assert_eq!(round(&withdrawn), Some(OfferRefusal::Withdrawn));
assert_eq!(check(&train), None);
assert_eq!(check(&validation), None);
assert_eq!(check(&test), None);
assert_eq!(check(&no_split), Some(OfferRefusal::NoSplit));
assert_eq!(check(&withdrawn), Some(OfferRefusal::Withdrawn));
// Withdrawn wins over NoSplit.
let mut both = no_split.clone();
both.withdrawn = true;
assert_eq!(round(&both), Some(OfferRefusal::Withdrawn));
assert_eq!(check(&both), Some(OfferRefusal::Withdrawn));
// A withdrawn Test item is Withdrawn, not TestBeforeCheckpoint.
let mut test_gone = test.clone();
test_gone.withdrawn = true;
@ -256,7 +246,7 @@ fn encoder_offer_entities_are_the_items_own() {
"a sibling's entity is not the item's"
);
assert_eq!(offer.key(), "item:a:1");
let p = Prompt::encode(ENCODE, &offer, &t);
let p = Prompt::encode(&offer, &t);
assert!(
p.text()
.ends_with("entities: entity:brokkr, entity:hero, entity:kay")
@ -359,7 +349,7 @@ fn prior_turns_print_only_text_a_live_train_item_holds() {
store.withdraw("item:a:1").unwrap();
let t = TrainItems::from_corpus(&store).unwrap();
let mint = Prompt::mint(MINT, &t);
let mint = Prompt::mint(&t);
for secret in ["withdrawnsecret", "testsecret", "validation reply"] {
assert!(!mint.text().contains(secret), "mint printed {secret}");
}
@ -370,7 +360,7 @@ fn prior_turns_print_only_text_a_live_train_item_holds() {
let encode = |key: &str| {
let item = store.get(key).unwrap().unwrap();
Prompt::encode(ENCODE, &EncoderOffer::for_round(&item).unwrap(), &t)
Prompt::encode(&EncoderOffer::for_round(&item).unwrap(), &t)
.text()
.to_string()
};
@ -407,6 +397,6 @@ fn prior_turn_match_uses_the_stores_text_key() {
}];
store.add(reply.clone(), &entities).unwrap();
let t = TrainItems::from_corpus(&store).unwrap();
let p = Prompt::encode(ENCODE, &EncoderOffer::for_round(&reply).unwrap(), &t);
let p = Prompt::encode(&EncoderOffer::for_round(&reply).unwrap(), &t);
assert!(p.text().contains("entity:brokkr: context line"));
}

View file

@ -10,10 +10,9 @@ use common::{cast, group_in_bucket, item_in, model};
use serde_json::Value;
use weksa::CorpusItem;
use weksa::score::{
Embedder, ItemScore, OllamaEmbedder, ScoreInput, Scorer, TestReadings, aggregate, chrf, cosine,
Embedder, ItemScore, OllamaEmbedder, ScoreInput, Scorer, aggregate, chrf, cosine,
leak_diagnostic,
};
use weksa::split::Checkpoint;
/// (reference, hypothesis, sacrebleu 2.4.3 sentence_chrf), map 491536c.
const VECTORS: [(&str, &str, f64); 6] = [
@ -877,78 +876,6 @@ fn leak_diagnostic_reads_validation_only() {
assert!(on_validation.max_chrf.unwrap().chrf > 99.0);
}
#[test]
fn test_readings_at_checkpoint() {
let train_item = train("item:t:1", UNRELATED);
let test = item_in("item:c:1", HELD_OUT, &group_in_bucket(90), cast());
let test_model = item_in(
"item:c:2",
"model words here",
&group_in_bucket(90),
model(),
);
let mut gone = item_in("item:c:3", "withdrawn words", &group_in_bucket(90), cast());
gone.withdrawn = true;
let val = validation("item:v:1", "gardening is quiet work");
let items = [
train_item.clone(),
test.clone(),
test_model.clone(),
gone.clone(),
val.clone(),
];
let scored = [
(&train_item, score(10.0, Some(0.5))),
(&val, score(40.0, Some(0.8))),
(&test, score(60.0, Some(0.6))),
(&test_model, score(100.0, Some(1.0))),
(&gone, score(90.0, Some(0.9))),
];
let t = TestReadings::at_checkpoint(Checkpoint::declare(2), &scored, &[HELD_OUT], &items);
assert_eq!(
(t.count(), t.chrf(), t.meaning()),
(1, Some(60.0), Some(0.6))
);
assert_eq!(
t.items(),
1,
"model-written and withdrawn Test items are excluded"
);
assert!(t.max_chrf().unwrap() > 99.0);
assert_eq!(t.coverage_by_n()[2].share, Some(1.0));
// A minted string that is not the Test text reads low; the same method as
// the Validation reading, so the same minted text reads alike in each.
let t = TestReadings::at_checkpoint(Checkpoint::declare(2), &scored, &["zzz"], &items);
assert!(t.max_chrf().unwrap() < 20.0);
assert_eq!(t.coverage_by_n()[2].share, Some(0.0));
let empty = TestReadings::at_checkpoint(Checkpoint::declare(2), &[], &[HELD_OUT], &[]);
assert_eq!(
(empty.count(), empty.chrf(), empty.meaning()),
(0, None, None)
);
assert_eq!((empty.items(), empty.max_chrf()), (0, None));
}
#[test]
fn validation_and_test_leak_agree_in_method() {
// The same text and minted strings, once in Validation and once in Test,
// read the same numbers.
let minted = chunks(3, " ");
let minted = refs(&minted);
let train_item = train("item:t:1", UNRELATED);
let v = leak_diagnostic(
&minted,
&[validation("item:v:1", HELD_OUT), train_item.clone()],
);
let test = item_in("item:c:1", HELD_OUT, &group_in_bucket(90), cast());
let t = TestReadings::at_checkpoint(Checkpoint::declare(1), &[], &minted, &[test, train_item]);
assert_eq!(t.items(), v.items);
assert_eq!(t.max_chrf(), v.max_chrf.as_ref().map(|p| p.chrf));
assert_eq!(t.coverage_by_n(), v.coverage_by_n.as_slice());
}
#[test]
fn held_out_train_union_excludes_withdrawn_train_items() {
let mut gone = train("item:t:1", HELD_OUT);