Repository navigation
SCA-4434: v3 Finish cuts a capture that sealed after the live window's tail - #26419
Conversation
…s tail A live v3 window idle inside live.MAX_IDLE made Finish cut its tail (A) while a newer pendant or server-batch capture (B), still waiting on its transcript and so in no window, got neither the manual-end cut nor a fast finish. A short B then stayed hidden under the Home word floor. request_finish now runs the existing bounded recent-source scan (_recent_finish_sources, at most 8 documents) inside its transaction when CONVERSATIONS_V3_FINISH_NEWER_CAPTURE is on (default). One sealed, unclaimed, eligible capture newer than the window's finished_at takes the recording-scoped cut through _finish_capture, and the response names it. Two such captures decline as recording_ambiguous. A capture an earlier recording-scoped Finish marked answers the retry, so A is never cut as well. New outcomes newer_recording_cut and newer_recording_requested. Removes the expected_failure from pipeline-lab finish_after_second_close and re-measures its budget. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ins, retry checks) - A newer capture takes the Finish only with has_content; one already known empty (already_empty) or declined keeps the window-tail cut, so a silent capture no longer swallows the cut on A. - Two newer captures: the newest wins, as in _latest_capture; an exact tie cuts the window tail instead of answering recording_ambiguous (a 404 the app reads as already closed). - A retry on a capture an earlier tap marked refuses it once it is private, locked, deleted, discarded, merged, a partial archive or a failed upload, and writes nothing. A mark that resolved empty no longer holds the Finish, so a second tap cuts the tail. - The redirect reads the account-deletion marker before writing (_account_deleting, shared with _live_window_or_deleting). - Every moved-Finish outcome counts with a newer_ prefix in omi_conversations_v3_finish_no_pointer_total, all pre-initialised. - Pipeline lab: the batch lane writes has_content with server_batch_audio_end at seal, as production's audio custody does in one transaction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4e5cfebb86
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…pture The session's last capture is often silence only (the quiet timeout seals A, the device stop seals B). Audio custody sets has_content on any committed audio and mark_new stamps v3_speech_landed_at at creation, so a silent batch B took the whole Finish and A stayed uncut until B's batch completed. When the newer capture is a server-batch capture whose projection has not landed (_batch_speech_landed), the same request_finish transaction now stores A's window-tail cut (exactly main's) and B's recording-scoped request, and answers with A's window. Both ledger reads precede both writes (_finish_window_tail / _finish_capture take a pre-read state). Counted as newer_dual_<tail outcome>. A capture whose speech landed keeps the redirect. Retries: when A already carries this window's Finish, the tail answers and B is left alone. A marked capture that can no longer answer (ineligible, or _finish_capture declines) now falls through to the tail cut instead of an empty-id 404 the app reads as already closed. Adds the older-than-mark test and fixes the change note's second-tap wording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…gnal and cost Adds test_one_finish_cuts_a_at_once_and_consumes_b_once_across_resolution_and_retry: B created through the real mark_new (creation stamp), Finish stores A's cut and B's request, B's projection lands and the real whole-record completion consumes the request (speech, or silence), then the same Finish again. A is cut once, B is requested and consumed once, and the retry answers A's window with already_cut and no writes, all under StrictFirestore. Removing the retry guard fails the speech case. Change note: states the one-Finish-two-cards behaviour, why batch captures use _batch_speech_landed rather than has_finish_content (mark_new stamps v3_speech_landed_at at creation; a fast-finish provisional transcript never sets record_projection_revision), and the provider cost: at most one fast-finish pass per stored-both Finish, bounded by the flag and the funded STT allowance. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts with the named-window Finish (#26361), the end_open_conversation End cut and the moved v3 live Finish code: - finish.py: keep main's named Finish, _recovered and outcome sets; the deliberate-Finish observer now also fires on the named path. Outcomes are matched after stripping named_/newer_/dual_ prefixes, so named_* counts now and newer_*/newer_dual_* (#26419) will once that lands. - outline.py: keep main's owner-level cuts and ends(); cut sources are looked up per cut instant, and an owner End cut carries the recording marks it answered. - service.py: _reconcile_groups is async and loads main's owner cuts. - routers/conversations.py: keep main's ended_at/Response params, End answer and finish_only_body; bind the Finish alongside them. - app: send X-Omi-Ended-At and X-Omi-Finish-Cut together; regenerate the perf production shell hash. - Replace a stale delivery test that patched a removed import with a direct test of the Home-projection summary observer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ture # Conflicts: # backend/docs/feature-flag-registry.md # config/feature-flags.yaml
…nish (#26344) After merging #26344: fast finish is chunked by default (5-minute chunks with 3 s overlap, sent concurrently), and a B over 20 minutes runs only for the long canary (LONG_PERCENT, 25 in production) under the fleet-wide LONG_DAILY_SECONDS cap (7200 s/UTC day in production). The change note no longer says there is no fast-finish daily cap. finish_after_second_close re-measured on the merged base: 299 reads, 74 writes, 12 no-op, STT 1 via fast_finish, LLM 6; caps unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Verification for c75e13c
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c75e13c470
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| One Finish may end two cards: A's window is cut at once; if B lands with speech, B's request becomes its own | ||
| manual end. The response names A's window, and a retry answers the same target without writing. | ||
| """ | ||
| from utils.conversations.v3 import triggers |
There was a problem hiding this comment.
Move the new end-to-end test's import to module scope
The previously reported helper and account-deletion imports have been moved, but the newly added end-to-end test introduces another function-local import here. backend/AGENTS.md explicitly requires “All imports at module top level — never inside functions,” including in backend tests. Move this triggers import into the module-level import block to complete the earlier correction.
AGENTS.md reference: backend/AGENTS.md:L168-L168
Useful? React with 👍 / 👎.
…tion _newer_capture ran record_fallback inside the @firestore.transactional body, which re-runs on contention, so one Finish could count its tie or full-scan fallback once per attempt. The body now marks a per-attempt flag, reset at the top of commit, and request_finish records the fallback once after the transaction returns. The new retry test aborts the first attempt after the scan and before any write; with the in-body recording it sees two calls. The race test's function-local triggers import moves to module scope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve backend/utils/conversations/v3/finish.py against #26440 (SCA-2918 per-owner holdout): keep this branch's three-tuple request_finish with newer_capture and the `capture or window` acknowledgement, and keep main's named_only strict fallback for a named Finish beside a legacy row. Main's holdout contract tests stubbed request_finish with the old two-tuple; they now return (outcome, recording id, None), matching this branch's request_finish contract. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f41ed5fe9
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if window is not None: | ||
| outcome, recording_id = conversations_v3_live.request_finish(uid, window['id'], now=now) | ||
| outcome, recording_id, capture = conversations_v3_live.request_finish( | ||
| uid, window['id'], now=now, newer_capture=newer_capture |
There was a problem hiding this comment.
Disable newer-capture retargeting for strict named Finish
When a held-out owner has a legacy conversation in progress alongside a live v3 window, process_in_progress_conversation calls this helper with named_only=True specifically to finish only the named window. This call now enables newer-capture retargeting even in that strict mode: if an unclaimed capture sealed after the named window, request_finish can cut that unrelated capture and return before reaching the strict=True path below. This can leave the requested window unfinished or finish both targets for a pending batch capture. Disable newer-capture retargeting when named_only is true.
Useful? React with 👍 / 👎.
| # Past a full scan, keep the tail cut rather than guess which capture is the newest. | ||
| if not capped | ||
| and not row.get(FINISH_RECORDING_FIELD) | ||
| and row.get('has_content') is True |
There was a problem hiding this comment.
Keep partially transcribed batch captures eligible for Finish
When B is a multi-unit batch capture whose first projected unit is silent while another unit remains pending, replace_record sets has_content=False even though B still has retained audio and its native ledger is processing. The existing test_finish_accepts_retained_audio_after_first_native_unit_is_silent covers this state for the recording-only Finish path, but this new filter excludes B outright when A's window is live. Finish consequently cuts only A and never stores B's request, so speech arriving from B's remaining units does not receive the requested manual end. Allow pending batch captures with retained audio to qualify, and distinguish a partial empty projection from whole-record silence before excluding them.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Deferring this as a non-regression follow-up. On main, Finish never redirects to B, so this PR introduces no case where B's request is lost. The recording-only Finish path (test_finish_accepts_retained_audio_after_first_native_unit_is_silent) still covers the partial-silent multi-unit capture. Telling a partial empty projection apart from whole-record silence in the live-window redirect filter will be its own change. Leaving this thread open.
There was a problem hiding this comment.
Follow-up filed as SCA-5067 (Pipeline backlog), taken after this PR merges. It covers the regression test (silent first unit with another unit still pending, Finish stores B's request), keeping whole-record silence excluded, and a post-release check of the already_empty decline rate against a comparable baseline.
finish_live_window(named_only=True) promises to finish only the window window_id names. With CONVERSATIONS_V3_FINISH_NEWER_CAPTURE on, the live named-window branch passed newer_capture=True to request_finish, so a holdout Finish could move the cut and its answer to a newer capture. Pass newer_capture=False on the named_only path; other paths are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6a2a0b479
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if row.get('data_protection_level') == 'private' or any(row.get(key) for key in _FINISH_BLOCKERS): | ||
| # It can no longer take a Finish. A 404 would read as "already closed" to the app; cut the tail. | ||
| logger.info('v3 Finish found its earlier capture no longer finishable; cutting the window tail') | ||
| return None |
There was a problem hiding this comment.
Instrument the retry fallback when a capture becomes ineligible
When a previously finished capture becomes private, locked, deleted, or otherwise blocked between taps, this branch redirects Finish to the older window tail but emits only an informational log. Unlike the corrected tie and capped-scan branches, it never appends to degraded, so request_finish skips shared fallback telemetry and counts the result as an ordinary tail cut. Mark this decision as degraded so the existing post-commit emitter records it once, including across transaction retries.
AGENTS.md reference: backend/AGENTS.md:L327-L327
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 319860b. The branch where an earlier finished capture is now private, locked, deleted or blocked appends to degraded, the same way the tie and capped-scan branches do. request_finish's post-commit _record_newer_capture_fallback() then records it once (conversation_finalization, newer_capture → window_tail, reason other, outcome degraded). The list resets on every transaction attempt. Tests: test_live_window_finish_retry_cuts_the_tail_when_the_finished_capture_cannot_answer asserts exactly one emission for each blocked state and none on the first tap's redirect. test_live_window_finish_records_degraded_targeting_once_across_transaction_retries[finished_capture_locked] asserts one emission across a simulated Aborted retry. Behaviour is unchanged.
Review panel review-20261127t015349-a22e, F1-F5 (SCA-4799 ruling).
F1: each live-window Finish stamps v3_finish_requested {at, path} in the
first write it stores on its response target's source (tail, newer, or
the tail alone in the stored-both case; B's request rides unstamped). The
planner carries the stamp to the derived row, and that row's first
visible manual-end settlement observes
omi_conversations_v3_finish_to_visible_seconds{path} once. Stamps older
than 2 h are dropped. Kept by the sync scrape profile.
F3: a selected newer capture that declines the cut counts in
omi_conversations_v3_finish_newer_declined_total{reason}; the tail cut
and its answer are unchanged. The unreachable newer_already_empty,
newer_batch_unavailable and newer_batch_disabled labels are removed.
F2/F4: document and pin the ledger read on the server-batch redirect and
marked pending-retry paths. F5: assert on the retained B row directly.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/database/conversations_v3_processing.py
…d Tasks graph metrics imported FINISH_STAMP_PATHS from v3.live, whose config.conversations_v3 import reaches utils.cloud_tasks, so diarizer.batch_pipeline_runtime gained a Cloud Tasks edge (test_gpu_batch_retry_cap_does_not_reach_cloud_tasks). Move FINISH_STAMP_FIELD/PATHS/MAX_AGE to a dependency-free v3.finish_stamp module; live re-exports them, so callers and behaviour are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…yright Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e0bc3ac71
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def test_newer_capture_finish_labels_are_reachable_or_absent(): | ||
| """Every pre-initialised newer_* outcome is one request_finish can return; declines are counted apart.""" | ||
| from utils.conversations.v3 import metrics |
There was a problem hiding this comment.
Move the new test imports to module scope
The new metrics-label test imports metrics inside its function, and test_finish_stamp_follows_the_cut_to_its_card_once in backend/tests/unit/test_conversations_v3_engine.py:815 likewise introduces a function-local import. Although the previously reported imports have been moved, these newly added imports still violate backend/AGENTS.md's explicit requirement that all imports be at module scope. Move both dependencies into their respective module-level import blocks.
AGENTS.md reference: backend/AGENTS.md:L168-L168
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 319860b. test_newer_capture_finish_labels_are_reachable_or_absent now uses a module-level metrics as v3_metrics import (test_episodes_finalize_paths.py:38). test_finish_stamp_follows_the_cut_to_its_card_once now uses a module-level from utils.conversations.v3.live import ... (test_conversations_v3_engine.py:13). Neither adds an import edge: planner already imports live at module scope, and v3_finish already pulls in metrics. test_runtime_image_contracts.py passes.
| # The newer capture was selected but declines the cut (already empty, batch unavailable or disabled, | ||
| # or ineligible): _finish_capture wrote nothing, so the tail is cut and answers. The decline is | ||
| # counted apart (FINISH_NEWER_DECLINED) once the transaction commits. | ||
| declined.append(outcome) |
There was a problem hiding this comment.
Emit shared fallback telemetry for declined capture cuts
When a selected newer capture's ledger is unavailable or batch manual-end is disabled, _finish_capture declines the request and this branch cuts the older window tail instead. It appends only to declined, so the post-commit code increments FINISH_NEWER_DECLINED without calling the shared fallback emitter. These degraded targeting decisions therefore remain absent from omi_fallback_total, contrary to the backend's new-fallback requirement. Also mark these declines as degraded and use the existing post-commit emitter so transaction retries do not duplicate telemetry.
AGENTS.md reference: backend/AGENTS.md:L327-L327
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 319860b. A selected newer capture that declines the cut now also records the shared fallback after commit, through the same _record_newer_capture_fallback helper: same component and newer_capture → window_tail modes, outcome degraded, with a reason label for each decline: batch_unavailable → unavailable, batch_disabled → dispatch_disabled, recording_ineligible → policy. already_empty emits nothing. That capture held only silence, so the window tail really is the last speech; this matches the resolved-empty retry, which also emits nothing. FINISH_NEWER_DECLINED{reason} is unchanged and still counts all four. degraded and declined can't both be set in one committed attempt, and the emitter is if/elif, so one Finish records at most one fallback. Retries reset both lists. Tests: the decline test asserts one emission per reason and none for already_empty. The retry test's [declined] case asserts one emission and one decline count across a simulated Aborted retry. The no-candidate test asserts none. Behaviour is unchanged.
…capture # Conflicts: # backend/docs/feature-flag-registry.md
…lined cuts A retried Finish whose earlier capture became private, locked, deleted or blocked now appends to `degraded`, so the existing post-commit emitter records it once (reason other), as the tie and capped-scan branches do. A selected newer capture that declines the cut (batch_unavailable, batch_disabled, recording_ineligible) now also records the shared newer_capture -> window_tail fallback after commit, with reason unavailable, dispatch_disabled or policy. already_empty stays a FINISH_NEWER_DECLINED count only: a silent capture is not the last speech, so the tail is the right answer. degraded and declined are exclusive per committed attempt, so one Finish records at most one fallback, and retries reset both lists. Tests: the fallback is asserted once per Finish across a simulated transaction retry for both new paths, and absent on the ordinary paths. Function-local test imports move to module scope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…apture) Combine the deliberate-Finish SLI (SCA-4489) with Finish newer capture (SCA-4434, #26419): - finish.py: every live-window path passes observe_recording into _acknowledge alongside #26419's capture-or-window answer. The SLI binds before the newer_/dual_ prefix strip (deliberate_finish already strips it), so it binds the recording the answer names: the newer capture on newer_*, the window tail on newer_dual_*, tail and declined Finishes. That is the same response target that carries v3_finish_requested. - conversations_v3_processing.py: settle keeps both the eligibility list and the Finish-to-visible sample, each reset per transaction attempt and emitted after commit. - routers/conversations.py: main's wall-budgeted Home read moved v3_home into read_page; record it there and run the beta Home summary validation on the final projected (possibly truncated) page. - Flag registry/yaml: keep both CONVERSATIONS_V3_FINISH_HOME_SLI and CONVERSATIONS_V3_FINISH_NEWER_CAPTURE rows. - Test: the SLI binds the stamped response target on tail, newer, newer_dual and declined paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
When Finish resolves to a live v3 window and a capture sealed after that window's last speech, Finish now also finishes that newer capture. Before, it cut only the window's tail. The bug was reproduced by pipeline-lab
finish_after_second_close(#26389):v3_recording_ids.A's window was still live: idle 125 s, inside
live.MAX_IDLE= 2 h. Sofinish_live_windowcalledrequest_finishon that window, which cutmembers[-1]= A. B got neither the manual-end cut nor a fast finish, and a short B stayed hidden under the Home word floor. The #26288 single-capture fallback and the #26361 named-window path both run only when no window is live.DESIGN
Reads and writes. This changes only the live-window Finish transaction, with
CONVERSATIONS_V3_FINISH_NEWER_CAPTUREon.the existing
_recent_finish_sourcesquery: at most 8 documents, 1 billed read when empty;when a newer capture qualifies, the account-deletion marker, then by path:
newer_recording_*)_finish_capture→_native_projection_state, sincenewer_stateis None)newer_already_requested/newer_consumed)newer_dual_*)Pinned by
test_server_batch_redirect_reads_the_capture_ledger_once,test_marked_pending_retry_reads_the_capture_ledger_once,test_stored_both_reads_each_ledger_once_before_any_write(exact ordered read paths).Settlement: none added. The Finish-to-visible sample is read from the derived row
settle_processingalready reads.v3_finish_requested) rides in the write the transaction already makes, and the planner carries it in the derived-row write it already makes: no added write.tailstamp in its existing write.on): each unit is split into chunks of at most 5 min with 3 s of overlap, sent concurrently. A B of up to 20 min (MAX_SECONDS) is a few prerecorded requests; the lab's 80 s B is one (STT 0 → 1).MAX_UNITS(8), up to 20 min.CONVERSATIONS_V3_FAST_FINISH:cohortby default, but production runsonfor the services that serve Finish and admission, so the cohort does not limit it there.CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT(25 in production) andCONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS(7200 s of such audio per UTC day across the fleet in production). That is the only fast-finish daily cap; a long pass reserves its planned seconds before any spend.fast_finish.funded→sync_admission(lane='batch')): consent and the owner's funded STT plan allowance.Production readback:
omi_conversations_v3_finish_no_pointer_totalbyoutcomefor thenewer_*andnewer_dual_*labels, against the tail path'scut/requested. That shows how often Finish finds a newer capture and which branch it takes.omi_conversations_v3_finish_to_visible_seconds{path}(tail/newer/newer_dual),le="60"bucket over_count, compared by path. One sample per Finish, at the response target's first visible manual-end settlement; kept by the sync scrape profile.omi_conversations_v3_finish_newer_declined_total{reason}: how often a selected newer capture declined and the tail answered.Change
database/conversations_v3_live.pyrequest_finish(..., newer_capture=False)gets a new parameter. When it is true, the transaction runs the existing_recent_finish_sourcesscan after its two document reads and before any write._newer_capture()selects the capture. A capture qualifies when it:finished_at;has_content(a projection that landed empty clears it);_capture_ineligible(row, now): sealed withinRECENT_FINISH_AGE, unclaimed, not marked for another window, not private, deleted, discarded, locked, merged, partial or upload-failed.The newest qualifying capture wins, as in
_latest_capture. The account-deletion check (_account_deleting, shared with_live_window_or_deleting) runs before any write.B's speech has landed (a live-lane capture with
has_finish_content, or a batch capture whose projection landed): redirect only. B gets the recording-scoped cut or request through_finish_capture, and the response names B. Outcomes arenewer_recording_cut/newer_recording_requested.B is a server-batch capture whose projection has not landed (
_batch_speech_landed). It may hold only silence: the session's last capture often does, after the quiet timeout seals A and the device stop seals B. The same transaction:Both ledger reads come first.
_finish_window_tailand_finish_capturetake a pre-readstate=, and StrictFirestore enforces the order in tests. The response names A's window, because the cut landed there. The outcome isnewer_dual_<tail outcome>.Why not
has_finish_contentfor batch B? In production it is true for almost every batch capture right after creation.create_in_progress_conversation→mark_newstampsv3_speech_landed_atat creation (utils/conversations/v3/triggers.py:61-69), and audio custody setshas_contenton any committed audio (database/server_batch_audio.py:60). So a batch capture's speech has landed only with its projection:record_projection_revisiontogether withhas_content. The lab, which creates captures through the product path, shows the same stamp. A test pins it:created_stamp=Truefails if the check goes back tohas_finish_content.The window-tail cut alone runs unchanged when:
finished_at;_finish_capturedeclines or answersalready_empty. It writes nothing in those cases.Retries never cut A twice.
already_cut/already_requested) and B is not touched._finish_capture, even if a window claimed it between taps._finish_capturedeclines, e.g. an unavailable ledger), the window tail is cut. The app'ssettleManualFinishreads a 404 as "already closed", so a 404 would leave A uncut._finish_capturewrites nothing on those declines, so the tail cut's reads still precede every write.utils/conversations/v3/finish.py: both live-window calls pass the switch. They are the empty body and a named window that is still live._acknowledgecounts the full label, then stripsnewer_/dual_to answer like the path that stored it. A window answer is what the app already settles on:settleManualFinishbinds_finishLiveIdto it (app/lib/providers/conversations_v3_provider.dart:145-173).config/conversations_v3.py:finish_newer_capture_enabled()adds the kill switchCONVERSATIONS_V3_FINISH_NEWER_CAPTURE. It defaults on; off is exactly main.utils/conversations/v3/metrics.py: pre-initialised labels inomi_conversations_v3_finish_no_pointer_total, apart from the tail path's outcomes, every one reachable:newer_recording_cut,newer_recording_requested,newer_already_cut,newer_already_requested,newer_resolved_empty,newer_consumed,newer_recording_ineligible(account being deleted);newer_dual_cut,newer_dual_requested,newer_dual_consumed,newer_dual_already_cut,newer_dual_already_requested,newer_dual_already_empty,newer_dual_resolved_empty.newer_already_empty,newer_batch_unavailable,newer_batch_disabledcould never be returned and are removed. A selected-then-declined capture counts inomi_conversations_v3_finish_newer_declined_total{reason}(already_empty,batch_unavailable,batch_disabled,recording_ineligible), once after the commit; the window tail still cuts and answers, counted as the tail's outcome.omi_conversations_v3_finish_to_visible_seconds{path}, histogram,path∈tail/newer/newer_dual, buckets 5 s – 2 h.request_finishstampsv3_finish_requested = {at, path}in the first write it stores on the response target's source: the tail fortail/newer_dual, B fornewer. In the stored-both case the tail's write is planned first (_window_tail_plan, no read or write), so B's request is stamped only when the answer names B; otherwise B rides along unstamped and B's own card never samples. Consuming cuts andalready_*answers write no stamp, so a retried Finish keeps the first. The planner carries the stamp to the derived row that shows the cut (first stamp wins).settle_processingobservesnow - atonce, at the row's first visible manual-end settlement (thev3_manual_end_home_countedtransition), after the transaction commits; a stamp older than 2 h, a hidden row, or a re-settlement records nothing.first_speech_to_visible_secondsis not reused: it fires at row creation, and a live window's row exists before its Finish.deploy/cloud_run_gmp_sync.yamlkeeps the histogram.scenario/ops.py): at seal, the batch lane writeshas_contentwithserver_batch_audio_end, as production'snote_server_batch_audiodoes in one transaction.finish_after_second_closenow expects the answer to name A's window (finish_response_names_a_window) and B to be fast-finished (b_fast_finished, the check main fails).listen_pusher_pipeline.mdx, change note, Firestore query driver forrequest_finish.Verification
All commands ran from
backend/in the lane worktree, throughomi-heavy. Base is origin/mainafab9560db2.Scenario on main:
finish_after_second_closegave XFAIL. A was cut, B got no fast finish, reads 236.Scenario with the change: PASSED. The answer names A's window; B fast finish
written; B on Home. Reads 304, writes 74, no-op writes 12, STT 1, LLM 6. The budget is re-measured.Scenario with
"env": {"CONVERSATIONS_V3_FINISH_NEWER_CAPTURE": "off"}: same as main, at this head. Target A,b_fast_finishedfails, 236 reads, 62 writes, 0 STT.All 13 committed scenarios: passed.
Unit tests:
tests/unit/test_episodes_finalize_paths.py, 154 passed; with the Firestore guard set, 1079 passed.End-to-end race test (owners' request):
test_one_finish_cuts_a_at_once_and_consumes_b_once_across_resolution_and_retry, parametrized by B landing withspeechorsilence. It runs entirely on StrictFirestore:triggers.mark_new, so it carries the creation stamp.replace_record), then the real whole-record completion (store.complete→_v3_finish_update) runs twice. B's request is consumed once: B ends withv3_manual_endfor speech, or the request is cleared for silence.already_cutand no writes; A is cut once and B is requested once.With the retry guard removed,
[speech]fails (the retry answerscapture-b).[silence]still passes, because a mark that resolved empty no longer holds the Finish, so the retry reaches A's tail either way.Each new test fails without its own fix. Mutation runs:
has_finish_contentas the batch speech signal: 4 fail (created_stamp=True);The previous round's mutations (
has_contentgate,already_emptydecline, newest-wins, deletion marker) still hold.Degraded-targeting telemetry counts once per Finish. A tie or a full scan records
omi_fallback_total(conversation_finalization,newer_capture→window_tail,degraded)._newer_captureonly marks a per-attempt flag, reset at the top of the transaction body;request_finishrecords it once after the transaction commits.test_live_window_finish_records_degraded_targeting_once_across_transaction_retries[tie|full_scan]aborts the first attempt after the scan and before any write. With the recording back inside the body, both cases fail: "Called 2 times".Targeted set: 43 files, 2597 tests passed: the changed tests, the Firestore guard set, every
test_conversations_v3_*,test_reliability_experiment_end_*,test_reason_label_enums,test_pipeline_lab_*,test_batch_pipeline_projectionandtest_server_batch_completion.scripts/check_feature_flag_registry.pyOK.Review fixes (panel
review-20261127t015349-a22e, F1–F5)test_live_window_finish_stamps_only_its_response_target[tail|newer|newer_dual],test_retried_live_window_finish_keeps_the_first_stamp[...],test_consuming_cut_keeps_the_stamp_of_the_finish_that_stored_the_request[tail|newer],test_finish_stamp_follows_the_cut_to_its_card_once(planner, dual card),test_finish_to_visible_is_observed_once_at_the_first_visible_settlement[...](re-settlement does not repeat),test_finish_to_visible_drops_stale_hidden_and_unstamped_rows[stale|hidden|unknown_path|no_time|unstamped],test_finish_to_visible_dual_card_samples_only_the_response_target,test_cloud_run_sync_scrapes_finish_to_visible.test_live_window_finish_counts_a_declined_newer_capture_and_still_cuts_the_tail[already_empty|batch_unavailable|batch_disabled|recording_ineligible]and, separately,test_live_window_finish_without_a_newer_candidate_counts_no_decline[none|older_than_window|silent];test_newer_capture_finish_labels_are_reachable_or_absent.test_live_window_finish_cuts_the_tail_without_a_newer_finishable_captureasserts on the retainedbthat neitherv3_manual_endnorv3_manual_end_requestedwas written (and, fornone, that B was not recreated).test_episodes_finalize_paths178,test_conversations_v3_fast_finish115,test_conversations_v3_contract119,test_firestore_query_shapes644,test_firestore_runtime_witnesses25,test_conversations_v3_live_passes53,test_conversations_v3_live_rederive129,test_conversations_v3_created_delivery59,test_conversations_v3_engine97,test_conversations_v3_finish_late_predecessor33,test_batch_pipeline_projection87,test_pipeline_lab_scenario51,test_monitoring_telemetry_contract58,test_fleet_deployment11,test_attach_cloud_run_gmp_sidecar117.python -m testing.pipeline_lab affected→ 15 scenarios, all passed, budgets unchanged (finish_after_second_closeincluded).The full backend unit suite is left to CI.
Lab vs production
manual_end = noin the lab. The lab's native-completion stand-in (batch_projection) skips the projection transaction, so neither A's window-scoped request nor B's recording-scoped request is ever promoted tov3_manual_end. Production promotes them: at admission for a window-targeted single unit, at whole-record ledger completion for a recording-scoped request (database/batch_pipeline_projection.py,whole_record_consumed), as for the existing v3: Finish a sealed recording before its first live window #26288 fallback. In the lab, A and B end in one conversation because no cut lands.4d2e913c). Under its chunked fast finish and extended lab STT stand-in,finish_after_second_closestill meets every check (b_fast_finished: written, STT 1 viafast_finish), now at 299 reads (was 304).Rollback
Set
CONVERSATIONS_V3_FINISH_NEWER_CAPTURE=offon the API service that servesPOST /v1/conversations. That restores exactly main's Finish without a deploy; cuts and requests already stored stay. Or revert the merge commit.Product invariants affected: none
Failure-Class: none
🤖 Generated with Claude Code