diff --git a/crates/mind-body/src/projection.rs b/crates/mind-body/src/projection.rs index 99d79f5..3ee9978 100644 --- a/crates/mind-body/src/projection.rs +++ b/crates/mind-body/src/projection.rs @@ -252,8 +252,9 @@ fn read_room(chat: &dyn MouthReader, request: &Request, own: &Addressee) -> (Roo display: delivery.sender_display.clone(), text: delivery.text.clone(), at_ms: delivery.at_unix_ms, - // The heartbeat's rule, the one that woke her: never a second opinion here. - to_her: is_for(own, delivery), + // The heartbeat's rule, the one that woke her: never a second opinion here. Under humans_pace a human's line in + // her own room always wakes her, so it is to her, as a direct message is (the plan's or unit's `own_rooms`). + to_her: is_for(own, delivery) || (request.own_rooms.contains(&delivery.room_alias) && delivery.sender != request.own_sender && !request.minds.contains(&delivery.sender)), event: delivery.event_id.clone(), reply: replied(&delivery.reply_to), }) diff --git a/crates/mind-body/src/projection/tests.rs b/crates/mind-body/src/projection/tests.rs index 95a53eb..01de541 100644 --- a/crates/mind-body/src/projection/tests.rs +++ b/crates/mind-body/src/projection/tests.rs @@ -945,6 +945,29 @@ fn request(dir: &std::path::Path, renders: Option, judge_against: Option< Request { instance: INSTANCE.into(), kind: TurnKind::Chat, state: None, room: Some("#swarm:gamecult.org".into()), seed: 5, renders, judge_against, operators: operators(), minds: minds(), own_sender: OWN.into(), tuning: dir.join(TUNING_FILE), through: Through::Projector, last_heard: vec![], recent: vec![], own_rooms: vec![], last_outcome: None } } +/// A human's line in her own room is to her (the humans_pace ruling: it always wakes her), with no name and no tag: the arrival +/// names who turned to her, the bridge opens on it and the speaking cues say who is waiting. A Mind's line there is not, and +/// neither is a human's in a room that is not hers. +#[test] +fn a_humans_line_in_her_own_room_is_to_her() { + let dir = tempfile::tempdir().unwrap(); + let stored = Stored(state()); + let nibu = "#nibu:gamecult.org"; + let mouth = |sender: &str, display: &str| ReadOnlyMouth { pending: ChatPending { persona: "eureka".into(), deliveries: vec![delivery(1, nibu, sender, display, "anyone around this evening?", &[])], tail: Some(vec![]), tail_gaps: vec![] }, reads: Cell::new(0) }; + let packet = |chat: &ReadOnlyMouth, own_rooms: Vec| { + let organs = Organs { persona: Some(&stored), chat: Some(chat), addressing: None, model: None }; + project(&organs, &Request { room: Some(nibu.into()), own_rooms, ..request(dir.path(), None, None) }, now()).unwrap()["packet"].clone() + }; + let meta = mouth(OPERATOR, "Meta"); + let own = packet(&meta, vec![nibu.into()]); + assert!(own["context"].as_str().unwrap().contains("turned to her"), "{own}"); + assert!(own["speaking"].as_str().unwrap().contains("is waiting on her"), "{own}"); + for (chat, own_rooms) in [(&meta, vec![]), (&mouth("@libby:gamecult.org", "Libby"), vec![nibu.to_owned()])] { + let other = packet(chat, own_rooms); + assert!(!other["context"].as_str().unwrap().contains("turned to her") && !other["speaking"].as_str().unwrap_or_default().contains("waiting on her"), "{other}"); + } +} + #[test] fn project_in_every_mode_writes_nothing() { let dir = tempfile::tempdir().unwrap();