Repository navigation
fix(episodes): stop live captures blocking closed summaries - #25481
Git-on-my-level merged 5 commits into
Conversation
Fence post-gap live membership and repair existing closed owners on normal compose. Preserve audio custody and finish/privacy guards. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ed947516d
ℹ️ 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".
| rows: list[dict[str, Any]] = episode_timeline.recorded_candidates( | ||
| uid, start, start, firestore_client=client, transaction=transaction | ||
| ) |
There was a problem hiding this comment.
Query the full proposed live window before checking overlaps
During lazy repair, a still-open capture can have committed audio extending beyond a later closed episode while no current live episode exists. Passing start as both bounds means recorded_candidates() only fetches episode starts through start + 30 minutes, but the resulting live window later extends to server_batch_audio_end. For example, a capture spanning 01:05–03:00 misses a closed episode starting at 02:00, so the overlap loop cannot see it and the transaction commits overlapping windows. Query through the proposed window end and fence or clip against any following episode before committing.
Useful? React with 👍 / 👎.
| 'conversation_ids': list(dict.fromkeys([*(target.get('conversation_ids') or []), cid])), | ||
| 'member_activity': {**(target.get('member_activity') or {}), cid: activity}, |
There was a problem hiding this comment.
Add joined live members to an existing recorded fact map
When the live target was resumed from an automatic recorded episode, resume_recorded() preserves its recorded_members map. This join adds cid to conversation_ids without adding its corresponding fact, unlike the previous _attach_recorded_window() path. If the episode subsequently idle/gap-closes while the capture remains open, the next connected sync attachment rebuilds membership solely from recorded_members in episode_recorded_components.attach(), overwriting the episode without this capture while its reverse link still points there. Keep the canonical fact map synchronized with membership on this path.
Useful? React with 👍 / 👎.
Require corroborated bounded clocks in the membership transaction and retain uncertain members while finished-subset summaries compose. Record closed-label clock refusal reasons. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep all three clocks mandatory for ownership moves while admitting an unowned first-frame capture from corroborated trusted stored clocks. Preserve recovery classification, clean rotated episodes, schedule compose after commit, and respect recorded-time rollback. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use stored admission row clocks for unowned captures and preserve strict corroboration for rehomes. Keep both real admission paths covered by the unchanged main regression. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Share the existing batch-first admission selector without added trust or future refusals. Keep strict three-clock validation exclusive to rehome and cover accepted admission parity cases. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
* feat(app): recordings and conversations (v3) capability and wire client Reads the per-account switch and the conversation in progress from GET /v1/conversations/live, and adds the audio-manifest and summary-stream clients. A v3 account makes no episode or Home-feed calls: both providers take a suppression hook, so the server episode-call counter that gates deleting the old code only counts released builds. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(app): v3 Home and conversation page For an account on recordings and conversations (v3): - Home is one flat list of conversations under day labels. The conversation in progress is the top row, from the live read. - A row tile shows where the conversation is: the breathing dot while it is going, a spinner while its transcript arrives, a pen while its summary is written, then the emoji. - A finished day label carries a chevron and opens that day summary; Today has none. - Opening a conversation in progress writes its summary and streams it in, with a pen and "Writing your summary…" over a skeleton; another writer falls back to re-reading every 2 s for up to 60 s. Accounts not on v3 see today Home unchanged (tested). Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(app): v3 Home render evidence; live row counts from its start The live row length reads the app clock, the live summary section takes a test stream, and the Home v3 test renders Home, the writing state and the streamed summary. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat: add recording-derived conversation wire contracts Failure-Class: none * feat: derive conversations from per-owner pendant recordings Failure-Class: none * fix: preserve recording audio owners through playback and merge retries Failure-Class: none * fix: keep v3 scheduling off the event loop and retain deletion access Failure-Class: none * fix(app): v3 review round 1 (DeepSeek + Luna) - The switch has an unknown state: until its first answer the app makes no episode or Home-feed read, so a v3 account never makes one; a first-answer server error runs today Home. Both answers are remembered per account. - The feed and episode providers re-check the switch on every read and drop cached episodes when it turns on; wrap-up, dismiss and open are gated. - Capture events refresh the list on a stable key (ids, statuses, steps), at most every 10 s; object identities caused a refresh loop. - The live row leads its day, honours the delete tombstone and home_hidden, cannot be selected for merge or bulk delete, and counts from created_at when started_at is missing. Recordings delivered by the socket never show. - The live poll skips ticks while a page covers Home; one read in flight per account switch. - The live summary keeps its streamed sections when the follow-up read fails, and polls one read at a time. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: suppress recording intelligence across finalizer replays Failure-Class: none * fix(app): v3 review round 1, tests lane - Tile states, the live row and the on-open summary apply only to an account on v3: an account rolled back keeps today Home whatever old documents say. - Day header: 44 pt tap target and the recap recovery action failure copy. - The tile pen reads "Writing your summary…". - Tests: polling window asserts its exact read count, unwatch stops the poll, failure copy is asserted, v3-off Home asserts the live episode row; light theme evidence. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): v3 review round 1, summary lane (Luna) - A summary that arrives whole in the done frame stays up when the follow-up read fails. - Polling has a wall-clock 60 s deadline, each read bounded by the time left; running out with nothing stored offers Try Again. - The stored summary no longer flashes for a frame beside the writing state. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: validate v3 ownership and declare serving query contracts Failure-Class: none * test: cover released capture polls and finish writer type fences Failure-Class: none * test: verify cursor visibility before renewing query review digest Failure-Class: none * test(app): format the v3 decoder test; the wire decoder owns malformed pieces Sol's generated wire decoder rejects a recording piece missing a required field, so the round-trip test no longer feeds one through the whole conversation; the piece reader's own drop is tested directly. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations): clip v3 playback to claimed windows Failure-Class: audio-window-isolation * fix(conversations): preserve exact audio for backup consumers Failure-Class: none * fix(conversations): close v3 writer, backlog and reader gaps Failure-Class: none * test(conversations): record review regressions and verification Failure-Class: none * fix(conversations): preserve title locks across upstream cleanup Relocate additive declarations so newer owner changes integrate without replacing their code. Cover the post-cleanup title fence and align the outside-query witness with cached admission. Failure-Class: none * fix(config): classify shared conversation rollout settings Declare stage and first capable build as public runtime configuration and pin their regular environment bindings across all Cloud Run services. Failure-Class: none * feat(app): a failed v3 conversation shows a warning tile, never its emoji Quality review: tile_state had no failed value, so a conversation whose transcription or summary failed read as finished on v3 Home. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(conversations): pin final review test selection and scope evidence Record the 651-test component run, scope limitations and repository verification repairs. Freeze the worktree for the required full preflight. Failure-Class: none * fix(app): an unreadable live row never leaves the v3 switch unanswered The compact live row from conversations/live omits finished_at, which the generated decoder requires, so the whole read failed. On a first launch that left the switch unresolved and held back both Homes. The switch now resolves from the v3 flag alone; an unreadable row is no live row. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations): honor manual intent and show failures and recognition uncertainty Failure-Class: none * test(conversations): separate v3 writer declarations from concurrent additions Failure-Class: none * fix(conversations): retain window mapping type when closing failed transcription Failure-Class: none * fix(conversations): offload async failure helpers through managed executor Failure-Class: none * test(app): a failed v3 conversation decodes through the generated wire type Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations): close final playback paging and lease integration gaps Failure-Class: none * fix(conversations): retain bounded personal context in v3 notes and outlines Reuse the composer context pack in one-shot notes, bound outline context, and version effective outline inputs. Keep context-only changes outside summary rewrite scheduling. Failure-Class: none * docs(conversations): record round-four context verification Record exact test commands, corrected rerun counts, frozen preflight receipt, token bounds and optional participant-linking boundary. Failure-Class: none * fix(conversations): pin v3 notes prompt and conversation fields against main's guards Main added the notes prompt-digest pin and the exact Conversation field pin after the v3 branch point. notes-6 covers the v3 notes path (all behind v3_models.active()); notes-5 stays reusable because non-v3 output is unchanged. The v3 fields are server-written by the builder, not projection-family. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(app): v3 Home render evidence includes the failed tile Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations): classify readers main added since the v3 branch point Episode live members (#25481), listen batch reconnect (#25466), notes quality repair (#25462), batch retention and enrichment custody each read conversations by id. Classify them for the v3 reader audit: capture, retention and custody own the recording layer; the episode and notes-repair writers are storage that never targets a recording. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(app): v3 decoders to schema, summary stream to a service The API-result boundary allows no null-swallowing or catch in backend/http/api/. The v3 wire types and their decoders move to backend/schema/conversation_v3_wire.dart (re-exported by the API file), and the summary stream consumer, which maps a 409 to SummaryInProgress, moves to services/conversation_summary_stream.dart. No behaviour change. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(app): purpose headers on the new v3 app files Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(app): emoji tile uses the shared OmiType scale Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(app): regenerate the perf production shell for the v3 provider Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore: regenerate client type method counts after merging main Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: align export and action-item tests with the v3 readers Data export deliberately includes recordings (include_recordings=True), and the conversation action-items route reads through read_product_conversation, which the stubbed-import test must call through. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: drop review-panel scoping briefs from the v3 evidence They were the prompts for the per-round scoping panels, not evidence; the per-round evidence and test inventories stay. Keeps the PR under the compare API's 300-file window the UI approval guard reads. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): address review — drop audio manifest, chat SSE newlines, dedupe, live close refresh - Remove the unused /v1/conversations/{id}/audio-manifest route and its models: it returned whole pieces without subtracting deleted spans. Playback and export use the window-exact conversation_audio artifact from /urls. - Summary stream sections travel in the chat SSE framing (newlines as __CRLF__), which the app's chat stream decoder turns back into newlines. - Outline dedupe drops only the same speech captured by another recording at an overlapping time; a sentence repeated within one recording is kept. - v3 Home re-reads the conversation list when the conversation in progress closes, so it appears as an ordinary row without waiting for a processing change. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): hydrated transcript, merged legacy audio, settled partials, redirect host - Projection reads the hydrated recording transcript (manual speaker corrections and the recurring-voice privacy filter applied); the strict decode only proves it is readable. - Playback resolves audio a merge copied from a legacy conversation (no recording alias) to the merged conversation's own file, so it stays in the window-exact artifact. - A partial-recording marker counts as pending transcription only until its newest planned generation is applied; a settled recording no longer pins its windows in "transcribing". - The v3 audio download redirects only to a Cloud Storage https signed URL. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): green the full backend suite and gauntlet; stay under 300 files - v3 markers count only when literally True (policy.flag): a truthy stand-in no longer sends non-v3 conversations down the recording or v3 paths. - v3 model module loads LangChain providers on first use, so importing process_conversation does not pull in every chat-model provider. - /summary/stream is exempt from gzip like the other streaming routes. - Deploy: the v3 stage, first build and task queue are declared on every product host and mapped to staging-conversations-v3 in staging; pusher/listen charts bind them; the v3 sweeper is not declared in dev, whose data plane is production Firestore. - Test fakes accept the new allow_recording / include_recordings / v3_enabled arguments, the listen-pusher harness forwards lookup options, and inventories/baselines list the new readers and context loads with their reasons. - Review-round test logs move out of the repository; the four change notes merge into one; Conflict lives in the v3 package; two small test files fold into their siblings; the four render frames are one composite image. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(flags): re-render registry for the v3 chart bindings Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): track the composite render evidence; classify the v3 task queue binding Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): strongest protection, custom-STT provenance, rewrite coverage, backfill batches - A derived conversation keeps the strongest protection of any contributing recording and never drops below its own (enhanced speech is never stored as standard). - uses_custom_stt follows any contributing custom-STT recording, so the paid-postprocessing guard still applies to the copy. - A late-speech rewrite clears summary_covers_through, so the covered-summary guard cannot return the old notes and spend the only automatic rewrite. - Multi-batch backfill: its own recording/structured conversion is not a race, and converted donors keep a durable pending obligation until the final batch lands. - The pusher canary test expects the v3 config-map references; the v3 gateway feature map lives in the gateway config loader (its only reader), keeping the PR under GitHub's 300-file compare. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(conversations-v3): null recording pieces stay legacy; keep repeats; re-arm on late audio - has_recording_pieces: the Conversation model defaults recording_pieces to None, so ordinary rows written through it carry the key; only a list (even empty) selects v3 playback, in /urls, the artifact task and builder, and plugin backup. - Late merges into a finished copy drop same-text lines only when they overlap the stored line in time; a repeated sentence a few seconds later is kept. - update_conversation re-arms the v3 builder when audio_files land on a settled recording (sync finalize, merges, projection repair), so the conversation gains its recording pieces. - The lifecycle writer inventory lists the planner's uses_custom_stt sibling field. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(playback): keep the Optional narrowing before the v3 snapshot Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem and change
A batch-live capture can be assigned to a gap-closed episode and remain there while audio is open. The composer returns
waitingbefore reaching its bounded transcript deadline, so finished recordings cannot get their episode summary.Use main’s admission selector for unowned live captures and corroborated capture clocks for rehomes at or after a silence boundary, with membership, reverse links, navigation and the timeline fence in one transaction. The normal compose tick repairs old post-gap live memberships. A true pre-boundary live member stays linked but is excluded from readiness and summary inputs until it finishes. Finished-subset writes tolerate audio appends while still fencing finish/hide/lock changes. Home preparation keeps the finished summary readable. The phone's existing one-processing-row aggregation is unchanged.
R41 clock safety: rehoming requires finite batch start, stored
started_atand canonicalrecorded_startwith trusted provenance. All must agree within five seconds, not exceed transaction server time by more than five seconds, and fall at or after the boundary. Missing, untrusted, future or conflicting clocks retain membership while finished-subset readiness still composes. This also refuses intervals straddling the boundary, even within the tolerance. The closed-labelomi_episode_live_member_clock_refusal_total{reason=~"missing|untrusted|future|disagreement"}counter records refusals after the transaction returns.Initial placement reuses main's admission start selector: finite
server_batch_audio_start, thenstarted_at, thencreated_at. Both batch admission and the live ownership transaction call the same shared helper. Initial placement adds no trust or future refusal; no known start preserves main's admission skip. Every rehome still requires all three trusted clocks and every R41 bound/refusal. Rotation cleans pending/provisional state and schedules the closed summary after commit; recovered-member classification follows a rehome. The recorded-time rollback switch also disables this placement/repair writer while finished-subset readiness remains protected.No recording deletion or merge; custody, audio acknowledgements, STT admission and billing are unchanged. No production account data is included in this PR or its tests.
Verification
test_admission_boundaries_pass_a_clock_carrying_rowdrives both real production paths: preview promotion and fresh create. Initial placement and rehome validation use separate clock policies.created_at, conflicting optional clocks and future starts; R41 rehome refusals remain covered. Four unit files passed in separate credential-freeomi-heavyprocesses: live-member-close 60, unchanged batch-audio-close 69, late-audio-recorded-time 38 and recorded-span 33 (200 total). Emulator files passed separately: live-member 29, Home 6. Targeted Pyright: 0 errors.ro-prod, aggregate Prometheus and Firestore COUNT only. Existingwaitingmetrics have no blocker reason, so this pattern's fleet share is unmeasured.Rollout and kill switch
Default on:
EPISODE_LIVE_MEMBER_CLOSE_ENABLED. Quality lead owns deployment and validation: no-traffic candidate, small serving slice, then all composer/attachment hosts in one release window after clean compose-error, timeline-conflict and Firestore-read-rate signals. Rollout services:backend,backend-listen,pusher,backend-sync,backend-sync-backfill, and their conversation-finalization executors. Confirm the exact serving release identity on each service. Watchomi_episode_live_member_total{outcome=~"rehomed|excluded_readiness"}, compose waiting/errors/conflicts and synthetic/consenting-owner end-to-summary latency. The counters are observations/commits, not unique users or measured product latency.Rollback: set
EPISODE_LIVE_MEMBER_CLOSE_ENABLED=falseon every affected host. This restores legacy placement/readiness for subsequent work; committed rehomes remain intact. No data migration, production write script, merge or deploy is performed by this PR author. Remaining nonterminal processing/transcript waits keep their existing bounds; deployed Home paint and the five-minute product goal still require release/device validation.Line-Count-Exception: backend/utils/episodes/composer.py | 2110 -> 2118 | Keep the readiness branch and one lazy-repair call beside the existing composer guards; transaction implementation lives in a new focused module.
Line-Count-Exception: backend/utils/episodes/service.py | 2256 -> 2314 | Keep existing service entrypoints and collaborator ownership intact while routing live placement and lazy repair to the fenced helper; avoid an unrelated orchestration refactor.
Failure-Class: none
🤖 Generated with Claude Code