Repository navigation
SCA-2324: feat(app): trace how long a sealed recording file waits before upload is accepted - #25332
Merged
Merged
Conversation
…rver accepts it X-Omi-Upload-Trace on the sync upload carries the oldest file's seal time, first attempt, attempt count and the last upload gate that closed after it was sealed. Measurement only: no gate reads it and no upload behaviour changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review finding on #25332: the single-file path prepared a trace but never cleared it on success, so a later retry of an accepted file would carry the previous cycle's first-attempt time and count. Now matches the batch path. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Nov 15, 2026
…t reads (#25331) Offline Sync keeps valid audio ahead of unknown/future capture clocks, with one isolated clock-recovery batch after at most 36 valid batch attempts. The shared budget is now saved on waiting WALs in the owner-fenced index before valid uploads, so repeated iOS process restarts cannot erase the turn. A recovery batch resets the shared budget after entering the gate, allowing valid work to resume. No request mixes valid and unknown-clock files. Only `invalidCaptureTime` (`invalid_capture_time`) retries daily during the first week, then weekly indefinitely until accepted. Other refusal reasons retain their existing expiry. The 25-refusal-per-drain cap and single-file isolation remain. A server rollout may start disabled and enable recovery later: an already expired refusal becomes eligible on its next weekly due date without user action or a new app install. Weekly probes cost at most five full-file requests per affected file per rolling 30 days after the first week (roughly 4–5 times its bytes plus request overhead), and stop on acceptance. This is a schedule bound, not a measured currency cost. The install migration is removed. It is unnecessary with non-expiring paced recovery and introduced an eager startup index save that blocked `walReady` in the gated-save test and consumed the first injected save failure. The existing flush still awaits the durable audio/index before publishing live custody proof or issuing pendant ADVANCE. Strengthened regressions assert no persisted row, proof, or ADVANCE while the actual audio index write is blocked or fails, followed by proof only after a successful save. Neither stored refusal clock is reset, so there is no migration/receipt crash boundary. Deterministic refusals remain aggregated without user attention or an immediate same-pass retry; the only deliberate policy difference is the slow, persisted invalid-date schedule. Rows retain the existing “Invalid recording date” label until accepted, then follow the existing uploaded/processing states. A settled pendant read failure gives the phone backlog its upload turn. Cancellation during a queued phone flush remains cancelled before the gate, including the new budget checkpoint. Pass serialization, the upload mutex, owner fencing, durability and acknowledgment rules remain in place. LittleFS first parsed DATA and subsequent audio idle both have conservative 60-second deadlines. Firmware 3.0.17–3.0.19 permits 500ms queueing plus 15s for an SD read, then unbounded BLE-buffer retries without a progress heartbeat. The tests cover first DATA arriving after 20 seconds, a healthy 45-second inter-DATA gap, and ACK-only traffic still failing at 60 seconds. Incomplete transfers retain the original device record, save parsed audio durably, never skip the unread head, and report failure after cleanup. Evidence: `app/docs/offline-storage-liveness.md`. The app does not rename existing files because the companion server fix accepts both `..._<timestamp>_uN.bin` and `..._uN_<timestamp>.bin` forms. New collision names keep the timestamp last. Rollback defines, all compile-time and default false: `OMI_WAL_CLOCK_PRIORITY_OFF`, `OMI_PHONE_AFTER_DEVICE_FAILURE_OFF`, `OMI_STORAGE_AUDIO_LIVENESS_OFF`, `OMI_DEVICE_COLLISION_TIMESTAMP_LAST_OFF`, and `OMI_INVALID_CAPTURE_TIME_RECOVERY_OFF`. The last restores seven-day expiry without changing stored state. The storage define restores the original five-second any-packet first-data detection and disables audio idle; it does not restore silent incomplete-transfer success, remove cleanup, or weaken custody/delete proof. These are not remote-config switches. Release notes for the lead: the normal store route is Codemagic with validated release tags, exact-source Release Eligibility and Mobile Release Eligibility receipts, then store approval and the documented phased/staged train. App/lib PRs need the ordinary source/review/CI gates, invariant/failure-class metadata, changelog fragment and UI evidence declaration; this service-only change declares no UI evidence. Codemagic contains Shorebird iOS/Android patch workflows and `app/shorebird.yaml`, so these Dart-only changes are patch candidates only for an installed binary already built with a compatible Shorebird release. Current store lanes use ordinary `flutter build`; updater compatibility of the owner's 1.0.592+1560 is unverified. Server-side recovery/parser work can ship separately, but cannot change this client's scheduling/timers or filename generation. Product invariant: INV-CAP-1. Failure-Class: FC-batch-fault-domain-head-of-line-poison UI-Evidence: none -- Changes are confined to WAL scheduling, transfer liveness and persistence; no widgets, layouts or user-facing strings were changed. Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2754 -> 2789 | Preserve the existing ledger authority and cancellation fences, checkpoint the bounded clock-class turn, and conservatively observe unaccepted unknown-clock audio for the merged end marker; index durability and restart regressions cover the shared state. Merged origin/main at `2d59f75eace67a03cc31dd07effa7ab73b8e15a5` into local head `f5758dd1afa9846ca4eaf6c864388c7efcf9d6e0`, preserving #25311 capture-end reporting and #25332 upload tracing. The only textual conflict was at the bulk-upload gate in `local_wal_sync.dart`; both clock-turn bookkeeping and trace preparation remain after the cancellation check. The marker remains an observer. Unknown-clock or refused WALs in its session, including future-clock chunks awaiting index publication, cannot produce a false zero watermark; accepted files and trusted trailing silence stay excluded. Focused regressions cover both clock classes accepted serially and failed publication. The fetched main uses a `pending_wals` JSON watermark and an `X-Omi-Upload-Trace` timing header; it contains no separate upload-watermark header. The capture-end observer now counts retained batch journals directly from disk instead of relying on the current writer and publishing list. Failed seal flush/close, failed append/publish, cancellation and process loss cannot erase the count. Replayed journals may overlap the ledger until server acceptance; they are excluded only for acknowledged files whose current byte length matches the accepted length, with no retained torn original. Transport-only synced, terminal-refused and corrupted rows stay conservatively pending. Unreadable evidence over-counts; an unavailable directory or unknown ledger suppresses the marker. An append during the asynchronous scan invalidates that observation and retains the end for a later accepted-file wake. Reports are bound to the account and WAL generation before queuing and after the scan. No new startup save, uploader, cleanup authority or audio deletion is added. Focused real-ledger regressions cover both failed seal operations, cancellation, replay and eventual zero after actual upload acceptance; additional cases cover append failures, account changes, unreadable evidence and a growing accepted prefix. Validation on local head `46a179598fb40829d679bddea9dca040c6719ede` completed 2026-11-15T00:32:09Z through `bin/omi-heavy`, Flutter 3.44.5 / Dart 3.12.2: full CI `app/test.sh` **8,837 passed, 5 skipped, zero failures across all 981 Dart files**; separate dev-controls spine **138 passed**; three exact CI timezone runs **39 passed each**. Focused four-file regression run **98 passed**. Format checked **23 Dart files**, unchanged. Nine touched Dart files analyze with no issues; full analyzer ratchet passed without baseline change. Expanded directory analysis reports 11 existing infos outside changed files, zero errors/warnings. The actual pre-push hook passed, including all **29 preflight checks**, generated-output validation and formatting. Backend type/unit selectors ran with no applicable backend delta, no skip overrides. Source clean; no push or release. The two failed-seal paths, account races, restart/replay, concurrent append and original CI custody/refusal regressions all passed. Full enumeration, files and logs: `Q12-I-durable-pending.md`, `evidence/q12-i-durable-pending/`. The lead owns publication, fresh CI and independent review.
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.
App: measure how long a sealed recording file waits before the server accepts it
Tracking: SCA-1766. Server side that reads the header: #25309. Independent of it: a server that does not
know the header ignores it.
The largest unexplained term in capture-to-notes latency is the upload tail: files that sit on the phone for
hours after they are sealed. Nothing measures it per file or says which gate held it. This adds that
measurement and changes no upload behaviour.
Failure-Class: none
UI-Evidence: none -- no screen, layout or copy changes
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2725 -> 2739 | the trace is prepared at the two existing upload sites and a rate-limit note at the existing catch blocks; the logic is in a new file
Line-Count-Exception: app/lib/backend/http/api/conversations.dart | 1524 -> 1528 | one header on the existing upload request
Line-Count-Exception: app/lib/services/wals/recording_transfer_coordinator.dart | 601 -> 605 | one note at each of three existing gates
What changed
UploadTrace(app/lib/services/wals/upload_trace.dart, new): remembers the last upload gate thatclosed and when, and per oldest file the first attempt time and attempt count. In memory, bounded.
X-Omi-Upload-Trace: sealed=<epoch>;first=<epoch>;gate=<label>;attempts=<n>onPOST /v2/sync-local-files, for the oldest file in the batch.sealedis the file's start time plus itslength.
gateis named only if it closed after the file was sealed; otherwisenone.background(a wake skipped while backgrounded),in_flight(coalesced into a runningpass),
auto_upload_off,rate_limited. The closed label set matches the server's; anything else isother.offline,server_holdandretries_exhaustedare in the set and not yet noted anywhere: thosepaths do not pass through one place, and I would rather report
nonethan guess.What it does not touch
When or whether anything uploads. No gate reads the trace. The header is taken by first file path inside the
existing upload call, so no uploader signature or test fake changes.
Limits of the measurement
Memory only: after an app restart, older waits report
gate=noneandattempts=1. A long tail withgate=nonetherefore means "the app was not running or nothing woke it", which is itself an answer.Product invariants affected
fences no sync and discards no frame.
Tests
app/test/services/wals/upload_trace_test.dart(new, 7 cases): first attempt; a gate after the seal is namedand the first attempt time is kept; a gate before the seal is not blamed; unknown labels fold to
other; amissing seal time sends nothing; an accepted upload resets the count; memory stays bounded; the label set.
Existing coordinator, batch lane and periodic sync tests pass unchanged.
🤖 Generated with Claude Code