Skip to content

[P0] Sync transcription: never mark failed audio completed or discard retry material #9586

Closed

Description

@Git-on-my-level

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-1160 computes failed_segments and unconditionally calls mark_job_completed.
  • backend/tests/unit/test_sync_v2.py:1195-1202 codifies: “Partial segment failure must still call mark_job_completed.”
  • app/lib/services/wals/local_wal_sync.dart:1045-1058 marks WALs synced when job status is completed.
  • desktop/macos/.../WALCloudSyncLogic.swift:100-109 follows 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

  • completed is 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


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

  1. added
    backend
    p0
    maintainer
    on Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendmaintainerp0reliabilitysync

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions