Repository navigation
fix(desktop): make WAL and Rewind recovery retry-safe - #9592
Merged
Merged
Conversation
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.
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./Applications/omi-persistence-integrity.appvia the named-bundlerun.sh --yolopath on isolated automation port 47995. The live bridge identifiedcom.omi.omi-persistence-integrity, andomi-ctl action rewind_settings_snapshotreturned 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
WALServiceUploadTestscovers 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.WALFrameEncodingTestslocks the length-prefixed on-disk frame format;WifiSyncServiceTestsverifies the injected WAL directory boundary.RewindVideoRebuildIntegrityTestscovers idempotent replacement, transaction rollback after insert failure, and validation-before-delete.RewindStorageVideoFrameExtractionTestsuses 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 × nominalFrameRateand 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)
WifiSyncServiceobtain its WAL dependency lazily and inject it immutably in tests, preventing test initialization from recovering a real user WAL directory.