heartbeat beat: a Mind waiting out failed wakes is not the beat's pick

Cooling is part of a Mind's standing, so the poll's floor and the beat read one derivation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-28 02:39:01 +01:00
commit 659bc6aa2b
2 changed files with 18 additions and 2 deletions

View file

@ -618,7 +618,7 @@ fn standings_of(rows: &[Row], state: &HeartbeatState, now: DateTime<Utc>, 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<Outcome> {
let minds: Vec<String> = 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<String> = rows.iter().filter(|row| row.cooling(now, beat_s)).map(|row| row.slug().0.clone()).collect();
let mut passed_over: Vec<String> = Vec::new();
let mut tried: Vec<usize> = Vec::new();
'floor: loop {
let floor = floors(&rows, &state, now, config, &minds, &passed_over).won;

View file

@ -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:?}");
}