diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index 9f805fd..7b11969 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -1428,6 +1428,8 @@ impl RunStores { ) -> Result { let store = |_| RunError::Store; check_drift(self, model, scorer)?; + // A refused round writes nothing: the round is read before any folder is made. + let mut splits = self.held_splits(n, &[Split::Train, Split::Validation])?; let inventory = self.inventory.inventory().map_err(store)?; let ontology = self.ontology.ontology().map_err(store)?; @@ -1444,8 +1446,6 @@ impl RunStores { PacketStore::open(&dir.join("permute.cc")).map_err(store)?, ]; - let mut splits = self.held_splits(n, &[Split::Train, Split::Validation])?; - let mut waiting: Vec = Vec::new(); let mut readings = Vec::new(); // Texts per split: (item text, recorded, replay, [drop, permute]). diff --git a/crates/weksa/tests/golf_loop.rs b/crates/weksa/tests/golf_loop.rs index 8d553dd..771da27 100644 --- a/crates/weksa/tests/golf_loop.rs +++ b/crates/weksa/tests/golf_loop.rs @@ -4121,6 +4121,28 @@ fn a_stance_ablation_refuses_a_cycle_round_and_missing_round_answers() { )); } +#[test] +fn a_refused_stance_ablation_creates_no_folder_and_wipes_no_store() { + let (dao, _) = recorded_dao(|_| {}); + let (mut rec, mut model) = (Lowerer::new(reader), Lowerer::new(reader)); + // No round 99: no folder appears. + assert!(matches!( + dao.run.stance_ablation(99, &mut rec, &mut model, &Scorer::new(Bag)), + Err(RunError::Malformed("round")) + )); + assert!(!dao.run.ablation_dir(99).exists(), "a refused ablation makes no folder"); + // An earlier ablation of a refused n keeps its stores byte for byte. + let kept = dao.run.ablation_dir(2); + std::fs::create_dir_all(&kept).unwrap(); + std::fs::write(kept.join("base.cc"), b"earlier ablation").unwrap(); + assert!(matches!( + dao.run.stance_ablation(2, &mut rec, &mut model, &Scorer::new(Bag)), + Err(RunError::Malformed("round")) + )); + assert_eq!(std::fs::read(kept.join("base.cc")).unwrap(), b"earlier ablation"); + assert_eq!(std::fs::read_dir(&kept).unwrap().count(), 1); +} + #[test] fn a_stance_ablation_refuses_a_cycle_round() { let mut dao = dao();