From 07722ab39657b9d04658029767e2781a974bd06d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 07:24:09 +0100 Subject: [PATCH] wave: pin the rest band, the no-focus depth and AgencyGraph::restricted against surviving mutants Co-Authored-By: Claude Sonnet 5.5 --- crates/ghostlight/src/cover.rs | 15 +++++++++++++++ crates/ghostlight/src/wave.rs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/crates/ghostlight/src/cover.rs b/crates/ghostlight/src/cover.rs index c266d73..e2fe013 100644 --- a/crates/ghostlight/src/cover.rs +++ b/crates/ghostlight/src/cover.rs @@ -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. diff --git a/crates/ghostlight/src/wave.rs b/crates/ghostlight/src/wave.rs index ecd9e1c..4e5a6d3 100644 --- a/crates/ghostlight/src/wave.rs +++ b/crates/ghostlight/src/wave.rs @@ -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);