Repository navigation
fix: recover oversized quarantine uploads with lossless FLAC - #24540
Conversation
Failure-Class: FC-recoverable-provider-failure-terminal
There was a problem hiding this comment.
2 issues found across 8 files
Confidence score: 3/5
batch_recovery_large_held_check.pycan report a largefailed_heldrow as clean when Firestore contains non-finite values. Validateduration_secondsandsettled_atwithmath.isfinite()and count invalid values as unknown.recovery_recognizers.pyadds function-local imports for runtime dependencies, which violates the backend import rule. Move thenumpyandsoundfileimports to module scope.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/scripts/batch_recovery_large_held_check.py">
<violation number="1" location="backend/scripts/batch_recovery_large_held_check.py:36">
P1: This gate can silently report clean for a large `failed_held` row containing a non-finite Firestore number. Validate `duration_seconds` and `settled_at` with `math.isfinite()` and count invalid values as unknown before applying the threshold or settlement comparison.</violation>
</file>
<file name="backend/utils/batch_pipeline/recovery_recognizers.py">
<violation number="1" location="backend/utils/batch_pipeline/recovery_recognizers.py:160">
P3: Move the new `numpy` and `soundfile` imports to module scope. The backend import rule forbids function-local imports for regular runtime dependencies, and the same pattern was added to `wav_duration_seconds`.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if document is None: | ||
| continue | ||
| row = {key: scalar(value) for key, value in document.get('fields', {}).items()} | ||
| if (row.get('duration_seconds') or 0) <= 3277: |
There was a problem hiding this comment.
P1: This gate can silently report clean for a large failed_held row containing a non-finite Firestore number. Validate duration_seconds and settled_at with math.isfinite() and count invalid values as unknown before applying the threshold or settlement comparison.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/scripts/batch_recovery_large_held_check.py, line 36:
<comment>This gate can silently report clean for a large `failed_held` row containing a non-finite Firestore number. Validate `duration_seconds` and `settled_at` with `math.isfinite()` and count invalid values as unknown before applying the threshold or settlement comparison.</comment>
<file context>
@@ -0,0 +1,89 @@
+ if document is None:
+ continue
+ row = {key: scalar(value) for key, value in document.get('fields', {}).items()}
+ if (row.get('duration_seconds') or 0) <= 3277:
+ continue
+ recovery = row.get('recovery') or {}
</file context>
| # uncompressed copy for large units while encoding FLAC. | ||
| if len(pcm) + 44 <= MODULATE_SAFE_UPLOAD_BYTES: | ||
| return canonical_wav(pcm) | ||
| import numpy as np |
There was a problem hiding this comment.
P3: Move the new numpy and soundfile imports to module scope. The backend import rule forbids function-local imports for regular runtime dependencies, and the same pattern was added to wav_duration_seconds.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/batch_pipeline/recovery_recognizers.py, line 160:
<comment>Move the new `numpy` and `soundfile` imports to module scope. The backend import rule forbids function-local imports for regular runtime dependencies, and the same pattern was added to `wav_duration_seconds`.</comment>
<file context>
@@ -133,6 +146,28 @@ def canonical_wav(pcm):
+ # uncompressed copy for large units while encoding FLAC.
+ if len(pcm) + 44 <= MODULATE_SAFE_UPLOAD_BYTES:
+ return canonical_wav(pcm)
+ import numpy as np
+ import soundfile as sf
+
</file context>
PR #24540 intentionally allows ordinary multilingual recovery to try Soniox after provider_failed, through the existing consent, funding and paid-intent guards. The old async test still asserted no second provider call on error. Update that expectation and cover alternate words, empty and error answers, privacy revocation during the first call, retained worker VAD and custody, bounded receipts, no repeat spending, and private exception sanitization. An errored first recognizer must never become two-empty silence evidence.
|
Luna round-2 delta review at c572502: SHIP. Minor finding disposition: pytest's default 432 tests across nine recovery files and all 34 local preflight checks passed. The original shard-6 uv setup failure passed after one rerun. Final-head unit run: https://github.com/BasedHardware/omi/actions/runs/41739078313. Merge and deployment remain lead-owned. |
|
Ready for lead merge at c572502.
No production access or changes. Lead-owned backend deployment is still needed on recovery-serving Cloud Run roles, including backend-integration; no worker, flag flip or redrive is included. Detailed local evidence: |
…24571) The development pusher image smoke fails with `missing installed dependency modules: soundfile`, blocking a qualified pusher digest for fleet-off. Add the backend's existing `soundfile==0.12.1` pin to the pusher manifest and regenerate only its Linux lock, preserving every existing package version. The reachable path is `pusher.main → routers.pusher → utils.pusher_finalization → utils.conversations.finalizer → utils.conversations.transcription_shadow → utils.stt.pre_recorded → utils.stt.modulate_batch → soundfile`. #24540 added the lazy FLAC import (also used in `recovery_recognizers`). `runtime_image_contracts.py` walks lazy imports and asserts dependency presence before image publication. Good run [41736493035](https://github.com/BasedHardware/omi/actions/runs/41736493035) installs 155 packages and checks 312 module paths; bad run [41752337247](https://github.com/BasedHardware/omi/actions/runs/41752337247) installs the same 155 packages and checks 313 paths. This is deterministic, rather than a transient package-index failure. The earlier #24531 / `dbf17bf82` run [41741443997](https://github.com/BasedHardware/omi/actions/runs/41741443997) passed build, dependency smoke and publication. It failed later in the development semantic probe (`listen_closed_early`, code 1006); that separate qualification remains with the rollout lead. Validation: - Reproduced the exact generated dependency assertion for `soundfile` in an empty isolated Python 3.11 environment, installed the declared pin, and observed PASS. - Real FLAC encode, duration read and lossless decode passed, exercising native libsndfile. - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` selecting `test_runtime_image_contracts.py` and `PYTEST_ADDOPTS='-k "pusher or dependency_probe"'`: 11 passed. Run serially through `omi-heavy` and `nice -n 19` in the canonical worktree venv. - Canonical `make setup` and worktree environment doctor passed. - Full `make preflight` with the draft PR body: all 15 selected checks passed. - Local Docker daemon unavailable; the requested exact-assertion reproduction/pass is the local proof. This lock change triggers Role Images CI: its Linux `backend/Dockerfile.roles --target pusher` build uses the same pusher lock and source surface and runs the offline probe on a public Python base. The shipped standalone Dockerfile/private-base development qualification remains with the lead. No deployment or workflow edits were run by this lane. Coverage follow-up: source-only backend import changes such as #24540 do not match the Role Images PR path filter. The older `runtime_image_contracts.yml` authenticated image-smoke job was retired November 1, so its source-only PR check does not fill that gap. The rollout lead owns disposition of source-change dependency coverage. Failure-Class: FC-runtime-image-boundary
Quarantine recovery always sent canonical WAV, so native recordings above Modulate's upload ceiling failed before Soniox could be tried. Encode WAVs above 95 MiB as lossless PCM16 FLAC, reject encoded uploads still above that safe cap locally, and try Soniox after provider_failed through the existing route, consent, funding and intent-token guards.
Modulate documents FLAC support at https://platform.modulate.ai/pricing. Whole-unit compression keeps word clocks and speaker labels intact and needs one provider call; splitting adds overlap/stitching and extra paid attempts. Below the cap the canonical WAV and call arguments are unchanged. The client sends the matching filename/MIME and accounts for FLAC duration. A failed first recognizer remains an error receipt and can never count toward two-empty silence/disposition evidence.
Validation: 552 unique unit tests passed across nine targeted files through
BACKEND_UNIT_TEST_FILE_LIST=... BACKEND_PYTEST_WORKERS=4 bin/omi-heavy run -- nice -n 19 bash backend/test.sh. The full hermetic harness passed: 204 passed, 3 skipped, 2 xfailed. Its original 120-second local wall limit expired under shared-host CPU contention; the identical suite passed in 195 seconds withE2E_PYTEST_TIMEOUT=600s, through omi-heavy.make preflightpassed all 34 checks through omi-heavy with the draft PR body. Synthetic audio only; no production access, writes or redrive.Post-deploy: source ~/.local/bin/gcp-agent-env.sh ro-prod, then run
python3 -I backend/scripts/batch_recovery_large_held_check.py --since <release-UTC-ISO>. It prints aggregates only and uses recovery settlement time to include old admissions failing after release. Zero new failed_held units over 3277 seconds with provider_failed is the gate; unknown settlement times fail closed.Deploy needed: lead-owned backend release on recovery-serving Cloud Run roles (including backend-integration); no worker change or flag flip. No redrive is part of this PR.
Independent read-only Luna review at 7d849dd: SHIP, no correctness findings. The reviewer ran no provider calls or production queries. CI is pending; merge and deployment belong to the lead.
CI repair: ordinary async recovery now intentionally follows the existing guarded Soniox route after
provider_failed; its old no-second-call assertion was stale. The test now covers alternate words, empty and error answers; privacy before and during the first call; bounded receipts; retained audio/worker VAD; no repeat spend; and private exception sanitization. Production code is unchanged by this repair. At c572502, 432 tests across nine recovery files passed throughBACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/recov100b/tests.txt BACKEND_PYTEST_WORKERS=4 bin/omi-heavy run --wait 3600 -- nice -n 19 bash backend/test.sh, including all six async cases. The initial local run timed out in the shared CPU admission queue before any test ran; the requeued run passed. The original shard 6 uv-setup flake passed after one rerun. Luna round-2 delta review returned SHIP at c572502; the nonblocking INFO log-capture coverage observation is tracked in #24546 and the existing recov100 anx card, with lead triage requested by 2026-11-04T12:00Z. CI at the repaired head is pending.Failure-Class: FC-recoverable-provider-failure-terminal