Repository navigation
fix(app): stop legacy SD sync on ring-buffer pendant firmware - #24678
Conversation
Gate SD discovery and downloads on resolved firmware. Fail rejected reads immediately and suppress retries until reconnect, while preserving device recordings. Log capture fail-closed reasons and document Home card visibility findings. Failure-Class: FC-protocol-status-mapped-to-wrong-cause
Keep failed firmware reads unknown and retryable, then re-route the existing WAL attachment when firmware resolves. Require confirmed legacy firmware before legacy SD attachment and reads. Capture SD ACK rejection per read before asynchronous stream cancellation so disconnect cannot erase failure or mark the recording synced. Cover firmware resolution and both SD reader cancellation races with hermetic tests.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
6 issues found across 15 files
Confidence score: 3/5
wal_syncs.darttreats firmware 3.0.17–3.0.19 as legacy SD even though those versions use the multi-file LittleFS path. Limit the legacy predicate to versions below 3.0.1.device_provider.dartcan still attach SD sync when the firmware read is empty, becauseWalSyncsmay fall back to the raw connect object's firmware value. Avoid routing on unverified firmware.wal_syncs.dartcan race a disconnect or firmware retry: an in-flight SD enumeration may access a cleared device or restore stale legacy WALs after switching to ring firmware. Serialize the route change or discard results from an outdated route.device_provider_test.dartraces the asynchronous SD reroute againsttestWalsinjection, making the test order-dependent. Use a synchronous fake or await a deterministic completion point.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/docs/ring-firmware-legacy-sd-sync.md">
<violation number="1" location="app/docs/ring-firmware-legacy-sd-sync.md:75">
P3: The verification summary says analysis covered “all nine touched Dart files,” but this PR touches 13 Dart files. Update the count or state the exact analysis path set so the verification record is accurate.</violation>
<violation number="2" location="app/docs/ring-firmware-legacy-sd-sync.md:77">
P3: The document references an uncommitted artifact directory for the full verification commands and output, but that directory is not part of the PR. Commit the reproducibility details or remove this reference and summarize the commands here.</violation>
</file>
<file name="app/lib/services/wals/wal_syncs.dart">
<violation number="1" location="app/lib/services/wals/wal_syncs.dart:51">
P2: This unawaited route change can race a disconnect or firmware retry: the in-flight SD enumeration can dereference a cleared device or repopulate stale legacy WALs after the device has switched to ring firmware. Serialize/cancel the enumeration and generation-check its result before publishing it.</violation>
<violation number="2" location="app/lib/services/wals/wal_syncs.dart:66">
P1: `_usesLegacySdcard` still classifies firmware 3.0.17–3.0.19 as legacy SD, although `syncAll` documents those versions as the multi-file LittleFS path. Require the legacy predicate to be limited to versions below 3.0.17, and use that same predicate in `SDCardWalSyncImpl`.</violation>
</file>
<file name="app/test/providers/device_provider_test.dart">
<violation number="1" location="app/test/providers/device_provider_test.dart:88">
P2: This test races the asynchronous legacy SD re-route with the `testWals` injection, so it can fail or pass depending on whether the BLE lookup overwrites `_wals` first. Use a synchronous spy/fake SD sync or await a controllable re-route before injecting and asserting the fixture.</violation>
</file>
<file name="app/lib/providers/device_provider.dart">
<violation number="1" location="app/lib/providers/device_provider.dart:1180">
P2: This routing is not fail-closed when the firmware read returns empty: `WalSyncs` can fall back to the raw connect object's legacy version and attach SD sync. Do not pass an unverified raw firmware value into the legacy gate when the enriched read failed.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
|
||
| bool get _usesLegacySdcard { | ||
| final firmware = _resolvedFirmware; | ||
| return firmware != null && firmware.isNotEmpty && firmware != 'Unknown' && !isRingBufferFirmware(firmware); |
There was a problem hiding this comment.
P1: _usesLegacySdcard still classifies firmware 3.0.17–3.0.19 as legacy SD, although syncAll documents those versions as the multi-file LittleFS path. Require the legacy predicate to be limited to versions below 3.0.17, and use that same predicate in SDCardWalSyncImpl.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/wals/wal_syncs.dart, line 66:
<comment>`_usesLegacySdcard` still classifies firmware 3.0.17–3.0.19 as legacy SD, although `syncAll` documents those versions as the multi-file LittleFS path. Require the legacy predicate to be limited to versions below 3.0.17, and use that same predicate in `SDCardWalSyncImpl`.</comment>
<file context>
@@ -47,6 +47,23 @@ class WalSyncs implements IWalSync {
+
+ bool get _usesLegacySdcard {
+ final firmware = _resolvedFirmware;
+ return firmware != null && firmware.isNotEmpty && firmware != 'Unknown' && !isRingBufferFirmware(firmware);
}
</file context>
| storage: WalStorage.sdcard, | ||
| device: device.id, | ||
| fileNum: 1); | ||
| syncs.sdcard.testWals = [phantom]; |
There was a problem hiding this comment.
P2: This test races the asynchronous legacy SD re-route with the testWals injection, so it can fail or pass depending on whether the BLE lookup overwrites _wals first. Use a synchronous spy/fake SD sync or await a controllable re-route before injecting and asserting the fixture.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/providers/device_provider_test.dart, line 88:
<comment>This test races the asynchronous legacy SD re-route with the `testWals` injection, so it can fail or pass depending on whether the BLE lookup overwrites `_wals` first. Use a synchronous spy/fake SD sync or await a controllable re-route before injecting and asserting the fixture.</comment>
<file context>
@@ -41,6 +56,40 @@ void main() {
+ storage: WalStorage.sdcard,
+ device: device.id,
+ fileNum: 1);
+ syncs.sdcard.testWals = [phantom];
+ expect(await syncs.getMissingWals(), firmware == '3.0.21' ? isNot(contains(phantom)) : contains(phantom));
+ });
</file context>
| final syncs = ServiceManager.instance().wal.getSyncs(); | ||
| syncs.setDevice(device, firmwareVersion: currentFirmwareVersion); | ||
| syncs.sdcard.setDevice(device); | ||
| // WalSyncs attaches legacy SD only for confirmed legacy firmware. |
There was a problem hiding this comment.
P2: This routing is not fail-closed when the firmware read returns empty: WalSyncs can fall back to the raw connect object's legacy version and attach SD sync. Do not pass an unverified raw firmware value into the legacy gate when the enriched read failed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/providers/device_provider.dart, line 1180:
<comment>This routing is not fail-closed when the firmware read returns empty: `WalSyncs` can fall back to the raw connect object's legacy version and attach SD sync. Do not pass an unverified raw firmware value into the legacy gate when the enriched read failed.</comment>
<file context>
@@ -1169,7 +1177,7 @@ class DeviceProvider extends ChangeNotifier implements IDeviceServiceSubsciption
final syncs = ServiceManager.instance().wal.getSyncs();
syncs.setDevice(device, firmwareVersion: currentFirmwareVersion);
- syncs.sdcard.setDevice(device);
+ // WalSyncs attaches legacy SD only for confirmed legacy firmware.
syncs.flashPage.setDevice(device);
syncs.storage.setDevice(device);
</file context>
| _device = device; | ||
| _firmwareVersion = firmwareVersion; | ||
| // Ring status shares the legacy characteristic but has a different layout. | ||
| _sdcardSync.setDevice(_usesLegacySdcard |
There was a problem hiding this comment.
P2: This unawaited route change can race a disconnect or firmware retry: the in-flight SD enumeration can dereference a cleared device or repopulate stale legacy WALs after the device has switched to ring firmware. Serialize/cancel the enumeration and generation-check its result before publishing it.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/wals/wal_syncs.dart, line 51:
<comment>This unawaited route change can race a disconnect or firmware retry: the in-flight SD enumeration can dereference a cleared device or repopulate stale legacy WALs after the device has switched to ring firmware. Serialize/cancel the enumeration and generation-check its result before publishing it.</comment>
<file context>
@@ -47,6 +47,23 @@ class WalSyncs implements IWalSync {
_device = device;
_firmwareVersion = firmwareVersion;
+ // Ring status shares the legacy characteristic but has a different layout.
+ _sdcardSync.setDevice(_usesLegacySdcard
+ ? (device?.firmwareRevision == _resolvedFirmware
+ ? device
</file context>
| recording lifecycle and device late-ready suites passed (174 tests). Analysis | ||
| passed for all nine touched Dart files, and formatting passed at 120 columns. | ||
| The coordinator suite includes 2,000 seeded ownership sequences. Full command | ||
| lines and local output are in the uncommitted `app/.agent-artifacts/ringsync/` |
There was a problem hiding this comment.
P3: The document references an uncommitted artifact directory for the full verification commands and output, but that directory is not part of the PR. Commit the reproducibility details or remove this reference and summarize the commands here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/docs/ring-firmware-legacy-sd-sync.md, line 77:
<comment>The document references an uncommitted artifact directory for the full verification commands and output, but that directory is not part of the PR. Commit the reproducibility details or remove this reference and summarize the commands here.</comment>
<file context>
@@ -0,0 +1,78 @@
+recording lifecycle and device late-ready suites passed (174 tests). Analysis
+passed for all nine touched Dart files, and formatting passed at 120 columns.
+The coordinator suite includes 2,000 seeded ownership sequences. Full command
+lines and local output are in the uncommitted `app/.agent-artifacts/ringsync/`
+handoff. These checks verify app logic, not physical audio/button delivery.
</file context>
|
|
||
| The focused firmware-routing, SD custody/packet/delete, capture coordinator, | ||
| recording lifecycle and device late-ready suites passed (174 tests). Analysis | ||
| passed for all nine touched Dart files, and formatting passed at 120 columns. |
There was a problem hiding this comment.
P3: The verification summary says analysis covered “all nine touched Dart files,” but this PR touches 13 Dart files. Update the count or state the exact analysis path set so the verification record is accurate.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/docs/ring-firmware-legacy-sd-sync.md, line 75:
<comment>The verification summary says analysis covered “all nine touched Dart files,” but this PR touches 13 Dart files. Update the count or state the exact analysis path set so the verification record is accurate.</comment>
<file context>
@@ -0,0 +1,78 @@
+
+The focused firmware-routing, SD custody/packet/delete, capture coordinator,
+recording lifecycle and device late-ready suites passed (174 tests). Analysis
+passed for all nine touched Dart files, and formatting passed at 120 columns.
+The coordinator suite includes 2,000 seeded ownership sequences. Full command
+lines and local output are in the uncommitted `app/.agent-artifacts/ringsync/`
</file context>
Only confirmed ring firmware short-circuits SDCardWalSyncImpl. Unknown firmware is already kept detached by WalSyncs, so the inner guard no longer hides cached legacy WALs after disconnect or for devices with no reported revision. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requested by David
What changed and why
User report: "Omi pendant connects but sends no audio or button events" (firmware 3.0.21, app 1.0.585). The app attached the legacy SD-card sync to every device, so ring-buffer firmware (>= 3.0.20) still ran the legacy listing. It read the ring status characteristic (
[used, unread, free, rtc_valid]) as[total, offset, start_ts], invented a phantom recording, sent legacy opcode 0x00, ignored the firmware's01 06invalid-command ACK, and stalled ("SD card read stalled") on every connect.1.0.2, which counted as known legacy firmware. It stays unknown, so legacy SD stays detached, the device-info retry runs, and a successful retry re-routes the attached device.app/docs/ring-firmware-legacy-sd-sync.md). No firmware-gated visibility in the capture card path. Side effect worth noting: the "Teach Omi your voice" card hid when firmware was1.0.2, so failed DIS reads also hid it. With the unknown fallback it now shows for those devices.Product invariants affected
INV-CAP-1: touches pendant sync routing and capture logging. Upholds it: ring firmware audio stays in the ring for the ring sync to drain, a rejected legacy read keeps the recording (never marked synced or deleted), and capture logging changes no behavior.
How it was verified
flutter test --no-pubon the touched suites (174 tests on the first commit, 88 on the follow-up), all passing.flutter analyze --no-pubon touched files: no new diagnostics (one existing info lint atbt_device.dart:312).dart format --line-length 120clean;make preflight29/29.Tests
test/services/wals/wal_syncs_firmware_routing_test.dart: ring firmware never consults SD sync; legacy unchanged; unknown firmware defers, then re-routes after resolution.test/unit/sdcard_custody_sync_test.dart,test/unit/sdcard_legacy_sync_test.dart: non-zero ACK is terminal, including disconnect during cancellation; recording retained.test/providers/device_provider_test.dart,test/unit/omi_connection_serial_number_test.dart: failed DIS read stays unknown and retries.test/unit/recording_lifecycle_telemetry_test.dart,capture_coordinator_test.dart: fail-closed reasons logged.UI evidence
UI-Evidence: none -- no UI code changed; routing, sync and logging only.
Failure class (fixes)
Failure-Class: none
Scoped cleanups (optional)
Line-Count-Exception: app/lib/providers/device_provider.dart | 1695 -> 1703 | firmware re-route after device-info retry; part of the fix
Line-Count-Exception: app/lib/services/capture/capture_coordinator.dart | 2964 -> 2971 | fail-closed reason logging requested by the report
🤖 Generated with Claude Code