Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(voice): cover account isolation for voice facts

Steven Enamakel779a1cfa05a2
diff --git a/crates/openhuman-core/src/channels/host/voice_tests.rs b/crates/openhuman-core/src/channels/host/voice_tests.rs
index 96f8cd942f..1b9fddfc2d 100644
--- a/crates/openhuman-core/src/channels/host/voice_tests.rs
+++ b/crates/openhuman-core/src/channels/host/voice_tests.rs
@@ -5,7 +5,10 @@ use tinychannels_bus::{ChannelRef, ConversationRef, VoiceNote};
fn scope(channel: &str, conversation: &str, turn: &str) -> HostVoiceScope {
HostVoiceScope {
configured_instance: channel.into(),
- channel: ChannelRef::default(),
+ channel: ChannelRef {
+ id: channel.split(':').next().unwrap_or(channel).into(),
+ account_id: Some(channel.into()),
+ },
conversation: ConversationRef {
id: conversation.into(),
..ConversationRef::default()
@@ -48,6 +51,34 @@ fn mirror_policy_reports_inbound_voice_from_recorded_envelope() {
assert!(!text.inbound_has_voice);
}
+#[test]
+fn same_conversation_and_turn_ids_do_not_cross_voice_facts_between_accounts() {
+ let mut voice = envelope("shared-conversation", "shared-turn", true);
+ voice.channel = ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("telegram:alice".into()),
+ };
+ let mut text = envelope("shared-conversation", "shared-turn", false);
+ text.channel = ChannelRef {
+ id: "telegram".into(),
+ account_id: Some("telegram:bob".into()),
+ };
+
+ record_inbound_envelope(&voice);
+ record_inbound_envelope(&text);
+
+ let alice = resolve_policy(
+ &ChannelVoiceConfig::default(),
+ &scope("telegram:alice", "shared-conversation", "shared-turn"),
+ );
+ let bob = resolve_policy(
+ &ChannelVoiceConfig::default(),
+ &scope("telegram:bob", "shared-conversation", "shared-turn"),
+ );
+ assert!(alice.inbound_has_voice, "Alice's voice turn was overwritten by Bob's text turn");
+ assert!(!bob.inbound_has_voice);
+}
+
#[test]
fn unknown_turn_defaults_to_no_voice() {
let policy = resolve_policy(&ChannelVoiceConfig::default(), &scope("t", "nope", "nope"));