tempo: every Mind of the roster votes; silence and an unreadable mind count as the default beat

Ruling eureka-body:ruling:tempo-silent-means-default: the tally is the lower median over all Minds, so one voter among silent Minds cannot move the beat. Addresses finding tempo-one-voter-decides. Also pins that the newest vote is found across pages of pulses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-31 08:02:30 +01:00
commit 1c0182195d
4 changed files with 48 additions and 11 deletions

View file

@ -619,8 +619,8 @@ pub fn poll(organs: &Organs, config: &Config) -> Result<Outcome> {
rows.push(row);
}
// The tempo is the tally of every readable Mind newest vote, braked or not.
let votes: Vec<u32> = rows.iter().filter_map(|row| row.read.as_ref().and_then(MindRead::vote)).collect();
// The tempo is the tally over every Mind of the roster, braked or not; a Mind with no vote or no readable mind counts as the default beat.
let votes: Vec<Option<u32>> = rows.iter().map(|row| row.read.as_ref().and_then(MindRead::vote)).collect();
let beat_s = tempo::tally(&votes);
let mut launches: Vec<String> = Vec::new();

View file

@ -331,6 +331,21 @@ fn a_standing_vote_stands_until_she_replaces_it_whatever_else_she_writes() {
assert_eq!(trace.tempo_s, 3600);
}
#[test]
fn her_newest_vote_is_found_across_pages_of_pulses() {
let rig = Rig::new();
rig.turn(ANN, 3000);
rig.turn(BOB, 3000);
rig.pulse(ANN, 2000, Some(600), None);
for n in 1..=12 {
rig.pulse(ANN, 2000 - n * 10, None, Some(1));
}
rig.pulse(ANN, 1000, Some(7200), None);
rig.poll();
let trace = rig.store.traces.borrow().last().cloned().unwrap();
assert_eq!(trace.instances[ANN].vote_beat_s, Some(7200));
}
#[test]
fn her_newest_vote_is_the_latest_admitted_not_the_highest_label() {
let rig = Rig::new();
@ -361,6 +376,19 @@ fn a_mind_whose_launch_keeps_failing_neither_starves_the_beat_nor_reads_as_never
assert_eq!(rig.launched().iter().filter(|slug| slug.0 == "bob").count(), 12);
}
#[test]
fn a_mind_that_cannot_be_read_votes_the_default_beat() {
let rig = Rig::new();
rig.turn(ANN, 3000);
rig.turn(BOB, 3000);
rig.pulse(ANN, 100, Some(7200), None);
rig.down[BOB].set(true);
rig.poll();
let trace = rig.store.traces.borrow().last().cloned().unwrap();
assert_eq!(trace.instances[ANN].vote_beat_s, Some(7200));
assert_eq!(trace.tempo_s, 900, "her 7200 and the unreadable Mind's default: the lower median is the default");
}
#[test]
fn no_votes_is_the_default_beat() {
let rig = Rig::new();

View file

@ -5,8 +5,7 @@
//! The Minds jointly hold the lever to one heartbeat. `tally` turns their votes
//! into the beat; `pick` chooses who takes the turn when a beat falls. The
//! heartbeat owns when a beat falls and what it launches; this module owns only
//! the two decisions. If the operator picks another tally
//! (`eureka-body:question:tempo-lever-tally`), only `tally` changes.
//! the two decisions.
use std::cmp::Ordering;
@ -17,11 +16,12 @@ pub const DEFAULT_BEAT_S: u32 = 900;
/// Interim, per `swarm-shares-log-bound`, until the swarm's governance sets it.
pub const LOG_BOUND_ORDERS: f64 = 1.0;
/// The swarm's tempo: the lower median of the votes (seconds per beat), each
/// Mind's newest. No votes is `DEFAULT_BEAT_S`. One outlier cannot move the
/// median, and the median is always a beat some Mind voted for.
pub fn tally(votes: &[u32]) -> u32 {
let mut sorted = votes.to_vec();
/// The swarm's tempo (ruling `eureka-body:ruling:tempo-silent-means-default`):
/// the lower median over every Mind in the roster, each her newest vote in seconds
/// per beat. A Mind with no standing vote, or whose mind cannot be read, is
/// `None` and counts as `DEFAULT_BEAT_S`, so a lone voter cannot move the beat.
pub fn tally(votes: &[Option<u32>]) -> u32 {
let mut sorted: Vec<u32> = votes.iter().map(|vote| vote.unwrap_or(DEFAULT_BEAT_S)).collect();
sorted.sort_unstable();
match sorted.len() {
0 => DEFAULT_BEAT_S,

View file

@ -30,6 +30,7 @@ fn the_score_is_the_wait_in_beats_times_ten_to_the_urgency_in_orders() {
#[test]
fn no_votes_is_the_default_beat() {
assert_eq!(tally(&[]), DEFAULT_BEAT_S);
assert_eq!(tally(&[None, None]), DEFAULT_BEAT_S);
assert_eq!(DEFAULT_BEAT_S, 900);
}
@ -45,13 +46,21 @@ fn the_tally_is_the_lower_median_and_one_outlier_cannot_move_it() {
(&[60, 60, 86_400, 86_400, 600], 600),
];
for (votes, want) in table {
assert_eq!(tally(votes), want, "{votes:?}");
let votes: Vec<Option<u32>> = votes.iter().copied().map(Some).collect();
assert_eq!(tally(&votes), want, "{votes:?}");
}
}
#[test]
fn a_silent_or_unreadable_mind_counts_as_the_default_beat() {
let silent = |voters: usize, vote: u32, total: usize| -> Vec<Option<u32>> { (0..total).map(|i| (i < voters).then_some(vote)).collect() };
assert_eq!(tally(&silent(1, 60, 8)), 900, "one voter among seven silent Minds cannot move the beat");
assert_eq!(tally(&silent(5, 60, 8)), 60, "a majority of the roster moves it");
}
#[test]
fn the_tally_does_not_depend_on_the_order_the_votes_came_in() {
assert_eq!(tally(&[900, 60, 300, 600]), tally(&[60, 300, 600, 900]));
assert_eq!(tally(&[Some(900), Some(60), None, Some(600)]), tally(&[None, Some(60), Some(600), Some(900)]));
}
#[test]