From 9457f4968401f8a4f7a359dad0a988ac81a0066d Mon Sep 17 00:00:00 2001 From: damocles Date: Sat, 7 Nov 2026 17:50:30 +0100 Subject: [PATCH] test the wake prompt and the Messaging permission after the tool removal --- hive-agent/src/serve_common.rs | 25 +++++++++++++++++++++++++ hive-types/src/permission.rs | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/hive-agent/src/serve_common.rs b/hive-agent/src/serve_common.rs index c1d6fe8e..910a290f 100644 --- a/hive-agent/src/serve_common.rs +++ b/hive-agent/src/serve_common.rs @@ -110,3 +110,28 @@ pub fn build_row(args: TurnRowArgs<'_>) -> TurnStatRow { session_id: bus.current_session_id(), } } + +#[cfg(test)] +mod wake_prompt_tests { + use super::format_wake_prompt; + + /// The prompt is the sender and body only: no `[msg #N]` tag and no + /// "N more pending, call recv" nudge, since the tools they pointed at + /// are gone. + #[test] + fn the_wake_prompt_carries_the_sender_and_body_only() { + let p = format_wake_prompt("todo", "you have todos", false, false); + assert_eq!(p, "Incoming message from `todo`:\n---\nyou have todos\n---"); + assert!(!p.contains("[msg #") && !p.contains("recv")); + } + + #[test] + fn a_banner_leads_the_prompt_and_redelivery_wins_over_interruption() { + let redelivered = format_wake_prompt("a", "b", true, true); + assert!(redelivered.starts_with(hive_sh4re::inbox::REDELIVERY_HINT)); + let interrupted = format_wake_prompt("a", "b", false, true); + assert!(interrupted.starts_with(hive_sh4re::inbox::INTERRUPTED_HINT)); + let plain = format_wake_prompt("a", "b", false, false); + assert!(plain.starts_with("Incoming message from `a`:")); + } +} diff --git a/hive-types/src/permission.rs b/hive-types/src/permission.rs index 43523962..7acb781e 100644 --- a/hive-types/src/permission.rs +++ b/hive-types/src/permission.rs @@ -184,6 +184,26 @@ impl From for &'static str { mod tests { use super::*; + /// Agents message each other over matrix, so no permission grants a + /// hyperhive messaging tool any more. `Messaging` stays a valid stored + /// value, and it grants nothing. + #[test] + fn messaging_is_an_accepted_value_that_grants_no_tool() { + assert!(Permission::Messaging.tools().is_empty()); + assert_eq!( + serde_json::from_str::("\"messaging\"").expect("stored value decodes"), + Permission::Messaging + ); + for p in Permission::ALL { + for tool in p.tools() { + assert!( + !["send", "recv", "ack_until"].contains(tool), + "{p:?} still grants the removed tool {tool}" + ); + } + } + } + /// The `as_str` spelling of every variant. `ALL` is stable-ordered, so /// a variant added to the enum but not to `ALL` or `as_str` shows here. #[test]