Skip to content

fix(backend): a live reconnect resumes its conversation instead of minting an empty stub - #15330

Merged
Git-on-my-level merged 5 commits into
mainfrom
fix/listen-reconnect-continuity
Sep 21, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
fix/listen-reconnect-continuity

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Failure-Class

Failure-Class: FC-split-mutation-authority

Summary

Realtime half of the 2026-09-19 conversation-fragmentation incident. The sync
half shipped as #15193 and is live in prod: offline sync no longer adopts live
reconnect stubs. This PR is the remaining half — live listen reconnects inside
the continuity window were still minting a fresh empty conversation
because
create_new_in_progress_conversation(rollover=True) had no durable continuation.

STT routing is not in this PR. #15222's routing foundation was dropped because
#15234 (live_chain.py / live_rollout.py / live_session.py /
stt_provider_policy.py) supersedes it and already owns provider selection. This
branch must not introduce a second authority over that choice.

Changes

  • database/listen_continuations.py + utils/conversations/live_continuation.py:
    a terminal or missing original recording binding stays immutable. A transactional
    metadata pointer on it names the still-active continuation. Concurrent proposals
    converge on the first resumable generation.
  • Resume requires exact source/device, in-progress status, no lock/discard/deletion,
    and a gap strictly below the shared utils/conversation_continuity.py threshold
    (the same 120 s split sync uses). Exact 120 seconds starts a new generation.
  • Empty expired generations and unexposed losing proposals are deleted only through
    lifecycle's fenced empty-conversation path. is_locked, tombstones, content, and
    sync_content_revision win. The original recording session is never rebound.
  • recording_sessions.py also protects those fences during empty-row cleanup.
  • Resume also calls speakers.refresh_for_conversation, the same conversation-scoped
    profile load fix(speakers): make cross-conversation speaker labeling viable on mobile (canonical identity, one manual-assignment owner, live names, summary refresh) #15247 added on mint, so a reused conversation does not start a new
    socket with empty speaker profiles.

A fake-clock replay at 0/35/70/105/119 s emits one conversation id; 120 s creates
a new one. Other-device Redis pointers cannot steal a same-device continuation.

Tests

  • test_listen_reconnect_continuity.py — same-origin reconnect reuse, exact
    120 s split, other-device isolation, locked/deleted/discarded exclusion,
    competing proposals converging without mutating the original binding.
  • test_listen_process_pending_shutdown.py — custom-STT marker persistence and
    client-id existence reads still hold on a continuity-eligible resume; rollover
    resolves a continuation first, then skips the guaranteed-miss existence read.
  • Additions to test_recording_sessions.py and test_sync_capture_continuity.py.
  • #15234's test_live_stt_chain.py remains green; this PR does not touch
    provider selection.

Out of scope

Provider ranking, health admission, STT_ROUTING_MODE, and any second connect
chain. Historical distinct explicit WAL targets and anonymous cross-device
discovery remain separate follow-ups.

Verification

  • Installed pre-push hook on the pushed head: exit 0, strict pyright clean, line-count ratchet held
    with no exception requested.
  • Both emulator lanes (test:listen-pusher-stack:emulator, test:sync-cloud-tasks-stack:emulator)
    run sequentially, passed.
  • Reviewer-confirmed on f28662cafe: none of the six dropped routing files exist on this branch, and
    backend/utils/stt/streaming.py, backend/routers/listen/receiver.py and
    backend/routers/listen/runtime.py are byte-identical to origin/main — so the ~116-line language
    inventory move that belonged to the dropped routing commit is fully reverted.

Not exercised: physical client reconnect acceptance, real Firestore contention on the
continuation pointer, and deployed reconnect rates. The 2026-09-18 pattern of eleven overlapping
live conversations is not claimed fixed; its cause is still unknown and needs a provider-epoch
replay.

Design by Codex (gpt-6-astra); routing half dropped and rebased by Cursor Grok; reviewed and split
by Claude.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 5 commits September 21, 2026 10:48
Keep locks, deletion tombstones and sync revision ownership ahead of empty-live-row cleanup. Content continues to use the existing codec-aware transactional fence.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed, including 33 recording-session cases. Existing resume assertions stay unchanged; fixtures now include their real source/device/finished-at metadata.

Failure-Class: FC-split-mutation-authority
Keep an immutable original recording binding and transactionally adopt its compatible active continuation. Reconnects inside the shared silence boundary reuse the continuation; expired empty and unexposed losing generations use lifecycle-owned fenced cleanup before STT admission.

Reject deleted, discarded, locked and other-device rows. Keep existing explicit WAL targets authoritative. Tests reproduce newest-first/interleaved legacy hints, the remaining partial-flap limit, same-origin 35-second reconnects, exact 120-second rollover, protected content and legacy principals.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed. Hermetic E2E: 120 passed, 3 skipped, 2 xfailed. Sync Cloud Tasks emulator gauntlet passed. Live provider/client acceptance was not run; only hermetic service seams are authorized.

Failure-Class: FC-split-mutation-authority
…policy

Move the unchanged resumable-continuation predicate out of database storage and into the shared continuity module. Async callers now depend on the pure rule; transactional metadata access stays on the persistence executor. This addresses the installed pre-push async-boundary guard without an exemption.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed after the move.
… path

The reconnect-continuity change now requires source/device/timeout on resume
and resolves a durable continuation before a rollover mint. The four skipped
tests still protect marker persistence, client-id reads, and the existence-read
skip; their hosts and fixtures needed those fields to reach that path.

Co-authored-by: Cursor <[email protected]>
#15247 refreshes conversation-scoped speaker profiles on mint. Continuity
makes resume the common reconnect path, so that load must happen there too
or a reused conversation would start a new socket with empty profiles.

Co-authored-by: Cursor <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 49dc2a7 into main Sep 21, 2026
65 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/listen-reconnect-continuity branch September 21, 2026 04:38
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