wave: pin the rest band, the no-focus depth and AgencyGraph::restricted against surviving mutants

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-03 07:24:09 +01:00
commit 07722ab396
2 changed files with 46 additions and 0 deletions

View file

@ -622,6 +622,21 @@ mod tests {
)
}
#[test]
fn restriction_keeps_only_the_edges_between_the_members() {
let mut graph = AgencyGraph {
subjects: vec![subject(1), subject(2), subject(3), subject(4)],
edges: BTreeSet::new(),
};
graph.link(subject(1), subject(2));
graph.link(subject(2), subject(3));
graph.link(subject(3), subject(4));
let members = BTreeSet::from([subject(1), subject(2), subject(4)]);
let kept = graph.restricted(&members);
assert_eq!(kept.subjects, vec![subject(1), subject(2), subject(4)]);
assert_eq!(kept.edges, BTreeSet::from([(subject(1), subject(2))]));
}
/// Verification 21, at the design profile: 2,400 subjects, 240 cells, a cap
/// of 24, 36 urgency slots. Every subject exactly once, the budget held, and
/// the head of the attention order attended in detail.

View file

@ -672,6 +672,37 @@ mod tests {
assert!(wave.turns.iter().any(|turn| turn.node == council));
}
#[test]
fn the_last_band_is_the_rest_for_every_farther_distance() {
let r = realm();
let focus = at_tap_room(&r);
let knobs = knobs(&[1, 5000], 1, 16);
let mut hierarchy = derive_hierarchy(&r.f.state);
let root = hierarchy.root();
// The root is three nodes from the council: past the last band.
for (gap, due) in [(5000u64, true), (4999, false)] {
hierarchy.last_attended.insert(r.wanderers, FictionalMinutes(10_000 - gap));
hierarchy.last_attended.insert(r.crown, FictionalMinutes(10_000 - gap));
let wave = plan(&r.f, &hierarchy, &focus, &knobs, 10_000);
let turn = wave.turns.iter().find(|turn| turn.node == root);
assert_eq!(turn.is_some(), due, "gap {gap}");
assert!(turn.is_none_or(|turn| turn.distance == 3));
}
}
#[test]
fn no_focus_opens_only_as_deep_as_the_depth() {
let r = realm();
let hierarchy = derive_hierarchy(&r.f.state);
let crown = node(&r.f, NodeAnchor::Institution(r.crown));
let wave = plan(&r.f, &hierarchy, &Focus::default(), &knobs(&[1], 1, 16), 10);
let open: Vec<_> = wave.turns.iter().filter(|turn| turn.open).map(|t| t.node).collect();
assert_eq!(open, vec![hierarchy.root()]);
// The crown is closed under the open root, so the root speaks for it.
assert!(!wave.turns.iter().any(|turn| turn.node == crown));
assert!(voices_of(&wave, hierarchy.root()).contains(&r.crown));
}
#[test]
fn knobs_without_bands_or_turns_are_refused() {
let mut bad = knobs(&[1], 1, 1);