fix(slice-1): F7 — remove unreachable needs_redrain arm in Step 2

Adversarial review F7 (Low, confirmed): the Step-2 Output::Timeout arm
checked `needs_redrain` but the flag could only be set inside Step 3
(which runs after Step 2 exits). The arm was unreachable dead code that
misled readers into thinking Step 2 re-drains inter-iteration.

The flag itself remains load-bearing for the bottom re-drain after
Step 3's Writer::write (str0m's mutation → drain-to-Timeout invariant).
Only the inner-loop check is removed; production behavior unchanged.

Refactor phase — existing tests stay green.
This commit is contained in:
opencode controller
2026-06-28 19:59:39 -04:00
parent b816a7aea6
commit 6f47e3ca1f

View File

@@ -101,22 +101,19 @@ pub fn drive(session: &mut RtcSession, now: Instant) -> Option<Duration> {
// initial value needed. Both exit arms assign before breaking, so the
// borrow checker is satisfied; clippy flagged the previous `= None`
// initializer as a write-then-overwrite.
let mut next_timeout: Option<Instant>;
// Track whether we owe a Writer write this cycle; re-drain if so.
// str0m's "mutate → drain to Timeout" invariant: after Writer::write,
// poll_output must be drained to Timeout before any other mutation.
//
// `needs_redrain` is set true only inside Step 3 below (after a
// Writer::write — a str0m mutation, which requires re-draining to
// Timeout). The previous loop also checked `needs_redrain` here
// inside the Step-2 Output::Timeout arm; that arm was unreachable
// (Step 3 hadn't run yet), so the check is gone but the flag itself
// stays load-bearing for the bottom re-drain (F7).
let mut needs_redrain = false;
let mut next_timeout: Option<Instant>;
loop {
match session.rtc.poll_output() {
Ok(Output::Timeout(t)) => {
next_timeout = Some(t);
if needs_redrain {
// We did an outbound write in the previous iteration;
// str0m needs to be drained again. Loop continues,
// but only handle Transmit/Event briefly before next Timeout.
needs_redrain = false;
continue;
}
break; // engine is fully drained
}
Ok(Output::Transmit(t)) => {