Skip to content

feat: receipt wait reads only finished jobs, live words keep their connection, a stored End finds its row - #26357

Merged
Nizarius merged 6 commits into
mainfrom
feat/live-words-keep-connection
Nov 26, 2026
Merged

Nizarius merged 6 commits into
mainfrom
feat/live-words-keep-connection

Conversation

@Nizarius

Copy link
Copy Markdown
Collaborator

What changed and why

Three follow-ups to #26348, each behind a per-account flag of that change and inert for an account the flag is off for, and one new analytics event that is not behind a flag.

  1. receipt_finished_note (new flag, used with receipt_long_poll). As first built, the receipts wait re-read every listed job when a wait started, on every wake and when it expired, which is several times the reads of the status polling it replaces. Now a finished upload job leaves a note in Redis for an hour before its wake, the wait reads job state only for a job a note or a wake names, and an expired wait answers without reading anything. The app status-polls a job the wait covers once a minute as a backstop. On a test phone the reads from waits fell to one per finished upload.

  2. vendor_recognizer_on_opened_app: silence keeps the connection. A /v4/live-words connection used to close after 20 s without audio, so a phone fed by a pendant reconnected after every pause, and the listen service counts new connections per signed-in user (shared with the capture connection). Now only the provider stream is given back after 20 s of silence and the next audio dials a new one on the same connection; the connection closes after 10 minutes without audio.

  3. end_open_conversation: a stored End finds its conversation. When End is pressed before the server has a conversation for the speech since the previous End, the End is answered pending and the app kept its Processing row until the 20-minute deadline. Conversation reads now serve the End instant the builder already stamps (v3_manual_cut_at, hidden from the published schema), and the app matches its row to the conversation whose cut equals the End time it sent; a pending acceptance keeps the 2-minute expiry.

  4. App Foreground Ended (analytics event, every account, no flag). One event each time the app leaves the front after at least a second there, with two whole numbers of seconds: in front, and in front with capture active. "In front" is the lifecycle state resumed only. The listening connection's own report counts a background launch as foreground, so time in the app could not be measured on iPhone; this number is the baseline for pricing a live stream before any rollout. Registered in contracts/analytics/events.json with its consumers; nothing is stored on the phone.

Change note: backend/docs/listen_pusher_pipeline/changes/2026-11-26-receipt-note-live-words-connection-end-finish-row.md.

Rollout

No rule exists for any of these flags at deploy. receipt_long_poll should be admitted for an account only together with receipt_finished_note. Before vendor_recognizer_on_opened_app is ramped beyond single accounts: the load balancer needs a path rule for /v4/live-words, the display stream has no plan-allowance check, and the server's one-connection-per-install map is per process.

Known limits

  • receipt_finished_note: a failed upload leaves no note and no wake (the once-a-minute poll finds it). A lost note, Redis being down and the phone in the background are not tested.
  • Live words: the provider give-back after real silence was seen with a probe on a local stack, not on a phone (the room never went quiet for 20 s).
  • End finish row: the 2-minute removal (no speech before the End) is covered by tests only. When the server replaces an implausible phone End time with its own, nothing matches and the row goes at 2 minutes. Conversation.model_dump() consumers carry the new key like the other v3 fields.

Product invariants affected

  • INV-CAP-1: app/lib/services/capture/empty_recording_notice.dart and app/lib/services/wals/** change only behind end_open_conversation, receipt_long_poll and receipt_finished_note. With the flags off, capture, upload and receipt handling take the same paths as before.

How it was verified

  • The event was checked on a test iPhone through a temporary local mirror that is not in this change (two visits recorded with the expected seconds); its arrival in the analytics store is not verified, because the local build has no analytics key.
  • Each of the three flagged changes was exercised on an iPhone with a pendant against a local prod-parity stack with the names selected through the development override: the receipts wait over 17 minutes in front (one job-status read per finished upload, each answered a fraction of a second after its result was written), the live-words connection held for 13 minutes without a reconnect, and an End followed by Finish before the server had the conversation (the Processing row was replaced about 14 s after Finish; before the fix it stayed for 20 minutes). The per-account switch itself is covered by unit tests only.
  • Backend: the changed test files and the registry and contract guards, one file per process; backend/scripts/typecheck.sh 0 errors; scan_async_blockers.py no findings.
  • App: flutter test (whole suite).

Tests

  • backend/tests/unit/test_reliability_experiment_receipt_finished_note.py (12 cases), test_reliability_experiment_live_words.py (15), test_reliability_experiment_end_answer.py, test_client_processing_trust_boundary.py (the new model field is classified).
  • App: test/utils/analytics/app_foreground_time_test.dart (9 cases), test/unit/receipt_waiter_test.dart, test/unit/sync_poll_storm_test.dart, test/providers/end_stored_finish_row_test.dart, two cases in test/pages/conversations/home_v3_test.dart.

UI evidence

UI-Evidence: none -- the only visible change (the Processing row leaving sooner after an End) is behind a flag that is off for all accounts.

Failure class (fixes)

Failure-Class: none

Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 3272 -> 3285 | test seam and upload times for the receipt waiter beside the wait it feeds
Line-Count-Exception: backend/database/batch_pipeline_projection.py | 1569 -> 1570 | one flag-gated call beside the wake it precedes
Line-Count-Exception: backend/routers/sync.py | 4281 -> 4297 | the note read inside the receipts wait route

🤖 Generated with Claude Code

Nizarius and others added 6 commits November 25, 2026 21:46
…ider stream is given back

Flag vendor_recognizer_on_opened_app. A connection used to close after 20 s without audio, and the
phone opened a new one on the next audio. A pendant sends nothing while it is quiet, so the phone
reconnected after every pause, and the listen service counts new connections per signed-in user.

Now the phone's connection stays open through silence. After 20 s without audio only the provider
stream is closed (it gets 3 s to deliver its last words), and the next audio dials a new one on the
same connection; lines stay timed in seconds of audio from the connection's first frame. A lost stream
is replaced the same way instead of closing the connection; three failures in a row without a word
still end it. The connection itself closes after 10 minutes without audio.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ow does not stay

Flag end_open_conversation. When End is pressed before the server has a conversation for the speech
since the previous End, the End is answered pending. The app then kept its Processing row until the
20-minute deadline, because the row could only be handed to a conversation that named the listening
session's recording, and on the phone-file route none does.

The conversation an End closed already carries that End's instant (v3_manual_cut_at); the conversation
reads now serve it, and the app matches its finish row to the conversation whose cut equals the End time
it sent. A pending acceptance keeps the 2-minute expiry, which clears the row and makes Home read its
list once.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ed_note)

With receipt_long_poll. A finished upload job leaves a note in Redis for an hour, written before its
wake. The receipts wait reads job state only for a job a note or a wake names, and an expired wait
answers without reading anything; the app status-polls a job the wait covers once a minute as a
backstop. As built before, every start, wake and expiry of a wait re-read every listed job.

Also updates the live-words flag description: silence keeps the connection.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…connection and the End finish row

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…and with capture active

One event each time the app leaves the front after at least a second there, with two whole numbers of
seconds: in front, and in front with capture active. In front is the lifecycle state resumed and nothing
else; the listening connection's own report counts a background launch as foreground, so iPhone
in-front time could not be measured. Not behind a flag: it is the baseline for pricing a live stream
before any rollout. Nothing is stored on the phone.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…w-ups

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Nizarius
Nizarius merged commit 87cf873 into main Nov 26, 2026
69 checks passed
@Nizarius
Nizarius deleted the feat/live-words-keep-connection branch November 26, 2026 03:33
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