From de720eacefa33aeaa583cf5a6723d8733d6691d1 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 27 Nov 2026 21:54:35 +0100 Subject: [PATCH] Persona wake: the open floor has one form gate and one speaker gate, and its once-per-line and tagged-line cases are pinned Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/src/heartbeat.rs | 5 ++--- crates/mind-body/src/heartbeat/tests.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/crates/mind-body/src/heartbeat.rs b/crates/mind-body/src/heartbeat.rs index f9f4c1d..f0ed00c 100644 --- a/crates/mind-body/src/heartbeat.rs +++ b/crates/mind-body/src/heartbeat.rs @@ -542,7 +542,7 @@ pub(crate) fn wakes(who: &Addressee, delivery: &ChatDelivery, speaker: Speaker, } let addressed = is_for(who, delivery); if speaker.human() { - let wakes = addressed || facts.own_room || facts.in_exchange || (speaker == Speaker::Member && facts.open_floor); + let wakes = addressed || facts.own_room || facts.in_exchange || facts.open_floor; return wakes.then_some(if addressed { WakeCause::AddressedByHuman } else { WakeCause::Human }); } let explicit = delivery.mentions.iter().any(|id| id == who.matrix_id()) || matches!(delivery.basis, Some(Basis::Tag | Basis::Reply)); @@ -563,9 +563,8 @@ pub(crate) struct Hearer<'a> { /// (`tempo::pick`) among the hearers whose floor is open, so the poll and the simulator choose the same one. None when the /// line is not open or no hearer is eligible. pub(crate) fn floor_to(hearers: &[Hearer], speaker: Speaker, beat_s: u32) -> Option { - let line = &hearers.first()?.delivery; + hearers.first()?; let open = speaker == Speaker::Member - && line.form == Form::Message && !hearers.iter().any(|hearer| hearer.delivery.is_direct || !hearer.delivery.mentions.is_empty() || is_for(hearer.addressee, &hearer.delivery)); if !open { return None; diff --git a/crates/mind-body/src/heartbeat/tests.rs b/crates/mind-body/src/heartbeat/tests.rs index 2531db0..fa57bd2 100644 --- a/crates/mind-body/src/heartbeat/tests.rs +++ b/crates/mind-body/src/heartbeat/tests.rs @@ -880,6 +880,20 @@ mod wake_rule { assert_eq!(rig.poll(), Outcome::Polled { launched: vec![Slug("bob".into())] }, "unless the line addresses her"); } + #[test] + fn every_open_line_a_mind_took_in_one_wake_is_taken_and_a_line_tagging_anyone_is_not_open() { + let rig = quiet_rig(); + said_in_general(&rig, general(1, "@newcomer:chat", "hello everyone!")); + said_in_general(&rig, general(2, "@other:chat", "hello, I am new too")); + assert_eq!(rig.poll(), Outcome::Polled { launched: vec![Slug("ann".into())] }); + rig.end_unit(ANN); + rig.advance(1); + assert_eq!(rig.poll(), Outcome::Polled { launched: vec![] }, "her one turn took both lines: Bob is not picked for the second"); + let rig = quiet_rig(); + said_in_general(&rig, ChatDelivery { mentions: vec!["@alice:chat".into()], ..general(3, "@newcomer:chat", "hello alice") }); + assert_eq!(rig.poll(), Outcome::Polled { launched: vec![] }, "a line that tags a person is not the floor's"); + } + #[test] fn a_minds_own_line_a_notice_an_edit_a_tag_or_an_operator_opens_no_floor() { for (line, why) in [