Skip to content

feat(app): flag to seal phone batch files at 15 s instead of 60 s - #26273

Merged
Nizarius merged 2 commits into
mainfrom
feat/mobile-batch-file-cap-15s
Nov 24, 2026
Merged

Nizarius merged 2 commits into
mainfrom
feat/mobile-batch-file-cap-15s

Conversation

@Nizarius

@Nizarius Nizarius commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Adds the PostHog flag mobile-batch-file-cap-smaller (rollout, default off). When it is on, the mobile Standard batch route seals a phone batch file at 15 seconds instead of 60.

A phone batch file is already sealed two seconds after speech stops; the 60-second cap only decides how long continuous speech waits on the phone before it can be uploaded. The goal is that more of a conversation is already transcribed when the user asks for a summary by hand.

  • MobileBatchFileCapGate (app/lib/services/experiments/mobile_batch_file_cap_gate.dart): fail-closed read, 2 s bound. Off, missing, a failed or a late read keeps 60 seconds.
  • MobileBatchBuffer.maxFileSeconds: the seal check uses it instead of the literal 60. Values outside 1 to 60 are ignored.
  • The gate is read once per app launch and never delays the lane: capture starts on the default cap and the answer applies from the next frame.
  • The retained-file limit scales with the cap (4096 files at 60 s, 16384 at 15 s) so the buffer admits the same span of capture. Without this the shorter cap would close the batch route after a quarter of the capture time it allows today. The byte limit is unchanged.
  • No frame is dropped or reordered; only file boundaries move. No server change.

Expected effect, from a production sample of fresh phone-file batch units (2026-11-23)

  • The cap binds rarely today: the median unit is 10 s long and about 1% of units sit at the 60-second cap.
  • Splitting every speech-cut file longer than 15 s into its own unit raises fresh phone-file units by at most 14%. Files sent in one upload request are still joined into one unit when they are at most 30 s apart, so the real rise should be lower.
  • The wait saved is about 2 s averaged over all units and about 20 s for the units that are actually split.
  • Transcription cost follows audio seconds and does not change. What rises with the unit count is per-unit database and storage work, by at most the same 14% on this route.

This flag does not touch the largest wait on this path, which sits after transcription (the ordered-merge head wait). It is the small, cheap part of the latency.

Rollout

Internal devices, then 1%, 10%, 50%, 100%. Watch batch units per captured audio hour, database reads and writes per unit, the sync upload refusal share, the phone's stale-file reports (Local WAL Stuck), and capture end to transcript written into the conversation. Rollback: set the flag to false; clients return to 60 seconds on their next launch. No PostHog row is created by this PR.

Product invariants affected

  • INV-CAP-1

Upheld: every frame is still written to the journal before routing, exactly as today; the cap only decides where one file ends and the next begins. When the buffer refuses a frame (file or byte limit, disk error) the caller keeps the ordinary live and WAL path, unchanged. The new test asserts that the four 15-second files together hold every frame in order.

How it was verified

  • flutter test test/services/wals/mobile_standard_batch_test.dart: 32 passed, including the four new tests.
  • flutter test test/services/wals/batch_ring_proof_test.dart test/services/live_preview/local_preview_routing_test.dart test/unit/wal_upload_resilience_test.dart: 91 passed (the other users of MobileBatchBuffer).
  • flutter analyze on the changed files: no issues.
  • scripts/check_feature_flag_registry.py: OK.

Not verified: a recording on a physical phone with the flag on. The PostHog row does not exist yet; a debug build can force the cap with --dart-define=OMI_MOBILE_BATCH_FILE_CAP_SMALLER=true. The unit and cost figures above are estimates from current production unit lengths, not a measurement of the flag.

Tests

In app/test/services/wals/mobile_standard_batch_test.dart:

  • a 15-second cap seals four files where the default seals one, and the files together hold every frame in order;
  • lowering the cap seals an open file that is already longer, and an invalid cap (0, 61) is ignored;
  • the file limit scales with the shorter cap, and the buffer still refuses a file beyond it;
  • the gate returns 15 only for an explicit true; false and a failed read return 60.

The existing test "60 seconds of silence is still sealed and processed" covers the default.

UI evidence

UI-Evidence: none -- no UI change

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

The mobile Standard batch route seals a phone batch file two seconds after
speech stops, or when the file reaches 60 seconds. During continuous speech
the cap is what decides how long audio waits on the phone before upload.

Add the PostHog flag `mobile-batch-file-cap-15s` (rollout, default off).
When it is on the buffer seals at 15 seconds. Off, missing, a failed or a
late read keeps 60 seconds. The flag is read once per app launch and never
delays the lane.

The retained-file limit scales with the cap so the buffer admits the same
span of capture; the byte limit is unchanged. No frame is dropped or
reordered and there is no server change.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Nizarius
Nizarius requested a review from mdmohsin7 as a code owner November 24, 2026 23:18
…maller

The flag key no longer carries the value. The debug override follows:
OMI_MOBILE_BATCH_FILE_CAP_SMALLER. Behaviour is unchanged (15 s when on,
60 s otherwise).

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Nizarius
Nizarius merged commit fcb82bc into main Nov 24, 2026
66 checks passed
@Nizarius
Nizarius deleted the feat/mobile-batch-file-cap-15s branch November 24, 2026 23:53
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