Skip to content

fix(sync): recover stuck offline recordings and enumerate current-firmware devices - #10397

Merged
mdmohsin7 merged 8 commits into
mainfrom
fix/offline-sync-reliability
Jul 23, 2026
Merged

mdmohsin7 merged 8 commits into
mainfrom
fix/offline-sync-reliability

Conversation

@mdmohsin7

@mdmohsin7 mdmohsin7 commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Closes #10033. Closes #10197.

Offline recordings upload and then sit at "Uploaded · processing on Omi" for
12+ hours without becoming conversations, some never sync at all, and stuck
recordings never retry. Three independent causes, each fixed here.

1. Stuck sync jobs never self-healed (backend)

A job whose worker died stayed in processing until the 24h reconcile TTL, so
the client polled a job that would never finish.

get_sync_job used to finalize any processing job quiet past
STALE_THRESHOLD_SECONDS (600s) to failed, on every read and for every
dispatch mode. That finalizer was later moved to the status-poll endpoint and
gated on dispatch_mode == 'cloud_tasks', which left inline/BYOK jobs with no
self-heal at all and made every other job depend on a client actively polling.

Restored the original behaviour. The pipeline heartbeats updated_at at every
stage and per segment, so 600s of silence only ever means the worker is gone.
queued jobs stay exempt — no worker has claimed them, and failing them caused
the spurious "retrying" loops in #7469.

This fixes the reported symptom end to end: the client already reverts a WAL
from uploaded to miss and re-uploads when the server reports failed, so a
dead job now recovers in ~10 minutes instead of 24 hours.

2. Ring-buffer devices were never enumerated in auto-sync (app)

Background and auto-sync discovery read firmwareRevision off the raw connect
object, which is frequently still 'Unknown'. isRingBufferFirmware('Unknown')
is false, so devices on firmware 3.0.20 and up — the current firmware — were
routed to the multi-file enumerator, which returns nothing for them. Their
offline recordings were never enumerated, never uploaded, and never became
conversations, unless the user happened to open the Auto Sync page, the one
caller that already passed the enriched firmware.

setDevice now carries the firmware resolved by getDeviceInfo, and both
discovery paths prefer it, falling back to the raw value so behaviour is never
worse than before.

3. Offline backlogs drained a few files at a time (app)

The backfill lane uploaded three files per batch, so recovering a backlog
crawled. Both lanes now share one batch limit of twenty.

The two lanes are kept. They earn their keep in SyncUploadGate, which holds a
separate rate-limit domain per lane so a backfill cooldown cannot stall a
freshly captured recording. They were not buying throughput control: ordering is
newest-first regardless of lane, and the backend caps multipart part size
(200 MB), not file count — the fresh lane has been sending twenty per batch all
along.

Tests

  • test_sync_job_stale_self_heal.py — stale processing self-heals for inline
    and cloud_tasks, a fresh job is untouched, and a stale queued job is never
    finalized.
  • wal_syncs_firmware_routing_test.dart — the enriched firmware wins over a raw
    'Unknown', falls back when absent, and a 3.0.20 device now classifies as
    ring.
  • local_wal_sync_test.dart — a small backlog drains in one batch; larger ones
    are bounded by the shared limit, newest first.
  • Existing sync-job tests updated to the restored self-heal contract.

cd backend && pytest on the sync suites — 193 passed.
cd app && bash test.sh — 933 passed. bash scripts/analyze_ratchet.sh — passed.

Failure-Class: none

Review in cubic

Restore the dispatch-agnostic stale-job finalizer: a job stuck in 'processing'
past STALE_THRESHOLD_SECONDS is failed on read (get_sync_job), so the client
reverts the WAL to 'miss' and re-uploads within ~10 minutes instead of sitting
at 'Uploaded · processing on Omi' until the 24h TTL.

The finalizer had been narrowed to a client-poll, cloud_tasks-only path, which
left inline/BYOK jobs — and any job whose client stopped polling — stranded for
24h. The pipeline heartbeats updated_at at every stage and per segment, so 600s
of silence only ever means the worker is gone. 'queued' jobs stay exempt: no
worker has claimed them, and failing them caused spurious retry loops (#7469).
Background and auto-sync discovery read firmwareRevision off the raw connect
object, which is frequently still 'Unknown'. isRingBufferFirmware('Unknown') is
false, so ring-buffer devices — firmware 3.0.20 and up, the current firmware —
were routed to the multi-file enumerator, which returns nothing for them. Their
offline recordings were never enumerated, never uploaded, and never became
conversations unless the user happened to open the Auto Sync page, the one
caller that already passed the enriched value.

setDevice now carries the firmware resolved by getDeviceInfo, and both
discovery paths prefer it, falling back to the raw value so behavior is never
worse than before.
The backfill lane uploaded three files per batch, so recovering a backlog of
offline recordings crawled. The two lanes exist to keep rate-limit domains
apart — a backfill cooldown must not stall a freshly captured recording — not
to throttle throughput, so both lanes now share one batch limit. The backend
caps multipart part size (200 MB), not file count, and the fresh lane has been
sending twenty files per batch already.
@mdmohsin7
mdmohsin7 merged commit 5ef0dd5 into main Jul 23, 2026
34 of 40 checks passed
@mdmohsin7
mdmohsin7 deleted the fix/offline-sync-reliability branch July 23, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant