Skip to content

live demand gate: skip presence for ineligible sessions, cohort-label fallback, last-known on single miss - #22465

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/live-demand-gate-presence
Oct 19, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/live-demand-gate-presence

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

The "Live STT - demand gate unavailable" alert has fired chronically (~9.8k events/24h, ~27% of sessions). Root cause (aggregates only, 2026-10-19): 100% from_mode=demand_presence, i.e. the Redis presence EVAL timing out (100 ms socket / 150 ms wait_for) on a heartbeat that every session, including ineligible ones, sends every second (~35M/day). Consumer check contributed 0. 24h cohorts: admitted 0, eligible_control 1.7k, ineligible 33.8k, so no session was actually routed to vendor because of it (vendor cost impact today: none). Report: data/run-2026-10-13-two-lane-nemotron/live-gate-unavailable-0850Z.md in the workspace repo.

Changes

  1. Non-admitted sessions heartbeat every 10 s instead of 1 s (about -90% Redis EVALs). Deliberately not a full skip: an ineligible socket's unknown/visible entry in the shared per-user hash is what forces the vendor for a sibling admitted socket, so dropping it would change admitted routing. Entries stay inside the 30 s lease; close still writes.
  2. record_fallback(demand_cohort=...) feeds omi_listen_demand_failure_detail_total{reason="gate_unavailable"} (closed label set; shared omi_fallback_total schema unchanged, per docs). The alert now pages on the admitted-cohort ratio (>10%, >=50 admitted sessions, 15 m) and keeps a label-independent all-sessions guard (>60%, >=100 sessions). Builds on monitoring: page demand-gate-unavailable on ratio over live sessions #22459 (merged).
  3. Admitted sessions bridge exactly one failed heartbeat with the last good answer for under the 30 s lease. A second consecutive miss, an expired answer, closing, or the Parakeet admission check (can_admit_window) all stay strict: vendor is the default when the gate is unavailable. update_presence logs demand_presence_unavailable error_class=timeout|connection|response|redis_error|other (rate-limited, never the message).

Not fixed: whether Redis latency or event-loop starvation causes the timeouts (Redis metrics not visible to the read-only tier; per-pod failures correlate with pod CPU, r=0.79).

How it was verified

Command (layer: unit, nice -n 19, backend venv): pytest tests/unit/test_live_demand_presence.py test_live_demand_consumers.py test_live_demand_switch.py test_live_demand_telemetry.py test_live_stt_chain.py test_monitoring_alert_rule_contract.py test_monitoring_gmp_shadow.py -> 270 passed. Not verified live; deploy rides the next listen slot with the HPA-min PR. Verify after deploy by the running revision's release SHA, and omi_listen_demand_failure_detail_total{reason="gate_unavailable"} plus the demand_presence_unavailable log line.

Product invariants affected

none

Failure class (fixes)

No fix: commits were detected; no declaration is required.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

… fallback, last-known on single miss

- Non-admitted sessions refresh their sibling-visible presence entry every 10s
  (lease 30s) instead of every second. Entries are kept, not dropped: an
  ineligible socket's unknown/visible entry still forces the vendor for a
  sibling admitted socket of the same user.
- record_fallback takes demand_cohort; omi_listen_demand_failure_detail_total
  gains reason=gate_unavailable. The shared omi_fallback_total schema is
  unchanged. Gate-unavailable alert pages on the admitted cohort ratio plus a
  label-independent all-sessions guard (builds on #22459).
- Admitted sessions bridge exactly one missed heartbeat with the last good
  answer within the 30s lease; admission into Parakeet never uses it.
  update_presence logs a bounded error_class, never the message.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T09:32:11.377036Z 540a1ac PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit ffec86b into main Oct 19, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/live-demand-gate-presence branch October 19, 2026 09:45
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…d at decide (#22471)

Follow-up to #22465 review (SCA-829 lows):
- A timed-out non-admitted heartbeat no longer consumes its 10s slot, so
  consecutive timeouts cannot age a hidden sibling entry out of the 30s lease.
- run() folds _presence_unavailable into visible before decide(), so a second
  miss found by an observe() publish forces the vendor in the same iteration.

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant