Skip to content

SCA-4372: resolve accepted review findings for the mobile batch upload hold - #26519

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/sca4372-review-followups
Nov 27, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/sca4372-review-followups

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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

Review Disposition
#26319 F1 Already resolved. Main receives the hold and age headers and observes age on batch admission.
#26319 F2 Already resolved by the recovered-WAL marker and the fresh-only guard filter. Independent comparison catches mismatches.
#26319 F4 Tests pin the flag key, refresh cadence, and immediate release and wake when a refresh completes.
#26319 F5 Proves the actual v2 headers and both histogram series for all three active states through the hermetic coalescing/publication path. The runbook records the serving receipt requirements for SCA-4508.
#26319 F6 Disposal prevents a final buffer seal from creating a detached hold. A test closes a real buffer after disposal and verifies publication.
#26319 F7 Controller regression test verifies that session roll and capture end both release the active recording before the reporter runs.
#26319 F8 Held-only drains report pending work and preserve retry backoff. Tests exercise the local drain, aggregation, provider and coordinator.
#26318 F1 Tests send held mobile uploads through v2 offer, drain and durable publication in both merged and individual modes.
#26318 F2 Keeps the batch-admission phone-age family and adds the bounded gate from the general upload trace. The runbook documents the filter and the reason for each family.
#26318 F3 Accepts in-range ASCII decimal ages with leading zeroes and bounds significant digits before converting. Tests exercise padded valid and out-of-range ages.

Verification

  • 92 focused Flutter tests passed under omi-heavy with flutter test -j "$OMI_HEAVY_CPUS".
  • 2,930 focused backend tests passed across six files selected by changed files under omi-heavy, including the real multipart route and strict completion transaction.
  • The complete backend changed-file selection also passed under omi-heavy. Across 243 files, 12,935 passed and 86 were expected failures.
  • Local repository preflight passed all 51 checks. The pipeline-lab affected scan selected no scenarios.
  • Serving samples and the actual ramp receipt are pending Release's serving canary.

Product invariants affected

  • INV-CAP-1. Teardown and delayed drain reporting preserve the existing custody and WAL publication path.

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

View guided diff Turn on auto-fix

🤖 Generated with Claude Code

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T14:45:06.877902Z c9a3579 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 92ad829 into main Nov 27, 2026
82 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/sca4372-review-followups branch November 27, 2026 15:37
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)
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