Skip to content

feat: gate hidden mobile Standard capture onto lossless upload-and-batch - #21479

Merged
Git-on-my-level merged 9 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mobile-upload-batch
Oct 14, 2026
Merged

Git-on-my-level merged 9 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mobile-upload-batch

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Hidden Standard pendant capture now uses local Silero VAD, a durable journal in the existing Opus WAL format, and the existing sync upload/batch pipeline. Showing the transcript or starting a realtime consumer resumes streaming at the packet boundary without replaying batched audio. The lane defaults off and needs an expiring server capability; old servers keep new clients streaming.

  • Reuses ListenClientState, LocalWalSync, RecordingTransferCoordinator, sync job polling/content dedupe, and backend temporal conversation assignment. Batch files retain recording origin and cannot mix with streamed safety copies in one upload.
  • Retains every original Opus frame, including silence. Sync acceptance archives unchanged bytes before 202 or decoding, with existing enhanced encryption and account-deletion fencing/purge. Today's private-cloud playback decodes/re-encodes Opus; raw sync staging expires. The production bucket lifecycle was checked read-only: the new raw prefix has no Delete rule.
  • Socket transcript expectations pause when batch owns audio and re-arm with a fresh live deadline; BLE ingress health remains active, avoiding false reconnect/recovery episodes. Journals recover after process kill/index interruption. Admission stops at 256MiB/4,096 retained audio files (including torn originals) or unknown/low space (512MiB reserve); pending audio is retained and later packets use existing live capture.
  • MOBILE_STANDARD_BATCH_ENABLED / MOBILE_STANDARD_BATCH_PERCENT / MOBILE_STANDARD_BATCH_UIDS: defaults false/0/empty. Private-cloud sync and no enabled apps, audio webhook, developer realtime-transcript webhook or custom STT are required. Deploy backend-sync archive support before listen authorization. First ramp ≤5% for ≥12h; rollback disables authorization and keeps processing pending files.
  • ONNX Runtime requires iOS 15.1; Podfile and Runner targets advance from 15.0. Flag rollback does not undo this binary minimum. Model is the bundled desktop Silero asset; its MIT license is included.

Validation:

  • Focused Flutter routing/buffer/restart/byte-fidelity/widget suite: 17 tests passed with capture evidence enabled; real controller verifies exclusive WAL/socket ownership.
  • Actual Dart/native Opus + Silero recurrent inference: 60 audio-seconds passed, 24.38 elapsed ms/audio-second. Single-thread arm64 host core benchmark: 300s, 7.08 CPU ms/audio-second (not physical-phone battery evidence).
  • iOS dev simulator build passed at iOS 15.1. Android arm64 ONNX Runtime and JNI LOAD segments have 16KiB alignment.
  • Analyzer ratchet passes with no new diagnostics; raw flutter analyze has the existing 2 generated-code warnings and 93 infos. Backend regressions: 124 passed; final mobile/sync/visibility/backend-demand suite: 249 passed. Real local HTTP archive canary: byte-identical silence before 202; injected archive failure returns 500 before dispatch. Full backend E2E: 128 passed, 3 skipped, 2 expected failures (138s with a 300s local timeout). Full Flutter CI on final head: 5,669 passed, 16 skipped; Final make preflight: 51 checks passed. Final batch/transcript/BLE watchdog/quota/upload/custody suite: 87 passed, including preserved BLE recovery, fresh live deadlines and exact fractional frame-count bounds.

All 11 workflow groups passed on final head d6e9525, including iOS compile, Android compile/JVM/emulator lifecycle acceptance, seeded journeys, full Flutter tests, backend six-shard unit/guardrails and hermetic stack gauntlets.

Physical iOS/Android suspension, noisy-speech recall and power qualification belong to the lead's ramp and workspace battery-hillclimb task. Native capture with a suspended/absent Flutter engine retains its existing route. No PR merge, release, deployment or submission performed.

Implementation, parity finding, benchmarks and release/rollback procedure: app/docs/mobile-standard-batch.md.

UI-Evidence: none

No UI widgets or user-facing strings change; routing uses the existing visibility signal.

Product invariants affected

  • INV-CAP-1: original frames cross the durable write boundary before live suppression. Silence is retained. No BLE subscription or pendant capture is paused to save power; fallback uses existing live/safety WAL capture.

Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 4384 -> 4437 | Only constructor/lifetime, server authorization, session invalidation, packet routing and intentional watchdog handoff hooks live in this owner; journal, VAD and batch policy are separate primitives. Avoids an unrelated capture ownership migration.
Line-Count-Exception: backend/routers/listen/receiver.py | 2510 -> 2520 | Ten-line opt-in client-state capability renewal in the existing control dispatch; admission logic is owned by the runtime and pure cohort helper.
Line-Count-Exception: backend/routers/sync.py | 2646 -> 2651 | One sync-admission-executor archive call at the existing acceptance boundary, before cache/202; the storage primitive owns byte fidelity and encryption; admission does not queue behind background storage saturation.
Line-Count-Exception: backend/utils/other/storage.py | 2049 -> 2075 | One narrowly scoped original-WAL archive primitive plus registration with the existing owner purge; reuses the established bucket, encryption and deletion fence.

Failure-Class: none

Corrects executor placement, recovery/handoff quota accounting and fractional upload bounds in this unshipped, default-off feature; the existing sync-fast-path regression from #7372 is retained and passed locally (204 tests). No deployed incident or new guard is introduced.

@Git-on-my-level Git-on-my-level added the ci:full Maintainer-granted: run full CI on this fork PR label Oct 14, 2026
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 14, 2026 11:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T13:29:50.489747Z d6e9525 Draft marked ready
ℹ️ 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.

@Git-on-my-level
Git-on-my-level marked this pull request as draft October 14, 2026 11:32
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 14, 2026 13:14

@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: d6e95254e9

ℹ️ 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 +211 to +213
await phone.addExternalWal(wal, admittedGeneration: phone.sessionGeneration);
if (wal.ownerUid != SharedPreferencesUtil().uid ||
!await phone.hasDurableWal(wal, admittedGeneration: phone.sessionGeneration)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind batch publication to its capture generation

When sign-out occurs with an open batch, clearAllUserState seals it before SyncProvider.clearUserData advances the phone WAL generation, while preferences still expose the retiring UID. The queued callback can therefore pass the owner check but read the successor sessionGeneration here and admit an old-owner WAL into the successor _wals; the later owner check only throws after that mutation/persistence. Bind the phone generation to the WAL when the batch starts or seals, then reuse that token for both calls so the completion is retired rather than exposed or uploaded after the next login.

AGENTS.md reference: app/AGENTS.md:L108-L108

Useful? React with 👍 / 👎.

deletion owns the prefix. Enhanced protection encrypts the unchanged bytes.
Ordinary legacy sync uploads remain unchanged.
"""
selected = [p for p in paths if Path(p).name.startswith('audio_omimobilebatch')]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate batch claims before permanent archival

On /v2/sync-local-files, any authenticated caller can select this path solely by naming a part audio_omimobilebatch...; the route permits parts up to 200 MiB and declares no whole-request limit. Because this runs before decode, arbitrary or malformed bytes are permanently stored with no TTL, and varying the content produces a fresh digest each time; read_bytes() plus enhanced encryption also materializes full-size heap copies before validation. Check the fixed WAL framing and the legitimate 60-second mobile size bound before archiving, while preserving accepted bytes unchanged.

AGENTS.md reference: backend/AGENTS.md:L205-L205

Useful? React with 👍 / 👎.

(_writer == null && _files >= maxFiles) ||
uid.isEmpty ||
!codec.isOpusSupported() ||
_bytes + payload.length + 4 > maxBytes) {

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 Refresh retained quotas after WAL deletion

When synced batch WALs are removed by the existing auto-remove or user cleanup paths, _bytes and _files remain at their initialization-plus-cumulative-write values because this buffer never observes deletions. Continuous hidden capture therefore reaches the 256 MiB threshold after roughly nine audio-hours and rejects every later packet for the rest of the process even if all prior files have been deleted and disk is empty, forcing the cohort back to live streaming and skewing the battery/network experiment. Recompute retained usage before rejecting, or decrement it from the WAL deletion path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Maintainer-granted: run full CI on this fork PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant