Repository navigation
SCA-4372: resolve accepted review findings for the mobile batch upload hold - #26519
Merged
Merged
Conversation
Preserve pending drain state and make hold teardown terminal. Verify the flag refresh, capture-end wiring and coalesced publication paths. Reuse the upload-trace gate for the hold-age metric, accept padded in-range ages and document the serving receipt required before ramp. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Nov 27, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Nov 27, 2026
## Summary The mobile hold test added in #26519 uses a `stage_audio` fake that rejects the `record_origin` keyword. Batch intake catches that `TypeError` during artifact setup and returns 503 in both parametrized cases. Match the production method’s keyword arguments in the fake so the existing test reaches admission, drain, and publication. The one-line change is in the test fixture. ## Verification - Reproduced both 503s on Worker 1 before the change. - Ran the full `test_batch_coalescing_completion.py` file on Worker 1 through `bin/omi-heavy` with a 90-second admission limit and a 150-second execution limit. All 13 tests passed, including both hold cases. They assert HTTP 202 admission, per-state hold age, and preservation of all three hold states through publication. Tracks SCA-4372. Lever A stays at 0%. ## Product invariants affected none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26527?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/26527?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26527&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. -->
Git-on-my-level
added a commit
that referenced
this pull request
Nov 28, 2026
Fixes SCA-4656 (incident SCA-4652, diagnosis SCA-4651). When a user
Finish arrives while the live listen session still holds uncommitted
audio, `POST /v1/conversation-finalization-jobs/run` waited 30 s, raised
`ServerBatchArchiveNotClosed` and answered HTTP 500. That spent an
attempt, and after five attempts the job was budget-requeued or
dead-lettered.
## Changes
- Wait up to 3 s for the live archive to commit (was 30 s). If it is
still uncommitted, yield the lease with a non-counting retry and answer
HTTP 200 `{"status": "deferred"}`. `attempt_count` and the worker claim
slot are unchanged.
- The deferred job becomes due 10 s later. `dispatch_requested_at` is
cleared and a due-time guard in `_claim_finalization_replay_txn` stops
any replay before the due time. The next reconciler pass then mints a
new dispatch generation.
- **Bound.** The first deferral stamps `live_archive_wait_started_at` on
the job. After `LIVE_ARCHIVE_MAX_WAIT` (10 min), the deferral
transaction raises `LiveArchiveWaitExpired` and writes nothing. The
worker then takes the pre-existing path: a counted
`ServerBatchArchiveNotClosed` retry under the normal attempt budget. A
session that never commits therefore cannot replay forever, and the
audio stays held.
- If the row is deleted during the wait, the delivery defers like any
other uncommitted delivery. The replay's admission read
(`_load_admitted_conversation`) then applies its existing missing-row
and fanout-claim handling. The deferral path adds no separate shortcut
for this case.
## Custody invariants and the tests that prove them
All tests are in
`backend/tests/unit/test_user_finish_first_archive_window.py`. They use
the real admission, claim, retry and replay transactions on the strict
Firestore fixture.
| Invariant | Test |
| --- | --- |
| Deferral never drops, deletes or finalizes without the held audio. The
conversation row is byte-identical after the delivery. The register,
complete and empty-delete writers are not called (the worker double
raises on any other writer). The projection deltas balance. |
`test_worker_defers_an_uncommitted_finish_and_replays_without_spending_an_attempt`
|
| A deferred job is not replayed before its due time, is replayed once
at the due time into generation 2 with attempts unchanged, and, once the
session commits, the redelivery hands the recording to batch (`register`
then `complete`, 200 `done`). | same test |
| Each redelivery inside the bound defers again without spending an
attempt, and the first start stamp is kept. |
`test_each_redelivery_inside_the_bound_defers_again` |
| At the bound, deferral stops and the pre-existing safe path runs: a
counted 500 `retry` with `attempt_count` 1 to 2, the conversation row
unchanged, and no delete or finalize. Mutation check: removing the
bound's `raise` fails this test. |
`test_deferral_is_bounded_then_takes_the_counted_not_closed_retry` |
| A row deleted mid-wait defers (non-counting) to the replay admission
read. |
`test_a_deleted_row_ends_the_wait_and_defers_to_the_replay_admission` |
| A natural end (`CAPTURE_END`) does not wait and keeps the not-closed
retry. | `test_a_natural_end_does_not_wait` |
## Firestore reads per delivery
A deferred delivery makes these reads. Reads this PR adds: **0**.
- Unchanged by this PR: claim transaction (job doc plus account-deletion
marker, 2), `get_finalization_job` (1), conversation admission read (1).
- Changed by this PR:
- Archive-wait polls: at most 6 conversation reads (3 s at 0.5 s), down
from at most 60 (30 s).
- The deferral transaction reads the job doc once. It replaces the read
that the pre-existing `_retry_or_dead_letter` retry transaction made.
- Per replay cycle (unchanged mechanism): 1 candidate row in the
reconciler page and 1 job read in the replay transaction.
- Cycles per job are bounded by `LIVE_ARCHIVE_MAX_WAIT`: about 10 at the
per-minute reconciler pass, and never more than 600 s / 10 s.
## Rollback and kill switch
- Rollback: revert this PR. The deferral adds no new data shape that
needs cleanup. `live_archive_wait_started_at` is an inert job field
after a revert.
- There is no dedicated flag for the deferral itself. The existing
switches remove the whole early-Finish path that reaches this code:
`CONVERSATIONS_V3_BATCH_MANUAL_END=off` restores the `no_content` answer
for an early Finish, and `CONVERSATIONS_V3_FAST_FINISH=cohort|off`
narrows admission.
## Verification
**Current head `f4668b1a4ca5129004d3142f34ebbdc3ff7bb988`** (origin/main
`c0e57162ec0` merged in, no rebase), m1-mac-studio, through
`bin/omi-heavy` with bounded timeouts:
- `tests/unit/test_user_finish_first_archive_window.py`: 22 passed.
- `bash test.sh` (changed-file selector, the same 651 files CI selects):
25,120 passed, 17 skipped, 2 failed. Both failures are in
`tests/unit/test_batch_coalescing_completion.py::test_mobile_hold_headers_survive_coalescing_and_publication[merged|individual]`
(503 `sync_batch_unavailable`). They fail identically with this PR's
three files reverted to origin/main, and on main CI since `92ad82907a`
(#26519, SCA-4372). This is main drift, not this change.
- Pre-push gate: passed on push.
- `git diff --check` is clean.
After the release lane serves the fix: on the first health tick, the
route's 5xx share should be under the tick rule, with no
`reason=server_batch_archive_not_closed` 500 and no
`cause=worker_failed` dead letter from this cause. Look for
`event=live_archive_wait outcome=expired` warnings, which mark sessions
that hit the bound.
**Earlier head `9d846f4db2983b7c44cb2d7f57b188980bb6dd7e` (not
current).** Five checks were red:
- PR Metadata Preflight and Hygiene: line-count ratchet, because the
exception was missing from the body.
- Backend unit shard 5/8 and Backend unit suite: the new route test hit
`UnsupportedFirestoreOperationError`. The strict fixture does not model
the projection-shard `set(merge=True)`, so the route answered 500. Fixed
by stubbing `_record_projection_delta`, as other finalization suites do.
- Backend Go Checks: a timing failure in
`TestScheduledResumeHandsBackClaimWhenStopWinsLaunch`, outside this
Python-only diff, and green on main.
Line-Count-Exception: backend/database/conversation_finalization_jobs.py
| 3765 -> 3794 | Keep the lease-fenced deferral, its bound and the
due-time replay guard inside the existing finalization transactions they
fence.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Summary
Resolves the accepted review follow-ups for #26319 and #26318 under SCA-4372. Rollout stays at 0%. Release owns the serving canary and the decision to ramp.
The handset changes are confined to the existing hold and WAL drain. The backend reads the gate from the existing request trace in memory and adds it to the phone-age histogram. The existing intake, coalescing and publication writes carry the same metadata. Additional Firestore reads and writes per upload are both zero. Rollback is a revert of this PR with the hold flag kept at 0%.
Accepted findings
Verification
omi-heavywithflutter test -j "$OMI_HEAVY_CPUS".omi-heavy, including the real multipart route and strict completion transaction.omi-heavy. Across 243 files, 12,935 passed and 86 were expected failures.Product invariants affected
UI-Evidence: none
Line-Count-Exception: app/lib/providers/sync_provider.dart | 1556 -> 1560 | Keep the provider idle and pass the held disposition to the coordinator.
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 3362 -> 3368 | Distinguish a held-only pass while retaining the local copy retention sweep.
Line-Count-Exception: backend/routers/sync.py | 4418 -> 4424 | Attach the existing upload trace to the phone-age observation at fresh admission.
Failure-Class: none
🤖 Generated with Claude Code