Skip to content

feat(app): tiered pendant capture — pause the live uplink after silence, resume on foreground or charge - #20837

Merged
Git-on-my-level merged 12 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/battery-tiered-capture
Oct 6, 2026
Merged

Git-on-my-level merged 12 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/battery-tiered-capture

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Tiered pendant capture on iOS: the live uplink (v4/listen websocket + BLE audio notifications) now pauses after the user's conversation-timeout of silence instead of running for as long as the phone is connected. Addresses the 42%-battery / 16h53m-background report of 2026-10-03 (#5491, #11307); design and history in the mobile-battery-efficiency project record.

  • Silence past the conversation timeout (existing setting, default 120s) pauses the uplink: BLE audio subscription cancelled, listen socket closed, WAL tail finalized, conversation processed. Live Activity shows Paused. Speech after the pause is missed until resume (accepted; firmware ring-buffer work is tracked separately).
  • Sticky across reconnects: BLE reconnect restores the link and syncs but does not reopen the uplink; reconnect latency is unchanged (iOS background BLE timeouts leave live transcription unavailable for minutes to hours #11307 preserved).
  • Resume triggers: app foreground, charge-start edge, island/app pause-card Resume, unmute. Manual mute still wins over auto-resume.
  • Socket close on pause: the manual mute/pause path now also closes the listen socket (it previously left it pinging every 20s).
  • Friend Pendant synthetic battery ticks removed: the 90%-every-30s fake battery no longer drives per-tick widget-timeline reloads; widget info updates once per connect and on real changes.
  • Periodic backlog sync: bounded, uplink-fenced WAL sync via the existing transfer coordinator (iOS BGAppRefresh opportunistic, no hourly promise; Android foreground-task repeat). A sync pass never opens the live uplink.

uplinkSilencePaused distinguishes automatic pause from manual mute without changing shared capture emissions. Details in app/lib/services/capture/CAPTURE_POLICY.md.

Failure-Class

Failure-Class: new

Product invariants affected

  • INV-DATA-1

Test plan

  • New regression tests: tiered capture (pause on 120s silence, sticky across reconnect, foreground/charging resume, WAL finalize-once), uplink silence timer, charge-start tracker, Friend Pendant emit-once + unsubscribe-on-pause, periodic sync fencing (backlog-only, never opens uplink): app/test/services/capture/tiered_capture_test.dart, uplink_silence_timer_test.dart, app/test/providers/device/charge_start_tracker_test.dart, app/test/services/devices/connectors/friend_pendant_connection_test.dart, app/test/services/wals/periodic_recording_sync_test.dart.
  • Targeted suites: 149 passed. Full app suite: 4752 passed, 19 skipped, 1 pre-existing flake (local_recordings_owner_test directory-deletion teardown; reproduced on base 6993ad4a22 at 4/500 repetitions). Spine: 138 passed.
  • flutter analyze: changed files clean; full-project 89 diagnostics identical to base. Analyzer ratchet passed. SwiftLint + plist validation pass. scripts/pr-preflight green on this body.

Review in cubic

@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.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Treat failed and empty charging reads as unknown, retaining the tracker's last successful state and UI/widget value. Only successful observations may create charge-start edges. Audit confirms notifications are real characteristic payloads, with empty notifications ignored. Cover read/notify recovery, clean reconnects, and genuine charging transitions through DeviceProvider.
Keep deviceConnected background-eligible to honor generous reconnect sync without weakening immediate BLE link recovery. Like periodic wakes, its discovery and backlog drain now run inside SyncWakeScope. Update stale foreground-only comments and prove capture start attempts cannot open sockets or BLE audio, reconnect bursts stop at two serial passes, and failures release holds without scheduling background retries.
@Git-on-my-level Git-on-my-level added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 6, 2026
Choose shape (a): keep pause intent intact until SyncWakeScope.whenIdle, then dispatch the existing resume transition. Apply the same fence to Home, pendant double-tap, Live Activity, foreground, and charging resume paths; re-arm the existing keepalive after successful resume. No background retry timer or sync admission bypass is added. Regressions reproduced the old failure for foreground and background reconnect drains and assert connected socket, active BLE audio, and armed keepalive after completion.
Firmware force-notifies charging state when notifications are enabled. If the read failed, preserve its per-connect resume gate for the first valid notification, even after the sync fence drops. Always record that sample; later genuine false-to-true edges still resume. Cover explicitly gated connects, notifications during/after sync, empty payloads, and ordinary first charging observations.
Latch the first-observation resume gate per connection. A scope that starts later defers capture work rather than consuming the first real charging edge after an unknown read. Connections initially admitted only for sync still observe without resuming. Add a provider regression for one initial edge and later genuine charge starts.
Enforce live-session liveness at the transport layer instead of relying on a safe gap before resume dispatch. Coalesce skipped transport attempts, await scope drop and capture commit, then revalidate current ownership and idempotently restore missing transports plus keepalive. A new scope during the re-drive records fresh demand; no retry timer, policy write, or session mint is introduced. Clear cancelled audio handles and make already-unmuted resume a no-op.

Keep dispatch deferral as an optimization only. Add the numbered eight-case resume/fence suite, including a real coalesced coordinator with a controlled microtask yield at depth zero. Case 3 fails on fbb0ba0 with a disconnected socket after the whole wake, and passes with reconciliation. Pure sync still opens zero transports.
@Git-on-my-level
Git-on-my-level merged commit fe5d070 into BasedHardware:main Oct 6, 2026
35 checks passed
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
Wifi-to-cellular handover during an upload pass, a normal server close, a
pendant BLE drop and reconnect mid-pass, and a hung pass: each asserts live
capture is back within 3 s and every emitted pendant packet is durable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
…#22873)

## Why

On 2026-10-20 a user lost about 4 hours of pendant audio, including a
2-hour conversation, and uploads stalled for the same 4 hours. A cold
start fixed both. Two investigations traced it to several gaps that
compound:

1. **Primary cause: a reconnect during a sync pass skipped capture, and
nothing restarted it.**
   - Every BLE connect wakes a `deviceConnected` pass.
- That pass ran inside `SyncWakeScope`, so
`DeviceProvider._onDeviceConnected` and `streamDeviceRecording` silently
skipped the capture start, and the uplink fence blocked socket and audio
opens.
- Nothing re-drove the skipped start when the pass ended or when the app
came to the foreground.
- The pass itself could hang forever on an untimed BLE read. Every later
wake (foreground, Retry) joined the stuck pass, so no uploads happened
either.
- A connected pendant on firmware 3.0.21 with no audio subscriber
**discards** audio (`transport.c` pusher, connected + unsubscribed
branch).
2. **Live socket recovery had dead ends.**
   - A normal server close (1000/1001) waited for the 15 s keep-alive.
   - The keep-alive cancels itself permanently on several conditions.
   - A network change or app resume never re-armed it.
3. **The upload worker only ran on wake events.**
- A wifi→cellular handover never reports offline, so it caused no wake.
   - Retries and the cooldown-end wake were dropped in the background.
   - Nothing woke the worker while rows sat in "Waiting to sync".
4. **BLE reads and writes had no timeouts.** On iOS, a second read of
the same characteristic overwrote the first caller's completion, so the
first caller's future never resolved.

## What changes

**1. Capture is never stranded by an upload pass.**
- Only the OS-granted `periodic` window (BGTask) still fences live
capture. Reconnect and watchdog passes no longer do
(`RecordingTransferCoordinator.fencesLiveCapture`).
- `DeviceProvider` always calls `streamDeviceRecording`.
- If a start lands inside a fenced pass, it is recorded and **replayed
when the fence drops**.
- Foreground resume starts a connected pendant that capture left idle.
- **Every pass has a hard time limit:** 60 min, or 10 min when fenced.
The limit sits inside the scope, so a hung stage releases the fence and
`_inFlight`. `SyncProvider` cancels the abandoned sync, and the
coordinator schedules a retry.

**2. Pendant audio is never silently dropped.**
- `NativeBleTransport` hands audio notifications that arrive with no
Dart listener to `OrphanAudioRoute`. These packets were previously
dropped by the broadcast controller, because the native GATT
subscription outlives capture's listener.
- Capture writes them synchronously to the existing safety WAL while the
WAL tracks the pendant codec. They then upload through the normal sync
path.
- **Why the WAL and not unsubscribing:** on shipped firmware,
unsubscribing while connected makes the pendant *discard* audio. It
writes flash only while disconnected
(`omi/firmware/omi/src/lib/core/transport.c` pusher). Unsubscribing is
therefore not a fallback.
- **Excluded:** muted policy (user intent), a caller stop (the
voice-profile flow), Transcribe Later (the native writer owns that
audio), and phone or call ownership.

**3. Live socket recovery.**
- A server close (except terminal codes 1008/4001/4002/4004/4005), a
socket error, connectivity restore, a network-type change and app resume
each kick an immediate reconnect.
- Backoff is bounded: 1, 2, 5, 10 and 15 s over a 5-minute window, with
the 15 s keep-alive still running underneath.
- The kick re-arms a keep-alive that had cancelled itself, and
re-installs a missing pendant audio stream while capture still owns it.

**4. Upload worker.**
- Any connectivity change wakes the worker, including a network-type
change (`ConnectivityService.onNetworkChange`).
- `cooldownElapsed` is accepted in the background. Retries also run in
the background, capped at 6 consecutive failures.
- A new `watchdog` wake runs every 10 minutes while recordings are
pending and no pass is running.
- The multipart upload response-body read now has a 2-minute timeout.

**5. BLE timeouts.**
- Dart `NativeBleTransport` read and write calls time out after 10 s. A
timed-out read returns empty; a timed-out write throws.
- Capture's codec read is bounded at 35 s and falls back to the last
known codec.
- **iOS** `OmiBleManager`: pending reads and writes are queued FIFO per
characteristic instead of overwritten, and each fails with `TIMEOUT`
after 10 s.

**6. Telemetry.**
- New registered event `Capture Recovery Observed`, with `kind`
(`capture_start_skipped`, `capture_start_redriven`,
`pendant_audio_orphaned`, `transfer_pass_timed_out`) and `trigger`, plus
a consumer question.
- Debug-log markers: `capture_start_skipped`,
`capture_stopped_with_device_streaming`, `transfer_pass_stuck`,
`ble_op_timeout`.

**Flags:** none. These restore intended behaviour and ship on by
default. Each new path is bounded (rate limits, retry cap, time limits)
and fails toward recording.

**Known trade-off:** on firmware that has opted into live persistence
(draft #20450, not released), orphan audio is also on the ring. The
pendant ring custody contract
(`app/lib/services/wals/PENDANT_RING_CUSTODY.md`) prefers keeping both
copies over losing one.

## Tests

Run as targeted Flutter tests under `nice -n 19`. Results:
- `test/services` + `test/providers`: 1638 passed.
- `test/spine` (`OMI_DEV_CONTROLS=1`): 138 passed.
- `test/unit` + `test/backend`: passed.

New tests:
- **`test/services/capture/capture_live_recovery_test.dart`**, through
the real controller, socket service and WAL with a scripted transport.
It covers:
  - a normal close reconnecting within 2 s;
  - repeated closes backing off but never stopping;
- a network handover, and separately an app resume, re-arming a
keep-alive that had cancelled itself;
  - terminal close codes not kicking a reconnect;
- **a reconnect during a fenced pass still yielding capture once the
pass ends**;
- **a hung fenced pass aborted by its time limit, after which capture
starts**;
  - reconnect passes not fencing at all;
- orphan packets being persisted, while muted and caller-stopped
pendants are left alone.
- **`recording_transfer_coordinator_test.dart`** covers:
- a hung pass being abandoned, releasing the fence and the joined wakes;
  - only `periodic` fencing;
  - a network handover waking a pass;
  - the watchdog waking only while work is pending;
  - background cooldown and bounded background retries.
- **`native_ble_transport_test.dart`** covers read and write timeouts
and orphan delivery.

Updated tests (these encoded the old contract):
- `periodic_recording_sync_test` now expects capture after the pass, and
bounded background retries.
- `tiered_capture_test` and `resume_sync_fence_test` now use the
`periodic` fence.
- `capture_recovery_replay_scenarios_test`: connectivity restore now
reconnects immediately rather than at the next 15 s tick.

**Not verified:** on-device behaviour (no physical pendant run), and the
iOS native change. The Swift change was syntax-checked with `swiftc
-parse` only and needs the iOS CI build.

## Regression guard for #20837

Fault-injection tests in
`app/test/services/capture/capture_live_recovery_test.dart`, group
"regression guard for #20837 (fault injection)". They run in CI through
`flutter test`.

**Each test asserts two things:**
- live capture (a connected socket plus the pendant audio subscription)
is running again within **3 s** of virtual time;
- **no pendant packet is dropped:** every packet emitted while the
pendant was connected is durable in the safety WAL.

**Faults covered:**
- **A Wi-Fi to cellular handover during an upload pass.** The socket
dies on the old interface, a network change follows, and the reconnect
pass is still running.
- **A normal server close (1000) of the live socket.**
- **A pendant BLE drop and reconnect in the middle of a fenced pass.**
Packets arriving while capture is deferred reach the orphan route and
are persisted, and capture starts when the fence drops.
- **A hung pass that never finishes.** The hard time limit ends it, and
capture starts.

By construction, each of these fails on the pre-PR code (reasoned from
the code paths; not executed against the old tree): either there is no
capture restart, or the restart comes at the 15 s keep-alive, beyond the
3 s bound.

## Review round 1 (Grok) fixes

- **FIX-FIRST, replay under phone or call ownership.** A start swallowed
by a fence is now replayed unless the pendant already owns capture, is
suspended, or was stopped by a caller. The reducer records the pendant
as suspended while a phone recording or call holds capture, and resumes
it afterwards. New test: "a start swallowed while a phone recording owns
capture resumes the pendant after it".
- **FIX-FIRST, orphan WAL priming race.**
- The codec boundary is taken only while the transport still has no
listener and no phone or call owns capture, and this is rechecked after
the await.
- No boundary is taken when the WAL already tracks the pendant codec
(new `LocalWalSyncImpl.currentCodec`).
- The backlog is written only while the WAL codec matches. Otherwise it
is dropped rather than written under the wrong codec.
  - A full backlog drops the oldest packet.
- **FIX-FIRST, an abandoned pass keeps running.**
- A timed-out pass is marked stale by a pass generation and stops at its
next stage boundary.
  - It holds an extra transfer keep-alive until it actually exits.
- No later pass discovers or drains beside it. That block is bounded by
a second time limit, after which the pass is presumed dead.
- The test now asserts that there is no second discovery or drain while
the body runs, and that the keep-alive is balanced.
- **SHOULD-FIX, iOS GATT queue.** Only the queue head is issued to
CoreBluetooth, which allows one outstanding read or write per
characteristic. The next request is issued when the head completes or
times out.
- **Not changed:**
- A timed-out Dart read still returns empty. That matches every other
native read failure, which also maps to empty, and the watchdog and
reconnect wakes retry.
- Only Opus goes to the safety WAL. That matches the primary capture
path's `checkWalSupported`.
- Fenced foreground periodic windows are capped at 10 min, as noted in
the review's NIT.
- **Merge with main:** the change is merged with main (#22197 rewrote
`ConnectivityService`). `onNetworkChange` is re-added on top of that
version and has a unit test.

## Review round 2 (Grok) fixes

- **FIX-FIRST, orphan priming race (supersedes the round-1 priming).**
- Orphan audio is now written synchronously, and only while the WAL
already tracks the pendant's codec. That holds in the incident shape,
where the pendant was the last source.
- The orphan path never calls `onAudioCodecChanged`, so it cannot race a
live start or wipe a session that subscribed in the meantime.
- When the codecs differ, packets are counted (`dropped`) and capture is
restarted.
- New test: "orphan packets never move the WAL off another source's
codec".
- **FIX-FIRST, gate on an abandoned pass.**
- An abandoned pass now blocks discovery and drain until it actually
exits. There is no time-based release any more.
- Its sync is cancelled on timeout, and every BLE and HTTP await beneath
it is now bounded, so it does exit.
- Every stage returns once the pass is stale. That includes the tail
after the drain (refresh and reconcile) and the `catch` path.
- **SHOULD-FIX, iOS late GATT replies.** After a timeout, the next
operation waits for CoreBluetooth's late reply, or a 5 s grace, before
it is issued. The late reply is never handed to the next waiter.

## Review round 3 (Grok): mergeable

- Grok's verdict: every FIX-FIRST from rounds 1 and 2 is resolved.
- **SHOULD-FIX taken:** a deferred start that is swallowed again by a
periodic fence raised in the same turn now re-arms and loops, instead of
being stranded.
- **Not taken in this PR (follow-ups):**
- correlate a late iOS GATT reply by operation id on notifying
characteristics;
- make a timed-out Dart read throw instead of returning empty, so a
storage list read that times out is retried rather than counted as "no
files".

## Product invariants affected

- INV-CAP-1: this extends it. A sync pass, a dead socket or a missing
listener must not stop consumption of pendant audio while the connected
firmware discards unconsumed frames.

UI-Evidence: none -- no UI change; capture, sync and BLE plumbing only

Failure-Class: FC-automatic-capture-pause-without-retention

Line-Count-Exception: app/lib/services/capture/capture_controller.dart |
4520 -> 4531 | recovery hooks only (part directive, state field,
resume/close/connectivity/stop hooks, sync dispose cancel); logic lives
in the new capture_live_recovery.dart part
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2757
-> 2758 | one read-only currentCodec getter so orphan audio never forces
a codec boundary on a WAL that already tracks the pendant codec

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Git-on-my-level added a commit that referenced this pull request Oct 20, 2026
…itor, rollout-hop capture health (#22892)

## Why

Builds 1.0.560–563 (#20837) skipped the pendant capture start whenever a
BLE reconnect landed during an upload pass, and nothing restarted it.
Firmware 3.0.21 discards audio while a phone is connected but not
subscribed, so the audio was recorded nowhere. About 640 users hit
`Capture Wedge Detected trigger=connected_no_bytes` over a week, and
nobody noticed until David lost a dinner on 10-20.

The app fix is #22873. This PR adds the gates that catch the next
regression of this class: at dev time first, on TestFlight at the
latest, and before a store rollout widens.

**Stacked on #22873** (`fix/app-capture-recovery` @ a9b92cc). It
contains that diff until #22873 merges; merge #22873 first.

## What changes

### 1. Dev time: capture-continuity suite
(`app/test/services/capture/capture_continuity_test.dart`)
- **`SimulatedPendant`** gives every BLE packet a unique frame id. The
link models firmware 3.0.21:
  - subscribed: the packet is notified;
  - disconnected: the pendant stores it on its own flash;
- connected with no listener: the orphan route (#22873), or a drop on a
fresh link.
- **`PendantFrameLedger`** finds every frame id in socket sends, the WAL
buffer, in-memory chunks, WAL files and uploads
(`ScriptedUploads.onUploadFiles`). It asserts the invariant **every
frame the pendant notifies is streamed to the live socket or persisted
in the local WAL**, and that live capture resumes within 5 s. It also
checks that both custody paths saw frames, so a broken decoder cannot
pass.
- **Scenarios** run through the real controller, socket service, WAL and
transfer coordinator:
- the exact 10-20 path: a reconnect 45 s into a stuck `deviceConnected`
pass, which must resume *while the pass is still stuck*;
  - background and foreground, with a close while backgrounded;
  - the layer-2 declaration;
- a 10-minute soak with every fault: wifi to cellular, a 1000 close,
reconnects mid-pass, and background with a drop.
- **Not duplicated:** #22873's count-based single-fault guards
(78b11b7).
- **Runtime:** about 6 s.
- **Discriminates (verified):**
- On the pre-#22873 tree (9e75c89, which contains #20837), the reconnect
scenario loses **125 s** of audio and the soak **320 s**.
- Mutations on #22873 fail too: removing the orphan route, or fencing
every pass (the #20837 contract).

### 2. Debug and TestFlight: capture-continuity invariant monitor
- **The gap it closes:** the existing `connected_no_bytes` watchdog only
watches *open capture sessions*. In the #20837 state there was no
session, so it was blind. It is also already exempt from the
`mobile-capture-recovery-v1` gate, so making it "unconditional" would
not have helped.
- **The check:** `CaptureContinuityMonitor` checks every 15 s while a
pendant is connected. It declares `Capture Wedge Detected` with
`trigger=connected_not_capturing` when all of these hold for 60 s:
- capture is expected (not muted, not Transcribe Later, no caller stop,
no phone or call owning capture);
  - there is no capture subscription;
- no frame reached custody. Orphan audio persisted to the WAL counts as
custody, so it stays quiet.
- **Output:**
- the event is emitted in every build, mirrored to the replacement
collector;
  - `Capture Recovery Resolved` fires when capture returns;
- the Home banner (`CaptureContinuityDogfoodBanner`) shows only in
`kDebugMode || Env.isTestFlight` builds.
- **Telemetry only:** it never retries or restarts anything.
- **Timer:** it runs only while a pendant is connected; idle controllers
hold no timer.

### 3. Store rollout hops: capture-health hold
(`app/scripts/mobile_capture_health.py`)
- **Placement:** the iOS phased jump to 100%
(`ios_phased_release_should_complete`) and each Android ladder hop
(`run_android`), the two exposure-expanding steps with no health check.
Dispatch itself stays gated by the operator release gate.
- **Rubric:** mirrors the operator gate's judge (Hermes
`omi_capture_wedge.py`, Observability). The rate is wedge users,
reweighted by 100/`omi_sample_pct`, over pendant users (`Device Session
Ended`), per (`$os`, `$app_build`) over 48 h. A build is **BAD at more
than 2x the previous build** (the largest build below it with at least
20 pendant users) **or at more than 50 wedge users a day**.
- **Deliberate differences from the operator gate:**
- the build is exact: the Android version code, or the iOS build
attached to the live App Store version (`GET
/v1/appStoreVersions/{id}/build`), never a same-version sibling;
  - the triggers include `connected_not_capturing` from layer 2;
  - a missing build or a failed query **HOLDS** (fail closed).
- **Override:** `capture_health_override=<reason>` on
`mobile_daily_train.yml` and on `mobile_rollout_watch.yml` (new manual
`workflow_dispatch`) lets one run through, with the reason logged. No
new workflow file.
- **Verified read-only against live PostHog 10-20**, matching the
operator gate:

| Build | Verdict | Detail |
|---|---|---|
| iOS 1389 (1.0.563) | BAD | 34%, 100 a day |
| iOS 1409 | BAD | |
| iOS 1417 (1.0.566) | BAD | |
| Android 1461 (1.0.566) | BAD | 13% against 0% |
| Android 1445 | ok | |

## Before merge (decision for a maintainer)
- **Codemagic needs a read-only PostHog key.** `mobile-daily-train` and
`mobile-rollout-advance` only have the `google_play` env group. Add
`POSTHOG_PERSONAL_API_KEY` (query read) to a Codemagic group and list it
in both workflows in `codemagic.yaml`. Until then, every hop **fails
closed (HOLD)**; use the override input to advance deliberately.
- **1.0.566 will hold** on both platforms once the key is in. That is
the gate working: the build predates #22873.

## Review
- **Grok round 1** (fixed):
  - iOS is judged on the exact store build from App Store Connect;
- any PostHog read failure HOLDS instead of raising (an `IncompleteRead`
could have aborted the train);
- the continuity timer is cancelled synchronously on dispose and
re-synced on stage-only device updates;
- the ledger requires the synthetic fill, so real 80-byte Opus audio can
never count as a pendant frame.
- **Grok round 2** (fixed): a malformed App Store Connect build resource
now returns "unknown build" (HOLD) instead of raising out of the iOS
train. Otherwise the round-1 fixes were confirmed sound.
- **Declined, by design:**
- the baseline is the lower build with the most pendant users (the
operator gate's `previous_build`), not the highest build number;
- the per-day cap is window users x 24 / hours, as in the operator
`judge`.

## Tests
All targeted, under `nice -n 19`:
- `flutter test test/services/capture test/services/wals test/providers
test/pages/conversations`: 1434 passed.
- `test/spine` (`OMI_DEV_CONTROLS=1`): 138 passed.
- `flutter analyze` on the changed files: clean.
- `python3 app/scripts/mobile_capture_health_test.py` (14),
`mobile_daily_train_test.py` (91, including the hop wiring), and both
dispatcher tests: OK.
- `run_checks.py --lane local` on the changed files: all selected checks
pass.

**Not verified:** on-device behaviour of the monitor and banner (no
physical pendant run), and Codemagic runs of the hold (no key
provisioned).

## Product invariants affected
- INV-CAP-1 (pendant audio retention): enforced, not changed. Layer 1
asserts it end to end (no notified pendant frame may miss both the
socket and the WAL), layer 2 detects it at runtime (a connected pendant
nobody consumes), and layer 3 holds a rollout that violates it in the
field. Capture behaviour is unchanged; the only controller edits are the
continuity-watch hooks.

Failure-Class: none

Line-Count-Exception: app/lib/services/capture/capture_controller.dart |
4520 -> 4539 | 4520 -> 4531 is #22873 (stacked); this PR adds 8 hook
lines (import, part directive, timer field, two watch syncs on device
update, dispose cancel, custody mark); logic lives in the new
capture_continuity_watch.dart part
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2757
-> 2758 | #22873 (stacked): one read-only currentCodec getter; this PR
does not touch the file

UI-Evidence: none -- the only UI is a debug/TestFlight-only diagnostic
banner (never shown in store builds), covered by a widget test in
capture_continuity_monitor_test.dart

🤖 Generated with [Claude Code](https://claude.com/claude-code)
kriegcloud pushed a commit to kriegcloud/omi that referenced this pull request Oct 20, 2026
…itor, rollout-hop capture health

Builds 1.0.560-563 (BasedHardware#20837) skipped pendant capture after a reconnect during
an upload pass, and ~640 users lost audio for a week before anyone noticed.
Three layers so the next one is caught at dev time, on TestFlight, or before
a store rollout widens:

1. Dev time: capture_continuity_test.dart streams a simulated pendant (unique
   frame ids) through the real controller, socket service, WAL and transfer
   coordinator: the exact 10-20 reconnect during a stuck upload pass,
   background/foreground, and a ten-minute soak with every fault (network
   change, server close, reconnects mid-pass, background). It complements
   BasedHardware#22873's count-based single-fault guards. PendantFrameLedger asserts every notified frame is streamed or
   persisted (incl. uploaded), and live capture resumes within 5 s. On the
   pre-BasedHardware#22873 tree it loses 125 s (RCA path) and 320 s (soak).

2. Debug/TestFlight: CaptureContinuityMonitor declares Capture Wedge Detected
   trigger=connected_not_capturing when a connected pendant that should be
   captured has no capture subscription and no frame reaches custody for 60 s
   (the state connected_no_bytes cannot see: no capture session). Event in all
   builds; Home banner only in debug/TestFlight. Telemetry only.

3. Store hops: mobile_capture_health.py mirrors the operator gate's judge
   (wedge users reweighted by omi_sample_pct / pendant users per os+build;
   BAD at >2x the previous build or >50 wedge users/day) and holds the iOS
   phased jump and the Android ladder hop. Fails closed; one-shot
   capture_health_override input on the train and rollout-watch workflows.

Stacked on BasedHardware#22873 (fix/app-capture-recovery).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant