Repository navigation
fix(pusher): classify durable projection failures and retry transient ones - #23690
Conversation
… ones
~988/h omi_audio_custody_failures_total{stage="projection"} since the #23641
fleet roll (2026-10-26 00:20Z): the durable flush_refs catch-all records one
unlabeled failure per dropped batch with no retry and no error class, so the
counter cannot be broken down by class or route from metrics, and every
transient GCS/Firestore hiccup drops the projection outright (the legacy
non-durable path retries three times; the durable path shipped with zero).
- omi_audio_custody_failures_total gains a bounded reason label
(other|conflict|transient) with pre-created zero baselines and closed-set
coercion (bounded_custody_failure_reason, registered in the reason-label
enum contract), so the next RCA can split classes from Prometheus alone.
- flush_refs splits its catch-all: deterministic ValueError (millisecond-keyed
chunk-name content collision, custody read-back verify mismatch) records
reason="conflict" and drops once — retrying replays the same collision; any
other exception requeues the receipts for a bounded PROJECTION_RETRY_BUDGET
(2) drain-loop passes while the session is live (teardown keeps today's
drop semantics; the loop's existing age/duration scans re-flush), and only
exhaustion records reason="transient".
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: 0c25fd5a63
ℹ️ 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".
| pending_refs[conv_id] = refs | ||
| queued_at[conv_id] = time.monotonic() | ||
| logger.warning('Durable audio projection failure; receipts requeued for retry') | ||
| return |
There was a problem hiding this comment.
Keep the recording close pending while projection retries remain
When a recording-close request arrives while the socket is still active, a transient projection failure now puts its receipts back into pending_refs and returns without marking the recording failed. The close-request loop immediately below nevertheless calls seal_record_audio and removes the request without checking pending_refs. This publishes record_audio_closed=True before the upload barrier has completed; if the retries subsequently exhaust, the failed recording remains sealed. That flag gates admission in backend/utils/batch_pipeline/live.py::admit_recording. Retain the close request and skip sealing until that conversation has no pending projection.
Useful? React with 👍 / 👎.
| if len(identity_refreshed) < 128: | ||
| identity_refreshed.add(conv_id) | ||
| projection_retries.pop(conv_id, None) | ||
| except ValueError: |
There was a problem hiding this comment.
Distinguish actual conflicts from wrapped storage failures
For timeline-v2 uploads, upload_audio_chunks_batch wraps exceptions from blob.exists() and existing-blob downloads in ValueError (backend/utils/other/storage.py, the existence-check and unreadable-collision branches). A temporary GCS timeout therefore reaches this handler, gets labeled as a deterministic conflict, and permanently drops the projection without using the new retry budget. Restrict the non-retryable branch to confirmed content or receipt mismatches, or preserve a distinct exception type for transient storage-probe failures.
Useful? React with 👍 / 👎.
| # batch drops to raw-live receipt recovery (matching the legacy batch path's | ||
| # three attempts). Deterministic ValueError conflicts never retry. | ||
| PROJECTION_RETRY_BUDGET = 2 |
There was a problem hiding this comment.
Update the required listen/pusher pipeline documentation
This changes the durable pusher projection lifecycle from immediate failure to bounded requeue, but the commit does not update backend/docs/listen_pusher_pipeline.mdx. The backend guide explicitly requires that document to be updated in the same PR for audio or listen/pusher WebSocket changes; the runbook edit does not satisfy that requirement. Document the retry budget, conflict classification, and teardown behavior in the owning pipeline guide.
AGENTS.md reference: backend/AGENTS.md:L161-L161
Useful? React with 👍 / 👎.
|
|
||
|
|
||
| def test_custody_failure_reason_label_is_a_bounded_vocabulary(): | ||
| from prometheus_client import REGISTRY |
There was a problem hiding this comment.
Move the new Prometheus import to module scope
The new metric-vocabulary test imports REGISTRY inside its function, contrary to the backend guide's explicit requirement that all imports be at module top level, never inside functions. Move this import alongside the test module's existing third-party imports.
AGENTS.md reference: backend/AGENTS.md:L165-L165
Useful? React with 👍 / 👎.
| and len(projection_retries) < 128 | ||
| ): | ||
| projection_retries[conv_id] = projection_retries.get(conv_id, 0) + 1 | ||
| pending_refs[conv_id] = refs |
There was a problem hiding this comment.
Preserve discontinuity boundaries when requeuing a failed batch
When a timeline-v2 receipt is noncontiguous with the pending batch, the drain loop calls flush_refs to separate the runs before unconditionally appending the new receipt. If that flush fails transiently, this assignment restores the old batch into the same pending_refs entry, so the append now combines both sides of the discontinuity. upload_audio_chunks_batch assumes its input is contiguous and constructs one span using the first start and summed sample counts (backend/utils/other/storage.py:944–949), causing gaps to disappear or overlaps to be duplicated in the projected timeline. Keep failed batches separate from the next run rather than restoring them into the accumulator that the caller will append to.
Useful? React with 👍 / 👎.
…set on drop Luna round 1 (FIX-FIRST) on PR #23690: - P1: the uploader wraps a failed blob.exists() probe as plain ValueError; classifying all ValueError as conflict would drop those batches without the retry they deserve. upload_audio_chunks_batch now raises a dedicated AudioChunkContentConflict(ValueError) only for the deterministic content-divergence case, and flush_refs treats only that class as terminal (plain-ValueError probe/read wrappers and custody read-back mismatches retry like any transient failure). - P2: the per-conversation retry budget was cleared only on success, so one exhausted batch left stale entries that denied retries to later independent batches of the same conversation and accumulated toward the 128-entry cap. The budget is now cleared on terminal drop as well. Both regressions are covered: a plain-ValueError probe failure retries and lands with no recorded failure; after a dropped batch, a later batch of the same conversation gets its full fresh budget. The fail-once-then-succeed tests now hold the socket open deterministically (teardown flushes correctly never requeue; ungated tests race the disconnect and flake).
|
Review round 2 (Luna delta): SHIP with two P2s — acknowledged and deferred with rationale: (1) a deterministic read-back mismatch (checksum/manifest ValueError from read_pcm) now retries twice before recording transient: bounded extra cost, safe drop semantics unchanged; a follow-up can introduce a dedicated CustodyReadbackMismatch class mirroring AudioChunkContentConflict. (2) the conflict arm does not pop the retry-map entry; a requeued-then-conflicted batch leaves a stale count (cleared on the next success or terminal drop for that conversation). One-line follow-up. Both tracked on the two-lane initiative plan (pprojfail-mskey-collision-owner-decision step); neither blocks the reviewed head 52eb029. |
…3945) ## What The 10-28/29 RCA of the fleet-wide `routers.pusher` WARNING "Durable audio projection failure; receipts requeued for retry" (report: `data/run-2026-10-13-two-lane-nemotron/pusherdur-rca-2026-10-29.md`) could not name the exception class from production logs: `flush_refs`' catch-all logs no exception detail, and the `reason` label collapses every non-conflict failure into `transient`. Why it matters: since pusher rev 208 (2026-10-26 23:04Z, first roll of #23690) the requeue:terminal log ratio is exactly 2.00 in every hour (the `PROJECTION_RETRY_BUDGET`), i.e. zero requeued batches are ever rescued — the dominant failure class is deterministic (read-back family per the #23690 review's deferred-P2), but the actual exception can no longer be identified without redeploying instrumentation. ## Changes - `backend/routers/pusher.py`: `except Exception` → `except Exception as exc`; one new WARNING per failed projection attempt — `Durable audio projection failure class: <type name>` — emitted on both the requeue and terminal arms. The exception's *message* is deliberately never logged (it can embed user-identifying object paths). - `backend/tests/unit/test_audio_durable_outbox.py`: `test_transient_projection_failure_drops_after_the_retry_budget` now also asserts the class line fires exactly once per failed attempt and carries only the type name. No behavior, metric, label-vocabulary, or existing log-line changes. ## Verification - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_audio_durable_outbox.py`: 63 passed. - `python3 backend/scripts/verify_pusher_rollout_gate.py`: OK. Failure-Class: none Reason: pure observability logging; no failure-handling or classification path changes (the dominant prod failure class is unchanged by this PR — it only becomes nameable). Line-Count-Exception: backend/routers/pusher.py | 1551 -> 1556 | +5 lines: one per-attempt exception-class WARNING (type name only) plus its safety comment — the fleet RCA gap this closes; no split is warranted for a single log line. Follow-up tracked on the two-lane initiative (anx event eebc3f01): classify the deterministic read-back mismatch as terminal-on-first-attempt (own reason, like the conflict arm) once this logging confirms the class split in prod. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23945?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/23945?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23945&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. -->
Summary
Pusher has logged ~988/h
omi_audio_custody_failures_total{stage="projection"}sincethe durable relay-custody path rolled out fleet-wide with #23641 (2026-10-26 00:20Z).
Custody itself is intact (commit failures 3-7/h, no audio loss): these are failures of
the OPTIONAL timeline projection (
flush_refsinbackend/routers/pusher.py), whosesingle
except Exceptionrecords one unlabeled counter per dropped batch — no retry,no error class, no route — so the counter cannot be broken down from metrics, and every
transient GCS/Firestore hiccup drops the projection outright (the legacy non-durable
path retries three times; the durable path shipped with zero in #23641).
Changes:
omi_audio_custody_failures_totalgains a boundedreasonlabel(
other|conflict|transient) with pre-created zero baselines and closed-set coercion(
bounded_custody_failure_reason, registered as a CLOSED_HELPERS helper in thereason-label enum contract). Existing single-argument call sites keep
other.flush_refssplits its catch-all. A deterministic upload conflict — differentbytes already live at the run's content-addressed name, now raised as the dedicated
AudioChunkContentConflict(ValueError)— recordsreason="conflict"and drops thebatch once; a retry re-runs the same collision. Any other exception (including the
uploader's plain-
ValueErrorprobe/read wrappers and custody read-back mismatches)requeues the receipts for a bounded
PROJECTION_RETRY_BUDGET(2) of drain-looppasses while the session is live — the loop's existing age
(60s)/duration/next-ref scans re-flush without a new scheduler — and only
exhaustion records
reason="transient"(drop semantics at teardown unchanged:there is no later pass to wait for). The requeue restores
queued_at; the retrybudget is cleared on both success and terminal drop so a later independent batch
of the same conversation starts fresh; the map stays bounded (128) like the
session's other sets.
Review round 1 (Luna, FIX-FIRST) resolved:
blob.exists()probe errors are wrapped as plainValueErrorby theuploader and were about to be classified conflict/no-retry. Fixed by classifying
ONLY
AudioChunkContentConflictas terminal; plain ValueError now retries(regression test included).
later independent batches and leaked entries toward the 128 cap. Now cleared on
terminal drop as well (regression test included).
No flag flips, no
.github/changes, no IAM, no data mutation. Alert expressionsalready
sum()over label sets, so the new label changes no rule.Testing
backend/test.shwithBACKEND_UNIT_TEST_FILE_LISTcoveringtests/unit/test_audio_durable_outbox.py(63 passed, 3 consecutive runs) andtests/unit/test_reason_label_enums.py(19 passed),BACKEND_PYTEST_WORKERS=4.applied); conflict never re-uploads a span and withholds the record close; budget
exhaustion drops exactly once after exactly
1 + PROJECTION_RETRY_BUDGETattempts;a plain-ValueError probe failure retries (P1); a later batch gets a fresh budget
after a terminal drop (P2); the reason label vocabulary is bounded and coerces
unknown values to
other. Retry tests hold the socket open deterministically —teardown flushes correctly never requeue, so ungated tests race the disconnect.
Product invariants affected
none
Line-Count-Exception: backend/routers/pusher.py | 1507 -> 1551 | durable flush_refs splits its catch-all into conflict/transient classes with a bounded requeue; the retry budget and both failure arms are one cohesion unit inside the session drain loop
Line-Count-Exception: backend/utils/other/storage.py | 2672 -> 2683 | one dedicated AudioChunkContentConflict exception class so the durable projection can distinguish the single deterministic conflict from retryable plain-ValueError probe/read wrappers
Failure class (fixes)
Failure-Class: none
Optional-projection reliability/observability hardening; no classified failure-class
definition matches (no custody/projection class exists yet) and no guard was bypassed.