Repository navigation
Description
Problem
The sync v2 pipeline can compute failed transcription segments but still mark the overall job completed. Clients interpret completed as permission to mark local WAL/audio as synced:
backend/utils/sync/pipeline.py:1115-1160computesfailed_segmentsand unconditionally callsmark_job_completed.backend/tests/unit/test_sync_v2.py:1195-1202codifies: “Partial segment failure must still callmark_job_completed.”app/lib/services/wals/local_wal_sync.dart:1045-1058marks WALs synced when job status iscompleted.desktop/macos/.../WALCloudSyncLogic.swift:100-109follows the same completed-status contract.
During a provider outage such as #9548, this can turn failed or partially failed STT work into terminal client acknowledgement. The user-visible risk is not merely delayed transcription: original retry material can be treated as safely synced even when required transcription did not succeed.
Scope
Make sync terminal status truthful and retry-safe. Preserve existing idempotency and avoid a broad conversation-lifecycle refactor; coordinate with #9516 where its single mutation owner becomes relevant.
Proposed deliverables
1. Explicit terminal-state semantics
Define and document the sync job state machine:
completed: every required segment succeeded or was explicitly classified as valid no-speech.partial_failure: one or more required segments failed; retry/recovery data identifies the failures.failed: all required useful work failed or the job cannot progress without intervention.- optional
dead_lettered: retry budget exhausted, with user-visible/support recovery path.
A failure must never be marked completed merely to acknowledge queue work.
2. Client retry/WAL contract
Update mobile and macOS behavior so WAL/audio is marked terminally synced only after a truthful successful completion. Failed/partial work must remain retryable or retain only the failed segment material under an explicit, tested retention policy.
Specify behavior for retry exhaustion, duplicate delivery, app restart, and partial success. Do not silently discard data.
3. Completion and backlog observability
Emit low-cardinality sync outcome metrics and expose a dashboard/alerting contract:
omi_sync_transcription_job_total{
outcome, provider, model, lane, deployment_version
}
omi_sync_transcription_segments_total{
outcome, provider, lane, deployment_version
}
Track accepted jobs, completed jobs, partial/failed jobs, oldest nonterminal age, retry/exhaustion count, and queue depth/age through the appropriate Cloud Tasks/Cloud Run/Prometheus or deliberate log-metric path.
Alert on completion-ratio collapse, retry/exhaustion growth, and oldest nonterminal job age. An HTTP enqueue success is not a completion SLI.
4. Behavioral and fault tests
Add hermetic tests for:
- all STT segments timeout ->
failed; client WAL remains retryable; - mixed success/failure ->
partial_failure; only safe material can be acknowledged; - genuine no-speech segments do not count as provider failures;
- duplicate task delivery is idempotent;
- retry/exhaustion leaves an inspectable recoverable state;
- mobile and macOS client state transitions agree with the backend contract.
Acceptance criteria
-
completedis impossible when required transcription work failed. - All-failure and partial-failure paths preserve a deterministic retry/recovery path; neither allows silent WAL/audio loss.
- Mobile and macOS use the same documented terminal-state contract.
- Job/segment outcome telemetry contains no UID, conversation ID, audio, transcript, or high-cardinality labels.
- Operational signals expose accepted-to-completed ratio, failure classes, queue age, retry/exhaustion, and oldest nonterminal age.
- Alerting detects a broad downstream provider failure even if sync request enqueue HTTP responses remain successful.
- Tests prove all listed fault cases through production behavior seams, not static source assertions alone.
- Any relationship to conversation lifecycle ownership is coordinated with refactor(backend): converge conversation lifecycle onto a single mutation owner #9516 without creating a second conflicting lifecycle owner.
Related
- Fix HOSTED_PARAKEET_API_URL: https → http for Cloud Run services #9548 / fix(backend): use http:// for parakeet ILB URL in Cloud Run services #9549 — upstream outage demonstrating why transport success is not completed user value.
- refactor(backend): converge conversation lifecycle onto a single mutation owner #9516 — broader conversation lifecycle mutation-owner convergence; this issue owns the narrower sync job/WAL contract.
- Durable conversation finalization: Cloud Tasks job seam so listen conversations cannot stay stuck in_progress/processing #9453 — durable live finalization, related but not a substitute for sync completion correctness.
Safety / agent notes
- Do not place raw audio, transcript text, UIDs, conversation IDs, credentials, or private production evidence in fixtures, logs, metrics, or issue comments.
- Use fake providers, fake task queues, and synthetic metadata for tests.
- Production queue changes, Firestore changes, migrations, retention/deletion policy changes, and rollout require separate maintainer approval.
Activity
fix(backend): never treat a degraded Parakeet 200 as no-speech (#9586) (