Skip to content

fix(conversations-v3): an older stretch of late-landing speech settles on landing too - #26771

Merged
kodjima33 merged 45 commits into
mainfrom
t3/v3-reconnect-splits
Dec 1, 2026
Merged

kodjima33 merged 45 commits into
mainfrom
t3/v3-reconnect-splits

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Device sync uploads an older talk file by file, often after newer speech has landed. Only the newest stretch may stay
open, so outline.stretches finished every older stretch at once, however recently its speech landed. The first
file's card was published on arrival. The next file of the same talk, landing a minute later, could not move that
published boundary (planner.preserve_finished_windows), so it became a second card. Settling on landing exists so
that "an offline batch whose speech is already old must not lock the moment it arrives", but it protected only the
newest stretch.

Production audit, metadata only, 24 h to 2026-11-30 04:22 UTC: 110 adjacent v3 card pairs with no gap, disjoint
recordings, no manual cut and 50+ words each side. 53 of them involve a recording that arrived through device sync.
In 21 of those, the first card was built already finished while newer speech from the same device existed, and its
neighbour landed within 5 minutes; 19 of the 21 had no recording placed before. That is the case this PR fixes. The
other pairs are batch-lane reconnects (#26749), concurrent double captures, or uploads more than 5 minutes apart (see
"Not changed here").

Containment: dark by default. Everything this PR adds runs only for owners listed in
CONVERSATIONS_V3_SETTLE_OLDER_OWNERS (owner tags sha256(uid)[:12], or *; read per pass), and only with
CONVERSATIONS_V3_SETTLE_ON_LANDING on. The default is empty, and then every pass is main's: no hold, no off-page
sibling lookup, no settlement wake, and has_pending and the projection commit run main's code (the commit's
past-deadline rotation now also applies only to sources the outline held for settlement). The existing
CONVERSATIONS_V3_SETTLE_ON_LANDING stays as it is: it defaults on and gates main's own landing settlement of the
newest stretch, so turning it off would change main. The new flag is registered as a rollout
(config/feature-flags.yaml): merge dark, then a test allowlist, internal owners, and *. Proof: scenario compare
with the allowlist emptied on both arms shows every committed scenario identical to main (below), and unit tests
pin the flag-off loader, has_pending, commit and plan to main's.

The mechanism. Live builder passes (service.reconcile, never derive or on-open) pass settle_older to
outline.stretches. Under CONVERSATIONS_V3_SETTLE_ON_LANDING (default on), _settle_older leaves out an older
stretch when all of these hold:

  • every recording in it is a device-sync landing (outline.device_sync_landing: sync intake stamped its
    sync_content_revision, a positive integer; no other sync stamp, such as sync_recorded_end_at, counts; and it is
    not a live capture that sync extended, sync_live_target), all from one known client_device_id;
  • a newer stretch holds speech from that same device, or the stretch already stores a deadline;
  • its speech is older than the lock delay, but it landed less than the lock delay ago;
  • no transcribed audio covers the silence gap after its last line (_audio_covers: completed and transcribed
    recordings only, on capture-time ends, never an arrival-stamped finished_at);
  • no conversation has placed any of its recordings (no claims), and none of them has lines in another stretch;
  • it is not bounded by a manual end or the window cap.

Its recordings stay pending until the lock delay after the stretch's last landing (outline.SETTLE_UNTIL, kept
pending by preview_wakes). A file that lands in that window joins the stretch. Once the wait ends, the stretch is
planned as one finished card. No second open card is ever committed. Every other capture keeps main's publication
schedule: live, batch and rotation captures whose transcript lands late, separate-origin Finish predecessors, and
synced speech behind only another device's speech.

The stored deadline. The projection commit writes the deadline to each held recording as v3_settle_until and
clears it once the stretch is planned. Without it, the wait would end as soon as the newer conversation locks and
leaves the loaded page. The older stretch would then be published as an open card, finished by the next newer
speech, and the next file would split again. sync_files_after_newer_speech covers that sequence.

The new wake. _after_projection enqueues a Cloud Task at every distinct deadline it holds
(triggers.enqueue(settlement=True)) with payload trigger: "settlement_deadline" and its own per-second task name,
so a same-minute arrival wake cannot swallow it, and each held row keeps its wake whichever page later loads it. routers/conversations_v3_tasks.py answers 503 for this trigger while the builder lease is busy, so the
queue retries it; untriggered and native_manual_ready requests behave as on main. A deadline already past (a sibling
still missing) re-checks once a minute through the same settlement task, never an ordinary minute wake. Each wake is
retried briefly (three attempts); one that still cannot be created makes the pass report more work.

The pass chain. service.has_pending keeps main's read first. Only when every other pending source it finds is
held until a future settlement deadline does it read in v3_pending_since order for owed work ahead of them. Held
sources on other pages therefore no longer keep the chain reconciling and waking the owner every minute; their
settlement task plans them. When it finds only such holds, it also re-creates the settlement task of the earliest one
off the page (idempotent by name) and reports more work until that succeeds, so a hold whose wake failed after the
commit is recovered from its stored deadline even if its source never returns to a page: no hold ends up with
neither a wake nor a continuation.

The new query. The pending page is ordered by v3_pending_since, not capture time. When it is full, a held
file's sibling can sit off the page, and the stretch would settle without it. Then, and only with settling on landing
on (the same switch the builder reads), load() looks for the off-page pending siblings of held device-sync files
(_hold_for_pending_siblings, on the existing conversations_v3_pending_capture_continuation index):

  • seeds are unplaced device-sync files with a known device whose old speech landed within the lock delay, or that
    store a deadline; ordinary recordings never qualify;
  • both sides use capture time (capture_span_without_transcript, never an arrival-stamped finished_at): it reads
    captures that start within 20 minutes of a seed cluster's capture span. A sibling is evidence only with the same
    known, non-empty device and a gap strictly below the silence gap, as grouping joins speech;
  • it reads capture metadata only. It never decodes a sibling or adds it to the pass, so an optional sibling can
    trigger no transcript (lake) read and no neighbour reads. Only one of the device's captures found within the
    silence gap of the cluster's span marks the stretch, which waits until both share a page, up to
    policy.TRANSCRIPT_WAIT (15 min) past its deadline;
  • one pass reads at most 32 documents and spends at most 10 s (SIBLING_SECONDS, far inside the 240 s builder lease)
    for every held cluster across all its load attempts (SiblingReads, created per reconcile pass beside
    UnlockedPage and shared by the bounded-load ladder and its batch-cap retry), 16 documents at a time, each query
    within 3 s. Each RunQuery's whole limit is taken from the allowance before it is sent, and it is never resumed
    (FIRESTORE_NO_RETRY: the SDK's resume after a mid-stream error asks for the same limit again), so no call can
    return more than was charged; a finished call gives back what it did not return;
  • a lookup that cannot finish (the allowance is spent) or fails marks nothing: the stretch keeps main's plan. A
    failure (a read, or a capture field it cannot parse) ends the lookup for the rest of the pass, every later load
    attempt included (SiblingReads.failed), is logged and counted as a degraded fallback, and the pass goes on. Main's
    load path is unchanged with the switch off.

Stored data and clock arithmetic are best effort. Every stored field this path reads goes through
outline.instant, a guarded capture clock and bounded audio durations: a value that is not a valid instant in
2000–2100 or a valid duration counts as absent. Every clock sum on the path (skew, lock delay, transcript wait,
deadlines, coverage, lookup windows) goes through one helper, outline.shifted, which gives no result when the sum
overflows or leaves that range; the caller then keeps main's plan. Only an eligible stretch's clocks are read.
_audio_covers skips a row it cannot read (no coverage), an unreadable stored deadline is no hold, capture spans
treat an unreadable field as absent, and in has_pending an unreadable stamp is owed work, as on main. A failed
pending-order read in has_pending (3 s timeout, never resumed) keeps main's answer, and has_pending answers owed
work the moment it reads it, so a later failure of the same read cannot lose it. None of them fails the pass.

The queries are registered with the Firestore query-shape drivers.

Observability. omi_conversations_v3_settle_older_total counts passes that hold an older stretch, and
backend-sync's managed Prometheus keep-list scrapes it (deploy/cloud_run_gmp_sync.yaml).

Relation to #26769. Late-speech absorption joins an earlier file into a later published card, backward only, and
costs a notes rewrite. It cannot join the upload order, which is the shape reproduced on production below. This PR
joins both orders without publishing the partial card first. Absorption still applies wherever this PR keeps main's
plan.

Not changed here (follow-ups)

Review rounds had added the changes below on shared paths. None is needed to keep the older talk on one card, so this
branch restores main's code for each (f4d380410d). Main already lives with future v3_pending_since stamps from
held Finishes and previews: such a recording stays pending and is planned by the deadline wake or any pass that loads
it. Each item is a separate follow-up:

  1. Pull a future v3_pending_since back to now when speech lands or a recording is re-armed. This covers the live
    transcript writer (database/conversations.py update_conversation_segments), mark_pending and
    promote_manual_end. It would make a held recording with fresh speech head the pending page on its first pass,
    instead of at its deadline.
  2. Clamp a future v3_pending_since on Finish and native re-arm (_window_tail_plan, _finish_capture,
    permits_native_source). A deferred older stretch is never the newest capture a Finish targets.
  3. Split unreadable recordings into terminal and retryable failures. Terminal ones would be a missing blob, a
    shredded key, a missing file or corrupt segments; retryable ones decode, type or fetch errors. Retryable ones would
    stay pending on a rotating retry, and an older stretch would wait while a sibling is temporarily unreadable. Main
    already treats corrupt segments as unreadable (TranscriptSegmentsDecodeError is a ValueError).
  4. Treat a lake-fetch outage (TranscriptPointerFetchError) as a retryable race (recording_decode_retryable)
    instead of failing the pass, on the main load path. (The new sibling read already isolates its own failures.)
  5. Keep a transient lake fetch on an unlocked preview's source out of the owner's deterministic backoff.
  6. Count only due pending work in the pass chain for every kind of hold. has_pending now skips settlement holds
    only (see "The pass chain"); main's other future holds keep their behaviour.

Also not changed: device-sync uploads that land more than 5 minutes apart (28 pairs; the builder has no sign that
more audio is coming, so this needs a client signal such as the phone's pending WAL count), and concurrent double
captures (29 pairs, a duplicate-capture problem, not a reconnect).

Expected latency cost

  • A device's synced old speech landing behind that device's newer speech, with no transcribed audio after it: its
    card appears up to the lock delay (5 min) after its last file lands, instead of at once. That is the wait the
    newest stretch already has. Production, same 24 h, metadata only: 25,408 of about 116,000 completed v3 cards were
    built from speech over 5 minutes old and finished within 4 minutes. In a random 1,500-card sample, 442 had no
    transcribed audio covering the next 5 minutes (the _audio_covers rule); 213 of those were device-sync files from
    one device, and 186 had newer speech from that device before the card was built. So about 3,150 cards a day
    (about 2.7%, two thirds of them hidden from Home) wait up to 5 more minutes. Before this round the gate let up to
    about 7,500 a day wait.
  • A pending sibling off the page: only on a full pending page; that stretch waits until both share a page, up to
    15 minutes past its deadline, re-checked once a minute.
  • Everything else is unchanged: live, batch and rotation captures, synced speech behind only another device's
    speech, the newest stretch, older stretches followed by transcribed audio, placed stretches, backfill, re-derive
    and on-open.
  • Reads and writes: the sibling lookup runs only on a full pending page with the switch on, for held device-sync
    files: at most 32 metadata documents per pass, and no transcript read. has_pending reads a second page only when every other pending source it
    found is held until a future deadline. A held stretch writes its deadline once (again when a new landing moves it)
    and gets no outline call until it is planned. Lab, all 27
    scenarios against main (flag on): 33 fewer reads, 21 fewer writes, 7 fewer LLM calls and 3 more no-op writes, all in the new
    scenario; flag off, none.
  • Default: none of the above. With CONVERSATIONS_V3_SETTLE_OLDER_OWNERS empty (the default) nothing changes;
    the numbers above are for *, and a test allowlist costs only its owners' share.
  • Rollback: empty CONVERSATIONS_V3_SETTLE_OLDER_OWNERS, or CONVERSATIONS_V3_SETTLE_ON_LANDING=off on the
    builder runners. That also turns off landing settlement
    for the newest stretch: at the default timing every stretch then counts from its last speech, and the sibling read
    does not run.

Product invariants affected

none

How it was verified

  • Review round 1 replays. The reviewer's replays are tests now (synthetic rows). On f3c75432bb 18 cases fail,
    each one below; here they pass:

    • Ordinary captures: a live batch capture landing late behind another device's speech, with and without a
      rotation stamp, gets its card on the first pass and stores no deadline (it was held 280 s). Main's separate-origin
      Finish test (test_conversations_v3_finish_late_predecessor.py) is restored unchanged and passes. Live captures,
      sync-extended live captures, another device's newer speech and an unknown device each keep main's plan.
    • Read cost: with the switch off, a full page of 32 seeds, each with 65 pending captures behind it, reads one
      capture-order document, as main does (it read 2,081). Ordinary recordings never seed the read with the switch
      on. 32 held sync clusters share one budget of at most 32 documents and wait (bounded) for what it did not finish.
    • Capture time and isolation: an arrival-stamped finished_at no longer stretches a seed onto another device's
      recording an hour later. Another device's adjacent capture, or one of its own device's an hour away, does not
      hold a sync file; its own device's off-page sibling does, without being read, and a lake fault on that sibling
      cannot fail the pass.
    • Continuation: two held rows across a one-source page no longer keep the pass chain going, owed work still
      does, and an overdue settlement wake keeps its own task name next to an ordinary wake of the same minute.
  • Review round 2 replays. On 776621f5eb 9 cases fail; here they pass:

    • Budget: sibling streams that fail after 15 documents read at most 32 in all (they read 480), and the
      bounded-load ladder's 32-, 8- and 1-seed attempts share one 32-read budget (they read 96).
    • Best effort: an off-page sibling next to another device's historical card, whose lake read fails, neither
      fails the load nor blocks an ordinary card in the same reconcile (both aborted). The lookup never decodes a
      sibling; a held file waits for its device's off-page sibling without reading it, and the two form one stretch
      once they share a page.
    • Wakes: two holds with distinct deadlines each get a settlement task, so the second keeps its wake after the
      first deadline's one-source pass loads only the first.
  • Review round 3 replays. On 8d3432b10e 7 cases fail; here they pass:

    • Budget: the installed SDK's RunQuery stream on a fake transport that breaks every 15 results makes one RPC
      and stops (it resumed with the original limit and read 51 documents against 32).
    • Best effort: a seed whose stored audio duration overflows a timedelta neither fails the load nor blocks an
      ordinary card in the same reconcile (both aborted).
    • Wakes: one transient failure creating the later deadline's task is retried and the pass commits (it raised,
      and the later hold had neither a task nor a continuation); a settlement wake that cannot be created is reported
      as more work; and an off-page hold whose wake cannot be created keeps the chain going until a pass creates it.
  • Review round 5 replays (the allowlist on). On 8c48da5abd 22 cases fail; here they pass:

    • Time: a year-9999 landing on an ordinary older card, a year-9999 stored deadline, and a year-9999 coverage end
      no longer overflow before the commit; the ordinary Home card is published, as on main. Clock sums that leave
      2000–2100 give no result.
    • Optional I/O: a stalled optional query takes its 3 s timeout, not RunQuery's 300 s past the 240 s lease: the
      pass commits and publishes (it returned raced with no Home card).
    • Evidence: a candidate with no device ID, or exactly a silence gap away, no longer holds the seed across three
      passes; it is published on the first, as on main.
    • Provenance: a malformed sync_recorded_end_at is no provenance (a normal recording behind newer same-device
      speech was withheld); only a positive integer sync_content_revision counts.
    • has_pending: an owed row read before the stream fails is kept: true, as main answers.
    • Containment: with the owner off the allowlist, two synced files are planned on arrival as on main (two cards,
      no stored deadline), the loader runs no sibling query, has_pending is main's ids-only read, and the commit
      writes no settlement field.
  • Review round 4 replays, and the audit of the new path. On 46c4b82471 19 cases fail; here they pass:

    • Parsing: a legacy row whose optional recorded_start is not an instant no longer aborts the reconcile, and
      its ordinary card is published, as on main. Unreadable coverage fields count as absent (the next readable field
      still proves coverage), an unreadable stored deadline is no hold, capture spans read unreadable stamps, absurd
      audio durations and odd types as absent, and has_pending counts unreadable stamps as owed work.
    • Lookup results: one interrupted sibling query and a real claim closure that overflows the 32- and 8-seed
      loads: the failure is carried through the ladder, the one-seed pass makes no further sibling read, and the card
      is published at its deadline, as on main (it was held 60 s past it). An allowance spent before a cluster is
      reached, or a lookup that cannot finish, keeps main's plan; a failed pending-order read keeps main's answer.
  • Pipeline lab on the merged tree (7d57d903e0, main e26598ae7f merged in), against main at 197be6283a, all 27
    committed scenarios.
    The new scenario turns the allowlist
    on in its own env (CONVERSATIONS_V3_SETTLE_OLDER_OWNERS: "*"); every other scenario runs the default (off).

    • Flag off (scenario compare --arm main@origin/main --arm head, the allowlist emptied on both arms by arm
      env): no difference. 27 of 27 scenarios are the same, and 0 of 376 metric keys (operations, outcomes, speakers,
      stages, STT routing) differ from main. sync_files_after_newer_speech fails identically on both arms there,
      since its expectations need the feature.
    • Flag on (scenario compare origin/main --worktree): 26 are identical on both arms (same outcomes,
      conversations and operation counts), among them late_sync_joins_published_card (v3: one card per sit-down, and late speech joins its published card (SCA-4537) #26769),
      sync_safety_copy_repeats_live (fix(conversations-v3): show a pendant safety copy's repeat of live speech once #26699) and main's seven stage_queues scenarios (feat(v3): builder stages on their own queues behind stage_queues #26824).
      sync_files_after_newer_speech fails on main (the older talk as two conversations, F1 and F2) and passes here
      (one conversation, F1+F2, on Home with notes), with 33 fewer reads, 21 fewer writes, 7 fewer LLM calls and 3 more
      no-op writes. Its 15 checks follow F1 through the newer conversation (the same device's) locking and leaving the
      page, an unrelated empty sync wake, another device's capture, and F2 moving the deadline. They check that no
      partial card exists at any of those points and that the joined card appears at the deadline.
    • All 27 scenarios with --jobs 4 --repeat 2 --stt replay passed in both repeats (summary below), and
      scenario/reach.json is re-measured on the merged tree.
  • Replay tests. Multi-pass replays drive the real service.reconcile and projection commit on the strict
    Firestore fixture, with the older files as device-sync landings of the owner's device:

    • two files of one older talk landing a minute apart while the owner is talking make one card, in upload order and
      in reverse order, with no partial card in between;
    • a second file appended to the first file's recording joins its card. That is the production shape below; main
      gives two cards;
    • the hold survives the newer card leaving the page;
    • with settle-on-landing off, after a placed first file, and behind only another device's speech, the plan is
      main's.

    Loader tests cover the held-sibling lookup across a page boundary (the held file waits, then joins its sibling once
    both share a page), its metadata-only reads, and a lookup the budget cannot finish (main's plan). Pure stretches
    cases cover every condition above.

  • Production repro of the bug, test account, current main. A 90 s socket capture landed first, and its card was
    open. Then two abutting 120 s WAL files of a talk two hours older went through /v2/sync-local-files, the second
    after the first had a card. The first file's card was processing 32 s after its file landed. Sync appended the
    second file to the same recording, and it became a second card. Final state: two cards from one recording, split
    exactly at the file seam. Not deployed, so there is no production after-run; the replay above is that shape.

  • Live-STT lane (not a bug). On the test account with private cloud sync off for the run, a 240 s + 460 s call
    with a 1.5 s reconnect gave one card holding both recordings.

  • Unit suites, after merging main. All test_conversations_v3* files and every file importing the
    v3 modules, transcript_multipart or sync_repeats (78 files) in one xdist session: 3,797 passed; the 13 failures
    are all test_conversation_events_bounds.py, which passes alone (21 passed): cross-file sys.modules
    contamination in a shared session, as backend/AGENTS.md warns. The Firestore query-shape, contract and
    index-oracle guards (the held-sibling lookup, its capture-window query and both has_pending paths registered;
    commit_projection's digest re-pinned for its allowlist gate), the pipeline lab tests, main's
    test_sync_live_repeat_lines.py, test_home_index_cutoff.py and test_mcp_conversation_detail_paging.py: 1,742
    passed. The feature-flag registry renders and checks clean (its tests: 122 passed). pipeline_lab affected selects
    every scenario. Pyright: 0 errors. The async-blocker scan finds nothing in the changed ranges.

  • Preflight: scripts/pr-preflight --pr-body-file with this body passed every check, including the line-count
    exceptions, the failure class and the product invariants.

Tests

backend/tests/unit/test_conversations_v3_settle_older.py (new, 107 cases; the allowlist is * there unless a case
clears it):

  • Pure stretches:
    • the wait and its deadline, and a file landing in the wait moving it;
    • main's plan for placed, shared, manually ended, settled, live-younger-than-the-lock-delay,
      followed-by-transcribed-audio, live-capture, sync-extended-live, other-device and unknown-device stretches, and
      for manual-end and window-cap bounds;
    • the newest stretch is never left out;
    • only resolved transcription proves recorded silence, and a skewed finished_at cannot veto the wait.
  • Wake: at the deadline, a one-minute settlement retry once past it, and none on derive.
  • Stored deadline:
    • cleared when a held source turns out unreadable;
    • an unreadable sibling does not block the readable one;
    • the hold survives the newer card leaving the page;
    • the metric is in the sync keep-list.
  • Replays: the multi-pass shapes above.
  • Loader: an off-page held sibling keeps the held file waiting until both share a page, the lookup never decodes a
    sibling, and a lookup the budget cannot finish keeps main's plan.
  • Review rounds 1 to 5: the replays and audit cases listed under "How it was verified".
  • Containment: the flag-off plan, loader, has_pending and commit are main's.

backend/tests/unit/test_conversations_v3_contract.py: the settlement_deadline wake answers 503 while the lease is
busy and runs once free. Its task name never collides with a same-minute arrival wake.

backend/tests/unit/test_conversations_v3_finish_late_predecessor.py: restored to main's version.

backend/tests/unit/test_conversations_v3_review.py: MemoryQuery.stream accepts the SDK's retry and timeout options
(the sibling lookup streams with retry=FIRESTORE_NO_RETRY).

backend/tests/support/firestore_conversations_v3_drivers.py: the held-sibling lookup (a held sync seed, and its
capture-window query) and both has_pending reads are registered query shapes.

Pipeline lab

Pipeline lab scenarios: passed (27 scenario(s) x2, jobs 4, stt replay, 272.9 s, ref 7d57d903e090)

scenario outcome checks seconds transcripts reads writes no-op writes stt llm
audio_single_recording_finish passed 9/9 22.706 synthetic 186 52 5 2 6
finish_after_long_reconnect_gap passed 8/8 19.743 scripted 236 64 7 1 6
finish_after_reconnect_late_transcript passed 8/8 20.508 scripted 267 74 8 1 7
finish_after_second_close passed 10/10 26.509 scripted 296 74 12 1 6
finish_cloud_audio_off passed 9/9 25.538 scripted 181 53 5 0 6
finish_double_tap passed 11/11 24.488 scripted 195 55 5 1 7
finish_next_opens_before_close passed 10/10 18.926 scripted 236 68 7 1 7
finish_no_closed_recording passed 9/9 16.804 scripted 166 47 4 0 6
finish_on_visible_conversation passed 10/10 16.254 scripted 170 47 4 0 6
finish_privacy_refused_fast_finish passed 8/8 12.832 scripted 37 8 1 0 0
finish_single_recording_fast passed 9/9 15.157 scripted 198 55 5 1 7
finish_transcript_never_lands passed 7/7 15.157 scripted 237 65 7 0 6
home_paging_past_hidden_runs passed 8/8 19.793 scripted 1027 47 4 0 6
late_sync_joins_published_card passed 9/9 17.909 scripted 308 78 7 0 10
reconnect_successor_lands_late passed 9/9 17.895 scripted 367 85 18 0 7
speaker_owner_absent passed 8/8 17.452 local 172 58 4 1 6
speaker_owner_and_person_finish passed 8/8 12.886 local 171 58 4 1 6
speaker_partial_final_pass_keeps_voices passed 8/8 12.46 local 157 55 4 1 5
stage_queues_automatic_end passed 11/11 11.036 scripted 175 52 4 0 7
stage_queues_late_text_rewrite passed 14/14 18.625 scripted 307 79 7 0 9
stage_queues_missing_queues passed 15/15 17.407 scripted 359 100 9 1 12
stage_queues_model_failures passed 14/14 15.771 scripted 204 54 4 0 7
stage_queues_switch_flipped_in_flight passed 19/19 19.905 scripted 694 181 20 0 22
stage_queues_user_end passed 12/12 20.043 scripted 207 59 5 1 7
stage_queues_user_end_during_backlog passed 14/14 20.379 scripted 337 94 7 1 12
sync_files_after_newer_speech passed 15/15 23.598 scripted 672 152 21 0 18
sync_safety_copy_repeats_live passed 3/3 20.525 scripted 225 59 8 0 6

Coverage: all 27 committed scenario(s) ran x2 and evaluated their checks.

The run used 7d57d903e0, the merge of main. 4835648f91 after it commits only the re-measured reach.json,
so the code under test is the head's.

UI evidence

UI-Evidence: none -- backend-only change

Failure class (fixes)

Failure-Class: FC-live-settlement-uses-capture-clock

Line-Count-Exception: backend/utils/conversations/v3/service.py | 2395 -> 2511 | the settlement wakes sit beside the held-Finish wake in _after_projection with a bounded-retry helper whose failure keeps the pass chain going, has_pending skips settlement holds with one more read in pending order and re-creates an off-page hold's wake, the pass's sibling-read allowance is threaded through the load ladder, plus the settle_older argument at the live stretches call
Line-Count-Exception: backend/database/conversations_v3.py | 2832 -> 3052 | the held-sibling lookup (gated, metadata-only, one pass budget) reads the same pending-page state load() already holds, and the projection commit stores the settlement deadline in the recording update it already writes

🤖 Generated with Claude Code

…s on landing too

Only the newest stretch may stay open, so outline.stretches finished every older
stretch at once, however recently its speech landed. Settling on landing therefore
protected only the newest stretch. Device sync uploads an older talk file by file,
often after newer speech has landed: each file's card finished on arrival, and the
next file of the same talk, landing a minute later, became a card of its own.

Live builder passes now leave out an older stretch whose speech is older than the
lock delay but landed less than the lock delay ago, when no conversation has placed
any of its recordings. Its recordings stay pending until the lock delay after its
last landing (outline.SETTLE_UNTIL through preview_wakes), and the owner is woken
then. Manual-end and window-cap stretches, placed stretches, backfill, re-derive
and on-open passes keep their plan. Under CONVERSATIONS_V3_SETTLE_ON_LANDING.
…ence gap of audio is unknown

Recorded silence after a stretch proves it ended, so it cannot gain speech from a
later file. In production 71% of the cards built from old speech that finished at
once had such silence in their own audio; waiting on them only added latency.
# Conflicts:
#	backend/testing/pipeline_lab/scenario/reach.json
Failure-Class: FC-live-settlement-uses-capture-clock
…unds

Distinguish terminal unreadable sources (missing transcript blob, shredded key,
missing file) from retryable transient decode failures so permanently unreadable
live recordings clear v3_pending instead of staying pending indefinitely.

Defer unplaced older stretches that share a hold or sit within silence_gap of a
temporarily unreadable pending source so a transient decode error on one held
file cannot publish its sibling alone and split the conversation.

Require genuine capture-audio end evidence (server_batch_audio_end,
sync_recorded_end_at, or recorded_end) in _audio_covers so an arrival-skewed
finished_at cannot veto older-stretch settlement.

Failure-Class: FC-live-settlement-uses-capture-clock
…verlap, and page-boundary sibling gaps

- Treat TranscriptSegmentsDecodeError as terminal in recording_input so corrupt stored transcripts clear pending instead of blocking siblings indefinitely, and bound retryable unreadable deferral by policy.TRANSCRIPT_WAIT.
- Remove bare deadline equality matching and arrival-stamped finished_at fallback from _blocked_by_unreadable_held so an F1 read failure cannot suppress unrelated talks.
- Load adjacent off-page pending siblings of held/late-landing unclaimed sources on saturated pages using the existing conversations_v3_pending_capture_continuation index (or mark _v3_unloaded_pending_sibling when at SOURCE_LIMIT) so a 1- or 32-source page boundary cannot publish F2 alone.
- Register _load_held_pending_siblings in Firestore query-shape drivers and add unit regressions for all three cases.

Failure-Class: FC-live-settlement-uses-capture-clock
…ng query truncation, and use last_speech_at capture span
…kip owner backoff on transient preview lake fetch
# Conflicts:
#	backend/tests/support/firestore_query_driver_registry.py
Return these shared paths to main's code; each moves to a follow-up:
- the live transcript writer, mark_pending and promote_manual_end pulling a future
  v3_pending_since back to now;
- the Finish and native re-arm clamp (live.due_pending_since);
- the loader's terminal and retryable unreadable split, the retryable rotation in the
  commit and the unreadable-sibling hold built on it;
- the lake-fetch outage race (recording_decode_retryable);
- the preview owner-backoff skip;
- the due_at filter in has_pending.

The settlement wait keeps the older capture on one card without them: a deferred source
keeps a future pending stamp the way held Finishes already do, and the deadline wake
plans it. Kept: the stored deadline, the settlement_deadline wake, the held-sibling
query with its unloaded-sibling hold, and the stricter audio-coverage proof.
# Conflicts:
#	backend/testing/pipeline_lab/scenario/reach.json
@kodjima33
kodjima33 marked this pull request as ready for review November 30, 2026 20:31
… newer speech

Review round 1 on #26771:
- outline._settle_older defers a stretch only when every recording in it is a
  device-sync landing from one known device and a newer stretch holds speech
  from that device, or a stored deadline continues the wait. Live, batch,
  rotation and separate-origin captures keep main's schedule; main's
  late-predecessor Finish test is restored.
- The held-sibling read runs only with settling on landing on and only for
  held device-sync files. It is bounded by capture time on both sides and by
  one 32-document budget per load, skips known device mismatches, and a read
  that fails marks the stretch waiting instead of failing the pass.
- has_pending does not count sources held until a future settlement deadline,
  and the overdue settlement wake uses the settlement task name, so an
  ordinary wake cannot swallow it and the route retries it while busy.

Failure-Class: FC-live-settlement-uses-capture-clock
…ded per pass, and wake every hold

Review round 2 on #26771:
- The sibling lookup reads capture metadata only. It never decodes a
  sibling or adds it to the pass, so an optional sibling can trigger no
  lake read and no neighbour reads. A sibling it finds, or a lookup it
  cannot finish, keeps the held stretch waiting until both share a page
  (bounded as before).
- One SiblingReads allowance per reconcile pass is shared by every load
  attempt and the batch-cap retry. Each query and each streamed document
  is charged before use, failed streams included; a failure ends the
  lookup for the pass.
- _after_projection enqueues a settlement task at every distinct held
  deadline, so an off-page hold keeps its wake.

Failure-Class: FC-live-settlement-uses-capture-clock
kodjima33 and others added 17 commits November 30, 2026 17:14
…arsing, never strand a hold's wake

Review round 3 on #26771:
- Each sibling RunQuery's whole limit is taken from the pass allowance
  before it is sent, and it streams with FIRESTORE_NO_RETRY: the SDK's
  resume after a mid-stream error asked for the same limit again (51 reads
  against 32). A finished call gives back what it did not return.
- Seed parsing (capture bounds) runs inside the lookup's one best-effort
  boundary: any failure ends the lookup, logs and counts a fallback, and the
  pass goes on with main's plan.
- Settlement wakes are retried briefly; one that still cannot be created
  makes the pass report more work, and has_pending re-creates the wake of
  the earliest held source off the page, reporting more work until it
  succeeds.
- MemoryQuery.stream accepts the SDK's retry and timeout options.

Failure-Class: FC-live-settlement-uses-capture-clock
…ibling extends a hold

Review round 4 on #26771, and the same two classes across the new path:
- Stored data is read best effort (outline.instant, a guarded capture
  clock, bounded audio durations): _audio_covers skips a row it cannot
  read, an unreadable stored deadline is no hold, capture spans treat an
  unreadable field as absent, and has_pending counts an unreadable stamp
  as owed work, as on main. None of them fails the pass.
- Only a sibling the lookup finds marks a stretch waiting. A lookup that
  cannot finish (allowance spent) or fails marks nothing, so the stretch
  keeps main's plan; a failure is carried through the load ladder
  (SiblingReads.failed) and no later attempt in the pass looks again.
- A failed pending-order read in has_pending keeps main's answer.
- commit_projection's body digest is re-pinned for the best-effort wake
  stamp.

Failure-Class: FC-live-settlement-uses-capture-clock
…an owner allowlist

Review round 5 on #26771, fixed as classes:
- Containment: the hold, the off-page sibling lookup, the settlement wakes,
  has_pending's settlement logic and the commit's settlement field run only
  for owners on CONVERSATIONS_V3_SETTLE_OLDER_OWNERS (owner tags or *,
  default empty). Off, every pass is main's code; the past-deadline
  rotation now applies only to sources the outline held for settlement.
- Time arithmetic: every clock sum on the path goes through
  outline.shifted, and outline.instant accepts only 2000-2100; a stretch
  whose clocks cannot be placed keeps main's plan, and only an eligible
  stretch's clocks are read.
- Optional I/O: each sibling query has a 3 s timeout and a pass's lookups
  share 10 s; has_pending's narrowing read has a 3 s timeout.
- Evidence: a sibling needs the same known device and a gap strictly below
  the silence gap; provenance is a positive integer sync_content_revision.
- has_pending answers owed work as soon as it reads it.

Failure-Class: FC-live-settlement-uses-capture-clock
# Conflicts:
#	backend/deploy/cloud_run_gmp_sync.yaml
#	backend/routers/conversations_v3_tasks.py
#	backend/testing/pipeline_lab/scenario/reach.json
#	backend/testing/pipeline_lab/scenario/spec.py
#	backend/utils/conversations/v3/triggers.py
…metrics; harden enable paths

Review round 6 on #26771. One gate, config.settle_older_enabled(uid): on
CONVERSATIONS_V3_SETTLE_OLDER_OWNERS, with the live builder settling on
landing. Off for an owner:
- triggers.enqueue(settlement=True) dispatches nothing, and the task
  route keeps main's trigger type: a settlement_deadline payload gets
  main's own 422, a task queued before the owner left the allowlist
  included.
- omi_conversations_v3_settle_older_total is registered on first use, so
  /metrics has no such series.
- CONVERSATIONS_V3_SETTLE_ON_LANDING=off turns off has_pending's held
  sources and the recovery wakes with everything else.
On:
- A hold's deadline counts from the latest valid landing of its own
  sources; an out-of-range stamp is dropped before the maximum.
- preview_wakes rotates an overdue settlement deadline on its own before
  it meets the source's Finish or preview wake, so a shared Finish
  deadline never moves; the commit's own rotation is removed.

Failure-Class: FC-live-settlement-uses-capture-clock
# Conflicts:
#	backend/database/conversations_v3.py
#	backend/deploy/cloud_run_gmp_sync.yaml
#	backend/tests/support/firestore_query_driver_registry.py
#	backend/utils/conversations/v3/outline.py
#	backend/utils/conversations/v3/service.py
…lder settlement off at custom timing too

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kodjima33
kodjima33 merged commit 9a944f8 into main Dec 1, 2026
70 of 71 checks passed
@kodjima33
kodjima33 deleted the t3/v3-reconnect-splits branch December 1, 2026 08:46
Nizarius added a commit that referenced this pull request Dec 1, 2026
Conflicts with #26771 (an older stretch of late speech settles on landing) and #26873 (memory redrive fence).
service.py: _load_live_batch and reconcile carry both the pass's shared sibling_reads allowance and the
lean_builder_pass lease row and clock; every load attempt gets both. The load driver names both sets of
neutral arguments. The projection commit's body digest is pinned again with both re-review notes. The
metrics keep rule is main's with outline_reuse added again. reach.json is measured again on the merged tree
(31 scenarios). test_conversations_v3_fewer_requests.py expects the sibling_reads argument on the load call.

Failure-Class: none
kodjima33 added a commit that referenced this pull request Dec 1, 2026
…26896)

## What turns on

#26771 (merged as 9a944f8): an older stretch of one device's synced
files settles on landing behind that device's newer speech. That covers
the hold, the off-page sibling lookup, settlement wakes and their task
route, and `has_pending`'s held sources. It turns on for **one owner
tag: Nik's account**. Everyone else stays off, and there is no `*`.

## How

- `CONVERSATIONS_V3_SETTLE_OLDER_OWNERS` is bound from Secret Manager
(`CONVERSATIONS_V3_SETTLE_OLDER_OWNERS`, version `1`, pinned) on
`backend`, `backend-sync`, `backend-sync-backfill` and
`backend-integration`. `backend-projection-pump` inherits it via
`derive_from: backend-integration`. The pump never runs a builder pass,
so the binding does nothing there.
- The owner tag is not in Git. The flag registry requires this for the
key ("Owner tags never go in Git (public repo)"), and the runtime-env
README requires it for uid hashes. The secret holds the single tag
(sha256(uid)[:12]). The secret is created and `backend-runtime@` has
`secretAccessor`, so the revision can mount it at deploy.
- `config/deployment-setting-classification.json` classifies the name as
a secret. The approved-bindings test pins version 1 on those five
services.

Widening is Nik's call. That means a new secret version plus a bump of
the pinned version here.

## Rollback (owner-scoped)

On a regression, shift traffic on `backend`, `backend-sync`,
`backend-sync-backfill` and `backend-integration` back to their
pre-enable revisions. Then revert this PR on main so the next deploy
keeps it off. Keep secret version 1 and its `backend-runtime@` grant
intact while any revision references it. After an owner-only rollback,
check the queue for `settlement_deadline` retries still pending.

## Secret startup risk

Cloud Run resolves an env `secretKeyRef` before the container starts. A
disabled or destroyed version, or a revoked grant, would block startup
of every revision that references it. The binding is pinned to version 1
and has an existing `secretAccessor` grant. It uses the same env
`secretKeyRef` pattern as every other secret in this manifest, for
example `CONVERSATIONS_V3_LIVE_RECAP_COHORT`: `runtime_env.yaml` carries
114 other secret bindings. Operational rule: never disable or destroy v1
while a revision references it. After deploy, verify that all four
services became Ready on the new revision.

During the 10% canary split, an enabled revision can enqueue a
`settlement_deadline` task to the service URL. A flag-off incumbent
returns 422 for it, and the queue retries up to 10 times with 30-300 s
backoff. The 5-minute sweep still wakes pending work at least 10 minutes
old. This affects only Nik's tasks, because only his owner tag enqueues
settlement wakes.

cost-delta-usd-day: 0

That's one owner, and only on a full pending page: at most 32 metadata
reads per pass.

## Product invariants affected

- INV-MEM-4

## Failure class (fixes)

No `fix:` commits were detected; no declaration is required.

## Verification

- `compose_runtime_env.py` recomposed `runtime_env.yaml`.
- `backend/scripts/pre-deploy-check.sh`: 710 passed.
- `make preflight` (see the PR checks).
Nizarius added a commit that referenced this pull request Dec 1, 2026
…y switch off (#26875)

## What changed and why

Open pull requests from the backend bottleneck work, joined into one so
they take one pass through CI
instead of one each. Two of the eight parts (#26862, #26851) have since
merged on their own; this PR carries
the same commits, so they add nothing to its diff. Six of them add a row
to the same three flag files (`config/feature-flags.yaml`, the
generated registry page, `backend/config/reliability_experiments.py`),
so merged one at a time each merge made
the next one conflict and cost it another full CI run.

Each part is the head of its own PR, merged here with a merge commit, so
the history of every part is intact.
The original PR carries the full description, measurements and review
notes of its part; they are closed in
favour of this one.

| Part | Original PR | Switch | What a merge changes in production |
|---|---|---|---|
| Flag budget renewal | #26862 (merged) | none | Already on main. |
| GPU worker floor 6 to 12 | #26851 (merged) | none | Already on main.
Nothing changes until the worker chart is rolled by the release owner. |
| Fresh class for just-recorded phone audio | #26848 |
`fresh_class_for_new_audio`, off | One more histogram label; one
in-process flag evaluation per qualifying upload. |
| Commit wake made dependable and measured | #26860 | `commit_wake`
(existing), off | New counters and two histograms for every account;
behaviour only for admitted accounts. |
| Declared unsupported language stays on the vendor route | #26870 |
`declared_unsupported_language_route`, off | Nothing without a rule. |
| One capture transport per listen session | #26822 |
`one_capture_transport`, off | Nothing without a rule, on the backend or
in a new app build. |
| Stored outlines of unvisited stretches are kept | #26832 |
`outline_keep_stored`, off | One new metric; nothing else without a
rule. |
| Live builder pass with fewer database requests | #26868 |
`lean_builder_pass`, `outline_context_on_demand`,
`tombstone_check_written_rows`, all off | Nothing without a rule. |

No flag store rule exists for any of the seven new switches, so no
account's behaviour changes at deploy.

### The parts in one paragraph each

- **Flag budget renewal (#26862).** Carries the three-file change of
#26600 (SCA-3850) onto current main: the
26 rows of `backend/config/flag_budget.json` that passed `review_by` on
2026-11-30 move to 2026-12-06 with
the reasons #26600 gives. One difference from #26600, after review: the
five rows that already carried a
row-specific reason (`BATCH_PIPELINE_PROTECTED_SHARE_ENABLED`,
`BATCH_PIPELINE_PROTECTED_SHARE_PERCENT`,
`SYNC_BACKFILL_WORKER_API_URL`, `SYNC_BACKFILL_WORKER_AUDIENCE`,
`LISTEN_BATCH_RECONNECT_ENABLED`) keep that
text, with the renewal sentence appended. No rollout setting or runtime
value changes.
- **GPU worker floor (#26851).** `replicaCount` and
`autoscaling.minReplicas` of the production batch worker
go from 6 to 12; `maxReplicas` stays 16. Nodes for the weekday peak
cannot be obtained on the day, so the
floor is the only setting that has them in place before the ramp. In a
replay of nine weekdays it about
  halves the mean wait for a worker for 27% more worker node-hours.
- **Fresh class for new audio (#26848).** A phone upload in the backfill
lane whose audio is at most 10 minutes
old is served with the fresh class (job row `priority` 0,
`admitted_priority` 1). Metering, the enrichment
queue and admission still read the admitted class. It reorders the GPU
queue and adds no capacity; the ramp
in the flag row stops at 25% until GPU capacity covers the weekday peak.
The GPU worker image must carry
  this build before the first rule is created.
- **Commit wake (#26860).** A wake that meets a busy account claim is
retried (0.5, 1, 2, 4 s), the first walk
waits 0.5 s, and serving-side commits of an admitted account ask the
in-process owner drain. Counters at
both ends and `commit_to_text` / `ready_to_text` histograms by path and
cohort. In the local load test,
  commit to written fell from a median of 11.2 s to 0.52 s.
- **Declared unsupported language (#26870).** For a multilingual-profile
user (#26431), a declared language
Parakeet cannot serve stays the declaration, so the upload takes the
vendor route at admission: no language
probe, no GPU unit, no refusal, no recovery wait. Supported and unknown
declarations, legacy-on owners and
  the record lane are unchanged.
- **One capture transport (#26822).** With the rule on, a batch-only
session sends no pendant audio on the
socket and a live session gets no phone-file grant, so the same audio is
no longer transcribed twice. Admit
accounts to `end_open_conversation` together with this rule: without
socket audio the baseline End closes
nothing. Stored text then depends on the phone's serial upload queue
alone.
- **Stored outlines kept (#26832).** A live builder or on-open pass
keeps the stored outlines of stretches it
did not visit, so a later visit with the same lines and prompt reuses
the model's answer instead of paying
  for it again. About 11% fewer outline calls with every account on.
- **Fewer database requests per builder pass (#26868).** Three
experiments remove bookkeeping reads and
writes of the live builder pass. On a synthetic day against the
Firestore emulator: same documents and
prompts, reads down 35%, writes down 19%. `tombstone_check_written_rows`
touches the commit's deletion
guard: please review it as such, and agree it with the owner of
conversation deletion before any account is
  admitted.

### Where the parts meet

- `_reconcile_outlines` in `backend/utils/conversations/v3/service.py`
now takes both `keep_stored` (#26832)
and `clock` (#26868). The two do not interfere: a stretch found by its
lines key keeps its stored
fingerprint, and `outline.with_unvisited` drops stored rows by that
fingerprint as before.
- `config/feature-flags.yaml`: the `commit_wake` row is #26860's; #26822
only adds its own row beside it.
- `backend/testing/pipeline_lab/scenario/reach.json` was measured again
on the combined branch.
- `backend/docs/feature-flag-registry.md` was rendered again from the
combined YAML.

### Changed after the automated review

The review bot left 34 comments. One was not valid, three are answered
without a code change, the rest are
fixed in this PR. Behaviour with every switch off is unchanged by all of
them. What changed in behaviour:

- **`one_capture_transport`, app half.** Safety copies are left untagged
per conversation window, by whether
pendant audio was really kept off the socket in that window, not by the
socket's mode when the conversation
closes. Before, phone-microphone copies (always sent) could end marked
as sent with no conversation id and
no upload. The app half now does nothing unless `end_open_conversation`
is also on for the account, because
without socket audio the baseline End closes nothing. The flag row makes
that pairing a precondition of
every cohort. The flag texts now say the rule covers the grant that
comes with the on-phone preview; the
  Standard cohort grant is unchanged and listed as a known limit.
- **`declared_unsupported_language_route`.** With language inheritance
switched off
(`BATCH_PIPELINE_LANGUAGE_INHERITANCE_ENABLED=false`) and a conversation
language that declares nothing, the
kept declaration was lost and the upload went to the GPU. Serving and
shadow intake now take one kept value.
- **`commit_wake`.** The retry set held a busy-claim token no walk
returns (it mattered only with the owner
drain switched off); corrected. `ready_to_text` now times a vendor-route
row without `ready_at` from its
  settle instant, as the ordered merge does.
- **`tombstone_check_written_rows`.** The ramp now starts with a step
that admits no account until the owner
  of conversation deletion has agreed the change to the deletion guard.
- **Simulator and lab.** The pipeline simulator clears an inherited
`OMI_RELIABILITY_EXPERIMENTS`; the lab's
final verdict carries STT routes and queue counts; a scenario's `route`
is validated when it is loaded.
- **Docs.** Wording corrected where it promised more than the code does
(the fresh-class pause is a bound on
promotions, not a guarantee for units already fresh; `served` is the
class on the job row, not who
transcribed the unit; when `lines_key` is written; which rollout
readouts are fleet-wide).

### CI

The first run of this PR had its emulator proofs job cancelled at the
20-minute limit (the job took 18.4 to
19.5 minutes on main that day; this PR's three added proofs take about
70 s there). #26882 has since raised
the limit to 25 minutes on main, so this PR changes no workflow.

### Tuning

- MAX_READY_UNITS (#26848, fresh ring size at which promotion pauses),
new: 600 waiting units, about 30 s of
fleet work at the weekday peak's lease rate; promotion resumes under
300.
- MAX_TIMED_OWNERS (#26860, receipt times kept for the wake start
histogram), new: 8192 accounts per process.
  Past it a wake still walks, untimed.
- SETTLE_SECONDS (#26860, wait before a wake's first walk): before 0 s,
after 0.5 s.
- BUSY_RETRY_DELAYS (#26860, retries of a wake's walk after a busy
account claim): before 0 retries (the wake
  was dropped), after 4 retries at 0.5, 1, 2 and 4 s.
- Worker floor (#26851): before 6, after 12 (`replicaCount` and
`autoscaling.minReplicas`); `maxReplicas`
  stays 16.

### Not in this PR

#26857 (the sweep that gives a lost memory extraction its task back) is
left out. #26859, merged to main on
2026-12-01, recovers the same lost memory obligations with its own
re-drive in the builder sweep, so the two
would now run side by side. #26857 stays open for its author to rework
or close.

Line-Count-Exception: backend/utils/batch_pipeline/scheduler.py | 1529
-> 1534 | the enqueue takes the served class and a rejoining row returns
to its admitted class; both belong to the two functions that own the
ring
Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1978
-> 2003 | the walk now returns its stop reason to the caller
(`walk_owner`, with `project_owner` kept as a wrapper for its existing
callers) and names its origin for the commit-to-text series; one observe
call, two origin markers and the method's signature and docstring.
Splitting the projector is outside this change.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart |
5265 -> 5276 | call sites of the experiment at the per-packet routing
boundary, socket publish, socket close and the status handler; its state
and helpers are in the new part file capture_one_transport.dart
Line-Count-Exception: backend/routers/listen/receiver.py | 3066 -> 3070
| two one-line calls and their two imports; the logic is in
routers/listen/local_preview.py
Line-Count-Exception: backend/utils/conversations/v3/service.py | 2570
-> 2647 | the experiments' branches sit in reconcile and
_reconcile_outlines beside the baseline calls they replace, so the two
paths can be read side by side and deleted together when the rollouts
end; the old branches and the switches go then
Line-Count-Exception: backend/database/conversations_v3.py | 3075 ->
3171 | PendingPage, the pending page clear_terminal_pending returns and
the batched source read share load's private helpers and the commit's
tombstone decision is carved out of its write loop in place; the
baseline paths they duplicate are removed when the rollout ends

## Product invariants affected

- INV-CAP-1: the change of #26822 is in the capture routing boundary
(`app/lib/services/capture/capture_controller.dart`,
`capture_conversation_custody.dart`). No packet loses custody: one that
is not sent is already in a phone file or the safety copy, and one the
safety copy refused is sent as before. Tests follow each packet to
exactly one place.

## How it was verified

Each part was verified on its own branch; the commands and results are
in its PR. On the combined branch:

- Unit, after the review fixes: the test files the parts change, every
`test_conversations_v3*`,
`test_reliability_experiment*`, pipeline lab and simulator file, the
batch intake, commit, projection,
scheduler, admission and language files, the local preview and Standard
batch files, the Firestore query
shape guard and the flag files, plus the multipart and part-retirement
files, every unit file that exercises batch intake and the unit files
main changed since: 216 files, 9,661 tests, all pass
  (`BACKEND_UNIT_TEST_FILE_LIST=<list> bash test.sh`).
- App, after the review fixes: `flutter test` on
`one_capture_transport_test.dart`,
`local_preview_admission_test.dart` and
`reliability_experiments_test.dart`: 73 pass; `flutter analyze` on
  the changed files: no issues.
- Firestore emulator: the integration files of #26868, #26832, #26870
and #26860 plus
`test_conversations_v3_unchanged_writes_firestore.py`: 45 tests pass,
also after the review fixes. After
the merge of #26847 (multipart reads and part retirement, which meets
`tombstone_check_written_rows` in the
projection commit) the same files plus
`test_conversations_v3_finish_emulator.py` and
`test_v3_multipart_transcript_firestore.py`: 92 pass; after the merge of
#26771 and #26873, with the locked
  closure cost and live catch-up files added: 104 pass. One of them,
`test_naming_a_speaker_rearms_a_recording_and_nothing_stored_differs`,
failed when run between 07:34 and
08:00 UTC, because the story's first recording (26 minutes, starting
eight hours before the run) then
crosses midnight UTC and the baseline outlines one more stretch. The
test now starts that recording half an
  hour earlier in that case, and the file passes inside the window.
- Pipeline lab, all 30 committed scenarios: 30 pass (`scenario run
--trace-calls`, the run `reach.json` was
measured from), 30 pass again after the review fixes, and all 31 (main
added one) after the last merge of main.
- Pipeline lab, old against new, run before the review fixes (`scenario
compare`, four arms: `origin/main`, this branch with every switch
off, with the four v3 switches on together, with all eight switches on
together). With the switches off,
every scenario main can run (28 of 30) has the same conversations and
exactly the same reads, writes and
no-op writes as main. With the switches on, no conversation differs;
reads fall 10.6% and writes 9.3%
over those scenarios, and the four v3 switches together give the same
result as all eight. The four
scenarios whose verdict changes with a switch are the ones written to
show that switch
(`fewer_requests_two_talks_and_late_sync`, `outline_kept_across_passes`
and the two
  `stt_route_declared_unsupported_language_*`).
- `scripts/check_feature_flag_registry.py`: OK. `scripts/pr-preflight`:
65 of 65 checks pass.

Not verified on the combined branch: a running stack, a phone,
production. The app half of #26822 was run on
a test phone from its own branch (results in #26822), not from this one,
and that run predates the changes
made in review (per-window untagging, the `end_open_conversation`
guard): tests are their only evidence.

## Tests

Every part brings its own tests (listed below). Added or strengthened in
review: the per-window untagging,
the `end_open_conversation` guard, a capture-end flush and the hold
counters in the app tests; the provider
open and the warm-before-admission order in
`test_reliability_experiment_one_capture_transport.py`; the kept
declaration with inheritance off in the three language test files; the
real projector walk with the claim held
and the vendor-row ready time in
`test_reliability_experiment_commit_wake.py`; changed lines against a
stored
outline in `test_conversations_v3_fewer_requests.py`; a real opened
conversation in
`test_reliability_experiment_outline_keep_stored.py`; the simulator's
inherited override in
`test_pipeline_sim_new_audio_wait.py`; the lab verdict's routes and the
route names at load.

- #26848: `tests/unit/test_reliability_experiment_fresh_class.py`,
`tests/unit/test_pipeline_sim_new_audio_wait.py`.
- #26860: `tests/unit/test_reliability_experiment_commit_wake.py`,
`tests/integration/test_batch_commit_wake_firestore.py`.
- #26870: `tests/unit/test_batch_multilingual_profile_routing.py`,
`tests/unit/test_batch_admission_language.py`,

`tests/integration/test_batch_declared_unsupported_language_route_firestore.py`,
two pipeline lab scenarios.
- #26822:
`tests/unit/test_reliability_experiment_one_capture_transport.py`,
  `app/test/services/capture/one_capture_transport_test.dart`.
- #26832:
`tests/unit/test_reliability_experiment_outline_keep_stored.py`,

`tests/integration/test_conversations_v3_outline_keep_stored_firestore.py`.
- #26868: `tests/unit/test_conversations_v3_fewer_requests.py`,
`tests/integration/test_conversations_v3_fewer_requests_firestore.py`,
one pipeline lab scenario.
- #26851: `tests/unit/test_batch_pipeline_chart.py` and the two HPA
replay files follow the new floor.
- #26862: `tests/unit/test_flag_budget.py` follows the new dates.

## UI evidence

UI-Evidence: none -- no screen changes

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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