Skip to content

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

test(voice): remove redundant module-backed tests

Steven Enamakela41bcd902d19
diff --git a/crates/openhuman-core/src/modules/voice_tests.rs b/crates/openhuman-core/src/modules/voice_tests.rs
index 25ba8d1596..3f916d60f7 100644
--- a/crates/openhuman-core/src/modules/voice_tests.rs
+++ b/crates/openhuman-core/src/modules/voice_tests.rs
@@ -7,50 +7,8 @@
//! honest — `tinyvoice`'s own loader E2E, which drives a real module over
//! a real broker against the published artifact.
-use super::{
- clamped, encode_samples, hallucination_mode_wire, HallucinationMode, VoiceCallError,
- VoiceIntent,
-};
+use super::{encode_samples, hallucination_mode_wire, HallucinationMode, VoiceCallError};
use crate::config::Config;
-/// The intent tags are a wire contract with the module. A rename on either
-/// side turns a real command into `Unknown`, which degrades silently — the
-/// user's "pause" simply goes to the agent instead — so every tag is
-/// pinned here rather than trusted to match by inspection.
-#[test]
-fn every_intent_tag_decodes() {
- let cases: &[(&str, VoiceIntent)] = &[
- (r#"{"intent":"pause"}"#, VoiceIntent::Pause),
- (r#"{"intent":"resume"}"#, VoiceIntent::Resume),
- (r#"{"intent":"next"}"#, VoiceIntent::Next),
- (r#"{"intent":"previous"}"#, VoiceIntent::Previous),
- (r#"{"intent":"volume_up"}"#, VoiceIntent::VolumeUp),
- (r#"{"intent":"volume_down"}"#, VoiceIntent::VolumeDown),
- (r#"{"intent":"mute"}"#, VoiceIntent::Mute),
- (r#"{"intent":"unmute"}"#, VoiceIntent::Unmute),
- (r#"{"intent":"unknown"}"#, VoiceIntent::Unknown),
- (
- r#"{"intent":"set_volume","percent":40}"#,
- VoiceIntent::SetVolume { percent: 40 },
- ),
- (
- r#"{"intent":"play","query":"numb"}"#,
- VoiceIntent::Play {
- query: "numb".to_string(),
- },
- ),
- (
- r#"{"intent":"open_app","app":"slack"}"#,
- VoiceIntent::OpenApp {
- app: "slack".to_string(),
- },
- ),
- ];
- for (json, expected) in cases {
- let decoded: VoiceIntent = serde_json::from_str(json).expect(json);
- assert_eq!(&decoded, expected, "decoding {json}");
- }
-}
-
#[test]
fn hallucination_modes_use_the_wire_spelling() {
// The module rejects an unknown mode rather than defaulting, so a typo
@@ -160,208 +118,6 @@ fn the_registry_entry_matches_the_interface_this_client_calls() {
);
}
-/// Drive the real published module through OpenHuman's own module host.
-///
-/// `#[ignore]`d, and it must stay that way. The bus belongs to whichever
-/// runtime creates it, so two `#[tokio::test]`s that each load a module find
-/// the second one's broker already dead and hang rather than fail. A
-/// module-backed test has to be the only one in its process:
-///
-/// ```sh
-/// GGML_NATIVE=OFF cargo test --lib --features "$(bash scripts/ci/product-features.sh)" \
-/// --ignored --exact --nocapture \
-/// openhuman::modules::voice::tests::the_published_module_answers_through_this_client
-/// ```
-///
-/// It also downloads from the pinned release, so it needs network and is not
-/// something CI should carry.
-#[tokio::test]
-#[ignore = "loads a real module: needs network, and must be alone in its process"]
-async fn the_published_module_answers_through_this_client() {
- let mut config = Config::default();
- config.modules.enabled = true;
- config.modules.allow_download = true;
-
- // The whole client surface, against the artifact the registry pins.
- assert_eq!(
- super::route(&config, "please pause the music")
- .await
- .expect("route"),
- VoiceIntent::Pause
- );
- assert_eq!(
- super::route(&config, "set volume to 40")
- .await
- .expect("route"),
- VoiceIntent::SetVolume { percent: 40 }
- );
- assert_eq!(
- super::route(&config, "what is the weather")
- .await
- .expect("route"),
- VoiceIntent::Unknown
- );
- assert_eq!(
- super::sequence_utterance(&config, "hey tiny open slack", "Hey Tiny")
- .await
- .expect("sequence"),
- super::UtteranceDisposition::Command {
- command: "open slack".to_string()
- }
- );
- assert_eq!(
- super::sequence_utterance(&config, "open slack", "Hey Tiny")
- .await
- .expect("sequence"),
- super::UtteranceDisposition::Ignored
- );
- assert_eq!(
- super::sequence_utterance(&config, "hey tiny", "Hey Tiny")
- .await
- .expect("sequence"),
- super::UtteranceDisposition::BareWake
- );
- assert_eq!(
- super::gate_recording(
- &config,
- 0.1,
- 0.5,
- super::RecordingGates {
- min_duration_secs: 0.3,
- silence_threshold: 0.01
- }
- )
- .await
- .expect("gate"),
- super::GateVerdict::TooShort
- );
-
- // The mode split is the reason this call takes a mode at all.
- assert!(
- super::is_hallucinated(&config, "okay", HallucinationMode::Dictation)
- .await
- .expect("dictation")
- );
- assert!(
- !super::is_hallucinated(&config, "okay", HallucinationMode::Conversation)
- .await
- .expect("conversation")
- );
-
- // 400 interleaved stereo samples at 32 kHz -> 100 mono at 16 kHz.
- let stereo: Vec<f32> = (0..400).map(|i| ((i as f32) / 20.0).sin() * 0.5).collect();
- let wav = super::prepare_capture(&config, &stereo, 32_000, 2, 0.0)
- .await
- .expect("prepare_capture");
- assert_eq!(&wav[0..4], b"RIFF");
- assert_eq!(&wav[8..12], b"WAVE");
- assert_eq!(wav.len(), 44 + 100 * 2);
- assert_eq!(
- u32::from_le_bytes(wav[24..28].try_into().expect("4 bytes")),
- 16_000,
- "the header must declare the rate the samples were converted to"
- );
-
- // The capture-side pipeline the always-on loop now runs entirely remotely.
- let mono = super::prepare_frames(&config, &stereo, 32_000, 2)
- .await
- .expect("prepare_frames");
- assert_eq!(mono.len(), 100, "samples, not a container");
-
- // 100 samples with a 320-sample frame is ONE short frame, not zero: the
- // module slices with `chunks`, not `chunks_exact`, so the trailing partial
- // frame is measured rather than dropped. Dropping it would lose the end of
- // an utterance.
- let energies = super::frame_energies(&config, &mono, 320)
- .await
- .expect("frame_energies");
- assert_eq!(energies.len(), 1, "a short trailing frame still counts");
-
- // And a frame size that divides evenly gives the expected count.
- let energies = super::frame_energies(&config, &mono, 25)
- .await
- .expect("frame_energies");
- assert_eq!(energies.len(), 4);
-
- // PCM16 framing must return the caller's samples untouched.
- let pcm: Vec<i16> = vec![0, 1, -1, i16::MAX];
- let wav = super::encode_wav_pcm16(&config, &pcm, 16_000, 1)
- .await
- .expect("encode_wav_pcm16");
- let expected: Vec<u8> = pcm.iter().flat_map(|s| s.to_le_bytes()).collect();
- assert_eq!(&wav[44..], &expected[..]);
-
- // A VAD session must segment across separate pushes — the whole reason it
- // is a session and not a batch.
- let vad = super::VadConfig {
- onset_threshold: 0.1,
- hangover_ms: 100,
- min_speech_ms: 60,
- max_utterance_ms: 5_000,
- };
- let session = super::VadSession::open(&config, vad)
- .await
- .expect("VadOpen");
-
- let events = session
- .push(&config, 20, &[0.5f32; 6])
- .await
- .expect("VadPush");
- assert!(
- matches!(
- events.as_slice(),
- [super::IndexedVadEvent {
- event: super::VadEvent::SpeechStart,
- ..
- }]
- ),
- "expected a single speech start, got {events:?}"
- );
- assert!(session.is_speaking(&config).await.expect("is_speaking"));
-
- let events = session
- .push(&config, 20, &[0.0f32; 6])
- .await
- .expect("VadPush");
- match events.as_slice() {
- [super::IndexedVadEvent {
- event: super::VadEvent::SpeechEnd {
- voiced_ms, emit, ..
- },
- ..
- }] => {
- assert_eq!(*voiced_ms, 120, "voiced time carries across pushes");
- assert!(emit);
- }
- other => panic!("expected a single speech end, got {other:?}"),
- }
-
- session.reset(&config).await.expect("VadReset");
- session.close(&config).await.expect("VadClose");
-}
-
-#[test]
-fn an_out_of_range_volume_is_clamped_at_the_boundary() {
- // `percent` is interpolated into an `osascript` command downstream, and
- // this type is decoded from a wire payload. The module clamps too, so this
- // is belt-and-braces — but the braces are three lines and the failure mode
- // is a shell command carrying a number nobody checked.
- let decoded: VoiceIntent =
- serde_json::from_str(r#"{"intent":"set_volume","percent":255}"#).expect("decodes");
- assert_eq!(decoded, VoiceIntent::SetVolume { percent: 255 });
- assert_eq!(
- clamped(decoded.clone()),
- VoiceIntent::SetVolume { percent: 100 },
- "the clamp is what `route` applies before any caller sees the intent"
- );
-
- // In-range values are untouched, including the boundary itself.
- for percent in [0u8, 1, 50, 100] {
- let intent = VoiceIntent::SetVolume { percent };
- assert_eq!(clamped(intent.clone()), intent);
- }
-}
-
#[tokio::test]
async fn every_entry_point_degrades_rather_than_hanging_when_the_module_is_gone() {
// The fallback directions are asymmetric on purpose, and the asymmetry is