Skip to content

Fix SD-card sync 0 B/s readout, notification-metadata leak, Redis fail-open + CI manifest drift (bug sweep #7) - #9522

Merged
eulicesl merged 4 commits into
mainfrom
claude/macos-bug-fixes-testing-i8z7cm
Jul 12, 2026
Merged

eulicesl merged 4 commits into
mainfrom
claude/macos-bug-fixes-testing-i8z7cm

Conversation

@eulicesl

@eulicesl eulicesl commented Jul 12, 2026 •

Copy link
Copy Markdown
Collaborator

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.updateProgress reassigned lastProgressUpdate = now on the line before computing elapsed = now - lastProgressUpdate, so elapsed was always 0 and bytesPerSecond always 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 pure bytesPerSecond(bytesDelta:interval:) seam), tracking lastProgressBytes and resetting it with the rest of the progress state at sync start/stop.

2. Notification metadata grew unbounded

NotificationService.notificationMetadata added one entry per delivered functional banner but only removed it in the didReceive delegate, 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 generic evictOldestMetadata), with matching removal from the order list on the interaction/error paths.

3. Redis rate limiter failed open permanently after a link drop (Rust)

RedisService cached a bare MultiplexedConnection and 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 a ConnectionManager (the connection-manager feature was already enabled), which transparently reconnects after a transient failure. Command call sites unchanged.

Root cause & durable guards

  • Client #1 read-after-write ordering on the interval timestamp → pure testable rate function + regression tests (real-rate / non-zero / zero-and-negative interval).
  • colors to the LED board #2 a side-table whose only removal path depended on optional user action → bounded FIFO eviction + regression tests (evict-beyond-cap / no-eviction-under-cap / exact-to-cap).
  • Add printing BLE device address to serial monitor #3 a permanently-cached connection with no invalidation → ConnectionManager auto-reconnect. No hermetic seam for live reconnection without a Redis server, so no unit test; verified with cargo 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.
  • No Swift toolchain in this environment; the new XCTest cases compile/run on macOS CI (desktop-swift-ci.yml). Opened as a draft for local verification before landing.

Product invariants affected

  • none (no locked-invariant path globs touched).

Deferred / tracked (not fixed here)

  • BYOK→session-401 contract hardening (latent, not an active bug). The WAL upload attaches BYOK keys under the session-invalidating .default policy, which violates the documented AGENTS.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, mirroring synthesizeSpeech) 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.
  • Remaining low/suspected batch-6 findings: WALService.totalFrames double-count on repeated failed writes; audio stop-path converter release ordering; RealtimeOmniService.pendingAudio uncap; RewindIndexer rebuild over-count; deferred-update install overwrite edge case.

Also included: pre-existing CI unblock

A separate commit registers check_isinstance_return_ratchet.py in .github/checks-manifest.yaml. That script is run by repo-checks.yml but was never added to the manifest when #9458 unified checks, so the manifest drift-guard fails on main and blocks every PR's pr-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

Review in cubic

claude added 4 commits July 12, 2026 02:41
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
eulicesl requested a review from Copilot July 12, 2026 02:47
@eulicesl
eulicesl marked this pull request as ready for review July 12, 2026 02:47
@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eulicesl
eulicesl merged commit 2fc74af into main Jul 12, 2026
24 of 27 checks passed
@eulicesl
eulicesl deleted the claude/macos-bug-fixes-testing-i8z7cm branch July 12, 2026 15:38
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. -->
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.

3 participants