Repository navigation
feat(conversations-v3): cut at sit-downs when the silence gap is over five minutes - #25829
Conversation
… five minutes Under CONVERSATIONS_V3_SILENCE_GAP_SECONDS above 300 (#25794's setting; default 300 leaves today's behaviour unchanged): - the outline sees pauses of 2 minutes or more as marker lines, and a sit-down rule replaces the hard-boundary sentence; - neighbouring conversation entries of a stretch join into one card, with short dictation between them as a section; - each card meets the Home word minimum on its own words. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cument the long-gap switch Panel review-20261119t234312-028e: - F1: neighbouring conversation entries that both name people and share none stay separate cards; - F2/F3: the runbook, flag declaration and registry say what a gap above 300 s does and that 300 turns it off; - F4: the one-open-window test now plans one joined window over two open preview rows, and fails if preserve_finished_windows stops finishing all but the last. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…under a long gap With a gap over 300 s, continuous speech forms multi-hour stretches. _capped cut them at the middle, which moves as live speech arrives; every part but the last locks, so each builder pass froze a new prefix and stranded the lines between cuts as one-line cards (lab, 11-18 at 900/900: 212 of 246 cards under 2 minutes; one 10-minute recording became 15 cards). Under a long gap the cut is now the last boundary within two hours of the stretch start, so later speech never moves an earlier cut. Default timing keeps the middle cut. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iming from landing Review of #25829 at 12efb32 (FIX-FIRST): - The two-hour cap now cuts after the longest prefix that ends within two hours of the stretch start, at every timing and ignoring outline sections. Neither live speech nor a paid outline revision moves a cut whose prefix already locked. - Under custom timing, lock age counts from the later of the stretch's last speech and when it landed. mark_pending stamps v3_speech_landed_at (same transaction, no new write), so a batch of old speech from offline sync no longer locks on arrival and strands the next batch as a new card. Default timing still counts from speech. - New multi-pass reconcile tests (real reconcile and commit on the strict fixture): (a) one open id for a 10-minute live recording at 900/900; (b) aged offline batches build one card under custom timing; (c) the cap cut survives the first paid outline and a later outline that drops a section, at 300 and 900. Each fails on the code it guards against (checked by mutation). - Engine and cohesion cap tests updated to the new cut; their section-rebasing and resume-partition checks are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment, reuse committed cap cuts - v3_speech_landed_at is written by the transaction that makes speech and v3_pending visible (update_conversation_segments for new speech, sync assignment append/create for recordings, the batch recording create in _mark_resolved). mark_pending no longer stamps it, so a reconcile that runs between the speech commit and changed() already sees the landing time. No added write. - preserve_finished_windows: a row that already holds a segment (id and timing) keeps it on later passes. Overlapping turns at a cap cut no longer move into the neighbour whose window and clipped claim contain them. - The two-hour cap cuts at a locked row's end before anywhere new (planner.windows committed=), so rows cut by main's middle cap, or by an earlier pass, keep their cut after upgrade and on a backfill resume, and the old open tail stays one card. - Tests: reconcile between the speech commit and the re-arm (fails without the stamp), sync assignment stamp and exact-retry preservation, derive ignores the landing clock, two-pass overlapping-turn ownership with non-overlapping claims, upgrade from main-cut rows, backfill resume of a main-cut run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a speech change - The two-hour cap reuses a locked row's cut only through the lines that row holds: when a locked row holds a part's first line, the part ends at the first line it does not hold. An unrelated locked card ending inside an over-cap stretch no longer cuts it, and an old cut that a turn straddles is still recognised, so the new cap never cuts into main's old open tail. - update_conversation_segments stamps v3_speech_landed_at only when the speech (id, timing, text) changed, so a no-op full write or retry does not extend the lock. - Tests: unrelated locked row control and the positive control (cohesion on and off), upgrade from a main cut that a turn straddles (300 and 900), no-op full write keeps the landing time. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…onalCall) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ct segment or audio claim) A transcript revision gives a held turn a new id while its audio stays inside the locked row's claim. The cap's ownership lookup now counts a line wholly inside a locked row's claim on that recording as owned, so reuse neither stops at a revised interior turn nor is bypassed by a revised first turn. A straddling turn is not inside the clipped claim, so the straddle case is unchanged. Test: main-cut seed, then the first and an interior held turn revised over two passes at 300 and 900; the locked boundary, its claims and the open id stay put. Co-Authored-By: Claude Opus 5.5 <[email protected]>
planner.Ownership.owner_of(line) is now the only ownership decision, used by _capped (cut reuse and finality) and preserve_finished_windows: 1. an exact hold of the segment from the line's own recording (v3_recording_ids), across every loaded row, locked then open; 2. only without one, containment in a row's window and audio claim on that recording, locked rows first (_contains_line). The cap reuses a cut only when a locked row owns the part's first line, and ends it at the first line another row or no row owns. A turn published in the open tail whose audio lies inside the locked prefix's claim therefore stays in the open tail instead of being finished with the prefix, and an exact hold on a later locked row beats an earlier row's claim. _holder is gone. Tests: open-tail turn inside the prefix claim (300 and 900, multi-pass: same open id, no finished fragment, one owner per segment); exact hold on a later locked row beats a claim (cap and projection) and needs the line's own recording. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in, one ownership index per plan - Ownership keeps deleted locked rows (tombstones) as owners of their lines, so routing isolates the deleted speech in the tombstone's own skipped window and the valid turns either side are not joined into one window that time-matches the tombstone and is dropped. The cap never reuses a tombstone's cut. Deleted open rows own nothing, as before. - Exact holds: a row naming the line's recording in v3_recording_ids wins over a legacy row that names none, wherever the legacy row sorts. - service builds one Ownership per plan() and passes it to the cap and both projections. - Tests: speech either side of a deleted card survives (300/900, service level, tombstones loaded as store.load does), tombstone never pins a cut, source-qualified beats legacy, deleted open row owns nothing, exact needs the same timing, one index per plan. Mutation pass: 14 ownership mutations, all caught. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged at head 2bb5bfc (merge commit c38aa71) on David's decision of 2026-11-20 to accept the default-timing replay range. Lab replay of 11-18 at default timing, scored against the reviewed ideal Home:
The range is noise in the replay itself. The lab driver stamps each pass with real elapsed time, so the same inputs settle into one of two outcomes per run. 8041a6e produced both outcomes, and runs that land in the same outcome match card for card. The cards that differ between outcomes are topic cuts inside stretches under two hours, which this PR does not change. A deterministic driver is a lab follow-up. Round 7 (tombstones, legacy precedence, one ownership index per plan) and the mutation pass over the ownership tests (14 of 14 caught) are described in the PR body. CI is green, 64/64. Still held: the custom-timing ramp (CONVERSATIONS_V3_SILENCE_GAP_SECONDS / CONVERSATIONS_V3_LOCK_SECONDS). It will be scored on merged main before the release owner gets a go/no-go. Follow-up from review, predating this PR: the retained-row duplicate check ignores speaker identity. |
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]>
…th an agent guide (#25862) The pipeline lab replays one recorded day through a ref's real pipeline code against local emulators. You can then compare, card by card, what that ref would have built with what production built that day. It is how the v3 sit-down work (#25794, #25829) was measured. This PR lands the lab on main so every agent works from one copy instead of a long-lived lane branch. ## Scope - **What it touches.** Everything is under `backend/testing/pipeline_lab/` and `backend/tests/unit/test_pipeline_lab_*.py`, plus: - one `make pipeline-lab ARGS=...` target; - a size budget for the new lab `AGENTS.md` in `.github/scripts/check_agents_md_lean.py`, set to its size at creation; - one `exempt` entry in `.github/firestore-collection-budgets.json` for `parakeet_batch`. That is the lab's STT adapter name, not a collection: the collection-budget scanner resolved unrelated `.collection(name)` parameters in `backend/database` to it. - five node ids in `backend/tests/fast_unit_duration_allowlist.txt`. The first test of each of those lab files drives real product code and pays its import chain in its call phase. - one reviewed edge in `backend/tests/unit/fixtures/sync_legacy_import_baseline.json`. The lab's sync-lane replay imports `utils.sync.pipeline` as its subject, and is deleted with that module in C11. - **What it does not touch.** No product module imports the lab, no service or deploy path runs it, and no workflow is added. - **Contents.** - Run store and spend ledger. - LLM record/replay proxy with a hard cap. - Pinned per-ref worktrees. - Stage registry and CLI. - Seeder, chain and v3 drivers. - Inspector. - Ideal-day scoring. - Read-only v3 exporter. - **Agent guide.** `backend/testing/pipeline_lab/AGENTS.md`, linked from the lab README, records what earlier agents got wrong: - replay bistability at default timing (repeat runs, report ranges); - no text in reports; - one replay at a time on the shared emulator; - never killing `dev_harness` supervisors by pattern; - harness parity with `store.load` (tombstones); - mutation passes for custody tests; - cleanup. - **`ideal/runs.py`.** It replaces the per-session scratch scripts: a score table against the day's ideal and a per-card diff across runs. It prints times, counts and flags only. - **`ideal/score.py`.** A line two conversations share now goes to the earlier-starting one. It used to go to whichever file the directory listing returned first. With overlapping cards that made the score depend on file order: Home precision on one 11-19 run came out 1.00 or 0.67. - **Speaker labels.** No raw speaker interpolation: - stored `SPEAKER_NN` labels come from `contracts.wire_speaker_label`; - the Home-judge prototype (`ideal/jevhome.py`) labels unnamed voices with the display authority's `SpeakerLabeler`; - the STT cassette's per-window diarization id comes from a named helper and is never shown as text. - **`v3/fake.py`.** It now accepts `max_events`. Without it, every fake-engine v3 run exited 2 after the options gained that key. ## Privacy and production - **The store refuses any root inside a git worktree.** Private data lives under a 0700 root outside git. Tests use synthetic fixtures only. - **Replays never touch production.** They write only to local emulators under the synthetic uid `local-dev-user`. - **`v3/prod_export.py` is the only production reader.** It is an operator tool, run by hand under a read-only GCP agent tier for one consenting owner and one day. - It reads that owner's v3 recordings and derived conversations for the day window. - That is one day's rows, a few hundred to a few thousand reads per run. - It has no schedule and nothing calls it automatically. - **No credential, uid, name, conversation id or transcript is in the diff.** The owner uid and the gateway token are read from 0600 files by path at the moment of use. ## Verification Run on `m5-mbp`, at this branch rebased on `origin/main`: - All 29 `tests/unit/test_pipeline_lab_*.py` files pass, each in its own process, as CI runs them: `bin/omi-heavy run -- .venv/bin/python -m pytest FILE -q`. - New tests: - `test_run_diff_reports_boundaries_and_home_flips_without_text` (the output carries no segment text); - `test_a_shared_line_goes_to_the_earlier_conversation_whatever_the_input_order`, which fails on the old scorer. - `ideal.runs score` and `ideal.runs diff` match the scratch scripts on the 11-18 and 11-19 replays. The one exception is the order fix above. - The lab's real-day replays for #25829 ran on this code, before the last commit's docs and tool. ## Review There were two panel rounds: - Round 1 had 17 findings: 16 fixed, 1 rejected with a reason. - Round 2 had 14: the blocker and 7 others fixed, 6 deferred. Under R28 only blockers block. Main fixes: - Exporter outputs are owner-only and never follow symlinks, and the git probe fails closed. - The write fence also refuses deletes and Redis pipelines. - The owner uid is redacted from every log record during an export. - The proxy allows plain HTTP only to loopback. - Pinned arms are refused when they contain untracked Python. - Lab roots and ids are validated before any write. - The CodeQL ReDoS and header-injection alerts are fixed. ## Follow-ups (not blocking) - **v3 Home visibility.** `v3/export.home_visible` should follow the product's `is_visible_conversation(hide_home=True)`: dream duplicates, bridge-pending and settling fragments. - **`corpus add-day --replace`.** It should clear optional v3 and audio artifacts the new snapshot omits. - **`run --in-place`.** It should record the sha of `HEAD`, not the requested ref. - **`decisions.jsonl` appends.** They should take an `flock` across the orchestrator and arm processes. - **Product logging.** `utils/encryption.decrypt` logs the uid on failure. The lab redacts it, but the product log line itself is a privacy follow-up. - **Replay determinism.** Stamp v3 passes on the simulated clock so default-timing replays are deterministic (see the lab `AGENTS.md`). Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…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)
Builds on #25794 (merged as 755558a): sit-down cutting when its silence gap is set above five minutes.
DESIGN:
CONVERSATIONS_V3_SILENCE_GAP_SECONDS(fix(conversations-v3): configure boundary timing and merge locked windows #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.---- 4 min without speech ----). A sit-down rule replaces the "N of recorded silence is a hard boundary" sentence. Line numbering is unchanged.conversationentries 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.planner.Ownership.owner_of, built once inplan()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 inv3_recording_idsahead 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 throughowner_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.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.CONVERSATIONS_V3_LOCK_SECONDS.READBACK:Home cards per active v3 owner-day, and thebelow_word_minimumshare 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,plannerandvisibilitycode 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):
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): realreconcile+commit_projectionpasses 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.Ownershipper plan.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. Withtest_conversations_v3_stretch_cohesion.py, expectations moved to the stable cut.test_sync_assignment_recovery.pyleaks 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)
Product invariants affected
none
Failure class (fixes)
Failure-Class: none
🤖 Generated with Claude Code