diff --git a/crates/weksa/tests/golf_loop.rs b/crates/weksa/tests/golf_loop.rs index f8f036e..773d8b5 100644 --- a/crates/weksa/tests/golf_loop.rs +++ b/crates/weksa/tests/golf_loop.rs @@ -4946,6 +4946,61 @@ fn a_cycle_decides_each_language_on_its_own_floor() { assert!(matches!(d.verdict(), Verdict::Rejected(Why::Regressed(_))), "{:?}", d.verdict()); } +/// A bilingual run whose head round loses one Validation item per language +/// (en-US item 2, ja-JP item 13), then FLOOR_ARMS_MIN more rounds: the first `good_repeats` +/// lose nothing, the rest lose what the head did. The candidate of the +/// returned cycle loses nothing. +fn bilingual_cycle(good_repeats: usize) -> Decision { + let mut dao = bilingual(LAOZI_JA); + let lossy = || { + let mut m = bilingual_fake(); + for key in ["item:daodejing:2", "item:daodejing:13"] { + m.answers.insert(key.into(), "not a draft".into()); + } + m + }; + let mut head = lossy(); + recorded(round(&mut dao.run, &mut head, &Scorer::new(Bag)).unwrap()); + for i in 0..FLOOR_ARMS_MIN { + let mut repeat = if i < good_repeats { bilingual_fake() } else { lossy() }; + recorded(round(&mut dao.run, &mut repeat, &Scorer::new(Bag)).unwrap()); + } + let mut model = bilingual_fake(); + model.candidate = Some((4, bilingual_answers())); + model.edit = Some(Ok(ONE_CONCEPT.to_string())); + run_cycle(&mut dao, &mut model) +} + +/// The panel accepts on the sum of the languages' gains only past the noise of +/// that sum (the root of their floors squared), through `cycle` and the floors +/// `floor_of` measures. Each language's gain here is inside its own floor and +/// the sum is past one step but inside the combined noise: a gain that looks +/// real language by language and is not. +#[test] +fn cycle_noise_term_is_pinned_through_cycle() { + // One repeat in three reads the lost items back: a floor in both languages. + let d = bilingual_cycle(1); + let rows = d.panel(); + assert_eq!(rows.len(), 2); + let delta = |r: &weksa::run::PanelReading| r.candidate.unwrap().composite - r.base.composite; + let sum: f64 = rows.iter().map(delta).sum(); + let noise = rows.iter().map(|r| r.floor.composite.powi(2)).sum::().sqrt(); + for r in rows { + assert!(r.floor.composite > 0.0, "{}: a floor to speak of", r.language); + assert!(delta(r) > 0.0, "{}: no language regressed", r.language); + assert!(r.candidate.unwrap().chrf >= r.base.chrf && r.candidate.unwrap().meaning >= r.base.meaning); + } + assert!(sum > LADDER_STEP, "the sum clears a step: {sum}"); + assert!(sum < noise, "and is inside the noise of the sum: {sum} {noise}"); + assert_eq!(d.verdict(), Verdict::Rejected(Why::NoGain)); + + // The same candidate over replicates that agree with the head has no noise to + // clear, and its gain is accepted. + let d = bilingual_cycle(0); + assert!(d.panel().iter().all(|r| r.floor.composite == 0.0)); + assert_eq!(d.verdict(), Verdict::Accepted); +} + #[test] fn ablation_reads_each_language_apart() { let mut dao = bilingual(LAOZI_JA); diff --git a/docs/targets/interlingua-lowering-map.md b/docs/targets/interlingua-lowering-map.md index 9766d35..ac72708 100644 --- a/docs/targets/interlingua-lowering-map.md +++ b/docs/targets/interlingua-lowering-map.md @@ -40,8 +40,8 @@ means no store holds it and nothing writes it. | Scene (cut `speaker-scene`) | Key `scene:@`, the item's split group; type `weksa.scene`: participants (speaker slugs) and, per ordered pair, relation features of slot `Scene` (relative status, intimacy, in-group, audience and whatever the loop adds), at an inventory revision (provenance; a run reads the features at its own head), and an `Annotator` | As Speaker. Keyed by the group, so a scene never straddles the split. `data/original/speaker-state.cc` holds Model-annotated keeper scenes, one per Train or Validation group of both languages (`weksa scene put|dump`); a Test group has none and reads `NoScene` | As Speaker; a model-annotated scene is never Test evidence | | Corpus item | Key `item::`, `n` canonical decimal >= 1 (no sign, no leading zero, from cut 2b); type `weksa.corpus_item` with text, language, speaker, split group, prior turns, source. Source `ModelWritten` carries a `ModelFamily` enum, the generator string as the fixture wrote it, and a prompt digest (cut 2b). The item carries no speaker state of its own: its speaker slug and group name the Speaker and Scene documents | Admitted once; the whole item is immutable (re-adding an identical item is a no-op, any difference is refused; a correction is a new item that `supersedes` the old); text already held under another key is refused unless the new item supersedes that key (cut 2b); withdrawn, never deleted, so old scores stay explainable | Importers and `weksa corpus add`, under `corpus-cast-plus-public-domain`; the source enum has no variant for Discord or any training-forbidden source (`corpus-clean`) | | Split assignment | Derived: `split(scheme, item.group)` | Fixed for a scheme; a new scheme is a new constant, never a reassignment. A model-written item whose group derives test is in no split; a superseding item keeps its predecessor's group | The hash function. Nobody assigns by hand, so there is no writer to forbid | -| Loop round | Key `run: