diff --git a/crates/rutster-media/src/reflex.rs b/crates/rutster-media/src/reflex.rs index 337e115..ae8d972 100644 --- a/crates/rutster-media/src/reflex.rs +++ b/crates/rutster-media/src/reflex.rs @@ -31,13 +31,6 @@ use std::time::Instant; use crate::pcm::{AudioPipe, AudioSink, AudioSource, PcmFrame}; use tokio::sync::mpsc; -// Task 2 will reintroduce these when `Reflex

` lands: `Reflex` holds the -// `mpsc::Receiver` drained on each 20 ms tick, and the -// `P: AudioPipe` generic bound names `AudioPipe`/`AudioSource`/`AudioSink` -// (plus `PcmFrame` for the source/sink methods it delegates to). They are -// intentionally absent here to keep Task 1 self-contained (no `tokio` dep -// added yet — Task 2 adds it together with the type that consumes it). - /// A turn-event advisory from the brain. The brain decodes its own /// speech-to-text / VAD results and forwards these; the FOB *owns* /// turn-taking and acts on them (slice-3 §4.3 — OpenAI Realtime @@ -254,6 +247,10 @@ mod tests { queued: std::collections::VecDeque, flush_calls: usize, barge_calls: usize, + /// Last inbound frame observed via `on_pcm_frame` — proves the + /// reflex delegates caller→brain audio to the inner pipe rather + /// than dropping it on the floor (Test 6's delegation check). + last_inbound_frame: Option, } impl MockPipe { @@ -262,6 +259,7 @@ mod tests { queued: Default::default(), flush_calls: 0, barge_calls: 0, + last_inbound_frame: None, } } fn push_frame(&mut self, frame: PcmFrame) { @@ -276,8 +274,8 @@ mod tests { } impl AudioSink for MockPipe { - fn on_pcm_frame(&mut self, _frame: PcmFrame) { - // capture count via separate test-side state if needed + fn on_pcm_frame(&mut self, frame: PcmFrame) { + self.last_inbound_frame = Some(frame); } } @@ -416,6 +414,11 @@ mod tests { reflex.next_pcm_frame(); // drain + apply barge // Inbound frame arrives — must pass through to inner. reflex.on_pcm_frame(PcmFrame::zeroed()); - // Inner captured it (no panic, no drop). + // The inbound frame is observable on the inner pipe — proof the + // reflex delegates to inner, never gates the caller→brain path. + assert!( + reflex.inner.last_inbound_frame.is_some(), + "inbound audio must reach inner even during barge" + ); } }