Repository navigation
fix(app): keep WAL until the device confirms deletion - #15156
Merged
Merged
Conversation
## Summary
- Deleted device recordings could resurrect ("I try to delete the files
but they come back", evidence: #14688): both device WAL syncs dropped
the WAL from the app list before the device-side delete was confirmed,
so a failed clear (no connection, BLE error, NACK) left the audio on
the device and the next sync re-imported it as a new recording.
- ring_storage_sync: _clearRingOnDevice now returns whether clearRing()
was confirmed; deleteWal / deleteAllPendingWals keep the WAL
(fail-closed) unless the device confirmed the clear. Absent device or
absent connection counts as failure. The documented single-stream
quirk (deleting one ring WAL clears the whole ring) is unchanged.
- sdcard_wal_sync: deleteWal removes the WAL only after
writeToStorage(delete) is accepted AND a getStorageList readback shows
totalBytes dropped below the WAL's discovered size. Rejected write,
ambiguous (empty) readback, or unchanged readback keeps the WAL. The
cascades (deleteAllSyncedWals / deleteAllPendingWals) inherit the
semantics per item: a failed item survives, the rest of the batch
proceeds.
- No UI changes: a failed delete simply leaves the item in the list.
## Failure-Class
Failure-Class: none
## Verification
- TZ=UTC bash app/test.sh — green (2413 tests), including the spine
c1_* acceptance contracts; analyze ratchet passed.
- New test/unit/wal_delete_durability_test.dart drives the real delete
paths through a scripted DeviceConnection: confirmed clear removes the
WAL; rejected command, unconfirmed readback, absent device, and no
connection each keep it; cascade partial-failure keeps the failed
item. No live Omi device on this host — BLE behavior is exercised via
the connection seam, the repo's hermetic-test pattern for this path.
Co-authored-by: multica-agent <[email protected]>
## Summary - Follow-up to review of #15156: sdcard deleteWal() still removed the WAL when _device was null or the WAL belonged to a different device than the active one — no delete command attempted, no readback, WAL gone from the app list. Delete-while-disconnected is the resurrection path from #14688 (evidence only); acceptance criterion 2 requires a no-connection delete to keep the WAL. - deleteWal() now treats an absent or mismatched owning device as unconfirmed and keeps the WAL (fail-closed, same semantics as the ring path). - Inverted the old fire-and-forget assertion in wal_delete_cascade_test.dart (a stale-device sdcard recording now stays until its own device confirms the delete) and added absent- device and mismatched-device cases to wal_delete_durability_test.dart. ## Failure-Class Failure-Class: none ## Verification - TZ=UTC bash app/test.sh — green (2415 tests), spine c1_* included; analyze ratchet passed; formatting clean (pinned toolchain, 0 churn). - Focused suites all pass: wal_delete_durability_test.dart (13 cases), wal_delete_cascade_test.dart, sdcard_legacy_sync_test.dart. Co-authored-by: multica-agent <[email protected]>
Git-on-my-level
deleted the
agent/m1-studio-omp-glm-5-3/53cc04905e61
branch
September 20, 2026 14:28
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.
Why
Deleted device recordings could resurrect: "I try to delete the files but they come back" (community signal: #14688 — referenced as evidence only; that issue tracks three symptoms and stays open for the team). Both device WAL syncs dropped the WAL from the app list before the device-side delete was confirmed:
ring_storage_sync.dartdeleteWal()called_clearRingOnDevice(), which logged theclearRing()result and returned void; the WAL was then removed unconditionally. A failed clear (no connection, BLE error, NACK) left the audio on the device ring, and the next sync re-imported it as a "new" recording.sdcard_wal_sync.dartdeleteWal()removed the WAL from memory first, then firedwriteToStorage(fileNum, 1, 0)and ignored the result. That bool is only "BLE write accepted", not "file deleted"; on disconnect or failure the file stayed on the card andstart()→_getMissingWals()re-imported it. It also dropped the WAL outright when its owning device was absent or a different device was active — delete-while-disconnected with no command and no readback.What changes
Deletion is now transactional, fail-closed on both paths — a WAL leaves the app list only after the device-side delete is confirmed:
ring_storage_sync.dart:_clearRingOnDevice()returns whetherclearRing()was confirmed (absent device, missing connection, BLE error, and rejected command all return false).deleteWal()/deleteAllPendingWals()keep the WAL unless the clear was confirmed. The documented single-stream quirk (deleting one ring WAL clears the entire ring) is unchanged.sdcard_wal_sync.dart:deleteWal()removes the WAL only when its owning device is the active device and the delete command is accepted and agetStorageListreadback showstotalBytesdropped below the WAL's discovered size. An absent or mismatched owning device, a rejected write, an ambiguous (empty) readback, or an unchanged readback keeps the WAL — same fail-closed semantics as the ring path. The cascades (deleteAllSyncedWals/deleteAllPendingWals) inherit the semantics per item — a failed item survives while the rest of the batch proceeds._walsfrom actual device state, so an item whose bytes are really gone disappears then; the resurrection path no longer exists.Scope
Diff confined to
app/lib/services/wals/**andapp/test/**(one new test file, one inverted legacy assertion). No firmware, tombstones, timestamp/import, mute, or sync-scheduling changes.Failure-Class
Failure-Class: none
Verification
TZ=UTC bash app/test.sh— green (2415 tests), including the spinec1_*acceptance contracts;analyze_ratchet.shpassed; touched files formatted with the pinned toolchain (pre-commit hook, 0 churn).app/test/unit/wal_delete_durability_test.dart(13 cases) drives the realdeleteWal/deleteAllPendingWalspaths through a scriptedDeviceConnection(the repo's hermetic seam for this path): confirmed delete removes the WAL; rejected ring clear, absent device, no connection, absent/mismatched owning device (sdcard), rejected delete command, readback that still shows the bytes, and empty (unconfirmable) readback each keep it; cascade partial-failure keeps the failed item and removes the confirmed one.wal_delete_cascade_test.dart's stale-device assertion was inverted to the fail-closed contract; its sync-phase and cascade-guard tests are unchanged and still pass.