Skip to content

feat(app): tell a failed pendant from a put-down one in the daily device-health event - #26418

Merged
Git-on-my-level merged 7 commits into
mainfrom
lane/device-dropoff-telemetry
Nov 28, 2026
Merged

Git-on-my-level merged 7 commits into
mainfrom
lane/device-dropoff-telemetry

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

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_events is 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 show charge_events > 0. charge_pin_edges_max and soc_frozen_samples never appear.
  • lost_audio_seconds is by design "time without a link", so it can't hold "connected, no audio".
  • Battery % is readable on only 10–20% of battery-indicator taps, which mostly happen while the pendant is disconnected.
  • The session end reason is connection_timeout for 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 Daily event (schema_version 2 → 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.

Question Fields
Out of range, powered off, or battery flat? gap_cause (battery_flat, out_of_range, power_off, manual, pairing_lost, phone_side, unknown), gap_last_rssi, gap_rssi_age_s, gap_rssi_trend
Last battery level and charging state before the disconnect, and how long before gap_battery_level, gap_battery_age_min, gap_battery_charging
Reconnect attempts failed, or none made? gap_fail_to_connect; iOS, open gap only: gap_saved_reconnect_enabled, gap_reconnect_suppressed
Seen advertising but never connected? iOS: gap_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)
Mic or audio stopped while BLE stayed connected? connected_no_audio_seconds, connected_no_audio_sessions, audio_packets_per_connected_minute
Daily rollup: not connected vs connected with no audio connected_seconds, disconnected_seconds, connected_no_audio_seconds, long_gaps, long_gaps_by_cause
Charging without firmware support charge_inferred_events, battery_min_level, battery_max_level
Support-reported symptoms: disconnects seconds after connecting, stuck at 1%, won't charge, erratic reading short_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, mostly RESET_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 Daily had 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.

  • Added events per active user per day: 0.
  • Added properties: up to 30 keys per daily event (25 on Android), about 22 property values per active user per day, about +0.6 KB per user-day. PostHog bills per event, so there is no added event cost.
  • Phone: one extra pass over data already loaded, once a day.

Kill switch

PostHog flag device_dropoff_telemetry_off (registered in config/feature-flags.yaml, posthog.row: absent, role kill). If it's true, the event drops every new field and goes back to schema_version 2. 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, since sendFeatureFlagEvents is 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 with connected_seconds = 0 after 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_down also requires a battery sample at most 3 hours old. The query runs on PostHog today. It returns no rows until schema 3 ships. Run with connected_time_fraction standing 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 a put_down share.

Firmware follow-up (written up, not implemented)

  1. Roll the 3.0.24+ Diagnostics characteristic out to the fleet. That makes charge_events, the charging bit, reset causes and charge_pin_edges_max real.
  2. In turnoff_all(), terminate the link before sys_poweroff(), with distinct HCI reasons for the button and battery-critical paths.
  3. Persist the last shutdown cause and expose it in the Diagnostics characteristic.
  4. Record a watchdog or hang marker, plus the LED state, that survives a cable reset. Then a 3.0.21 freeze with a solid blue LED reports itself on the next connection.

Verification

  • flutter test test/unit/device_dropoff_signals_test.dart test/unit/device_health_telemetry_test.dart: 59 passed (via omi-heavy).
  • flutter analyze on the changed Dart files: no issues.
  • python3 scripts/check_feature_flag_registry.py: OK. Registry doc re-rendered.
  • The analyst HogQL ran against PostHog (aggregate only).

Layer measured: unit tests and static analysis. The production readback comes after release: run the query above, plus a coverage check of schema_version = 3 and gap_cause presence on the daily event.

Scope panel scope-20261126t154826-3a9e triage

The scope panel (luna, deepseek, glm-flash) returns a dossier without triageable finding IDs (omi-panel triage accepts review findings only), so its 27 risks are triaged here in panel order (R1–R27).

# Risk Call
R1 New fields conflict with the frozen typed registry row Reject. Untyped rollup fields are the established path for this event (#20490 added soc_frozen_samples and others). events.json and the ring-read row are untouched.
R2 Labels are heuristics; a stale battery sample can fake a put-down Accept. unknown stays explicit, and put_down needs a battery sample at most 3 h old.
R3 RSSI 0 or age −1 misclassified Already guarded. Tests added for RSSI 0, age −1 and age 30001.
R4 Reconnect proof ignores lostAudioResolvedAt Accept. Audio resuming now closes the gap, with a test.
R5 Days the app never runs emit nothing Accept. Stated in the query header and the PR.
R6 Zero-audio time is confounded by capture being off Accept. Documented as zero-packet time, not proof of a broken mic.
R7 Typed-registry route would fail CI Accept. Legacy fields only.
R8 7-day and 24 h retention bound coverage Accept. Documented.
R9 Battery samples only exist while connected Accept. Covered by the freshness rule in R2.
R10 Payload grows by about 0.5 KB per user-day Reject. Billing is per event, and the size is stated.
R11 No dedup across installs Reject. Existing behavior, out of scope.
R12 8-day replay vs 7-day rings Reject. Pruning drops the oldest rows first, so the latest retained gap is the true latest. The existing connection_history_incomplete flag marks partial days.
R13 Android fallback snapshot has no connected_at Reject. It inherits connected_time_fraction's existing behavior.
R14 Mixed row types could corrupt gaps Already filtered to disconnect rows, and tested.
R15 Map properties may not be queryable Reject. JSONExtractKeysAndValues on disconnects_by_reason ran in PostHog during design.
R16 Kill-switch path and name rules Already compliant. The registry check passes.
R17 Bucket on properties.day, not timestamp Already does. Now stated in the query header.
R18 out_of_range may rarely fire Accept. The post-release readback measures the unknown share.
R19 Restarted counters fake zero-audio sessions Accept. A packet last_at inside the session vetoes it, with a test.
R20 phone_side is Android-only Accept. Documented.
R21 Stop day lost if the app is not opened within 7 days Accept. Documented.
R22 Schema 3 with missing keys is ambiguous Reject. A killed event emits schema 2.
R23 disconnected_seconds must use the corrected value Already does.
R24 Existing fields must stay unchanged Accept. A test asserts every legacy key's value is equal with the fields on or off.
R25 Storage growth Reject. Duplicate of R10.
R26 Flag read cost Reject. Read once per emission.
R27 Malformed rows Accept. Malformed-row test added.

Review panel review-20261126t160746-ed30 triage

# Finding Call
F1 Missing days pass the stop's zero-connection check Accept. Each of the 3 stop days needs an event at zero.
F2 Android connected_at is stamped before GATT succeeds Accept. The open link counts only once a packet arrives on it, with a test.
F3 An unknown charging bit can fake battery_flat Accept, modified. A level rising into the loss now vetoes battery_flat. Requiring charging == false would disable the cause on the whole 3.0.21 fleet, which has no bit.
F4 A gap maturing after its start day was emitted misses that day's long_gaps Reject. It needs a gap starting within 30 min before an after-midnight emission, and the next day's gap fields still describe it.
F5 Person-day rows mix devices Accept. The query works per pendant model, restricted to Omi pendants.
F6 Cause coverage differs by platform Accept the documentation part: per-platform coverage is now in the doc. Native changes (Android manual rows, status 137 mapping) are out of scope for this Dart-only PR.
F7 gap_fail_to_connect overstated Accept. Reworded, and taken out of the hardware rule into its own column.
F8 Null scan counts never reach PostHog Accept. Added gap_scan_covered; uncovered counts are omitted.
F9 Full-log branch untested Accept. A 500-row boundary test was added.
F10 Kill switch reads isFeatureEnabled Reject. It matches the sibling upload_end_marker_off pattern, 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

Git-on-my-level and others added 4 commits November 26, 2026 10:55
…-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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T14:36:02.484750Z a5ec19e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +73 to +76
if (connectedAt > 0 && connectedAt < observedAt)
(
start: connectedAt,
end: observedAt,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment thread app/docs/device-dropoff-telemetry.md Outdated
Comment on lines +112 to +113
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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +457 to +459
'connected_seconds': connectedMs.clamp(0, end - start) ~/ 1000,
'disconnected_seconds': disconnectedMs ~/ 1000,
'audio_packets_per_connected_minute': connectedMs < 60000 ? null : received * 60000 ~/ connectedMs,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +79 to +83
if (linkProven && connectedAt < observedAt)
(
start: connectedAt,
end: observedAt,
packets: diagnostics['audio_packets_received'] is int ? diagnostics['audio_packets_received'] as int : null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +329 to +330
if (DeviceDropoffSignals.linkEstablished(diagnostics)) {
establishedMs += exposureEnd - activeSince.clamp(start, exposureEnd);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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]>
@Git-on-my-level
Git-on-my-level merged commit 2de7dd0 into main Nov 28, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/device-dropoff-telemetry branch November 28, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant