diff --git a/crates/weksa/src/run.rs b/crates/weksa/src/run.rs index 93ae120..299ea72 100644 --- a/crates/weksa/src/run.rs +++ b/crates/weksa/src/run.rs @@ -23,7 +23,7 @@ //! uses the template table. The prompt source pin covers `context.rs`, //! `split.rs` and `lower.rs`. -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::fmt; use std::io::ErrorKind; use std::path::{Path, PathBuf}; @@ -801,23 +801,21 @@ pub enum RoundOutcome { Recorded(RoundRecord), } -/// The rule codes an admission refusal broke, each once: validator rules by +/// The distinct rule codes an admission refusal broke: validator rules by /// code, a store refusal by its variant name. Nothing from the packet or the /// stores is kept; an I/O failure is `io`. -fn admit_rule_codes(e: &StoreError) -> Vec { - let mut codes: Vec = match e { +fn admit_rule_codes(e: &StoreError) -> BTreeSet { + match e { StoreError::Invalid(rs) => rs.iter().map(|r| r.rule().to_string()).collect(), - StoreError::Refused(r) => vec![r + StoreError::Refused(r) => [r .to_string() .split([' ', ':']) .next() .unwrap_or_default() - .to_string()], - StoreError::Io(_) => vec!["io".to_string()], - }; - codes.sort(); - codes.dedup(); - codes + .to_string()] + .into(), + StoreError::Io(_) => ["io".to_string()].into(), + } } /// How one item fared: where it was refused, or the text it lowered to, with diff --git a/crates/weksa/tests/golf_loop.rs b/crates/weksa/tests/golf_loop.rs index 4b18427..6269f99 100644 --- a/crates/weksa/tests/golf_loop.rs +++ b/crates/weksa/tests/golf_loop.rs @@ -2899,6 +2899,16 @@ fn views_with_one_meaning_share_one_unanswered_lowering_prompt() { assert_eq!(unique.len(), 2); } +/// Several refusals under one rule in one packet: the item still counts once. +fn every_concept_unknown(d: &mut PacketDraft) { + for r in &mut d.referents { + r.concept = "concept:999".parse().unwrap(); + } + for p in &mut d.predications { + p.concept = "concept:999".parse().unwrap(); + } +} + #[test] fn admit_refusals_are_counted_by_rule_and_printed_with_the_label() { use weksa::packet::EntityId; @@ -2913,7 +2923,7 @@ fn admit_refusals_are_counted_by_rule_and_printed_with_the_label() { }; let mut model = fake(&[ (1, edited(1, nobody)), - (2, edited(2, unknown_concept)), + (2, edited(2, every_concept_unknown)), (3, edited(3, empty)), ]); let r = recorded(round(&mut dao.run, &mut model, &Scorer::new(Bag)).unwrap());