Repository navigation
fix(pendant): stop status polls writing the SD card on 3.0.24, and read the ring in bounded, credited ranges - #25415
Merged
Merged
Conversation
On 3.0.24 one pendant drained about 2.5 times faster than on 3.0.21. While a phone is connected the storage worker refreshes the status characteristic every 250 ms through sd_ring_get_info(), which commits the buffered batch before answering. 3.0.21 buffered nothing while connected, so that was free. With live persist there is always a buffered batch, and each poll rewrote the whole 16 KiB batch plus a metadata sector with two media syncs: about four card writes a second for the whole connection. - Status polls use sd_ring_peek_info(), answered from RAM with the SD host left suspended. CMD_RING_INFO and the start of a READ still commit first. - A partly filled batch whose records were all sent live may wait four seconds for more audio. A record the phone was not sent is still written within one second of arriving. Either edge of the link flushes at once. - The storage worker sleeps until a command, a stop or a live mark wakes it, instead of polling every millisecond while connected. The custody, SD-ring and storage host harnesses ran in no CI lane and did not build on Linux (-I let src/lib/core/features.h shadow glibc's). They now build with -iquote and run as cv1-ring-custody-host. Not measured: current draw. That needs the jig. Failure-Class: new Co-Authored-By: Claude Fable 5.2 <[email protected]>
On firmware 3.0.24 one phone downloaded 440,500 ring records in eight hours and was credited for 194,000. The backlog grew instead of clearing, and the pendant spent that time transmitting at full rate. One read ran from the read pointer to the write head under a 30 minute timeout. BLE delivered about 68 records a second; the phone stored a chunk every 8 s at first and every 150 s half an hour in. Whatever was still in memory when the link dropped was stored without credit and fetched again. - Proof checks reloaded the whole recording index once per referenced file, and proofs were kept after the pendant released them, so each chunk re-checked every earlier one. A check now reads the index once, and an acknowledged advance drops the proofs below it. - With app-owned reclaim and a ring id, a pass reads 2,700 records at a time, stores them, advances the pendant, then asks for the next range. A dropped link costs at most the range in flight. - A lost advance acknowledgement is settled by asking for the read pointer, not by failing the pass and reading the range again. - With live persist the ring always holds audio the live proof is about to release. A pass reads only up to the connection's first live mark, which is as far as a live proof cannot reach, and does not start at all once the read pointer is past it and marks reach the write head. Firmware without those capabilities, 3.0.21 and earlier, keeps the single read and single advance it had. Failure-Class: none Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review of the previous commit: a disconnect queues a flush on the priority queue, which the SD worker serves before the write queue. A record sent just before the disconnect could reach the batch after that flush had run, carry a live session, and wait on the four-second interval although nothing shows the phone received it. The longer interval now applies only while the link is up. With no link every record is back on the one-second bound, so that record is written within a second of reaching the batch. Failure-Class: none Co-Authored-By: Claude Fable 5.2 <[email protected]>
…reads Review of the bounded-read commit found two faults in it. The live-tail rule accepted a write head within two batches of the last mark. An unsent batch followed by silence sat inside that slack: no mark would ever follow, nothing else moved the ring, and every sync skipped it until the next reconnect. The pendant marks every commit of an unbroken live run at the committed write position, so the comparison is now exact, taken a moment after INFO so the mark for that commit can arrive. Each bounded read restarted the estimated clock run and start time used when the pendant has no usable clock. One recording became several, each later part shifted by the transfer time. That state now carries across the reads of a pass and restarts only where records were released unread. Failure-Class: none Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Nov 15, 2026
…one proof; recover bad capture dates; storage inventory in Diagnostics (#25405) # Drain pendant safety copies only after exact phone custody is durable Failure-Class: new Main PR #25415 already delivered bounded 2,700-record reads, credit before the next READ, live-tail avoidance, shared clock continuity across windows, lost-ADVANCE acknowledgement settlement through INFO, and batched index validation with spent-proof retirement. Its firmware status-poll/buffering changes are also already on main. This PR uses that windowed reader as its base; it adds the missing phone-custody safeguards, interrupted-tail recovery, batch-route proof, bad-date import guard and read-only Diagnostics inventory. Base: origin/main `9c93fa0b2d85fb1232f31fe3f5b88a19a4c406e7`; combined head: `4958743c0142ed8e86d510bcceb9d5de13ec07c0`. Both merges were normal, explicitly reconciled in the two services and custody contract. There is no firmware or executable server diff against this main. Pinned main still accepts unscoped foreign-owner references, corrupted indexed rows, same-length replacement bytes and empty proof lists without files/indexes. A hermetic probe using its exact custody module produced five expected safety failures (including positive-memo revocation) and one passing changed-ring control. The fixes here retain nonempty owner/device-scoped, content-bound exact coordinates and reject those cases. Main's positive whole-window file-result memo is replaced by index-row reuse with fresh overlapping byte checks before every skip and ADVANCE; its index-load and retirement bounds remain tested. One reader owner covers the entire bounded-window pass through source-connection STOP, queued notifications, indexed persistence and final acknowledgement. Immutable downloaded ranges survive reconnect and restart; exact indexed receipts replay before READ, including an interrupted partial tail, without creating a second recording file. ACKed proof candidates are retired from subsequent ADVANCE work; only freshly revalidated released live refs remain eligible for an in-flight duplicate skip. Download receipt journals remain until fresh INFO confirms the read pointer. Progressing recovery-ON windows have no fixed 5/30-minute completion cap; silence and a separate 45-second persistence-progress deadline stop stalls. Firmware without app-owned reclaim keeps main's single unbounded READ and anonymous completion ACK. The app follows main's window/credit pacing; no additional live-dependent per-chunk sleep is added. Historical unmapped live copies still cannot be reclaimed by inference. Batch capture preserves the original live session/ring identity and contiguous ordinals only for packets it accepts. Its fsynced checkpoint journal survives restart; publication waits for the exact file prefix and persisted WAL index. Declined packets take the ordinary capture path once. Muting, packet gaps/reordering, new epochs, old firmware and disk failures never widen proof. R16 corrections require nonempty owner/device-scoped, content-bound references for replay, ADVANCE and duplicate suppression. Ownerless/legacy/hashless proofs, foreign accounts, corrupted WAL rows, missing indexes and changed bytes fail closed. SHA-256 uses the existing upload content-digest scheme. Empty packed records have a canonical fsynced, indexed zero-duration marker before reclaim; an empty reference list cannot authorize a range. The persistence deadline remains active after DATA/DONE and only completed indexed progress renews persistence/coordinator progress. A truly stuck OS write retains ownership until it settles or the process restarts. Previously duplicated audio files are preserved; different filenames are not assumed to receive generic server deduplication. R16b correction: valid decoded ring audio is persisted even when the phone clock or unread-duration estimate is unusable (including a zero-duration estimate). Estimate construction and the flush plausibility check now downgrade only metadata to explicit unknown time (`timerStart = 0` plus the existing clock-run token). They cannot reject a file/index write. The original bytes, owner/device scope, digest and exact ring coordinates still authorize reclaim. Unknown time is not a claim about a calendar capture date or successful server processing. Clock-switch OFF retains the old estimate arithmetic and elapsed offsets. R16b bounded validation: each owned READ window takes one persisted-index snapshot and refreshes it after its own indexed write. DATA checks only proof ranges overlapping its complete record interval; it does not parse the full index or hash unrelated proof files. Same-operation references are deduplicated; positive file hashes are never cached between notifications or ADVANCE decisions. Every production index writer, including the worker, recovery and clear paths, revokes prior snapshots before mutation. A revoked snapshot cannot suppress or acknowledge audio; it does not erase the existing receipt. Independent account, epoch and content fences stay in force. Tests use 10,002 index rows and a 10,001-row fake-pendant READ to count index loads/hashes, verify fresh replacement-byte rejection, and ensure only the gap creates a file. Q12-AC's guard admits device dates from 2024-01-01 through phone now +24h inclusive. New ring, LittleFS and Dart Limitless imports outside that window receive an estimated time and explicit clock-run token when the phone is a plausible reference. Raw clock resets remain separate runs. Estimates affect import grouping/naming but never substitute for device/ring/session/sequence/ordinal proof keys or indexed byte custody. Existing WALs are not renamed or migrated. Native Limitless writers and the pendant's original clock-error generator remain outside this fix. The existing Diagnostics JSON gains bounded ring state, RTC observations, protocol history and a local recording inventory: active/retired/foreign memory buckets, raw indexes/backups/quarantines/temporary files, batch journals, ownership receipt counts, loader outcomes, file totals, missing references and uncertain orphans. Large aggregation runs off the UI isolate. It invokes no loader, repair, migration, custody validation or ADVANCE and reads no audio. The export marks unavailable/concurrent sources incomplete and does not export WAL names, paths, owner values or audio bodies. Existing outer device diagnostics identifiers remain; bounded ring coordinates and eight-byte record prefixes are diagnostic metadata. ## Safety and failure classification INV-CAP-1: `product/invariants/pendant-audio-retention.md`; custody contracts: `app/lib/services/wals/CUSTODY.md` and `app/lib/services/wals/PENDANT_RING_CUSTODY.md`. File fsync AND persisted index precede exact-range validation and ADVANCE. Retry/account fences remain. Invalid or partial proof retains the pendant copy for re-download. Timestamp estimates and clock-run tokens never authorize reclaim. This range adds exactly one registry definition, FC-phone-durable-pendant-proof. Its batch, interrupted-download and R16 tests are the prevention artifacts. AC's importer work is also an instance of the existing FC-sync-capture-time-zero-tolerance; that definition is unchanged. The installed protocol permits only one Failure-Class declaration, so the single `new` declaration covers the added definition and this paragraph records the existing class. Both classes remain represented in the individual commit trailers. ## Validation Main's window/cost suite passes 26 tests, including four new window-boundary metadata cases. AA reader/receipt suites pass 62 with two skips; the broader custody/live/batch/coordinator/diagnostics suites pass 154. Capture-clock-OFF passes 88 with two skips; all three switches OFF passes 28 with 13 intentional skips. Changed-service/window-test analysis is clean. The foreign legacy downloaded-receipt test from fork commit `ce0364da11afbc98b664c86a1366a735a19fef68` is retained: it tests downloaded `ring_ranges`, distinct from the ownerless `live_ranges` checkpoint case, and its complete file passed formatting and execution. The final committed head is qualified with the full app suite, all journeys, standalone preflight and the installed pre-push hook. Terminal results, exact head/body hashes, the reconciliation table and pinned-main red-probe evidence are recorded in `q12-aa-ring-proof.md` and `evidence/q12-aa/main-reconciliation/`. Commands: `cd app && bash test.sh --concurrency=4`; `make mobile-verify ARGS="fast --all"`; `make preflight`; `OMI_PR_BODY_FILE=<this body> BACKEND_UNIT_FILE_BUDGET_SECONDS=900 "$(git rev-parse --git-path hooks/pre-push)" origin "$(git remote get-url origin)" </dev/null`, through omi-heavy. These are local hermetic checks, not CI or installed-device acceptance. Earlier green heads and failed integration/control attempts are retained as historical evidence and do not certify this head. UI-Evidence: none -- The diff against merged origin/main changes no widget, layout or user-facing string; device_diagnostics.dart only adds a section to the existing shared JSON. The evidence gate scans all app/lib Dart paths and explicitly accepts this truthful no-visual-change declaration; no screenshot or evidence manifest is needed. ## Device acceptance Install the combined artifact while preserving app data; do not uninstall, clear storage or reset the ring. Use firmware 3.0.24, all three repair switches ON, adequate phone disk, charging and a foreground connected app. Keep pendant recording live. At baseline, +2 minutes and +10 minutes (extend for UI rounding), record Device Storage used/total/free/percent and these Offline Sync numbers: Waiting on your Omi duration and MB; Waiting on this phone duration; Transcribing on Omi duration; Downloading from your Omi done/total and fraction. Export Settings → device → Diagnostics → Share at the same points and record phone UTC, ring identity, read_seq/write_seq, dropped count, capacity/used and persistence grant. PASS requires Device Storage used to FALL while connected AND recording; within the same ring, read_seq must gain faster than write_seq, dropped count must not rise, saved audio must play, and new live capture must continue. Faster draining only while recording is paused does not pass. Reconnect/cancel during persistence and restart after index-before-receipt must replay the known prefix before READ without making a second audio file. Missing index, changed/corrupted file, foreign owner, wrong ring, ownerless legacy proof and unknown prefix must retain audio. Verify empty markers are indexed control metadata, never uploaded as audio. Physical RF/background/power-loss/disk-pressure behavior, digest cost, owner export, live Home display of estimated dates and sustained drain remain unverified here. Firmware 3.0.24 broad rollout remains gated on the live-recording storage decrease. ## Rollout and rollback RELEASE ORDER: A build containing the bad-date guard MUST NOT go to the App Store before server recovery PR #25401 (#25401) is serving with its recovery switch ON and its readers qualified. Until then an impossible-date import carries an estimated time that the server treats as an ordinary date. Verify the serving revision and switch before releasing this app; local tests do not establish that prerequisite. Qualify how Home presents untrusted display time separately. All three repairs are ON by default. Rebuild with `--dart-define=OMI_RING_DRAIN_RECOVERY_OFF=true` to restore main's windowed-reader behavior without AA indexed-tail reconstruction, exit-path recovery or downloaded-span suppression; `--dart-define=OMI_BATCH_RING_PROOF_OFF=true` to restore the prior batch proof behavior; `--dart-define=OMI_DEVICE_CAPTURE_CLOCK_REPAIR_OFF=true` to restore previous new-import timestamp predicates and naming. Use all three for a full behavior rollback. Conservative proof validation remains enforced. Already-reclaimed pendant copies cannot be restored by a flag; their indexed phone files must be preserved. Existing estimated runs and old files are not rewritten. Keep compatible server readers for estimates already admitted. No remote lease was added: the existing flags path can return an unbounded last-known-good ON value and exposes no server-validation age. A fresh HTTP read cannot establish a fresh grant. A fail-closed remote switch needs a bounded server grant/cache-freshness contract and client lease checks, beyond a configuration-key change; this follows the lead's exception. The three compile-time switches remain the available rollback controls. ## File growth Counts below are actual origin/main → combined-head source counts. Declarations for files below the 1,500-line threshold also document the requested integration boundaries; the ratchet may report those as unnecessary. Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4941 -> 4944 | Preserve original packet coordinates at the existing batch routing boundary without introducing another capture owner. Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2789 -> 2864 | Publish owner-scoped indexed content proofs and expose primitive inventory observations at the existing WAL owner. Line-Count-Exception: app/lib/services/wals/pendant_ring_custody.dart | 1102 -> 1743 | Keep exact receipt replay, account/content validation and contiguous ADVANCE decisions in the single custody authority; retain immutable diagnostics getters. Line-Count-Exception: app/lib/services/wals/ring_storage_sync.dart | 1230 -> 1551 | Keep streaming read ownership, persistence deadlines, empty-record markers, exit acknowledgement and timestamp normalization beside the existing parser. Line-Count-Exception: app/lib/services/devices/connectors/omi_connection.dart | 1498 -> 1580 | Observe bounded read-only protocol events beside connector operations without altering protocol authority. Line-Count-Exception: app/lib/pages/settings/device_diagnostics.dart | 1091 -> 1094 | Add one JSON export section to the existing diagnostic builder without changing presentation. Line-Count-Exception: app/lib/services/wals/wal.dart | 1204 -> 1303 | Persist exact source coordinates and the existing SHA-256 content identity with the WAL serialization that owns indexed custody. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Git-on-my-level
added a commit
that referenced
this pull request
Nov 21, 2026
## Summary Supersedes #23643 for Android Custom Live realtime capture. [SCA-3592](https://multica-01.tail76ea03.ts.net/scaling-forever/issues/01a1ff2e-a8dd-7191-a8bd-303b9ec9deb0) owns design, acceptance and release follow-through. - On all supported Custom Live platforms, send Omi controls to the secondary and binary audio to Custom Live. Send an Omi evidence record together with its binary frame only when the user enables secondary raw audio. - Watch decoded Limitless audio for the admitted Android Custom Live capture and BLE epoch. Retry firmware stream enable once per episode, under live ownership checks. Require a full window of progressing decoded audio before rearming. Close the watch when that owner retires, the link drops or flash drain takes over. - Preserve #25534's recording identity across short reconnects and the existing WAL/reclaim paths, including #25415's range and proof behavior. The original PR also proposed automatic flash offload, persistent Transcribe Later preference switching and GATT replacement. Those behaviors are outside this successor's approved recovery path. ## Verification and release - Three regression assertions failed on pinned main `460379212835226dfbc3baa7b37b16b373f2bf55` before the socket fix. All 86 focused tests passed on Flutter 3.44.5. The suites exercise the raw-audio consent pair, decoded-frame stall retry and link loss, sustained frame progress, pending-write ownership, reconnect telemetry and the protected capture paths. - The provider republishes normalized metadata after capture starts. A new replay failed on the draft when that update retired the watchdog. The fix retains the same admitted recording and BLE link across that refresh and fences changes in account or pause. - The retained-capture reconnect regression failed on the second-round head. The connector now closes the old epoch immediately and re-arms after setup only if that same capture still owns the new link. The replay proves one retry on each link without a second capture start. - Release QA needs a paired Android+Limitless run verifying normal quiet behavior, a known utterance around an injected midstream stall, decoded-audio resumption, and a transcript on the Custom Live endpoint. The local device lab had no Android handset attached. - Production readback uses `Recording Observation` by app version/build. Count one detection-eligible and one detection-enabled/disabled observation per recording, and report restored, exhausted and censored outcomes. Report exhausted episodes per 1,000 detection-enabled recordings alongside enabled/eligible coverage. Older builds lack the Custom Live session dimension, so SCA-3592 records the historical baseline as unavailable. Use the first complete qualifying 24 UTC hours on the first instrumented build for the production baseline. - Default on. Release can disable the firmware watchdog using the cached PostHog boolean `android-custom-live-audio-recovery-kill`. Full rollback is a rebuild with `--dart-define=OMI_CUSTOM_LIVE_CAPTURE_FIX=false` or a revert. No backend write, new endpoint, or audio retention change. ## Product invariants affected - INV-CAP-1. The Android Limitless retry adds no uplink pause or subscription removal and makes no claim about audio from before restoration. The tiered-capture and resume/sync-fence guard suites were exercised. Failure-Class: new UI-Evidence: none Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 5095 -> 5175 | Bind watchdog admission and telemetry to the admitted recording, account and BLE connection. Line-Count-Exception: app/lib/services/devices/connectors/limitless_connection.dart | 2237 -> 2294 | Connect realtime health to BLE setup, decoded audio and generation teardown. ## Review provenance - R1 `review-20261121t180552-ffc0` reviewed `f091e051a8f8e9809f1fb8aa4339b4ce81b130c5`. Two reviewers returned SHIP. The third timed out. The controller-level coverage finding was accepted and tested on the next head. - R2 `review-20261121t183640-a410` reviewed `7ea054a3f366f9f50545f166c5d8164f7a32e780`. The retained-capture reconnect finding was a blocker. The other answered reviewer raised three nonblocking findings. The third timed out. All four findings were triaged. - Pipeline accepted the verified reconnect correction at `1899388f6ea4f10e93542c194391de3963694cfd` under the two-round rule. The disposition and regression evidence are on SCA-3592. Regular binary consent routing passed a supplemental local replay. Maintained coverage and unchanged-settings refresh behavior are tracked in SCA-3617 and SCA-3616.
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 this fixes
One pendant on CV1 firmware 3.0.24 drained its battery about 2.5 times faster than it had on 3.0.21, and the audio stored on it never finished syncing. Over the same battery range (99% to 72%) it lasted 6.2 hours on 3.0.21 and 2.3 to 2.7 hours on 3.0.24. Two separate defects, one on each side of the link, both switched on by live persist.
Firmware: a status poll wrote the SD card. While a phone is connected the storage worker refreshes the status characteristic every 250 ms through
sd_ring_get_info(), which commits the buffered batch before it answers. 3.0.21 buffered nothing while connected, so that cost nothing. With live persist there is always a buffered batch, so each poll rewrote the whole 16 KiB batch plus a metadata sector with two media syncs: about four card writes a second for the whole connection. This was item 8 of the 3.0.23 review ("Storage INFO flushes a partial batch every 250 ms") and was not fixed in 3.0.24.App: the ring was downloaded faster than it was credited. In an eight-hour log the app downloaded 440,500 ring records and was credited for 194,000; the backlog grew from 262,253 to 329,069 records while connected.
What changes
Firmware (
omi/firmware/omi/src/sd_card.c,lib/core/storage.c)sd_ring_peek_info(), answered from RAM with the SD host left suspended.CMD_RING_INFOand the start of a READ still commit first, so what they report is readable.App (
app/lib/services/wals/ring_storage_sync.dart,pendant_ring_custody.dart)No wire format or capability bit changes.
app/lib/services/wals/PENDANT_RING_CUSTODY.mdsection 6 records the behaviour.Compatibility
firmware that frees ring space itself keeps the single unbounded read.The ranged 13-byte READ exists in firmware from 3.0.20, but the app only uses it where the firmware advertises
CAP_APP_ACK_RECLAIMandCAP_RING_ID.Verification
Ran on macOS:
make -C omi/firmware/omi/tests run: custody 47 checks, SD-ring and storage harnesses 0 failures, including 8 new cases. Also built and passed under GCC 13 on Linux in a container.make -C omi/firmware/tests testandomi/firmware/omi/tests/run_host_regressions.py: pass.flutter teston the ring, custody and WAL suites: 194 pass, 21 of them new (ring_windowed_sync_test.dart,pendant_ring_custody_cost_test.dart). The full hermetic app suite passed (8,881 tests) on an earlier revision of this branch.Not done, and owed before a firmware release:
Risks
cv1-ring-custody-host.Product invariants affected
Failure class (fixes)
Failure-Class: new
FC-status-poll-commits-buffered-storageis added for the firmware defect, guarded by the two host harnesses. The app defect has no registered class and none is added, since a PR may add one.UI-Evidence: none -- no UI source changes; the app edits are in the sync and custody services.
🤖 Generated with Claude Code