Skip to content

SCA-4372: hold sealed mobile Standard batch uploads - #26319

Merged
Git-on-my-level merged 8 commits into
mainfrom
sca4372-mobile-batch-upload-hold
Nov 26, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
sca4372-mobile-batch-upload-hold

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

SCA-4372, app PR. Release verifies the deployed recovery labels from the backend follow-up before ramping. #26334

DESIGN:

  • Reads and writes — no new Firestore reads or writes in the batch upload path. Delay eligibility in the phone's existing WAL drain and keep the existing file, index, acknowledgement, and retry lifecycle.
  • Hold — 300 seconds in the background or while the on-device live preview engine runs, and 60 seconds in the foreground without it. Release the session when pending audio or its oldest sealed file reaches that limit, on foreground, or on capture end. Deadline wakes drain phone WALs without discovering or downloading pendant storage. The existing 300-second and 20-file request caps still apply.
  • Expected batch reads — about 1.37B/day at the issue baseline, falling to about 0.6–0.7B/day at full adoption.
  • Kill switch — PostHog mobile-batch-upload-hold defaults off. Off keeps the immediate per-seal wake and releases held files on the next client tick once the flag is observed. Release provisions the mobile flag through the existing flag store. An active hold refreshes the shared flag snapshot at most once a minute.
  • Ramp — 0→5→25→100 under the SCA-3891 cut guard with Margin GO. Use the latency and never-arrived guards below. Roll back on any lost-audio or custody alarm.
  • Production proof — count units/day from omi_batch_pipeline_unit_diarization_outcome_total and measure batch reads per audio-hour. Compare the settled readback to the SCA-4372 baseline after adoption.
  • Open risks — phone loss or uninstall can remove held audio before cloud acceptance. Check GPU memory with larger units and qualify iOS background timer execution on a device. Suspended apps rely on the next execution window or foreground recovery.

Rollback guards

  • Latency. In server GMP, add the p90 of omi_batch_pipeline_upload_hold_age_seconds to the p90 of omi_batch_pipeline_upload_to_transcript_seconds, grouped by hold_state and filtered to recovered="false" in both histograms. Turn the flag off when the sum exceeds H + 300 s in any state. H is 60 s for fg60 and 300 s for bg300 and fg_preview300. This rule uses two marginal percentiles. The phone computes hold age at HTTP send time from the oldest included seal, capped at one day.
  • Never-arrived. In PostHog, compare Mobile Held WAL Backlog by build, trigger, and cohort. Turn the flag off if the enabled cohort shows a backlog above control, using the count distribution and oldest_held_age_s > H + 900 s for the oldest file's effective hold_state. For an unknown state, including a WAL recovered without an active deadline, use H = 300 s for the backlog check. Use the same time cutoff when comparing against control. A file count is separate from the age cutoff. The app samples sealed mobile Standard files still awaiting acceptance in both cohorts. On-device seal metadata supplies age for held WALs, and capture end supplies the control reference. Each process sends at most one startup sample, one per foreground, and one additional sample per hour. Check delivery and ingestion coverage for both cohorts before using the comparison. The repository records a 2% stable default ingestion sample for unlisted events. Release should verify the keep-list or adequate sampled coverage, especially at 5% rollout.
  • Recovered. The app sends X-Omi-Upload-Recovered: 1 for held WALs recovered from the index or the seal journal. Those requests carry recovered="true" in both GMP histograms and are tracked separately from the latency guard. Recovered and fresh files upload in separate requests under the same size caps.

Product invariants affected

  • INV-CAP-1. Sealing and index publication still run before upload scheduling. Both existing local receipts and unindexed journal files are recoverable after restart. A held sibling also prevents an immutable partial capture claim.

Verification

  • Hermetic Flutter coverage for the three states, foreground and capture-end release, age, flag off, both request caps, journal re-scan, and upload metadata.

Line-Count-Exception: app/lib/backend/http/api/conversations.dart | 1642 -> 1645 | Attach the hold state and age at the existing multipart send.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 5103 -> 5106 | Signal the existing capture-end and rollover boundaries so the hold releases promptly.
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 3212 -> 3256 | Connect WAL lifecycle sampling and recovered request metadata to the existing upload drain.
Line-Count-Exception: app/lib/utils/analytics/analytics_manager.dart | 3155 -> 3168 | Attribute the device signal to the release build and distinguish a resolved off cohort from unavailable flags.

  • omi-heavy run -- flutter test -j "$OMI_HEAVY_CPUS" with the focused hold, capture, upload trace and coordinator tests (113), plus WAL custody, account generation, upload gate and resilience tests (249) — 362 passed.
  • Feature flag registry validation passed.

UI evidence

UI-Evidence: none

This patch changes upload scheduling and telemetry without changing any screens or strings.

Failure class

Failure-Class: none

Hold-age follow-up verification: 228 affected Flutter tests passed, covering dispatch timing, replay age, clamping, disabled flags, and WAL restart recovery.

Targeted Dart analysis and all 228 affected Flutter tests passed after the CI lint correction.

Recovery and backlog follow-up verification: 329 affected Flutter tests passed through omi-heavy, covering indexed and unindexed journal recovery, separate request grouping, send headers, both cohorts, deadline changes, signal cadence, account cutover, and existing WAL and multipart paths. The Dart analyzer ratchet passed after the explicit analytics import correction. Analytics event registry validation passed.

Git-on-my-level added a commit that referenced this pull request Nov 25, 2026
…26318)

SCA-4372, PR 1 of 2. Release lands this before enabling or releasing the
Flutter hold.

DESIGN:
- Reads and writes — no new Firestore reads or writes in admission or
projection. Carry the validated `X-Omi-Upload-Hold` state in the
existing receipt and content-ledger writes. Missing or unrecognized
values report `unknown`.
- Expected batch reads — about 1.37B/day at the issue baseline, falling
to about 0.6–0.7B/day at full adoption of the companion mobile change.
#26319
- Kill switch — PostHog `mobile-batch-upload-hold` defaults off in
Flutter. Off restores the immediate seal wake and releases held files on
the next client tick that observes the flag.
- Ramp — Release provisions the flag before the app ramp and moves
0→5→25→100 under the SCA-3891 cut guard with Margin GO. Roll back if the
per-state guard exceeds H + 300 seconds, or on any lost-audio or custody
alarm.
- Production proof — count units/day from
`omi_batch_pipeline_unit_diarization_outcome_total` and measure batch
reads per audio-hour. Compare the settled readback to SCA-4372 after
adoption.
- Guard expression — by `hold_state`, roll back when phone hold-age p90
from `omi_batch_pipeline_upload_hold_age_seconds` plus server
upload-to-transcript p90 from
`omi_batch_pipeline_upload_to_transcript_seconds` exceeds `H + 300 s`. H
is 60 s for `fg60` and 300 s for `bg300` and `fg_preview300`. Missing
cohort samples leave the guard blind. Sync observes the optional
`X-Omi-Upload-Hold-Age-Ms` on fresh batch admission. It has no Firestore
field or operation. All three Cloud Run GMP profiles retain both
histograms. Filter queries to explicit states on labeled revisions
during the backend roll.

## Product invariants affected

None.

## Verification

- Hermetic multipart requests through the real sync route and intake
assert bounded header propagation through the existing content ledger.
- The completion test exercises the ordinary multi-unit transaction and
asserts one latency sample across a post-commit settlement failure and
terminal replay. The coalescing test verifies both original labels
survive merged completion. The metric tests check closed labels, the
sync and worker registries, and the GMP relabeling rules.
- `omi-heavy run -- bash backend/test.sh
test_batch_pipeline_projection.py test_batch_upload_measurements.py
test_sync_future_early_parity.py test_batch_upload_gaps.py
test_batch_coalescing_completion.py` — 173 passed.

Line-Count-Exception: backend/database/batch_pipeline_projection.py |
1548 -> 1550 | Publish the first durable sample before a post-commit
callback can fail and leave only a replay.
Line-Count-Exception: backend/routers/sync.py | 4196 -> 4205 | Accept
and observe the two optional phone hold telemetry headers at the
existing sync endpoint.


Hold-age follow-up verification: `omi-heavy run -- bash backend/test.sh
test_batch_upload_measurements.py test_sync_future_early_parity.py
test_fleet_deployment.py` — 99 passed.
Git-on-my-level added a commit that referenced this pull request Nov 26, 2026
SCA-4372. Backend follow-up for recovered mobile batch WALs. Companion
app PR #26319

DESIGN:
- Accept exactly `X-Omi-Upload-Recovered: 1`. Both hold-age and
publication latency histograms use `recovered="true|false"`. Absent and
invalid values map to false. The existing five `hold_state` values and
GMP keep-lists cover the new samples.
- No new Firestore reads or writes. Carry the true marker through the
existing intake and completion metadata, including original receipts of
coalesced uploads.
- Expected batch reads remain about 1.37B/day at the issue baseline,
falling to about 0.6–0.7B/day at full adoption of the app hold.
- The default-off `mobile-batch-upload-hold` flag is the kill switch.
Release verifies both deployed histograms carry the recovery label, then
ramps the app 0→5→25→100 under the SCA-3891 cut guard with Margin GO.
- Latency guard. By `hold_state` and with `recovered="false"` on both
GMP histograms, turn the hold flag off if phone hold-age p90 plus server
upload-to-transcript p90 exceeds H + 300 s. H is 60 s for `fg60` and 300
s for `bg300` or `fg_preview300`. Monitor recovered samples separately.
Roll back on any lost-audio or custody alarm.
- Production proof uses units/day from
`omi_batch_pipeline_unit_diarization_outcome_total` and batch reads per
audio-hour.

## Product invariants affected

None.

## Verification

- Affected backend tests through omi-heavy. Upload measurements (72),
ordinary projection (86), coalescing completion (11), and multipart
route and intake parity (30). 199 passed total.
- Tests exercise a recovered ordinary completion and coalesced original,
absent and invalid headers, valid hold-age buckets, and GMP forwarding.

Line-Count-Exception: backend/routers/sync.py | 4205 -> 4208 | Read the
optional recovery header at the existing sync intake.

## UI evidence

UI-Evidence: none

## Failure class

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26334?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26334?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26334&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
…upload-hold

# Conflicts:
#	app/lib/services/capture/capture_composition.dart
#	config/feature-flags.yaml
@Git-on-my-level
Git-on-my-level merged commit ff29c15 into main Nov 26, 2026
74 of 76 checks passed
@Git-on-my-level
Git-on-my-level deleted the sca4372-mobile-batch-upload-hold branch November 26, 2026 05:57
Git-on-my-level added a commit that referenced this pull request Nov 27, 2026
…d hold (#26519)

## Summary

Resolves the accepted review follow-ups for #26319 and #26318 under
SCA-4372. Rollout stays at 0%. Release owns the serving canary and the
decision to ramp.

The handset changes are confined to the existing hold and WAL drain. The
backend reads the gate from the existing request trace in memory and
adds it to the phone-age histogram. The existing intake, coalescing and
publication writes carry the same metadata. Additional Firestore reads
and writes per upload are both zero. Rollback is a revert of this PR
with the hold flag kept at 0%.

## Accepted findings

| Review | Disposition |
| --- | --- |
| #26319 F1 | Already resolved. [Main receives the hold and age
headers](https://github.com/BasedHardware/omi/blob/ba1c952f4ea/backend/routers/sync.py#L797-L802)
and [observes age on batch
admission](https://github.com/BasedHardware/omi/blob/ba1c952f4ea/backend/routers/sync.py#L1424-L1431).
|
| #26319 F2 | Already resolved by the [recovered-WAL
marker](https://github.com/BasedHardware/omi/blob/ba1c952f4ea/app/lib/services/wals/local_wal_sync.dart#L325-L327)
and the [fresh-only guard
filter](https://github.com/BasedHardware/omi/blob/ba1c952f4ea/backend/docs/runbooks/batch-upload-coalescing.md#L98-L103).
[Independent
comparison](https://github.com/BasedHardware/omi/blob/ba1c952f4ea/backend/routers/sync.py#L841)
catches mismatches. |
| #26319 F4 | Tests pin the flag key, refresh cadence, and immediate
release and wake when a refresh completes. |
| #26319 F5 | Proves the actual v2 headers and both histogram series for
all three active states through the hermetic coalescing/publication
path. The
[runbook](https://github.com/BasedHardware/omi/blob/c9a357986ee14f371b2d48e467020de7a530b996/backend/docs/listen_pusher_pipeline/changes/2026-11-25-mobile-upload-hold-metric.md#pre-ramp-latency-receipt)
records the serving receipt requirements for SCA-4508. |
| #26319 F6 | Disposal prevents a final buffer seal from creating a
detached hold. A test closes a real buffer after disposal and verifies
publication. |
| #26319 F7 | Controller regression test verifies that session roll and
capture end both release the active recording before the reporter runs.
|
| #26319 F8 | Held-only drains report pending work and preserve retry
backoff. Tests exercise the local drain, aggregation, provider and
coordinator. |
| #26318 F1 | Tests send held mobile uploads through v2 offer, drain and
durable publication in both merged and individual modes. |
| #26318 F2 | Keeps the batch-admission phone-age family and adds the
bounded gate from the general upload trace. The runbook documents the
filter and the reason for each family. |
| #26318 F3 | Accepts in-range ASCII decimal ages with leading zeroes
and bounds significant digits before converting. Tests exercise padded
valid and out-of-range ages. |

## Verification

- 92 focused Flutter tests passed under `omi-heavy` with `flutter test
-j "$OMI_HEAVY_CPUS"`.
- 2,930 focused backend tests passed across six files selected by
changed files under `omi-heavy`, including the real multipart route and
strict completion transaction.
- The complete backend changed-file selection also passed under
`omi-heavy`. Across 243 files, 12,935 passed and 86 were expected
failures.
- Local repository preflight passed all 51 checks. The pipeline-lab
affected scan selected no scenarios.
- Serving samples and the actual ramp receipt are pending Release's
serving canary.

## Product invariants affected

- INV-CAP-1. Teardown and delayed drain reporting preserve the existing
custody and WAL publication path.

UI-Evidence: none

Line-Count-Exception: app/lib/providers/sync_provider.dart | 1556 ->
1560 | Keep the provider idle and pass the held disposition to the
coordinator.
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 3362
-> 3368 | Distinguish a held-only pass while retaining the local copy
retention sweep.
Line-Count-Exception: backend/routers/sync.py | 4418 -> 4424 | Attach
the existing upload trace to the phone-age observation at fresh
admission.

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/26519?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26519?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26519&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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