Skip to content

fix(desktop): make WAL and Rewind recovery retry-safe - #9592

Merged
Git-on-my-level merged 2 commits into
mainfrom
codex/macos-persistence-integrity
Jul 13, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
codex/macos-persistence-integrity

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 12, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Follow-up to the confirmed persistence deferrals in #9522. WAL frame writes now use immutable FIFO batches, recoverable sidecars, collision-free per-device identities, and serialized metadata commits. Rewind video rebuilds now replace each chunk transactionally from the encoded sample timeline, exclude the active encoder chunk, and report bounded failure summaries.

Product invariants affected

none

How it was verified

  • cd desktop/macos && rtk ./test.sh — all launcher/e2e contract checks passed, Rust backend tests passed (319), and all Swift suites passed in process isolation (252 suites).
  • cd desktop/macos && rtk xcrun swift test --package-path Desktop --filter 'WALServiceUploadTests|WifiSyncServiceTests|WALFrameEncodingTests|RewindVideoRebuildIntegrityTests|RewindStorageVideoFrameExtractionTests' — 36 focused persistence/rebuild tests passed together.
  • cd desktop/macos && rtk rm -rf Desktop/.build && rtk xcrun swift build -c release --package-path Desktop --triple arm64-apple-macosx — clean arm64 release build completed.
  • Launched /Applications/omi-persistence-integrity.app via the named-bundle run.sh --yolo path on isolated automation port 47995. The live bridge identified com.omi.omi-persistence-integrity, and omi-ctl action rewind_settings_snapshot returned the real Rewind retention, capture interval, exclusion, storage, and indexed-frame state.
  • rtk make preflight — every selected local manifest check passed. Advisory warnings only reported pre-existing/known large-file thresholds.

Tests

  • WALServiceUploadTests covers failed-write retry, metadata failure/restart recovery, no duplicate audio rewrite, frames arriving during I/O, device/codec identity collisions, SD-card collisions, corrupt-primary/valid-backup recovery, and later backup rotation.
  • WALFrameEncodingTests locks the length-prefixed on-disk frame format; WifiSyncServiceTests verifies the injected WAL directory boundary.
  • RewindVideoRebuildIntegrityTests covers idempotent replacement, transaction rollback after insert failure, and validation-before-delete.
  • RewindStorageVideoFrameExtractionTests uses real HEVC samples to prove actual low-cadence PTS/ordinal reconstruction, unsafe-timeline rejection, marker-buffer handling, and active-chunk exclusion.

Root cause and durable guard (bug fixes)

WAL persistence had no single owner for a frame batch: a mutable capture buffer could cross an awaited disk write, metadata could advance separately from audio durability, and timestamp-based identities could collide when producers shared a second. The durable guard is an immutable queued batch plus a hash/length sidecar transaction, exclusive temp-file publication, one revisioned metadata queue, and behavioral fault-injection tests across write, retry, restart, and producer interleavings.

Rewind rebuild estimated rows from duration × nominalFrameRate and deleted/injected rows across separate database operations. That invents frames for low/variable-cadence media and leaves partial state on failure. The durable guard is encoded-sample PTS enumeration plus one GRDB delete/insert transaction per finalized chunk, exercised against real encoded fixtures and forced transaction aborts.

The recurrence evidence is #9522, which explicitly deferred both WAL frame-count inflation and Rewind rebuild over-counting after the preceding macOS bug sweep.

Scoped cleanups (optional)

  • Made WifiSyncService obtain its WAL dependency lazily and inject it immutably in tests, preventing test initialization from recovering a real user WAL directory.
  • Preserved a validated metadata backup while recovering a corrupt primary, then resumed normal backup rotation after the first successful canonical write.

Review in cubic

@Git-on-my-level
Git-on-my-level merged commit 4b7d870 into main Jul 13, 2026
20 of 23 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/macos-persistence-integrity branch July 13, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant