Repository navigation
Fix SD-card sync 0 B/s readout, notification-metadata leak, Redis fail-open + CI manifest drift (bug sweep #7) - #9522
Merged
Conversation
StorageSyncService.updateProgress reassigned `lastProgressUpdate = now` on the line before computing `elapsed = now.timeIntervalSince(lastProgressUpdate)`, so `elapsed` was always 0 and `bytesPerSecond` was always 0 — the SD-card sync UI permanently showed 0 B/s (no speed/ETA). Compute the rate over the real elapsed interval using the bytes downloaded in that window, via a pure `bytesPerSecond(bytesDelta:interval:)` seam; track `lastProgressBytes` and reset it alongside the other progress state at sync start/stop. Root cause: read-after-write ordering bug on the interval timestamp. Durable guard: the rate math is a pure, synchronously testable function with regression tests for the real-rate, non-zero, and zero/negative-interval cases. WifiSyncService uses a separate sliding-sample method and was not affected. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01RAxLsaxtwVNDTWAZFfJp9q
NotificationService.notificationMetadata gained one (title, assistantId) entry per delivered functional banner but only removed it in the `didReceive` delegate — which fires solely on user interaction (click / custom dismiss action). A functional notification the user never touches (ages out of Notification Center, or is cleared without a dismiss action) never triggers `didReceive`, so its entry leaked for the life of the process, growing once per un-interacted notification. Fix: track insertion order and FIFO-evict the oldest entries past a 200-entry cap on insert, via a pure generic `evictOldestMetadata(order:store:max:)`; also drop ids from the order list on the interaction and add-error removal paths so both structures stay bounded and consistent. Root cause: a side-table whose only removal path depended on optional user action. Durable guard: bounded FIFO eviction with regression tests for evict-beyond-cap, no-eviction-under-cap, and exact-to-cap. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01RAxLsaxtwVNDTWAZFfJp9q
…ling open RedisService cached a bare MultiplexedConnection and returned that same clone to every caller forever, with no reconnect-on-error path. Once the Redis link dropped, every subsequent command errored, and the rate limiter (which fails open on a Redis error by design) then stopped enforcing limits entirely — unmetered — until the process restarted. Fix: cache a redis ConnectionManager (the `connection-manager` feature is already enabled) instead of a MultiplexedConnection. ConnectionManager transparently re-establishes the underlying link after a transient failure, so a dropped connection recovers on the next command. Command call sites are unchanged (ConnectionManager implements the same async command traits); added a double-checked cache set under the write lock to avoid a redundant manager on a race. Root cause: a permanently-cached connection with no invalidation. Verified with `cargo build` and `cargo test` (328 passed). No hermetic seam for live reconnection without a Redis server, so no unit test is added — stated explicitly. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01RAxLsaxtwVNDTWAZFfJp9q
`.github/workflows/repo-checks.yml` runs `check_isinstance_return_ratchet.py`, but #9458 ("unify deterministic checks behind manifest") never registered it in `.github/checks-manifest.yaml`, so the manifest drift-guard contract (`test_workflow_checks_are_registered_or_exempt`) fails on `main` — blocking every PR's `scripts/pr-preflight` and the Hygiene job. This is pre-existing main breakage, not introduced by the batch-7 fixes in this PR. It is a full-tree backend baseline ratchet invoked with no diff args, so it belongs in the `exempt` list alongside the other full-tree, not-diff-scoped checks. Verified `scripts/pr-preflight` now passes (13 checks). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01RAxLsaxtwVNDTWAZFfJp9q
eulicesl
marked this pull request as ready for review
July 12, 2026 02:47
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes three low-severity but user-visible/ops-impacting issues across the macOS desktop app and its Rust backend, plus unblocks CI by correcting deterministic-check manifest drift.
Changes:
- Correct SD-card sync throughput calculation by tracking byte deltas over real elapsed intervals, and add regression tests for the rate seam.
- Prevent unbounded notification metadata growth by adding a FIFO eviction cap with unit tests.
- Make Rust Redis usage resilient to transient disconnects by switching the cached connection type to
ConnectionManager, and exempt a pre-existing full-tree check in the CI manifest.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| desktop/macos/Desktop/Sources/WAL/StorageSyncService.swift | Fixes throughput math by computing B/s from (bytesDelta, interval) and resets progress counters appropriately. |
| desktop/macos/Desktop/Tests/StorageSyncThroughputTests.swift | Adds regression tests for the pure throughput helper (non-zero rate, zero/negative interval). |
| desktop/macos/Desktop/Sources/ProactiveAssistants/Services/NotificationService.swift | Adds bounded FIFO eviction for notification metadata and cleans up order tracking on interaction/error. |
| desktop/macos/Desktop/Tests/NotificationMetadataEvictionTests.swift | Adds tests validating eviction behavior (beyond cap / under cap / exactly to cap). |
| desktop/macos/Backend-Rust/src/services/redis.rs | Switches cached Redis connection to ConnectionManager to allow transparent reconnection. |
| .github/checks-manifest.yaml | Exempts check_isinstance_return_ratchet.py as a full-tree baseline check to resolve manifest drift. |
| desktop/macos/changelog/unreleased/20260712-sdcard-sync-speed-readout.json | Adds a macOS changelog entry for the SD-card sync speed readout fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Git-on-my-level
added a commit
that referenced
this pull request
Jul 13, 2026
## 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. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9592?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
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.
Summary
Batch 7 of the macOS bug sweep — clearing the confirmed low-severity deferrals surfaced by the batch-6 second-pass hunt, each personally re-verified against the source. Three fixes, each low-risk with a regression test where a hermetic seam exists.
This is likely the last substantive sweep PR: a fresh deep review of the previously-unswept surfaces (onboarding, settings, Sparkle/update, MCP OAuth, menu-bar/window lifecycle) turned up no confirmed user-affecting bugs, and the BYOK-vs-session-401 suspicion resolved to a false alarm (the Python backend returns 403, never 401, for BYOK failures) — so the findings are converging.
Fixes
1. SD-card sync always showed 0 B/s
StorageSyncService.updateProgressreassignedlastProgressUpdate = nowon the line before computingelapsed = now - lastProgressUpdate, soelapsedwas always 0 andbytesPerSecondalways 0 — the SD-card sync UI never showed a real speed/ETA. Now computes the rate over the real elapsed interval using the bytes downloaded in that window (via a purebytesPerSecond(bytesDelta:interval:)seam), trackinglastProgressBytesand resetting it with the rest of the progress state at sync start/stop.2. Notification metadata grew unbounded
NotificationService.notificationMetadataadded one entry per delivered functional banner but only removed it in thedidReceivedelegate, which fires solely on user interaction. A banner the user never touches leaked its entry for the life of the process. Now tracks insertion order and FIFO-evicts past a 200-entry cap (pure genericevictOldestMetadata), with matching removal from the order list on the interaction/error paths.3. Redis rate limiter failed open permanently after a link drop (Rust)
RedisServicecached a bareMultiplexedConnectionand returned that clone forever with no reconnect path. Once the Redis link dropped, every command errored, and the rate limiter (fail-open by design) stopped enforcing limits entirely until restart. Now caches aConnectionManager(theconnection-managerfeature was already enabled), which transparently reconnects after a transient failure. Command call sites unchanged.Root cause & durable guards
ConnectionManagerauto-reconnect. No hermetic seam for live reconnection without a Redis server, so no unit test; verified withcargo build+cargo test(328 passed).Testing
cargo test(Backend-Rust) — 328 passed, 0 failed.python3 scripts/check_desktop_test_quality.py— OK (debt decreased).python3 scripts/check-sources-root-layout.py— OK.python3 scripts/check-e2e-flow-coverage.py --strict— both changed Swift files covered.scripts/pr-preflight— 13 checks pass.desktop-swift-ci.yml). Opened as a draft for local verification before landing.Product invariants affected
Deferred / tracked (not fixed here)
.defaultpolicy, which violates the documentedAGENTS.md"Session 401 vs BYOK/provider 401" contract. It is currently unreachable (the backend returns 403, never 401, for BYOK failures), so it is not an active bug. The contract-aligned fix (route the upload through.providerCredentialBoundary, mirroringsynthesizeSpeech) changes real session-invalidation behavior and was deliberately kept out of this low-risk PR — tracked as defense-in-depth for a focused follow-up.WALService.totalFramesdouble-count on repeated failed writes; audio stop-path converter release ordering;RealtimeOmniService.pendingAudiouncap;RewindIndexerrebuild over-count; deferred-update install overwrite edge case.Also included: pre-existing CI unblock
A separate commit registers
check_isinstance_return_ratchet.pyin.github/checks-manifest.yaml. That script is run byrepo-checks.ymlbut was never added to the manifest when #9458 unified checks, so the manifest drift-guard fails onmainand blocks every PR'spr-preflight/Hygiene. Pre-existing breakage, not caused by the batch-7 fixes; added here to unblock this (and every) PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01RAxLsaxtwVNDTWAZFfJp9q
Generated by Claude Code