Skip to content

fix(app): bound sync upload batches by audio seconds, not file count - #21319

Merged
kodjima33 merged 3 commits into
BasedHardware:mainfrom
aryanorastar:fix/app-sync-batch-by-audio-seconds
Oct 13, 2026
Merged

kodjima33 merged 3 commits into
BasedHardware:mainfrom
aryanorastar:fix/app-sync-batch-by-audio-seconds

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Addresses the batching/backlog part of #21177. Two CV1 pendant users on Android (Galaxy S25 Ultra, Android 16, app 1.0.558, firmware 3.0.21) report thousands of recordings of 10 seconds or less and a backlog of 1,200–2,500 that only clears overnight.

Pendant ring custody (#20462, first shipped in v1.0.554) drains buffered pendant audio into a new WAL every 10 seconds (LocalWalSync._drainPendantTail); before it, pendant audio went through the 60-second chunker. nextSyncUploadBatch still capped a sync job at five files — a limit sized for 60s chunks, where five files were 300s of audio. With 10s WALs every job carried 50s, so the same audio needed six times as many sync jobs against the same SyncRateLimiter.

Batches are now bounded by audio, up to 300s (the budget five 60s chunks carried, and the one the backend's 600s stale guard was sized against), and by a 20-file ceiling. The ceiling is the capture manifest's limit: a batch that claims live capture first sends every file to /v2/sync-capture-manifest, whose SyncCaptureManifestRequest.files accepts at most 20 (backend/routers/sync.py, published as maxItems in docs/api-reference/app-client-openapi.json). For 10s pendant WALs the ceiling binds first: 200s per job instead of 50s. The first WAL is always admitted, so a WAL longer than the budget still uploads, alone. Custody and the 10s drain are untouched.

The whole-conversation manifest rule is preserved: a conversation with more pending WALs than one batch holds never claims a manifest, so no claim covers a subset and no request exceeds the manifest limit.

Product invariants affected

  • INV-CAP-1 — no change to what is retained. This changes only how retained WALs are grouped for upload; every pending WAL still reaches a batch, and none is dropped or skipped.

How it was verified

  • 264 tests across the 11 sync test files (test/unit/sync_*_test.dart, local_wal_sync_test.dart, wal_upload_resilience_test.dart) pass, and pass again with --dart-define=CAPTURE_EVIDENCE_V1_DARK_WRITE=true.
  • Uploader level (sync_manifest_claim_drain_test.dart, driving LocalWalSyncImpl.syncAll with a recording uploader): 20 ten-second WALs in one live conversation upload as one batch that claims the manifest; 21 drain as 20 + 1 and 30 as 20 + 10, with no batch claiming. With the ceiling set back to 30, those two tests and the contract test fail ([21], [30], 30 > 20).
  • Batcher level (local_wal_sync_test.dart): the new tests fail against main's five-file batcher; existing expectations (25 × 60s → 5, 6 × 60s → 5) are unchanged.
  • dart format and flutter analyze clean.

Not verified, and not claimed

  • Not run on a device with a real pendant backlog.
  • No speaker-separation claim. Larger upload batches do not give the transcription model longer continuous audio — processing still runs per speech segment — and speaker quality was not measured. The speaker attribution in App creating thousands of short recordings #21177 is not addressed here.

Not in this PR

  • The Offline Sync list showing one row per 10s WAL is already handled on main by 659c131 ("show each Offline Sync recording as one row, not one per file"), which is not in the reporters' v1.0.558. This PR leaves custody storage alone.
  • Speaker-correction UI is out of scope. The reporter's "assign one speaker, then the screen refreshes" matches the per-label summary reprocess in v1.0.558, which main already batches into a labeling session (7d4da97, not yet in an Android build).
  • Backlogs already pending on devices drain in the larger jobs once a build with this reaches them.

Tests

  • sync_manifest_claim_drain_test.dart, 10s pendant WALs against the manifest file limit: 20, 21 and 30 WALs, asserting batch sizes and manifest claims through syncAll, plus a test that pins the client ceiling to the manifest maxItems in the published OpenAPI contract.
  • local_wal_sync_test.dart, upload batching: forty 10s WALs batch as 20 (200s); ten 45s WALs as 6 (the audio bound); a 400s WAL uploads alone.

UI evidence

UI-Evidence: none -- sync upload batching only; no screen, widget or copy changes

Failure class (fixes)

Failure-Class: none

No registered class describes a consumer limit sized for one producer's granularity that silently changes meaning when the producer's unit shrinks. This is an ordinary instance fix, guarded by the tests above, including the contract pin against the manifest limit.

🤖 Generated with Claude Code

aryanorastar and others added 2 commits October 12, 2026 20:47
Pendant ring custody (BasedHardware#20462, first shipped in v1.0.554) drains buffered
pendant audio into a new WAL every 10 seconds. The upload batcher still
capped a sync job at five files — a limit sized for 60s chunks, where five
files were 300s of audio. With 10s WALs a job became 50s: six times the sync
jobs for the same audio against the same rate limiter, and a separate ~50s
conversation per job with too little audio to separate speakers.

Reported in Discord and BasedHardware#21177: thousands of <=10s recordings on a CV1
pendant, a backlog of 1,200-2,500 that only clears overnight, and every
voice attributed to the wearer.

Bound each batch by audio instead: up to 300s (five 60s chunks, the budget
the backend's 600s stale guard was sized for), with a 30-file ceiling that
keeps per-file VAD fan-out at one job of 10s WALs. A WAL longer than the
budget still uploads, alone. Custody and the 10s drain are untouched.

Verification:
- flutter test test/unit/local_wal_sync_test.dart: 144 passed, with and
  without --dart-define=CAPTURE_EVIDENCE_V1_DARK_WRITE=true.
- The three new tests fail against main's batcher (5 files instead of 30 for
  40 x 10s WALs; 5 instead of 6 for 10 x 45s; a 400s WAL batched with another).
- Existing expectations (25 x 60s -> 5, 6 x 60s -> 5) are unchanged.
- dart format and flutter analyze clean on both files.
- Not exercised on a device with a pendant backlog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…imit

A batch that claims live capture first sends every file in it to
/v2/sync-capture-manifest, and SyncCaptureManifestRequest.files accepts at
most 20 (backend/routers/sync.py, published as maxItems in
docs/api-reference/app-client-openapi.json). The previous ceiling of 30 let a
recent single-conversation batch of 21-30 ten-second WALs pass the
whole-conversation claim check and then make a guaranteed-failing manifest
request before falling back to the paced backfill lane.

Cap batches at the manifest limit. A conversation with more pending WALs than
one batch holds now never claims, which is the existing whole-conversation
rule rather than a claim over a subset. The 300s audio budget is unchanged;
for 10s pendant WALs the file ceiling binds first, at 200s per job against
the 50s it was before this PR.

Verification:
- New uploader-level tests in sync_manifest_claim_drain_test.dart drive
  LocalWalSyncImpl.syncAll with a recording uploader: 20 WALs upload as one
  claiming batch; 21 drain as 20 + 1 and 30 as 20 + 10 with no claim; and the
  client ceiling must not exceed the manifest maxItems in the OpenAPI
  contract.
- With the ceiling set back to 30, the 21-file, 30-file and contract tests
  fail ([21], [30], 30 > 20).
- 264 tests across the 11 sync test files pass, with and without
  --dart-define=CAPTURE_EVIDENCE_V1_DARK_WRITE=true.
- dart format and flutter analyze clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Pushed e7ac4ad for the manifest mismatch the review reproduced — thanks for running the 21–30 file case; the batcher-level tests could not see it.

A batch that claims live capture sends every file to /v2/sync-capture-manifest, and SyncCaptureManifestRequest.files accepts at most 20 (backend/routers/sync.py, maxItems: 20 in the published OpenAPI contract). The ceiling is now 20, so a conversation with more pending WALs than one batch holds never claims, which keeps the whole-conversation rule instead of claiming a subset. The 300s audio budget is unchanged; for 10s pendant WALs the ceiling binds first, at 200s per job against the 50s on main.

Uploader-level tests in sync_manifest_claim_drain_test.dart now drive syncAll with 20, 21 and 30 ten-second WALs in one live conversation: 20 upload as one claiming batch, 21 drain as 20 + 1 and 30 as 20 + 10 with no claim. A fourth test pins the client ceiling to the manifest maxItems read from docs/api-reference/app-client-openapi.json, so the two cannot drift apart again. Set back to 30, the 21-file, 30-file and contract tests fail ([21], [30], 30 > 20). 264 tests across the 11 sync test files pass, with and without the dark-write define.

The body now says it addresses the batching/backlog part of #21177 rather than closing it, and it drops the speaker-separation claim: larger upload batches do not give the model longer continuous audio, and speaker quality was not measured.

@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed the batching change against the backend and API contracts — it holds up well.

  • app/lib/services/wals/sync_upload_batch.dart: _takeWithinBudget + _batchHasRoom replace the fixed five-file take() in all three batching paths (plain, dark-write non-claimable, dark-write claimable). The batchFiles == 0 short-circuit guarantees a WAL longer than the 300s budget still uploads alone, so no pending WAL can strand. I verified the constants against their sources: _syncUploadBatchAudioSeconds = 5 * chunkSizeInSeconds = 300s (wal.dart), and syncUploadBatchMaxFiles = 20 matches SyncCaptureManifestRequest.files.maxItems in docs/api-reference/app-client-openapi.json. The whole-conversation claim rule in canClaimLiveCapture (local_wal_sync.dart) is untouched, and the 20-file ceiling keeps any manifest-claiming batch inside the published server limit — the 21-WAL drain test confirms neither resulting batch claims a subset.
  • app/test/unit/local_wal_sync_test.dart: the three new tests pin the behavior at both extremes — 10s custody WALs batch to 20 files / 200s, 45s WALs stop at six files (270s, a seventh would pass 300s), and a 400s WAL uploads alone.
  • app/test/unit/sync_manifest_claim_drain_test.dart: the drain tests (20 → [20] with a claim; 21 → [20, 1]; 30 → [20, 10], no subset claims) cover the manifest-limit interaction end-to-end, and the OpenAPI cross-check test asserting syncUploadBatchMaxFiles <= maxItems keeps the ceiling from silently drifting from the published contract.
  • app/changelog/unreleased/20261012-sync-upload-batch-audio.json: "four times as much audio" checks out — 200s vs 50s per job for 10s pendant WALs.

One note for the merge decision: since this PR comes from a fork, the CI tier skipped the Dart suite on this head. I ran the sync/WAL unit tests locally — all 296 tests across the 18 sync/wal test files pass, including the new ones.

Nice fix — the audio-seconds budget keeps the 60s-chunk case exactly what it was (5 × 60s) while unthrottling the 10s pendant custody tail from #21177.

Automated maintainer review on behalf of the Omi maintainers. Formal approval and the merge decision are left to a human maintainer (cc @mdmohsin7, already requested).


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trusted contributor, confirmed bug (pendant 10s WALs shrank batches to 50s of audio vs the 300s budget) still present on main, scoped diff with 3 new regression tests, CLEAN/CI green.

@kodjima33
kodjima33 merged commit 68d1bf0 into BasedHardware:main Oct 13, 2026
43 checks passed
aryanorastar added a commit that referenced this pull request Oct 16, 2026
…ciliation (#21362)

## What changed and why

Daily Recap recovery was unreachable on mobile/web, and successful
recovery could still disappear behind an older read or remain hidden on
Home. Offline Sync also left restored uploads without a job handle
permanently processing and overstated what successful processing proved.
Complete the recovery path and reconcile these remaining sync/reporting
gaps. Fixes #11821; remaining customer-account outcomes are tracked by
#21360.

- Add historical-date recovery to mobile Notifications settings/Daily
Recaps and web Conversations using the existing idempotent `POST
/v1/users/daily-summaries` authority. No push token or enabled schedule
is needed; source recordings and existing recaps are preserved.
- Publish successful mobile recovery to mounted Home readers, including
a previously empty Home section. Fence older reads, preserve existing
cards on failures, and offer retry. A malformed list envelope is a read
failure, not an empty account.
- Give web recap snapshots owner-scoped cache keys and one read lease
for initial load/refresh/pagination. Re-read after a creation/deletion
commits before adopting an older result, retain chronological order and
server offsets, reject late data after account switches, and surface
recap read failures with a specific retry.
- Reconcile uploaded WALs with missing/blank job handles: requeue
retained audio through the existing deduplicated upload path without
consuming retries; preserve unavailable rows when local audio is
missing. Persist the outcome and fence asynchronous file checks on
account changes.
- Show **Processed** rather than inventing a created conversation for an
empty/silent completed job. The legacy status card and empty-pending
state no longer claim completion while another recording needs
attention. Local-copy cleanup copy states the deletion period without
promising a cloud audio copy. Retention behavior, storage settings,
capacity controls and batching are unchanged.

## Product invariants affected

INV-CAP-1 — retained recordings stay intact through orphan-job recovery.
Requeueing preserves audio and retry budget; missing-file outcomes
remain visible rather than being acknowledged as synced. No deletion or
retention policy changes.

## How it was verified

- `bash app/test.sh`: full hermetic suite passed, **5,368 passed / 21
skipped**. Analyzer ratchet passed; existing informational diagnostics
remain within baseline.
- Focused mobile recovery/API/Home/sync tests: **176 passed**. WAL suite
also passed with `CAPTURE_EVIDENCE_V1_DARK_WRITE=true`: **146 passed**.
- `make mobile-verify ARGS='fast --paths
app/lib/pages/home/widgets/home_daily_recaps.dart
app/lib/pages/conversations/sync_page.dart
app/lib/pages/conversations/auto_sync_page.dart
app/lib/services/wals/local_wal_sync.dart'`: **23 existing relevant
journeys passed**. These are the seeded journey lane, separate from the
new focused recovery tests.
- `bun run check`: typecheck, Moonshine smoke, and the full current web
suite passed: **127 files / 682 tests**. The final recap lifecycle file
passed all 8 tests.
- Actual WAL service lifecycle regression: restored orphaned upload →
retained file requeued → upload ACK with job ID → job polling →
confirmed processing/conversation result → durable index reload. Audio
bytes stay unchanged; uploader/status transport are test seams, not a
real-device/backend-capacity measurement.
- Local HTTP smoke from the first commit exercised the real FastAPI
creation/list routes and emulator storage: disabled schedule, no FCM
token, missing October 4 recap beyond automatic catch-up, stable ID on
retry, one generation, zero pushes, honest 400 for an empty date, and
unchanged source conversation/prior recap/schedule. Only the summary
provider and quota gate were fixture seams.
- The recovery widget was exercised through that local API in an iOS
simulator and browser preview. The final actual legacy/Auto Sync widgets
were rendered with synthetic inventories and the bundled font, asserted,
captured, and visually inspected. No physical customer-device or
customer-account recovery test is claimed. Impeccable's final
changed-target detector returned no findings.

## Tests

`daily_summary_creation_test.dart` and `apiDailyRecaps.test.ts`:
endpoint/date/response identity, malformed/legacy replies and status
failures. `daily_recap_recovery_action_test.dart` and
`GenerateRecapAction.test.tsx`: date selection, cancellation, single
flight and honest failures. `home_recap_recovery_test.dart`: successful
recovery from another screen reveals Home, older responses cannot hide
it, and failed reads retry.

`useRecapsCreation.test.ts`: ownership, creation vs initial read, reads
both before and during deletion, malformed-response retry, stable
identity, chronological pagination and raw server offsets.
`ConversationSplitView.test.tsx` verifies the user-facing read-error
retry. `local_wal_sync_test.dart` covers missing/empty/whitespace
handles, durable retry state, preserved bytes, unavailable audio, and
the whole retained-file upload/poll lifecycle.
`sync_completion_truth_test.dart` and
`sync_row_recovery_window_test.dart` execute the actual sync
screens/rows and prevent false completion, conversation and cloud-copy
claims.

## Release and customer verification

The October scheduler/gateway/retry fixes (#21020, #21304, #21310) are
already on current main. Production notifications deployments for #21304
and #21310 succeeded on October 12. They restore the known generation
failures and remain required context for this report.

This PR needs **merge, a mobile release containing these changes, and
web deployment**. It uses existing backend contracts; **no new backend
deployment is required by this PR**. macOS already uses the shared
creation endpoint.

The remaining customer-account checks are operational verification, not
an assertion that the client PR restored customer data: confirm
scheduled recaps resumed, generate/check each missing eligible date from
retained server conversations, and confirm every reported recording
reached processing completion on the customer's installed release. The
feedback lacks a platform/version/exact sync error; do not claim the
orphan-job fix is its proven cause.

#21347 remains open for malformed stored recap read validation; #21319
remains open for pendant upload batching, and #21216 tracks
capacity/backlog complaints. Their causes are not established for this
customer. Do not duplicate those fixes or claim those separate symptoms
solved by this PR. Keep #21360/Featurebase open until the account
outcome is verified.

Local preflight passed all 27 checks. Architecture and
implementation/release checklist: `app/docs/recap-recovery.md`.

## UI evidence

Synthetic inventories; screenshots contain no customer data.

![Recovery on
iOS](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/001-mobile-ios-recovery-dark.png)
![Legacy sync needs
attention](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/003-mobile-ios-sync-needs-attention.png)
![Confirmed
processing](https://raw.githubusercontent.com/BasedHardware/omi/04dda1ae63f6cca9181534b01de1bfac73300b47/.agent-artifacts/ui-evidence/daily-recap-recovery-completeness/004-mobile-ios-sync-processed.png)

## Failure class (fixes)

Failure-Class: FC-read-in-flight-across-delete-resurrects-row

The existing class covers stale list adoption across a committed
mutation. The shared recap read owner fences both deletion and recovery;
controllable-future tests cover reads admitted before and during
deletion. The orphan-upload and missing-control changes are separate
concrete gaps, guarded by their service/UI regression tests.

Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2690
-> 2728 | Keep orphan-job reconciliation, snapshot iteration, post-await
row revalidation, persistence and session fencing inside the existing
WAL lifecycle owner rather than splitting mutation authority.
aryanorastar added a commit that referenced this pull request Oct 16, 2026
…io (#21829)

## What changed and why

Bound a ring-buffer download that becomes silent after READ_BEGIN or
DATA. The
initial five-second timeout was cancelled on BEGIN, leaving only a
30-minute
overall deadline. A connected, stalled read therefore kept the transfer
owner
busy instead of yielding to normal capture/retry orchestration.

- Reset a 15-second idle deadline on the first valid BEGIN and nonempty
DATA,
matching the existing legacy SD idle bound. Repeated BEGIN, empty DATA
and
  control chatter are not progress.
- Observe arrival before queued custody/disk work. On timeout, stop
admitting
notifications, send STOP on the original connection epoch, drain already
received bytes and flush complete records through the existing durable
WAL
owner. Do not acknowledge an unfinished source or advance an unproven
frontier.
- Cancel idle timers on completion/error and put read-command failures
through
the same cleanup. A valid DONE arrival cancels the radio idle deadline
even
while its validation waits behind custody I/O. Healthy DONE and existing
  custody capability gates remain.
- Make the ring custody fixtures wait for read/status admission rather
than
  fixed startup sleeps, keeping the original durable-advance assertions.
- Preserve the saved cause, original stack and phase when a read-command
  failure goes through cleanup; keep catch-and-continue behavior.

Related: #21279 (uploaded jobs queued/429), #21387 (merged polling
backoff),
#21319 (merged short-WAL batching), #21755 (merged backfill
dispatcher-owner
repair), #21823 (merged batch-worker quarantine), and #21362
(retained-upload
recovery). These are separate stages.
This PR does not close the customer case or assert that the reported 1.4
KB/s,
capture interruption, cloud worker state or missing recaps share this
cause.
No firmware version or diagnostic export was supplied for the Discord
0/127
report, and no production repair, storage deletion or deployment is
performed.

Why isn't this a shared primitive instead? The existing ring reader
already
owns read admission, STOP, notification ordering, durable flush and
frontier
validation. Its watchdog belongs inside that owner, not in a parallel
recovery
actor. The injectable timer tests the real owner without waiting 15
seconds.

## Product invariants affected

- INV-CAP-1 — complete received records still use existing durable
file/index
  registration. Timeout leaves the source pending and sends no unproven
advance. Legacy firmware may reclaim on BLE delivery before app
durability;
this does not repair or conceal that existing risk or promise recovery
of
  incomplete records.

## Verification

- Production ring-owner regression: 14 tests passed, including idle
BEGIN,
partial audio, ignored chatter, cancelled deadlines, healthy DONE and
bytes
queued behind a deliberately blocked custody check, with and without
DONE.
- Capture interruption/reconnect journey (`mobile-verify fast --paths
app/lib/services/wals/ring_storage_sync.dart`): 3 checks passed, no
skips.
- Full app analyzer ratchet: passed. `make preflight`: 25 checks passed.
- Broader ring/custody/capture regression suites: all 129 passed on the
final
code, including the diagnostic guard and the 14 ring-owner tests above.
- Diagnostic guard: confirmed red without the transfer failure's saved
error,
then green with its original stack, cause and phase preserved.
Changed-file
  analyzer: no issues found.
- Physical BLE throughput, microphone behavior, customer-account
processing
and released-app retest: not performed; require hardware/account
evidence.

Architecture and implementation/release checklist:
`app/docs/offline-sync-stall-recovery.md`. The listen/pusher pipeline
map is
updated. This needs a mobile release after merge, not a backend
deployment.

## UI evidence

UI-Evidence: none -- transfer lifecycle only; no UI, copy or layout
changes

## Failure class

Failure-Class: FC-sync-failure-records-drop-cause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants