Repository navigation
feat(conversations-v3): per-owner live re-derive for fragmented live windows - #25817
Conversation
…windows Adds `--mode rederive-live` to the per-owner v3 repair tool. For one owner and one [since, until) window it replans finished live v3 windows from their sealed source recordings with the current planner, keeps the earliest absorbed id, retires absorbed rows as sync bridges, and records exact priors for undo. Failure-Class: FC-irreversible-terminal-hide 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: 10ce159f1b
ℹ️ 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".
| page.append(entry) | ||
| size += amount | ||
|
|
||
| @firestore.transactional |
There was a problem hiding this comment.
Purge undo priors when their conversation content is deleted
After a live re-derive, deleting a rebuilt conversation leaves its original transcript and notes in this new sibling collection. The deletion path in routers/conversations.py::_delete_conversation_under_gate and database/conversations.py::delete_conversation removes primary content and known sibling evidence, but a repository-wide search for conversations_v3_rederive_priors and its accessors finds no deletion integration. Consequently, inline encrypted content in entry['raw'] remains recoverable with the owner's key even after conversation erasure succeeds; refusing undo on a tombstone does not erase this copy. Add these priors to the conversation-erasure lifecycle, including copies belonging to absorbed rows.
Useful? React with 👍 / 👎.
| tx.delete(coll.document(entry['id'])) | ||
| removed += 1 | ||
| else: | ||
| tx.set(coll.document(entry['id']), entry['raw']) |
There was a problem hiding this comment.
Protect post-rebuild owner edits before restoring a prior
If the owner edits a rebuilt conversation before the operator undoes the run, this full-document replacement silently discards those edits. For example, database/conversations.py::update_conversation_title updates user_title and structured.title without clearing v3_rederive_live_run, so the row still passes the run-stamp check and its new title is overwritten by the old snapshot. The same problem applies to owner corrections and other mutations that retain the stamp. Refuse undo when owner-managed state has changed since the rebuild, or explicitly preserve that state rather than treating the run stamp as proof that the document is unchanged.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
|
|
||
| def load_live_rederive(uid, *, since, until, run_id, firestore_client=None): |
There was a problem hiding this comment.
Add the required conversation-lifecycle change note
This commit introduces a new lifecycle operation that rebuilds, retires, and restores live conversations, but its changed-file list contains no note under backend/docs/listen_pusher_pipeline/changes/. backend/AGENTS.md explicitly requires a note in that directory for conversation-lifecycle changes; the runbook update does not satisfy that separate requirement. Add a change note covering the repair behavior, rollout/flag state, and verification evidence.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
| stamp = (snapshot.to_dict() or {}).get('v3_rederive_live_run') if snapshot.exists else None | ||
| if stamp not in (None, run_id): | ||
| return 'undo_newer_run_first' |
There was a problem hiding this comment.
Recognize already-restored priors when resuming an undo
If run B rebuilds rows previously rebuilt by run A, undoing B restores their original v3_rederive_live_run='A' stamps. Since undo_live_run restores source-connected groups in separate transactions, an interruption after the first group leaves those restored rows alongside groups still stamped B. Retrying undo B then rejects the restored A stamps here as undo_newer_run_first, so the remaining groups cannot be restored; the transactional check in undo_live_rederive has the same problem. Distinguish already-restored priors from genuinely newer runs, for example by recording group completion atomically with restoration.
Useful? React with 👍 / 👎.
…es created rows fully Panel review-20261119t194708-ded2 on 10ce159: - F1: undo refuses (owner_edited_rebuilt_row) when the owner edited, shared, locked or added photos to a row the run wrote or created. - F2: a created row is hidden in the undo transaction, then erased with the conversation deletion helper so its child collections go too. - F3: a partition whose final batch would exceed the transaction write cap blocks (backfill_partition_budget) before any write. - F4: the dry-run reports rows_retired_est (eligible rows minus windows that adopt one) instead of a mislabelled upper bound. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…esumes partial commits - A source whose stored document is within a claims update of Firestore's 1 MiB limit is blocked as size_limit: its rows stay untouched and the dry-run reports it up front (SCA-2791 shape). A planned claims list that would grow a committed source past the limit blocks the partition as document_too_large before priors or commit. - A resumed partition after a mid-commit failure replans the rows the run already wrote (their own notes marker no longer protects them), so the absorbed rows still retire; undo is exact from the partial and resumed states. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…baseline Undo of a live re-derive now refuses when the owner changed a row the run wrote, created or retired after the run: a settled partition records a digest of each row's owner surface (title, overview, edit fields, star, folder, photos, visibility, lock, deletion, merge), and a retired row must still be the run's bridge to its survivor. A post-run merge of a rebuilt row also refuses before baselines exist. A prior too large to record blocks as document_too_large before any write. Adds regressions for a summary edit or merge after baselines, a merge before baselines, a window crossing until, an oversized prior, retirement only in the final commit batch, and run_step recording baselines. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…honour account deletion An interrupted undo of a live re-derive can now be rerun: rows it already restored (even ones carrying an earlier run's stamp) and created rows it already hid (stamped v3_rederive_live_undone) are finished instead of refused as a newer run or an owner edit. Priors are written in transactions fenced on the account-deletion marker. A row the owner changed before its partition settled gets a baseline that never matches, so undo keeps refusing it. The dry-run reports sealed live sources no window claimed (sources_unclaimed). Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves conflicts with the claim transfer (absorbed donors) in commit_projection and the custom boundary timing in reconcile. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
… lists bridges on survivors The survivor of a live re-derive lists the rows it retired in sync_merged_from, so deleting it purges its bridges through the existing sync-bridge path. Deleting a conversation a run stamped deletes its undo priors (and its bridges') from every live run of the owner first; a finished undo drops the run's priors; priors are never written for a conversation already tombstoned. Undo refuses once account deletion began, and refuses a group too large for one transaction before restoring any. The dry-run preview now carries sources_unclaimed. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
… or protection change Deleting a stamped conversation, or migrating its protection level, now empties its undo priors (and its bridges') to a purged stub in every live run of the owner, paging through all run ledgers. A run holding a stub refuses undo as a whole. data_protection_level is part of the owner surface. The rerun check ignores the commit hook's home feed stamps. The dry-run reports windows that would cross the partition edge. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s deleted rows The survivor's sync_merged_from now lands in the final commit batch with the retirements, so a partial commit never lists still-live rows. Deleted rows are offered as protected finished rows so their unreleased claims fence the replan. A failed commit empties the copies of rows the owner deleted or re-protected after they were recorded. Undo re-applies the recurring-voice fence to restored rows and counts claims in the group size. A live run's ledger keeps the loader's sources_unclaimed. Failure-Class: FC-irreversible-terminal-hide 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: 36e529d42b
ℹ️ 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 any(raw.get(field) for field in OWNER_EDIT_FIELDS): | ||
| return 'edited' |
There was a problem hiding this comment.
Preserve owner-edited summaries when selecting rows to rebuild
If an owner edits a live conversation's summary before this repair runs, database/conversations.py::update_conversation_summary writes structured.overview and removes structured.sections, but does not set user_overview or another field in OWNER_EDIT_FIELDS. This check therefore considers that conversation eligible, and _rederive_live_prior clears its structured data before rebuilding, silently replacing the owner's summary. Persist and check an explicit summary-edit marker so these rows are protected, just like manually retitled rows.
Useful? React with 👍 / 👎.
| } | ||
| if any(owner_changed(current[cid] or {}, by_id[cid]) for cid in ours): | ||
| raise Conflict('owner_edited_rebuilt_row') | ||
| from database.recurring_voice_privacy import filter_processing_write |
There was a problem hiding this comment.
Move the new privacy-helper import to module scope
The new undo transaction imports filter_processing_write inside its callback, contrary to the explicit requirement in backend/AGENTS.md that all imports be at module scope. Move this import to the module's import block; the newly added local imports in the protection-migration and prior-purge helpers need the same treatment.
AGENTS.md reference: backend/AGENTS.md:L168-L168
Useful? React with 👍 / 👎.
| priors = runs.list_priors(uid, run_id, firestore_client=firestore_client) | ||
| if any(leases.held(uid, 'summary-' + e['id'], firestore_client=firestore_client) for e in priors): | ||
| return _undo_refused(uid, run_id, 'notes_in_flight', firestore_client) | ||
| blocker = rederive_store.live_undo_blocker(uid, run_id, priors, firestore_client=firestore_client) |
There was a problem hiding this comment.
Keep both builder leases alive during undo preflight
For a large live re-derive run, or an operator connection with high Firestore latency, this preflight can exceed the leases' 240-second lifetime: it performs one sequential summary-lease read per prior, and live_undo_blocker then performs two more sequential document reads per prior. Neither builder lease is renewed until after the first restoration group. Consequently, the first undo_live_rederive rejects the expired backfill lease with lease_lost, and retrying repeats the entire scan without making progress. Keep both leases renewed throughout enumeration and validation, rather than starting renewal only after restoration.
Useful? React with 👍 / 👎.
| # No rebuilt window covers its time: nothing absorbed it, so it stays as it is. | ||
| kept += 1 | ||
| continue | ||
| retire[cid] = _retire_patch(survivor, run_id) |
There was a problem hiding this comment.
Preserve standalone task associations before retiring donors
When an absorbed live conversation already owns standalone action items, this retirement leaves their conversation_id pointing to the now-deleted donor and does not transfer their target_task_id links into the survivor. The survivor's task list and progress count then exclude those tasks: routers/action_items.py::get_conversation_action_items and get_conversation_action_items_count query only the requested conversation ID, while requesting the deleted donor returns 404. Ordinary live refinement avoids this through store.merge_donors_have_tasks, but the new retirement path bypasses that guard. Protect task-bearing donors, or migrate their task associations and links together with corresponding undo state.
Useful? React with 👍 / 👎.
Failure-Class: none
…es like a sync merge A card whose summary the owner rewrote (notes written, overview, no generated sections: the summary endpoint deletes them) is protected, and undo refuses it before baselines. The retire patch carries v3_claims_transferred_to and a bumped sync_content_revision, as a sync merge's absorbed row does, so deleting a bridge releases none of the survivor's claims. Undo refuses when a named source is gone, before any write. A resumed attempt keeps the first prior of a row. The protection migration empties only copies of rows it actually re-protects. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…el and preflights undo sources save_priors reads each row's protection level in its transaction and refuses a copy at a level the row has left; the protection migration also empties the copy of a row a live run stamped after its snapshot. The undo pre-check reads every source of every group before the first restores. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
… row A failed commit drops the undo copies of rows it did not write (a resume records them again), so the stamp-gated deletion and protection paths reach every copy. The protection migration empties a re-derived row's copies only after re-protecting it. The commit checks tombstones of the rows it retires. Rows with app results are protected: the owner can edit them without a marker and a replan never regenerates them. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y failed live commit The protection migration purges live re-derive copies after its rows and photos are written, recording re-derived rows on every attempt so a retry purges again; copies already at the target level (and created-row copies) are kept. A live commit that fails for any reason drops the copies of rows it did not write. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves the reconcile conflict with settle-on-landing stretches (#25829). Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…left behind Each live attempt and each undo first drops the run's copies of rows no run stamped since the copy (a process stopped between recording the copy and stamping its row). Undo never restores such a row, so the copies are only retained content. A row a newer run restamped keeps its copy, so undo still waits for that run. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…undo copies Each partition reads its copies by id before its commit and when it settles (the settle step takes the ids from the partition ledger), so prior reads grow linearly with the run. The full stale-copy scan runs once per resume and once per undo. The loader's range overflow blocks as rederive_live_range_overflow, distinct from the final-commit write cap. The runbook says a permanently refused undo keeps its copies until the owner deletes the rows or the account. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cle inventory pins it The settle step takes the partition's copy ids from a local, not from a new field on the pinned 'notes' partition payload. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on touched The settle step baselines every row the partition writes or retires, so rows a failed attempt already wrote get a baseline after the resume. Retired bridges clear summary_due_at as main's absorbed rows do (declared in the lifecycle writer inventory). The runbook says to undo only settled runs: before settle the run's own notes may discard a card or add app results. Failure-Class: FC-irreversible-terminal-hide Co-Authored-By: Claude Opus 5.5 <[email protected]>
## What changed and why SCA-3299. A sync redirect was hiding the donor recording while leaving its V3 Home card claims there. Sync now moves an eligible donor's transcript-only claims and its cards' source links to the survivor in the same Firestore transaction, with an immediate pending marker for V3. Deletion re-reads the card links after durable delete intent. Sources with playback, tombstones, competing claims, or insufficient speech evidence stay in place. The operator command previews one nominated redirect chain, applies only the reviewed revision-bound receipt, and restores only fields whose documents still match the repair commit. It preserves published card content and visibility. A historical overlap without exact segment and custody evidence remains for review. Coordinate the preview with the live re-derive owner in #25817 and record the TestFlight build and serving revision in SCA-3299 before readback. This release is separate from the sit-down configuration rollout. ## Product invariants affected none ## How it was verified - 2,083 focused backend unit cases passed across sync assignment, V3 claim growth, claim deletion and the lifecycle writer guard. - `make preflight` passed all 42 selected checks with this PR body. - Both Firestore emulator tests passed. They cover the stale V3 reconcile commit, deletion with a stale card snapshot, dry-run drift, apply retries, rollback and edit/tombstone conflicts. - Production preview, mutation, serving verification and internal TestFlight QA are pending release and operational approval. ## Tests - `backend/tests/unit/test_conversations_v3_claim_growth.py` asserts two redirects, retry idempotency, preserved user title and one owner per segment after V3 reconciliation. - `backend/tests/integration/test_conversations_v3_sync_custody_firestore.py` exercises live Firestore transaction semantics on the local emulator. UI-Evidence: none -- backend custody fix with no UI changes ## Failure class (fixes) Failure-Class: FC-split-mutation-authority Line-Count-Exception: backend/utils/sync/assignment.py | 1617 -> 1677 | Keep claim, redirect, card linkage and rollover staging in the owning transaction. The standalone custody module owns speech and claim validation. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/25845?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25845?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25845&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1f957dc21
ℹ️ 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 any(raw.get(field) for field in OWNER_EDIT_FIELDS) or summary_edited(raw): | ||
| return 'edited' |
There was a problem hiding this comment.
Protect owner-edited action items before rebuilding a card
If an owner edits or completes a conversation action item before the repair runs, this eligibility check still permits rebuilding the card. routers/conversations.py::update_action_item_description and the completion endpoint call database/conversations.py::update_conversation_action_items, which updates only structured.action_items, without setting any checked edit marker. _rederive_live_prior then clears the entire structured object, discarding those changes. The standalone-task guard does not protect a surviving card because it checks only retired donors. Persist and check an action-item edit marker, or preserve these owner-managed items when rebuilding.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2cb2f3213
ℹ️ 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".
| for cid in result['created']: | ||
| # Already hidden with no claims; the deletion helper also erases its child collections. | ||
| conversations_db.delete_conversation(uid, cid) |
There was a problem hiding this comment.
Protect task-bearing created rows before undo removes them
If an owner creates a standalone task linked to a card newly created by the repair, undo still deletes that card. POST /v1/action-items accepts conversation_id, and its create path writes only the task, so neither owner_changed nor the embedded action-item revision detects this activity. delete_conversation does not migrate these sibling tasks, leaving their conversation links dangling; get_conversation_action_items subsequently returns 404 for that ID. Check for standalone tasks before restoring any undo group and refuse removal, or preserve their associations by migrating them to a restored conversation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 851024a013
ℹ️ 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".
| structured = raw.get('structured') | ||
| if isinstance(structured, dict) and structured.get('action_items'): | ||
| # Historical items can contain owner edits with no revision marker. | ||
| return 'action_items' |
There was a problem hiding this comment.
Preserve owner-managed calendar event state before rebuilding
If an owner has marked an extracted calendar event as created before the repair, this eligibility check still allows the conversation to be rebuilt. routers/conversations.py::set_conversation_events_state persists that choice through update_conversation_events, which writes only structured.events and sets no checked edit marker. _rederive_live_prior then clears the entire structured object, losing the owner's event state whenever the window changes. Protect rows with owner-managed events or preserve those events across the rebuild, as is already done for embedded action items.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f387796ff
ℹ️ 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 retired and merge_donors_have_tasks(uid, retired, firestore_client=client, transaction=tx): | ||
| raise Conflict('rederive_live_donor_tasks') |
There was a problem hiding this comment.
Fence task creation against donor retirement
If a task-create request validates a donor immediately before this transaction retires it, the task can still commit afterward with its conversation_id pointing to the deleted donor. The new transactional task-create fence in database/action_items.py::_check_undo_removals checks conversation availability only when an undo-removal marker exists, but live retirement writes no such marker. Consequently, this task query can correctly return empty and both transactions can succeed sequentially, leaving the task absent from the survivor's task list and its original conversation endpoint returning 404. Unlike the previously reported case of an already task-bearing donor, the fresh evidence here is the marker-only create fence, which leaves this validate-before-retire/commit-after-retire ordering unprotected. Add a shared transactional fence for retirement and task association, or migrate the association.
Useful? React with 👍 / 👎.
## Change Add an explicit historical sit-down timing option to the per-owner live repair in #25817. This branch targets the repair branch so its review covers only the timing change. - Use 900 seconds of recorded silence for partitioning, outlining and planning. Refuse forced partition cuts and verify internal seams against decoded speech, since late text can extend past the stored end time. - Use the 3,600-second lock from the latest speech landing. Stop on unknown landing times or an unsettled stretch. Pass the timing through the existing backfill run ledger and refuse a worker configuration mismatch. - Keep ordinary derive and non-opt-in live repair timing. The dry-run still estimates counts with placeholder outlines. ## Worker verification 178 focused backend unit tests passed under Python 3.11 on synthetic data. Coverage includes the 899/900-second seam, 3,599/3,600-second lock, stale recording-end metadata, worker configuration drift, the sit-down outline and resulting card, and the existing repair and undo regressions. SCA-3355 tracks the owner-scoped preview and publication approval. Production account data was untouched. Keep live application gated on the reviewed repair, exact serving evidence, the private preview, and its approved rollback. ## Product invariants affected None selected by PR preflight. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/25863?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25863?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25863&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
What
backend/scripts/conversations_v3_backfill.py run --mode rederive-livereplans one owner's finished live v3 windows in one[since, until)window from their source recordings with the current planner (#25764 manual cuts and exclusive claims, #25786 stretch cohesion), and commits the result. Until now the repair tool could only re-derive legacy donors (derive) and rows a backfill had made (rederive). Finished live windows are kept as they are byplanner.preserve_finished_windows, so the fragments built before those fixes (a lunch tail of ~18 tiny visiblemanual_endcards, ~66 hiddenbelow_word_minimumtopic pieces on 11-19) stay fragmented.It runs as an ordinary backfill run: same ledger, start marker, queue,
backfill-builderlease, outline and notes path,status,resumeandundo.CONVERSATIONS_V3_BACKFILL=offstill stops all of it.DESIGN:
Reads and writes per owner-day. Sized against one real owner-day (2026-11-19 UTC, ro-prod metadata-only
runQuery, counts only): 503 documents started that day (203 sources, 244 v3 rows: 86 visible and 158 hidden; 56 deleted or merged).Dry-run: one metadata read of the window (503 reads), then per partition (≤192 documents planned, ≤256 loaded) the started_at range read plus by-id reads of sources and rows named by claims outside the range, plus one lease read. About 1,000 reads. No writes, no model calls.
Run: the same loader reads (~550). Each commit batch's transaction reads its sources and the rows it writes or retires, plus a tombstone per written row (~400–700). It writes:
For the sized day that is at most ~700 writes, and fewer when windows are unchanged, because an unchanged window gets no write.
Priors: each partition reads its own copies by id twice, before its commit and when it settles (at most 256 each).
resumeandundolist the run's copies once (pages of 200). So prior reads grow linearly with the run, not with partitions times copies.Undo: lists priors (pages of 200), reads each row, its tombstone and its sources once per group, and writes each restored row and source once.
LLM cost. One outline call per stretch in the partition (cache hits are free), then notes only for windows that changed. Unchanged windows keep their row and their notes. The dry-run prices this at the gateway Luna card, the same as the backfill estimate: outline per stretch, plus notes, agentic notes or tasks-only by word count for every window after. By that card an owner-day plans at well under $1 (a planning estimate; gateway usage has the actual spend). The coordinator reads the exact number from the dry-run before running.
Custody.
service._match). A rebuilt window whose speech, bounds, claims and Home decision equal the stored row is not written, so its notes do not re-run.deleted,discarded, a clearedsummary_due_at,sync_merged_into,v3_claims_transferred_to, a bumpedsync_content_revisionandv3_derived=false. That is the patch a sync merge gives its absorbed rows, so deleting a bridge later releases none of the survivor's claims. The survivor lists its bridges insync_merged_from, so deleting it purges them, as with a sync merge. That list lands in the final commit batch together with the retirements, so it never names a row that is still live. Nothing is hard-deleted, subcollections stay, and reads by id follow the bridge. Droppingv3_derivedkeeps every v3 planner read (claims closure, time queries, adoption) from treating it as a user deletion. Its claims leave the sources in the same commit that writes the survivor, so no claim is orphaned and claims stay deduplicated. Audio pieces come from the planner's exclusive claims, so no audio is duplicated.backfilledandv3_rederive_live_run. Their notes take no memories, tasks, webhooks, notifications or created fanout, and they use the backfill's own notes marker.sinceoruntil;sources_blocked_size_limit, the SCA-2791 shape). The dry-run reports this per partition before any write.claimson its sources, so it never arms or cancels an audio purge.rederive_live_coverage) and writes nothing if any segment an eligible row held would not be in a rebuilt or protected row.rederive_live_opencovers speech within five minutes of now, and is checked before any paid call.rederive_live_boundarycovers a window that would crosssinceoruntil.rederive_live_outline_failedmeans a repair never commits fallback failed tiles.document_too_largemeans a source's claims would grow past the limit or a prior is too large to record, and is checked before any write.conversations_v3_backfill_runs/{run_id}/conversations_v3_rederive_priors. That collection sits under the owner, so account deletion purges it, and it has a budget in.github/firestore-collection-budgets.json.purgedstub, in every live run of the owner, before anything else. Every copy belongs to a row a run stamped after the copy was made, because a commit that fails for any reason drops the copies of rows it did not write, and a resume records them again. Each partition's attempt first drops the run's copies of the rows it loads that no run stamped since, andresumeandundodo so for every copy of the run, which covers a process that stopped between recording a copy and stamping its row. Undo never restores such a row, so these copies would only ever be retained content. So the stamp-gated deletion path always reaches a copy. After a protection migration has written its rows and photos, it empties the copies of every stamped row it reached that were stored at another level. It records those rows on every attempt, so a retry after a failed purge purges again. The commit also checks the tombstones of the rows it retires, so a row the owner deletes before its retirement fails the commit. A run with a stub refuses undo as a whole rather than restoring around it. Rows no run touched pay nothing. A finished undo deletes the run's priors.owner_deleted_rebuilt_row), or while a newer live run restamped one (undo_newer_run_first). It also refuses after the owner changed a row the run wrote, created or retired (owner_edited_rebuilt_row). Once a partition settles its notes, the run records a digest of each row's owner surface: title, overview, edit fields, star, folder, photos, visibility, lock, deletion and merge. Undo compares against that digest. Before the digest exists, it checks the edit fields, visibility, lock and any merge against the stored prior. A row the owner changed before its partition settled gets a baseline that never matches. A retired row must still be the run's bridge to its survivor. It checks every prior before restoring any group, and each group's transaction checks again.v3_rederive_live_undone), are finished, not refused. That holds when they carry an earlier run's stamp, too.undo_source_missing). It checks every source of every group before restoring the first group.save_priorsreads each row's level in its transaction.account_deletion). Before restoring anything, it refuses a group of rows sharing sources that is too large for one transaction (undo_group_too_large: more than the write cap or 8 MB).home_source_versionandhome_content_invalidatedon every conversation write. So a restore is exact apart from those two fields, and the rerun check ignores them.Production number that proves it. After deploy, the coordinator runs the dry-run on the named owner's 11-19 and then the run. The readback is the run ledger's
windows_after,visible_after,rows_retiredandoutline_calls, taken against the dry-run's before counts. For the lunch tail and the 08:16–12:56Z stretch, the target is visible finished v3 windows shorter than 30 s per active source-hour going from the 2.538/h lunch baseline to near 0, with 0 same-file duplicate pairs.Not in scope / known limits
in_progressfor hours. They count as unsealed, so rows on them stay protected and the dry-run reports them assources_blocked_unsealed.process_conversation) may discard a rebuilt card or add app results to it. So an owner discard or app run on that card during the notes drain cannot be told apart from the run's output, and undo before settle can restore over it. After settle, the baseline digest covers both. The runbook says to undo only settled runs.windows_afteris the fewest windows the run can produce androws_retired_est(eligible rows minus the windows that adopt one) the most it is expected to retire. The run ledger has the exact counts.backfill_partition_budgetbefore any write.Verification
Unit tests at the code layer only. Nothing ran against the emulator or production.
tests/unit/test_conversations_v3_live_rederive.pyhas 58 tests, plus two deletion wiring tests intest_merge_conversations_canonical_delete.py. They run the real loader, planner, commit transaction and undo transaction on the strict in-memory Firestore:untilstay byte-identical;until, an oversized prior and claims growth past the document limit each block before any write;sync_merged_from, and the dry-run reports unclaimed live speech and windows that would cross the edge;test_conversations_v3_*files pass, as do every test file that importsmerge_conversationsor exercisesmigrate_conversations_level_batch. Two migration fakes gainedto_dict, which real snapshots have. The Firestore query-shape, outside-query, index-oracle, runtime-witness and lifecycle-writer guards pass, as docheck_conversation_lifecycle_writes.pyandcheck_conversation_readers.py. GitHub's backend unit shards have failed only on 1-second per-test timing guards in files this PR does not touch (test_live_recap_telemetry,test_monitoring_adapter_hpa_contract). The recap test runs in 0.5 s locally; reruns were requested.Review
Panel
review-20261119t194708-ded2on 10ce159: FIX-FIRST. Luna and GLM Flash completed; DeepSeek failed with an empty result. Triage:database.conversations.delete_conversation, which also deletes its children, after the transaction hides it and drops its claims.rows_retired_est.Panel
review-20261119t202258-de84on 8b07afc: FIX-FIRST. Luna and GLM Flash completed; DeepSeek timed out. Triage:document_too_largebefore any write. Regression added.rederive_live_boundaryblock test and a multi-batch commit test showing retirement only in the final batch. Not added: the moved-source path, which live sources never take, becausespeech_movedis false for them and any concurrent change fails the revision fence assource_changed.finished_at, so they never sit in a later merge's gap. Writing smart-merge donor lineage would forge a merge ledger that no merge wrote.Panel
review-20261119t210824-f141on 7a6d35b was invalid: an earlyomi-panel collectremoved its checkout while members ran. Its one finding (checkout missing) was rejected and the panel rerun.Panel
review-20261119t212417-ad5eon 7a6d35b: FIX-FIRST. Luna and GLM Flash completed; DeepSeek timed out. Triage:save_priorsreads the account-deletion marker in each transaction and refuses (account_deletion). Regression added.record_baselinesfirst checks the row against its prior. A row the owner changed before the settle gets a baseline that never matches. Regression added.undo_newer_run_first. Regression added for run-over-run.v3_rederive_live_undone, and a rerun erases such rows instead of refusing. Regression added.recording=Truewithoutv3_backfill_runis written only by v3 capture. Legacy conversations are not recordings, so they are never loaded as sources, and converted donors are blocked asbackfill_donor. A sealed recording no window claims is live speech the builder lost, and making it a card with no derived effects is the repair. The dry-run now reports it assources_unclaimed, so the operator sees it first.structured,apps_resultsand folder are being rewritten by the run's own notes pass, so they cannot be compared with the prior. F2's fix closes the gap up to the settle. A partition that never settles is resumed, not left half done.classify_live_windowcount test. Thesource_changedfence for live sources is the existing revision fence incommit_projection, which its own suite covers.Merged origin/main (#25817 had become conflicted). Main's claim transfer (
_v3_absorbed) and custom boundary timing combine with this change. Live re-derive runs with derive timing, so the custom timing paths are off for it.Panel
review-20261119t220910-1af6on eeb6bda: FIX-FIRST. Luna and GLM Flash completed; DeepSeek failed with an empty result. Triage:save_priorsrefuses a conversation already tombstoned. Regressions added, including the deletion wiring.sync_merged_fromlists its bridges, so deleting the survivor purges them through the existing sync-bridge path. Undo restores the survivor's prior document, and with it the prior list. This also gives smart merge the lineage that the de84 F5 finding asked about.sources_count, sosources_unclaimedreaches the preview. Regression added.undo_group_too_largerather than failing midway. Regression added.Panel
review-20261119t225938-d579on 7d8cfcc: FIX-FIRST. Luna and GLM Flash completed; DeepSeek failed with an empty result. Triage:purgedstub, so no copy stays at the old level. Regression added, including the migration wiring.data_protection_levelis in the owner surface and in the check before baselines. Regression added. A purged stub refuses the whole undo, so a migrated row is never restored around.windows_crossing_edge. Regression added.Panel
review-20261119t235010-7c85on 49d66c9: FIX-FIRST. All three members completed. Triage:sync_merged_fromis staged with the retirements and lands only in the final batch. Regression added: in a partial commit the survivor lists nothing.protected_deleted). Regression added.filter_processing_writeinside the undo transaction. Regression added.sources_unclaimed).sources_unclaimed. Regression added.Panel
review-20261120t002457-a83aon 36e529d: FIX-FIRST. All three members completed. CI on 36e529d was green. Triage:v3_claims_transferred_toand a bumpedsync_content_revision, as a sync merge's absorbed row does. Regression added.undo_source_missing) before writing anything. Regression added.classify_live_windowtestsdeletedandsync_merged_intofirst, so every bridge the run writes counts as deleted. No path clearsdeletedon a bridge.save_priorskeeps an existing copy, so a resumed attempt records nothing over the first. Regression added.Panel
review-20261120t010840-047fon c3c99c5: FIX-FIRST. Only Luna completed; DeepSeek returned an empty result and GLM Flash timed out. CI on c3c99c5 was green. Triage:save_priorsreads each row's current protection level in its transaction and refuses (source_changed) a copy at a level the row has left. The migration also empties the copy of any row a live run stamped after the migration's snapshot. Regression added for the fence.Panel
review-20261120t014903-c9ebon 4de3684: FIX-FIRST. Luna and GLM Flash completed; DeepSeek returned an empty result. CI on 4de3684 was green. Triage:protected_app_results). The owner can edit those with no marker, and a replan never regenerates them. The dry-run counts them. Regression added.windows_crossing_edgebefore any write, and the operator widenssince/untilor leaves that capture alone. Clipping a capture's lines to the partition would split one conversation in two, which is the fragmentation this tool removes.Panel
review-20261120t023041-3445on cac9f55: FIX-FIRST. Only Luna completed; DeepSeek and GLM Flash timed out. CI on cac9f55 was green. Triage:Conflict. If the cleanup itself fails, the partition stays unfinished until resume or undo. Regression added.Panel
review-20261120t031408-74adon b8b9a68: FIX-FIRST. Only Luna answered; DeepSeek returned an empty result and GLM Flash an invalid one. Triage:Panel
review-20261120t035349-fb30on 2684b6f: FIX-FIRST. Luna and GLM Flash completed; DeepSeek returned an empty result. CI on 2684b6f was green (68 checks, after rerunning one shard whose git checkout hit an early EOF). Triage:prior_ids). The full scan for stale copies runs once perresumeand once per undo. The budget entry states this. Regression added: a partition run withlist_priorsmade to fail.deleted, and the migration skips deleted rows, as it does every sync-merge bridge on main. So the bridge document itself stays at the old level with the same content as its copy, and the copy exposes nothing the bridge does not. The copy cannot be restored either: re-protecting the survivor changes its owner-surfacedata_protection_level, so undo refuses the run (owner_edited_rebuilt_row).windows_crossing_edgebefore any paid call, so the operator widens the window first.rederive_live_range_overflow, andbackfill_partition_budgetmeans only the final-commit write cap. Regression added; runbook updated.That push (c5aadce) failed the lifecycle payload inventory: a new field on the pinned
'notes'partition payload. Fixed in f20d08a: the settle step takes the ids from a local. CI on f20d08a was green (64 checks).Panel
review-20261120t044101-1ca3on c5aadce: FIX-FIRST. All three members completed. Triage:process_conversation, which the run's own notes use, writes bothdiscardedandapps_results. So before a partition settles, a difference from the prior can be the run's output. Refusing on it would turn every such row's baseline intoCHANGED_BEFORE_SETTLEand make the run permanently un-undoable. Rows that were discarded or had app results before the run are protected and never touched. After settle, the digest compares both. The gap is the notes drain of a just-rebuilt card, and the runbook says to undo only settled runs._live_run_ids. That reads the owner's run documents once each, and an owner holds a handful of operator runs. A mode filter would add a query shape and an index for no measurable saving.prior_idsis now every row the partition writes or retires. So a resumed partition's settle step also baselines the rows the failed attempt already wrote. The regression fails without the fix.keep_levelmakes that purge write nothing for copies already at the level, and only rows a live run stamped pay its reads.rows_unchanged,rows_retiredandpriors_recorded, and asserts that no later transaction sets, updates or deletes a conversation.summary_due_at, as main's absorbed-row patch does. The site is declared in the lifecycle writer inventory. Regression added.rows_kept_unabsorbed). A row with speech that no window holds blocks the pass by design.Failure-Class: FC-irreversible-terminal-hide
Line-Count-Exception: backend/database/conversations.py | 5307 -> 5341 | Protection migration purges old-level repair priors, and the owner writers and processing transaction preserve embedded task and calendar edits.
Line-Count-Exception: backend/database/action_items.py | 2182 -> 2224 | The action-item create transactions own the source recheck that fences linked tasks against repair undo.
Product invariants affected
none
🤖 Generated with Claude Code