Repository navigation
fix(v3): size cap measures the real stored transcript size (no mid-speech splits) - #26705
Conversation
…eech splits) The SCA-2918 cap estimated each line at 3 * (json + 64) bytes with no compression, about 5.6x the stored transcript_segments field, so ordinary long conversations were cut mid-speech near line 400. Measure the field the derived-row writer stores instead (speaker sidecars, zlib JSON, enhanced hex + AES-GCM base64), encode the whole part once and binary-search a cut only when it reaches the 900 KiB budget. The two-hour cap, locked-row cuts and the CONVERSATIONS_V3_TRANSCRIPT_SIZE_CAP switch are unchanged. Failure-Class: new
…e proportional guess Failure-Class: new
…e atomic at a time cut Failure-Class: new
…check Failure-Class: new
…eplacing it Round-1 packed rows to 900 KiB of real stored bytes, which leaves no headroom for subset re-encoding at sidecar capacity, late speech or other fields, and its prefix search was non-monotone around capacity transitions. Restore main's additive estimate and _capped cut byte-for-byte. When the estimate would size-cut a window (offset to the two-hour cut) or block a resumed merge, measure that window once with the writer's codec (real protect_segments on a deep copy, seeded sidecar filler, zlib, enhanced length). At most 512 KiB keeps it whole; otherwise, or on any probe failure (including evidence encryption), main's cut applies unchanged. No measurement runs unless the estimate exceeds the budget. Failure-Class: new
…strict, stable, bounded probe The pre-routing probe can be fooled when ownership routing restores evidence a conflict or capacity drop removed. The reconcile pass now builds each gate-widened fresh or unlocked row after routing and sizes it with the commit's own codec (conversations_v3.encode_row, transcript inline). Over 768 KiB field or 900 KiB document, that stretch is planned again with exactly the estimate's cuts. The gate is opt-in (reconcile only); backfill keeps main's cuts. The probe budget is 384 KiB; probes are strict in the timing fallback too (ProbeFailure, distinct from EvidenceCapacity), use a fixed shadow expiry, run at most twice per stretch per pass, skip windows over 2,000 lines, and the resumed-merge probe runs only for an otherwise allowed merge. Planning runs off the event loop. Failure-Class: new
…heir own modules conversations_v3_row_codec owns encode_row and stored_size (one codec for the commit and the size check); v3/size_gate owns the post-routing check. Re-review the commit_projection query-coverage digest: no new Firestore query. Failure-Class: new
…al row stores Planner is main's cut for cut; it only marks boundaries the size estimate alone made. v3/size_merge re-plans without them, builds the rows as committed, and keeps a merged row only if every boundary is main's and the commit codec's encoding is <= 768 KiB field and <= 900 KiB document. commit_projection writes that checked encoding on every attempt. Removes the pre-routing gate, probes and size_gate. Failure-Class: new
…coding prepare Failure-Class: new
…og each judged merge _capped with keep ends a window that would pass the two-hour cap at its last kept size cut (one of main's) instead of at a new time cut, so stretches over two hours merge between main's cuts. keep empty is main's behaviour. Each merged row the final-row check judges logs event=v3_transcript_size_merge outcome=merged|kept_oversize|kept_error|kept_locked parts field_bytes doc_bytes (no uid, no text). Lifecycle inventory names the moved build() sites. Failure-Class: new
Failure-Class: new
…rged rows, keep speaker evidence - size_merge.check encodes every row of the merged plan with the commit codec and carries each encoding; any row over the limits or failing to encode means main's rows (kept_sibling). - FIELD_LIMIT 400 KiB, DOCUMENT_LIMIT 480 KiB: a later late append as large as the row fits Firestore. - A stored row owning lines on both sides of a main size cut is planned as locked at its extent (Ownership.locked_ids), so no plan moves published speech out of it. - A merge keeping fewer speaker placements than main's rows (commit codec round trip) is rejected before build, and its checked bytes are re-read: kept_evidence. Failure-Class: new
…dget Failure-Class: new
|
@Git-on-my-level handing this PR to you (Nik's call). It is now a draft, and nothing here is deployed. Current head is Root cause. What this PR does. Main's planner is kept cut for cut.
The commit writes exactly the checked bytes. Result on a real 65-minute, two-speaker recording (702 segments). Main cuts it 400 + 302. This PR keeps one row:
Why it can't merge. Round-5 review, three regressions versus main:
Rounds 1–5 of the review notes and the real-recording replay harness are with Nik. The harness runs |
|
@Git-on-my-level assigned to you. Two questions only you can answer:
|
|
@Git-on-my-level update: per Nik we're taking this back and finishing the custody piece here (round 6: size-checked late appends with a continuation row, merges only for final rows, exact provenance). No need to pick it up; review is welcome. |
…nal rows; exact speaker provenance - v3/locked_append: a locked row gaining late lines is encoded with the commit codec first; over 768 KiB field or 900 KiB document it keeps exactly its published lines and claims and the late lines go to a new continuation row. Applies to every locked row, main's included. - size_merge: remove the inferred pin; a merged row must commit final in this pass (not planner.is_unlocked), so live and provisional cards grow exactly as on main (kept_live). - size_merge: every line occurrence of the candidate plan must decode and reveal to exactly the provenance (provider, unit, label, timing store) of main's built rows; any reveal rejection, decode failure or changed binding means main's rows (kept_provenance). Failure-Class: new
Failure-Class: new
…-evidence budget, every row size-checked Production: all 215 mid-speech size splits in 24 h were made while the stretch was live, so the final-only merge could not apply. The size merge, provenance comparison and their hooks are gone. - planner._capped keeps main's append-only cuts, two-hour cap, locking and ownership. A size cut lands at TRANSCRIPT_BUDGET = 2 x 900 KiB, or before the part's speaker evidence passes 70% of the timing-fallback caps (per line from the compact record the storage writes), or before a segment id it already holds. - v3/size_check encodes every row with the commit codec; a stretch with a row over 768/900 KiB is planned with main's 900 KiB budget, a published row it would cut locked at its stored extent. Rows are written as exactly the checked bytes. - v3/locked_append (round 6) unchanged: late lines past the limits go to a continuation row. Failure-Class: new
…jection's digest Failure-Class: new
…e checked encoding Failure-Class: new
Failure-Class: new
…ontinuation only past Firestore's hard limits, for new speech only - planner._Evidence counts each unit's envelope exactly as speaker_grouping_storage serializes it, the compact-record total and their exact encrypted lengths, against 95% of each hard cap, and ends a part before a unit's second timing store. The owner's 702-line dinner (units of 679 and 23 lines) is one row; the 70% margin had split it 609 + 93. - locked_append routes late speech only when the grown row, with the commit's settle stamp, would pass Firestore's hard limits; a failed probe takes main's path. Held vs new speech uses the row's own append dedupe (planner.present_in, extracted unchanged from build). Continuations are cut by main's budget and carry no parent title or sections; with nothing held the locked row is left unwritten. - size_check carries every row within the hard limits as its final encoding, and replans only planned (not locked) rows past the soft limits. Failure-Class: new
…tally's fields for the type checker Failure-Class: new
…d rows past hard limits; keep a published live card across re-outline - size_check.prepare encodes as the commit writes (codec and settle stamp) and reads back every line's speaker placement from those bytes; a degraded encode is retried once and never cached. Evidence loss on a planned row plans its stretch with main's budget; only storable, intact bytes are carried. - A row with a stored prior still past a hard limit freezes that prior: kept exactly as stored with its claims, its new lines in bounded successors. - locked_append routes late speech to continuations when the grown row would lose speaker evidence, not only past the hard limits; continuations are cut by bytes and evidence. - commit_projection refuses any staged row or source claim update past Firestore's hard limits before it is sent, with Firestore's own rejection, so the existing park path applies. - planner keeps a published live card longer than main's budget whole across a re-outline: a topic starting inside it becomes a section. Failure-Class: new
…ished-extent re-outline, quiet probes - A frozen prior is built as a locked row over the lines it holds: stored transcript and claims kept, End and processing still run on it; only new speech moves. - staged_sizes measures each field value and the document by Firestore's storage-size rules, shared by the size check and the commit guard, after the configured settle stamp; a guard rejection names its conversation id for the one-seed size quarantine. - Re-outline protection is decided by what the card published (its stored lines), only with the size cap on; ownership just locates it. - Candidate and probe encodes are quiet; speaker_grouping_storage.quiet() reports codec failures apart from capacity drops. Exceptions and degraded results retry once; a codec that keeps failing leaves the row to the normal writer instead of routing or replanning. Failure-Class: new
…ty; codec faults and telemetry follow the written payload - locked_append.split holds every line inside a span the row already claims (re-issued ids or text), as well as the append dedupe; frozen and overflowing locked rows write exactly their stored transcript, and only unclaimed speech goes to continuations. - planner.build marks v3_size_extended once a card's lines exceed main's budget under the size cap; the mark survives live rewrites and re-outline protection reads it only with the size cap on. - size_check.prepare treats any codec fault (encode, encryption, authentication, readback) as no cache plus one retry; a persistent fault leaves the row to the normal writer. Quiet encodes keep the outcomes they suppressed, and the final plan reports them once for each payload written as checked. - lifecycle inventory declares locked_append.as_locked, a read-only builder view. Failure-Class: new
…dget Failure-Class: new
…rs the card's claimed span; telemetry after the write lands - Rule A: Ownership.freeze makes a frozen row own, as a locked run, every line whose audio overlaps its claims by any amount (planner.claimed_overlap, also used by locked_append.split). planner.build builds a frozen window over the stored transcript alone, so extent, claims, v3_size_extended and sync_content_revision are the stored version's own. Removes locked_append.keep_published/as_locked. - Rule B: an outline cut inside a protected card's claimed audio interval becomes a section, whoever owns the neighbouring lines; on a finished stretch preserve_finished_windows holds the card's own lines apart, so an unowned turn inside gets its own row. - The suppressed speaker-storage outcomes travel with the checked encoding and are reported once, after that row's successful write (report_written); a discarded plan reports nothing. Failure-Class: new
Failure-Class: new
…seed quarantine A published row exceeds Firestore's hard limits only if the same audio's stored transcript more than about doubles (rows publish near 330-400 KB and the pre-commit check bounds new rows at 768 KiB). That case now takes main's own overflow path: the exact staged guard refuses the write before it is sent, naming the document in Firestore's message, and the pass parks with the one-seed quarantine. - Removes Ownership.freeze and frozen_ids, planner.claimed_overlap, the frozen build window and its service hooks, and size_check's hard set. - Locked late appends classify held vs new speech with main's own append dedupe again. Failure-Class: new
…aim late turns stay on the locked card Round 14 review of #26705: - A commit-guard rejection of the lease's open window is charged to the seeds whose claims feed it, and load skips that window while all its sources are quarantined, so independent recordings keep committing. - An overflowing locked append keeps new turns inside the card's own claimed audio on the card when it still fits; only the rest goes to continuations, so every routed turn stays playable. Failure-Class: new
…m-bound late turns stay; honor the size-cap switch Round 15 review of #26705: - A published open card that fallback would keep at its stored extent but whose rebuild passes a hard limit is released and cut by main's budget, so the pass commits main's partition. The round-13/14 park attribution and the open-window load skip are reverted to main; locked rows keep main's park. - A locked append that overflows keeps every new turn inside the card's own claims whenever that is within the hard limits, even past full-evidence capacity (the codec's fallback, as main); only speech outside its claims is routed. - CONVERSATIONS_V3_TRANSCRIPT_SIZE_CAP=off runs main's plan, append and writer, keeping only the staged hard-limit guard. Failure-Class: new
…en late speech stays on the visible card Round 16 review of #26705: - An open row whose rebuild fails the hard check joins Ownership.released, which both the stored-extent pin and _keep_published skip, so the retry applies the actual topic and size cuts instead of rebuilding the whole card into the guard. - During evidence-only overflow of a locked append, a continuation Home would hide as its own row is not created; its speech stays on the visible card without its own placement. - The words replay asserts main-budget compliance and the safety properties, not an exact partition. Failure-Class: new
…placement that fits; required continuations show as their owner Round 17 review of #26705: - The hard release installs main's 900 KiB budget for the stretch before retrying, so the released outline and size cuts apply together (main's partitions from the same wide card). - Speech kept on the visible row during evidence-only overflow keeps its own placement unless that would cost one the row keeps without it (probed both ways on the commit's bytes). - A continuation the hard limits require under a visible owner carries the owner's passed word gate, so it is visible on its first write. Failure-Class: new
…ate-turn evidence chosen turn by turn Round 18 review of #26705: - A continuation the hard limits require records its owner (v3_home_owner) and, on every build while the owner stands, takes the owner's effective Home fields, whatever its own classification; its kind and End ownership are untouched. - Home-hidden late turns kept on the visible row are walked in order: each keeps its own placement only if a probe with it keeps every placement already retained within the hard limits. A locked row's probed storable bytes are the ones committed. Failure-Class: new
…he planned owner; capacity-chosen late evidence Round 19 review of #26705: - A continuation (v3_home_owner) takes a window's End only for a distinct End after its owner's cut, so re-arm keeps one End and leaves a settled continuation settled. - A continuation's Home visibility comes from its owner as planned in this pass, else as loaded, and is persisted on its row. - Short late turns' evidence is chosen by the storage's capacity rules (sidecar totals, then the timing fallback tally at the hard caps), with no probes; the commit's own encode is the one real-codec check, with at most one retry. The review's 200-turn case: 7.3 s -> 165 ms per pass (main 155 ms), 204 -> 2 encodes of the card. Failure-Class: new
… continuations resolve their owner on narrow loads Round 20 review of #26705: - The evidence choice skips lines whose sidecar the reader cannot reveal (position MAX_SEGMENTS or later). Bytes past a hard limit count as hard even with a readback fault. A row whose chosen evidence fails the hard check routes its late turns outside the claims to visible continuations on the next attempt, or appends as main if the kept row still cannot store, so the pass never parks on its own choice. - store.load reads a continuation's absent owner by id (cut, Home fields, deletion flags); a continuation takes a new End only on a resolved owner's distinct later cut, and its v3_home_owner link clears once the owner is deleted or discarded. Failure-Class: new
…ing for the owner's End; keep the End receipt Round 21 review of #26705: - Every reduced locked row accepted without a probe in the evidence-only path is checked by the commit's own encode; past a hard limit the next attempt routes its late turns only if the probed reduced row stores, else appends as main (the measured full append), never parking. - A continuation whose outline failure recovers on open clears the failure without a processing obligation for the End its owner holds. - A continuation keeps its owner's cut as v3_home_owner_cut when the link clears; a row that is or was a continuation takes an End only after that cut. Failure-Class: new
…connect (#26749) ## What changed and why A socket reconnect mid-speech seals the current batch recording and opens the next one on the same device at once. The next recording has no transcript until it seals, so the v3 builder read it as silence: the first card locked at the five-minute rule, and the rest of the conversation became a second card when it landed. `CONVERSATIONS_V3_CAPTURE_CONTINUITY` (on by default) did not cover this. `load()` kept a stretch open only for a following recording that was already `v3_pending`. `_mark_successor_pending` held one only behind a rotation-stamped seal, which is off in prod, and only when that source spoke last. Synthetic shape of the incident: recording A runs 0:00 to 2:56, the socket drops, and A seals at 3:00 as B opens on the same phone. B captures ten more minutes of the same talk and lands 11 minutes after A ended. On `main`, A's card locks and gets notes about five minutes after A landed, and B becomes card 2. The fix, under `CONVERSATIONS_V3_CAPTURE_CONTINUITY`: - **Which sources.** Any loaded recording whose latest server seal came within 90 s of its last line (`policy.LIVE_SEAL_GAP`, either way within 10 s, `policy.CAPTURE_SKEW`). - The seal clock is `record_sealed_at`, else `home_transcription_pending_at`. It is never `finished_at`, which is the last archived audio frame. - A quiet seal comes at least 120 s after the last speech, so it never qualifies and reads nothing. - A source the user ended with Finish does not qualify. - **Which successor** (`database/conversations_v3.py` `_mark_successor_pending`): the next `batch_live_v1` capture from the same `client_device_id` that opens within 90 s of that line. - Each such seal gets its own `started_at` window query anchored at its last line, most recent seal first, read in pages of 16 (`SUCCESSOR_PAGE`). - All the lookups of one pass read at most 64 documents (`SUCCESSOR_READS`; an empty query counts as one). - The first successor the user ended (a requested or applied Finish) fences off every later capture, even once it is discarded with its Finish kept. Any other discarded successor never holds. - **Rotation is `main`'s, under either setting.** Its lookup and hold are `main`'s code: a successor still capturing within the cap, or processing within 15 min of `finished_at`, marks a page continuation (`policy.awaiting_transcript`, unchanged). The clocks and proof below apply only to the reconnect lookup, after the continuity flag and the device and lane match. - **Which stretch.** A held source carries `outline.SUCCESSOR_HOLD`. The last stretch holding it stays open whichever device spoke last. Earlier stretches settle. - **How long** (`policy.successor_hold_until`, absolute deadlines on server stamps that do not move): - While capturing: up to 15 min after `created_at`. - After a first close inside that window: up to 15 min after it, never past both windows. The first close is the earliest of `record_admitted_at`, `home_transcription_pending_at` and `record_sealed_at`. - A close after the window starts no wait. An expired hold stays expired through a late close, a reseal or a retry. - A Finish bounds every wait to 5 min (`FINISH_WAIT`) after its trusted request time, `v3_finish_requested.at`. Without that stamp, the bound runs from the first close. - Failure receipts are checked before status. Stamps more than 10 s in the future never hold. - **When it has landed** (`_capture_landed`): - Proven silence: `empty_transcription.terminal`, whose empty spans cover the closed audio. - The durable proof that every unit of the latest seal landed: `capture_end.units_landed`. Batch projection now writes `record_units_landed_seal_at` (the seal the job covered) in the transaction that commits the authoritative sibling completion (`database/batch_pipeline_projection.py`), last in that transaction and only while the row still carries that seal. - For seals completed before that proof existed: the capture ledger's best-effort `transcribed` transition after the latest seal (`capture_end.seal_proof`). It is one read with a 3 s timeout and no retry, memoized per successor per pass. - A first projected unit proves nothing, silent or not, nor does a unit held for recovery (`units_held`). ## Round 5: the two review items on `17a21f9e3d` 1. **Rotation is exactly `main`'s.** The rotation scan no longer calls `policy.successor_hold_until`; its loop is `main`'s, line for line, except that it stops at the silence gap with `break` so the reconnect lookup still runs. - The review's case now settles: A rotated at 300 s, B opened then on another device and closed at 400 s into the server-batch handoff (`completed`, `home_transcription_pending_at`, no speech yet). At 621 s A's card locks with its notes queued, with capture continuity on or off, as on `main`. - The round-3 rotation case still holds: B queued with `finished_at` 610 s and no close stamp keeps A open at 620 s, and B joins it at 650 s. 2. **Line-count exception matches the file.** `backend/database/conversations_v3.py` is 2,678 lines (2,511 on `main`), and the exception below says so. Validated with this body by `make preflight`. ## Round 4: the two review items on `d5c20e5eb9` 1. **`main`'s rotation wait is back.** Rotation successors no longer go through the reconnect policy first. - `policy.awaiting_transcript` (main's rule) decides and marks `_v3_page_continues`, as on `main`. Where it let go, the reconnect wait still ran; Round 5 removes that. - The review's case now holds: A rotated at 300 s, B still in finalization with `finished_at` 610 s and no close stamp, capture continuity off. At 620 s A stays open, and B joins it at 650 s. - The rotation tests in `test_conversations_v3_review.py` are `main`'s again, unchanged. 2. **A discarded successor's stored Finish still fences.** After the device and lane match, a discarded successor carrying its Finish ends the scan without holding A. - The review's case now settles: B's Finish at 228 s, C opened at 229 s, then B discarded with the Finish kept. A is not held at 529 s or 598 s. - An ordinary discard only releases B. ## Round 3: the three review items on `5a03416141` 1. **Finish is bounded by its original request.** - `v3_finish_requested.at` is projected and drives the 5 min bound. - The ordinary wait runs from a stable first close, so a moved seal cannot extend it. - The latest seal generation is used only for the landed proof. - The immediate successor's Finish fences off later captures. - The review's cases: a Finish at 300 s with the close at 460 s releases by 601 s; a seal moved to 597 s still releases by 670 s; with B finished at 228 s and C opened at 229 s, A is not held at 529 s. 2. **Unrelated rows cannot exhaust the lookup.** - Each live seal has its own window query, most recent first. The rotation query is unchanged from `main`. - Pages continue past cards and other devices' rows, and total reads stay at most 64 per pass. - The query-shape driver observes both shapes. Both are single-field `started_at` ranges, so no index is needed. 3. **Durable whole-capture completion, bounded lookups.** - Projection persists the seal it proves with the sibling completion. - With no proof, an absent ledger no longer counts as complete, and `units_held` no longer releases. - A stale ledger after all speech landed releases promptly on the proof. - The ledger fallback is memoized per successor per pass with a 3 s timeout: twelve matching sources read it once. ## Expected latency cost - **Quiet seals** (how a conversation normally ends): no change, and no extra read. - **Reconnect mid-speech, then the talk goes on:** one card. It locks on the normal lock delay after the rest of the capture lands. - **Reconnect mid-speech, then silence:** the card can arrive up to about 10 min later than today. A batch row the socket created that has heard no speech stays open while the socket streams (`utils/stt/speech_clock.quiet_since`, `FC-transport-liveness-read-as-speech-activity`). - **Worst case, about 30 min after the reconnect:** the capture runs almost 15 min, closes, and its transcript never lands. - **A capture running past 15 min after a reconnect:** still splits, up to 10 min later than today. Listen resuming the same recording on reconnect would remove that case. - **The user ends B:** the hold lasts at most 5 min after the Finish request, however late the close. - **A successor with no proof** (its projection completed before this deploy, and no ledger `transcribed`): it waits out its bound, 15 min after its first close. - **Reads while held:** the existing follow-up wake runs a pass about once a minute. Each pass reads the successor windows, at most 64 metadata documents (usually one or two), plus, without the durable proof, one ledger document per partly projected successor. - **Rollout order:** the proof writer runs wherever batch projection completes; the hold runs on `backend-sync`. Until the writer is live, holds release on the ledger's `transcribed` or wait out their bound. ## Product invariants affected none ## How it was verified - **Replays fail on the old code.** The multi-pass replays use the real loader on a query-capable copy of the strict Firestore rows, with the real `service.reconcile` and `commit_projection`. - On round 4's loader (`17a21f9e3d`), the round-5 regression fails with capture continuity on and off, as the review found. On `main`'s loader it passes with both. The round-3 rotation cases pass on all three. - On round 3's product files (`d5c20e5eb9`), the round-4 regressions fail as the review found: the rotation successor still in finalization past the cap (loader case and continuity-off replay), and the discarded B whose Finish must fence C. The ordinary-discard control passes on both. - On round 2's files (`5a03416141`), the round-3 replays fail: a silent first unit with no ledger, a stale ledger with all speech landed, and a Finish with the close 160 s after the request. - On this head everything passes. - **Mutation checks.** Without its device match, the reconnect lookup fails the round-5 regression with continuity on. Each round-4 rule was removed in turn, and each removal failed its own test: - a discard dropping its Finish fence; - a discard able to hold; - no `main` rotation rule; - the rotation flag made group-wide. - **Round 3 rule checks, still caught:** - no Finish fence; - a single page; - no landed memo; - ignoring the durable proof; - round 2's ledger rule; - the writer stamping no proof; - the writer ignoring the seal generation; - the latest seal as the wait anchor; - Finish timed from the close; - accepting a future Finish; - oldest cut first. - **Pipeline lab.** All 17 committed scenarios, `--jobs 4 --repeat 2 --stt replay`: every check passed in both runs (552.8 s on a loaded host). - Three scenarios were flagged nondeterministic only by one `account_deletions` read between repeats, the account-deletion check's wall-clock cache. Rerun alone, all three passed deterministically with the same counts. - Round 3's traced run refreshed `reach.json`, which lists `utils/sync/capture_end.py` for the four reconnect scenarios. Rounds 4 and 5 add no file to any scenario's reach, so it stands. - `reconnect_successor_lands_late` passes 9/9 within budget, at 367 reads. - Other scenarios' counts are unchanged. - The lab's transcript stand-in now stamps the completion proof, as production's sibling completion does. - **Unit suites.** 158 suites ran under the CI per-test budget (`BACKEND_UNIT_TEST_FILE_LIST=... bash test.sh`): all `test_conversations_v3*`, `test_pipeline_lab*`, `test_batch_pipeline_projection*`, capture-end, record-seal and server-batch-completion files. All 158 files passed: 5,042 tests, none failed. - **Firestore index guard set** (7 files, 928 passed, including 644 query-shape tests): the `_mark_successor_pending` driver runs a rotation source and a live-cut source, and records both shapes: `started_at >` with limit 8, and the `started_at` window with limit 16. Both are single-field ranges, so no composite index is needed. - **Type check:** `scripts/typecheck.sh` reports 0 errors. - **Preflight:** `make preflight` with this body passed 40 of 41 checks, including the line-count exceptions, the failure class, the index guard and the lifecycle write guard. The one failure is `feature-flag-registry` at today's date: 82 flag reviews due 2026-11-22 are past their grace, repo-wide, and this PR changes no flag. `scripts/check_feature_flag_registry.py --as-of 2026-11-29` passes. - **Not yet seen in production.** This is not deployed, and no real reconnect on a deployed backend has run through it. The hold runs on `backend-sync`; the proof writer runs wherever batch projection completes. ## Tests `backend/tests/unit/test_conversations_v3_successor_hold.py` (71 cases): - **Round 5:** rotation lets a closed capture from another device go as `main` does: a multi-pass replay of the review's case, with capture continuity on and off. - **Round 4:** - Rotation keeps `main`'s wait for a same-device batch successor still in finalization past the cap, as a loader case and a continuity-off multi-pass replay. - A discarded successor keeps the fence of its stored Finish; an ordinary discard only releases it. - **Loader matrix:** - Capture window, and first-close waits and bounds. - A reseal after the first close. - The Finish request bound: request at 300 s with the close at 460 s, a seal moved to 597 s, a Finish while capturing, and a future Finish. - Proof present with a stale ledger, proof of an older seal, and units held for recovery. - One unit projected; no proof and no ledger; transcribed; transcribed before a reseal. - Complete silence, and silence on the first unit only. - Failure receipts, and future stamps. - Device, lane, sync, deleted and discarded. - Window bounds. - **A finished successor fences off a later capture** (B finished at 228 s, C opened at 229 s, A free at 529 s). - **Crowding:** 24 other-device captures plus 16 cards are paged through in three pages; past 64 documents the lookup stops. - **Lookup order:** the newest cut is looked up before an older crowded one, and rotation keeps its own lookup beside a crowded earlier cut. - **Twelve sources matching one successor:** one ledger read, with the 3 s timeout; zero reads with the durable proof. - **The real projection completion** stamps the seal it proves after the last sibling, and writes nothing for a job admitted before a reseal. - **Round 2 cases kept:** - A late seal stays expired. - Quiet rollover and skew read nothing; continuity off reads nothing. - Interleaved device, and an earlier independent stretch. - 18 cards in the window. - Two reconnects in a row. - Finish and owner End still end the stretch. - **Multi-pass replays:** - The incident, with continuity on and off. - A silent first unit with the ledger absent, transcribed, or stale. - Another device speaking last. - A requested Finish, closed at once or 160 s late. Each test runs at or under the 1.0 s CPU budget. Elsewhere: - `test_conversations_v3_review.py`: back to `main`'s rotation tests. `MemoryQuery` accepts read options (timeout, retry) and `<`. - `test_batch_pipeline_projection.py`: the completion helper takes an optional `job`. ## UI evidence UI-Evidence: none -- backend-only change ## Failure class (fixes) Failure-Class: FC-live-settlement-uses-capture-clock Line-Count-Exception: backend/database/conversations_v3.py | 2511 -> 2678 | the successor hold extends the loader's existing check in place beside #26705's edits to the same file; splitting the store is out of scope for an incident fix Line-Count-Exception: backend/database/batch_pipeline_projection.py | 1567 -> 1582 | the completion proof must commit in the sibling-completion transaction that already lives here 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Round 22 review of #26705: the on-open outline recovery recognized a companion only by its live v3_home_owner link, which clears once the owner is deleted. It now also recognizes the persisted End receipt (v3_home_owner_cut), so a companion without a distinct End of its own clears the stale failure with no processing; one that owns a distinct End keeps ordinary recovery. Failure-Class: new
|
Prod deploy status (04:37 UTC Nov 30): How it got there:
Post-deploy: 60 min watch running, plus a prod reconnect repro (baseline produced 2 cards for one call). |
… lost within the soft limits After #26705 the size check still replanned a stretch at main's 900 KiB estimate budget when the commit codec dropped speaker placements past the per-segment sidecar capacity, even though the stored bytes were far under the store caps. The re-cut never restored the evidence and only split the conversation mid-speech. A row within the soft limits now carries its probed bytes (main's writer bytes, placements degraded to the timing markers); rows past the soft limits replan exactly as before. Failure-Class: FC-size-cap-measures-proxy-not-stored-encoding
… lost within the soft limits After #26705 the size check still replanned a stretch at main's 900 KiB estimate budget when the commit codec dropped speaker placements past the per-segment sidecar capacity, even though the stored bytes were far under the store caps. The re-cut never restored the evidence and only split the conversation mid-speech. A row within the soft limits now carries its probed bytes (main's writer bytes, placements degraded to the timing markers); rows past the soft limits replan exactly as before. Failure-Class: FC-size-cap-measures-proxy-not-stored-encoding
… lost within the soft limits After #26705 the size check still replanned a stretch at main's 900 KiB estimate budget when the commit codec dropped speaker placements past the per-segment sidecar capacity, even though the stored bytes were far under the store caps. The re-cut never restored the evidence and only split the conversation mid-speech. A row within the soft limits now carries its probed bytes (main's writer bytes, placements degraded to the timing markers); rows past the soft limits replan exactly as before. Failure-Class: FC-size-cap-measures-proxy-not-stored-encoding
…lity as bounded streams (#26787) ## What changed and why #26705 (live on prod `backend-sync`) keeps v3 cards whole up to twice the old estimate budget, about 600 KB of decoded transcript. v3 write equality (`_same_transcript`) decoded stored transcripts through public chat's inline bound (256 KiB stored, 512 KiB decoded). It could not compare such a card even with itself, fell back to a write, and every unchanged re-arm rewrote the card. **Change (write equality only; `backend/database/conversations_v3_write_equality.py`).** - Main's comparison runs first, unchanged. - When main's bounded decode refuses a transcript **for its size** (stored past 256 KiB or decoded past 512 KiB on either side), the two stored transcripts are compared as streams. A transcript refused for its shape (for example a 257-character anchor) still writes, as on main. - Each field must pass the writer's own field check (`estimate_firestore_value_bytes` ≤ `HARD_FIELD_LIMIT`, as `guard_staged` measures) on the stored representation, before decryption. - Enhanced fields are authenticated and decrypted. Both are decompressed in 64 KiB chunks and compared byte for byte, without parsing. - Supported envelope: the writer's field limit, at most 32 MiB decoded, and no grouping sidecar. Sidecar ciphertext differs on every encode and needs serving validation. Anything outside the envelope writes, as on main (`EQUALITY_UNAVAILABLE`). - **Shared chat is unchanged** and keeps main's bounded reader. It is publicly reachable and saw 0 requests in 24 h. ## Production measurement (metadata only, 24 h to Nov 30 15:11 UTC) - `omi_conversations_v3_equality_unavailable_total` in namespace `backend-sync`: **12,969** equality fallbacks. - Rows over the same window (`omi_conversations_v3_projection_rows`, `backend-sync`): **680,192** written and **4,140,516** skipped as unchanged. So about 1.9% of written rows fell back. - The counter has no reason label, so the share caused by this bound is **not measured**. The once-per-process `omi_fallback_event from=elide_write` log line matched nothing in 24 h. ## Verification - **Live passes:** `test_a_large_stored_card_compares_equal_and_unchanged_rearms_write_nothing`. Production loader, real codec, strict commit fixture. - Input: 600 evidence-free lines plan as two cards; the large one decodes past 512 KiB. - New code: two unchanged re-arms stage **0** writes, and a real change (a late turn) still writes exactly one row. - Main: rewrites the large card on the first re-arm. - **Bounded memory:** `test_a_large_transcript_compares_in_bounded_memory[standard|enhanced]`, measured with `tracemalloc`. - Standard: 62,000 segments, 544,725 B stored, 16,086,670 B decoded. Equal in **1.95 MiB** peak and 0.024 s. - Enhanced: 30,000 segments, 704,120 B stored, 7.8 MB decoded. **2.27 MiB** peak. - A one-segment change compares unequal. - The test asserts peak < 3 × stored + 4 MiB. It fails on 2efdc2f, which materialized the card; the review measured +453 MiB RSS there. - **Writer limit:** `test_a_transcript_field_past_the_writer_limit_is_never_equal`. The enhanced case has compressed bytes within the limit but an encrypted string past it, the review's 1,203,529 B shape; a standard field is past the limit too. Neither is ever equal. It fails on 2efdc2f. - **Sidecars:** `test_a_large_transcript_with_a_grouping_sidecar_still_writes`. - **Shape refusals:** `test_a_small_transcript_refused_for_its_shape_still_writes`, which fails on e6975ad. The emulator proof `test_projection_writes_when_inline_anchor_is_rejected` passes locally on the Firestore emulator, 19/19 in that file. - **Suites:** - All `tests/unit/test_*v3*.py`. - Every test file touching the bounded decoder, write equality or shared chat, one process per file. - All affected lab scenarios. ## Product invariants affected none ## Failure class (fixes) Failure-Class: new 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…hat the writer stores BasedHardware#26705 keeps v3 cards up to ~600 KB of decoded transcript, but shared chat and v3 write equality decoded through public chat's inline 512 KiB bound. Shared chat rejected those cards and write equality could not compare them, rewriting each on every unchanged re-arm. Both readers now decode within writer-sized limits (Firestore's field limit, a 16 MiB decode ceiling, 65,536 segments). Failure-Class: new
What changed and why
#26372 (SCA-2918) cuts long conversations in the middle of continuous speech.
planner._transcript_bytesestimates each line as3 * (len(json.dumps(segment)) + 64)with no compression, and_cappedcuts once the running sum passes 900 KiB. Segment metadata dominates that estimate, so ordinary speech reaches the budget long before the stored field nears Firestore's limit.Production, last 24 h (metadata only): 215 mid-speech size splits for 143 users. 0 had a finished stretch when the first part was created: all 215 were cut while still live, the first part created 25-74 minutes before the speech ended. Round 6's final-only merge would have merged none of them. One 65-minute recording (Nov 28): 702 lines, cut mid-sentence while its whole stored enhanced field was 284,756 B (27% of the 1,048,487-byte limit).
Design (round 13): cut later, with main's machinery
The size merge is gone:
size_merge, merged-row and provenance comparison,kept_live, the mergeSTRETCH_FIELDpaths and their service hooks.Where the size cut lands (
planner._capped). Main's deterministic, append-only cuts, the two-hourCAP, "every part but the last locks", ownership and locked runs are unchanged. A size cut happens when either:TRANSCRIPT_BUDGET = 2 x 900 KiB(MAIN_TRANSCRIPT_BUDGET = 900 KiBremains for fallback); orEVIDENCE_SHARE) of each hard cap ofspeaker_grouping_storage's timing fallback. The evidence is counted exactly as the storage serializes it:json.dumps({'id': first_sid, 'timing_unit': {'scope', 'timing_store', 'segments': {sid: {'id', 'provider'}}}}), which grows by exactly one, "sid": {...}entry per member;_protect_timing_markerssums it, from the_timing_recordcompact-record bytes;4 * ceil((n + 28) / 3).test_evidence_accounting_is_exactchecks that against the real sidecarsprotect_segmentswrites.The budgets are:
MAX_BYTESper unit envelope (65,536 B)MAX_ENCODED_BYTESper unit, encrypted (98,304 B)MAX_TIMING_TOTAL_BYTES, compact records and envelopes decoded (262,144 B)MAX_TIMING_TOTAL_ENCODED_BYTES(393,216 B)MAX_TIMING_UNITS(1,024)(b) also cuts before a segment id the part already holds, because the fallback binds labels by id, and before a unit's second timing store, which the fallback drops. Both sums only grow as lines are appended, so cuts stay append-only. Logged as
event=v3_transcript_size_cap_split/event=v3_transcript_evidence_cap_split.Final-row validation (
v3/size_check.py).prepareencodes every final row exactly as the commit stages it, quietly, on the DB executor: the commit codec plus the configured settle stamp. Each field value and the document are measured by Firestore's storage-size rules, using the samestaged_sizesas the commit guard. It then reads back from those bytes every line's reader-visible speaker placement,(provider, unit, label, timing store)in order, through the serving decode andreveal_segments. This covers retained, appended and new lines on both protection levels.speaker_grouping_storage.quiet()separately from intentional capacity drops) means no cache and one retry. A fault that persists leaves the row to the normal writer: no carry, no replan, no routing.commit_projectionreports them once, after that row's successful write (report_written). A plan discarded by adoption or a replan reports nothing.MAIN_TRANSCRIPT_BUDGET(event=v3_transcript_size_check outcome=fallback|replan). Fallback never shrinks a published row: a stored, undeleted, unlocked row owning lines on both sides of a fallback or evidence cut joinsOwnership.locked_ids, so it is planned as locked at its stored extent.Ownership.released): it loses both its stored-extent pin and its Rule B outline protection, its stretch gets main's 900 KiB budget in the same retry, and it is cut by that budget and its topics, as main would cut it (outcome=recut). The first part keeps the card's id through main's matching, and claims follow main's normal writes. A locked row past a hard limit is not carried: the exact staged guard refuses it before anything is sent, with Firestore's own message naming the document, and the pass parks as on main.commit_projectionwrites exactly those bytes on every attempt and retry.commit_projectionrefuses any staged derived row (after stamps, privacy filtering and rederive lineage) and any source claim update past the hard limits before sending it (guard_staged). It uses Firestore's own rejection and message, so main's existing park path applies unchanged.Late appends into locked rows (
v3/locked_append.py), strictly a fallback. A locked row appends late speech exactly as on main whenever the grown row stores intact, including past the soft limits. "Intact" means within the hard limits with every speaker placement kept, decided on the commit's own bytes bysize_check.prepare; the final representation is re-verified and carried bysize_check.below_word_minimum) is not created: its speech stays on the visible row. Each turn keeps its own placement where the storage's capacity rules keep it at no cost to a placement already kept (locked_append.choose, no encode). The committed bytes are checked once with the real codec, with at most one retry. A continuation the hard limits require shows on Home as its owner does in this pass, from its first write and whatever its classification (v3_home_owner). It never takes the owner's End. Past full-evidence capacity the codec's compact fallback keeps what it can, as on main. The rest of the speech main's own append dedupe calls new (planner.present_in: ids, revised ids, overlapping equivalent text) goes to continuations. These are cut by main's 900 KiB budget and the evidence budget, untitled. If even the retained append is past a hard limit, the row grows as on main and the pass parks.CONVERSATIONS_V3_TRANSCRIPT_SIZE_CAP=off, planning, late appends and the writer are main's: no size check, no replan, no routing. Only the commit's staged hard-limit guard stays.A published live card keeps its extent across re-outline (
planner._keep_published). Cohesion on and off, only with the size cap on.v3_size_extendedonce its lines exceed main's 900 KiB estimate under the size cap; only the larger budget creates such cards.preserve_finished_windowsholds the card's own lines apart through its existing provisional custody. An unowned turn inside the interval therefore gets its own row, as on main. The card keeps its id, lines and claims and keeps growing; topics that start after its lines still cut. Live cards under main's budget keep main's topic cuts exactly, so the existingtest_delayed_short_topics_across_recordingsis unchanged. Production runs with cohesion on:CONVERSATIONS_V3_STRETCH_COHESIONis unset onbackend-sync,backendandbackend-sync-backfill, and the code default is on.Owner's real recording on round 8 (reported): the dinner is one row (282,372 B, 702/702 placements); three dinners are 800 + 801 + 505 with 2,106/2,106 placements. Round 9 keeps both: the dinner and three-hour tests are unchanged and pass.
Review items (round 22)
v3_home_ownerlink, which clears once the owner is deleted. It now also recognizes the persisted End receipt (v3_home_owner_cutpresent). Such a row, unless it owns a distinct End (manual_end), clears the stale outline failure with no processing scheduled. A companion that owns a distinct End keeps ordinary outline recovery.test_a_continuation_resolves_its_owner_on_a_narrow_load[deleted_then_open|unlinked_then_open], through the realfailure_patchand the production loader. The owner's claims are released and it is removed; the companion is then opened at once, or after a separate pass already cleared its link. Through two re-arms it stayscompletedwith nothing pending, the failure cleared, no End, and the receipt equal to the deleted owner's cut. Both went toprocessingbefore the change.Non-test code this round: +6 / -3 (net +3).
Review items (round 21)
Each counterexample was written as a test first and failed before the code changed.
report_writtenof its own encode).test_a_reduced_locked_row_past_the_hard_limits_appends_as_main, at a twentieth: the near-limit card with unstamped placements, conversation kind, one 40-word turn inside its claim and ten unclaimed 16-word turns with unstamped placements, visible on their own so nothing is chosen. The plain append is 44,960 / 46,667 B; the reduced row would be 52,876 B document. It commits every line once, visible, with nothing pending and every write within the hard limits, stable on re-arm. It returnsblockedbefore the change.v3_home_owner) whose outline failure recovers has the failure cleared (and its tile back to done). It keeps its settled status, and no processing obligation is added for the End its owner holds.test_a_continuation_resolves_its_owner_on_a_narrow_load[on_open]: the continuation is written with a failed outline (the realfailure_patch), then opened through the production loader with a working outline and re-armed twice. One End, no cut on the continuation,completed, nothing pending and the failure cleared. Without the change it goes toprocessing.v3_home_owner_cut(or None). Clearing the visibility link keeps it, and_takes_endlets a row that is or was a continuation take an End only after that cut.[owner_deleted]through two re-arms: the link is gone, the receipt equals the owner's cut, and there is no End, no cut and no processing. Without the receipt rule the survivor takes the owner's End.service.py2113 -> 2256.database/conversations_v3.pyis 2500 against main's 2511, since the owner read moved todatabase/conversations_v3_home_owners.py, so it needs none. Validated with the actual body bymake preflight.Non-test code since round 19's head (rounds 20 and 21, pushed together): +97 / -18 (net +79); round 21 alone +25 / -12 (net +13); the runbook +3 / -2.
Review items (round 20)
Both counterexamples were written as tests first and failed on round 19's head before the code changed.
reveal_segmentsrejects a sidecar on any line at a position ofMAX_SEGMENTSor later, solocked_append.chooseno longer gives a placement back there.size_check.checknow counts a row whose committed bytes pass a hard limit as hard even when their readback also faults; the guard refuses those bytes either way.outcome=choice_over_limit). If the kept row still cannot store, the measured plain append (main's) is used, so the pass never parks on its own choice.test_a_selection_past_the_hard_limits_never_leaves_late_speech_pending[unrevealable|over_limit], at a twentieth.unrevealableis the review's geometry: 12 placed card lines and 13 sidecars, the 450->777 media replay, ten unstamped late turns.over_limithas every card line placed and nine sidecars to spare, so the choice is valid by the model but its bytes pass the limit. Both commit with every line stored once and visible, nothing pending and every write within the hard limits, stable on re-arm. Both returnblockedon round 19.store.loadreads a continuation's owner that the pass did not load by id (database/conversations_v3_home_owners.attach, a new 26-line module, soconversations_v3.pystays under main's line count): oneget_allof just its cut, Home fields and deletion flags (planner.HOME_OWNER_META). A missing owner reads as deleted._takes_endgives a continuation a new End only on a resolved owner and a distinct, later cut; an unresolved owner gives none.shown_as_ownerclearsv3_home_owneronce the owner is deleted or discarded.test_a_continuation_resolves_its_owner_on_a_narrow_load[on_open|owner_deleted], through the production loader with a real owner End cut (end_open_conversation).on_open: opening the settled ten-turn continuation reads only it and its source, yet there is one End, no cut on the continuation and no processing re-queued.owner_deleted: the owner's claims are released, the owner removed and the source re-armed, and the continuation keeps no link. Both fail on round 19.Non-test code this round: +81 / -15 (net +66); the runbook +3 / -2.
Review items (round 19)
One End owner through re-arm. In retained-window planning (
preserve_finished_windows), a row that owns a window's last line takes the window's End only throughplanner._takes_end. A continuation (v3_home_owner) takes it only for a distinct End, a cut after its owner'sv3_manual_cut_at.v3_home_ownernever carries End ownership.test_a_required_continuation_shows_as_its_visible_owner[conversation|media|background|media-toggle]now records the owner's End on its source, as the End writes it. The ten turns land after every card line and before that End, and the continuation's processing has settled before re-arm. Through re-arm there is exactly one End (the owner's), no cut stamp on the continuation, and the continuation stayscompletedwith no processing re-queued. Without_takes_endthere are two Ends.Visibility from the owner as planned in this pass.
locked_append.shown_as_ownerreads the owner from this pass's planned rows, falling back to the loaded owner when the pass leaves it untouched. It runs before sizing, and the effective fields are persisted on the continuation's committed row.[media-toggle]: manual-End Home visibility is off for the 35- and 54-line passes (the 450/777 ones) and on when the ten turns land. Owner and continuation are both visible on that first write. Reading the stored owner hides the continuation.Bounded codec work. The kept row is built once with the short turns stripped.
locked_append.choosepicks the turns whose own evidence can return, by the storage's own capacity rules and with no encode:protect_segments's checks);planner._Evidenceat the hard caps; it now takes ashare).The choice rides on the row (
size_check.CHOICE).size_check.check's own encode of the final row is the one real-codec check. If those bytes lose a placement the choice expected, the chosen evidence comes off and the row is encoded once more, and those are the bytes committed. In the evidence-only case the kept row is part of the already probed grown row, so its separate storable probe is gone.mixedandalternatingkeep their exact placement sets.Non-test code this round: +155 / -52 (net +103), mostly the capacity model in
locked_append.choose; the runbook +3 / -2.feature-flag-registrystill fails identically onmain(date rollover, other teams' flags).scripts/check_feature_flag_registry.py --as-of 2026-11-29passes here.Review items (round 18): the general rules
v3_home_owner, persisted). On every build while that owner stands, it takes the owner's effective Home fields (home_hidden,home_hidden_reason;locked_append.shown_as_owner). It keeps its ownkindand End ownership. The round-17_stretch_wordsfloor is gone.test_a_required_continuation_shows_as_its_visible_owner[conversation|media|background]: the 450->777-line replay at a twentieth with the outline classified as each kind (background is wearer-recognized). The continuation is visible on its first committed write, keeps its own kind, plays 10/10, and stays visible on re-arm. All three fail without the change: hidden on the first write, or on re-arm before the owner link was persisted.locked_append.placed); otherwise only that turn's placement is stripped. The final selection's bytes are the ones committed:size_check.checknow carries a locked row's storable probed bytes even where the codec drops evidence (main's append path), so the write is exactly what was probed.test_evidence_only_overflow_keeps_claim_bound_turns_on_the_locked_card[mixed|alternating], at a tenth with the sidecar capacity scaled with the lines.mixed(250 + 5 + 2 with 256 sidecars at full scale): every original and in-claim placement plus the stamped late turn's.alternating(stamped, unstamped, stamped, unstamped): the first two late turns, the ones that fit. The committed bytes are checked on the first write and on re-arm. Both fail with round 17's all-or-nothing choice.Non-test code this round: +51 / -33 (net +18); the runbook +3 / -2.
feature-flag-registry(Hygiene andmake preflight) fails identically onmainsince 2026-11-30 00:00 UTC: flags of other teams passed their 7-day grace. It is not changed here.scripts/check_feature_flag_registry.py --as-of 2026-11-29passes on this branch.Review items (round 17)
fallback), so the released outline and size cuts apply together.test_an_open_card_revised_past_the_hard_limits_is_cut_as_main[outline-on|outline-off]now asserts main's exact partitions from the same wide card. Main's budget is scaled to nine of a topic's twelve lines, so topic 1's tail after the size cut is a topic of its own, as the 19-line tail is at full scale. Cohesion off: each topic cut by main's budget (260+19+260+19 at full scale). Cohesion on: the stretch cut by main's budget, then at the topic boundary (260+19+241+38). Both hold after End and after re-arm. Without the change both cases fail.locked_append.keeps_as_many, viasize_check.placed, the per-line readback). The evidence is stripped only if keeping it would cost a placement the stripped payload keeps, or pass a hard limit.test_evidence_only_overflow_keeps_claim_bound_turns_on_the_locked_card[stamped]: stamped originals, the five-word late turn stamped in its own batch unit, ten unstamped in-claim turns still overflowing the sidecars. The committed bytes keep every original placement and the late turn's own, on re-arm too. Fails with round 16's always-strip.overflowssays'hard') under a visible owner carries the word gate the owner already passed (continuations(..., visible=True)sets_stretch_wordsto at leastMIN_HOME_WORDS). Its Home visibility on the first write therefore matches main's append to the visible card.test_a_required_continuation_shows_as_its_visible_owner: at a twentieth, a visible End card grows from 35 to 54 lines (49,872 B field / 51,023 B document; the review's 450->777 lines at 1,043,824 / 1,045,746 B). Ten more turns of 140 words from another late source need a continuation, and it ishome_hidden: Falseon its first committed write. Without the change it is hidden.Non-test code this round: +78 / -27 (net +51); the runbook +4 / -3.
Review items (round 16)
ownership.locked_ids, but_keep_publishedput the same card back in the outline hold, so a 558-line card with a revised second topic was rebuilt whole, refused by the guard and leftin_progress. Now any stored open row that fails the hard check joinsOwnership.released, which both the pin and_keep_publishedskip, and the retry applies the actual topic and size cuts.test_an_open_card_revised_past_the_hard_limits_is_cut_as_main[outline-on|outline-off], through the productionstore.loadandcommit_projectionat a twentieth: two 279-line sources (12 here) at 36 words published as one open card with the size marker, then both completed at 53 words with a second topic at line 280 (13 here). It commits with no quarantine, every part within main's budget and the hard limits, the card's id on the first part, and every line once. A healthy recording 6 h later commits, and End settles every card with its processing queued. Both cases returnblockedwithout the change.[words]case (round 15's 2x250-line 28->61 replay) no longer asserts main's exact partition. It asserts main-budget compliance and the safety properties.locked_append.overflowsnow says'evidence'or'hard'), a continuation Home would hide as its own row is not created. Its lines stay on the visible original with their own placement stripped (locked_append.unplaced), so the card's stored placements are not put at risk.test_evidence_only_overflow_keeps_claim_bound_turns_on_the_locked_cardadds a five-word late turn from a later recording to the unstamped fixture. One visible card with all eleven new turns, 11/11 covered by itsrecording_pieces, on re-arm too. Without the change there are two rows.Non-test code this round: +50 / -24 (net +26); the runbook +4 / -2.
Review items (round 15): the park path is replaced, not patched
size_check.checknow also returns those row ids) is unpinned and the stretch is planned again with main's budget, so the end state is cut as main cuts it. Locked rows keep main's park. The round-13/14 park attribution is gone:_size_quarantine,_quarantine_park,size_error_documentandstore.loadare back to main's code, andguard_stagedno longer tags its error.test_an_open_card_revised_past_the_hard_limits_is_cut_as_mainreplays the 2x250-line 28->61-word revision at a twentieth (2x13 lines) through the realstore.load(the lease's realopen_id) andcommit_projection, with healthy recordings 30 s and 6 h later. It commits parts within main's budget (round 16: exact partition not required) with the card's id on the first part, no quarantine and no park, and every line published once. End then settles every card withv3_process_pendingand clears every source. It returnsblockedwithout the change.locked_append.storable), even if evidence exceeds full-evidence capacity. Only speech outside its claims is routed, so routed turns always have unclaimed, playable audio.test_evidence_only_overflow_keeps_claim_bound_turns_on_the_locked_card: a locked card with no timing stamps atMAX_SEGMENTS, then a same-length revision with ten distinct 0.7 s turns inside its claim and ten older turns omitted. One row, all ten on the card, 10/10 covered by itsrecording_pieces, on re-arm too. Round 14 made a continuation.size_cap = transcript_size_cap_enabled()gates the size-check loop and the late routing; off returns main's plan and build directly. The runbook says so.test_late_speech_of_the_same_unit_keeps_every_placement[off], the 580+1+220 replay at a tenth: one card with every line (101), as main, on re-arm too.[on]keeps the card plus the in-claim turn and routes the 30 late lines, with every placement kept.Non-test code this round: +73 / -60 (net +13); the runbook +7 / -4.
Review items (round 14, superseded by round 15 item 1 for the park)
open_idpoints at was treated as unattributable (the open window is loaded on every pass), so the owner backed off and the next healthy recording never ran. Now the commit guard's rejection names its row (error.conversation_id), and_size_quarantinecharges it to the seeds whose claims feed that card.store.loadskips the open window while every one of its sources is quarantined, so its closure stays out of unrelated passes until the hold lapses.test_a_rejected_open_card_quarantines_its_own_seeds_and_the_next_recording_commits, through the realstore.loadwithopen_idset to the rejected card: exactly its seeds (a,b) are quarantined, the stored card and claims are unchanged, the independent recordingccommits on the next pass, and nothing loops (two passes). It fails without either half (no quarantine; orblockedon the second pass).locked_append.claimed). If even that does not fit, main's split applies.test_late_turn_inside_a_locked_cards_audio_stays_playable: an overflowing late append plus a distinct 0.7 s turn inside the card's audio. The card keeps its published lines plus that turn, only the other recording's speech moves, and every row'srecording_piecescover every transcript turn it serves. It fails without the fix.Non-test code this round: +53 / -19.
Review items (round 13): the frozen-card path is removed
All three round-12 must-fixes were inside the frozen path, and rounds 9 to 12 each found new edge cases there:
Why it can go. A published row only exceeds Firestore's hard limits if the same audio's stored transcript more than about doubles. Real speech rows publish at about 330-400 KB, the pre-commit check bounds every new row at 768 KiB, and re-transcribing the same audio cannot double it.
Round 13 parked that case with the one-seed quarantine; round 15 cuts an open card by main's budget instead (above). Removed:
Ownership.freezeandfrozen_ids,planner.claimed_overlap, the frozen build window and its playback/piece handling, the frozen service hooks,size_check's hard set, and their tests. Non-test code is -50 net lines this round (+32 / -82).test_an_open_card_revised_past_the_hard_limits_is_cut_as_main):test_a_revision_past_the_hard_limits_parks_with_one_seed_quarantineused the round-8 two-source revision to many more high-entropy words, at a twentieth. The card is published under main's budget (no extended marker, revision 1). The staged guard refuses the oversized rebuild before sending, and the pass returnsblockedwithdocument_too_large, quarantining the seed's closure (r,r2). The stored card and both sources' claims are untouched, nothing is written, and the independent recording commits on the next pass.test_a_130_minute_dinner_cuts_once_at_the_two_hour_cap).Review items (round 11)
Round 12 replaces case-by-case handling with the two rules above and deletes what they supersede (
locked_append.keep_published,locked_append.as_locked,size_check.report, the stored-estimate classifier). Non-test code shrank by 3 net lines this round (+102 / -105).test_a_new_turn_inside_a_protected_card_gets_its_own_row[off|on x inserted|next]: a 52-line published card (your 520 at a tenth) gets one distinct turn from a new recording between old lines 26 and 27, then End brings a new topic at that turn or the next. The card keeps every published turn and its id, and the inserted turn gets its own row.test_codec_faults_and_telemetry_follow_the_written_payload[timing_write]: planning twice, the first plan discarded as adoption does, reports nothing. The written row reports main's single event after its write.Review items (round 10)
test_reoutline_protection_follows_what_the_card_published[shorter_live_write]: a large card is published, a shorter revision is committed while it is still live, then End brings a new mid-card topic. The card keeps its extent. Withsize_cap_off, main's topic cut applies whatever the mark says.test_codec_faults_and_telemetry_follow_the_written_payload[sidecar_fault]: a probe-only primary-sidecar encryption fault. The faulted bytes are never cached; the retry's bytes keep 10/10 shadow predictions, and no event fires.[timing_write]: a healthy row on the timing fallback reports the one event main reports.test_a_probe_only_codec_failure_keeps_main_append[encrypt|decrypt]: a probe-only encryption or readback authentication fault leaves the storable late speech in the original card (80 lines, main's 712 at full scale).service.py2,113 to 2,182.make preflightruns with this body.Review items (round 9)
test_staged_sizes_measure_field_values_exactly_and_name_the_rejected_row: a 1,048,257 B value in a 1,048,452 B document stores. A value past 1,048,487 B is refused before sending, with Firestore's size message and the row's id (size_error_document).test_reoutline_protection_follows_what_the_card_publishedcovers both threshold crossings and the size cap off.test_evidence_only_sidecars_keep_falls_back_to_main_cutsasserts no speaker-grouping events), and a probe-only codec fault keeps main's append.Review items (round 8)
test_late_speech_of_the_same_unit_keeps_every_placement: 70 published lines, then 30 new lines of the same batch unit before the owner End. Appending would pass the storage's per-unit cap, so the new lines go to a continuation. The card is kept exactly as published and all 100/100 lines keep their placement, matching main's 800/800.test_evidence_only_sidecars_keep_falls_back_to_main_cuts: two 24-line sources with per-line evidence and no timing stamps. Their longer row would lose it, so validation falls back to main's cuts and 48/48 placements are kept, matching main's 470/470.test_sidecar_failure_during_the_check_is_never_cached:[1]: the crypto failure hits only the first check encode. The retry's bytes are cached with 8/8 placements.[99]: every check encode fails. No bytes are ever cached, and the commit's own encode keeps 8/8, matching main's 80/80 at full scale.test_reoutline_at_end_keeps_a_published_live_card(cohesion off and on): a 70-line live card is re-outlined at End with a new topic at line 36. It keeps all 70 lines and its id, as in your 702-line case at line 351.Review items (round 6)
test_late_speech_into_a_locked_card[storable]uses the real commit codec at a tenth. The grown card lands past the soft limit and below both hard limits, and it appends exactly as on main with no continuation. A probe exception takes main's path. The checked final encoding is what is written.[all_ids_revised]: every card source id is replaced with the same words and timing. No park, no duplicate, the card unchanged, and continuations hold only the late recording's lines.[last_id_revised]: only the last id is replaced. No reissued turn, so the line count matches main's.[two_sources]: two individually storable late recordings, together over the hard limit, are partitioned into continuations that each store.[overflow]: the card's transcript and claims are unchanged. The late recording's claims name only the continuations. With routing disabled the pass parks, as on main.Continuations carry no parent title or sections.
Review items (round 5)
test_late_speech_into_a_locked_card(round 6 item above). An End-locked card plus high-entropy late speech that would pass the hard limits commits with every row stored; small and storable appends land in the card as on main.test_round5_live_counterexamples_never_reshuffleruns two live passes per case:test_dinner_density_speech_stays_one_card_through_live_passes_and_endchecks one card from the first live pass through End, cohesion on and off, with the same id, a growing extent and all claims naming it. Fallback is the only place a cut could land inside a published row, and there the row is locked at its extent (test_fallback_never_shrinks_a_published_row). Where a genuine new outline topic does apply, a live card splits at it exactly as main splits any live card under its own budget. Main kept 485 lines in the round-5 replay only because its mid-speech size cut had locked them.test_three_hour_dense_stretch_keeps_every_placement_main_keepscovers three hours of dense speech, with per-job units and with one large unit where the evidence budget binds. After the commit codec round trip, every line's(provider, unit, label, timing store)is identical to main's, withreveal_segmentsaccepting every sidecar.test_recordings_that_reuse_segment_ids_never_share_a_rowchecks that two recordings reusing ids land in separate rows with all 64 bindings correct. Earlier merge-only cases now run through the size check: the sibling that inherits a large prior is planned with main's budget and gives main's rows; the matched prior with a large retained overview stores under the limits.Evidence the timing fallback cannot represent (shadow predictions, live-store stamps) is kept only by per-segment sidecars of at most 256 segments per row. Main's own parts already exceed that at dinner density (main's 483-line part), so this design does not add that loss to main.
Line-count exceptions
Line-Count-Exception: backend/utils/conversations/v3/service.py | 2113 -> 2259 | the planning block and build loop become plan()/build() (re-indented, unchanged) for the size-check replan with deferred effects and the hard-overflow re-cut, plus the locked-row late-append split (Home-hidden speech kept on the visible row with capacity-chosen evidence and its over-limit recovery, owner visibility and End for required continuations) and the rollback gate; the size logic lives in planner.py, v3/size_check.py and v3/locked_append.py
Product invariants affected
none
How it was verified
test.sh, warn 0.10 s, fail 1.0 s): 45 files pass, 5,102 tests, no timing-guard failure. They cover v3, speaker grouping, offload, write equality, self-heal and recovery, the lifecycle-writer inventory and query shapes. Every new test is at or under 0.05 s CPU.origin/main(merge commit, no rebase or force-push).python -m testing.pipeline_lab affected:discard, 16 scenarios;scenario runof all 16: 16/16 passed._plan_projectionwith production constants.Tests
backend/tests/unit/test_conversations_v3_engine.py, through the real_plan_projection,encode_row,protect_segmentsandreveal_segments.main_cappedis a literal copy of main's cut, andscaled()divides every size bound (budgets, limits, storage capacities) by 10. Covers:backend/tests/unit/test_conversations_v3_live_passes.py, through the realreconcileandcommit_projectionon StrictFirestore. The new tests write through the real commit codec and read back throughdecode_row. Covers:test_conversations_v3_backfill.pyparity now ignores the carried encoding, which is the per-encode copy of the row.UI evidence
UI-Evidence: none -- backend planner change, no UI.
Failure class (fixes)
Failure-Class: new
Failure-class transition narrative (only when needed)
Adds
FC-size-cap-measures-proxy-not-stored-encoding(familycross-boundary-contract): a size cap that protects a storage limit must not cut content on a proxy several times the stored size, and correcting that must not trade away the guard's safety. The planner's estimate and the writer's codec disagreed by about 5.6x, so the guard split ordinary conversations at a quarter of the field limit. No existing class states this:FC-permanent-write-rejection-retried-forevercovers retrying a rejected write, not the guard's measure.Canonical guard:
Artifacts:
backend/tests/unit/test_conversations_v3_engine.py,backend/tests/unit/test_conversations_v3_live_passes.py. Evidence: the production numbers above (this PR).🤖 Generated with Claude Code