Repository navigation
fix(listen): harden v3 rotation failure paths before the canary - #25731
Merged
Merged
Conversation
…led successor, counts producer skips
…ion successor; bound producer skips
This was referenced Nov 19, 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.
Problem
Follow-up to #25726 (merged as
ae68d3176d, rotation off). The round-4 review found these failure paths in_rotate_v3_recordingand the supersede step. They have to land before the one-owner canary.Change
routers/listen/conversations.py, supersede block increate_new_in_progress_conversation). Thesupersede_live_continuationcall runs after the switch. It is now wrapped in try/except: a failure is logged and counted aspointer_failed, and the create always continues to its tail (capture timeline, admission attach,_refresh_speakers,send_conversation_session). Test:test_a_failed_pointer_move_still_finishes_the_successor_and_counts_it, using the real create path inCaptureHarness. The successor is fully bound, the old row is sealed, the phone gets the session event, and the Redis id names the successor._clear_failed_successor, where any failure is caught and logged. AWebSocketExceptionfrom the create is still re-raised. Test:test_a_failing_redis_restore_never_masks_ownership_loss._clear_failed_successorfirst publishes the successor's close barrier (close_server_batch_audio, with its producer token if it has one), then callsdelete_empty_recording_conversation(..., allow_empty_server_batch=True)and checks the result.database/recording_sessions.py:294-310).successor_keptand logged. It isin_progressand not current, so stale recovery seals or deletes it.tombstone_and_delete_empty_conversationon_FakeFirestore:test_a_failed_create_publishes_the_barrier_then_deletes_its_empty_successor: the unclosed owned successor is deleted. With the barrier call removed, this test fails, because the delete is a no-op.test_a_failed_create_keeps_a_successor_that_has_audio: the successor is kept when it hashas_content,server_batch_audio_receivedorserver_batch_audio_start/end.host.recording_session_idalready names the successor's session while frames still go to the old row. That label feeds telemetry (receiver.py:886) and the recording-session lease renewal, never audio binding: the archive binds bycurrent_conversation_id, which never names a failed successor.test_frames_during_a_failed_create_never_bind_to_its_successorruns 40 frames through a realLiveAudioArchivewhile the create fails, with the session label observed assession-2. Every frame lands in the old row's window, the successor is deleted, and nothing stays uncommitted.WebSocketException), the Redis restore is skipped, because another socket owns the recording. Test:test_ownership_loss_skips_the_redis_restore.skipped_produceroutcome. It is counted once per row (the set keeps the last 64 row ids;test_producer_skips_stay_bounded) when the reconnect producer protocol blocks rotation, and only for owners rotation admits.pointer_failed,skipped_producerandsuccessor_keptare added toRecordingRotationOutcome. Test:test_a_reconnect_protocol_skip_is_counted_once_per_row.Rotation stays off in every environment (
CONVERSATIONS_V3_RECORDING_ROTATION=off). No flag, chart or runtime env value changes.Before widening (design only, not in this PR)
A crashed v3 socket leaves its recording
in_progress, whether or not rotation ran. Only listen stale recovery seals it:recover_stale_in_progress(routers/listen/conversations.py), on the owner's next connection, after an hour of quiet. The durable quiet check armed at creation refuses it. Inrecovery_admission_refusal(database/conversation_finalization_jobs.py:380),if conversation.get(TERMINAL_NO_DERIVED_EFFECTS_FIELD): return 'terminal_no_derived'matches every v3 recording, becauseutils/conversations/v3/triggers.py:61(mark_new) stampsterminal_no_derived_effects=Trueat creation. The quiet check reaches it atdatabase/conversation_quiet_checks.py:212.Smallest fix: exempt only v3 recordings with server-batch audio from that refusal:
For a recording the marker means it never takes derived effects. It does not mean the row is already finalized. Processing still goes through
recording_short_path(utils/conversations/v3/service.py:54): no model, apps, memories or webhooks, thenlifecycle.completeplus the v3 builder trigger.The refusal is shared with
database/stuck_backfill.py:59, so the fix needs one test per caller:recording_short_pathwith no derived effects;A separate sweeper would duplicate the quiet check's lease and fence logic, so I'd not build one. Ownership: lane/conversations-v3. Until this lands, widening past a canary leaves any crash-orphaned v3 recording invisible until the owner reconnects.
Verification
test_listen_batch_speech_quiet.py,test_listen_v3_rotation_custody.py,test_listen_v3_rotation_continuation.pyandtest_reason_label_enums.pyall pass. Listen, v3, quiet-finalization, desktop-batch, recording-session and query-shape suites: 2572 passed, 1 skipped.backend/scripts/typecheck.sh: 0 errors.scripts/pr-preflight --pr-body-file.Line-Count-Exception: backend/routers/listen/conversations.py | 1458 -> 1519 | rotation failure handling (pointer-move guard, failed-successor cleanup, producer-skip count) stays beside the create path it guards
Product invariants affected
none
Failure class (fixes)
Failure-Class: FC-transport-liveness-read-as-speech-activity
🤖 Generated with Claude Code