Repository navigation
feat(app): capture regression gates — continuity suite, invariant monitor, rollout-hop capture health - #22892
Conversation
A pendant reconnect landing inside its own reconnect sync pass skipped capture start, nothing re-drove it, and the pass could hang forever on an untimed BLE read. A connected but unsubscribed legacy pendant discards audio, so ~4 h was lost (2026-10-20). Uploads stalled behind the same stuck pass. - Only the OS periodic window fences live capture; a swallowed pendant start is replayed when the fence drops; foreground starts an idle connected pendant. - Transfer passes get a hard time limit (60 min, 10 min fenced) that releases the fence and the in-flight pass; the watchdog wakes while rows are pending; any network change wakes a pass; retries and cooldown-end run in background. - Server close, network change and resume kick an immediate bounded-backoff socket reconnect; the keep-alive can no longer die for good. - Pendant audio reaching the transport with no capture listener is persisted to the safety WAL (unless muted or caller-stopped). - BLE read/write timeouts in Dart; iOS queues same-characteristic reads and writes FIFO with a 10 s timeout instead of orphaning the first caller. - Capture Recovery Observed analytics event; multipart body read timeout. Failure-Class: FC-automatic-capture-pause-without-retention Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ence orphan WAL priming, stop abandoned passes - A start swallowed by a sync fence is replayed unless the pendant already owns capture or a caller stopped it; the reducer records a suspension when a phone recording or call owns capture. - Orphan WAL priming takes a codec boundary only while the transport still has no listener, rechecks after the await, skips it when the WAL already tracks the pendant codec, and drops (never mis-tags) packets otherwise; a full backlog drops the oldest packet. - A timed-out pass is marked stale and stops at its next stage boundary; it keeps the transfer keep-alive until it exits, and no later pass discovers or drains beside it (bounded by a second time limit). Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # app/lib/services/connectivity_service.dart
…e abandoned-pass gate, honour late GATT replies - Orphan audio is written synchronously and only while the WAL already tracks the pendant codec; it never takes a codec boundary, so it cannot race a live start or wipe a session that subscribed meanwhile. - An abandoned transfer pass blocks discovery and drain until it really exits (no time-based release); every stage, including the post-drain refresh/reconcile tail and the catch path, returns once the pass is stale. - iOS: after a GATT timeout the next op waits for CoreBluetooth's late reply (or a 5 s grace) and that reply is never handed to the next waiter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…itor, rollout-hop capture health Builds 1.0.560-563 (#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 #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-#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 #22873 (fix/app-capture-recovery). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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: 600bcff043
ℹ️ 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".
| def resolve_build(stats: Stats, os_name: str, version: str) -> str | None: | ||
| """The store build of a marketing version: its build with the most pendant users.""" | ||
| builds = [(key[1], row) for key, row in stats.items() if key[0] == os_name and row.version == version] | ||
| if not builds: | ||
| return None | ||
| return max(builds, key=lambda item: item[1].pendant_users)[0] |
There was a problem hiding this comment.
Resolve the exact App Store build before judging health
When multiple iOS build numbers share the live marketing version, this selects whichever build has the most pendant users, which can be a TestFlight sibling rather than the binary in the phased App Store rollout. run_ios() then uses that verdict to decide whether to jump the rollout to 100%, so a healthy sibling can mask a regression in the production build. Resolve the live version's attached build from App Store Connect and judge that exact build number.
Useful? React with 👍 / 👎.
| for (final frame in source.processBytes(List<int>.from(packet))) { | ||
| phone.onFrameCaptured(frame, captureRoot: _captureEvidenceRoot); | ||
| } | ||
| CaptureContinuityMonitor.instance.onFrameInCustody(); |
There was a problem hiding this comment.
Only mark orphan frames after WAL admission succeeds
When storage admission is blocked and the pendant buffer has reached its 2,000-frame cap, LocalWalSyncImpl.onFrameCaptured() drops the frame and returns without storing it, but this path still calls onFrameInCustody(). During a connected-without-listener episode, continued orphan packets therefore keep refreshing the custody timestamp even though every frame is being discarded, suppressing the new wedge alert and rollout signal during actual audio loss. The WAL API needs to report whether admission succeeded before custody is recorded.
Useful? React with 👍 / 👎.
| DispatchQueue.main.asyncAfter(deadline: .now() + Self.gattLateReplyGrace) { [weak self] in | ||
| guard let self, self.lateReadReply.remove(key) != nil else { return } | ||
| self.issueNextRead(key) |
There was a problem hiding this comment.
Retire the old GATT reply before issuing the next operation
If a timed-out CoreBluetooth operation replies after the five-second grace period, this code has already removed the late-reply marker and issued the next request for the same characteristic. Because the delegate callback carries no operation ID, that old reply will dequeue and complete the new request, after which another request may be issued while the real new operation is still outstanding. This can return stale read data or falsely acknowledge writes whenever a BLE reply arrives more than 15 seconds after issuance; reconnect or otherwise invalidate the characteristic queue instead of advancing it on a timer.
Useful? React with 👍 / 👎.
| hold = capture_health_hold("ios", version=version) | ||
| if hold: | ||
| return False, f"phased rollout is {age_hours:.1f}h old; held on capture health: {hold}" |
There was a problem hiding this comment.
Pause the iOS phased release when capture health holds
Returning False here only suppresses the train's early jump to 100%; it does not stop Apple's active phased release from advancing on its normal day-by-day schedule. Consequently, a BAD or unknown verdict can still widen exposure automatically after the first day and eventually reach 100%, contradicting the workflow's promise that capture health holds the rollout in place. The hold path needs to PATCH the phased release to PAUSED or otherwise apply an actual App Store brake.
Useful? React with 👍 / 👎.
| key = env.get(KEY_ENV, "").strip() | ||
| if not key: | ||
| raise CaptureHealthError(f"{KEY_ENV} is not configured for this workflow") |
There was a problem hiding this comment.
Provision the PostHog key for both Codemagic rollout lanes
Both production callers reach this branch without POSTHOG_PERSONAL_API_KEY: the committed mobile-daily-train and mobile-rollout-advance definitions import only the google_play variable group, so every scheduled check returns an unknown-health HOLD and Android rollout hops stop indefinitely unless someone manually overrides them. Codemagic requires a secret's variable group to be referenced by the workflow, as described in its environment-variable documentation; import a read-only PostHog group in both lanes before enabling this gate.
Useful? React with 👍 / 👎.
| final codec = state.codecByDevice[deviceId]; | ||
| final phone = _wal.getSyncs().phone; | ||
| final persistable = codec != null && codec.isOpusSupported() && phone.currentCodec == codec; |
There was a problem hiding this comment.
Buffer orphan packets until their codec is known
When a native-restored subscription forwards audio into a fresh CaptureController while a periodic sync fence has deferred capture startup, codecByDevice is still empty because the codec read only occurs during the deferred start. Every packet therefore takes this non-persistable path and is permanently dropped for the duration of the fence, recreating the audio-loss condition this orphan route is intended to prevent. Buffer the raw packets until the codec is resolved, or resolve the codec before deferring the start, instead of requiring a prior live session to have populated the cache.
Useful? React with 👍 / 👎.
… failure, timer lifetime, strict ledger
- iOS phased jump judges the build attached to the live App Store version
(GET /v1/appStoreVersions/{id}/build), never a same-version sibling.
- check_rollout holds on any exception, so a dropped PostHog body cannot abort
the train before other platforms or the candidate submit run.
- The continuity timer is cancelled synchronously on dispose and re-synced on
stage-only device updates.
- PendantFrameLedger requires the synthetic fill, so real 80-byte Opus audio
is never counted as a pendant frame.
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: 0fce883621
ℹ️ 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".
| final custody = _lastCustodyAt; | ||
| final silentSince = custody != null && custody.isAfter(since) ? custody : since; | ||
| if (now.difference(silentSince) < threshold || _declaredAt != null) return; |
There was a problem hiding this comment.
Resolve the episode when custody resumes
If orphan routing begins successfully persisting frames after this monitor has already declared a wedge, onFrameInCustody() advances silentSince, but this branch returns because _declaredAt is non-null and never calls _resolve. As long as the capture subscription remains absent, the dogfood banner therefore continues claiming audio is not recorded, no recovery event is emitted, and a later failure of the orphan path cannot open a fresh episode. Treat resumed custody as recovery before applying the declaration guard.
Useful? React with 👍 / 👎.
| ClientTelemetry.instance.observeWedge( | ||
| operationId: const Uuid().v4(), | ||
| phase: 'detected', | ||
| trigger: trigger, | ||
| outcome: 'pending', |
There was a problem hiding this comment.
Mirror the recovery to the replacement collector
When client-telemetry migration is enabled, detection writes a pending wedge using this fresh operation ID, but the ID is immediately discarded and _resolve only emits the legacy Capture Recovery Resolved event. The replacement collector therefore never receives a matching phase: 'resolved'/outcome: 'recovered' terminal, so after PostHog retirement every recovered connected_not_capturing episode remains permanently pending and its recovery latency is lost. Retain the operation ID and mirror resolution as CaptureWedgeMonitor does.
Useful? React with 👍 / 👎.
| hold = capture_health_hold("android", build=codes[0]) | ||
| if hold: | ||
| return f"android=staged {staged_version} {codes[0]} @{current:.0%} held on capture health ({hold})" |
There was a problem hiding this comment.
Check every APK in a multi-code staged release
When Play returns an in-progress release with multiple versionCodes, this checks only codes[0] even though the subsequent hop preserves and advances every code in that release. Google documents versionCodes[] as all APKs in the release and an inProgress release's APKs as being served according to userFraction (Play Developer API); therefore a regressed APK in codes[1:] can expand to the next fraction while a healthy first code passes the gate. Judge every newly staged code, or otherwise identify the exact APKs whose exposure the hop expands.
Useful? React with 👍 / 👎.
| 'Share Debug Logs now, then force-quit and reopen Omi.', | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Localize the TestFlight banner
This banner is enabled for every TestFlight build, not only local debug sessions, so these hardcoded title and message strings are displayed to TestFlight users in English regardless of locale. Move both strings into the localization resources and reference them through context.l10n; the app guide requires all user-facing strings to use that path.
AGENTS.md reference: app/AGENTS.md:L118-L118
Useful? React with 👍 / 👎.
… of failing the iOS train
Parsing of GET /v1/appStoreVersions/{id}/build moved inside the lookup's
try: a 200 without an attributes dict now means 'unknown build' (the
capture-health hold fails closed) rather than a TrainError that skipped the
rest of run_ios. Tests cover the malformed bodies the module stub hid.
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: 10d6231920
ℹ️ 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".
| SELECT properties['$os'] AS os, toString(properties['$app_build']) AS build, person_id, | ||
| max(100.0 / greatest(coalesce(toFloatOrNull(toString(properties['omi_sample_pct'])), 100.0), 0.01)) AS w | ||
| FROM events | ||
| WHERE event = 'Capture Wedge Detected' AND properties['trigger'] IN ({triggers}) |
There was a problem hiding this comment.
Keep wedge events available to the rollout gate
When OMI_CLIENT_TELEMETRY_POSTHOG_RETIREMENT is enabled, both continuity and existing wedge monitors suppress Capture Wedge Detected before it reaches PostHog (capture_composition.dart:185-188 and 206-208), but this gate still queries only PostHog. With Device Session Ended rows still supplying the denominator, affected builds appear to have zero wedge users and can pass both the ratio and absolute-cap checks; keep these events in PostHog until the gate is migrated, or read the replacement collector here.
Useful? React with 👍 / 👎.
| WHERE event = 'Device Session Ended' AND timestamp >= now() - INTERVAL {int(hours)} HOUR | ||
| AND properties['$os'] IN ('iOS', 'Android') |
There was a problem hiding this comment.
Restrict the denominator to in-scope capture devices
Device Session Ended is emitted for every DeviceType and includes a device_vendor property, but this denominator counts all of them while the selected wedge triggers cover only the Omi/OpenGlass/Friend capture paths. On builds with Apple Watch, Plaud, Bee, Fieldy, Limitless, or Ray-Ban users, those users therefore dilute the candidate's wedge rate even though they cannot produce either numerator trigger, allowing a pendant regression below the absolute 50-user cap to pass the rollout gate. Filter the session rows to the device population covered by these triggers.
Useful? React with 👍 / 👎.
| row = stats.get((os_name, str(build))) | ||
| if row is None or row.rate is None: | ||
| return Verdict(True, f"{os_name} {build}: no pendant sessions in the last {hours}h; cannot judge capture health") | ||
| per_day = row.wedge_users * 24.0 / hours |
There was a problem hiding this comment.
Normalize the cap by the build's actual exposure time
For a newly staged build, this divides its observed wedge users by the full 48-hour lookback even though the build may have been exposed for only the four-hour Android or twelve-hour iOS observation window. For example, 80 users wedging during a new Android build's first four hours are reported as 40 users/day and remain below the 50/day cap; if the ratio comparison is unavailable or the baseline rate is already elevated, the rollout advances despite already exceeding the absolute cap. Base this normalization on the candidate's first exposure/event time, capped by the configured lookback.
Useful? React with 👍 / 👎.
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_bytesover 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)SimulatedPendantgives every BLE packet a unique frame id. The link models firmware 3.0.21:PendantFrameLedgerfinds 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.deviceConnectedpass, which must resume while the pass is still stuck;2. Debug and TestFlight: capture-continuity invariant monitor
connected_no_byteswatchdog only watches open capture sessions. In the feat(app): tiered pendant capture — pause the live uplink after silence, resume on foreground or charge #20837 state there was no session, so it was blind. It is also already exempt from themobile-capture-recovery-v1gate, so making it "unconditional" would not have helped.CaptureContinuityMonitorchecks every 15 s while a pendant is connected. It declaresCapture Wedge Detectedwithtrigger=connected_not_capturingwhen all of these hold for 60 s:Capture Recovery Resolvedfires when capture returns;CaptureContinuityDogfoodBanner) shows only inkDebugMode || Env.isTestFlightbuilds.3. Store rollout hops: capture-health hold (
app/scripts/mobile_capture_health.py)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.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.GET /v1/appStoreVersions/{id}/build), never a same-version sibling;connected_not_capturingfrom layer 2;capture_health_override=<reason>onmobile_daily_train.ymland onmobile_rollout_watch.yml(new manualworkflow_dispatch) lets one run through, with the reason logged. No new workflow file.Before merge (decision for a maintainer)
mobile-daily-trainandmobile-rollout-advanceonly have thegoogle_playenv group. AddPOSTHOG_PERSONAL_API_KEY(query read) to a Codemagic group and list it in both workflows incodemagic.yaml. Until then, every hop fails closed (HOLD); use the override input to advance deliberately.Review
IncompleteReadcould have aborted the train);previous_build), not the highest build number;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 analyzeon 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 localon 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
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