Admit rules are a set: one count per item per rule, pinned by a packet that breaks V5 many times

Soul s1 low: the per-item dedup was unpinned. A BTreeSet makes it structural.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Weksa 2026-11-10 14:08:46 +00:00
commit d502cb396a
2 changed files with 20 additions and 12 deletions

View file

@ -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<String> {
let mut codes: Vec<String> = match e {
fn admit_rule_codes(e: &StoreError) -> BTreeSet<String> {
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

View file

@ -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());