From 10c0547431865762ec0ce923a29aae3b027db3a8 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Thu, 2 Jul 2026 23:50:29 -0400 Subject: [PATCH] refactor(media): fix stale Task-1 forward-ref comment + strengthen Reflex test 6 Fix 1: removes a Task-1 forward-reference comment in reflex.rs that contradicted itself once Task 2 added the imports it claimed were "intentionally absent." Fix 2: MockPipe::on_pcm_frame was a no-op, so Test 6 could not distinguish "delegated to inner" from "dropped on the floor." Add last_inbound_frame: Option capture + assert delegation so the reflex's inbound-passthrough guarantee is verified, not assumed. Addresses the two Important findings from the Task 2 review. Signed-off-by: Aaron D. Lee --- crates/rutster-media/src/reflex.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) 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" + ); } }