Repository navigation
SCA-4656: Defer finalization while live audio is uncommitted - #26402
Merged
Merged
Conversation
Co-authored-by: multica-agent <[email protected]>
Stamp the first uncommitted-archive deferral on the job. After ten minutes the deferral transaction refuses without writing, and the worker takes the pre-existing counted not-closed retry, so a session that never commits cannot replay forever. A row deleted mid-wait now defers to the replay's admission read, which owns the missing-row handling, instead of fencing the job directly. The worker-route test stubs the projection delta the strict fixture does not model, and now asserts the held audio is untouched, the replay at the due time, redelivery to batch after the commit, and the bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
commented
Nov 28, 2026
Git-on-my-level
left a comment
Member
Author
There was a problem hiding this comment.
REVIEW: SHIP 10d7dbd
PANEL: review-20261128t033830-1e41 on #26402 @ 10d7dbd (luna completed 3m, deepseek completed 6m)
F1. [minor] backend/docs/listen_pusher_pipeline/changes/2026-11-24-user-finish-first-archive-window.md:32
The existing note still documents a 30-second wait, up to 60 reads, and a counted retry, while this change uses a 3-second wait, up to 6 reads, and a non-counting deferral bounded at 10 minutes. This is a documentation drift finding, not a runtime blocker. Suggested follow-up: add a 2026-11-28 change note and mark the older sentences superseded.
Panel integrity warning: reviewer checkout was modified under .multica/.
Git-on-my-level
deleted the
agent/omi-control-owners-sol/a4fab207339e
branch
November 28, 2026 03:45
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.
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/runwaited 30 s, raisedServerBatchArchiveNotClosedand answered HTTP 500. That spent an attempt, and after five attempts the job was budget-requeued or dead-lettered.Changes
{"status": "deferred"}.attempt_countand the worker claim slot are unchanged.dispatch_requested_atis cleared and a due-time guard in_claim_finalization_replay_txnstops any replay before the due time. The next reconciler pass then mints a new dispatch generation.live_archive_wait_started_aton the job. AfterLIVE_ARCHIVE_MAX_WAIT(10 min), the deferral transaction raisesLiveArchiveWaitExpiredand writes nothing. The worker then takes the pre-existing path: a countedServerBatchArchiveNotClosedretry under the normal attempt budget. A session that never commits therefore cannot replay forever, and the audio stays held._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.test_worker_defers_an_uncommitted_finish_and_replays_without_spending_an_attemptregisterthencomplete, 200done).test_each_redelivery_inside_the_bound_defers_againretrywithattempt_count1 to 2, the conversation row unchanged, and no delete or finalize. Mutation check: removing the bound'sraisefails this test.test_deferral_is_bounded_then_takes_the_counted_not_closed_retrytest_a_deleted_row_ends_the_wait_and_defers_to_the_replay_admissionCAPTURE_END) does not wait and keeps the not-closed retry.test_a_natural_end_does_not_waitFirestore reads per delivery
A deferred delivery makes these reads. Reads this PR adds: 0.
get_finalization_job(1), conversation admission read (1)._retry_or_dead_letterretry transaction made.LIVE_ARCHIVE_MAX_WAIT: about 10 at the per-minute reconciler pass, and never more than 600 s / 10 s.Rollback and kill switch
live_archive_wait_started_atis an inert job field after a revert.CONVERSATIONS_V3_BATCH_MANUAL_END=offrestores theno_contentanswer for an early Finish, andCONVERSATIONS_V3_FAST_FINISH=cohort|offnarrows admission.Verification
Current head
f4668b1a4ca5129004d3142f34ebbdc3ff7bb988(origin/mainc0e57162ec0merged in, no rebase), m1-mac-studio, throughbin/omi-heavywith 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 intests/unit/test_batch_coalescing_completion.py::test_mobile_hold_headers_survive_coalescing_and_publication[merged|individual](503sync_batch_unavailable). They fail identically with this PR's three files reverted to origin/main, and on main CI since92ad82907a(SCA-4372: resolve accepted review findings for the mobile batch upload hold #26519, SCA-4372). This is main drift, not this change.git diff --checkis 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_closed500 and nocause=worker_faileddead letter from this cause. Look forevent=live_archive_wait outcome=expiredwarnings, which mark sessions that hit the bound.Earlier head
9d846f4db2983b7c44cb2d7f57b188980bb6dd7e(not current). Five checks were red:UnsupportedFirestoreOperationError. The strict fixture does not model the projection-shardset(merge=True), so the route answered 500. Fixed by stubbing_record_projection_delta, as other finalization suites do.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