Repository navigation
SCA-4489: Measure deliberate v3 Finish to first Home summary - #26332
Git-on-my-level wants to merge 29 commits into
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bbbbb0651
ℹ️ 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".
| finish_home_sli.observe_home_summary( | ||
| uid, {**row, 'id': cid, 'v3_notes_written': True, 'tile_state': 'done'} | ||
| ) |
There was a problem hiding this comment.
Emit the summary receipt for foreground notes writes
When a user opens a manually finished card before background notes complete, summary.stream() persists its notes through writers.store_summary(), which sets v3_notes_written=True but never calls observe_home_summary(). The receipt added here only runs when settle_processing() sees the first notes write; after store_summary(), its outcome is already None. Consequently, a summary actually available on Home remains unmatched until another reconcile happens to emit a receipt, potentially turning a successful sub-60-second Finish into a late or unmatched sample. Emit the observation after the foreground summary commit as well.
Useful? React with 👍 / 👎.
| from database.conversations import is_visible_conversation | ||
| from utils.conversations.fragment_visibility import is_relevance_discarded | ||
| from utils.conversations.summary_delivery import present |
There was a problem hiding this comment.
Move the new function-local imports to module scope
The new helper imports its dependencies inside observe_home_summary(), contrary to the explicit import convention in backend/AGENTS.md: all imports must be at module scope. The new import in fast_finish._run() has the same issue. Move these dependencies to module scope, restructuring shared dependencies if necessary to avoid a cycle.
AGENTS.md reference: backend/AGENTS.md:L166-L168
Useful? React with 👍 / 👎.
| # v3 TestFlight Finish-to-Home readback | ||
|
|
||
| SCA-4489 measures deliberate v3 beta Finishes that reach the Finish API. The |
There was a problem hiding this comment.
Add the required pipeline change note
This introduces a conversation-lifecycle observation contract, including a new Finish request header and runtime flag, but the commit's complete changed-file list contains no note under backend/docs/listen_pusher_pipeline/changes/. backend/AGENTS.md explicitly requires a note there for conversation-lifecycle changes; the separate SLI runbook does not fulfill that location requirement. Add the pipeline note and link it to the relevant contract and rollout documentation.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
| final finishCut = manualFinish && Env.isTestFlight | ||
| ? '$finishSource,${const Uuid().v4()},${DateTime.now().millisecondsSinceEpoch}' | ||
| : null; |
There was a problem hiding this comment.
Include coordinator-driven Finish actions in the cohort
On TestFlight, Home's Wrap Up action calls finishLiveCapture() → finishCaptureWithOutcome() → the coordinator's ProcessConversationStage, whose _processConversationBody() invokes this method without manualFinish: true. Therefore this condition leaves finishCut null for that deliberate Finish, and processInProgressConversationOutcome() sends X-Omi-Finish-Cut: none, explicitly excluding it from the backend denominator. The same omission affects Live Activity Finish actions routed through the coordinator. Propagate deliberate-Finish metadata through that path rather than relying solely on the flag used by the detail End button and pendant double-tap.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba3bb40eda
ℹ️ 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 (next != null && next.isNotEmpty) { | ||
| outbox.flush(onlyOwner: next); | ||
| _armTimer(); |
There was a problem hiding this comment.
Defer owner-change flushing until the durable store is installed
On a cold start with an already-signed-in user, _init() calls AnalyticsManager.bindIdentity() before runApp(), which invokes this flush and loads the default MemoryTelemetryStore. When _MyAppState.initState() subsequently installs the transport, ClientTelemetryOutbox.attachStore() refuses to replace an already-loaded store. Consequently, Finish cuts remain memory-only for that session, previously persisted cuts are not recovered, and terminating the app loses pending observations—including client-only cuts intended to preserve the denominator. Install the file store before identity binding, or defer flushing until transport initialization completes.
Useful? React with 👍 / 👎.
| status_code=403, | ||
| detail={"code": "telemetry_forbidden", "message": "beta app channel required"}, | ||
| ) | ||
| if finish_home_sli.enabled() and conversations_v3_enabled(uid): |
There was a problem hiding this comment.
Offload the blocking v3 eligibility check from telemetry ingest
When the SLI flag is enabled and an eligibility cache misses, such as on a cold worker, conversations_v3_enabled() calls client_seen_cached() and potentially capable_cached(), both of which perform synchronous Redis exists() calls on cache misses. This endpoint is asynchronous, so those reads block the serving event loop; slow Redis can stall unrelated requests and health checks rather than just delaying telemetry. Evaluate eligibility with await run_blocking(db_executor, conversations_v3_enabled, uid) before emitting the observations, following the backend's executor dispatch and Redis pool rules.
AGENTS.md reference: backend/AGENTS.md:L276-L282
Useful? React with 👍 / 👎.
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]>
…wance Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve service.py: keep the PR's async _reconcile_groups (owner cuts, held-Finish routes) beside main's paged unlocked-window helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The readback scored the timestamp of a qualifying Home fetch, so a summary eligible at 20 s but fetched at 90 s scored late, and one never fetched scored unmatched. The notes write paths now emit `eligible` after the commit that leaves a Finish window Home-eligible with a summary: notes settlement, the fast_end_feedback early-shown write and an on-open notes write. Each checks the row its transaction already read against the Home feed's visibility filters, so a Finish costs no extra Firestore reads or writes. The readback scores the first eligibility after the cut and reports the Home fetch separately as validation (fetched, not fetched, fetched without eligibility, eligibility-to-fetch p95). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SCA-4434) (#26344) ## DESIGN: SCA-4434 Lane A. Goal: 95% of deliberate v3 Finishes show a first Home card within 60 s. David approved the extra STT spend at about 23:45Z on 2026-11-25. This revision answers the Owners DESIGN review at 83ea3fe the independent reviews at 9397a50, cc33310, 4b89d6f (SHIP) and 34222fe (SHIP, with one P2 and four P3s fixed here), 3a75ec5 (SHIP; the Owners-required P3-a privacy fix and P3-b to P3-e are in this head), and the Owners and Release design changes on SCA-4434 (02:23Z and 02:25Z on 2026-11-26). **What it reads and writes.** - The fast first transcript (`backend/utils/conversations/v3/fast_finish.py`) reads the same retained audio packs from GCS it reads today. - It writes the same provisional transcript through `update_conversation_segments`, fenced inside its transaction, and then the same manual-end cut. - Nothing new is stored in Firestore. Admission no longer reads the conversation row before the pass; the pass reads it once (one fewer Firestore read per Finish). - **New in Redis:** one counter per UTC day, `v3_fast_finish:long_audio_seconds:<day>` (26 h TTL), for the fleet-wide long-recording budget. Only long passes touch it: one `GET` before a slot is taken, one `INCRBYFLOAT`+`EXPIRE` pipeline to reserve, and one `INCRBYFLOAT` to settle, all on a client with 1 s connect and read timeouts. Cloud Run backend services already get `REDIS_DB_HOST` from `gcp_backend.yml`, and v3 code already uses `database.redis_db`. **One end-to-end deadline: 45 s from record admission** (`PASS_DEADLINE_SECONDS`). That leaves about 15 s of the 60 s first-card budget for the write, the builder and Home. - **Where the clock starts.** Both the 60 s budget and `WALL_SECONDS` start at record admission, when `_manual_finish_admitted` runs (`backend/utils/batch_pipeline/live.py:449`), not at the Finish tap. The time from the tap to admission (upload, seal, admission) is outside both. The production readback below (Finish to first visible card) is measured from the tap and includes it. - **What counts.** Slot wait, every Firestore call (refresh, funding, privacy, the post-chunk refresh, write and cut), every retained-audio reference read, both language probes, chunk queue wait, provider requests and one retry. - **How each part is bounded.** - **Every Firestore call of a chunked pass is bounded** (Owners' blocker; short passes too). The pass runs each call on a small dedicated pool (`fast_finish_io`, 8 workers) and waits only until its bound: the deadline for the row refresh, funding and privacy (the language probe's privacy check included), and `WRITE_GRACE_SECONDS` (1.5 s) past it for the post-chunk refresh, the transcript write and the cut. Past its bound the call is abandoned (cancelled if it has not started; a running one ends on the client's own timeouts), the pass yields `deadline` and the slot is released within the deadline plus 2 s. Reads accept `timeout=`, but `firestore.transactional` commits do not (the installed client's `Transaction._commit` takes no timeout), so abandonment is used uniformly. - **The write is fenced, and the cut never follows an abandoned write.** The default writer's in-transaction guard refuses a transaction body that starts, or reruns after contention, past the bound. It checks the time again after the fence's own reads (34222fe P3), so nothing is written. The pass calls the cut only after the write returned `True` inside its bound. A commit already sent when the pass stops can still land, but only without a cut from this pass. Because the transaction read the conversation document, a cut or lock committed after that read either waits behind the commit or aborts it; on the rerun the guard refuses. Serial kill-switch passes keep today's unbounded calls and the bare fence. - The pass checks the deadline before every reference it reads, including several references inside one chunk. - Each reference's storage metadata and download timeouts are capped to what is left (`read_reference(read_budget=ArtifactReadBudget(deadline, ...))`). The serial kill-switch path keeps today's 30 s and 60 s. - Under `verification_stt_deadline`, a provider request's connect, pool, write and read timeouts share what is left (`budget_timeout`) instead of each taking all of it. - **Language probes are bounded as a whole** (34222fe P2). The vendor probe and the self-hosted gate keep each part of their own timeouts (connect 2 s; read, write and pool 8 s and 6 s), each capped to what is left (`probe_timeout`); with 40 s left the gate keeps 2 s connect and 6 s read. Because those parts add up, and an httpx read timeout is per read, the whole language resolution also runs on `fast_finish_io` and is abandoned at the deadline, so the pass stops as `deadline` and the slot is released within the deadline plus 2 s. A probe with under `PROBE_MIN_SECONDS` (3 s) left is skipped and the row's language is kept; the pass goes on. The time is checked before the privacy read, so an abandoned resolution makes no reads (P3-b), and again after it. An abandoned probe that already passed privacy may still finish in the background; its result is dropped and its audio was charged when it was allowed. - **Chunk send minimum** (P3-e): a chunk's first request is sent only with at least `CHUNK_SEND_MIN_SECONDS` (5 s) left. With less it would almost certainly time out, so it is not paid for and the pass yields `deadline`. The retry keeps its 10 s minimum. - That context also turns off the provider's own retry and Soniox credit failover for these requests. Batch keeps both. - **At the deadline** the pass cancels its queued chunks, waits at most `STOP_GRACE_SECONDS` (2 s) more for running ones, writes nothing, releases its slot and yields to batch with the bounded outcome `deadline`. A request still running then ends on its own timeouts, and its result is dropped. - **An early stop** (`provider_error`, `privacy_blocked`, `audio_error`) sets a stop flag. No running chunk sends another request or retry, and a chunk checks the flag again after its privacy answer, just before it is charged and sent. Queued chunks are cancelled, and the slot is released as soon as the requests already in flight end. **Short and long, against the deadline.** A pass is long only when its audio exceeds 20 minutes (`MAX_SECONDS`), never because of its chunk count. - A short pass keeps 4 chunks in flight, whatever its chunk count. Up to about 19.8 minutes is one round. A 19.9-minute unit (5 chunks) or a six-minute Finish split into six units takes two rounds, still on the short slots. - A long pass keeps 3 in flight and is capped at 9 chunks: three rounds, up to about 44.6 minutes. - A 2-hour recording is 25 chunks, about nine rounds of 3, so it returns `too_long` before any read or spend. **Fairness.** - Length, canary and daily-cap refusals are decided from the units alone, before any slot is taken (`fast_finish.screen`). A Finish they refuse is counted as `too_long`, `long_canary` or `long_cap`, never `busy`, and never holds or waits for a slot. - Short and serial passes share two pass slots. A long pass takes its own single slot. - A short Finish waits up to 10 s, inside its deadline, for a slot instead of answering `busy`. - On the 6-worker `fast_finish_chunk` pool, a long pass's 3 in flight always leave 3 workers for short Finishes. - Memory per process: at most 11 chunk buffers (about 106 MB), plus one per pool worker for a request a stopped pass left running, plus one decoded pack per pass. This is independent of recording length. A cancelled chunk job waiting in the pool's queue now drops its buffer at once (34222fe P3), so queued cancelled jobs hold no audio. The per-chunk privacy check runs on the chunk pool itself, not on `fast_finish_io`. During a Firestore brownout a started chunk can sit in that check holding its buffer until the coordinator's own bound (deadline plus 2 s) releases the slot; the check then ends on the client's timeouts. In that window the bound is soft by at most the six pool workers' buffers. **Privacy at every send.** - Privacy is asked before any audio is read, as before. - It is asked again inside every chunk job just before its provider request and before its retry, so a chunk that waited in the shared pool's queue is asked when it actually starts. - It is asked right before the language probe posts audio to the vendor (Modulate language ID) or the self-hosted classifier (`before_probe` / `before_self_probe`). - A refusal stops the pass. Cancellation stops queued work. A request already dispatched may finish, but its result is never written. The in-transaction fence on the write is unchanged. - **One denial ends the pass** (Owners, SCA-4434 03:36Z; review P3-a; race closed after the afb7e49 review P3-1). The pass's privacy authority is sticky, with the denial held in a `threading.Event` because chunk jobs on several pool threads set and read it. What the code guarantees: when any check refuses or errors, the denial is recorded before that check returns. From then on every later check answers False without asking, including the self-hosted (shadow) gate's, the vendor probe's, every chunk dispatch and every retry. A check whose read was already in flight answers False when it returns, whatever it read. Each chunk reads the denial again immediately before it is charged and sent, alongside `stop`. So no probe of either kind, chunk request or retry starts after a denial is recorded, and the pass ends `privacy_blocked`. The only send it cannot recall is a request that had already started before the denial was recorded; its result is never written. **Firestore per Finish.** - Privacy is one check before the audio plus one per chunk dispatch, per retry and per language probe, instead of one per unit. - That is the same as today for a Finish of 5 minutes or less (2 checks), and 1 to 4 more for longer short Finishes. - A canary long Finish costs 6 to 11 checks plus its two refresh reads (one before the chunks, one before the write), the funding gate and one write. Admission's own extra read of the row is gone, so every Finish reads it once fewer than before. - Each check is one batch-privacy transaction on the owner's privacy document. At about 190 Finishes a day that is an estimated few hundred to about 1,000 extra reads a day, and about 16 extra writes a day (transcript plus cut wake for canary long Finishes). This is far below the 10M/day review line. **Provider audio-seconds per Finish.** - Each Finish costs its own audio, plus 3 s per fixed cut (silence cuts add nothing), plus a resend of any chunk that fails once, plus at most 30 s for a language probe when the language is undeclared. - Up to 20 minutes this is under 1% above today. - The added spend is long Finishes, about 32 a day in the 12 h baseline: - **At the 25% canary:** about 8 a day, about **4 audio-hours a day** at a 30-minute mean. - **At 100%:** about 11 to 16 audio-hours a day, the approved "about 11+". - **Fleet bound:** `CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS=7200` (kept; Owners confirmed 7,200 s) per UTC day **across the fleet**, in the shared Redis counter above, so it survives scaling and restarts. - **Reserve:** a long pass reserves the most it can send: every chunk twice (its one retry) plus one 30 s probe clip, about 3,666 s for a 30-minute Finish. It uses `INCRBYFLOAT`, and the reservation is taken back at once if that went over the cap. Retries therefore can never push the day past the cap (34222fe P3). While passes run, the counter reads high. Against the 7200 s default only one 30-minute pass's reservation fits at a time across the fleet (two would need 7,332 s), and after it settles to about 1,818 s the next one fits. At the 25% canary (about 8 long Finishes a day) a concurrent second long Finish is rare and falls back to batch as `long_cap`; raise the cap if the readback shows that happening. - **Settle:** the reservation is settled down to the audio actually sent (overlaps, retries and the vendor probe included; chunks never sent are refunded). The settle runs in the background on `fast_finish_io`, after the slot is released, and is best effort. - **Under the deadline** (34222fe P3): the reserve is one pipeline round trip on a client with 1 s connect and 1 s read timeouts. A pass reserves only with at least `RESERVE_MIN_SECONDS` (3 s) left, so the reserve ends before the deadline. With less left it refuses as `deadline` and reserves nothing. - **Fails closed:** when Redis errors or takes over 1 s, the long pass is refused as `long_cap`. Two passes racing for the last room may both be refused, but neither can push the day over. - The in-process counter is removed. The percentage is the operative limit; the cap is the hard backstop, and the 24 h report reads both the counter and `audio_seconds_total`. **Provider capacity.** - Per backend-integration process, concurrent prerecorded requests from fast finish rise from at most 2 (one serial request per pass slot) to at most 6, the chunk pool. In prod that pool resolves to `STT_PRERECORDED_MODEL=parakeet,modulate-velma-2`. - Fleet worst case is 6 times the process count. I have no measured hosted Parakeet capacity figure to state, so the stop thresholds below watch its 429/5xx rate and latency. - With one retry per chunk, a pass fails only when a chunk fails twice. At a 2% request failure rate, a 9-chunk pass loses about 0.4% instead of about 17% with no retry. **Canary and stop rules.** - **Exposure.** Long Finishes (over 20 minutes) go through the chunked path for `CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT=25` of owners (salted uid bucket; outside it, `long_canary`), within the daily cap above (past it, `long_cap`). Finishes up to 20 minutes are not gated: their audio is unchanged. - **Stop expansion or roll back** (`LONG_PERCENT=0`) if any of these holds in the first 24 h: - long-path audio (`audio_seconds_total{path="long"}`, which includes the vendor probe clip, the same audio the cap charges) is over 6 h a day; - `deadline` plus `provider_error` is over 30% of long passes; - chunk queue p95 is over 5 s; - `busy` is over 5% of passes; - prerecorded provider 429/5xx on backend-integration is over twice its baseline. - **Kill the whole chunked path** (`CHUNKED=off`) if short-pass `written` share falls below its baseline, or short-pass `provider_error` or `deadline` is over 5%. - **24 h report** after serving: - `sum by (path) (increase(omi_conversations_v3_fast_finish_audio_seconds_total[24h]))`, converted to audio-hours and multiplied by the provider contract rate for the cost, checked against `GET v3_fast_finish:long_audio_seconds:<day>`; - outcomes by label; - wall p95; - chunk queue p95; - provider error rates. - **Expand to 100%** only after a clean report. **Production number that proves it** (same 12 h prod window and query as the baseline, after serving): - Fast-card share of Finishes **at least 95%** (baseline 55/96). - Finish to first visible card, **wall-clock p95 60 s or less**. - Supporting readback: `omi_conversations_v3_fast_finish_wall_seconds` p95 (from record admission, not the tap; every written pass) under 45 s, plus `{outcome}`, `chunks`, `chunk_seconds`, `chunk_queue_seconds` and `audio_seconds_total{path}` (vendor probe included). **Rollback.** - `CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT=0` stops long passes only. - `CONVERSATIONS_V3_FAST_FINISH_CHUNKED=off` on `backend-integration` restores one serial request per unit, the 20-minute cap and today's slot behaviour. - Both are config changes. Provisional segments already written are replaced by the batch record projection as usual. To roll back the code, revert this PR. Failure-Class: none ## What changed and why - **Split.** `chunk_plan` produces chunks of 5 minutes or less. A cut goes in a retained-audio silence of at least 1 s near the even length. Otherwise it falls at the even length with a 3 s overlap. The remaining audio is shared evenly. - **Stitching** (re-review P3.1). At a fixed cut, the earlier chunk owns lines that start before the overlap's middle. **Every** later line that starts before the earlier chunk's last line ended is compared against it (`join`). - Words, which carry their own timing, go by time. - Utterances (Parakeet and Modulate return utterances lasting seconds, with no word timings) go by text (`seam`). Where the head of the later text repeats the end of the earlier text, the repeat is dropped. A clipped word is allowed on either side (the earlier chunk's last, the later chunk's first), and the clipped fragments are dropped too. Otherwise each such line loses the share of its tokens that falls before the earlier chunk's last end. - Parakeet's `[0, 0]` fallback spans its whole chunk instead of being dropped. - **Long versus short by duration, not chunk count** (re-review P2): `pass_class` and the `audio_seconds_total` path label both use more than 20 minutes of audio. - **Screening before any slot** (re-review P3.5): `fast_finish.screen` runs in `live.py` before slot acquisition and again inside the pass. - **Language route once per pass.** `pre_recorded.prerecorded_bytes_route` (kept in `pre_recorded.py`, where its local `batch_language` import already was) now takes `before_probe` / `before_self_probe`. `prerecorded_from_bytes` keeps its behaviour and takes an optional `route`. - **Deadline module** (cc33310 review P3.4): `verification_stt_deadline`, its ContextVar, `budget_timeout` and `probe_timeout` live in the new leaf module `utils/stt/prerecorded_deadline.py`. It imports no other `utils.stt` module, so `pre_recorded`, `batch_language` and `language_gate` import it at top level with no cycle, and `pre_recorded.verification_stt_deadline` is re-exported unchanged. `fast_finish` imports `pre_recorded`, `prerecorded_deadline` and `batch_language.MAX_PROBE_SECONDS` at top level and adds no function-local imports (only `live.py` imports `fast_finish`, lazily, as before). - **Hard wall** (9397a50 P3.4, cc33310 P2): - `budget_timeout` makes the request phases share one budget. This tightens the speaker-tag verifier's `verification_stt_deadline` the same way, since it was the same per-phase issue. - `probe_timeout` caps each part of the vendor probe's and the self-hosted gate's own timeouts to what is left. Under no caller deadline both keep their defaults. - Reads are bounded per reference, and every Firestore call is bounded by abandonment (see DESIGN), with the write fenced in its transaction. - The stopped-pass wait is bounded to the deadline plus 2 s. An early stop blocks further dispatches and retries and returns when the in-flight requests end (cc33310 P3.3). - **No leaked reservation** (cc33310 P3.2): `row['started_at']` is read before `LONG_BUDGET.reserve`, so a row without it returns `error` with nothing reserved. - **Small fixes from the 3a75ec5 review:** the `get_fast_finish_io_executor` docstring now says the pool also runs the language resolution and the background budget settles (P3-c). A chunk job takes its buffer with `holder.pop()` inside `try/except IndexError`, so a holder the stopped pass emptied at that moment reads as abandoned (P3-d). - **Daily cap by audio sent, fleet-wide** (9397a50 P3.3; Owners and Release). It is a shared Redis counter per UTC day that fails closed; the in-process counter is gone. The flag registry, overlay comment, runbook and change note say it is a fleet bound. `AUDIO_SECONDS{path}` includes the vendor probe clip, so the readback and the cap count the same audio. - **Unchanged from the previous revision:** the deadline, slots, window, privacy at dispatch, one retry and the canary. New bounded outcomes are `deadline`, `long_canary` and `long_cap`. Metrics are unlabelled histograms for chunks per pass, chunk seconds, chunk queue seconds and wall seconds, plus an audio-seconds counter labelled `path=short|long`, all in the `cloud_run_gmp_sync.yaml` keep rule. - **Flags.** - `CONVERSATIONS_V3_FAST_FINISH_CHUNKED`: `ops_kill`, declared on prod `backend` and `backend-integration`. - `CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT`: rollout, with a dated ramp to 2026-12-10, declared `25` on prod `backend-integration`. - `CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS`: config, declared `7200`. - All are registered in `config/feature-flags.yaml` and `deployment-setting-classification.json`. `runtime_env.yaml` and the registry are regenerated. - **Multi-unit Finishes (8 units or fewer)** are written in one pass, and the cut is stored only after the whole transcript is written, so no partial window can lock. - **Pipeline-lab stand-in.** With CHUNKED on by default, main's admission stand-in handed the pass a unit with no retained references. The chunked plan was empty, so the pass ended `empty` before any STT call, and `audio_single_recording_finish`, `finish_double_tap` and `finish_single_recording_fast` failed (measured at c7c0042). Now the stand-in gives the unit one lab reference over the recording, which `live.read_reference` reads as silence. `ops.install` scripts the chunked path: `_transcribe_words` answers each chunk with the scripted lines in its window and counts `transcribe_calls`, and `prerecorded_bytes_route` is replaced, so no language probe runs. CHUNKED stays on in the lab, and the serial kill-switch stub is unchanged. Fast-finish segments carry uuid4 ids that summarisation prompts cite. The lab's fake LLM gateway seeds its answers from the prompt, so it now renames random UUIDs in first-seen order before seeding (the rule `determinism.py` already applies to run artifacts). Its answers then repeat, and the repeat comparison is unchanged. Harness only; no production code changed. Known limit: diarization labels are per chunk, so the same provisional `SPEAKER_00` in two chunks may be two different people. Provisional rows claim no speaker number, and the canonical transcript replaces them. ## Overlap with open PRs (for Release ordering) None of #26332, #26335 or #26336 had landed. Separately, main had moved 17 commits and conflicted with this branch in `backend/deploy/cloud_run_gmp_sync.yaml` (main edited the same keep regex), so origin/main at 220610c was merged in, and again at 3e42abf (the same keep-regex conflict, resolved the same way). It was refreshed onto repaired main at afab956 (after #26382) with no conflicts. The conflict was resolved by taking main's rule and keeping this PR's fast-finish chunk-metrics alternative; `runtime_env.yaml` and the registry re-render unchanged. `git merge-tree` of this head with each PR head: - **#26332** (SCA-4489, Finish-to-Home SLI). It overlaps on four files: - **Textual conflicts in `config/feature-flags.yaml` and `backend/docs/feature-flag-registry.md` only.** It inserts `CONVERSATIONS_V3_FINISH_HOME_SLI` right above `CONVERSATIONS_V3_FAST_FINISH`, beside this PR's three new rows. Resolve by keeping both rows, then re-render the registry. - **`backend/utils/batch_pipeline/live.py` merges cleanly.** Its hunk is `@@ -433,13` in `_manual_finish_admitted`: it imports `finish_home_sli` and calls `observe_route(uid, conversation_id, 'batch')` before `single = ...`. This PR changes the same function: the deadline at entry, the bounded `read`, `screen` before slot acquisition, and `row=None` passed to `run`. - **`backend/utils/conversations/v3/fast_finish.py` merges cleanly.** Its hunk is `@@ -353,6` in `_run`: `observe_route(..., 'fast')` after `if written is False: return 'superseded'` and before the cut. This PR rewrites `_run` (bounded calls, fenced write, `_bounded(cut, after)`); the merged call lands in the same place, after the write and before the cut. - **Order:** either PR can go first. If `observe_route` does any I/O, it sits outside this PR's Firestore bounds and should be cheap or bounded. - **#26335** (SCA-3684): `prod.overlay.yaml`, `runtime_env.yaml`, `deployment-setting-classification.json` and the registry merge cleanly. Its overlay hunk `@@ -1919,6` is the closest to this PR's `backend-integration` env block. Re-run `compose_runtime_env.py` and `render_feature_flag_registry.py` after whichever lands second. - **#26336** (SCA-3499): its conflicts are in the registry, the flag file and `backend/charts/batch-pipeline-worker/templates/deployment.yaml`, all against content already on main (its base predates the shared-live retirement and the SCA-3503 retirements), not against this PR's rows. Its overlay hunks (`@@ -972/-1352/-1743/-2131`) do not touch the fast-finish env lines. Same regeneration step. ## Product invariants affected - INV-MEM-4: not affected. The only shared-code changes are: - two lazily built executor getters in `backend/utils/executors.py` (`fast_finish_chunk`, `fast_finish_io`); - a behaviour-preserving `prerecorded_bytes_route` helper inside `utils/stt/pre_recorded.py`; - the deadline context moved into `utils/stt/prerecorded_deadline.py`, with the deadline-shared request and language-probe timeouts. No memory intake, consolidation or promotion path changes. ## How it was verified All commands ran from `backend/` in the lane worktree on `lane/ff-long-multi`, through `omi-heavy run` with bounded timeouts. Layer: hermetic unit tests. There was no live provider call and no deploy. - `bash test.sh tests/unit/test_conversations_v3_fast_finish_chunked.py tests/unit/test_conversations_v3_fast_finish.py`: 112 and 115 passed, 3 of 3 runs. New for the 3a75ec5 review: - **afb7e49f review P3-1 and P3-2**, deterministic with events and a barrier, no sleeps. The denying chunk is held where it raises `_Refused` until the others decide, so the coordinator cannot set `stop` first and hide a missing check: - three chunks dispatched at once. Chunk A's privacy read errors, while chunk B's read, already in flight, answers True only after the denial is recorded. B (and C) send nothing, and the pass ends `privacy_blocked`. This fails without the two new checks, 3 of 3 runs; - three chunks whose first requests all go out (barrier), then all fail. The first retry check errors, and the other chunks' retry reads answer True after the denial. Only the three first requests are ever sent. This replaces the single-chunk retry test and fails with the sticky wrapper removed, 3 of 3 runs (as does the first test); - the reviewer's scratch race test (30 runs), run here as a temporary uncommitted copy, passes 30 of 30 with the fix and fails 17 of 30 without the new checks. - the shadow gate's privacy check **refuses**, and separately **errors**, then every later check would allow. The route asks the shadow gate, the vendor probe, then the gate again. All three answer False, privacy is asked only twice (before the audio and by the shadow gate), and no probe is sent. No chunk is uploaded, no probe audio is charged to `AUDIO_SECONDS` or the fleet budget, and the pass ends `privacy_blocked`. Both cases fail without the fix; - a resolution abandoned at the deadline makes no privacy read when it later reaches the probe; - with under 3 s left the probes are skipped without a privacy read; - a chunk is not sent with under 5 s left (`deadline`); - tests that use a sub-second deadline on purpose set `CHUNK_SEND_MIN_SECONDS` to 0. New for the 34222fe review: - a vendor probe and a self-hosted gate that are slow in every phase. The reviewer's 8 s case is scaled to 0.8 s left: each phase runs to its capped timeout, about 2.4 s in total. The pass returns `deadline` before the deadline plus grace in both cases. Both fail without the outer bound; - with under 3 s left, both probes are skipped after the privacy check, the row's language is kept, the pass goes on and no probe audio is charged; - with the cap set to exactly one reservation (2 × 1,818 + 30 s), a pass that retries every chunk writes and stays within the cap, and a racing reservation during it is refused; - a long pass with under 3 s left returns `deadline` and reserves nothing; - a Redis settle that takes 1 s does not hold the pass (it returns in under 0.8 s), and the settle still lands; - the write guard raises after a fence whose reads outlast the bound; - when the pool is blocked, every cancelled queued chunk job's buffer holder is empty after the pass stops. New for the Owners and Release changes: - through `_manual_finish_admitted` with a 0.6 s deadline (at least 0.5 s for `test_real_clock_budget_ratchet`) and a Firestore row refresh that stalls 5 s: the pass counts `deadline` and both slots are free again within the deadline plus 2 s; - a transcript write whose commit stalls past its bound: the pass returns `deadline` within the deadline plus 2 s and calls no cut. When the stalled transaction body then runs, its guard raises and nothing is written. A write inside its bound runs fence, then write, then cut, in that order; - fleet budget on a shared fakeredis: reserve then settle up (retry and probe), full refund of a pass that sent nothing, over-cap reservations taken back at once, one key per UTC day with a TTL of at most 26 h; - two simulated processes (two budget objects on one Redis): after process A's long pass, process B is refused `long_cap`; - Redis down: `screen`, `run` and `reserve` refuse long passes as `long_cap` (also when only the reserve pipeline fails), and short passes still write; - a chunk whose privacy answer arrives after the pass stopped sends and charges nothing. This test fails without the new stop check; - with 40 s left the gate keeps 2 s connect and 6 s read; with 3 s left every part is at most 3 s; the vendor probe keeps (2, 8, 8, 8) with 40 s left; - `test_conversations_v3_fast_finish.py`: the pass is handed no row and reads its own (live.py's duplicate read removed); an undecodable row read by the pass is `ineligible`. New for the cc33310 review: - through `_manual_finish_admitted` with a 0.6 s deadline (at least 0.5 s for `test_real_clock_budget_ratchet`) and a storage read that stalls until its timeout: the read's timeout is capped to at most 0.6 s, the pass counts `deadline`, and both slots are free again within the deadline plus 2 s (without the read budget it is a 30 s read); - the serial kill-switch path still reads without a budget; - one 300 s chunk over ten packs, each read 0.15 s, with a 0.2 s deadline: at most two references are read; - a slow refresh, funding or privacy call ends the pass as `deadline` with no audio read; - a long row with no `started_at` returns `error` with nothing left reserved; - after an early `provider_error` the chunks still running take no retry and the pass returns in under 1 s (the deadline is 45 s); the same holds after a privacy refusal at one chunk's dispatch; - the self-hosted gate sends nothing once the deadline has passed and is unchanged without a deadline; - `AUDIO_SECONDS{path="long"}` includes the 30 s vendor probe clip. New for the 9397a50 review: - both review seam probes, which fail before this fix: "epsilon zeta" is no longer duplicated, and a clipped "o …" head keeps "store" while dropping "sto"; - words joined by time; - a six-minute 6-unit Finish and a 19.9-minute single unit stay short (window 4, `path=short`) and run while a long pass holds the long slot; - a non-canary or over-cap long Finish is counted `long_canary` or `long_cap` with the long slot busy, never `busy`; - the language probe refused by privacy at send, with nothing charged; - an allowed probe charged at 30 s; - the cap charged with a retry (the sum of all requests sent); - a stopped pass returns in under 1 s while its request runs 1.5 s; - `budget_timeout`, verifier and probe timeouts summing within the deadline. - Related suites: 104 files (adding `test_redis_db_client_factories.py`), After the refresh onto afab956, 150 files passed: the 104 related files (the chat test included, repaired by #26382), the pipeline-lab tests (main's new `finish_privacy_refused_fast_finish` scenario included) and the ratchet. Earlier, on the tree merged at 3e42abf, 103 passed. `test_chat_stream_error_fallback.py` fails on the merged tree with `ImportError: cannot import name 'speaker_evidence_erasure' from 'utils.observability'`. That comes from main's #26311 (`utils/metrics.py` imports the new module while the chat test harness stubs `utils.observability`). Every file in that import chain is identical to origin/main, so it is a main breakage, not this PR's; it passed before the merge. They cover pre-recorded STT, `batch_language`, the language gate and the serving language probe, speaker-tag verification, teaching placement, batch_pipeline_live, executors, runtime env compose/validator, projection pump deploy target, flag budget, background task ratchet and others. `test_empty_capture_recovery.py` was left out: it fails on this host only because the native Opus library is missing. - Pipeline lab at 98c2321, CI's command (`scenario run --jobs 4 --repeat 2 --json --stt replay`), all 13 scenarios with CHUNKED on: 12 passed, and `finish_after_second_close` is its committed strict xfail. 0 nondeterministic and 0 repeat differences. The five scenarios that reach summarisation on fast-finish words (`audio_single_recording_finish`, `finish_after_reconnect_late_transcript`, `finish_double_tap`, `finish_next_opens_before_close`, `finish_single_recording_fast`) each end with B written, with a gist and 1 action item. New test: the fake gateway gives one answer when only random ids in the prompt differ, and a different answer when the words differ. With the renaming disabled, fresh ids gave equal answers 0 of 20 times. The determinism, LLM-proxy and fake-upstream-oracle tests: 36 passed. Earlier, at 729f357: A guard run reached the real STT provider zero times and stopped any call to it. It counted each `_transcribe_words` chunk stub call and each serial `_transcribe` call: - `audio_single_recording_finish`: chunk stub 1, serial 0, real provider 0; `fast_finish` B written; vendor stt 2/2 (1 chunk plus 1 cassette play); - `finish_after_reconnect_late_transcript` and `finish_after_long_reconnect_gap`: chunk stub 1, serial 0, real provider 0; B written; stt 1/1; - `finish_after_second_close`: no fast-finish pass runs (the xfail's product gap: B never gets the Finish), so 0 calls of any kind, stt 0/0; - `finish_double_tap` and `finish_single_recording_fast`: B written, stt 1/1. The two fast-finish suites plus `test_pipeline_lab_scenario.py` and `test_pipeline_lab_stage_reuse.py`: 294 passed. - pyright on the changed modules (`fast_finish`, `live`, `pre_recorded`, `prerecorded_deadline`, `batch_language`, `language_gate`, `executors`): 0 errors. `pre_recorded.py` stays at its 1659-line base. `render_feature_flag_registry.py --check-parsers` passed, and `compose_runtime_env.py` regenerated the runtime env. `scan_async_blockers.py`, `scan_import_time_side_effects.py` and `check_module_stub_pollution.py` all reported 0 violations. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e4725054c
ℹ️ 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 cut_at > now: | ||
| cut_at, basis = now, 'server_cut' | ||
| else: | ||
| basis = 'client_cut' |
There was a problem hiding this comment.
Preserve clock-skew fallback when deduplicating outbox cuts
For a device clock more than 10 minutes behind the server, from_request() correctly substitutes a server_cut, but the independently delivered outbox event accepts the same old timestamp as an exact client_cut here. finish_home_readback.readback() then selects the earliest cut for that operation, overriding the API's clock-skew fallback. For example, a clock 15 minutes behind and a summary ready 20 seconds after Finish produces an exact 920-second latency rather than timing unknown, corrupting both the within-60-second rate and p95. Reconcile the two observations so an explicitly detected skew cannot subsequently become an exact client-clock sample.
Useful? React with 👍 / 👎.
| outbox = outbox ?? | ||
| ClientTelemetryOutbox( | ||
| store: MemoryTelemetryStore(), | ||
| clock: clock ?? DateTime.now, | ||
| newId: newId ?? _defaultId, | ||
| ); |
There was a problem hiding this comment.
Retain Finish cuts after transient upload retries are exhausted
When Finish is tapped offline, this outbox inherits ClientTelemetrySchema.maxAttempts = 5; ClientTelemetryOutbox._flushOwner() consumes those attempts within one flush and permanently removes the observations on exhaustion. With immediate network failures, its four backoffs total at most 30 seconds, so an outage lasting a minute can erase the cut before connectivity returns. If the Finish API also never received the request, that Finish disappears from the denominator entirely instead of remaining unmatched, systematically excluding the failures this dedicated outbox is meant to measure. Give Finish cuts a retry policy that parks exhausted transient uploads for a later flush until their retention deadline rather than deleting them.
Useful? React with 👍 / 👎.
The readback took the earliest eligibility across every card linked to a recording and, separately, the earliest fetch across the same set, so a sibling card on Home could validate an eligible card Home never showed. The eligibility join now carries the winning card, and fetch validation checks that card only. A Finish whose eligible card never reached Home is reported as eligible_card_not_fetched, and other_linked_card_fetched flags the projection mismatch when Home returned a sibling instead. The score still reads eligibility only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the flag registry: keep main's chunked fast-finish flags (#26344) and the CONVERSATIONS_V3_FINISH_HOME_SLI entry; re-render backend/docs/feature-flag-registry.md from config/feature-flags.yaml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve backend/utils/conversations/v3/finish.py against #26440 (SCA-2918 per-owner holdout): finish_live_window takes both named_only and observe_recording, and every _acknowledge call, including main's named_only strict fallback, carries observe_recording. The route's held-out named-only call passes no observer, so it stays unobserved, as on main. Main's holdout contract tests stubbed _acknowledge with four positional arguments; they now accept the observe_recording argument this branch adds. 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: 1a046bcdf9
ℹ️ 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 finish_home_sli.enabled() and conversations_v3_enabled(uid): | ||
| for observation in observations: | ||
| finish_home_sli.observe_client_cut( |
There was a problem hiding this comment.
Exclude legacy-intake Finishes from the v3 cohort
When an owner belongs to conversations-v3-holdout, conversations_v3_enabled(uid) still returns true, but triggers.mark_new() explicitly leaves their new captures on legacy intake (backend/utils/conversations/v3/triggers.py:24–36). Pendant Finish still records a client cut, so this endpoint includes that legacy Finish in the v3 denominator even though it cannot produce the v3 window and eligibility observations required by readback. Successful legacy Finishes therefore become unmatched v3 failures, corrupting the experiment whenever the holdout is populated. Distinguish actual v3 captures from legacy intake when admitting or reconciling cuts, while retaining coverage for existing v3 captures that continue draining for held-out owners.
Useful? React with 👍 / 👎.
| # again. If this cleanup fails too, the partition stays unfinished until resume or undo. | ||
| await run_blocking(db_executor, rederive_store.drop_unwritten_priors, uid, run_id, priors) | ||
| raise | ||
| finish_home_sli.observe_windows(uid, rows, finish_windows) |
There was a problem hiding this comment.
Emit eligibility when reconciliation reveals an existing summary
If a completed manual-end card already has notes while hidden and reconciliation later makes it visible without reprocessing—for example, after enabling CONVERSATIONS_V3_MANUAL_END_HOME_VISIBLE—that commit is its first Home-eligible summary write. The existing branch at service.py:952–960 explicitly handles this transition without another notes write, but the observation added after commit only emits the window mapping. Since eligible is emitted only by the summary persistence and settlement helpers, this successful Finish remains unmatched even if Home subsequently returns its summary. Observe qualifying readiness transitions after the reconciliation commit as well.
Useful? React with 👍 / 👎.
Resolve backend/utils/conversations/v3/service.py: keep this branch's _reconcile_groups helper (Finish SLI held-route observation) and main's size-quarantine helpers from #26441 (SCA-2918) side by side; the two were independent insertions at the same spot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both Finish-cut producers (finish_home_sli.from_request and the durable /v1/telemetry/v3-finish-cuts endpoint) checked stage admission only. Home sends a held-out owner (SCA-2918, v3_intake_held_out) to legacy Home, so such an owner's Finish could add an unmatched miss to the v3 denominator, including through the strict named_only branch, which binds nothing. finish_home_sli.home_cohort now applies Home's rule, in Home's order: conversations_v3_enabled and not v3_intake_held_out (unknown holdout membership fails open, as Home serves that owner v3). Admitted owners' unmatched cuts still count as misses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
home_cohort reads stage admission (Redis on a cache miss) and the intake holdout membership; the async /v1/telemetry/v3-finish-cuts handler now awaits it through run_blocking(db_executor, ...), as the router does for its other blocking reads. from_request stays inline: its only caller, process_in_progress_conversation, is a sync endpoint on FastAPI's threadpool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Takes #25992 (native Finish summary matching, natural deadline scheduling). Conflicts resolved by keeping both sides: - conversation_finalization_jobs: main's capture_allowed() helper (`allowed`) with this branch's completed_manual_end private status. - conversations_v3_processing: main's native notes visibility receipt and clearing join this branch's write-path eligible signal, which now reads the full committed update. - service: main moved plan() into _plan_projection; the Finish window bindings (finish_windows, remember_window) are threaded through it. - planner, live, engine tests: both sides' additions. Interaction fixed: a native Finish manual end (sealed tail, not a recording cut) now carries its recording in _finish_sli_sources, so the SLI still binds its window. #25992's zero-preview provenance test accepts this branch's private completed_manual_end transaction status. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve backend/docs/feature-flag-registry.md by re-rendering it from the auto-merged config/feature-flags.yaml with scripts/render_feature_flag_registry.py: main's CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS row (retry_cap text from #26379) followed by this branch's CONVERSATIONS_V3_FINISH_HOME_SLI row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #26473 (live_words_cascade) and #26431. Conflicts kept both sides: - api/conversations.dart, capture_controller.dart: the End request takes both finishCut (X-Omi-Finish-Cut) and liveTail (live_tail body field). - conversations_v3_processing.settle_processing: the SLI's update dict and eligible_after check keep the cascade's absorbed-landing covers_through. - v3/service.py: import both finish_home_sli and live_tail. 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: 5bbc79ab8d
ℹ️ 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".
| try { | ||
| await outbox.add( | ||
| ClientTelemetryObservation( |
There was a problem hiding this comment.
Serialize cut insertion with other outbox operations
When a Finish occurs during an owner-change or timer-driven flush, this direct outbox.add() bypasses the serialization provided by ClientTelemetryOutbox.schedule(). Both insertion and flushing call _persist(), so they can concurrently write and rename the same finish_home_sli_outbox.json.tmp file; an older snapshot can overwrite the newly persisted cut, while the other rename fails and is silently caught here. There is also a load race: _ensureLoaded() marks itself loaded before awaiting the read, allowing insertion before recovered observations overwrite the owner's queue. Unlike the existing general telemetry caller, enqueue the cut through serialized outbox operations and await its persistence, so an offline Finish cannot disappear from the denominator when the app terminates.
Useful? React with 👍 / 👎.
| measure_finish = not (derive or on_open) and finish_home_sli.enabled() | ||
| held_finishes = set() if measure_finish else None |
There was a problem hiding this comment.
Preserve Finish window mappings during on-open reconciliation
If a user opens the live card after Finish marks its recording but before the background builder reconciles it, conversation_summary_stream() can reconcile that card with on_open=True and then persist its summary. This condition disables the Finish window mapping for that reconciliation, even though store_summary() now emits eligible for the resulting completed manual-end card. The next background reconciliation emits window later, but readback's _first() rejects eligibility observations preceding the mapping timestamp. Consequently, a summary ready within 60 seconds is reported as unmatched or scored only at a later write. Emit the mapping for qualifying on-open commits as well, before their summary can become eligible.
Useful? React with 👍 / 👎.
…inish SLI Two measurement-contract gaps from review on #26332: - A user's Finish through the capture coordinator (live page Finish, Home Wrap Up, record stop, Live Activity) reached forceProcessingCurrentConversation without the deliberate flag, so it never recorded the app-side Finish cut and fell out of the denominator. ProcessConversationStage now carries deliberateFinish from _reduceFinish, and the cut is recorded, as before, ahead of the WAL drain. The pendant handoff's own Process Now stays cut-free. The flag gates only the cut; the manual-Finish Home row keeps its existing triggers. - _manual_finish_admitted returned before naming the route for a native manual stop, so a scored native batch Finish read back as route=unknown. Confirmed native admission now emits route=batch once and returns before the legacy manual-end path. 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: 03433d4577
ℹ️ 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".
| final conversationRevision = _systemSurfaceConversationRevision; | ||
| // The app's deliberate Finish names the live window. Pendant Finish uses | ||
| // the current recording. Capture the cut before awaiting the WAL snapshot. | ||
| final finishSource = liveConversationId == null ? 'pendant' : 'app'; |
There was a problem hiding this comment.
Classify coordinator-driven Finish actions by their actual source
When a user finishes from the phone recording button or Live Activity, liveConversationId is null: battery_info_widget.dart calls finishLiveCapture() without it, and performSystemSurfaceAction() constructs FinishRequested(target: target) without it. Both now propagate deliberateFinish: true, but this expression labels their cuts as pendant. Consequently, ordinary app-driven Finishes contaminate the pendant cohort and disappear from the app cohort in the readback's by_route_source results. Derive the source from the deliberate action metadata rather than whether the request names a live window.
Useful? React with 👍 / 👎.
| // The app's deliberate Finish names the live window. Pendant Finish uses | ||
| // the current recording. Capture the cut before awaiting the WAL snapshot. | ||
| final finishSource = liveConversationId == null ? 'pendant' : 'app'; | ||
| final finishCutAt = DateTime.now(); |
There was a problem hiding this comment.
Capture the Finish timestamp before coordinator teardown
For a Finish during live phone capture, capture_coordinator.dart::_reduceFinish() orders StopPhoneLiveStage before ProcessConversationStage. The former runs _stopPhoneLiveBody(), which awaits cleanup, WAL session finalization, socket shutdown, and preference persistence before execution reaches this timestamp. Those delays are therefore excluded from the purported user-Finish-to-Home latency: a 20-second teardown followed by a summary 45 seconds later is scored as within 60 seconds despite taking 65 seconds from the user's action. Capture and propagate the cut time when the deliberate Finish is requested, before these asynchronous stop operations.
Useful? React with 👍 / 👎.
| await FinishHomeSliTelemetry.instance.recordCut( | ||
| operationId: finishCutId, | ||
| source: finishSource, | ||
| occurredAt: finishCutAt, | ||
| ); |
There was a problem hiding this comment.
Preserve synchronous Finish feedback before awaiting telemetry
On TestFlight, this new await suspends forceProcessingCurrentConversation() before it calls onManualFinishStarted(). However, live_conversation_end_button.dart:165–167 calls this method and immediately checks whether v3.finishRow changed, before awaiting its returned future. That check now always leaves started false, so even a successful End resets its suppression state and skips the navigation to Home's processing result at line 182. Publish the existing synchronous Finish feedback before the telemetry await, while still persisting the cut before the WAL drain, or update the caller to determine whether Finish started after awaiting.
Useful? React with 👍 / 👎.
The Finish cut's source was inferred from whether a live conversation id was passed, so an id-less coordinator Finish (Live Activity, the live page's Finish while the pendant records) was counted as `pendant`. forceProcessingCurrentConversation now takes an explicit FinishCutSource: coordinator Finishes and the live conversation End button are `app`, the pendant double tap is `pendant`; no source means no cut. The wire values (`app`, `pendant`) in X-Omi-Finish-Cut and the durable cut are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
…sh-home-sli # Conflicts: # backend/docs/feature-flag-registry.md # backend/utils/conversations/v3/service.py
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
…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]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
…Finishes, gate SLI to the Home cohort Review fixes (exact-head review of 48882f7): - App: the Finish outbox singleton no longer loads before its file store is installed. AnalyticsManager.bindIdentity runs before the transport install, and its owner-change flush used to pin the outbox to the in-memory default store, so an offline cut was lost on restart. Owner changes before install are remembered and applied (purge, flush) once install attaches the store. - Backend: an already_visible Finish binds its cut to the card it answered with and emits already_visible; the readback scores it ready at the cut (0 s) on its own route instead of an unmatched miss. - Backend: route and window observations are gated on the Home cohort (conversations_v3_enabled and not held out, read off the event loop). A window binding is emitted only by the commit that first ends the card with that Finish recording; held is emitted once per recording per instance instead of on every reconcile pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 627cc35e6f
ℹ️ 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".
| elif observe_recording is not None and outcome == 'already_visible' and window and window.get('id'): | ||
| # The Finish found its window already on Home with notes: the card the answer carries is ready at | ||
| # the cut, so the SLI scores it as a 0 s success instead of an unmatched miss. | ||
| observe_recording(recording_id, visible_card=window['id']) |
There was a problem hiding this comment.
Verify summary readiness before scoring an already-visible Finish
When a user retries Finish on a recently sealed window whose notes failed and no newer live window exists, request_named_finish() can return already_visible: its check in backend/database/conversations_v3_live.py:902–904 requires only status == 'completed' and an unset home_hidden. However, failure_patch() explicitly leaves failed summaries completed with tile_state='failed'. Emitting visible_card unconditionally here makes readback score that failed window as a zero-second success, bypassing the normal eligibility checks even if its summary never succeeds. Verify settled, readable summary readiness before emitting the zero-latency observation; otherwise retain the binding without declaring readiness.
Useful? React with 👍 / 👎.
…Finish request Review fixes (exact-head review of 627cc35): - App: forceProcessingCurrentConversation no longer awaits the Finish cut's telemetry write before publishing the manual Finish row. The End button reads finishRow as soon as the call returns; with the await in front it saw no row, released suppression and skipped the Home return after a successful End. The cut is still timestamped at the tap, its write starts there, errors are logged and swallowed, and the request waits for the write, so the cut is still on disk before the request leaves. Every deliberate Finish entry point (End, live page, Wrap Up, record stop, Live Activity, pendant double tap) goes through this one function. - Readback: every headerless beta request on a recording logs a legacy candidate under the same recording key, and the readback used the earliest one whenever any manual-end proof named the recording. A proof now proves one request: the last candidate logged at or before the recording's first proof (or the first within 5 s after it). Other candidates on that recording, and candidates with no proof, are excluded and reported in legacy_excluded, neither cuts nor misses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
…cut on retry, score already-visible only with a summary Review fixes (Owners and Luna's exact-head review of 0ff2da5): - Legacy attribution no longer guesses by timing. Every headerless candidate carries a random per-request id, and the live-window Finish, which binds only on a deliberate outcome, emits its proof with that id. The readback scores a candidate only where a deliberate Finish is established: its own request carries a proof, or a recording-level proof (a committed manual-end marker, which names no request) follows the recording's only candidate. Several candidates under a recording-level proof are `ambiguous`, and other requests beside a request-tied proof are `not_the_proven_request`. Both are excluded and reported in legacy_excluded, never picked. - Retries keep the original cut. Later proven requests on a recording are counted as `retry`, and the earliest proven cut is scored, whatever the log order. A proven legacy cut never replaces an earlier cut for the same Finish. - already_visible: the Finish path's check (completed, not home_hidden) does not prove that notes exist. The event now records `summary` (completed, readable overview or note section, none of Home's hiding flags). Only a proven summary scores 0 s. Otherwise the Finish goes to already_visible_unproven and is not scored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
…en already-visible Finishes in the denominator - A recording-level manual-end proof no longer scores the recording's sole headerless candidate; such candidates are reported in legacy_excluded.recording_only_proof (replaces "ambiguous"). - An already_visible Finish without a proven summary stays in the cohort on the already_visible_unproven route: a later eligibility of its card or a linked card scores it, otherwise it is a miss. already_visible_unproven remains a diagnostic counter. - Runbook states both rules and the cohort limit for headerless conversation and batch Finishes, whose proofs are emitted asynchronously without a request id. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
Push status
Current head:
f5aa87442dc237a68473b53c1d907ce85b8b40e2, one commit on top of054406c49812bdfc60a129edc9a16b51019e7522that fixes the two FIX FIRST findings from Owners' and Luna's reviews of054406c4. Not rebased or force-pushed. Readback, runbook and comment changes only; no app code (the End-button ordering accepted at0ff2da52is unchanged).Rules at this head
legacy_manual_endproof names that candidate's own request id. A proof that names only the recording never scores a candidate, even the recording's only one. Those candidates are reported inlegacy_excluded.recording_only_proof, which replacesambiguous. Retries keep the earliest proven cut.not_the_proven_request,retryandno_proofare unchanged. Excluded candidates are neither cuts nor misses.totals.finishesand in the p95 rank. Analready_visibleFinish whose event proves a summary scores 0 s on thealready_visibleroute. One without that proof stays in the cohort on thealready_visible_unprovenroute. A latereligibleof the card it answered with, or of another linked card, scores it. Without one within 60 s it is late or unmatched, which means a miss.already_visible_unprovenis still reported, as a diagnostic count of these Finishes. It no longer removes them from the totals.Review fixes in this head
054406c4,_attributescored the recording's only candidate whenever a recording-level proof followed it. That proof may come from a deliberate Finish that logged no candidate of its own, so the candidate it scored could be an unrelated headerless request. Now_attribute(backend/scripts/finish_home_readback.py:256-274) scores only request-tied proofs. Any recording-level proof sends that recording's unproven candidates torecording_only_proof(:151,:273).LEGACY_PROOF_TOLERANCEis removed because timing no longer plays any part in attribution.Emitters and cohort shrinkage. The headerless conversation Finish (in-progress conversation finalization) and the batch Finish emit only recording-level proofs:
complete_server_batch_captureatbackend/database/conversation_finalization_jobs.py:1264andtriggers.changed(manual end) atbackend/utils/conversations/v3/triggers.py:150, called from the batch-pipeline pass atbackend/utils/batch_pipeline/live.py:543. Both run in asynchronous finalization, after the request has returned. To carry the request id there, it would have to be persisted on the finalization job and on the manual-end marker. That is a Firestore schema change, not a small one, so it is not in this PR. As a result, headerless Finishes on the conversation and batch paths are no longer scored.legacy_excluded.recording_only_proofreports how many there are. Headerless live-window Finishes are still scored, because they prove their own request. Headered Finishes on every path are still scored through their operation token. The runbook (backend/docs/runbooks/v3-finish-home-sli.md:11-36) states this limit.054406c4, readback hitcontinueat:178-183before the Finish reachedall_delays, so these Finishes dropped out oftotals.finishesand out of the p95 rank. Now (finish_home_readback.py:181-198, route at:216-219) they stay in the cohort with the answered card linked from the cut.already_visible_unproven(:186) only counts them.Tests (
backend/tests/unit/test_v3_finish_home_sli.py):test_recording_only_proof_after_an_unrelated_sole_candidate_is_not_scored_as_its_finish(:708): an unrelated candidate at 1 s, then a recording-only proof at 30 s.test_already_visible_without_a_proven_summary_stays_in_the_cohort(:895, replaces..._is_reported_not_scored): within 60 s, late, and unmatched cases.test_more_than_five_percent_unproven_already_visible_cannot_pass_the_objective(:922): 94 ready plus 6 unproven givesp95_at_or_below_60s: false.Run against
054406c4's readback, all three fail on their scoring assertions (finishes1≠0, 0≠3, 94≠100). The existing legacy tests now use therecording_only_proofkey, andtest_readback_only_admits_proven_legacy_candidatesnow uses a request-tied proof. Those changes also fail on054406c4, but only on the renamed key.Earlier head (not current):
054406c49812bdfc60a129edc9a16b51019e7522Fixed at that head: legacy-proof attribution by request instead of timing, retries keeping the original cut, and
already_visiblescored only with a proven summary. Its sole-candidate fallback and its exclusion of unproven already-visible Finishes are superseded by the rules above.Review fixes in that head:
0ff2da52,_proven_candidatepicked the last candidate logged at or before the recording's first proof, so an earlier non-Finish candidate at 1 s, a recording proof at 2 s and the real Finish at 3 s scored the 1 s request and excluded the Finish. Now every headerlesslegacy_candidatecarries a random per-request id (backend/utils/conversations/v3/finish_home_sli.py:100), and the live-window Finish, which binds only on a deliberate outcome, emits itslegacy_manual_endwith that same id (observe_legacy_manual_end,:144). The readback (backend/scripts/finish_home_readback.py:140-158,_attributeat:247) scores a candidate only where a deliberate Finish is established: its own request carries a proof, or a recording-level proof (the committed manual-end marker on the conversation and batch paths, which has no request context) follows the recording's only candidate (within the 5 s log-jitter allowance). Several candidates under a recording-level proof were excluded asambiguous(nowrecording_only_proof), and other requests beside a request-tied proof asnot_the_proven_request. Timing never chooses between candidates. Both buckets are reported inlegacy_excludedand are neither cuts nor misses.legacy_excluded.retry; the earliest proven cut is scored, whatever the log order, and a proven legacy cut never replaces an earlier cut for the same Finish key (finish_home_readback.py:155-158). Headered Finishes already kept the earliestcutper finish key.already_visibleprove summary readiness? No, so it is no longer scored without proof.request_named_finish(backend/database/conversations_v3_live.py:902-904) returnsalready_visiblefor a window that iscompletedand nothome_hidden, which does not prove readable notes or rule out Home's other hiding flags._acknowledge(backend/utils/conversations/v3/finish.py:136-141) now passesvisible_summary=finish_home_sli.visible_summary(window)(finish_home_sli.py:304: completed, an overview or rendered note section viasummary_delivery.present, none of Home's hiding flags; shared withhome_ready). The event recordssummary, and the readback (finish_home_readback.py:176-183) scores 0 s only whensummaryis true; otherwise, including events from emitters that predate the field, the Finish goes to the reported, non-scoredalready_visible_unprovencount.Tests (
backend/tests/unit/test_v3_finish_home_sli.py):test_intervening_earlier_candidate_never_takes_the_finish_requests_proof(the 1 s / 2 s / 3 s case),test_out_of_order_recording_proof_between_candidates_is_ambiguous,test_retry_never_moves_the_cut_forward(retry proof logged before the original's; old rule scored the retry's 57 s instead of the original's late 62 s),test_retry_logged_before_the_original_keeps_the_original_cut,test_emitted_proof_carries_its_own_requests_id(real emitters),test_already_visible_without_a_proven_summary_is_reported_not_scored,test_visible_summary_requires_notes_on_a_shown_card(8 cases),test_a_proof_for_another_recording_does_not_prove_this_request, andtest_recording_level_proof_*(three tests replacing the two timing-rule tests from0ff2da52). Run against0ff2da52's readback and emitters, 14 of these 15 test cases fail. The intervening, out-of-order, retry-ordering and already-visible cases fail on their scoring assertions.test_retry_logged_before_the_original_keeps_the_original_cutfails there only on the newretrybucket, and the other-recording test passes there. The existing already-visible tests now bind withvisible_summary=True, andtest_already_visible_finish_binds_the_card_it_answered_with(backend/tests/unit/test_episodes_finalize_paths.py) assertsvisible_summary: Truefor a completed card with notes. The runbook documents both rules.Earlier head (not current):
0ff2da52df92b93a7cd10ac9a12c17c836242feeReview fixes in that head (item 2's timing rule is superseded by the request-tied rule above):
627cc35e,forceProcessingCurrentConversationawaited the Finish cut's telemetry write beforeonManualFinishStarted. The End button (app/lib/pages/conversations/widgets/live_conversation_end_button.dart:166-168) readsfinishRowas soon as the call returns, so it saw no row, released its suppression and skippedHomeNavigation.returnHomeafter a successful End. Now (app/lib/services/capture/capture_controller.dart:4463-4475) the cut is still timestamped at the tap and its write starts there, but it is not awaited before the manual Finish row is published; errors are logged and swallowed. The write is joined after the WAL snapshot and before the request is sent (capture_controller.dart:4498), so the cut is on disk before the request leaves. The row, the placeholder andonLiveFinalizedpublish synchronously at the tap again, as onorigin/main. Every deliberate Finish (End, live page, Home Wrap Up, record stop, Live Activity, pendant double tap) goes through this one function, so they all get the same fix. Regression test (app/test/providers/force_processing_placeholder_test.dart):End publishes the manual Finish row before the cut write completes; the request waits for itholds the telemetry store's write open, checks that the manual Finish row is published synchronously by the call, checks that no request is sent while the write is pending, then releases it and checks that exactly one request and one cut follow. The test fails on627cc35e's controller (Expected: not null, Actual: <null>, "the row is published synchronously at the tap") and passes now. The End button's Home return after a successful End is covered byhome_v3_test(End from a deep link selects Home after the drain), given a capture that publishes the row synchronously, which the new test now pins for the real controller. The existing testa coordinator Finish records exactly one Finish cut before its request leaves(renamed from "... before the WAL drain") now asserts the cut is recorded before the request leaves, not before the drain starts.legacy_candidateunder the same recording key (backend/utils/conversations/v3/finish_home_sli.py:86-99). The readback took the earliest such candidate whenever anylegacy_manual_endproof named the recording. Now (backend/scripts/finish_home_readback.py:137-153,_proven_candidateat:231) a proof proves one request: the last candidate logged at or before the recording's first proof, or, failing that, the first one withinLEGACY_PROOF_TOLERANCE(5 s) after it. On the live-window path, the Finish request logs its candidate and its proof in the same call. On the conversation path, the proof is logged after the finalization commit, which follows the request's bind. Other candidates on that recording, and every candidate on a recording with no proof, are excluded and reported inlegacy_excluded(not_the_proven_request,no_proof). They are neither cuts nor misses. Readback-only change: the emitters are unchanged, because the conversation path's proof comes from the finalization commit, which has no request context, so the request can only be identified by log order. Tests (backend/tests/unit/test_v3_finish_home_sli.py):test_legacy_proof_cuts_at_the_finish_request_not_an_earlier_request_on_the_recording,test_legacy_proof_committed_after_the_finish_proves_that_request_not_a_later_one,test_legacy_candidate_without_proof_is_excluded_and_reported_not_a_miss,test_emitted_legacy_events_read_back_as_the_proven_finish_request(real emitters), andtest_readback_only_admits_proven_legacy_candidates(now also assertslegacy_excluded). All five fail against627cc35e's readback. The runbook documents the rule.Earlier head (not current):
627cc35e6f5b94146d8dbe217a11f6efaab7c3e1Review fixes in that head:
AnalyticsManager.bindIdentity(app/lib/main.dart:423) runs beforeinstallFinishHomeSliTelemetryTransport(app/lib/main.dart:607). Its owner-change flush loaded the singleton outbox on the default in-memory store, andattachStorethen refused the file store, so a cut recorded offline was lost on restart. NowFinishHomeSliTelemetry.instanceis built withdeferUntilInstalled: true. Beforeinstall()runs,onOwnerChangedonly records the owners to purge and never loads the outbox.install()(app/lib/services/telemetry/finish_home_sli_telemetry.dart) attaches the file store, the token and the post, applies the pending purges, and then flushes. The transport callsinstall(). Regression tests (app/test/services/telemetry/finish_home_sli_telemetry_test.dart):a cut recorded offline survives a restart and is delivered after itbinds identity before install, records an offline cut, simulates a restart in which identity binds before install again, and asserts the cut is delivered.an owner change before install purges the previous owner once the store is attachedcovers the deferred purge. With the deferral disabled, both tests fail: the file is empty.The
recordCut/outbox.tmprace is not fixed by this change.recordCutstill callsoutbox.addoutside the outbox's serial schedule. It is listed under follow-ups._acknowledge(backend/utils/conversations/v3/finish.py) now calls the observer withvisible_cardonalready_visible.Finish.bind(backend/utils/conversations/v3/finish_home_sli.py) emits analready_visibleevent with the finish key and the card key. The readback (backend/scripts/finish_home_readback.py) scores that Finish as ready at its cut (0 s) on its ownalready_visibleroute and validates the Home fetch against that card. Tests:test_already_visible_finish_is_ready_at_its_cut_not_a_miss,test_already_visible_bind_emits_a_scoreable_event(real emitters exported and read back),test_legacy_already_visible_finish_is_scored_once_proven,test_acknowledge_binds_already_visible_with_its_card(backend/tests/unit/test_v3_finish_home_sli.py), and the route-leveltest_already_visible_finish_binds_the_card_it_answered_with(backend/tests/unit/test_episodes_finalize_paths.py).finish_home_sli.measuredandmeasured_asyncapply the kill switch and thenhome_cohort(uid);measured_asyncruns the cohort read throughrun_blocking(db_executor, ...). They gate the reconcile window and held observations (_reconcile_groupsinbackend/utils/conversations/v3/service.py), the fast route (fast_finish._run, which runs on a worker thread and reads synchronously) and the batch route (batch_pipeline/live._manual_finish_admitted, which runs off the loop).remember_windownow takes the storedpriorrow andwas_ended, and it skips recordings that the stored card already held as an ended manual-end card. A window binding is therefore emitted by the commit that first ends the card with that Finish recording, not again on later passes. On-open passes now measure too, so a card first committed by an on-open pass is still bound once. Backfill and re-derive passes still do not measure.heldis emitted once per held recording per instance (observe_held, a bounded TTL set). A repeat from another instance cannot change a score, because the readback reads route signals as a set. Tests:test_reconcile_measures_only_home_cohort_owners_and_holds_once,test_held_route_repeats_only_after_its_window,test_window_binding_is_remembered_only_when_new_in_the_commit(5 cases),test_repeated_reconcile_commits_emit_one_window_eventandtest_route_observations_are_limited_to_the_home_cohort.The runbook (
backend/docs/runbooks/v3-finish-home-sli.md) documents thealready_visibleroute and the cohort gating and once-only emission.Follow-ups (not in this PR)
These are the other P2 findings from the capped review. This PR does not address them:
server_cut).recordCut/outbox.tmprace:recordCutwrites throughoutbox.addoutside the outbox's serial schedule, so it can race a scheduled persist on the shared.tmpfile. Fix Client #1 does not change this.Earlier head (not current):
48882f73597d09a2fa674b7f7f990ec0e09929d948882f73597d09a2fa674b7f7f990ec0e09929d9was a merge commit oforigin/mainatba1c952f4ea43c49a5132a6c8bf3c2d192396e81into this branch (previous head936055332770fc408d192b4f4d926555918a3784). That main includes #26419 (92e192d8, Finish newer capture). Not rebased or force-pushed.How the two PRs combine:
backend/utils/conversations/v3/finish.py: every live-window path passesobserve_recordingto_acknowledgealong with SCA-4434: v3 Finish cuts a capture that sealed after the live window's tail #26419'scapture or windowanswer andnewer_capture = finish_newer_capture_enabled() and not named_only. The SLI binds before thenewer_/dual_prefix is stripped (deliberate_finishstrips it too). It binds the recording the answer names: the newer capture onnewer_*; the window tail onnewer_dual_*,tailand a declined newer capture. The ride-along capture request innewer_dualis not bound.v3_finish_requestedstamp (server time, written once on the response target, feedingomi_conversations_v3_finish_to_visible_seconds) is unchanged. This PR writes no Firestore stamp. Itscut_atis the client's pre-drain cut (or server receipt for untagged requests) and appears only in the restricted SLI log. The SLI binds the same recording that carries the stamp, so both measurements describe one target without double-stamping.backend/database/conversations_v3_processing.py(settle_processing): the settle transaction keeps both the SLIeligiblelist and SCA-4434: v3 Finish cuts a capture that sealed after the live window's tail #26419'sfinish_latencysample. Each is reset on every transaction attempt and emitted only after commit.backend/routers/conversations.py(get_conversations): main's wall-budgeted Home read movedv3_homeintoread_page.v3_home_readrecords it there. The beta Home-summary validation now runs on the final projected page, which may be a truncated prefix.config/feature-flags.yamlandbackend/docs/feature-flag-registry.md:CONVERSATIONS_V3_FINISH_HOME_SLIandCONVERSATIONS_V3_FINISH_NEWER_CAPTUREeach keep their own row.test_live_window_finish_binds_the_sli_to_its_stamped_response_targetcovers thetail,newer,newer_dualand declined paths.Earlier head (not current): the correction was published at
ba3bb40eda6e52ffa8f1a708451b070e5941004d, and the original correction commitsea04e49cf7andfae78fdd51remain in the branch history. At that earlier head, the pre-push typecheck had 0 errors (origin/main81ffc850a3). Atfae78fdd51, Pyright hit its complexity limit inbackend/utils/conversations/v3/service.py, and extracting the SLI bookkeeping fixed it. Live TestFlight Home validation and the mature 24-hour production readback remain pending.DESIGN
SCA-4489 measures deliberate v3 TestFlight Finishes for SCA-4434.
appandpendantsources. A client cut that never binds to a Finish API request remains unmatched in the denominator.unknownand their timing basis is server receipt.fast_end_feedbackearly-shown write and an on-open notes write emiteligibleafter commit. Fast-finish and batch admission only write transcripts; their summaries become eligible through the same notes writes. Hidden (including below the word minimum), discarded, merged, locked or note-less cards never emit it and count as a miss./v1/conversationsHome response (after ownership, acknowledged-episode projection and redaction) logssummaryfor the same qualifying cards as validation only. The readback reports it separately (home_fetch_validation); when the app fetches Home never changes the score. Validate it against a live TestFlight Home response before starting the production cohort.Implementation
The client cut is taken at the tap, stored before the Finish request leaves, and retried independently if the Finish call is offline. The server binds tagged cuts to recording/window/route events; older untagged requests require committed manual-end proof. Eligibility events are emitted after the notes writes commit; Home-response summary events are kept as reader validation. The runbook includes live-reader validation and the read-only production query.
Product invariants affected
UI-Evidence: none -- instrumentation only.
Failure-Class: none
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 5149 -> 5178 | Records the deliberate cut at the tap without delaying the Finish row, for the double tap and the coordinator's Finish, joins its write before the request, and forwards its token beside the End time.
Line-Count-Exception: app/lib/services/capture/capture_coordinator.dart | 3261 -> 3265 | The Finish stage carries the user's deliberate intent to the SLI cut.
Line-Count-Exception: app/lib/utils/analytics/analytics_manager.dart | 3168 -> 3170 | Purges the dedicated telemetry outbox when account ownership changes.
Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 3765 -> 3770 | Emits legacy manual-end proof only after the transaction commits.
Line-Count-Exception: app/lib/backend/http/api/conversations.dart | 1787 -> 1791 | The existing Finish request owns header serialization, merged with the End-time header.
Line-Count-Exception: backend/routers/conversations.py | 3504 -> 3534 | Observes summary availability after the actual Home projection and binds an already visible Finish to the card it answered with.
Line-Count-Exception: backend/utils/conversations/v3/service.py | 2117 -> 2176 | Keeps route/window joins (cohort-gated, emitted once per new binding) and extracts SLI bookkeeping so the enforced typecheck can analyze reconcile.
Verification
At head
f5aa87442dc237a68473b53c1d907ce85b8b40e2(current):omi-heavy run -- bash test.sh:test_v3_finish_home_sli80,test_episodes_finalize_paths186,test_client_telemetry25,test_server_batch_completion63,test_conversations_v3_contract125 andtest_conversations_v3_finish_late_predecessor33 (the last two cover the comment-only touch tofinish.py). 512 passed, 0 failed. No app code changed, so Flutter was not rerun.054406c4's readback (shown above).At head
054406c49812bdfc60a129edc9a16b51019e7522(earlier head, not current):omi-heavy run -- bash test.sh:test_v3_finish_home_sli79,test_episodes_finalize_paths186,test_client_telemetry25,test_server_batch_completion63. 353 passed, 0 failed. No app code changed, so Flutter tests were not rerun.0ff2da52df92b93a7cd10ac9a12c17c836242fee's readback and emitters: 14 of 15 failed (details above).Earlier head (not current):
0ff2da52df92b93a7cd10ac9a12c17c836242feetest_v3_finish_home_sli63 (4 new),test_client_telemetry25,test_episodes_finalize_paths186,test_conversations_v3_engine99,test_conversations_v3_contract125,test_conversations_v3_created_delivery66,test_conversations_v3_fast_finish115,test_conversations_v3_fast_finish_chunked128,test_conversations_v3_finish_late_predecessor33,test_server_batch_completion63,test_demand_surface_http10. 913 passed, 0 failed.flutter test -j "$OMI_HEAVY_CPUS":force_processing_placeholder_test,finish_cut_source_test,capture_one_source_test,finish_home_sli_telemetry_test,home_v3_test,process_now_conversations_tab_testandfinish_opens_conversation_test: 147 passed. All oftest/services/captureandtest/providers: 1961 passed.Earlier head (not current):
627cc35e6f5b94146d8dbe217a11f6efaab7c3e1test_v3_finish_home_sli(59, of which 13 are new),test_episodes_finalize_paths(1 new),test_conversations_v3_contract,test_conversations_v3_engine,test_client_telemetry(telemetry contract),test_server_batch_completion,test_conversations_v3_created_delivery,test_conversations_v3_fast_finish,test_conversations_v3_fast_finish_chunked,test_conversations_v3_finish_late_predecessor,test_batch_pipeline_live,test_conversations_v3_commit_readback,test_monitoring_telemetry_contract,test_demand_surface_httpandtest_reliability_experiment_end_open_conversation. Underpytest -n, these files hit a test-collection mismatch between workers. That mismatch already exists at48882f73, so this run used a single process.flutter test -j "$OMI_HEAVY_CPUS":finish_home_sli_telemetry_test(3, including the 2 new cold-start tests),client_telemetry_outbox_test,finish_cut_source_test,capture_one_source_test,force_processing_placeholder_test,home_v3_testandprocess_now_conversations_tab_test. 121 passed. With the deferral disabled, both new cold-start tests fail (the outbox file is empty).Earlier head (not current):
48882f73597d09a2fa674b7f7f990ec0e09929d9bash test.sh: 19 files, 1434 passed, 0 failed. Counts per file: test_conversations_v3_engine 99, test_conversations_v3_fast_finish 115, test_conversations_v3_contract 125, test_conversations_v3_live_capture 24, test_episodes_finalize_paths 185, test_conversations_v3_live_passes 59, test_monitoring_telemetry_contract 58, test_conversations_v3_live_rederive 134, test_v3_finish_home_sli 46, test_client_telemetry 25, test_conversations_v3_created_delivery 66, test_demand_surface_http 10, test_server_batch_completion 63, test_flag_budget 26, test_runtime_image_contracts 107, test_omi_flags 84, test_flag_docket_retirement 128, test_pipeline_lab_scenario 51, test_route_policy_inventory 29.flutter test -j "$OMI_HEAVY_CPUS": finish_cut_source_test, finish_home_sli_telemetry_test, capture_one_source_test, force_processing_placeholder_test, home_v3_test and process_now_conversations_tab_test. 105 passed.Earlier head (not current):
client_telemetry_outbox.dart.🤖 Generated with Claude Code