Repository navigation
fix(listen): refill speaker embedding budget and skip unavailable pooled PCM - #21047
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
# Conflicts: # backend/docs/listen_pusher_pipeline.mdx
|
Coordinating the #21051 review fixes: I have added actual matcher regressions for a noisy one-second accumulation, a failed two-second reconnect shortcut at nearest-print distance >=0.75, then clean fresh speech reaching the ordinary five-second floor. Both must stay retryable until normal recognition. The current #21047 confident-rejection early stop would violate that contract for shortened evidence; I am waiting for its removal and will merge main again without force-pushing, then run the combined budget/reconnect tests. Other fixes keep retained rollover peers competition-only and fence donor receipt revisions and cancelled cache publications. |
|
The #21051 review fixes are now published at dc8c3c4, with 117 targeted regressions passing and zero type errors. This includes the one-second pending / failed two-second shortcut / ordinary five-second recovery contract. I verified current #21047 head ac13f6d has terminal green CI. Per the coordinator instruction I am waiting for #21047 to land, then will merge origin/main again (no history rewriting), run the combined budget/pool/carry/reconnect suite, and push the final integrated #21051 head. |
…1051) Reconnects reset diarizer ids and evidence, leaving short owner replies unknown. Preserve same-account/device owner continuity acoustically while keeping enrollment thresholds, margins, joint arbitration and paid non-owner naming unchanged. Use one accepted owner centroid, enrolled-profile digest and donor receipt provenance in the existing private authenticated per-user encrypted cache: 120-second TTL, 16 KiB cap, atomic consumption and device/writer revision fencing. A reconnect needs two fresh seconds and the stricter 0.35 session-distance gate as well as the enrolled profile. Shortened accepts cannot seed another handoff; absent, expired, corrupt, different-device or changed-profile evidence retains ordinary five-second recognition. Preserve #21047's refilling budget/retry behavior and #21052's pending near-miss band. Retain rollover peers only as competition until they provide five fresh seconds. An accepted short owner's proof survives capsule expiry while its original donor and receiving authority remain valid. Read receiving, original acoustic donor and immediate rollover donor authority in one projected Firestore transaction, bounded to three documents; fence the matcher generation and rebuild/arbitrate/publish without another await. One shared publication gate applies already-known receiving rejections/retractions, then denies every publication or renewal if final authority is unavailable. Earlier positive receipts cannot create or refresh manual, automatic, carried or shortened owner labels. The acquisition, retained-evidence reevaluation, mapped-voice renewal and rollover paths all use this gate; idle refresh also stops when reevaluation cannot publish. No cache refresh follows a failed final read. Existing labels without a known rejection remain unchanged on read failure; observed corrections retract them. Failed carry releases the old per-conversation attempts without replenishing the socket budget. Merged origin/main at `b2f6d2fe26b6` with an ordinary merge, preserving upstream owner-retry changes and pipeline documentation. Translation, dream inventory and Swift CI repairs are already upstream; this PR contains no app/desktop repair diff. The success-path failover fixture now dispatches the real final-authority transaction against its strict store; the rollover test rebuilds continuity when rebinding its host so the account id agrees with the store. Both retain all their original assertions. Spent-attempt telemetry: a spent query vetoed by unavailable final authority emits exactly one bounded `authority_unavailable` live match exit; zero-seeded labels and the closed reason inventory include it. No acoustic rejection is synthesized and the negative-only publication gate is unchanged. The reviewer reproduction is extended across two/five seconds and known/absent receiving rejection, asserting one exit, no live decision, no identity/cache publication, retraction of a known stale manual mapping, and unchanged short-probe reconnect accounting. All four new cases failed before the telemetry fix and now pass. The six targeted suites pass 332 tests, including the full 72-case authority matrix, rejection/renewal protections, reconnect/rollover suites, bounded exit inventory and current-main owner retry telemetry. No identity, arbitration, cache, threshold or budget behavior is changed by this accounting fix. Validation (all local test commands use `env -u GOOGLE_APPLICATION_CREDENTIALS -u GOOGLE_CLOUD_PROJECT CLOUDSDK_CONFIG=$(mktemp -d)`): - The 72-case matrix crosses earlier positive/negative/absent receipts, manual/automatic/carried publication, two/five seconds, healthy/failed snapshots and a real receiving correction committed during the transactional read. It failed 32 cases before the gate and now passes all 72. Actual assignment/rejection operations and strict transaction reads exercise the behavior, not mocked decisions. - Mapped two/five-second owners and idle refresh additionally check that failed authority cannot change an uncorrected mapping, renew the speech gap or write a capsule. Existing known-rejection regressions continue to require manual/automatic retraction. - Current telemetry-focused validation: all 332 tests across six suites pass through backend/test.sh, including the full authority matrix, exit inventory, reconnect/rollover and current-main owner retry telemetry. Typecheck has zero errors; all 34 make preflight checks pass. Exact head `19571162160c186dc7f4ba66a7595c059ecad061`: [Backend Unit Tests](https://github.com/BasedHardware/omi/actions/runs/38012356343). Measurement: supplied rollover counts imply 48.4% `none` among automatic owner outcomes, not proven identity loss. Archived-scope drops are the leading code-based hypothesis; bounded rollover reasons expose the gate taxonomy. `omi_owner_reconnect_total{outcome,reason}` separates lookup/acoustic attempts, accepts and rejections. Gap choice, denominators and carry reasons are documented in `backend/docs/owner-continuity.md`. Risks and reviewer focus: inspect the single negative-only publication gate and every caller, especially a stale positive manual receipt followed by a failed transaction and a receiving correction. Review encrypted consume/revision ordering, the three-document read bound, and competition-only carry across plan changes. Two seconds/0.35 lack production false-accept calibration. Strict synthetic tests prove binding and control flow, not live Firestore contention/retries or real-audio calibration. No Google credentials, production data or production API calls; no deployment or product-acceptance claim. Leave unmerged for owner review. Failure-Class: FC-independent-owner-voice-accepts ## Product invariants affected none Line-Count-Exception: backend/routers/listen/speakers.py | 1147 -> 1425 | Keep rollover accounting and joint arbitration integrated while isolating encrypted handoff/cache I/O and centralizing negative-only final authority across acquisition, rollover and revalidation.
Follow-up to #20964 (merged a02bee4; deployed to production listen 2026-10-08 21:08Z). Long-lived pendant sockets exhaust the lifetime embedding caps, and one unavailable pooled PCM interval aborts otherwise usable speech.
Before measurements supplied with the incident (not independently queried):
embedding_budget: 106k exits in 11.9h (8.9k/h), over twice all live decisions (~47k).no_pcm: 1.4/h → 1,280/h.Replace lifetime socket exhaustion with a monotonic-wall-time token bucket: initial/capacity 16, refill 240/3600 attempts per second (one per 15 seconds). Attempts over t socket-hours are bounded by floor(16 + 240*t): ≤256 in the first hour and ≤240/hour asymptotically, at ≤10s query PCM per attempt (≤2,560s first-hour and ≤2,400s/hour steady-state query audio). An arbitrary one-hour window can use up to 256 including saved burst credit. Idle credit caps at 16; failures spend tokens; reservation precedes awaits. Conversation/profile churn and client audio timestamps cannot mint tokens. Reconnection still creates a new socket budget, as before; this is not an account-wide cap.
Keep 12 attempts per voice per conversation. Reset uncarried IDs on rollover; carried manual mappings and validated automatic owner carry retain their attempts. Profile refresh within the same conversation preserves attempts. Accepted voices stop spending. All rejected voices, including far/noisy rejections, retain fresh-audio recovery opportunities within the 12-attempt allowance and socket bucket. Later clean clips can evict noisy evidence and re-arbitrate owner claims, withdrawing a competing automatic owner mapping. Failed one-second reconnect evidence is also allowed to accumulate normal full-length owner evidence. Retained evidence can still be re-arbitrated or rechecked against a recovered owner without more model calls.
Skip unavailable PCM intervals; emit
no_pcmonly for an entirely unusable pool and recheck actual remaining PCM duration. Metric names, labels and exit reasons stay unchanged; the proposeddecided_voicereason and early stop were removed after the independent review. Mergedorigin/mainincluding #21052 (5b42496d5c) without rebasing or rewriting the published branch. Its calibrated[0.65, 0.70)owner near misses remainunknown/pending. Acceptance thresholds, margins, carry eligibility and paid non-owner naming/free owner recognition are unchanged.Failure-Class: none
The existing classes do not cover permanent exhaustion of a socket-scoped live embedding budget or aborting a pooled extraction on one unavailable interval. The fix is implemented in the matcher admission primitive with behavioral regression tests, rather than adding a separate guard.
Product invariants affected
none (as reported by
scripts/pr-preflight --lane local --suggest).Validation
backend/test.sh, including fix(speakers): keep calibrated live owner near misses pending #21052's pending-band tests. The revised budget suite passed all 24 cases with the unchanged default 0.30s CPU guard.backend/test.sh. All 1,491 cases passed their assertions. The parallel run loaded the pre-optimization churn test and flagged its CPU time; it also flagged unchanged mixed-cache and speaker-learning cases at 0.34–0.60s. The final budget file passed the default 0.30s guard; the two unchanged timing-offender files passed serially with the documented CI 1.0s ceiling (50 cases). No timing policy or allowlist is changed in this PR.OMI_PR_BODY_FILE=/tmp/owner-budget-pr.md make preflight: 31 checks passed. PR-body metadata validation and required pre-push contracts also run before publication. The failure-class history ratchet skips on the shallow local clone.SpeakerMatcher.matchand WAV encoding: original far/noisy recovery, near-threshold recovery, competing automatic owner withdrawal, and replay of the failed one-second reconnect state described by fix(listen): preserve acoustic owner continuity across reconnects #21051. fix(listen): preserve acoustic owner continuity across reconnects #21051 is not merged into this branch; the replay is not a composed reconnect implementation test.api.omi.mecalls.Reviewer risks