Skip to content

fix(sync): recover waiting recordings at startup before another upload - #23233

Merged
aryanorastar merged 4 commits into
mainfrom
fix/startup-sync-reconciliation
Oct 23, 2026
Merged

aryanorastar merged 4 commits into
mainfrom
fix/startup-sync-reconciliation

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Final merge acceptance — 2026-10-23

Final diff reviewed at 970d03e6e77ed0c65a2a97b9e77eab47660f6611. Aryan explicitly accepts appropriate simulator/local integration evidence for Omi; the earlier physical-only merge prerequisites below are superseded, not represented as completed physical testing.

  • Fresh focused run on this head: 45 tests passed, including startup/provider admission, account/session replacement, callback replacement, coordinator recovery, and paywall navigation. Command: cd app && flutter test --no-pub --concurrency 1 --reporter expanded test/providers/sync_provider_background_admission_test.dart test/providers/sync_provider_startup_reconciliation_test.dart test/providers/sync_provider_session_generation_test.dart test/services/wals/recording_transfer_coordinator_test.dart test/widgets/trial_paywall_navigation_test.dart.
  • Installed iPhone 16 Pro simulator / iOS 26.5 component-integration run passed all three stages: persisted synthetic WALs were seeded in process 64239, the host terminated it and verified that PID exited, then relaunched the same app as process 64868. Cold startup surfaced the completed conversation before any new upload; the genuinely queued job retained its handle. Reconnect rediscovered inventory and reset the exhausted local retry budget. A later completed server response surfaced the second conversation and acknowledged only its WAL.
  • Throughout all stages: zero upload calls/attempts, auto-sync opt-out respected, all three original file hashes and capture timestamps unchanged, and transfer-lease refcount returned to zero. The third local recording intentionally remains pending under auto-upload opt-out; no fake all-synced/customer-recovery claim. The production On the Way UI was inspected before/after and driven with Marionette debug controls.
  • Test composition: unchanged production SyncProvider, RecordingTransferCoordinator, SyncReconciler, LocalWalSync, HTTP/parser, file persistence and native lease bridge. External auth/token I/O, device discovery and loopback server job responses are synthetic; HTTP-header metadata uses the sanctioned local-harness initializer to avoid product telemetry. This is not full shipping-app sign-in/startup, actual STT, BLE, background scheduling/expiration or customer audio recovery.
  • Build identity: fresh Dart/assets compiled from this head with Flutter 3.44.5/Dart 3.12.2, local_dev/debug isolation. An already-built identical-native simulator shell was reused: app/ios and pubspec.lock match the previously compiled shell's source; the only pubspec difference is removal of bundled fonts, covered by fresh assets. No new full native-build claim. Simulator BGTaskScheduler scheduling was unavailable, as expected; no physical/background-execution evidence is claimed.
  • Evidence is retained privately with this maintainer task (phase/result journals, build/test logs, hashes and screenshots). Earlier broad-suite/CI evidence and the explicitly disclosed Siri timing flake in Flaky Spotlight cooldown assertion in the full Flutter suite #23380 remain historical; a passing fresh focused run does not erase that record. No production code was modified for this pass.

Merge is separate from release and customer resolution. Refs #23223 stays open pending release and customer outcome. No deployment, customer-account access, recording deletion or production job mutation is authorized/performed by this verification. Final current-head required checks and approval are rechecked immediately before merge.


On relaunch, the transfer coordinator can reconcile an uploaded recording while SyncProvider._admittedWorkGeneration is still -1: the returned completed conversation is not surfaced, device discovery is skipped, and recovery depends on another upload starting first. Refactoring native keep-alive acquisition alone would also risk admitting an old account after an asynchronous lease wait.

The existing coordinator now admits a transfer synchronously before native acquisition. Native lease holds for abandoned bodies do not re-admit work. Reconciliation, discovery, inventory refresh, reconnect retry resets and drains use the admitted account generation. A reconcile pass snapshots its conversation callback with its phone owner, so reattachment cannot deliver an old result into a replacement callback. Auto-sync opt-out remains respected; genuinely queued jobs remain pending with their original handles.

Refs #23223. The Discord screenshot (381 recordings / 42 hours / nine almost ready) shows On the Way, not the on-device transcription banner. These are reproduced code defects, not a confirmed diagnosis or recovery of that account's backlog. #22484 is the existing merged missing-handle/poll-order fix; #21999 is a separate open proposal for legacy sequenced jobs and does not establish this account's cause.

Validation:

  • Four regressions fail against unchanged main a8fdd3889d and pass after the fix: completed-conversation delivery before a new upload, startup device discovery, account replacement during native acquisition, and callback replacement during a status read.
  • 41 focused provider/coordinator tests pass. The real provider, coordinator, reconciler and phone WAL owner run against synthetic device/status/persistence boundaries. Completed conversation delivery executes the production HTTP/parser path over a fake HttpClient. The existing On the Way widget renders a pending recording, receives startup completion, renders all synced, and retains the same WAL; queued-job and auto-upload opt-out checks prevent false completion and duplicate sends.
  • Final full app run: 7,063 passed, four skipped, no failures; the separate opt-in protected spine also passes. All six hermetic mobile journeys pass (23 checks). The final normal pre-push gate passes all 24 selected manifest checks, and the analyzer ratchet passes with the original baseline unchanged. The history-dependent failure-class ratchet explicitly skips this shallow clone; no local full-history coverage is claimed.
  • The first broad run exposed an existing paywall test tapping the removed trial_paywall_free widget; it also failed with all three production sync files restored to unchanged main. A separate test-only commit exercises system back and the actual close control, retaining restore/no-pop/late-completion assertions. All four navigation tests and the final full suite pass; paywall production code is unchanged.
  • Remote CI on 07ea53ac7898e859f492aa81d4adc257e654f942, checked 2026-10-23 through Code Review: Dart Analyze & Tests, Android compile/emulator/JVM, metadata, hygiene, formatting and backend merge gate pass; no failed or running checks remain. iOS compile and seeded-journey lanes were skipped; local hermetic journeys above are separate evidence. Cubic reported its review quota exhausted, which is not a completed independent review.
  • Commands: TZ=UTC bash app/test.sh; (cd app && flutter test test/widgets/trial_paywall_navigation_test.dart); (cd app && flutter test test/providers/sync_provider_background_admission_test.dart test/providers/sync_provider_startup_reconciliation_test.dart test/providers/sync_provider_session_generation_test.dart test/services/wals/recording_transfer_coordinator_test.dart); (cd app && bash scripts/analyze_ratchet.sh); make mobile-verify ARGS="fast --paths app/lib/providers/sync_provider.dart app/lib/services/wals/recording_transfer_coordinator.dart app/lib/services/wals/sync_reconciler.dart"; make preflight.

Release and limits:

Product invariants affected

  • INV-CAP-1: keep the existing capture/custody owner and native lease; change when a scoped recovery pass is admitted, with no audio loss or new pendant-uplink pause. app/lib/services/capture/OWNERSHIP.md defines pre-await generation capture and owner-ready recovery.
  • INV-UI-1 / INV-UI-3 / INV-PERF-1: no layout, copy, palette, new UI controls, UI-isolate audio work or additional poller. Existing queue rendering is exercised headlessly.

Failure-Class: FC-sync-gated-on-consumer-trigger

UI-Evidence: none -- startup/session wiring only; no widget layout or user-facing copy changes. Existing On the Way transition is tested through the real provider; no physical-device or native-build qualification is claimed.

Merge verification gate

Marked ready for code review on 2026-10-23 at Aryan's request. The former physical-only gate is superseded by the final simulator-first acceptance above; current-commit CI and independent approval still apply. Passing automated CI does not establish recovery of this customer’s recordings.

2026-10-23 maintainer review and merge gates

Main integration conflict resolved without dropping system-back coverage; pushed c4aa08b. The 45 focused provider/coordinator/navigation tests, analyzer ratchet, 24 selected preflight checks and 23 hermetic cases across six mobile journeys pass. The bounded full Flutter run completed with 7,123 passed, 9 skipped and one failure in the unchanged Siri cooldown timing test. That file and service match main; its isolated suite then passed all 28 tests. This is not a green full-suite claim: the timing failure is tracked in #23380. Exact-head GitHub checks were green at the final review snapshot. The former installed-phone prerequisite is superseded by the final simulator-first acceptance above. Customer-specific verification remains post-release follow-up, not a claim of recovery. No recordings, customer account, or production jobs were changed. Current main was merged again in 970d03e (docs-only conflict).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-23T14:11:40.705470Z 970d03e 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verdict: the production change is correct and well scoped; nothing blocking from my side — leaving for human maintainer review before merge.

The bug: at startup the coordinator could reconcile/discover while SyncProvider._admittedWorkGeneration was still -1, so a completed server job was acknowledged without surfacing its conversation, and device discovery was skipped until another upload started. The fix binds admission before any await can yield.

  • app/lib/services/wals/recording_transfer_coordinator.dart — new onTransferAdmitted hook called synchronously at the top of _run(), before _onTransferStarted (native keep-alive), gated on !_abandonedPassRunning so an abandoned body's lease hold cannot re-admit an old account. Placement is exactly right: admission happens before the first yield point.
  • app/lib/providers/sync_provider.dart — onTransferAdmitted binds _admittedWorkGeneration to the live _sessionGeneration (with an _isDisposed guard); _reconcileAdmittedWals re-attaches the reconciler per pass with a generation-bound callback; _onReconciledConversations now receives the generation as a parameter instead of re-reading it at callback time; connectivity-restored retry reset and _onTransferPassTimedOut are admitted-generation gated. Auto-sync opt-out is preserved: discovery/reconcile run, uploads stay gated.
  • app/lib/services/wals/sync_reconciler.dart — poke() snapshots the callback with its phone owner before awaiting, so a late result cannot be delivered into a replacement account's callback. Small and correct.
  • app/test/providers/sync_provider_background_admission_test.dart — six substantive regressions: completed-job delivery before any upload, discovery with auto-upload off, queued-job stays pending (no re-upload), account replacement during native lease acquisition, callback adoption after reattachment, and an On the Way widget round-trip. Real provider/coordinator/reconciler run against synthetic device/status/persistence boundaries — the logic under test is production code, not mocks.
  • app/test/services/wals/recording_transfer_coordinator_test.dart — admission-count assertions match the new semantics (synchronous with wake, not re-run beside an abandoned body).
  • app/test/widgets/trial_paywall_navigation_test.dart — verified this is a legitimate rebase adaptation, not scope creep: the trial_paywall_free control was removed on main (single "Try for $0.00" button) after this branch's merge-base; the replacement exercises system-back and close dismissal. No paywall production code changed.
  • app/docs/offline-sync-stall-recovery.md — new section matches the code (admission, snapshotting, opt-out claims all check out against the diff) and stays honest that the Discord 0/127 case is not a confirmed resolution.
  • app/changelog/unreleased/20261022-startup-sync-reconciliation.json — user-facing change described accurately; format matches existing fragments.

Security/privacy: the generation binding closes a real cross-account window (an old pass reconciling results into a replacement account) — covered by the replacement-account regression. Performance: one extra reconcile/discovery pass at startup; no new per-call queries. Cost: none.

USER IMPACT: when you reopen Omi, recordings that finished processing while the app was closed appear (and the On the Way queue updates) without needing a new upload to trigger it; pending device recordings are discovered at startup even with auto-upload off.

Nothing blocking. Optional follow-up: assert the auto-sync opt-in path (autoSyncOfflineRecordings: true) still drains at startup — the existing coordinator tests cover the drain gate, so this is belt-and-braces.


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

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

@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 bug fix (startup sync admission), scores ~4/5 (diff >300 lines is the only miss, tests present, CI green), but mergeStateStatus is DIRTY — per no-rebase hard rule, holding at approve rather than merging.

@aryanorastar
aryanorastar marked this pull request as draft October 23, 2026 03:21
Preserve the current dismissal controls and the system-back guard. Focused provider/coordinator/navigation verification: 45 tests passed; analyzer ratchet passed. Full-suite and final-head CI verification remain in progress; keep draft.
@Git-on-my-level

Copy link
Copy Markdown
Member

The production change here is correct and nicely scoped — admission is bound before any async yield and every recovery path is generation-fenced; no blocking issues found.

  • app/lib/services/wals/recording_transfer_coordinator.dart — onTransferAdmitted is invoked synchronously at the top of _run() before _onTransferStarted (native keep-alive), and gated on !_abandonedPassRunning, so holding an abandoned body's lease never re-admits an old account.
  • app/lib/providers/sync_provider.dart — onTransferAdmitted pins _admittedWorkGeneration to the live _sessionGeneration (with a -1 disposal guard); _reconcileAdmittedWals re-attaches the reconciler with a generation-bound callback before poke(); onConnectivityRestored and _onTransferPassTimedOut early-return unless the admitted generation is current; _drainEligibleWals now checks the admitted rather than session generation. The fences line up end to end.
  • app/lib/services/wals/sync_reconciler.dart — poke() snapshots onConversations before the first await, so a mid-flight status read can't deliver an old account's result into a replacement callback.
  • app/test/providers/sync_provider_background_admission_test.dart — six regressions matching the four claimed failure modes, running the real provider/coordinator/reconciler over synthetic device/persistence boundaries, plus an On the Way widget test that asserts zero uploads and that the acknowledged recording is retained rather than deleted.
  • app/test/services/wals/recording_transfer_coordinator_test.dart — the admission-count assertions (1 before the lease, still 1 while an abandoned body holds the gate, 2 only after it exits) directly pin the ordering guarantee.
  • app/test/widgets/trial_paywall_navigation_test.dart — the handlePopRoute() addition repairs a stale finder against main's paywall changes; the docs show it reproduced on unchanged main. Fine to carry with the merge.
  • app/docs/offline-sync-stall-recovery.md and app/changelog/unreleased/20261022-startup-sync-reconciliation.json — honest that the Discord 0/127 case is not confirmed by these tests, with post-merge verification steps left open.

UX: reopening the app now surfaces completed syncs and runs device discovery without another upload first; genuinely queued jobs stay pending — no duplicate uploads, and auto-sync opt-out is still respected.
Security: no new data flows; the account-replacement fencing actually tightens cross-account isolation (a retired pass can no longer poll or surface the replacement account).
Blast radius: confined to the WALS sync subsystem; the failure mode is recovery staying as slow as today, not data loss.

USER IMPACT: recordings that finished syncing while the app was closed now appear when you reopen it, instead of waiting for the next upload.

Still wanted before merge: full-suite CI confirmation on the final commit (the checklist itself flags this), and flipping the PR out of draft once that's green — the merged head is already green on Dart Analyze & Tests and Android Emulator Acceptance.


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

Keeps both the startup admission (#23223) and request-refusal (#23049)
sections of offline-sync-stall-recovery.md.
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Merged current main (970d03e6e7) to clear the conflict.

The only conflict was in app/docs/offline-sync-stall-recovery.md. Main's #23049 request-refusal section and this PR's #23223 startup-admission section are independent, so both are kept. sync_provider.dart merged automatically.

Checks after the merge:

  • Both PRs' sync regressions passed together (133 tests): startup reconciliation, background admission, session generation, the transfer coordinator, needs-attention retry, upload resilience, sync row and completion widgets, and paywall navigation. In one earlier combined run, two widget tests failed. Both passed when run alone and on a rerun of the full set.
  • The analyzer ratchet passed.

The PR diff against main is unchanged: the same 8 files.

@aryanorastar
aryanorastar marked this pull request as ready for review October 23, 2026 14:11

@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.

Well-reasoned sync fix (refs #23223), CI clean. Not merging: author's own PR body explicitly states merge stays blocked pending physical iPhone verification that hasn't happened yet.

@aryanorastar
aryanorastar merged commit 8d75fea into main Oct 23, 2026
54 checks passed
@aryanorastar
aryanorastar deleted the fix/startup-sync-reconciliation branch October 23, 2026 17:18
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