Skip to content

fix: recover oversized quarantine uploads with lossless FLAC - #24540

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/recov100
Nov 3, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/recov100

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

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 with E2E_PYTEST_TIMEOUT=600s, through omi-heavy. make preflight passed 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 through BACKEND_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

Failure-Class: FC-recoverable-provider-failure-terminal

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 8 files

Confidence score: 3/5

  • batch_recovery_large_held_check.py can report a large failed_held row as clean when Firestore contains non-finite values. Validate duration_seconds and settled_at with math.isfinite() and count invalid values as unknown.
  • recovery_recognizers.py adds function-local imports for runtime dependencies, which violates the backend import rule. Move the numpy and soundfile imports 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:

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Luna round-2 delta review at c572502: SHIP.

Minor finding disposition: pytest's default caplog capture level would miss INFO-level private-text leakage. The current provider exception logger (recovery_disposition.stage_failure) emits WARNING with bounded fields, and recovery INFO logs use bounded outcomes; no current leak was identified. The six-case regression test covers the present exception path. Broader INFO capture is tracked separately in #24546, within the existing recov100 anx card, for lead triage by 2026-11-04T12:00Z. This nonblocking coverage improvement does not reset the reviewed release-blocking head or its in-flight CI.

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.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Ready for lead merge at c572502.

  • 432 tests across nine recovery files passed locally through backend/test.sh, omi-heavy, and nice -n 19 with four workers.
  • All 34 local preflight checks and the remaining push gates passed.
  • Canonical read-only Luna round-2 delta review: SHIP. Nonblocking INFO capture coverage follow-up: test: capture INFO logs in async recovery privacy assertions #24546, existing recov100 anx card step async-info-log-capture, lead triage requested Nov 4 at 12:00Z.
  • Final-head unit run: all six shards, guardrails, and aggregate suite succeeded. All current PR checks are complete with zero failures; PR is CLEAN/MERGEABLE.
  • The original shard-6 uv setup flake passed after one rerun. No additional rerun was needed on this head.

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: /Volumes/Ephemeral/scratch/recov100b/report.md.

@Git-on-my-level
Git-on-my-level merged commit 8bd3318 into main Nov 3, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/recov100 branch November 3, 2026 23:44
Git-on-my-level added a commit that referenced this pull request Nov 4, 2026
…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
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