Repository navigation
fix(batch): read gapped, unframed raw-live packs through their custody manifest - #25045
Merged
Merged
Conversation
…y manifest A live capture pack can carry gap_count != 0 without a declared frame_schema. CapturePack.append counts a capture-clock discontinuity and a retained zero-sample frame alike, while capture_start/capture_end span the whole wall interval. LiveAudioArchive only declares frame_schema when the framed cohort admits the owner, so the default fleet writes gapped packs with no frame table in the media metadata. raw_audio_read skipped every such pack, and the decoder measured its expected length from the wall span, so nothing could be listed or decoded. commit_capture always writes the custody manifest beside the media under the same name, even when the media metadata omits custody_manifest_path. Read that manifest for gapped, unframed packs and position each recorded frame on the capture clock: listing emits one entry per contiguous run, decoding walks the recorded frames and verifies each packet against the manifest, and gaps stay explicit. retained_record_units now honors raw_offset_samples and the fragment span, so a multi-entry pack is no longer read whole for every entry. RAW_LIVE_GAPPED_PACKS_ENABLED is a default-on ops kill switch; off restores the previous skip. No audio is fabricated, no timestamp is shifted, and no retained bytes are deleted.
…e retained proof The retained proof reads every chunk through read_reference, which decoded raw-live packs with decode_capture. A gapped pack's retained zero-sample frames are not decodable opus packets, so the proof still failed on exactly the packs this change targets. Resolve the writer's custody manifest in read_reference and decode through decode_capture_frames for omi-wal packs; gapped flac/pcm16 packs keep the ordinary decoder because their encoded bytes are the contiguous captured PCM. Also key the conversation manifest index by the writer's shared name so a single-segment pack name matches, and compare the next overlap against the raw fragment's tail rather than the whole pack.
…ode-deepseek-v4/cba7b8268396 # Conflicts: # config/feature-flags.yaml
Git-on-my-level
added a commit
that referenced
this pull request
Nov 20, 2026
## What changed and why Quarantine recovery re-reads only the mismatched retained source, once, under the same privacy and generation fences. Both reads must disagree with the manifest's SHA-256 of decoded PCM before recovery commits `failed_held` with `retained_digest_changed`. The successful CAS emits the bounded `omi_fallback_total` reason; the task receives 200 and duplicate deliveries and automatic redrive do not retry the source. A matching confirmation resumes ordinary recovery. Storage outages, missing inputs, invalid manifests, and switched-off target 409s keep their existing paths. The SHA-256 check, custody, expiry/deletion policy, and reviewed operator redrive are unchanged. Set `BATCH_PIPELINE_RETAINED_DIGEST_HOLD_ENABLED=false` to restore the legacy single-read 500 for new mismatches without altering existing held rows. Recovery, merge, projection, expiry, and metrics readers are listed in `backend/utils/batch_pipeline/CONTRACT.md`. State exit: retained_digest_changed is a refusal reason on the existing terminal failed_held state. Normal retained dead-letter expiry still applies, and only a reviewed operator redrive can requeue the row. ### Cause evidence An offline native-Opus probe reproduced the exact digest failure with identical object bytes and generation. Admission's `source_metadata=True` read used the frame table to skip a zero-sample diagnostic packet; recovery used the plain decoder, which decoded that packet. The asymmetric branch arrived in #25045, before #25675. A rewrite to a different generation cannot satisfy the pinned read. This proves a decoder path can cause the error without a rewrite; it does not identify the affected production cohort or establish the rollout trigger. This change does not alter decoder selection or regenerate manifests. ## Product invariants affected none ## How it was verified - M1, Python 3.11: `env PYTHON=.venv/bin/python bash test-preflight.sh` passed all 18 checks. - M1, `BACKEND_PYTEST_WORKERS=2 bash test.sh` with 10 selected unit files: digest, invalid/missing inputs, artifacts, serving, held dead-letter, projection exception taxonomy, pipeline sim, flag budget, and quarantine recovery. All selected files passed after rerunning the three affected fixture/flag files. - Held-custody, recovery-admission, and recovery-custody conformance: 112 simulator cases passed; 56 Firestore emulator cases skipped because no loopback emulator was running. - `make preflight` passed all 44 checks; the offline native-Opus decoder probe passed. - Not verified: the post-deploy one-hour error window. No production reads, writes, merges, or deploys for this PR. ## Tests `backend/tests/unit/test_batch_pipeline_retained_digest_hold.py` exercises the real FastAPI handler, manifest materialization, and recovery transactions with synthetic pinned reads. It covers confirmed mismatch, delivery replay, transient mismatch, read outage, rollback, stale intent, changed URI, privacy revocation, and automatic versus reviewed redrive. ## UI evidence UI-Evidence: none -- backend recovery only ## Failure class (fixes) Failure-Class: FC-batch-fault-domain-head-of-line-poison <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/25761?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/25761?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25761&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.
What changed and why
The #25000 orphan repair's retained proof recovers nothing from the 10,942
sealed-and-received stale
batch_livecandidates: every sampled candidate'sretained raw-live objects are gapped and unframed, and
raw_audio_read.list_packsskipped every such pack. This change reads thosepacks through the custody manifest the writer already committed, so listing,
decoding, and the retained proof all see the audio that is actually there.
Gap semantics (base
9c051da5be4b).backend/utils/other/raw_audio.py:156-160(CapturePack.append):gap_countincrements when the next frame's server-projected
timestampdiffers from theprevious frame's end by more than 2 ms, and again for every retained
zero-sample frame. It is a count of discontinuities, not a duration.
backend/utils/other/raw_audio.py:196-199(CapturePack.encoded):capture_start/capture_endspan the whole wall interval, while the omi-walpayload is only the concatenation of captured packets. Decoded PCM is
therefore shorter than the wall span by the total gap time.
backend/utils/other/live_audio_archive.py:253-260(_write):frame_schemais set only when
framed_pack(uid)(AUDIO_CUSTODY_FRAMED_PERCENT) admits theowner and every frame has samples. The default fleet therefore writes gapped
packs with
gap_count != 0and no frame table in the media metadata.backend/utils/other/audio_outbox.py:82-119(commit_capture): the custodymanifest is written for every durable pack under the same name as the media,
but
custody_manifest_pathis recorded in the media metadata only when framed.The manifest is the writer's own record of each frame's byte range, sample
count, and capture start, so it is the only truthful source for a gapped
pack's internal gap positions.
backend/utils/other/raw_audio_read.py:72(base):(not framed and int(metadata['gap_count']) != 0)skipped the pack outright.backend/utils/other/raw_audio.py:113-116(base): the opus omi-wal decoderdecoded the container as one continuous stream, which would have closed the
writer's gaps.
What the change does.
list_packsresolves a gapped, unframed pack's manifest from oneaudio-outbox/{uid}/{conversation_id}/prefix listing and emits one entry percontiguous run, with
raw_offset_samplesinto the unchanged pack and theframe's true
start. Gaps stay explicit; nothing is closed or resampledacross them.
_decode_packmeasures the expected length from the sum of recorded samplesand decodes through
decode_capture_frames, which verifies each packetagainst the manifest's byte range and digest and skips retained zero-sample
frames.
retained_record_unitsnow honorsraw_offset_samplesand the fragment span.Without that, a multi-entry pack was read whole for every entry, duplicating
audio and closing the writer's gaps.
is fabricated, no timestamp is shifted, and no retained bytes are deleted.
Product invariants affected
none
Tuning
No numeric capacity, rate, or budget changed. The only new knob is the
default-on ops kill switch
RAW_LIVE_GAPPED_PACKS_ENABLED; there is no percentramp. The extra I/O is one
audio-outboxprefix listing per conversation thatactually contains a gapped, unframed pack, plus one small manifest read per such
pack; both are bounded by the existing
max_count/deadline budget and theexisting 120 s pack-index cache.
New states and exits
No new repair disposition or exit.
sealed_received_audio_secondsnow countsonly captured samples (gap time excluded);
sealed_received_stt_secondsstillspans the gap because that silence is what a batch provider is billed for. A
gapped pack whose manifest cannot be resolved keeps today's behavior: it is not
listed, and the row still exits
storage_empty_received/operator_rerun.How it was verified
Repository
BasedHardware/omi, worktree/Volumes/Ephemeral/scratch/worktrees/omi/omi-lane-gappedpacks-upstream-keep-clean,branch
lane/gappedpacks, baseorigin/main9c051da5be4b.ro-prod(no content reads, no uidsor paths printed): of 2,000 listed
raw-live/objects, 1,169 hadgap_count != 0; 1,168 of those were opus with noframe_schema, and 1,168had no
pcm_sha256. A 25-object check confirmed each gapped pack has exactlyone
audio-custody-manifest-v1object under the matchingaudio-outboxname.This establishes the field shape the fixtures reproduce; it is not a fleet
repair measurement.
backend/tests/unit/test_raw_live_gapped_packs.py(new, 10 tests) drives thereal writer (
CapturePack+commit_capture) to produce the productionobject shape, then exercises listing, decode, proof spans, materialization,
the zero-sample-frame case, the kill switch, a missing manifest, the
continuous-pack regression, and the framed path.
test_audio_custody_frames,test_audio_durable_outbox,test_audio_projection_raw_read,test_audio_chunk_archive_listing,test_audio_raw_read_metrics(287passed);
test_record_orphan_repair,test_record_gap_fill,test_source_audio_listing,test_record_seal_*,test_record_partial,test_restore_recording_obligation(443 passed);test_sync_ingest_archive,test_batch_pipeline_custody_property,test_audio_cleanup_custody,test_batch_cleanup_custody,test_sync_playback_frame_alignment,test_conversation_frame_evidence(106 passed);scripts/test_check_feature_flag_registry.py(109 passed).scripts/check_feature_flag_registry.pyreports OK; the registry doc wasregenerated from
config/feature-flags.yaml.Not verified: no production audio was decoded, no repair was planned or applied,
and the #25000 apply path is untouched and stays off. The fleet-wide
register-versus-park count remains unmeasured.
Tests
backend/tests/unit/test_raw_live_gapped_packs.pyis the regression test thatwould have caught this: before the change,
list_packsreturned[]for agapped, unframed pack and
read_packraisedCoverageMismatch. It also pinsretained_proof's span accounting (audio_secondsexcludes the gap,stt_secondsincludes it) and the materialized unit's silence fill at the truecapture positions.
UI-Evidence: none -- backend change only
Failure class (fixes)
Failure-Class: FC-capture-session-window-read-as-content-duration
The capture window (
capture_start..capture_end) bounds the content; it isnot the content duration. The base decoder measured the expected decoded length
from that wall span, and a naive proof would have counted gap time as audio. The
content duration is the sum of the writer's recorded frames, which is what
sealed_received_audio_secondsnow reports.Rollback
Set
RAW_LIVE_GAPPED_PACKS_ENABLED=false(or0/off/no) to restore theprevious skip in both listing and decoding. The switch does not change the
writer, the manifest format, or the framed path, so a code rollback is also
safe: no stored bytes or metadata are rewritten.