Skip to content

fix(listen): preserve finalization after source close - #10066

Merged
Git-on-my-level merged 2 commits into
mainfrom
codex/fix-listen-finalization-source-close
Jul 20, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
codex/fix-listen-finalization-source-close

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Keep inline/BYOK finalization under pusher process ownership after the originating listen WebSocket closes, instead of cancelling it during connection cleanup.
  • Treat the opcode-201 live acknowledgement as best-effort so a closed source connection cannot reclassify an already-completed Firestore job as a worker failure.
  • Add a deterministic hermetic listener → pusher → Firestore regression: claim a held job, close the source after opcode 104 and pusher cleanup, then prove the original job and conversation complete without another session.

Product invariants affected

None.

Failure class

Failure-Class: none

No existing failure class covers cancellation of durable work by the wrong WebSocket lifetime owner. This repair converges finalization on the existing process-scoped task owner and proves the real ownership boundary through the hermetic stack.

Verification

  • backend/.venv/bin/pytest -q backend/tests/unit/test_listen_finalization_cloud_tasks.py — 68 passed.
  • npm run test:listen-pusher-stack:emulator — passed, including the new post-opcode-104 source-close scenario.
  • make preflight — passed.
  • backend/test.sh — ran the 683-file suite; one unrelated existing fast-unit timing guard failed in tests/unit/test_audio_merge_tasks.py::TestEnqueueAudioMergeJob::test_schema_v2_task_named_by_conversation_and_fingerprint (0.14s over its 0.12s budget). All targeted finalization tests above passed.

Closes #9995

Review in cubic

@mintlify

mintlify Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Jul 19, 2026, 10:19 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Keep a claimed inline/BYOK finalization owned by the pusher process after its originating listen connection closes, while treating the live result callback as best-effort.

Failure-Class: none
…gauntlet

The new _inline_finalization_survives_source_close scenario waited for the
finalization job to reach 'processing', which is not a valid job status.
FinalizationJobStatus is 'queued' | 'leased' | 'completed' | 'dead_letter' |
'blocked_byok'. 'processing' is a ConversationStatus, not a job status.

claim_finalization_job transitions the job to 'leased', and the test's
inline_finalization_hold_entered seam fires inside finalize_persisted_conversation
(which runs only after the claim), so the observable claimed state is 'leased'.
Waiting for the nonexistent 'processing' status caused the gauntlet to time out.

Failure-Class: none
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Fixed the failing Listen Pusher Stack Gauntlet check.

Root cause: the new _inline_finalization_survives_source_close stack scenario waited for the finalization job to reach status processing, which is not a valid FinalizationJobStatus. The valid job statuses are queued → leased → completed (plus dead_letter, blocked_byok); processing is a ConversationStatus. claim_finalization_job transitions the job to leased, and the test's inline_finalization_hold_entered seam fires inside finalize_persisted_conversation (after the claim), so the observable claimed state is leased. Waiting for the nonexistent processing status caused the gauntlet to time out.

Fix: wait for leased instead of processing. Test-only change — no production code modified.

Verification: Listen Pusher Stack Gauntlet now passes (was FAILURE, now SUCCESS). All other checks remain green.

@Git-on-my-level
Git-on-my-level merged commit 9aa2d10 into main Jul 20, 2026
34 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/fix-listen-finalization-source-close branch July 20, 2026 03:58

This branch was successfully deployed

1 active deployment
staging - docs — 0fa4ea8c Deployed Jul 20, 2026 by mintlify[bot]
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.

fix(listen): recover inline/BYOK finalization when the pusher WebSocket closes

1 participant