Repository navigation
fix(watch): preserve recording recovery copies until iPhone receipt - #22059
Conversation
|
Verdict: the custody design here is strong — write-ahead PCM segments, digest-verified receipts, and fail-closed ownership on the iPhone side — and I found no ownership or data-loss hole in the transfer chain. Two follow-ups below before this leaves draft; nothing blocking. What I verified:
Follow-ups:
Performance: fsync every 1.5s plus a SHA256 over ≤1.94 MB per transferred segment — bounded, and the bounded_writer harness asserts RSS stays under 128 MB across 90 minutes of writes. USER IMPACT: Apple Watch recordings now survive Stop and app restarts and keep retrying transfer until the iPhone confirms receipt; users see a pending-transfers count with Retry on the Watch, and recovered audio shows up in Recordings for manual processing. Still want as a reviewer: the explicit ship-order statement (1), the localization fallback confirmation (2), and a hardware verification plan for the incident session. Leaving for human maintainer review: the recovery-custody design and dual-companion release sequencing for #20479 need maintainer sign-off before this leaves draft. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Answers to the three follow-ups: 1. Ship order. The Watch app is embedded in the iOS app (
The released-iPhone-drops-new-Watch-files case only arises in local mixed installs, not in store builds. 2. Localization. Intended and consistent. The Watch catalog's source language is 3. Hardware verification. Planned on a paired Watch with a TestFlight build:
The original eleven-hour session cannot be recovered by this change. Before it, the Watch kept no original file, so whatever survives of that session exists only server-side, and that needs a prod check rather than this build. |
kodjima33
left a comment
There was a problem hiding this comment.
aryanorastar: 1412-line/26-file Apple Watch recording-recovery change adding a new durable WatchRecordingStore subsystem; also touches .github/checks-manifest.yaml (known cascade-conflict-prone shared file per memory). Reads as new capability, not a narrow fix, and touches a risky shared file -> approve-only, not merge.
…ding-recovery # Conflicts: # app/ios/Runner.xcodeproj/project.pbxproj # backend/utils/sync/pipeline.py
Record the post-merge project-membership check and split the release step: deploy the sync processing backend before the iOS build that contains the paired iPhone and Watch apps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verdict: the custody design here is correct and well scoped to the Watch recording-loss incident (#20479) - no blocking findings, and I'm noting the maintainer approval on this head.
Correctness notes (file-by-file):
- app/ios/Runner/WatchRecordingStore.swift: append() writes length-prefixed 320-byte PCM16 frames under one recursive lock with 1.5s fsync cadence, seals at 6,000 frames (one-minute segments bounded at 1.94MB), and recoverInterruptedSegment() rebuilds from the offset-matched .tail journal, preserving torn suffixes for diagnosis. Data-slice compaction (remainder copy) plus autoreleasepool drainage bound memory; the bounded_writer harness scenario asserts RSS stays under 128MB across a simulated 90-minute session.
- Ownership fails closed at three layers: WatchRecoveryTransferQueue only sends current-account files, WatchRecordingInbox.receive() rejects metadata.ownerUID mismatch against flutter.uid (wrongOwner), and watchRecordingOwner() in app/lib/services/capture/watch_recording_receipt.dart refuses to list any audio_omibatchwatch file without a committed receipt whose reconstructed filename matches exactly. A file published between .bin write and receipt commit is invisible to the scanner rather than adopted - the right direction for cross-account safety.
- app/ios/Runner/AppDelegate.swift: didReceive file runs WatchRecordingInbox.receive synchronously (correct - WCSession removes file.fileURL on return, and the comment documents it), then returns the receipt via transferUserInfo so the Watch ACK survives backgrounding; on rejection the Watch retains its source and retries.
- backend/utils/sync/recording_intent.py + pipeline.py: the phone keep-intent predicate is extracted unchanged and extended with a strict fullmatch regex for watch recovery files; mixed/bulk uploads still do not establish a keep choice, and backend/tests/unit/test_phone_batch_process_now.py plus the new e2e test cover both sources. backend/utils/sync/ARCHITECTURE.md matches the code.
- Watch UI (ContentView.swift, WatchRecorderControlling.swift, omiwatchApp.swift): pending-transfer badge, retry on scene activation, localized error strings, and a capture-health watchdog that retires the recording indicator when frames stop arriving.
Performance: the 60s retry cycle SHA256-digests pending one-minute segments (max 4 in flight) - negligible. UX: recovered recordings appear in Recordings and keep the explicit Process Now keep behavior instead of being auto-discarded. Blast radius if wrong: Watch recovery copies only; live transcription is untouched, and every failure mode retains or quarantines audio rather than exposing it cross-account.
USER IMPACT: Apple Watch recordings now survive Stop, app restarts, and failed transfers - the Watch keeps a recovery copy until the iPhone confirms receipt, and recovered audio shows up in Recordings instead of being silently dropped.
Still wanted (non-blocking): backfill this PR into the empty evidence_prs of .github/failure-classes/FC-watch-audio-released-before-durable-receipt.json after merge, and a physical-device spot-check of the documented 1.5s power-loss window would strengthen the custody claim.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Pushed 4848528 (from ca035fc): merged current origin/main and ordered the rollout checklist.
Re-run on the merge: watch recovery harness 18 runs / 49 assertions (UTF-8 locale); Flutter receipt/ownership/WAL 228 passed; backend sync and Process Now 984 passed; hermetic Watch Process Now e2e 1 passed; Watch target and Debug-dev iPhone simulator builds succeeded; Open: the RayBan simulator build fails locally with |
…ocale AppDelegate.swift contains non-ASCII bytes, so under an unset locale Ruby defaults to US-ASCII and the custody source-scan test raised "invalid byte sequence in US-ASCII" instead of asserting. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Pushed db25f6b (from 4848528): the Watch recovery harness now reads sources as UTF-8.
RayBan follow-up: the |
|
Auto-fix isn't included in your plan ↗ |
…ding-recovery # Conflicts: # backend/utils/sync/pipeline.py
|
Pushed 85d0032: merged current main (8edd56d) and resolved the conflict in
|
kodjima33
left a comment
There was a problem hiding this comment.
Reconfirming with new evidence: independent technical review (Git-on-my-level, file-by-file) found no blocking issues on the Watch recording-custody design; kodjima33 already approved; CI green; tests extensive. Upgrading from yesterday's approve-only to merge: 4/5 confidence (diff size is the only failing criterion).
…23280) ## Final merge acceptance — 2026-10-23 Reviewed/tested head `821c326f07846966173b6a66b70c3187094da442`. Fresh native suites pass **24 tests / 84 assertions**. The production recorder/view/store probe passes **7 lifecycle cases on the 40 mm Watch SE 3 simulator / watchOS 27.0**: canceled/late permission, ABA permission, failed activation, Stop, repeated Stop, denial and missing owner. Permission/audio-session I/O is injected; `physicalAudio=false`. Native screenshots confirm visible Stop and separate Retry with pending transfers, idle Record/Retry, and visible Stop at accessibility3 with a long recovery error. This is not real microphone, radio transfer or paired-Watch evidence. Aryan explicitly accepts simulator-led Omi verification and authorized merging this PR if ready. This final acceptance supersedes the earlier physical-device-only merge gates below; physical Watch connectivity/audio and customer release outcomes remain explicitly unverified follow-up, not claims of recovery. Required current-head CI and an existing approval passed before merge. No deployment or store release is authorized/performed in this task. `Fixes` was changed to `Refs` so #23275 stays open for release/outcome follow-up rather than closing on code merge alone. --- The active Watch screen hides Stop behind the Omi logo, and recorder teardown leaves AVAudioSession active. This adds a visible **Stop recording** button, keeps Retry transfer separate, and shares microphone cleanup across Stop, cancelled permission and failed startup. A delayed permission answer cannot reactivate a cancelled recording. Refs #23275. Follow-up to #22059. Current main already addresses minute-by-minute Home backup clutter through [#23288](#23288): the shared custody ledger owns Watch copies, Offline Sync exposes automatic work, and Home lists explicit user-held recordings. This branch now integrates that pipeline and removes its superseded Home grouping proposal. No additional Dart projection, retention rule, backend, firmware or API change is introduced here. Public store release of #23288 has not been verified. ### Verification - Native Watch simulator probe runs the actual production recorder/view/store with synthetic permission and audio-session I/O: **7 lifecycle cases passed**, including late/ABA permission, activation failure, Stop, repeated Stop, denial and missing owner. It opens no microphone. - Existing custody, relay and presentation suites: **24 tests, 84 assertions passed** after main integration. - Separate Personal Team-signed QA host on **physical iPhone 16 Pro / iOS 27.0.1**, compiling unchanged production recorder/view/store: the final approximately **70-second** capture saved **60.00 + 10.09 seconds of validated, non-zero PCM**, stopped, successfully deactivated AVAudioSession with zero errors, and left file sizes unchanged for two seconds. Final result UTC: **2026-10-23T04:22:27Z**. A direct-phone spoken test also produced non-zero audio. Aryan manually verified Stop: the timer stopped and orange microphone indicator disappeared. Earlier runs with the Mac device view open contained only zero PCM and are not counted as audible capture evidence; a later start was blocked while the phone was locked. The final run used the unlocked phone directly with the device view closed. Retained parts include earlier QA runs, so totals are attributed by session metadata. The battery adapter is a no-op; this does not exercise physical watchOS, paired delivery or the production Omi app/account. - Native 40 mm Watch simulator renders active Stop + Retry, stopped Record + Retry, and accessibility3/error state. The stopped-state Retry clipping and accessibility title wrapping found during inspection are corrected. - Current-main analyzer ratchet, local preflight (20 selected checks; the history-dependent guard explicitly skips on this shallow clone) and push hooks passed. Full app suite: **7,120 passed, four skipped**, plus **138 protected contracts passed**. All hermetic mobile journeys passed (**23 executions, zero failures/skips**). Code Review confirms **iOS Compile Check, Dart Analyze & Tests, Hygiene and Desktop Swift Static & Test Contracts passed on `821c326f07846966173b6a66b70c3187094da442`**, with no failed or running source checks at verification. Scope-skipped lanes are not claimed as executed. Reproduce native checks from the repository root: ```sh ruby app/ios/test/watch_recording_recovery_test.rb ruby app/ios/test/watch_audio_chunk_relay_test.rb ruby app/ios/test/watch_recording_presentation_test.rb ruby app/ios/test/watch_recording_controls_probe.rb --device <booted-watch-simulator-uuid> --output <temporary-directory> TZ=UTC bash app/test.sh make mobile-verify ARGS='fast --all' make preflight ``` The SDK probe needs the CocoaPods Ruby environment (`xcodeproj`). Private physical-run build/source hashes and result JSON are retained locally; no microphone audio, device identifier, customer account or signing credential is published. ### Merge gates and release **Ready for review; do not merge until paired-Watch acceptance passes:** press Stop and check microphone indicator with phone reachable/unavailable, pending transfers and screen-off/resume; capture across a minute boundary; restart/retry real WatchConnectivity transfers; verify receipt-owned originals, playback and processing on iPhone; confirm Home has no automatic minute-copy rows and originals remain accessible through Offline Sync. The iPhone-host result does not satisfy these Watch gates. Simulator file delivery is unsupported by [Apple's WatchConnectivity documentation](https://developer.apple.com/documentation/watchconnectivity/wcsession/transferfile(_:metadata:)). Longer recovery qualification remains tracked in `app/docs/apple-watch-recovery.md`. Source checks have passed on the exact pushed head. Complete paired-hardware acceptance and compare against David's concurrent work before readiness; refresh affected checks if changes follow that review. No review of unpublished changes is claimed. After acceptance, this needs merge and a signed iPhone release containing the updated Watch companion. This follow-up adds no backend deployment; #22059's existing processing-backend rollout dependency remains separately tracked. No deployment, app-store release or older-audio recovery is claimed. ### Product invariants INV-CAP-1: preserve original recovery files, session fencing, durable receipts and account ownership; microphone teardown does not change custody. INV-UI-1 / INV-UI-3: reuse native controls and existing localized Stop labels, preserve explicit controls with pending/error state and large text. INV-PERF-1: no new per-frame UI work, scan, timer or uploader; main's canonical custody pipeline remains authoritative. ### Failure class Failure-Class: new Root cause: recorder cleanup stopped the engine without releasing AVAudioSession; permission checking also activated audio before validating the original start generation. Trigger: #23275; these lifecycle defects predate #22059, while that PR introduced the minute-copy clutter now handled by #23288. Prevention uses a shared `releaseCaptureResources` primitive for Stop and failed startup, plus generation validation before session activation. The durable guard is `app/ios/test/watch_recording_controls_probe.rb` with `app/ios/test/fixtures/watch_recording_controls_app.swift`, executing the production model with synthetic OS I/O. It is an explicit SDK/simulator lane, not a default hermetic CI or physical Watch qualification. ### UI evidence UI-Evidence: .agent-artifacts/ui-evidence/watch-session-controls/evidence.json Actual native views with synthetic state; no physical microphone or transfer claim.    ## 2026-10-23 maintainer review and merge gates Reviewed the current production Stop/cleanup/generation changes and reran the native recovery, relay and presentation suites: 24 tests / 84 assertions pass. No new blocking source finding in this bounded review. Existing iPhone-host microphone evidence is not a paired-Watch test. Ready for code review at Aryan's request; merge stays blocked until real Watch Stop/microphone release, minute-boundary capture, reachable/unreachable phone transfer retry, screen-off/resume, retained originals/playback/processing and Home/Offline Sync behavior are verified. No physical device was accessed in this review and no deployment/release was performed.
What changed and why
Apple Watch audio arriving after Stop or an iPhone process restart can be discarded by the live recording-state gate. The Watch previously kept no original file. #21072 removed the iPhone's whole-session memory growth, but did not address durable transfer or recovery. Refs #20479; keep the incident open pending the customer's original-audio investigation.
This adds an independent recovery path while retaining live transcription:
Recovery copies use the existing local Recordings playback and Process Now pipeline. Processing remains manual to avoid automatically duplicating a successful live conversation. Both mobile companions need release. The existing format is supported, but the new explicit keep rule also requires deploying the shared sync processing backend. It cannot reconstruct audio that an older Watch app never saved, and does not promise one eleven-hour conversation.
Architecture, implementation and rollout checklist:
app/docs/apple-watch-recovery.md.Validation
ca035fc9ac0cd7ba2b07435f1075ee9f948fc5a5: Mobile App Checks (including pinned Xcode 26.6 iOS compile and required Mobile Release Eligibility), Backend Unit Tests, Backend Hermetic E2E, API contracts, runtime source closure, and latest PR Metadata Preflight. An older metadata run was superseded/cancelled; its replacement passed.Merge with current main (10ef495, checklist 4848528, harness db25f6b)
Merged
origin/mainat a87589a with a merge commit (no rebase, no force-push).app/ios/Runner.xcodeproj/project.pbxproj: resolved by hand, not by taking either side. Kept main's entries, including theSafeFoundationSinks.swiftfile ref/build files andSiriSession. Kept this PR'sWatchRecordingStore.swiftref and its three build files, plus the Watch target'sSafeFoundationSinks.swiftbuild file pointing at main's file ref. Dropped the duplicate copies the conflict produced. Result: 467 object IDs, all defined exactly once, no dangling references,plutil -lintOK. Sources membership:WatchRecordingStore.swiftonce each in Runner, RunnerRayBanDat and omiWatchApp;SafeFoundationSinks.swiftonce each in Runner, RunnerRayBanDat, omiWatchApp and BatteryWidget.backend/utils/sync/pipeline.py: kept both imports (user_selected_recordingfrom this PR, main'sinput_limitsnames); both are used.AppDelegate.swift,local_recordings_provider.dart,.github/checks-manifest.yamlandbackend/utils/sync/ARCHITECTURE.mdauto-merged. Every file except the two resolved conflicts matchesgit merge-treeof the two parents exactly, and the diff against main is the same 26 files as before the merge.Re-run on the merge:
ruby app/ios/test/watch_recording_recovery_test.rb: 18 runs, 49 assertions, 0 failures under both an unset locale andLANG=en_US.UTF-8. db25f6b makes the harness read sources as UTF-8. Before that, under an unset (US-ASCII) locale, the custody source-scan test raisedinvalid byte sequence in US-ASCIIon the non-ASCII bytes already inAppDelegate.swift.flutter test test/unit/watch_recording_receipt_test.dart test/unit/local_recordings_owner_test.dart test/unit/local_wal_sync_test.dart test/services/wals/: 228 passed.flutter analyzeon the touched Dart files: no issues.BACKEND_UNIT_TEST_FILE_LIST=<22 sync/Process Now files> bash backend/test.sh: 984 passed, includingtest_phone_batch_process_now.py.bash backend/testing/e2e/run.sh testing/e2e/test_watch_recovery_process_now.py: 1 passed.xcodebuild -project Runner.xcodeproj -target omiWatchApp -configuration Debug-dev -sdk watchsimulator CODE_SIGNING_ALLOWED=NO build: BUILD SUCCEEDED.flutter build ios --simulator --debug --flavor dev -d <iPhone 16 Pro sim>: builtRunner.appwith the Watch companion embedded (Xcode 27.1, Flutter 3.44.5).scripts/rayban_dat.sh build ios --simulator --debug -d <sim>fails withCycle inside RunnerRayBanDaton main 1e1879f itself, the same as on this branch. The cause is main's phase order (Thin Binary before Embed Frameworks); this PR does not change it. The fix is in a separate PR, fix(ios): unblock the Ray-Ban DAT build and keep its project file clean #22596, where the same build succeeds.git diff --checkclean;make preflight: 55 checks passed;scripts/pr-preflight --pr-body-filepassed.Code/build/CI checks are complete. Keep this draft for physical paired-device qualification: phone terminated/unavailable, screen off, account change, disk pressure and 11h06m capture with sample/digest, battery and transfer checks. Apple does not deliver WatchConnectivity files in Simulator, so the executable file-custody harness is not a paired transfer test. Then merge, deploy the shared sync-processing image to fresh/backfill workers and inline processing hosts, and release the signed iPhone app with its Watch companion. Historical customer recovery remains unverified.
Product invariants affected
INV-CAP-1, INV-UI-1, INV-UI-3, INV-PERF-1: reuse the existing recordings surface, native Watch controls, async phone receipt reads and bounded audio files. No whole-session memory buffer or automatic duplicate transcription.
UI evidence
Failure class (fixes)
Failure-Class: new