Repository navigation
feat(app): tell a failed pendant from a put-down one in the daily device-health event - #26418
Conversation
…-health event Heavy users who stop capturing show no failure events first, and today's telemetry cannot tell a dead, uncharged or broken pendant from one that was put down. Add drop-off fields to Mobile Device Health Daily (schema 3), derived from the native diagnostics snapshot the rollup already reads: - gap cause for the most recent disconnect not recovered within 30 min (battery_flat / out_of_range / power_off / manual / pairing_lost / phone_side / unknown), from RSSI at loss and the last battery sample, because firmware power-off and walking away both read connection_timeout - last battery level, its age and charging bit before the gap - failed reconnect attempts inside the gap; on iOS, reconnect intent and advertising sightings from the native reconnect-scan log - connected vs disconnected seconds, and connected time without audio - charging inferred from rising battery runs (charge_events needs the 3.0.24 diagnostics characteristic the fleet does not have yet) No new events, native calls or BLE traffic. Kill switch: device_dropoff_telemetry_off (true restores the schema 2 shape). Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Support-reported hardware faults (disconnects seconds after connecting, stuck at 1% then off, won't charge, erratic reading) left no trace in the schema 2 fields. Add short_sessions and gap_short_sessions_24h (links that drop within 30 s), battery_low_seconds (time at or below 5%) and battery_erratic_steps (20-point steps within 10 minutes) to the schema 3 drop-off fields, and count them plus firmware resets as hardware evidence in the documented analyst query. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ounters Scope panel follow-ups: a disconnect whose outage records audio resuming is reconnected even without a later disconnect row; a zero-packet session whose day bucket saw a packet inside it is a restarted counter, not silence. The analyst query requires a battery sample at most 3 hours old before calling a stop put-down. Adds tests for stale RSSI age, app_closed, malformed rows and unchanged legacy values. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4619ae33e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (connectedAt > 0 && connectedAt < observedAt) | ||
| ( | ||
| start: connectedAt, | ||
| end: observedAt, |
There was a problem hiding this comment.
Require an established link before treating connected_at as a session
On Android, OmiBleForegroundService.connectToDevice sets connectionStartTime when starting a connection attempt, with currentAttemptEstablished = false, and getExtendedDeviceDiagnostics exposes that timestamp as connected_at even while the pendant remains unreachable. Adding it unconditionally to sessions makes reconnectAt treat a pending retry as a successful recovery. A retry started shortly after a real disconnect can therefore remove the outage from gaps entirely; a later retry incorrectly closes it and excludes subsequent failures. Require established-link evidence before using this snapshot timestamp to close a gap.
Useful? React with 👍 / 👎.
| AND arrayCount(y -> y.1 >= x.1 AND y.1 <= x.1 + 2 AND y.2 > 0, days) = 0 | ||
| AND x.1 + 2 <= dateDiff('day', toDate('2020-01-01'), today()) - 1, |
There was a problem hiding this comment.
Require observed zero days when confirming a stop
When either of the two days following a zero-connected day has no telemetry, this predicate still accepts the stop: it only checks that no positive-connected rows exist, not that both follow-up days have observed zero values. The calendar-age check does not establish their presence. This contradicts the query's stated rule that missing days are not zero days and can classify incomplete observation windows as confirmed drop-offs, biasing the hardware-versus-put-down results. Require explicit zero-connected rows for both subsequent dates.
Useful? React with 👍 / 👎.
Review panel follow-ups: - an Android connected_at stamp is a session only once a packet arrives on that link (Android stamps it when a GATT attempt starts) - a battery level rising into the loss is charging, not flat, when the firmware reports no charging bit - gap_scan_covered makes reconnect-scan coverage explicit, because null properties never reach PostHog; test the full 500-row log boundary - analyst query: per pendant model, an event required on each of the 3 stop days, and failed reconnects reported beside the classification instead of as hardware proof; per-platform cause coverage documented Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 512a63b20b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 'connected_seconds': connectedMs.clamp(0, end - start) ~/ 1000, | ||
| 'disconnected_seconds': disconnectedMs ~/ 1000, | ||
| 'audio_packets_per_connected_minute': connectedMs < 60000 ? null : received * 60000 ~/ connectedMs, |
There was a problem hiding this comment.
Exclude pending Android attempts from connected seconds
When an Android reconnect remains pending across midnight, connectedMs includes the pending attempt: the active-session calculation accepts connected_at unconditionally, while OmiBleForegroundService.connectToDevice stamps it before establishing GATT, including for passive reconnects. Publishing that value as connected_seconds gives an unreachable pendant positive connected time and lowers audio_packets_per_connected_minute. In particular, the new stop query requires three days with exactly zero connected seconds, so these attempts can prevent a real stop from being detected. Apply established-link validation to the new connected-time metrics rather than exposing attempt time as connected time.
Useful? React with 👍 / 👎.
| if (linkProven && connectedAt < observedAt) | ||
| ( | ||
| start: connectedAt, | ||
| end: observedAt, | ||
| packets: diagnostics['audio_packets_received'] is int ? diagnostics['audio_packets_received'] as int : null, |
There was a problem hiding this comment.
Include established silent links in the audio rollup
For a pendant that previously streamed audio but reconnects with a failed mic or notification path, this condition excludes its ongoing session until it delivers a packet. Conversely, once a packet proves the session, _audio excludes it from silent time. Thus an ongoing zero-packet session can never contribute to connected_no_audio_seconds, even on iOS where connected_at is set only after didConnect. If the link stays up through daily emission, those days are permanently reported as zero silent time because completed days are not re-emitted. Use established-link evidence independent of audio delivery when constructing sessions for the silence calculation, while retaining the guard against pending Android attempts.
Useful? React with 👍 / 👎.
Review F1/F2 follow-ups on the schema 3 rollup: - F1: a pending Android GATT attempt stamped `connected_at` was billed as connected time, so a stop day never read zero `connected_seconds`. The schema 3 split now counts the open link only with established-link evidence (a packet or an RSSI read on that link), and keeps the legacy `connected_time_fraction` unchanged. Test: a pending attempt adds zero connected seconds. - F2: the active session entered the audio rollup only when a packet arrived, so an established silent iOS session never reached `connected_no_audio_seconds`. Establishment no longer depends on audio, while the Android pending-attempt guard stands. Test: an established active silent session is counted. Failure-Class: none Co-authored-by: multica-agent <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5db53972bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (DeviceDropoffSignals.linkEstablished(diagnostics)) { | ||
| establishedMs += exposureEnd - activeSince.clamp(start, exposureEnd); |
There was a problem hiding this comment.
Reject established session stamps that have already disconnected
On Android, when an established link disconnects and no retry starts (for example, status 137 or Bluetooth being turned off), OmiBleForegroundService retains connectionStartTime, the packet counters, and RSSI history; getExtendedDeviceDiagnostics still exposes that old start as connected_at. Consequently, linkEstablished returns true from the disconnected session's evidence, and this branch counts time through exposureEnd, including the outage and potentially double-counting the completed session already included from its disconnect row. The new connected_seconds can therefore remain positive on fully disconnected days and prevent the documented stop query from detecting them. Reject an active stamp when a subsequent disconnect ended that session, or provide explicit current-link state from native diagnostics.
Useful? React with 👍 / 👎.
Review follow-up on F1: Android teardown persists the disconnect row but leaves connected_at, the RSSI history and the audio day buckets populated. linkEstablished treated those historical samples as proof of a live link, so the rollup billed from the old stamp through the exposure end. A fully disconnected next day then still read positive connected_seconds, which defeats the three-zero-day stop query. A completed disconnect row at or after the stamp now closes the interval; the pending-attempt and iOS silent-session evidence paths are unchanged. Regression: a completed disconnect with a stale stamp and historical sample adds no connected time, and the next day stays at zero. Failure-Class: none Co-authored-by: multica-agent <[email protected]>
Summary
When an Omi user stops capturing, telemetry can't tell a pendant that failed or became unusable (dead or uncharged battery, broken BLE, broken mic) from one that was put down. A churn study (heavy users who stop) found no failure events before the stop, but the known gaps meant it couldn't rule hardware out:
charge_eventsis 0 for everyone. The rollup is correct, but the charging bit comes only from the firmware Diagnostics characteristic, which ships from 3.0.24. The fleet is on 3.0.21: 14,212 of 26,135 daily events in the last 7 days, against 29 on 3.0.24, and 16 of those 29 do showcharge_events > 0.charge_pin_edges_maxandsoc_frozen_samplesnever appear.lost_audio_secondsis by design "time without a link", so it can't hold "connected, no audio".connection_timeoutfor nearly every loss (602,881 of 650,590 iOS disconnects). Firmware power-off (turnoff_all→sys_poweroff) and the battery-critical shutdown cut power without terminating the link, so the phone sees a supervision timeout, the same as walking out of range.This PR adds drop-off fields to the existing
Mobile Device Health Dailyevent (schema_version2 → 3). They're computed in Dart from the native diagnostics snapshot the rollup already reads (disconnect_history_v2,battery_history_v2,ble_log,audio_packet_days). There's no new event, native call, pigeon change, scan or BLE traffic, and no firmware change.A gap is a disconnect whose next connection starts ≥ 30 minutes later, or hasn't started yet. Each day's event describes the most recent gap that started before the day's end, so a fully disconnected day still carries the cause of the stop.
gap_cause(battery_flat,out_of_range,power_off,manual,pairing_lost,phone_side,unknown),gap_last_rssi,gap_rssi_age_s,gap_rssi_trendgap_battery_level,gap_battery_age_min,gap_battery_charginggap_fail_to_connect; iOS, open gap only:gap_saved_reconnect_enabled,gap_reconnect_suppressedgap_scan_covered,gap_scan_windows,gap_advert_sightings(counts omitted when the 24 h native log doesn't reach the gap start; absent on Android, which logs no scan results)connected_no_audio_seconds,connected_no_audio_sessions,audio_packets_per_connected_minuteconnected_seconds,disconnected_seconds,connected_no_audio_seconds,long_gaps,long_gaps_by_causecharge_inferred_events,battery_min_level,battery_max_levelshort_sessions,gap_short_sessions_24h(link dropped within 30 s),battery_low_seconds(time at ≤ 5%),battery_erratic_steps(≥ 20-point step within 10 min)Field reference, cause rules and the analyst query:
app/docs/device-dropoff-telemetry.md.Why the symptom fields exist: of 25 cancellers who reported a hardware problem to support in the 90 days before cancelling and had telemetry, 18 had no failure or reset event in the 14 days before. Their connected fraction and failure-event rate looked like cancellers who never contacted support. The schema 2 fields could not see these faults. Firmware resets (
device_resets_by_reason, about 0.1% of daily rows, mostlyRESET_LOW_POWER_WAKE) are rare but real, so the query counts them as hardware evidence.Cost
Measured through the read-only PostHog bridge, aggregate HogQL, 7 days to 2026-11-26:
Mobile Device Health Dailyhad 26,131 events from 4,991 users, about 0.75 per active pendant user per day. It is keep-listed at 100%, so new fields are not sampled.Kill switch
PostHog flag
device_dropoff_telemetry_off(registered inconfig/feature-flags.yaml,posthog.row: absent, rolekill). If it's true, the event drops every new field and goes back toschema_version2. If it's absent, false or unreadable, the fields stay on. On for everyone; no PostHog row is needed until someone uses it. The flag read adds no events, sincesendFeatureFlagEventsis false.Query that separates hardware drop-off from put-down drop-off (after release)
It is in
app/docs/device-dropoff-telemetry.md. A stop is the first day withconnected_seconds = 0after at least 5 connected days in the previous 14, with the next 2 days also at zero. All 3 days must have an event. The query works per Omi pendant model, so a second paired device such as a watch can't mask the stop. Each stop is classified as:hardware: flat battery, the pendant seen advertising, mostly silent connected time, short-session churn, an hour or more stuck at ≤ 5%, an erratic or cliff battery step, or a firmware reset in the 14 days before the stop. Failed reconnect attempts are reported in their own column, because Android's direct connect also fails when the pendant is simply absent;put_down: a clean loss (out of range, powered off or manual) with more than 20% battery left;unclassified: anything else.The query buckets on
properties.day, because emission can be up to 7 days late. Days the app never ran emit nothing, so a missing day is not a zero day.put_downalso requires a battery sample at most 3 hours old. The query runs on PostHog today. It returns no rows until schema 3 ships. Run withconnected_time_fractionstanding in on schema-2 data, it found 1,626 Omi pendant stops and classified 89 of them as hardware (cliffs and resets). Once schema 3 has a month of data, check its recall against the support-reported hardware group before trusting aput_downshare.Firmware follow-up (written up, not implemented)
charge_events, the charging bit, reset causes andcharge_pin_edges_maxreal.turnoff_all(), terminate the link beforesys_poweroff(), with distinct HCI reasons for the button and battery-critical paths.Verification
flutter test test/unit/device_dropoff_signals_test.dart test/unit/device_health_telemetry_test.dart: 59 passed (viaomi-heavy).flutter analyzeon the changed Dart files: no issues.python3 scripts/check_feature_flag_registry.py: OK. Registry doc re-rendered.Layer measured: unit tests and static analysis. The production readback comes after release: run the query above, plus a coverage check of
schema_version = 3andgap_causepresence on the daily event.Scope panel
scope-20261126t154826-3a9etriageThe scope panel (luna, deepseek, glm-flash) returns a dossier without triageable finding IDs (
omi-panel triageaccepts review findings only), so its 27 risks are triaged here in panel order (R1–R27).soc_frozen_samplesand others).events.jsonand the ring-read row are untouched.unknownstays explicit, andput_downneeds a battery sample at most 3 h old.lostAudioResolvedAtconnection_history_incompleteflag marks partial days.connected_atconnected_time_fraction's existing behavior.disconnectrows, and tested.JSONExtractKeysAndValuesondisconnects_by_reasonran in PostHog during design.properties.day, not timestampout_of_rangemay rarely fireunknownshare.last_atinside the session vetoes it, with a test.phone_sideis Android-onlydisconnected_secondsmust use the corrected valueReview panel
review-20261126t160746-ed30triageconnected_atis stamped before GATT succeedsbattery_flatbattery_flat. Requiringcharging == falsewould disable the cause on the whole 3.0.21 fleet, which has no bit.long_gapsgap_fail_to_connectoverstatedgap_scan_covered; uncovered counts are omitted.isFeatureEnabledupload_end_marker_offpattern, and the flag has no arms.UI evidence
Telemetry only: no screen, widget or string changes.
UI-Evidence: none
Product invariants affected
none
Failure class (fixes)
The follow-up
fix:commit corrects code that is new in this PR. It is not a released defect.Failure-Class: none
🤖 Generated with Claude Code