# RB-04 MAJOR: run_live_session is a 200+ line multi-responsibility monolith **Severity:** MAJOR **Path:** `src-tauri/src/commands/live.rs:349-579` **Source:** [2026-04-22 code review](../code-review-2026-04-22.md) **Labels:** release-blocker, major, refactor, concurrency ## Problem `run_live_session` owns mic startup, runtime error draining, resampling, progressive WAV persistence, overload dropping, inference scheduling, and shutdown/finalisation in one 200-line function. The state machine is spread across mutable locals — hard to audit, hard to reason about under concurrency, and already contributing to lifecycle bugs nearby (RB-01, RB-05, RB-06). ## Acceptance - Split into focused types / functions: capture setup, streaming state, inference scheduler, WAV writer lifecycle, shutdown handler. - Each function ≤ 30 lines, single responsibility. - State machine explicit — not implicit in the interleaved mutable locals. - Lock discipline documented: what must be held when, across what `await` boundaries. - Existing behaviour preserved — 193 workspace lib tests still green; manual dogfood smoke test of a 30-second live dictation. ## Fix scope Large. Probably one dedicated session. ## Dependencies - **Unblocks:** RB-01 (live session race fix becomes tractable once the state machine is small). - **Related:** RB-05, RB-06 (both lifecycle bugs in the same function).