Repository navigation
fix(stt): drain the live tail at a bounded catch-up rate instead of carrying a permanent backlog - #23147
Conversation
…arrying a permanent backlog
Live audio that arrives while a successor dials and replays its prefix is
held in the 26 s live tail and was drained at exactly the endpoint rate:
`_next_audio_slot` discards every missed slot and the pump never ran ahead
of 1x, so after a near-full prefix a leg carried a 15-25 s backlog for the
rest of its life, every later pump slip added to it for good, and the next
client burst tripped the tail bound as `send_queue_full` while the vendor
socket was healthy (P47, follow-up B).
`ReplayTailSocket._pump_tail` now asks `ReplayPacer.send` for the catch-up
rate while the tail holds more than TAIL_CATCHUP_FLOOR_SECONDS (1 s) of
audio and returns to the sustained rate below it. The rate is
`LISTEN_LIVE_TAIL_CATCHUP_RATE` (default 1.5; `1` restores the exact-rate
tail) times the endpoint's declared sustained rate, capped per successor
family (Soniox/Modulate/Deepgram 2x, the Parakeet window 4x, unknown 1x).
Recovery legs' `RecoveryWriterPace` is installed at the same ceiling so the
transport can carry the drain; admission still sets the sustained wire rate
and the two-packet queue still bounds any burst. The prefix replay is never
accelerated. `omi_stt_live_tail_catchup_seconds_total{successor}` counts
audio delivered above the sustained rate and stays 0 with the switch off.
Virtual-clock simulations drive the real Modulate adapter: a 24 s backlog
after a full dial+prefix drains to the floor in ~47 s against real-time
input and a later 3 s burst is absorbed; a 5 s client burst on an initial
leg settles in ~8 s with the 2 s write confirm untouched; four 750 ms pump
stalls at the receiver's real 30 ms flush size are recovered. Each case is
paired with the switch off reproducing the permanent lag and the
`send_queue_full` death. The wire is checked byte for byte against the
capture and never exceeds the ceiling plus the queue allowance.
Failure-Class: new
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7911b58a75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| LIVE_TAIL_CATCHUP_RATE_ENV = 'LISTEN_LIVE_TAIL_CATCHUP_RATE' | ||
| DEFAULT_LIVE_TAIL_CATCHUP_RATE = 1.5 |
There was a problem hiding this comment.
Wire the catch-up kill switch into the runtime manifests
The new behavior is described as operator-disableable with LISTEN_LIVE_TAIL_CATCHUP_RATE=1, but this key is absent from both backend/deploy/runtime_env.yaml and the dev/prod backend-listen Helm values. In a production incident, the normal validated deployment path therefore cannot set the advertised kill switch and every new pod continues using the 1.5 default; add the setting to the authoritative runtime-env sources and generated Helm/runtime outputs.
AGENTS.md reference: backend/AGENTS.md:L153-L153
Useful? React with 👍 / 👎.
| # Ceiling on the live-tail catch-up multiple per successor family. Soniox asks | ||
| # for "real-time or near real-time" input and warns that prolonged bursts may | ||
| # disconnect; Modulate and Deepgram document no ingest ceiling; the window leg | ||
| # has no wire and a 60 s PCM cushion sized for a catch-up burst. | ||
| TAIL_CATCHUP_CEILINGS = {'soniox': 2.0, 'modulate': 2.0, 'deepgram': 2.0, 'parakeet': 4.0} |
There was a problem hiding this comment.
Document the new wire pacing in the owning pipeline contract
This changes live STT wire cadence and adds provider-specific catch-up ceilings, but the commit does not update backend/docs/listen_pusher_pipeline.mdx. That file is the repository-owned contract for listen audio, environment, and wire behavior, so leaving the new 1.5x default and family ceilings only in the operational windowed-STT document makes the canonical pipeline description stale.
AGENTS.md reference: backend/AGENTS.md:L159-L159
Useful? React with 👍 / 👎.
…the other bucket (#23248) ## Summary Soniox leg deaths with `reason=other` rose from 0.5 to 37.5/h after #23147's live-tail catch-up went live (train 72936c9, all 40 listen pods, 2026-10-22 03:26Z) and became the largest Soniox death family. Every event is the same shape: `omi_fallback_event component=stt_live_session from=soniox to=soniox reason=other outcome=degraded`, with no vendor error frame, no transport failure and no drain timeout behind it. Root cause: the candidate-dial handlers in `connect_configured_chain` and the Soniox idle-reopen latch normalized failures they could not classify with `default='other'`, latching the fallback metric's bucket token onto leg outcomes. A leg carrying that latch reported `reason=other` on every later failover hop. The emitting code is unchanged since before the catch-up train; the catch-up removed the `send_queue_full` deaths (~123/h) that used to end those sessions first, so the same sessions now walk deep enough to surface the untyped latch (~8x amplification of a pre-existing path). Fix — the untyped closes get typed reasons: - A `RejectedStream` is our own refusal of a dial: a reason the live vocabulary cannot name (a selection sentinel raised through a nested chain, any unclassified token) now types as `config_incomplete`, censored for provider evidence exactly like the `other` bucket it replaces (`dial_failure_reason` in `live_chain.py`). - The idle wrapper's unclassifiable reopen failures degrade to `connection_lost`, matching the documented rule for unknown provider shapes (`soniox_idle.py`). - `normalize_live_stt_reason` never returns the `other` token as a default; the bucket stays reserved for `record_fallback`'s own label bounding. - `failure_reason` no longer forwards a wrapper's untyped startup latch verbatim (defensive: an unlatched `ParakeetConnectionError` maps to `provider_5xx`). No new metric cardinality: `config_incomplete` and `connection_lost` are existing labels in both vocabularies. Provider benching semantics are unchanged — both replacement tokens are censored for provider evidence, like `other` was. ## User-visible impact None from these hops. All observed events were `outcome=degraded` inside a recovery walk that continued and adopted a successor; no `reason=other outcome=exhausted` events occurred after the rollout. The catch-up change itself worked as intended (`send_queue_full` 123 -> 0.9/h, `replay_ring_overflow` 35 -> 3.8/h, chain exhaustion ~96 -> 4.7/h). ## Failure class (fixes) Failure-Class: FC-typed-failure-collapsed-to-generic Product invariants affected: none ## Test plan - [x] `tests/unit/test_live_dial_failure_reason_typing.py` (new): dial-reason matrix (selection sentinels, unclassified tokens, provider classes), the `normalize_live_stt_reason` guard, and a chain-level test asserting a sentinel-fed dial failure emits typed hops with no `other` anywhere. - [x] `tests/unit/test_soniox_idle_close.py`: a failed reopen latches a typed death reason, never `other`. - [x] Regression sweep via `BACKEND_UNIT_TEST_FILE_LIST` + `test.sh` (nice -n 19): 127 tests across 23 affected files (live chain, selection skips, resilient stream, replay delivery, fallback observability, reason enums, recovery matrix, soniox idle/capture-axis, reconnect budget/continuity) — all green. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23248?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/23248?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23248&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…r budget (#23271) ## Why - **Local delivery deaths are no longer covered.** P34 (#23074, train P 2026-10-21 22:24Z) moved Soniox/Modulate local delivery deaths off `reason="capacity_full"`. `omi-stt-capacity-full-exhausted` therefore no longer sees sessions exhausted by our own send path. - **Vendor out-of-credits paged nothing purpose-built.** Modulate's 429 "Insufficient credits" (2026-10-22 from ~02:00Z) was only caught ~1h late, by the generic sync failure-rate rules. #23234 now types it `provider_budget_exhausted` on `omi_sync_transcription_job_total`. ## What | Rule | Severity / for | Condition | |---|---|---| | `omi-stt-local-delivery-exhausted` (Live STT) | warning / 30m | `omi_fallback_total{component="stt_live_session",reason=~"send_queue_full\|replay_send_stalled\|delivery_expired",outcome="exhausted"}` / listen-accepted > 0.03, with >= 100 accepted per 15m | | `omi-sync-provider-budget-exhausted` (Backend-sync, gmp-cloud-run) | critical / 5m | `sum by (namespace) increase(omi_sync_transcription_job_total{outcome="provider_budget_exhausted"}[15m]) >= 3` on backend-sync and backfill | - **Where the rules live:** in `alert-rules.json` and the split exports (`alerts/live-stt.json`, `alerts/backend-sync.json`). - **Supporting changes:** - the live-STT rule is added to the pusher live-alert import allowlist (`live-alert-gate.json`, `verify_pusher_live_alert_route.py`); - the GMP inventory is regenerated; - a contract test is added. ## Verification - **Backtest of the local-delivery rule** (prod Prometheus, 15m steps): | Window | p50 | max | Result | |---|---|---|---| | Post-P34, pre-#23147 (10-21 22:40Z to 10-22 03:10Z, replay-pacing bug live) | 0.039 | 0.060 | fires | | Post-#23147 (10-22 03:40Z to 08:00Z) | 0.000 | 0.012 | silent | Thresholds were set off-peak; I'll revisit after the 10-22 14–16Z peak read. - **Budget rule:** the outcome is new, so there is no history. It stays silent until #23234 is deployed to Cloud Run. - **Tests:** `BACKEND_UNIT_TEST_FILE_LIST` covering all 25 monitoring, alert and GMP unit files passes. Review: infra rollout lead before merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23271?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/23271?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23271&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…r budget P34 (BasedHardware#23074) moved Soniox/Modulate local delivery deaths off capacity_full, so omi-stt-capacity-full-exhausted no longer sees them. Add omi-stt-local-delivery-exhausted (warning, >3% of accepted sessions exhausted on send_queue_full|replay_send_stalled|delivery_expired, >=100 accepted/15m, for 30m). Backtest: fires through the pre-BasedHardware#23147 pacing bug (p50 0.039, max 0.060), silent after BasedHardware#23147 (max 0.012). Modulate's 429 "Insufficient credits" (10-22 from ~02:00Z) paged nothing purpose-built. BasedHardware#23234 types it provider_budget_exhausted on sync jobs; add omi-sync-provider-budget-exhausted (critical, >=3 jobs/15m on backend-sync or backfill via gmp-cloud-run, for 5m). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Peak re-check 2026-10-22 08-16Z (incl. 14-16Z peak, 386-1,021 accepted/15m) after #23108/#23147: ratio p50 0.000, p90 0.0033, max 0.0047. Broken state (pre-#23147) ran p50 0.039, max 0.060. 0.02 is 4x above today's max and half the broken median, so a pacing regression pages sooner. Co-authored-by: Claude Opus 5.5 <[email protected]>
…the other bucket The candidate-dial handlers in connect_configured_chain and the Soniox idle-reopen latch normalized failures they could not classify with default='other', latching the fallback metric's bucket token onto leg outcomes. A leg that later died carried reason=other into every failover hop. After BasedHardware#23147's live-tail catch-up removed the send-queue-full deaths that used to end those sessions first, the untyped latches became the largest Soniox death family (P59, 2026-10-22 train 72936c9: omi_fallback_event component=stt_live_session from=soniox to=soniox reason=other outcome=degraded rose 0.5 -> 37.5/h, with no vendor error frame or transport failure behind any of them). A RejectedStream is our own refusal of a dial, so a reason the live vocabulary cannot name now types as config_incomplete - censored for provider evidence exactly like the other bucket it replaces. The idle wrapper's unclassifiable reopen failures degrade to connection_lost, matching the documented rule for unknown provider shapes. normalize_live_stt_reason itself never returns the other token as a default, and failure_reason no longer forwards a wrapper's untyped startup latch verbatim. Delivery was not impaired: every observed hop was outcome=degraded inside a recovery walk that continued and adopted a successor. ## Failure class (fixes) Failure-Class: FC-typed-failure-collapsed-to-generic Product invariants affected: none
Summary
Live audio that arrives while a successor dials and replays its prefix is held in the 26 s live tail (
ReplayTailSocket). The tail pump drained it at exactly the endpoint rate:_next_audio_slotdiscards every missed slot andReplayPacer.sendnever armed a slot above 1.0×, so after a near-full prefix (the norm: mean prefix 14–18.5 s, 20–25 s bucket ~1,050/day on 2026-10-21) a leg carried a 15–25 s backlog for the rest of its life, every later pump slip (P32 loop-lag max 745 ms) added to it for good, and the next client burst tripped the tail bound assend_queue_fullwhile the vendor socket was healthy and the pod idle. Modulate dies last in 74 % of exhausted sessions because it is the most common recovery successor. This is follow-up B ofomi-workspace data/run-2026-10-13-two-lane-nemotron/local-delivery-deaths-2026-10-22.md§7; P47's #23108 (prefix margin) is the stopgap, this is the structural fix.ReplayTailSocket._pump_tailnow asksReplayPacer.sendfor the catch-up rate (catchup=True) while the tail holds more thanTAIL_CATCHUP_FLOOR_SECONDS(1 s) of audio and returns to the sustained rate below it. The rate isLISTEN_LIVE_TAIL_CATCHUP_RATE(default 1.5;1restores today's exact-rate tail; clamp [1, 4], unparsable or out-of-range → default) times the endpoint's declared sustainedReplayLimits.rate, capped per successor family: Soniox / Modulate / Deepgram 2.0, the Parakeet window (no wire) 4.0, unknown 1.0 (an unidentified endpoint never runs ahead). The replay prefix is never accelerated. Recovery legs'RecoveryWriterPaceis installed at the same ceiling so the transport can carry the drain; admission still sets the sustained wire rate and the two-packet queue still bounds any burst. The tail bound (26 s), residence (28 s) and thesend_queue_fulloverflow death are unchanged.omi_stt_live_tail_catchup_seconds_total{successor}counts audio seconds delivered above the sustained rate and stays 0 with the switch off (proof the flag is live).Branch
lane/tail-catchupintomain.Lane / contract
P47b
tail-catchup(two-lane rollout swarm). This PR is the producer of two draft rows inswarm/contracts.md: envLISTEN_LIVE_TAIL_CATCHUP_RATEand metricomi_stt_live_tail_catchup_seconds_total{successor}(successor ∈ parakeet/modulate/soniox/deepgram/unknown, zero-filled underrecovery_enabled()like the other replay series). No other shared names, labels or outcome tokens touched. Owner sign-offs: none needed —replay_delivery.py,config/live_stt_replay.py,live_metrics.py, their tests and the operational doc.Product invariants affected
none
Design choices (the brief asked for these in the PR)
send_queue_fullseries means (today: producer outran the drain for 26 s straight — a transport that genuinely cannot keep up — which is also a circuit-vote input, the same class as §7 A that needs a ruling). With catch-up the tail no longer drifts toward the bound under the measured conditions (24 s backlog + 3 s burst drains; four 750 ms slips are recovered), so the death path becomes the real signal it was meant to be. Residence expiry at 28 s still meters individual over-age packets as before. Drop-oldest stays available as a follow-up if the series does not fall after the roll.The 2 s write-confirm bound on initial paid legs (brief item 2)
Reviewed; no change proposed — there is no evidence it is where healthy legs die. In the 24 h window
omi_stt_replay_queue_high_waternever exceeded 4 packets (≤1: 11,822 of 11,923), and the §3 analysis puts the local deaths on the pacer's own arithmetic (exact-rate drain + discarded slots), not on a socket stall; the simulations here keepwrite_wait_seconds=2.0on the initial-leg case and a 5 s client burst settles in ~8 s without touching it. The one path where 2 s is plausibly tight is §7 C: a Soniox idle reopen writes the whole ≤10 s_pendingas one packet into a fresh TCP connection, where slow-start can take several RTTs (~35k reopens/day). That is a different fix (split the first write or warm the connection), not a wider confirm bound, which would only keep a stalled socket alive longer per packet and delay failover. A bounded increase would needdelivery_expiredcounts on initial legs attributable to a confirm stall with an empty queue (the P34queue_agelogs cover raw-socket deaths), and that evidence is not in hand.Verification
Layer: backend unit tests on the shared virtual clock, real
SafeModulateSocket/SafeSonioxSocketadapters over a fake transport, no live vendor. All run throughbin/omi-heavy run -- … backend/test.shwithBACKEND_UNIT_TEST_FILE_LIST,nice -n 19,BACKEND_PYTEST_WORKERS=4, on this branch rebased ontod90643dc2b:tests/unit/test_live_tail_catchup.py(43 tests). Each scenario drives the real Modulate adapter with a real-time client that captures on its own cadence, so a stalled pump finds every packet it missed; every captured packet carries a distinct marker and the wire is checked byte for byte against the capture (ordered, no gap, no duplicate), and no 2–4 s window of writes exceeds the ceiling plus the two-packet queue allowance:LISTEN_LIVE_TAIL_CATCHUP_RATE=1the same leg carries ≥23 s for 60 s and the 3 s burst diessend_queue_fullwith the vendor socket alive.3: eighteen 0.5 s packets go at 3×, the nineteenth sees exactly the floor and the rest go at 1×; the counter reads exactly 9 s.1, clamp,inf,nan, garbage).test_live_recovery_matrix.py(writer pause/resume now parametrised over the switch on/off: the queued packets may close up at the ceiling, cadence exactly 1× with it off) andtest_live_replay_provider_pairs.py(the slow-consumer full-ring case: prefix admissions still ≤1× + one packet, cumulative delivery never past the ceiling + one packet, and the last live packet lands inside ~15 s instead of the ~19 s lag the exact-rate tail kept). 103 passed across the three files.live_stt_replay,replay_delivery,resilient_stream,live_metricsor the listen receiver pass: 1,112 passed, 0 failed (including P34'stest_soniox_local_delivery_deaths.py,test_parakeet_window_live.py200,test_live_recovery_canary_regressions.py,test_live_recovery_pacing.py,test_replay_prefix_wall_margin.py,test_live_demand_switch.py).NOT run: the full backend suite (CI), staging, or any live listen pod.
Rollback
Set
LISTEN_LIVE_TAIL_CATCHUP_RATE=1on the listen deployment to restore the exact-rate tail without a code deploy (read per leg at pacer construction, so new legs pick it up), or revert this PR. Nothing persisted; one new counter, no label change on existing series.Judge it by (after the next listen roll)
omi_fallback_total{component="stt_live_session", reason="send_queue_full"}byfrom_modeshould fall toward zero (the P34 series §7 B names as the judge).omi_stt_live_tail_catchup_seconds_total{successor}rising proves the flag is live; it stays flat if the switch is1.omi_listen_demand_exhausted_sessions_totalwith Modulate dying last should drop.Failure class
Declaring
new: FC-drain-rate-equals-arrival-rate — a bounded buffer fed at a fixed rate and drained at exactly that rate, with every missed drain slot discarded, has no restoring force: its occupancy can only grow, so every scheduler slip and every arrival burst becomes permanent lag and a healthy consumer eventually hits the bound and is rejected as a local capacity failure. Root cause:ReplayPacer.sendarmed every slot atself.rateand_next_audio_slotrebases past a missed slot, so the live tail could never run ahead of the client. Durable guard: the drain has an explicit bounded catch-up rate that engages only while the held backlog exceeds an explicit floor (TAIL_CATCHUP_FLOOR_SECONDS), the bound itself is unchanged, and the virtual-clock simulation pins both directions (switch on: backlog returns to the floor with no death, no reordering, no duplication; switch off: the permanent lag and thesend_queue_fulldeath). Why not a shared primitive: the pacer and the tail are already the shared primitives (ReplayPacer,ReplayTailSocket); the missing piece was a second rate on the one pump that drains a held backlog, which now lives there.Failure-Class: new