Repository navigation
feat(audio): losslessly compact new custody PCM writes (SCA-2302) - #25326
Merged
Merged
Conversation
This was referenced Nov 14, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Nov 15, 2026
Instrumentation only for SCA-2302. Sibling of the merged #25326 and #25357; no behavioural correction, no competing review. ## Why `omi_audio_pcm_storage_seconds` times the whole optional step, so production data could not say which codec child consumed the time or how far a killed child overran its own granted budget. Release's historical 5-minute vectors put ~86% of admitted attempts inside the single `(0.25, 0.5]` bucket, which is exactly the resolution that query cannot provide. ## What changed Three files, no behaviour change: - `backend/utils/other/audio_pcm_storage.py` — two diagnostic histograms and their observation points. - `backend/tests/unit/test_audio_pcm_storage.py` — exactly-once and no-observation tests (10 new cases). - `backend/docs/runbooks/audio-durable-outbox.md` — a diagnostics subsection with the read queries, costs and limits. | metric | labels | observed | | --- | --- | --- | | `omi_audio_pcm_storage_stage_seconds` | `stage={encode,decode}`, `child_result={success,timeout,error}` | once per child that actually ran, timed from just before `subprocess.run` through its return or handled exception | | `omi_audio_pcm_storage_stage_timeout_overshoot_seconds` | `stage={encode,decode}` | only for a child killed by its own timeout: full stage wall time beyond the granted timeout | `child_result` is that child's own outcome, not the call's terminal decision — a `success` encode on a call that later keeps PCM still reports `success`. Both histograms use `(.005,.01,.05,.1,.25,.5,1,2)`; eight children are pre-created and never observed at zero, so `increase()` can see a first burst without a fabricated sample. ## Unchanged Subprocess argument vectors, `_stage_timeout`, the 0.4 s shared budget, the 0.08 s decode reserve, the single codec slot, eligibility bounds, the savings floor, byte-exact verification, PCM fallback, `DECISIONS`/`INPUT_BYTES`/`SAVED_BYTES`, the single `record_fallback` on `deadline`, and every custody/ACK/reader/object-lifetime semantic. `omi_audio_pcm_storage_seconds` keeps its buckets, and the p99 guard keeps its threshold and population. The timestamps are taken around the child only, after each granted timeout is already computed, so no forwarded timeout changes. ## Cost 88 new series per pod with the pinned `prometheus-client==0.21.1` (8 children x 11 series: 8 buckets, `+Inf`, `_sum`, `_count`); 96 if a client also emits `_created`, which is the owner's ceiling. One clock read and one local tuple append per child that runs, plus a flush after the slot is released. Disabled, ineligible and busy calls allocate nothing and observe nothing. No per-request, content, size or account label. ## Limits, stated in the runbook Overshoot includes startup, cleanup and thread descheduling, so it is neither a pure process-start cost nor a wall-clock bound. Stage series are empty while the compression flag is `false` because no child runs — absent data is not a fast encode. A missing observation, scrape gap, counter reset or silent target is UNKNOWN, never a zero pass. The whole-helper-minus-stage difference is an approximate diagnostic, not exact admitted overhead: the populations differ, the two histograms use different monotonic clocks, the flush is after slot release, and scrape-window boundaries differ. Merging or deploying this cannot pass the failed pusher canary and is not a reactivation, a qualification or a savings claim. Reactivation still needs separate scoped Release authorization plus independent both-surface verification. ## Verification - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_audio_pcm_storage.py`: **46 passed**, including all pre-existing codec, custody-frame and gapped-pack coverage. - `make preflight`: **37 checks passed**. - Pre-push gate passed. New tests cover: encode+decode each observed once as `success`; encode timeout with one overshoot and no decode observation; decode timeout reporting `encode=success`/`decode=timeout` with original PCM, one fallback and the slot released; a handled child error recorded as `error` with no overshoot; `not_smaller` observing only the successful encode; disabled/ineligible/busy observing nothing and leaving the live counters untouched; and the eight children existing at zero before any observation. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/25414?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/25414?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25414&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. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New custody PCM is stored uncompressed even when it contains long silent intervals. Listen and pusher now share a bounded representation helper: use lossless FLAC only when decoding reproduces every PCM byte and saves at least 5%; otherwise retain PCM.
Packs without a complete PCM identity proof retain their original container. No classifier or hosted call is added. The existing media/manifest commit barrier, consent, encryption, frame positions and generation/hash verification continue to apply. Existing readers already handle FLAC. Native Opus, PCM8, mobile originals, PCM projections and historical objects are unchanged. No expiration, deletion, storage-class migration or rewrite job.
The margin-owner follow-up adds an optional-step timing histogram, zero-initialized outcome counters, actual hung-child timeout and busy-capacity custody-commit tests, and exact per-surface canary queries and rollback thresholds. The review follow-up counts input bytes only after eligibility and encoder-slot admission, and documents verified per-attempt saved bytes. CI and independent review must cover the final head.
Validation:
test.shrunner passed all 82 tests in the existing desktop-batch file. Its old raw-container equality assertion now checks verified recovered PCM for compressed captures and exact original bytes for uncertain captures.08eace0d360d2e11479e483dd1fbfc77f2bcead7.Release: SCA-2302; deployment intake SCA-2304. David requested implementation here and deployment through Release. The single independent Multica review of record plus green exact-head CI is required before merge. Release owns listen/pusher deployment, rollback and a full 30-minute canary with serving-source proof. The runbook requires eligible traffic, verified FLAC outcomes and committed FLAC-byte growth, zero new integrity failures, and quantitative optional-latency/custody-failure thresholds. Set
AUDIO_CUSTODY_PCM_COMPRESSION_ENABLED=falseto stop new compression while preserving custody and FLAC reads. No capacity, access or storage-retention change is requested.Failure-Class: none
This first-release correction updates an existing container-byte assertion to validate losslessly recovered PCM and keeps unproven zero-sample originals in their raw container. The review follow-up corrects pre-release attempt-byte accounting and adds regression coverage for admission, fallback and retries. No existing merged failure class is claimed.