Skip to content

fix(sync): recover retained recordings after upload refusals - #23056

Merged
aryanorastar merged 2 commits into
mainfrom
fix/failed-sync-recovery
Oct 23, 2026
Merged

aryanorastar merged 2 commits into
mainfrom
fix/failed-sync-recovery

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Offline Sync can mark every member of a refused multi-file request as permanently failed, and HTTP 403 was classified as an audio refusal. The resulting saved files show Failed with only Delete, despite the single-file uploader supporting an explicit retry. Refused 400/413 batches now isolate members through the existing upload gate before assigning a per-file verdict; authentication failures retain the file, persist a pause and stop that drain. The card, recording/file rows and error-card Retry re-arm historical request refusals through the existing owner. No audio is deleted or retimed; local-only custody and confirmed missing/audio/window verdicts stay excluded.

Refs #23049. The original spent-budget card no-op (#21828) is already merged and released in iOS 1.0.566 (App Store release notes). #21320 remains separate: navigation/bulk cleanup does not solve request-level attribution or an authentication refusal.

Validation:

  • Eight failures reproduced against unchanged main before the fix. All 84 focused state/provider/UI regressions pass, including persisted refusals, mixed terminal files, local-only custody, coalesced retries, authentication persistence, account changes during isolation and manifest completeness. The final broad app rerun passed: 7,016 tests, nine skips, zero failures, plus 138 spine tests. The final normal pre-push gate and all 25 selected preflight checks pass. Its history-dependent failure-class ratchet explicitly skips this shallow clone; no history-dependent coverage is claimed locally.
  • All six hermetic mobile journeys pass (23 assertions); make mobile-verify ARGS="fast --all".
  • Changed Dart files analyze cleanly; the full analyzer ratchet passes with the original baseline unchanged.
  • Native iPhone 16 Pro / iOS 26.5 simulator build and agent-flutter interaction passed with real SyncProvider, LocalWalSyncImpl and AutoSyncPage and a synthetic uploader: requests [3, 1, 1, 1], two files synced, one uploadRejected, all three original files retained. The existing Share Recording control produced a valid 60-second, mono 16 kHz WAV. No customer audio, production account or live STT was used. Initial local-Firebase SDK settings requests logged test-configuration errors; they were not successful Omi uploads. Captures and source hashes are in .agent-artifacts/ui-evidence/fix-23049-upload-refusal/verification.json.
  • Regression commands: flutter test test/unit/wal_upload_resilience_test.dart test/unit/wal_sync_display_state_test.dart test/providers/sync_provider_needs_attention_retry_test.dart test/providers/sync_provider_sync_wal_wake_test.dart test/pages/conversations/offline_sync_recording_blocks_test.dart test/widgets/sync_row_recovery_window_test.dart; bash app/test.sh; bash app/scripts/analyze_ratchet.sh; make preflight.

Expected-value changes have external/owning contracts: RFC 9110 §15.5.4 permits retry with different credentials; §15.5.14 refuses the request's size, not each member's audio. backend/utils/sync/files.py:validate_input_files rejects a whole request when one filename/timestamp is invalid. An isolated single-file 400/413 still stops automatic uploads. Existing Wal.markUploadRejected already preserves bytes for deliberate resubmission. The regression executes that owner, not source-string assertions. It extends the existing FC-batch-fault-domain-head-of-line-poison guard surface rather than adding a separate retry authority.

Release and customer verification:

  • Needs merge, CI/review and an iOS/Android app release. No backend deployment, firmware update, bulk migration or account-data mutation is introduced by this PR.
  • The supplied log excerpt confirms stale phone-local backlog but includes no upload response, terminal refusal reason, app version or decode result. These are demonstrated app defects, not a confirmed diagnosis or recovery of that customer's nine files. Retained-record counts are not recovered-record counts.
  • Physical phone verification remains: update to the released build, retry one affected recording, verify the resulting conversation stays after refresh/reopen, and verify a saved export plays. Do not delete Pending/All, log out, reset or reinstall to troubleshoot while local audio may remain.
  • Invalid historical recording timestamps and genuinely undecodable/missing audio are not repaired by retry; no original time is invented and no server age/timestamp guard is bypassed. Keep Offline Sync can strand intact recordings after batch or authentication refusals #23049 open until the customer's outcome is verified.
  • Architecture and implementation checklist: app/docs/offline-sync-stall-recovery.md.

Product invariants affected

INV-CAP-1: refuse neither custody nor capture. No uplink pause, frame deletion or firmware assumption is added; failed requests retain phone files, original times and ownership. Existing live-capture fences and manifest-completeness checks stay in force.

INV-UI-1 / INV-UI-3: reuse existing neutral Omi retry controls and localized copy; keep playback/export navigation.
INV-PERF-1: bounded upload isolation in the existing async owner; no UI-isolate audio work is added.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2764 -> 2804 | Keep refusal isolation and verdict persistence at the existing upload owner; use the existing bounded batch selector, gate and account-generation fence.

UI evidence

Retained refusal retry

Valid siblings recovered

Retained audio export

View guided diff Turn on auto-fix

2026-10-23 maintainer review and merge readiness

Resolved current-main integration by keeping the extracted wal_policy.dart owner and holdForUser automatic-upload exclusion, while retaining 400/413 refusal isolation and treating 401/403 as authentication pauses; reviewed head fc58d4d. The 84 focused state/provider/UI tests, analyzer ratchet and 25 selected preflight checks pass. In a dedicated iPhone 16 Pro / iOS 26.5 simulator, the production SyncProvider, LocalWalSyncImpl and AutoSyncPage exercised Try Again against a synthetic uploader: request batch sizes were [3, 1, 1, 1], two WALs became synced, the persistently rejected WAL stayed uploadRejected, original timestamps stayed unchanged, and all three 1,944,000-byte source files remained. The Synced tab displayed the two successes. This is fixture-backed processing, not actual Omi STT or recovered customer conversations; placeholder Firebase warnings are not successful account authentication.

Aryan approved risk-proportionate verification on 2026-10-23 and authorized proceeding with this merge candidate. This PR changes client-side refusal attribution and deliberate retry, not the native recorder, background lease, codec or backend processing contract. The production-owner simulator interaction, focused failure/account/custody regressions and current-head CI satisfy its pre-merge scope; live STT and the customer's actual recordings are not required to validate that bounded change. Fresh GitHub checks report no failed or pending checks, the required Mobile Release Eligibility check passes, existing approval is present, and the branch is cleanly mergeable. No source was changed by this readiness reassessment.

Actual server conversation recovery, playback/export on the customer's released phone build and customer acceptance remain post-release incident follow-up, not claims of completed verification. The separate physical QA host has not produced a passing phone result. Keep #23049 open. This merge is not a backend deployment or confirmation of an app/store release, and no production/customer data was used.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Refs #23049. Preserve local audio and original capture times while separating request failures from per-file verdicts.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T09:44:22.247341Z fc58d4d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level Git-on-my-level added flutter flutter work positive-signal Automation verified a genuine fix/quality contribution labels Oct 21, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: the production change is correct and nicely scoped — batch-refusal isolation, the 401/403 authentication pause, and manual re-arm of historical refusals all verify against the diff; leaving for human maintainer review before merge.

What I verified on this head:

  • app/lib/services/wals/local_wal_sync.dart — 403 moves out of _kDefinitiveUploadRefusalStatusCodes ({400, 413}) and joins 401 as an authentication pause: retry budget pinned to walMaxAutoRetries, status left as retryable miss, drain breaks, state persisted (lines 2224-2281). A multi-file 400/413 no longer blanket-marks the batch: members requeue for single-file isolation through the same serialized gate (isolateAfterRefusal + attemptedWalIds reuse, ~line 2229), bounded to one pass per member, and only a single-file refusal calls markUploadRejected(). Generation checks guard both catch entry and post-failure state.
  • app/lib/services/wals/wal.dart — new prepareManualRetry() re-arms only uploadRejected -> miss and resets the budget; isRetryableSyncState() now admits uploadRejected alongside failed. Doc comments match the new behavior.
  • app/lib/providers/sync_provider.dart — retryableAttentionWals now excludes onDeviceOnly custody; the coalesced syncWal path calls prepareManualRetry() before _wakeTransfer, so a coalesced tap genuinely re-admits a refused row (covered in sync_provider_sync_wal_wake_test.dart).
  • app/lib/pages/conversations/auto_sync_page.dart and sync_page.dart — Try Again appears for retryable/refused rows with an onDeviceOnly guard, and uploadRejected is removed from the delete-only terminal set, so retained refusals keep a recovery path instead of Delete-only.
  • Tests — wal_upload_resilience_test.dart (+118, incl. the partial-manifest claim guard during isolation), sync_provider_needs_attention_retry_test.dart (persisted refusal recovered without touching outsideRecoveryWindow/unsupportedAudio/local-only siblings), and the offline_sync_recording_blocks_test.dart widget case all target the right behaviors.
  • app/docs/offline-sync-stall-recovery.md, the changelog fragment, and the FC-batch-fault-domain JSON update are accurate against the code I read.

Blast radius: only users with refused or auth-paused uploads see changed behavior — no deletion, no retiming, no server contract change; retry amplification is bounded (one isolation pass per member, exhausted budget on auth failure).

USER IMPACT: recordings previously stuck showing Failed with only a Delete option after an upload refusal now get a Try Again that actually re-uploads them, and one bad file in a batch no longer blocks its siblings.

Still wanted: I could not run the Dart suite in this environment (no Flutter SDK available to me); CI is green on this head, but a maintainer sanity-run of the regression commands listed in app/docs/offline-sync-stall-recovery.md before merge would close that gap.


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.

Good-faith fix from a trusted contributor with tests and UI evidence, but diff is large (633 lines/21 files) and GitHub currently reports mergeStateStatus=UNKNOWN; approving, holding merge for a clean mergeability recheck.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: the production change is correct and nicely scoped — I verified the refusal-isolation and retry paths against the diff and found nothing blocking.

What I verified:

  • app/lib/services/wals/local_wal_sync.dart — 403 leaves _kDefinitiveUploadRefusalStatusCodes (now 400/413 only) and becomes an authentication pause: on 401/403 the drain persists a spent retry budget and stops that pass instead of issuing audio verdicts (both the batch path and the single-file path). A refused multi-file 400/413 request is split into single-file attempts through the same upload gate. The isolation loop is provably bounded: a single-file definitive refusal calls markUploadRejected(), and isAutoUploadEligible() only admits status == miss, so each member gets exactly one additional attempt (batches are capped at 20 files per sync_upload_batch.dart). This removes the head-of-line poisoning without deleting or re-timing any audio.
  • app/lib/services/wals/wal.dart — prepareManualRetry() re-arms only uploadRejected -> miss and leaves timerStart/seconds untouched; automatic wakes stay excluded, exactly as the doc comment promises. isRetryableSyncState() now distinguishes request refusals from permanent audio verdicts.
  • app/lib/providers/sync_provider.dart — retryableAttentionWals admits spent budgets and refusals but keeps onDeviceOnly custody and corrupted/outsideRecoveryWindow/unsupportedAudio terminal; the error-card retry checks failedWal status before falling back to the attention retry, so a coalesced tap can no longer silently drop a refused row.
  • app/lib/pages/conversations/sync_page.dart and auto_sync_page.dart — refused recordings now offer Try Again instead of Delete-only, and onDeviceOnly rows offer neither action; the trailing-action classification matches the provider's.
  • app/docs/offline-sync-stall-recovery.md — the new section is source-backed and accurate to the code (403 auth-pause semantics, bounded isolation, shared retry classification). The .agent-artifacts/ui-evidence additions follow existing precedent on main.
  • Tests — auth-pause persistence with re-login re-arm (wal_upload_resilience_test.dart), isolation never claiming a partial live-capture manifest, persisted-refusal explicit retry excluding permanent verdicts (sync_provider_needs_attention_retry_test.dart), and coalesced-retry admission (sync_provider_sync_wal_wake_test.dart) all cover the new behavior.

UX: users with recordings stuck as Failed/Delete-only after a server refusal now get a working Try Again and can recover them without losing audio. Blast radius: offline-sync drain and its UI only; worst case if the isolation heuristic is wrong is one bounded re-attempt per file, never data loss. Cost/performance: no new external calls beyond the bounded per-member retries.

USER IMPACT: recordings previously stuck as permanently failed after an upload refusal now offer Try Again and can recover, and one bad file no longer blocks the rest of a batch.

Nothing blocking from my side; the approval already on this head stands from my perspective too. Optional nicety only: a brief in-app note when an isolated single-file retry gets refused again (it lands terminal uploadRejected), so users understand why Delete is then the only action.


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

@aryanorastar
aryanorastar marked this pull request as draft October 23, 2026 05:55
Move the 400/413 refusal classification into mains extracted wal_policy part; retain holdForUser automatic-upload fencing. Focused state/provider/UI checks: 84 tests passed; analyzer ratchet passed. Final full-suite/CI and physical acceptance remain gates; keep draft.
@aryanorastar
aryanorastar marked this pull request as ready for review October 23, 2026 09:44
@aryanorastar
aryanorastar merged commit 3f9c5c7 into main Oct 23, 2026
53 of 54 checks passed
@aryanorastar
aryanorastar deleted the fix/failed-sync-recovery branch October 23, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flutter flutter work positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants