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<PcmFrame> 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 <himself@adlee.work>
This commit is contained in:
@@ -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<P>` lands: `Reflex` holds the
|
||||
// `mpsc::Receiver<AdvisoryEvent>` 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<PcmFrame>,
|
||||
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<PcmFrame>,
|
||||
}
|
||||
|
||||
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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user