Repository navigation
fix(finalization): admit a user finish inside the first archive window - #26213
Merged
Merged
Conversation
A live audio-only capture writes has_content only when a 60 s archive window commits, so a Finish in the first minute was answered no_content and ignored: the recording stayed open until the socket closed or the quiet timer fired. Admit a client finalize when the live session already holds audio, and let the finalization worker wait for that session to commit it before the batch handoff.
…inish adds no query
…kip producer rows and seconds-old successors Review findings: a reconnect producer fences archive writes once the row leaves in_progress, a repeated finish could cut the successor, and the change should ramp from the owner account like the fast first transcript.
The fixture gains the transaction-bound photos.limit(1) existence probe as a read, so admission's read-before-write ordering is enforced by these tests.
…rvice and the review's known limits
This was referenced Nov 24, 2026
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.
What changed and why
A Finish pressed in the first minute of a mobile recording did nothing. The app showed Processing, no summary arrived, and the row later disappeared.
Mobile captures are server-batch-only. The listen session marks
server_batch_audio_receivedat the first audio frame and writeshas_contentonly when a 60-second archive window commits. A user finish before that commit reached finalization admission with no transcript and no content marker, was answeredno_content, and the request returned the recording unchanged. The recording stayed open until the socket closed or the quiet timer fired. A pendant keeps streaming, so that could take minutes or never happen.Production readback (2026-11-24, one test account, synthetic speech over
/v4/listen, thenPOST /v1/conversationswith the socket held open):in_progress(ignored)capture_end, created only when the socket closed 20 s laterprocessingclient_finalize, created with the requestFor the 77 s recording the session rolled over at once, committed the tail in 2.8 s, and the record sealed 4.4 s after the request. #26192 does not cover the short case: its manual-end marker needs a
client_finalizejob, and none was created.The change:
_create_or_get_finalization_intent_txn): aclient_finalizeof a batch-owned row withserver_batch_audio_receivedtrue, no committed audio, an open archive, no reconnect producer and at least 10 seconds of age is admitted. Every other trigger, and every other row, keepsno_content.finalize_persisted_conversation): for that job it re-reads the row every 0.5 s for at most 30 s until the session has committed the audio, then registers the recording and closes the capture as before. A row that never gains audio keeps the existingServerBatchArchiveNotClosedretry.No new write: the session's existing rollover commit supplies the audio bounds. Cost is at most 60 extra row reads per early finish.
Rollout and rollback
It rolls out with the fast first transcript:
CONVERSATIONS_V3_FAST_FINISH(defaultcohort, thev3-fast-finishruntime rollout cohort;onadmits every owner;offstops it). With the default, nothing changes for an owner outside the cohort.CONVERSATIONS_V3_BATCH_MANUAL_END=offalso stops it. A job admitted before either switch still completes.Known limits, to settle before
onnote_server_batch_audioandclose_server_batch_audiorefuse a producer row once its status leavesin_progress, so the session could not commit the audio. The serving listen image predatesLISTEN_BATCH_RECONNECT_ENABLED, so today's mobile rows carry no producer. When that image ships, this change stops applying to mobile rows until the fence lets the owning token write while the row isprocessing. The same fence would then refuse the tail of a finish after the first window; that is independent of this change.in_progress(PUSHER_RECORD_CLOSE_NOTIFY_ENABLEDis off). If frames stop while the socket stays open, the audio commits only at teardown and the job spends its retry budget meanwhile.POST /v1/conversationssent again more than 10 seconds after a finish can cut the successor recording.cohortmode a cold membership lookup (one Redis read and one point read, cached 60 s) runs inside the admission transaction, for a row that already passed the row checks, the age floor and the kill switch.on, give it a non-counting retry reason.Product invariants affected
How it was verified
test_user_finish_first_archive_window.py: 20 passed. The admission cases run the real admission transaction and lifecycle reducer onStrictFirestore(which now models the transaction-boundphotos.limit(1)probe as a read) and assert the queued job and the row's move toprocessing; a refused finish is asserted to write nothing. It covers the early admission, the rows that stay empty (no audio yet, closed empty archive, not batch-owned, legacy, reconnect producer, seconds-old successor, no creation time), non-user triggers, both switches, the cohort gate, the worker wait, the timeout, a natural end that does not wait, and a deleted row.backend/test.sh:test_conversation_finalization_jobs,test_server_batch_completion,test_listen_finalization_cloud_tasks,test_record_finalizer_discard_registration,test_record_finalizer_photo_registration,test_conversation_quiet_finalization,test_client_processing_finalize,test_conversation_smart_merge_finalizerandtest_conversations_v3_fast_finish: all passed.cohort.Tests
backend/tests/unit/test_user_finish_first_archive_window.py.Failure-Class: none
Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 3750 -> 3754 | The early admission is decided inside the existing admission transaction, on the snapshot that transaction already holds; four lines on the existing no-content branch.