Repository navigation
Conversation
Merging conversations that overlap in time sorts the merged transcript by start, so the sources' lines interleave. The correction transfer that runs after the merge expected each source's lines as one block in merge order, so its captured-speech check failed for every such merge, with or without transcript corrections. The merge rolled back, the sources came back unmerged, and no failure message reached the user. The merge now returns where each source line landed, and the transfer checks the captured speech and moves correction anchors through that map. Merges whose sources do not overlap keep the same layout as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Verdict: the fix is correct and nicely scoped — it resolves a real bug where every merge of conversations overlapping in time failed and silently rolled back, and the explicit placement map is the right design. Leaving formal approval to a human maintainer since this touches the correction-transfer transaction. Findings by file:
Security/data integrity: the correction and receipt remapping stays inside the same Firestore transaction with the same ReviewConflict fences (account-deletion fence, deleted/locked source, already-moved anchors). No new trust boundary, no data leaves the transaction. Blast radius if wrong: merges — but the strengthened shape check plus the per-position text check make a mis-bound correction anchor fail closed into a rollback, which is the pre-existing safe path. Performance: one permutation map per merge on top of the sort that already existed — negligible. USER IMPACT: merging two recordings that overlap in time now completes and keeps transcript corrections on the right lines, instead of the merge quietly undoing itself. What I'd still want as a reviewer (non-blocking): a variant with corrections on both overlapping sources, and a pinning test for equal- by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…start ordering Review follow-up. Both tests drive the real perform_merge_async and the real correction transfer with the same fakes as the existing overlap test. - Corrections on both overlapping sources land on their own merged lines, both sources are sealed, and undoing one source's correction through its moved receipt restores only that line. - Lines from different sources with the same merged start keep source order (the stable sort), and a correction on the later source's tied line stays on that line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Added both tests to 🤖 Generated with Claude Code |
…22385) Co-Authored-By: Claude Opus 5.5 <[email protected]>
What changed and why
Fixes #22319.
Merging two conversations that overlap in time (for example, a short recording made during a longer one) fails on
main.perform_merge_asyncsorts the merged transcript by start, so the sources' lines interleave. The correction transfer added in #21480 (review_overlay_merge.transfer) then looked for each source's lines atoffset + i, as if every source were one block in merge order. For an overlapping merge that check raisesReviewConflict('Captured speech changed during merge'), whether or not either conversation has transcript corrections.perform_merge_asynccatches it after the merged conversation has already been processed, deletes the merged conversation and resets the sources._handle_merge_failuresends no failure notification, so the user's merge just undoes itself.The fix:
_merge_transcript_segments_with_placementsreturns the merged transcript plus, for each source, the merged index of each of its lines._merge_transcript_segmentsstill returns the same transcript.perform_merge_asyncpasses those placements totransfer, which checks the captured speech and moves correction anchors (and their Undo receipts) through them. The shape check now requires the placements to cover every merged line exactly once.transferkeeps the block-per-source layout, which is what merges of non-overlapping conversations produce.Product invariants affected
none
How it was verified
origin/main(8ed3ad1b1b): the chronological sort in_merge_transcript_segments(7f47667) and the positional check intransfer(feat(dream): verified shared harness, immutable corrections, and all-user cleanup #21480).long-early, short-only, long-late. The old check rejects it. The new one accepts it with placements[[0, 2], [1]], so a correction onlong-latemoves to merged line 2. Non-overlapping sources still get[[0, 1], [2]], the old layout.scripts/backend-python-format --write(no changes),python -m py_compileon the changed Python files, andscripts/failure-class validateon this body.ci:full).Tests
backend/tests/unit/test_merge_overlapping_sources.py::test_overlapping_merge_completes_and_keeps_the_correction_on_its_lineruns the realperform_merge_asyncand the realtransferagainst the strict in-memory Firestore fixture. Two encrypted conversations overlap, and the owner first corrects the later line of the longer one throughedit_user_segment. The test asserts that the merge completes (failure handler not called, one completion message), that the merged transcript reads early line, short line, corrected late line, and that the source is sealed to the merged conversation. Onmainthe transfer rejects this merge and the failure handler runs.backend/tests/unit/test_merge_deleted_source_race.py: two tests stubbed the merge step thatperform_merge_asynccalls. The stubs now target the new helper.UI evidence
UI-Evidence: none -- backend-only change; the regression test drives the merge end to end.
Failure class (fixes)
Failure-Class: new
Failure-class transition narrative
New class
FC-merged-layout-assumed-from-source-order.backend/tests/unit/test_merge_overlapping_sources.py, which feeds interleaving sources through the real merge and the real transfer.origin/mainbefore this change.evidence_prsis empty because this PR is the first instance.🤖 Generated with Claude Code