diff --git a/crates/mind-body/src/heartbeat.rs b/crates/mind-body/src/heartbeat.rs index 8ed66f6..4462fde 100644 --- a/crates/mind-body/src/heartbeat.rs +++ b/crates/mind-body/src/heartbeat.rs @@ -618,7 +618,7 @@ fn standings_of(rows: &[Row], state: &HeartbeatState, now: DateTime, config let last = state.last_turn_at.get(&row.slug().0).copied(); Standing { slug: row.slug().0.clone(), - eligible: row.idle(), + eligible: row.idle() && !row.cooling(now, config.beat_s), waited_s: last.map(|turn| u64::try_from((now - turn).num_seconds()).unwrap_or(0)), last_turn_ms: last.map(|turn| turn.timestamp_millis()), // The seam for topic subscriptions (a later cut): a Mind's nearest subscription scores her deliveries here. @@ -904,7 +904,7 @@ pub fn poll(organs: &Organs, config: &Config) -> Result { let minds: Vec = config.personas.iter().map(|mind| mind.matrix_id.clone()).collect(); // A Mind whose start failed on a line the floor gave her passes it on: the next of the pick takes it in the same poll. One whose // last wakes failed is waited out (`cooling`) and passes the floor on likewise. - let mut passed_over: Vec = rows.iter().filter(|row| row.cooling(now, beat_s)).map(|row| row.slug().0.clone()).collect(); + let mut passed_over: Vec = Vec::new(); let mut tried: Vec = Vec::new(); 'floor: loop { let floor = floors(&rows, &state, now, config, &minds, &passed_over).won; diff --git a/crates/mind-body/src/heartbeat/tests.rs b/crates/mind-body/src/heartbeat/tests.rs index 00b8004..e0aafdb 100644 --- a/crates/mind-body/src/heartbeat/tests.rs +++ b/crates/mind-body/src/heartbeat/tests.rs @@ -1293,3 +1293,19 @@ fn a_claim_survives_a_trace_that_cannot_be_read() { assert_eq!(rig.store.state.borrow().clone().unwrap().handled_mentions, ["ann:$e1"]); } +/// Soul's p7: the beat waits out a Mind's failed wakes as the poll does. +#[test] +fn the_beat_does_not_start_a_mind_that_is_cooling() { + let rig = quiet_rig(); + rig.say(ANN, delivery(1, "@op:chat", "Ann, please", &[])); + rig.poll(); + rig.fail_turn(ANN); + rig.advance(5); + let now = rig.now(); + rig.with_state(|state| { + state.last_beat_at = now - Duration::seconds(i64::from(BEAT_S) + 1); + state.last_turn_at.insert("bob".into(), now); + }); + let Outcome::Polled { launched } = rig.poll() else { panic!("held") }; + assert!(!launched.iter().any(|slug| slug.0 == "ann"), "{launched:?}"); +}