Skip to content

test(listen): verify legacy drop finalization across reconnect flag states - #25607

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/finalization-drop-gate
Nov 20, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/finalization-drop-gate

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed

The exact requested runtime fix is already on the freshly fetched base: PR #25599, merged as 0ff616e7dfd23b14a1ff6da30019040aa445f665. This follow-up strengthens its regression test rather than adding a duplicate gate. No serving code changes.

The test now runs real ListenSessionRuntime._teardown_components, LiveConversationController.disconnect_batch_producer, process_conversation, and the archive-close helper. It retains the sibling test's mocked socket/cleanup harness, fakes persistence side effects, and mocks the schedule_finalization admission boundary. The same mobile batch capture is tested with LISTEN_BATCH_RECONNECT_ENABLED unset, false, and true, for iOS/Android and omi/phone sources. Unset/false must close the archive and schedule finalization once; true must flush the tail and skip scheduling.

Mechanism and scope verification

  • Before fix(listen): gate the drop hold on the reconnect switch again #25599, backend/routers/listen/runtime.py took the batch_disconnect == 'legacy' / resumable_after_drop(...) arm without consulting the flag. That arm only flushed speaker assignments; it did not call process_conversation or schedule_finalization. It is an elif branch, not an immediate function return: later teardown cleanup still runs.
  • Current runtime.py:1503-1505 already gates that arm with the real config.listen_reconnect.enabled() accessor (backend/config/listen_reconnect.py:16). The accessor defaults to false and enables only the normalized value true.
  • backend/routers/listen/batch_close.py:12-38 requires quiet ownership, mobile platform, server-batch ownership, no explicit finalization reason, and a fresh in_progress row with has_audio(...). That audio predicate requires has_content and finite, increasing audio bounds; server_batch_audio_received=True alone is insufficient.
  • Quiet admission can admit the stated committed-audio rows after their quiet deadline and recording-session lease expire, provided dispatch is configured and lifecycle/privacy/content guards pass. evaluate_quiet_check checks those conditions (backend/database/conversation_quiet_checks.py:210-223,270-294); quiet_finalization.run requests SERVER_RECOVERY finalization with an expired-lease requirement (backend/utils/conversations/quiet_finalization.py:184-194). The existing test_quiet_check_finalizes_an_open_phone_batch_capture_with_committed_audio exercises actual admission and job creation with no producer metadata or close barrier. A renewed live lease defers admission. The quiet evaluator publishes the batch close barrier only when listen_reconnect.end_due(...) is true, which a producer-less row cannot satisfy.
  • Desktop, non-legacy disconnect outcomes, and captures without audio keep their existing runtime behavior. This PR changes tests only.

Validation

From the task lane root, each test file in its own pytest process:

/Users/dazheng/workspace/omi/bin/omi-heavy run -- backend/.venv/bin/python -m pytest backend/tests/unit/test_mobile_batch_disconnect.py -q
# 28 passed
/Users/dazheng/workspace/omi/bin/omi-heavy run -- backend/.venv/bin/python -m pytest backend/tests/unit/test_listen_batch_reconnect_grace.py -q --disable-warnings
# 52 passed

Mutation proof: temporarily removed only and listen_reconnect.enabled() from the runtime branch and ran:

/Users/dazheng/workspace/omi/bin/omi-heavy run -- backend/.venv/bin/python -m pytest backend/tests/unit/test_mobile_batch_disconnect.py -q --tb=short --disable-warnings -k 'schedules_finalization_only_with_reconnect_off and false'

All four explicit-false mobile/source combinations failed at schedule_finalization.assert_awaited_once_with: zero calls. Original runtime bytes were restored in finally; there is no runtime diff.

make preflight: passed, 37 checks. PR metadata preflight: passed. The complete bounded pre-push hook also passed at commit 3a695d5c58b709d69a413b8385f4be93444bcb20 (including selected backend tests and pinned formatting).

Local hermetic validation only. No production reads or writes, no GCP tier used, no deployment or merge. The supplied production metrics, flag state, and rollout timestamp were not independently remeasured. The scoping was stale about the missing gate: it is already fixed on current main. It also described the skip as a return; the actual branch continues with cleanup. Quiet admission is conditional, not structurally impossible for every row matching the hold predicate.

Rollback

Revert this test-only commit; serving behavior remains the #25599 gate. To restore the original runtime defect, reverting #25599's and listen_reconnect.enabled() line would re-enable the ungated hold; that is not part of this PR.

View guided diff Turn on auto-fix

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T14:56:37.122190Z
We couldn’t complete this review. Comment @codex review to try again.
3a695d5 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Git-on-my-level
Git-on-my-level merged commit 80ebd6f into main Nov 20, 2026
67 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/finalization-drop-gate branch November 20, 2026 18:03
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