Skip to content

fix(conversations-v3): keep short topics and speaker labels cohesive - #25786

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/v3-stretch-cohesion
Nov 19, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/v3-stretch-cohesion

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

DESIGN

  • Reconciliation reads the same recordings, existing derived rows, claims and outline cache and writes through the existing fenced planner and commit. The prompt uses a stretch-local label map built from those same segments. The planner counts words in memory after applying silence, manual and cap boundaries. No new storage calls or writes per row are planned. Fewer short topics can yield fewer derived writes.
  • The outline still uses the same call cadence and one prompt per stretch. The changed prompt invalidates old outline cache keys on first use. Existing processing and notes eligibility still applies to the resulting cards, so notes for recovered visible cards can replace skipped notes on formerly hidden fragments.
  • Within a fresh hard-bounded stretch, all speech contributes to the stretch total. Media and background keep their own cards and visibility policy and act as barriers to folding. A short conversational topic isolated by a passive topic may therefore stay visible. If any topic in the bounded stretch has a published claim, fresh pieces qualify on their own words.
  • Default on. Set CONVERSATIONS_V3_STRETCH_COHESION=off on the v3 reconciliation runners to restore the former prompt and per-topic minimum for future passes. Already published claims and windows keep their custody.

READBACK

  • On new post-deploy rows, measure visible v3 cards per active source-hour and the fraction of finished pieces hidden with below_word_minimum. Use the same filters and observation-window lengths before and after. Keep pre-activation rows and claims separate from rows wholly produced after activation.
  • The fix(conversations-v3): honor manual cuts and preserve exclusive audio claims #25764 lunch baseline measured 8 visible sub-30-second rows in 3.1521 active source-hours, or 2.538 per hour, with four same-file duplicate pairs. It did not report the all-duration visibility rate or the exact hidden-reason share. Take a matched before sample for those two denominators, and retain the sub-30-second rate and same-file pair count as comparable continuity measures.
  • The replay sample previously measured 74 of 82 outline prompts with per-segment abstentions and 2,702 distinct raw labels. The paired prompt experiment requires a dev gateway token and was skipped. Effect on model cut rate remains unmeasured.

Failure-Class: none

Verification

  • Synthetic tests cover first-appearance labels, shared abstention labels, disabling the prompt change, six hidden short topics becoming one visible 517-word card, and silence, cap, and manual-cut isolation.
  • The original service regression for claim clipping and same-start IDs still runs with two substantive chapters so cohesion does not make it vacuous.

Initial review

Panel review-20261119t125314-5686 returned FIX-FIRST on the initial head. All twelve findings were triaged. The follow-up preserves media and background topics as visibility boundaries in ordinary topic folding. Fresh fragments separated from published speech qualify on their own words. Regressions reproduce both issues before the follow-up and pass with the fix. The follow-up also keeps the reserved Omi assistant label distinct from abstentions, removes the duplicate primary heading from folded topics, and documents rollback in the v3 runbook. Short topics continue to fold while the stretch is open so opening a live card cannot publish an intermediate short topic prematurely.

Follow-up review

Panel review-20261119t132538-3f30 returned FIX-FIRST and all five findings were accepted. The correction removes pooled word eligibility for every fresh piece in a bounded stretch with published ownership, including pieces separated by passive topics. The new regression failed before the change and passed afterward. The focused changed-file selection passed 460 tests across 18 files.

Retry review

Panel review-20261119t135344-5622 returned FIX-FIRST and all nine findings were triaged. A retained published row that was already visible under the conversation word gate keeps that qualification on subsequent enabled passes. It cannot qualify any new fragment. Passive-role, manual-end and wearer-recognition rules still apply. The regression covers the first projection, a repeat with published claims, and a switch-off pass. Added cap-spanning and resume-section cases, accepted standard off spellings, and made Omi identity depend on the reserved numeric speaker ID. The focused changed-file selection passed 462 tests.

@Git-on-my-level
Git-on-my-level merged commit ea7e866 into main Nov 19, 2026
84 of 88 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/v3-stretch-cohesion branch November 19, 2026 15:04
Git-on-my-level added a commit that referenced this pull request Nov 20, 2026
… five minutes (#25829)

Builds on #25794 (merged as 755558a): sit-down cutting when its
silence gap is set above five minutes.

## DESIGN:

- **What changes.** When `CONVERSATIONS_V3_SILENCE_GAP_SECONDS`
(#25794's setting) is over 300 s, v3 cuts at sit-downs instead of at the
silence itself. At the default of 300 s nothing changes, so this PR
alone changes nothing in production; the gap setting is the switch, and
setting it back to 300 is the rollback.
- The outline sees pauses of 2 minutes or more as marker lines (`---- 4
min without speech ----`). A sit-down rule replaces the "N of recorded
silence is a hard boundary" sentence. Line numbering is unchanged.
- Neighbouring `conversation` entries of one stretch join into one card,
with topics as sections. Dictation under the Home word minimum that sits
between two of them joins as a section. Media, background and longer
dictation stay separate. Manual-end stretches keep their existing single
card.
- Under a long gap, each card meets the Home word minimum on its own
words. Otherwise #25786's stretch-level total lets every piece of a
two-hour stretch onto Home.
- **Two-hour cap, at any timing.** A stretch over two hours is cut after
the longest prefix that ends within two hours of its start, then again
from there. The cut ignores the outline and does not move as live speech
arrives; main's middle cut moved every pass and stranded one-line cards
(traced on 11-18, 13:54–14:04). The cap and the projection share one
ownership rule and one index per plan (`planner.Ownership.owner_of`,
built once in `plan()` and passed to both projections): an exact hold
(id and timing) wins first, across open and locked rows, with a row
naming the line's recording in `v3_recording_ids` ahead of a legacy row
naming none; only without one does containment in a row's window and
audio claim decide, locked rows first, so a revised turn stays with its
row. A deleted locked row (tombstone) still owns its lines, so the
deleted speech stays isolated in its own skipped window and never joins
the valid speech either side; the cap never reuses a tombstone's cut.
Deleted open rows own nothing, as before (left to the time-matched
tombstone path). When a locked row owns a part's first line, the part
ends at the first line it does not own: rows main already cut, or an
earlier pass cut, keep their cut after upgrade and on backfill resume,
even when a turn straddles it or a held turn is revised. A locked row
that owns none of the stretch's lines never cuts it. The plain duration
branch (no locked owner of the part's first line) still finishes every
part but the last without consulting later lines' owners: with no locked
owner there is no committed cut to keep, and the projection still routes
each finished part's lines through `owner_of`, so a line a protected row
owns is retained by that row and only lines no protected row owns can
land in the finished part. A stretch over two hours has to be cut
somewhere, so this is the existing cap behaviour.
- **One owner per segment.** A row that already holds a segment keeps it
on later passes, even when overlapping turns put it inside a neighbour's
window and clipped claim; a turn published in the open tail stays there
even when its audio lies inside the locked prefix's claim.
- **Lock clock under custom timing.** With either setting off 300, the
lock delay counts from the later of the last speech and
`v3_speech_landed_at`. That field is written in the same transaction as
the speech (live transcript write, sync assignment, batch recording
create), only when the speech changed, so a reconcile between the commit
and the re-arm already sees it. Offline batches of old speech no longer
lock on arrival. Default timing and backfill derive still count from the
last speech.
- **Reads and writes.** No new query, document or transaction. Speech
transactions on v3 recordings carry one more timestamp field.
- **Model calls.** Outline calls per stretch are unchanged, and a long
gap means fewer, longer stretches. Each prompt grows by the marker
lines, under 1% of tokens. Notes calls fall with the card count.
- **Latency.** No change of its own. Lock timing is #25794's
`CONVERSATIONS_V3_LOCK_SECONDS`.
- **Invariant kept.** At most one open window per owner plan (#25800).
Joining works inside one stretch and never holds an earlier stretch
open. There is a test for it.
- **Production number that proves it.** `READBACK:` Home cards per
active v3 owner-day, and the `below_word_minimum` share of derived rows.
Both fall, while the visible cards' word share of the day's speech stays
within 5% of baseline.

## Lab evidence

Pipeline lab (m5-mbp): the owner's real days, replayed offline through
each ref's own `outline`, `planner` and `visibility` code with real
outline calls. Scored against a reviewed ideal Home: 11-17 and 11-18
were reviewed by the owner, and 11-19 was judged by Fable. Dictation is
excluded. No production reads or writes, and no transcripts leave the
lab host.

**Whole finished day** (3 runs each, gap 900 s / lock 900 s, on #25794's
head c9e058c, which is identical in v3 code to 755558a):

| Day | Arm | Home cards | Whole ideal cards | Home precision |
|---|---|---|---|---|
| 11-19 | #25794 | 8-9 | 4/6 | 0.56-0.62 |
| 11-19 | + this PR | 9 | 4/6 | 0.56 |
| 11-18 | #25794 | 19-23 | 3-5/9 | 0.56-0.67 |
| 11-18 | + this PR | 10-13 | 5-7/9 | 0.54-0.70 |
| 11-17 | #25794 | 24-33 | 0/2 | 0.29-0.46 |
| 11-17 | + this PR | 7-12 | 0/2 | 0.22-0.43 |

Ideal Home recall is equal, except one of three 11-17 runs of this PR,
which missed one of the 2 ideal Home cards.

**Full live replay of 11-18** (incremental arrival, real locking, gap
900 / lock 900): #25794 gives 213 cards, 16 on Home, 6/9 recalled, 3/9
whole, precision 0.62. With this PR: 210 cards, 10 on Home, 5/9, 4/9,
precision 0.70. Live fragmentation, which neither ref changes, dominates
the live score; it is being traced separately.

Replays at main 755558a+ against this PR, at default timing and at gap
900 / lock 3600, are running. Results go in a comment before merge. At
default timing this PR is inert by construction: `outline.sitdown()` is
false at 300 s.

## Tests

- `test_conversations_v3_sitdown.py` (new): the 300 s threshold, the
prompt rule swap and gap markers, joining, long dictation, manual end,
the per-card word gate, and one open window.
- `test_conversations_v3_lock_timing.py`: the prompt-threshold test now
uses a 240 s gap, where the hard-boundary sentence still applies.
- `test_conversations_v3_live_passes.py` (new): real `reconcile` +
`commit_projection` passes on the strict fixture. One open card while
live speech stays inside the lock delay; offline batches of old speech
at 900 and 300; the cap cut survives the first paid outline, and ignores
a section a later outline drops (300 and 900); a reconcile between the
speech commit and the re-arm does not lock; derive ignores the landing
clock; overlapping turns at the cap keep one owner across passes with
non-overlapping claims; rows cut by main's middle cap keep boundaries,
segments and claims after upgrade, also when a turn straddles the old
cut or a held turn is revised (300 and 900); a turn published in the
open tail inside the prefix's claim stays in the open tail with no
finished fragment (300 and 900); a full write that changes no speech
keeps the landing time; resuming a main-cut backfill run keeps its rows.
Each was checked to fail with its fix removed.
- Tombstone and precedence: valid speech either side of a deleted card
in one stretch survives in live cards and the deleted speech does not
reappear (300 and 900); a tombstone never pins a cap cut; a
source-qualified exact hold beats an earlier legacy one; a deleted open
row never owns a line; an exact hold needs the same timing; one
`Ownership` per plan.
- Mutation pass over the ownership rule (14 mutations, every one caught
by at least one test): tombstones dropped; cap reusing a tombstone cut;
legacy before source-qualified; exact ignoring the recording; claim
before exact; no claim fallback; a separate locked-only cap rule; no cut
reuse; a locked run ignoring an owner change; the projection retaining
open-owned lines; the projection building its own index; service passing
no index; deleted open rows owning lines; exact ignoring timing.
- `test_sync_assignment_recovery.py`: the landing time commits with
assigned speech for recordings only, and an exact retry preserves it.
- `test_conversations_v3_engine.py`: a locked row holding none of an
over-cap stretch never cuts it (control), and one holding the stretch
start keeps its cut; an exact hold on a later locked row beats an
earlier row's claim, for the cap and the projection, and needs the
line's own recording. With `test_conversations_v3_stretch_cohesion.py`,
expectations moved to the stable cut.
- All v3 suites pass together (728 tests); the sync assignment,
cross-job, live transcript, manual speaker, batch projection, listen
failover and lifecycle files pass one file at a time. Their combined
xdist run has order-dependent failures and a hang that reproduce on main
without this PR (`test_sync_assignment_recovery.py` leaks state into
later files on the same worker).

Line-Count-Exception: backend/database/conversations.py | 5293 -> 5307 |
the landing stamp must commit inside update_conversation_segments'
speech transaction, gated on a speech change
Line-Count-Exception: backend/utils/sync/assignment.py | 1610 -> 1617 |
the landing stamp must commit inside the sync assignment transaction
that writes the speech

## Follow-ups (not in this PR)

- The retained-row duplicate check ignores speaker identity, so it can
suppress a distinct speaker's near-identical turn. This predates this PR
(reviewer note on #25829); it needs its own fix and test.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
aryanorastar pushed a commit to PINYOPATTANAWASANPORN/omi that referenced this pull request Nov 20, 2026
…atures, string claim times)

The attribution wrappers now pass every argument through (outline.messages gained cohesion=).
Seeded recordings get their claim times back as datetimes: the planner compares them with segment
times. Failed driver events record where they failed (file:line, never the message), and the v3
overlay takes max_events for short probe runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 20, 2026
…windows (#25817)

## What

`backend/scripts/conversations_v3_backfill.py run --mode rederive-live`
replans 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 by `planner.preserve_finished_windows`, so
the fragments built before those fixes (a lunch tail of ~18 tiny visible
`manual_end` cards, ~66 hidden `below_word_minimum` topic pieces on
11-19) stay fragmented.

It runs as an ordinary backfill run: same ledger, start marker, queue,
`backfill-builder` lease, outline and notes path, `status`, `resume` and
`undo`. `CONVERSATIONS_V3_BACKFILL=off` still 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:
  - the rebuilt and created rows;
  - a 5-field retire patch per absorbed row;
  - a claims-only update per affected source;
  - one prior document per changed, created or retired row;
  - about 10 ledger updates per partition.

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). `resume` and `undo` list
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.**
- *Adoption.* A rebuilt window keeps the id of the earliest row it
absorbs (`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.
- *Retire.* Every other absorbed row becomes a sync bridge to its
survivor: `deleted`, `discarded`, a cleared `summary_due_at`,
`sync_merged_into`, `v3_claims_transferred_to`, a bumped
`sync_content_revision` and `v3_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 in
`sync_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. Dropping
`v3_derived` keeps 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.
- *No derived effects.* Rebuilt rows are stamped `backfilled` and
`v3_rederive_live_run`. Their notes take no memories, tasks, webhooks,
notifications or created fanout, and they use the backfill's own notes
marker.
- *Never touched.* These are offered to the planner as published
finished rows, so their lines, claims and audio stay theirs. They are
never written, and the ledger counts each one:
  - open windows, and every source an open window holds;
  - rows overlapping `since` or `until`;
- deleted rows, because until their claims are released those claims
still fence their speech;
- rows with app results: the owner can edit those with no marker, and a
replan never regenerates them;
- rows whose summary the owner rewrote. The summary endpoint deletes the
generated sections, so a card with notes, an overview and no sections
counts as edited, which is the rule refinement already applies;
- edited rows (user title, overview or corrections, transcript
corrections, speaker assignments, star, folder, photos, kept-by-user,
absorbed by a merge);
- locked, shared, private, discarded, deleted, unreadable,
legacy-backfilled, notes-pending and transcribing rows;
- rows on sources that are pending, unsealed, transcribing, failed,
purge-pending, private, deleted or legacy donors;
- rows on a source whose stored document plus a few more claims would
pass the 1 MB document limit (`sources_blocked_size_limit`, the SCA-2791
shape). The dry-run reports this per partition before any write.
- *No audio purge.* The commit for a live re-derive writes only `claims`
on its sources, so it never arms or cancels an audio purge.
- *Speech coverage.* The pass blocks (`rederive_live_coverage`) and
writes nothing if any segment an eligible row held would not be in a
rebuilt or protected row.
- *Fail-closed blocks.* `rederive_live_open` covers speech within five
minutes of now, and is checked before any paid call.
`rederive_live_boundary` covers a window that would cross `since` or
`until`. `rederive_live_outline_failed` means a repair never commits
fallback failed tiles. `document_too_large` means a source's claims
would grow past the limit or a prior is too large to record, and is
checked before any write.
- *Partial failure.* Priors are written before the first commit batch,
and the run's own rows are recognised on a resume. So a commit that
fails after some batches can be resumed to finish, or undone exactly.
Retirement happens only in the final batch, so nothing is hidden before
its survivor exists.
- *Undo.* Before each commit, the run writes every changed, created or
retired row's stored document and its claims with their list positions
to
`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`.
- No copy outlives what it copies. Priors are never written for a
conversation already deleted, or once account deletion began. Deleting a
conversation a run stamped empties its priors and its bridges' priors to
a `purged` stub, 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, and `resume` and `undo` do 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.
  - Undo takes both builder leases and waits for in-flight notes.
- It restores each group of rows that share a source in one transaction:
documents back exactly and each source's claim list back in its original
order. A row the run created is hidden in that transaction, then erased
with the conversation deletion helper, so its child collections go too.
- It refuses after the owner deleted a rebuilt row
(`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.
- An interrupted undo is rerun as is. Rows it already restored, and
created rows it already hid (`v3_rederive_live_undone`), are finished,
not refused. That holds when they carry an earlier run's stamp, too.
- Restored rows pass through the recurring-voice fence the commit uses,
so a voice link the owner revoked is never written back.
- Undo refuses when a source named by the run is gone
(`undo_source_missing`). It checks every source of every group before
restoring the first group.
- A copy is never recorded at a protection level its row has left:
`save_priors` reads each row's level in its transaction.
- A resumed attempt keeps the first copy of a row, so claim positions
are the ones from before the run.
- Undo refuses once account deletion began (`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).
- The test compares every conversation document before the run with
after undo, byte for byte. In production, the Firestore commit hook also
stamps `home_source_version` and `home_content_invalidated` on 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_retired` and
`outline_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

- 34 of the sized day's sources are stuck `in_progress` for hours. They
count as unsealed, so rows on them stay protected and the dry-run
reports them as `sources_blocked_unsealed`.
- A late live speech append to a rebuilt row after the run is replaced
by the restored document on undo. The runbook states this.
- Before a partition settles, the run's own notes
(`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.
- Dry-run "after" counts outline each stretch as one chapter, so
`windows_after` is the fewest windows the run can produce and
`rows_retired_est` (eligible rows minus the windows that adopt one) the
most it is expected to retire. The run ledger has the exact counts.
- A partition whose final commit would exceed the transaction write cap
(sources + retired rows + row + lease over 450) blocks as
`backfill_partition_budget` before any write.

## Verification

Unit tests at the code layer only. Nothing ran against the emulator or
production.
- New `tests/unit/test_conversations_v3_live_rederive.py` has 58 tests,
plus two deletion wiring tests in
`test_merge_conversations_canonical_delete.py`. They run the real
loader, planner, commit transaction and undo transaction on the strict
in-memory Firestore:
  - the fragmented lunch folds into one card that keeps the earliest id;
  - hidden topic pieces of one stretch become one visible card;
  - a second pass over its own result writes nothing;
  - open windows and rows past `until` stay byte-identical;
  - edited and locked rows are skipped and keep their speech;
  - unsettled speech refuses before a paid call;
  - lost speech blocks the pass;
- undo restores every row and claim exactly, and a rerun of undo is
idempotent;
- undo refuses after an owner deletion, an owner edit (title, star,
photos) of a rebuilt or created row, a summary edit or merge after
baselines, a merge before baselines, or a newer run;
- an over-cap partition, a window crossing `until`, an oversized prior
and claims growth past the document limit each block before any write;
- a source already near the document limit is reported by the dry-run
and left alone;
- a commit that fails after its first batch leaves the absorbed rows
untouched, resumes to the full result, and undoes byte for byte;
- an undo interrupted before erasing a created row finishes on rerun,
and an undo of a later run over an earlier run's rows can be rerun, then
the earlier run undone;
- an owner star before the partition settles is never taken as the
baseline;
- priors are never written once account deletion began, or for a
conversation the owner deleted, and deleting a rebuilt conversation
purges its priors and its bridges' priors;
- undo refuses once account deletion began, and refuses a group too
large for one transaction before restoring any;
- the survivor lists its bridges in `sync_merged_from`, and the dry-run
reports unclaimed live speech and windows that would cross the edge;
- a deleted row whose claims are not yet released still fences its
speech;
- a card whose summary the owner rewrote is left alone, and undo refuses
after a summary rewrite made before baselines;
- deleting a retired bridge releases none of the survivor's claims, and
undo refuses when a named source is gone;
- a resumed attempt keeps the first copy of a row; a failed commit keeps
no copy of a row it did not write; a protection migration empties a
re-derived row's copies only after re-protecting it;
- a row deleted before its retirement fails the commit, and a card with
app results is left alone;
  - a failed commit empties the copies of rows changed meanwhile;
  - undo applies the recurring-voice fence;
- the run ledger counts unclaimed speech, and in a partial commit the
survivor does not list its bridges yet;
- a deleted or re-protected conversation keeps no undo copy and undo
refuses, a protection migration empties copies of stamped rows first,
and a restored row is recognised despite the commit hook's stamps;
  - the dry-run preview counts before and after and writes nothing;
  - the operator dry-run prints no uid and refuses the live edge.
- Main was merged in again (#25829 settle-on-landing stretches; the live
path keeps default timing). All `test_conversations_v3_*` files pass, as
do every test file that imports `merge_conversations` or exercises
`migrate_conversations_level_batch`. Two migration fakes gained
`to_dict`, which real snapshots have. The Firestore query-shape,
outside-query, index-oracle, runtime-witness and lifecycle-writer guards
pass, as do `check_conversation_lifecycle_writes.py` and
`check_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-ded2` on 10ce159: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek failed with an empty result. Triage:
- F1 (blocking) accept: undo now refuses when the owner edited a row the
run wrote or created. There are regressions for title, star and photos
on both kinds of row.
- F2 (blocking) accept: a created row is erased through
`database.conversations.delete_conversation`, which also deletes its
children, after the transaction hides it and drops its claims.
- F3 (major) accept: the write cap is checked before priors or commit.
Regression test added.
- F4 (nit) accept: renamed and recomputed as `rows_retired_est`.

Panel `review-20261119t202258-de84` on 8b07afc: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek timed out. Triage:
- F1 (blocking) accept: a settled partition records an owner-surface
digest per row (title, overview, edit fields, visibility, lock,
deletion, merge), and undo refuses when it changed. There is a
regression for a summary edit.
- F2 (major) accept: a rebuilt row merged away after the run refuses
undo, both before and after baselines, and a retired row must still be
the run's bridge to its survivor. Regressions added.
- F3 (minor) accept: an oversized prior blocks as `document_too_large`
before any write. Regression added.
- F4 (minor) partly accept: added the `rederive_live_boundary` block
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,
because `speech_moved` is false for them and any concurrent change fails
the revision fence as `source_changed`.
- F5 (minor) reject: retired rows lie inside their survivor's span, and
the smart-merge barrier gap begins at the survivor's `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-f141` on 7a6d35b was invalid: an early
`omi-panel collect` removed its checkout while members ran. Its one
finding (checkout missing) was rejected and the panel rerun.

Panel `review-20261119t212417-ad5e` on 7a6d35b: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek timed out. Triage:
- F1 (blocking) accept: `save_priors` reads the account-deletion marker
in each transaction and refuses (`account_deletion`). Regression added.
- F2 (major) accept: `record_baselines` first checks the row against its
prior. A row the owner changed before the settle gets a baseline that
never matches. Regression added.
- F3 (major) accept: a row equal to its prior is already restored,
whatever stamp it carries, so a rerun is not `undo_newer_run_first`.
Regression added for run-over-run.
- F4 (major) and F7 (minor) accept: the undo's hide stamps
`v3_rederive_live_undone`, and a rerun erases such rows instead of
refusing. Regression added.
- F5 (minor) reject, and the case is now reported: `recording=True`
without `v3_backfill_run` is written only by v3 capture. Legacy
conversations are not recordings, so they are never loaded as sources,
and converted donors are blocked as `backfill_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 as
`sources_unclaimed`, so the operator sees it first.
- F6 (minor) reject: before a partition settles, `structured`,
`apps_results` and 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.
- F8 (nit) partly accept: added a `classify_live_window` count test. The
`source_changed` fence for live sources is the existing revision fence
in `commit_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-1af6` on eeb6bda: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek failed with an empty result. Triage:
- F1 (blocking) accept: priors are purged when a stamped conversation is
deleted, along with its bridges' priors, in every live run of the owner.
A finished undo drops the run's priors. `save_priors` refuses a
conversation already tombstoned. Regressions added, including the
deletion wiring.
- F2 (blocking) accept: each undo transaction reads the account-deletion
marker and refuses. Regression added.
- F3 (blocking) accept: the survivor's `sync_merged_from` lists 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.
- F4 (major) accept: the estimate copies every `sources_` count, so
`sources_unclaimed` reaches the preview. Regression added.
- F5 (major) accept: undo checks every group's writes and bytes against
one transaction before restoring any, and refuses with
`undo_group_too_large` rather than failing midway. Regression added.

Panel `review-20261119t225938-d579` on 7d8cfcc: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek failed with an empty result. Triage:
- F1 (blocking) accept: a protection-level migration of a stamped row
first empties its priors to a `purged` stub, so no copy stays at the old
level. Regression added, including the migration wiring.
- F2 (blocking) and F4 (minor) accept: the purge pages through every run
ledger by id, with no 200-run cap.
- F3 (blocking) accept: `data_protection_level` is 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.
- F5 (minor) accept: the rerun check compares rows apart from the commit
hook's stamp fields, and the PR states that a restore is exact apart
from those two fields. Regression added.
- F6 (nit) accept: the dry-run reports `windows_crossing_edge`.
Regression added.

Panel `review-20261119t235010-7c85` on 49d66c9: FIX-FIRST. All three
members completed. Triage:
- F1 (blocking) accept: when the commit fails after the copies were
written, the copies of rows the owner deleted or re-protected in that
gap are emptied to stubs. The commit's revision fence makes any such
change fail the commit, so the gap is always caught there. Regression
added.
- F2 (blocking) accept: the survivor's `sync_merged_from` is staged with
the retirements and lands only in the final batch. Regression added: in
a partial commit the survivor lists nothing.
- F3 (major) accept: deleted rows are offered as protected finished
rows, so their unreleased claims fence the replan (`protected_deleted`).
Regression added.
- F4 (minor) reject: the purge runs only for rows a live run stamped,
and only over that owner's live runs, which are operator runs counted in
single digits per day. Undo already refuses on the tombstone, so
deferring the purge would only keep the copy longer.
- F5 (minor) accept: the group size counts each prior's claims and up to
64 KB per source claims list.
- F6 (minor) accept: restored rows go through `filter_processing_write`
inside the undo transaction. Regression added.
- F7 (minor) reject: a source's claims are a set keyed by conversation
and span, and no reader depends on their list order. Exactness is tested
when nothing else moved. When another row's claims moved meanwhile, the
restored set is still exact.
- F8 (minor) accept: both regressions added (partial-commit survivor and
the run ledger's `sources_unclaimed`).
- F9 (minor) reject: an owner-day is 1–3 partitions of at most about 250
priors, so re-listing costs under 1,000 reads per run, against the
commit's own writes of about 700.
- F10 (minor) accept: a live run keeps the loader's `sources_unclaimed`.
Regression added.
- F11 (minor) reject: the re-derive repairs window boundaries. Rewriting
every row whose stored status or tile differs would re-run notes for
windows that did not change, which the brief excludes. Stuck notes
belong to the summary repair path.


Panel `review-20261120t002457-a83a` on 36e529d: FIX-FIRST. All three
members completed. CI on 36e529d was green. Triage:
- F1 and F2 (blocking) accept: a card with notes, an overview and no
generated sections counts as owner-edited. It is protected, and before
baselines undo refuses it. This is the convention main's refinement
uses, because the summary endpoint writes no separate marker. App-result
edits have no marker at all, so they are caught only once baselines
exist.
- F3 (blocking) and F8 (minor) accept: the retire patch now carries
`v3_claims_transferred_to` and a bumped `sync_content_revision`, as a
sync merge's absorbed row does. Regression added.
- F4 (major) accept: the migration empties only the copies of rows it
actually re-protects. Regression added.
- F5 (minor) accept: undo refuses (`undo_source_missing`) before writing
anything. Regression added.
- F6 (minor) accept: regression added for deleting a bridge.
- F7 (minor) reject: `classify_live_window` tests `deleted` and
`sync_merged_into` first, so every bridge the run writes counts as
deleted. No path clears `deleted` on a bridge.
- F9 (nit) accept: `save_priors` keeps an existing copy, so a resumed
attempt records nothing over the first. Regression added.

Panel `review-20261120t010840-047f` on c3c99c5: FIX-FIRST. Only Luna
completed; DeepSeek returned an empty result and GLM Flash timed out. CI
on c3c99c5 was green. Triage:
- F1 (blocking) accept: `save_priors` reads 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.
- F2 (major) accept: the undo pre-check reads every source of every
group before the first group restores. Regression added with two groups.

Panel `review-20261120t014903-c9eb` on 4de3684: FIX-FIRST. Luna and GLM
Flash completed; DeepSeek returned an empty result. CI on 4de3684 was
green. Triage:
- F1 (blocking) and F7 (nit) accept: the migration empties copies only
after it re-protects a row, for every row stamped at that moment.
Nothing is purged before, so a failed migration leaves undo intact.
Regression added.
- F2 (blocking) accept: the commit checks tombstones for the rows it
retires. Regression added. The deletion-path half is closed by the
invariant under F5.
- F3 (major) and F5 (major) accept: every copy now belongs to a row its
run stamped, because a failed commit drops the copies of rows it did not
write. That means the stamp-gated deletion and migration paths reach
every copy, and a resume records fresh copies under the level fence.
Regressions added.
- F4 (major) accept: rows with app results are protected
(`protected_app_results`). The owner can edit those with no marker, and
a replan never regenerates them. The dry-run counts them. Regression
added.
- F6 (minor) reject in code, and documented instead: a capture longer
than one partition makes both partitions' windows cross the edge. The
dry-run already reports this as `windows_crossing_edge` before any
write, and the operator widens `since`/`until` or 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-3445` on cac9f55: FIX-FIRST. Only Luna
completed; DeepSeek and GLM Flash timed out. CI on cac9f55 was green.
Triage:
- F1 (blocking) accept: the migration purges after its rows and photos
are written, and records re-derived rows on every attempt. So a retry
purges even when the row is already at the target level. Copies already
at the target level, and copies of created rows, are kept. Regressions
added.
- F2 (blocking) reject: a copy exists only for a row that passed
protection, and protection refuses any row with a set owner field (star,
folder, photos, user title or overview, and so on). So a prior's owner
fields are always unset, and clearing one cannot differ from the prior.
Setting one is caught. After settle, the baseline digest compares by
equality.
- F3 (blocking) accept: the cleanup that drops unwritten copies runs for
every failure, not only `Conflict`. If the cleanup itself fails, the
partition stays unfinished until resume or undo. Regression added.

Panel `review-20261120t031408-74ad` on b8b9a68: FIX-FIRST. Only Luna
answered; DeepSeek returned an empty result and GLM Flash an invalid
one. Triage:
- F1 (blocking) accept, closed from the run side: each attempt and each
undo first drops the run's copies of rows no run stamped since the copy,
which covers a hard stop between recording a copy and stamping its row.
A row a newer run restamped keeps its copy, so undo still waits for that
run. Regression added. Not taken: purging on every deletion regardless
of stamp. That broke five deletion test suites built on fake clients,
and it would add a run-ledger read to every product deletion.

Panel `review-20261120t035349-fb30` on 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:
- F1 (major) accept: each partition reads only its own copies, by id,
before its commit and when it settles. The settle step gets the ids from
the partition ledger (`prior_ids`). The full scan for stale copies runs
once per `resume` and once per undo. The budget entry states this.
Regression added: a partition run with `list_priors` made to fail.
- F2 (major) reject: a retired bridge is `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-surface `data_protection_level`, so undo refuses the run
(`owner_edited_rebuilt_row`).
- F3 (minor) accept as documented: a run whose undo refuses for good
keeps its copies until the owner deletes the touched conversations or
the account. The runbook says so, and says the copies are dropped by
hand only with the owner's approval, since that gives up the undo. No
release command was added, so priors are never dropped as a side effect.
- F4 (nit) reject: as designed and documented. Whether a window crosses
an edge depends on the outline's windows. The dry-run reports
`windows_crossing_edge` before any paid call, so the operator widens the
window first.
- F5 (nit) accept: the loader's range overflow now blocks as
`rederive_live_range_overflow`, and `backfill_partition_budget` means
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-1ca3` on c5aadce: FIX-FIRST. All three
members completed. Triage:
- F1 (blocking) and F5 (minor) reject, documented as a known limit:
`process_conversation`, which the run's own notes use, writes both
`discarded` and `apps_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 into `CHANGED_BEFORE_SETTLE` and 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.
- F2 (major) reject: only deleting a row a live run stamped reaches
`_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.
- F3 (major) accept: `prior_ids` is 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.
- F4 (minor) reject: this is intentional (panel 3445 F1). A retry after
a failed purge must purge even when the row is already at the target
level. `keep_level` makes that purge write nothing for copies already at
the level, and only rows a live run stamped pay its reads.
- F6 (minor) reject: the test already pins `rows_unchanged`,
`rows_retired` and `priors_recorded`, and asserts that no later
transaction sets, updates or deletes a conversation.
- F7 (minor) accept: the retire patch clears `summary_due_at`, as main's
absorbed-row patch does. The site is declared in the lifecycle writer
inventory. Regression added.
- F8 (minor) reject: the branch is reachable. An eligible row with no
spoken segments adds nothing to the coverage set, and when no rebuilt
window overlaps it, it stays as it is (`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](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant