Repository navigation
fix: make live capture uploads durable and self-healing - #19199
Merged
Git-on-my-level merged 12 commits intoSep 26, 2026
Merged
Git-on-my-level merged 12 commits into
Git-on-my-level merged 12 commits into
Conversation
Failure-Class: FC-accepted-session-completes-silently-without-payload
Git-on-my-level
force-pushed
the
fix/silent-upload-death
branch
from
September 26, 2026 15:41
c4a2afb to
013bd0a
Compare
Git-on-my-level
marked this pull request as ready for review
September 26, 2026 16:55
This was referenced Sep 28, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Sep 30, 2026
…#19921) ## What changed and why This raises the production `conversation-finalization` Cloud Tasks queue from 4 to 16 `max-concurrent-dispatches` in `deploy-backend-stack`, and updates `backend/docs/listen_finalization_jobs.mdx` to match. No test pins the value 4. Since #19199 (deployed on backend-sync revision `a90b225`, 2026-09-26 ~17Z), every listen finalization and every self-heal `SERVER_RECOVERY` job has gone through this queue to `POST /v1/conversation-finalization-jobs/run` on backend-sync. Before that the queue saw about 10 attempts per 3 hours. Since then it sees 5–10k per 3 hours. At 4 concurrent dispatches it is saturated. Measured in Cloud Monitoring (`cloudtasks.googleapis.com/queue/*`, queue `conversation-finalization`): | window | queue depth (6h max) | task_attempt_delays p50 | p99 | | --- | --- | --- | --- | | 09-24 to 09-26 14Z | 0–3 | 0 s | ≤16 s | | 09-26 20Z to 09-30 08Z | 248–728 | 211–380 s | ~521 s | The replay reconciler (`claim_finalization_replay`) re-mints a queued job's dispatch generation once it has been queued for more than `LISTEN_FINALIZATION_RECONCILE_STALE_SECONDS` (default 300 s). A median queue delay of ~370 s is longer than that window, so most jobs are re-enqueued before their first task runs. The original task is then acked as `stale_generation`. In 2026-09-29 12Z backend-sync logs there were 3,190 finalization requests: 1,690 stale-generation acks, 1,010 completions and 475 recovery terminals. About half the dispatch capacity was spent acknowledging duplicates, and every user conversation waited about 6 minutes before finalization started. 16 dispatches leave headroom for the current load of about 0.9 requests/s with a mean handler time of about 5 s. The handler is I/O-bound, and backend-sync keeps at least 5 instances at concurrency 20. ## Rollout The live queue was raised to 16 by an operator on 2026-09-30. Until this merges, every full prod deploy resets it to 4. The value is applied only by a full prod backend deploy (`deploy_targets == 'all'`). To take effect before that, an operator can run `gcloud tasks queues update conversation-finalization --location=us-central1 --project=based-hardware --max-concurrent-dispatches=16`. After the change, check that `task_attempt_delays` p50 falls below 300 s and that stale-generation acks stop. ## Product invariants affected none ## Failure class (fixes) Failure-Class: none ## Verification - Config-only change to the composite action's `gcloud tasks queues update/create` arguments. No expression contexts changed. - `scripts/pr-preflight` for this branch. 🤖 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/19921?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This was referenced Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: make live capture uploads durable and self-healing
What changed and why
Make pendant capture durable until transcript confirmation, recover WAL delivery in bounded background passes, and surface prolonged upload/transcript silence instead of treating socket reachability as delivery. Add server-side reconciliation and observability so abandoned
in_progressrows are finalized independently of a live listen session and empty/discarded rows stay out of default conversation lists.Product invariants affected
INV-TASK-2: the kept-conversation title fallback does not change task candidate or acceptance authority.INV-MEM-4: the finalization fallback and zombie reconciler reuse the existing conversation processing path and do not introduce a memory writer or promotion route.Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 3753 -> 3807 | capture session ownership must retain the transcript-confirmed WAL lifecycle, connected-socket byte watchdog, and reconnect repair handoff at the existing socket/event owner
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 1437 -> 1572 | the phone WAL owner must enforce bounded retention, ID-less live-drain eligibility, and terminal upload refusal state at the existing persistence and upload boundary
Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 2462 -> 2512 | server-recovery admission must read the active recording-session lease inside the existing atomic finalization-intent transaction
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3335 -> 3360 | the kept-versus-discarded verdict and deterministic title fallback must remain atomic at the existing final conversation assembly boundary
Capability changes
UIApplicationbackground-task lease; Android keeps its existing foreground-service lease.Review fixes
uploadRejectedalongside the pre-existing terminal statuses when a stale syncing flag remains set, while non-terminal statuses retain syncing precedence. The trust-boundary callee inventory now pins the reviewed read-only active-recording-session lease lookup; all conversation writes remain routed through_apply_snapshot_bound_projection.bytes_sent_no_transcripttelemetry, transfer retry, and persistent warning without waiting for close.SERVER_RECOVERYreads that identity-bound lease in its admission transaction and refuses an unexpiredin_progressowner.uploadRejected; 401 remains retryable and a reset after re-login makes it automatically eligible again. ManualsyncWal()honors an explicit retry for every terminal WAL state, while automatic connectivity wakes continue to leave permanent refusals parked and user-reviewable.OMI_AUDIO_TIMELINE_REJECTS_TOTAL, per-segmentrejectedincrements, and the deleted round-4 compatibility assertion. Existing series semantics are unchanged..invalidtask creation notify Dart. Dart clears its refcount, so the nextacquire()creates a fresh native lease; a standalone Swift state-machine test and Dart pairing tests cover both paths.Listen Socket Zero Transcriptevents coalesce for five minutes, use a 16-hex SHA-256 recording correlation, and keep at most 10,000 UID entries. The aggregate Prometheus outcome counter increments before coalescing and remains authoritative.How it was verified
backend/.venv/bin/python -m pytest backend/tests/unit/test_release_probe_discard_gate.py— 6 passed, exit 0.backend/.venv/bin/python -m pytest backend/tests/unit/test_conversations_status_filter_cap.py backend/tests/unit/test_live_session_transcript_outcome.py backend/tests/unit/test_selfheal_sweep.py backend/tests/unit/test_stale_processing_periodic_scheduling.py— 58 passed, exit 0./Users/dazheng/.local/share/mise/installs/flutter/3.44.5/bin/flutter test test/backend/http/conversations_default_filter_test.dart test/providers/sync_provider_sync_wal_wake_test.dart test/services/capture/capture_wedge_monitor_test.dart test/services/wals/recording_transfer_coordinator_test.dart test/services/wals/sync_transfer_keep_alive_test.dart— 78 passed, exit 0./Users/dazheng/.local/share/mise/installs/flutter/3.44.5/bin/flutter test test/services/capture/capture_coordinator_test.dart test/unit/local_wal_sync_test.dart test/unit/wal_recovery_test.dart test/widgets/capture_recovery_banner_test.dart— 139 passed, exit 0.xcrun swiftc -parse app/ios/Runner/AppDelegate.swift— exit 0./Users/dazheng/.local/share/mise/installs/flutter/3.44.5/bin/dart format --line-length 120 <touched Dart files>and/Users/dazheng/.local/bin/black --line-length 120 --skip-string-normalization <touched Python files>— clean, exit 0.scripts/pr-preflight --pr-body-file PR_BODY.md— 48 selected checks passed in 138.59s, exit 0.backend/.venv/bin/python -m pytest backend/tests/unit/test_selfheal_recovery.py backend/tests/unit/test_recording_sessions.py backend/tests/unit/test_live_session_transcript_outcome.py— 89 passed, exit 0.backend/.venv/bin/python -m pytest backend/tests/unit/test_audio_timeline_round4.py— 8 passed, exit 0./Users/dazheng/.local/share/mise/installs/flutter/3.44.5/bin/flutter test test/unit/local_wal_sync_test.dart test/unit/wal_upload_resilience_test.dart test/services/capture/capture_wedge_monitor_test.dart test/widgets/capture_recovery_banner_test.dart— 109 passed, exit 0./Users/dazheng/.local/share/mise/installs/flutter/3.44.5/bin/flutter test test/services/wals/sync_transfer_keep_alive_test.dart— 7 passed, exit 0.ruby ios/test/sync_transfer_background_lease_test.rb— 1 test, 2 assertions, exit 0.xcodebuild -list -project app/ios/Runner.xcodeproj— project parsed and both app targets include the lease source, exit 0.backend/.venv/bin/python -m pytest backend/tests/unit/test_stale_processing_emulator_concurrency.py— 8 skipped locally becauseFIRESTORE_EMULATOR_HOSTis absent; the live-lease and session-creation/recovery races are wired into the emulator gauntlet.cd app && mise exec -- flutter test test/unit/local_wal_sync_owner_uid_test.dart test/unit/local_wal_sync_test.dart— 41 passed, exit 0.cd backend && ./.venv/bin/python -m pytest tests/unit/test_recording_sessions.py tests/unit/test_listen_receiver_opus_frame_capacity.py tests/unit/test_listen_multichannel_mix_buffer_leak.py tests/unit/test_listen_reconnect_continuity.py tests/unit/test_listen_process_pending_shutdown.py tests/unit/test_conversation_finalization_jobs.py tests/unit/test_stale_processing_emulator_concurrency.py— 125 passed, 8 emulator-only skipped, exit 0.cd app && mise exec -- flutter test test/unit/wal_upload_resilience_test.dart test/unit/local_wal_sync_test.dart test/unit/wal_unsupported_audio_terminal_test.dart test/providers/sync_provider_terminal_wal_state_test.dart— 67 passed, exit 0.The requested
~/workspace/omi/backend/.venv/bin/pythoninterpreter is not present on this host, so backend tests used the equivalent worktree-localbackend/.venv/bin/python. No live service was called, and no device/native runtime acceptance was attempted.Tests
Failure class (fixes)
Failure-Class: FC-accepted-session-completes-silently-without-payload
Line-Count-Exception: backend/routers/listen/receiver.py | 1617 -> 1627 | per-UID zero-transcript telemetry coalescing and throttled live-session lease renewal must live with the accepted-socket outcome owner