Repository navigation
fix(sync): end the endless record_capture_pending retry for final records - #25770
Git-on-my-level wants to merge 3 commits into
Conversation
…ords
A registered record's WAL coverage proof (live_upload._covered) is a pure
function of the WAL bytes, the record's job list and their pinned
artifacts. Once the record is closed and sealed and has settled, every retry
gets the same negative, yet the answer stayed the retryable 503
record_capture_pending, so phones re-sent the same WAL every 30 s forever.
On 2026-11-19 that was ~10.2k 503s per 10 min on POST /v2/sync-local-files,
~94% audio_coverage_unproven, over ~2.35k recordings, all completed and
closed and 70% sealed and unchanged for 6 h or more.
When coverage is unproven (fresh or memo hit) and the record is final
(closed, sealed, not partial, no upload session or seal refusal, not deleted,
finished_at and record_sealed_at both >= 6 h old), answer HTTP 400
record_capture_unprovable (retryable: false). Every shipped app keeps the
WAL on a 400 (refused, no attention, re-offered at most daily for seven
days); none deletes or releases audio on it. Coverage-check errors and
records that can still change keep the 503.
The sync route's provenance projection now carries the record finality
markers so the router sees them on the same single document read.
Kill switch SYNC_RECORD_COVERAGE_TERMINAL (default true); false restores
the 503. Counter omi_pipeline_record_coverage_terminal_total{memo} and log
event=sync_record_upload outcome=terminal.
Failure-Class: new
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis 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. |
Panel review-20261119t090057-6d55 follow-ups: - Non-finite or unrepresentable stored clocks are never final (keep 503). - Pin the late memo-hit and memo=off coverage returns to the terminal 400. - Document that past/outside-record audio stays on the phone as a refused upload (recoverable only inside the seven-day re-offer window or by an app build), that terminal answers leave the wait counters, and the 1 + N 400s of an isolated batch. - Keep the flag budget alphabetical. Failure-Class: FC-final-record-coverage-negative-retried-forever Co-Authored-By: Claude Opus 5.5 <[email protected]>
Coordinator decision on #25770 (conservative split): answer the terminal keep-local 400 record_capture_unprovable only for audio_bytes_differ on a final record. That cause now means the record holds audio at every instant of the WAL; after the first mismatch the coverage walk continues on time alone, so a WAL that also reaches past or outside the record reports that cause. wal_audio_past_record, wal_audio_outside_record, record_unit_exhausted and unknown causes keep the retryable 503, because the server may not hold that audio; admitting it is a separate gap-fill or handoff follow-up. The coverage memo stores the static cause instead of 1 so memo hits answer the same way. A legacy 1 reads as unknown (503); the previous revision reads a cause as a miss. The terminal counter and log line carry cause=. Failure-Class: FC-final-record-coverage-negative-retried-forever Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
I’m leaving this PR for the sync custody owner. It replaces a retryable coverage response with a terminal keep-local refusal in the same registered-record admission path as #25444 and changes the response handled by #25868. It also continues fetching and decoding record units after a byte mismatch, even with terminal handling switched off. The 24-file change needs a custody and cost review before it can be treated as a small fix. No flag change is needed for this complaint pass. |
|
When this PR returns to the merge queue, please update its branch against current |
## What changed and why The backend can send a 1,800-second `record_capture_pending` wait after a cached negative audio-coverage check (#26333). The mobile upload gate capped all recording waits at 300 seconds, so affected recordings could retry early even after an app restart. Honor typed recording waits up to 30 minutes. Preserve the five-minute cap for header fallback and local backoff. Each wait remains scoped to the recording session. The existing receipt path still controls when a local recording can be released. Related: #21216, #25770, #26333. ## Product invariants affected - **INV-CAP-1** — the wait changes retry timing only. The affected file remains readable and pending throughout the deferral, with the existing server receipt still required for release. ## How it was verified - The restart regression failed before the patch. The queue issued another request at six minutes despite a 30-minute response. - 81 focused Flutter tests passed. The updated loopback HTTP test separately passed with the full 1,800-second response. - The backend coverage-wait suite passed 27 tests, including the 1,800-second response. - Analyzer ratchet and all 27 local preflight checks passed. - Independent review checked the bounds, persisted values, and unchanged custody logic. - Production coverage and historical recording recovery require separate verification. ## Tests - `recording_wait_deferrals_test.dart` checks typed and header limits, default waits, and short backoff. - `wal_upload_resilience_test.dart` checks a restarted queue, a sibling session uploading independently, retained audio, and exact expiry. - `wal_retry_manifest_transport_test.dart` verifies the typed 503 over loopback HTTP, no request during the restored wait, and a queued receipt after expiry. ## UI evidence UI-Evidence: none -- Upload retry timing only. ## Failure class Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26396?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/26396?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26396&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. -->
DESIGN
Reads: no new reads. The sync route's existing provenance read (one conversation document, field-masked) now also projects
record_audio_closed,record_audio_partial,record_sealed_at,record_seal_refused_atandrecord_upload_sessions. The read count stays the same. The payload grows by those fields:record_upload_sessionsis a map of up to 128 sessions, but it is normally empty on a closed record. Every other input (intakes/bp_<content>, jobs, artifacts, the coverage memo) is already read today.Writes: none new. The change adds no Firestore, GCS or Redis writes and no custody write.
RECORD_TOKEN_LEASE_MODE=off(prod), which the test asserts.rearm_partialwake still runs before the answer on a memo-first hit, unchanged. It writes only when the token lease is serving.Behavior (conservative split, coordinator decision): an unproven coverage answer (a fresh negative or a memo hit) returns HTTP 400
{"code":"record_capture_unprovable","retryable":false}instead of the retryable 503record_capture_pendingonly when both of these hold:audio_bytes_differ, meaning the record holds audio at every instant of the WAL and only the bytes disagree. After the first mismatch the coverage walk continues on time alone, so a WAL that also reaches outside or past the record reports that cause instead;wal_audio_past_record,wal_audio_outside_record,record_unit_exhaustedand unknown causes keep the 503, because the server may not hold that audio.record_upload_sessions, norecord_seal_refused_atand is not deleted, and bothfinished_atand the lastrecord_sealed_atare at least 6 h old.1, so a memo hit answers the same way. It is the same Redis key, TTL and write count. A legacy1reads as an unknown cause (503), and the previous revision reads a cause value as a miss. The mixed window is bounded by the 300 s TTL.Expected rates. The baseline was read with
ro-prodon 2026-11-19:POST /v2/sync-local-fileson backend-sync answered 503 = 10,239, 409 = 291 and 400 = 13.audio_coverage_unprovenis ~94% of the 503s. In the 10% sampled app log there were 941 such lines out of 1,005 record waits.audio_bytes_differ) ≈ 61% of the 503s if every such record were final. Only about 70% of looping records are final today, so the expected drop is about 0.61 × 0.70 ≈ 43%. That is about 4,400 fewer per 10 min, leaving about 5,800 of 10,239. Records that cross the 6 h line later keep adding to the drop. The new time-only walk can move some formeraudio_bytes_differWALs intowal_audio_past_record, which would make the drop slightly smaller.audio_bytes_differfrom past/outside.Production number that proves it: the unsampled backend-sync request-log count of 503 on
POST /v2/sync-local-filesper 10 min, which theomi_pipeline_upload_admission_503log metric also tracks. The target is ≤ 6,500 per 10 min within 2 h of serving (expected about 5,800), against 10,239 before.outcome=terminal cause=audio_bytes_differlines must be present. The sampledoutcome=pending reason=audio_coverage_unprovenlines should fall by roughly 45% whilewal_audio_past_recordandwal_audio_outside_recordcoverage lines stay at about their current level.event=sync_record_upload outcome=terminallines must be present. The 400 count must decay after the first day.SYNC_RECORD_COVERAGE_TERMINAL=false.Problem
The registered-record WAL fence (
backend/utils/batch_pipeline/live_upload.py) returned a retryable 503record_capture_pendingfor every WAL whose audio it could not prove byte-for-byte against the record. The phone keeps the audio and retries every 30 s. Nothing is lost, but the request storm never ends and the app shows uploads waiting forever.Measurement (ro-prod, counts and hashed record keys only)
audio_coverage_unproven6,040 (memo hit 3,373 / miss 2,667),coverage_check_failed188,record_jobs_missing143,owner_context_mismatch130,content_receipt_conflict8;record_router_missing(intake.py:702) 0audio_bytes_differ65%,wal_audio_past_record20%,wal_audio_outside_record15%intakes/bp_<key>)completed+record_audio_closed; 0 partial; 83% sealed; 146 discarded; 0 deletedRoot cause
_covered(live_upload.py,def _covered) compares decoded WAL PCM byte-for-byte with the record's pinned units. Its inputs are the WAL bytes, the job list fromintakes/bp_<content>.segment_ids(thereadtransaction inregistered_record_response) and the immutable artifacts._pending(AUDIO_COVERAGE_UNPROVEN), the retryable 503 at the threeAUDIO_COVERAGE_UNPROVENreturns.audio_bytes_differ: independently decoded Opus versus the record's PCM, which the 2026-11-15 handoff note already says cannot compare byte-for-byte.Why a keep-local 400 and not a release
I checked the shipped app at origin/main
app/liband its history from August through October:markUploadRejected. The WAL is kept.record_capture_pendingNo build deletes audio on a 400.
I rejected the other options from the brief:
audio_bytes_differcase it would mostly duplicate transcript the record already has.RECORD_GAP_FILLunset,RECORD_TOKEN_LEASE_MODE=off,RECORD_WAL_HANDOFF_ENABLED=false). Ramping them is a release decision. If they ramp later, any refused WAL whose proof arrives is still accepted on a daily re-offer within the 7 days.Follow-up (separate change): audio the record lacks
wal_audio_past_record(20%) andwal_audio_outside_record(15%) were about 35% of the sampled coverage negatives. That is roughly 2,100 of 6,040 sampled lines per hour, or about 3,400 of the 10,239 503s per 10 min.RECORD_GAP_FILL,RECORD_TOKEN_LEASE_MODEandRECORD_WAL_HANDOFF_ENABLEDare all off in prod today.RECORD_GAP_FILL_PERCENTramp row and its 2026-11-07 note: they still say_covered, which this PR renamed to_coverage_gap(panel review-20261119t104804-09ff F2).cause=onevent=sync_record_coverageplus the remainingreason=audio_coverage_unprovenwaits measure this backlog.Change
live_upload._coverage_gapreturns the static cause (_coveredis now a thin wrapper around it).coverage_final(row)and_coverage_unproven(..., cause=)give the terminal 400 only foraudio_bytes_differon final records, on all three coverage-negative returns: memo-first hit, late memo hit and fresh miss. The memo (database/sync_record_wait_cache.py) stores the cause. The 503 stays everywhere else.fsr_metadata.PROVENANCE_FIELDSprojects the record finality markers. Before this, the field-masked loaded row lacked them, so the router could not see finality.retain_uploadandrearm_partialcan now seerecord_audio_closedon this path. Both are no-ops in prod whileRECORD_TOKEN_LEASE_MODE=off.SYNC_RECORD_COVERAGE_TERMINAL(ops_kill, default true) is registered in the runtime env, charts, flag budget, flag registry and deployment classification.omi_pipeline_record_coverage_terminal_total{cause,memo}is declared in the metric inventory. Terminal answers are not counted inomi_pipeline_record_wait_answers_totaloromi_pipeline_record_wait_memo_hits_total, so read those together with the new counter. New log line:event=sync_record_upload outcome=terminal reason=audio_coverage_unproven cause=audio_bytes_differ record=<16 hex> path=coverage memo=….listen_pusher_pipeline.mdxis updated, with a change note atchanges/2026-11-19-record-coverage-terminal.md.Tests
backend/tests/unit/test_sync_record_coverage_terminal.py, synthetic data only:audio_bytes_differis terminal;wal_audio_past_record,wal_audio_outside_record,record_unit_exhaustedand unknown stay 503, on both memo hit and miss;1reads as unknown;memo=offreturns also answering 400;bin/omi-heavy, all passing: the 21 test files that reference the changed modules, plus the flag budget, runtime env validator, pusher config references andscripts/check_feature_flag_registry.py.--changedselector picked 2,092 files becauseutils/metrics.pyis imported everywhere. I stopped it after 249 passing files with no failure and left the full selection to CI.Product invariants affected
Failure-Class: new
🤖 Generated with Claude Code