Repository navigation
fix(stt): close router-on saturation, paid cost and alert blockers - #20660
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
All reported issues were addressed across 28 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Address review round on router-on readiness: - Paid spillover admission now runs after the connect-backoff lease and the episode dial budget agree a real dial will happen, so backoff skips and expired episodes can no longer exhaust the per-minute cap without provider traffic. Denial still releases any half-open probe and restores the configured chain (PRRT_...OgR). - Terminal-after-text ratio and volume floor now share a cohort-aligned denominator: same-interval transcribed sessions (omi_live_session_transcript_outcome_total outcome=transcribed), emitted at the same session teardown as the failure counter, so long-running sessions cannot push the ratio over threshold from a healthy current cohort (PRRT_...OgU). - Rebuild-cap test guards the full registry + legacy allowance (MAX_REGISTRY_TARGETS + 4) instead of the registry alone (OgW). - A malformed STT_ROUTING_ON_PERCENT degrades the legacy rebuild cap to the router-off policy instead of aborting legacy failover (OgX). - The no-text lease failback grant is consumed by the first Parakeet-family reservation whatever endpoint identity dials, so a TargetEngineMismatch retry cannot obtain a second Parakeet dial (Oga). - Occurrence-gated alert annotations describe their real firing criteria (attempt + loss event) instead of a nonexistent volume floor (Ogd).
76030bf to
836e0a3
Compare
… test #20671 changed _pump_replacement to always adopt the ReplayTailSocket wrapper on replacement legs (including empty-prefix ones), per its receiver.py comment: exposing the raw paced writer stalls receive/disconnect observation behind a buffered client burst. This one test in test_soniox_typed_rejections.py was not updated to match and has asserted receiver.stt_socket is the raw replacement socket ever since, failing deterministically on every main CI run. Fix mirrors the already-updated sibling assertions in test_stt_session_failover.py: assert isinstance(..., ReplayTailSocket) and check .connection for the underlying raw socket instead of identity on stt_socket itself.
|
CI unblocked: cherry-picked the upstream test fix for #20691 (pre-existing main breakage, not a PR regression). Both failing checks (
|
## What changed and why Set `STT_FAILOVER_RECOVERY_ENABLED=true` for prod listen in the Helm values and runtime overlay, regenerate the runtime manifest and feature-flag registry, and align the listen pipeline/rollout docs. This enables the recovery stack from #20391/#20491/#20534/#20560/#20671 for new stable listen sessions after deployment. Dev listen remains `false` in its chart and runtime overlay. The shared base and code default stay `false`, so a missing environment variable means off. `SONIOX_IDLE_CLOSE_SECONDS`, router mode, provider order, and allocations are unchanged. ## Canary evidence — coordinator to complete **PLACEHOLDER:** attach the 25% prod listen canary versus control evidence after it holds through the next peak: exact image/config, observation window including peak, cohort and scrape coverage, session counts, recovery/continuity and terminal-after-text rates, latency and error comparison, and the coordinator's acceptance decision. Canary success is supplied context; this PR preparation does not independently qualify production health. Keep this PR draft until the coordinator fills this evidence and authorizes the stable flip. ## Deploy and rollback Deploy prod listen Helm through the normal `gcp_backend_listen_helm.yml` workflow (`environment=prod`, `mode=deploy`) after the coordinator merges the approved config flip. This draft does not merge or deploy anything. Rollback: revert this PR and deploy listen through the same normal workflow. For emergency rollback, use `gcp_backend_listen_helm.yml` with `environment=prod`, `mode=rollback` (select the pre-flip Helm revision if needed). ## Follow-up This flag also flips the canary-only terminal-after-text (TAT) metric, `omi_live_session_terminal_after_text_total`, fleet-wide. After stable rollout, relax the canary-scoped selectors from #20660 for the alert's volume floor, numerator, and denominator together. Alert rules are unchanged here; the coordinator owns this follow-up to #20660. ## Product invariants affected - INV-MEM-4: the generated runtime manifest is in scope; canonical memory intake, promotion authority, and processing-host bindings are unchanged. ## How it was verified - `PATH="$PWD/backend/.venv/bin:$PATH" bash backend/scripts/pre-deploy-check.sh`: passed runtime/workflow/state validation for dev and prod, plus 284 deploy contract tests. - `BACKEND_UNIT_TEST_FILE_LIST="$PWD/.local/stable-flip-test-files.txt" bash backend/test.sh`: 73 cases passed across `test_stt_failover_recovery_flag.py` (45) and `test_listen_stt_rollout.py` (28), including Helm canary rendering and flag-off behavior. - Offline `helm template` for prod and dev: exactly one recovery declaration per rendered listen container, prod `true` / dev `false`. Compared chart env and composed runtime state against `origin/main`: only prod listen's recovery value changed; other runtime settings and code defaults were preserved. - `OMI_PR_BODY_FILE=.local/pr-stable-flip-round2-body.md make preflight`: all 38 selected checks passed, including the committed-diff rerun. - `scripts/pr-preflight --lane local --metadata-only --pr-body-file .local/pr-stable-flip-body.md`: all 3 metadata checks passed. - Re-ran the committed-diff preflight with the required INV-MEM-4 citation for `backend/deploy/runtime_env.yaml`. Production acceptance remains the coordinator's canary evidence above. ## Tests Added `test_stable_recovery_flag_is_scoped_to_prod_listen` in `backend/tests/unit/test_listen_stt_rollout.py`: prod listen must declare `true` in Helm values and both committed/freshly composed runtime manifests; dev listen must declare `false`. Exhaustive runtime declaration paths require pusher, sync, desktop-backend, jobs, shared config, and every other service to leave the flag unset. `test_stable_recovery_code_default_remains_off` checks unset and explicit false against the production reader. Existing default-off and canary tests are unchanged. This pins the rollout boundary identified in Luna's review of #20696; the shared composition primitive already validates general config consistency, while this test preserves the intended service scope. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20696?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Keep the router off until saturation escape, paid spillover admission, bounded no-text rescue and continuity alerts are reviewable. Router-on selection now retains permitted configured endpoints when custom breaker state is saturated. Endpoint aliases use the family breaker, and router-on managed rebuild accounting admits the registry's 16 targets plus legacy endpoints.
Paid spillover admission is gated by
STT_PAID_SPILLOVER_BUDGET_ENABLED=false(default). Redis atomically admits at most 30 router-promoted paid dials per provider per Redis UTC minute, shared across pods, accounts and endpoint aliases; rotations do not reset the cap; provider limits are configurable (integer 0–10000). Malformed or out-of-range caps deny promotion before Redis access, log once per provider without the raw value, and restore configured order. Denial/Redis failure restores configured order. This is a router promotion budget: the static chain can still require paid traffic.No-text rescue is gated by
STT_NO_TEXT_RESCUE_ENABLED=false(default) and requiresSTT_FAILOVER_RECOVERY_ENABLED=true. One session gets at most 60 seconds each of paid wall-time admission and admitted audio (including replay), configurable between 5 and 120 seconds. Lease expiry tries Parakeet once using normal capture replay and owner fences. If cheap admission fails, the session terminates rather than silently extending paid processing. Empty audio remains ambiguous. Returned cheap decoding retains audio and suppresses further no-text rescues for that session; real transport faults retain normal recovery. The gated window progress deadline also rearms after text. Rescue evidence requires capture-mapped text overlapping the original stalled interval; later/unmapped text is unproven. Physical transport cleanup remains bounded by the existing abort path.#20391 already ships recovery-gated terminal-after-text telemetry. Recovery is enabled across production listen, so the dedicated rule now includes all backend-listen series, including stable and former-canary traffic, while retaining the 20-session accepted-session volume floor; the independent mid-session terminal rule covers every path. Chart sources and the canonical combined Grafana export alert on terminal-after-text and mid-session terminal failure, replay continuity, paid capacity, combined pressure, POST latency, lifecycle/persistence gaps, snapshot readiness, unknown selected targets and stage disagreement. The existing live-STT importer and coverage gate include the new rules (26 active UIDs); monitoring import must precede live coverage verification. No workflow changes.
Production is read-only. Aggregate 24h queries on 2026-10-04 returned approximately 811 first-text-deadline window outcomes, 5,152 text outcomes, and 634 deadline fallback events. They have different populations and cannot attribute paid billing. The new aggregate rescue audio/proof metrics support that join going forward. A synthetic one-hour all-paid Soniox remainder costs $0.0754 versus at most $0.001257 of leased Soniox audio plus subsequent cheap processing; provider billing increments remain outside that audio-price model; admitted replay is included in the lease budget.
Validation: 973 focused hermetic unit cases across thirteen files through
backend/test.shwith the unchanged 0.30s CPU guard; saturation tests cover all breaker entries protected, capacity signals on/off, alias/default tails, both recovery modes and hard withdrawals. Receiver tests exercise lease expiry, successor text/emptiness, replay audio budget and cheap re-entry. Local disposable Redis qualification passed: 200 concurrent attempts across four clients admitted exactly 30.make preflightpassed 33 checks; backend pyright reports zero errors. The unchanged 0.30s CPU guard was rerun in file isolation after machine-load failures. Round 2: 108 focused cases passed throughbackend/test.sh(44 router-readiness, 16 exported-query counter fixtures, 48 monitoring contracts). A negative-control replay of the prior exported queries reproduces the diluted non-firing alert while both fixed exports fire at 2%. Fixtures cover job/cohort isolation, the 20-session volume floor, the strict 1% threshold and no data. Cap cases cover all three providers, defaults, bounds, malformed values, denial before Redis, one warning without the raw value, corrected configuration and real configured-order fallback. CI status will be attached at handoff.Failure-Class: FC-live-stt-audio-lost-on-provider-death
Before any on-percent > 0: coordinator Luna review, terminal CI on this exact head, merge and deployment by the coordinator, uniform image/config and isolated namespaces, enabled limiter/rescue canary qualification, production-shaped paid headroom tests, rendered adapter/replay soak and tested live alert delivery/rollback. This PR does not authorize enablement, merge or deployment.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4074 -> 4077 | Flutter 3.44.5 formatter normalized inherited origin/main changes during merge; formatting only