Skip to content

fix(speakers): make cross-conversation speaker labeling viable on mobile (canonical identity, one manual-assignment owner, live names, summary refresh) - #15247

Merged
Git-on-my-level merged 22 commits into
mainfrom
feat/mobile-cross-conversation-speakers
Sep 21, 2026
Merged

Git-on-my-level merged 22 commits into
mainfrom
feat/mobile-cross-conversation-speakers

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Why

Goal: label a speaker once — in a conversation or across conversations — and have the name show up in live transcription and in summaries, on mobile. An audit of the mobile app and the backend speaker pipeline (independently verified by a second model, which also refuted one of the audit's claims) found that the matching policy from #12935 and the profile transaction from #14842 are sound, but the identity and mutation boundaries around them are not:

# Defect (verified at the base commit) Effect for the user
1 Mobile decodes speakerId by parsing the provider label and drops the wire speaker_id. Since #12097 the backend allocates conversation-local ids while the label restarts at SPEAKER_00 after any reconnect/STT failover. Repro: expected id 2, got 0. Two different people collapse into one "Speaker 1"; labeling one bubble mislabels the other person; backend suggestions target the wrong bubbles.
2 Offline/WAL chunks are transcribed independently and merged with no speaker scope. Repro through the production transaction: ids [0, 0]. Same collapse for synced audio.
3 REST assign replaces the whole transcript array; live capture writes whole snapshots from its cache; the socket keeps a third map. Failed saves are painted as success. Labels revert, corrections get overwritten, a failed save still looks saved (and could still teach).
4 The transcript widget negative-caches unknown people forever; the photo/timeline layout shows no speaker identity at all. Names never appear until the page is rebuilt; timeline users see no names.
5 Nothing offers a summary refresh after a label change. Summaries keep saying "Speaker 2".
6 The bulk option only lists untagged segments. A wrong auto-assignment must be fixed bubble by bubble (#4853).
7 No signal whether a person's voice was actually learned; rename drops sample metadata and resets the sample version. "I tag people every day and only two are recognized" (#7187) is invisible to the user.

Problem and change

Mobile decoded provider labels instead of canonical speaker IDs, offline chunks reused independent IDs, and competing REST/live/socket mutations could lose manual corrections. Failed mobile saves could still look successful. This change preserves canonical mobile identity without rewriting provider labels, allocates scoped WAL identities, and routes all three assignment APIs through one transactional owner. The owner persists explicit MANUAL segment overrides and speaker defaults with segment IDs and a generation, invalidates affected profiles and client projections, and protects saved decisions from stale live/sync snapshots. Mobile paints and notifies only after acknowledgment, honors selected versus whole-speaker scope, and keeps failed saves open.

Transcript and photo timeline names follow PeopleProvider. Rename preserves voice metadata. People exposes evidence-derived ready / saved_sample_awaiting_embedding / not_learned / unknown states. Verified audio alone does not imply usable recognition or a running job. Profiles refresh at the next conversation boundary. Saved changed attribution offers an explicit summary reprocess action; failure retains the label and retry. Name-only suggestions use the existing sheet, malformed events are ignored, and detection receives the actual language.

Live enrollment remains best-effort. REST extraction and the acknowledged delayed Pusher request remain working. Pusher publishes audio manifests during capture, but a crash between assignment and dispatch, an attempt before manifest/tail availability, or extraction/provider failure can still lose teaching. No enrollment job, outbox, lease, retry worker, or reconciliation guarantee is added. Persisted MANUAL provenance is the receipt for the separately stacked durability follow-up.

Verification

Product verification uses local synthetic tests. Focused pre-commit results: canonical decode/local store 9 Flutter tests; sync identity/teaching 45 backend tests; manual owner/routes/listen/sync 83 backend tests plus 41 trust-boundary and 4 projection tests; capture/composition 102 Flutter tests; metadata 3 Flutter tests; readiness/teaching/runtime 51 backend tests plus 46 lifecycle tests; mounted transcript/people 23 Flutter tests; summary action/provider 16 Flutter tests plus 1 production formatter-to-stub-LLM test; language/teaching/runtime 45 backend tests. Final validation is listed below.

Final commands:

  • BACKEND_UNIT_TEST_FILE_LIST=<the five previously CI-red files> bash backend/test.sh — 350 passed across the five previously CI-red files (test_sync_v2.py 176, test_sync_cloud_tasks.py 91, test_sync_transcription_prefs.py 66, test_listen_process_pending_shutdown.py 13, test_conversation_archive_filter_contract.py 4), exit 0 (review round 2).
  • python3 backend/scripts/check_unit_test_discovery.py — 1195 selected, 0 orphans, exit 0 (review round 2).
  • Full bash backend/test.sh (no file list) is not re-run this round: test_mentor_notifications.py reaches live Google HTTPS through this Mac's ADC and hangs. Review round 3 used file lists only.
  • Review round 3 speaker list (13 files: previous 16 minus the six duration-guard files, plus test_transcript_segment.py, test_speaker_match.py, test_transcribe_decisions.py) — 569 passed, exit 0.
  • Review round 3 duration-guard files in isolation (6 files from the previous 16-file list) — 56 passed, exit 0 (CPU warnings only; none exceeded the 0.30s fail limit). Combined unique coverage 625 passed across 19 files.
  • bash app/test.sh — hermetic app suite 2488 passed, 5 skipped, exit 0 (review round 2). No Flutter test files were touched this round.
  • bash app/scripts/analyze_ratchet.sh — passed, exit 0 (several lint codes under baseline; no baseline raise).
  • OMI_PR_BODY_FILE=<this body> make preflight — 42 checks passed, exit 0 in 140.35s.
  • scripts/failure-class validate --pr-body-file <this body> — ok, exit 0 after 7e4513376e (declaration FC-split-mutation-authority).
  • scripts/pr-preflight --suggest is covered by the preflight product-invariants check; no path-matched locked invariant besides the voluntary INV-UI-1 citation. INV-MEM-4/INV-TASK-2 authority remains unchanged.

Tests execute production wrappers, providers/widgets, HTTP handlers, formatter and strict transaction seams. Audio/storage/STT/embedding/LLM boundaries use synthetic fakes. The strict Firestore fixture proves ordering and write policy, not real distributed contention.

The name-only expectation replaces the previous ignore behavior according to the existing person_id_for_client wire contract (backend/utils/transcribe_decisions.py) and the accepted F9 scope: an empty person ID with a name is a suggestion, never an automatic assignment. Existing static serialization inventories only remove the retired whole-array dumps; they are not claimed as behavioral coverage.

Schema/clients regenerated with backend/scripts/export_openapi.py --app-client --write, public/integration export, generate_dart_models.py --all, generate_swift_openapi_types.py, and generate_ts_openapi_types.py. Cached fake Firestore/Redis dependencies were used locally. One select localization key added using app/scripts/l10n.py add with real translations for all 49 locales. Diff accounting against local origin/main bb6bde8: handwritten production 787 additions / 558 deletions across 31 files; tests 895 / 34 across 16 files; localization 797 / 48 across 99 ARB/generated Dart files; other generated schema/clients 35 / 3 across 6 files; docs/guard metadata 74 / 12 across 5 files. Rebased locally over the connected-component sync update and added bridge/retry/manual-curation regressions. Dart formatted at line length 120; Python via scripts/backend-python-format --write.

Commit consolidation preserved the exact validated tree (8ace33da42b4194ddecde7cbea85cca66d52d51f). Review-round-1 fixes added eleven local commits on this branch. No product-tree repro copies or unstaged changes. No skip hatch or ratchet-baseline increase was used. Four exact file-size exceptions below are required by the real diff.

Invariants and failure class

INV-UI-1: no new purple; edited timeline uses neutral colors. INV-MEM-4 and INV-TASK-2: no new memory/task write authority; manual teaching does not create memories or tasks, and opt-in reprocessing retains existing routes and policies.

Failure-Class: FC-split-mutation-authority

Reusable behavioral guard: backend/tests/unit/test_manual_speaker_assignments.py, together with canonical mobile decode, WAL identity, mounted people-refresh, readiness and summary-action tests. Repairs the same competing identity/profile authorities as prior-art #14842. No ratchet baseline is raised.

Follow-ups and limits

  • Stacked durable teaching owner/outbox/job, leases, audio-readiness wakeups, bounded retries, deletion/correction fencing and reconciliation worker (accepted plan row 4).
  • Cross-client canonical speaker_id adaptation: installed old mobile builds remain affected until updated; macOS/Windows/web domain adaptation is not completed by regenerated wire clients. Allocator/egress label rewriting needs its own cross-client/hash migration.
  • Threshold changes, centroid/multi-sample enrollment and locked-match reevaluation remain excluded. Existing live >=5s/<=3-clip versus sync longest-clip >=1s policy divergence remains.
  • No new inline suggestion cards; only the existing name sheet is wired.
  • Exact historical summary-staleness receipt remains deferred; the reprocess offer does not claim that an older summary used unnamed speakers.
  • Past-conversation acoustic relabeling, historical identity repair, merge-people, and an offline manual-edit queue need separate designs.
  • On-device/custom-STT diarization and multiple people sharing a phone-call channel remain capability gaps. Manual editing still works; new recognition is not advertised there.
  • Hot replacement of current-session locked matches/profiles remains deferred; refresh occurs at a new conversation boundary.
  • Brand cleanup beyond the edited speaker UI remains out of scope.
  • No new workflows, broad remote backfill, remote issue creation, release or deployment work.
  • Private-cloud-off prevents new saved capture audio, not existing profiles or all recognition. Teaching needs available saved audio.

Not run: physical acoustic acceptance, real voice/provider/LLM accuracy, device installation, production/dev backend, remote account/storage operations, or distributed Firestore contention.

Line-Count-Exception: backend/database/conversations.py | 2526 -> 2676 | Keep the transactional speaker command at the existing conversation codec and projection boundary; pure manual policy is extracted to utils/manual_speaker_assignments.py.
Line-Count-Exception: backend/utils/sync/pipeline.py | 2498 -> 2506 | Pass retry-stable speaker scope and detected language through the existing STT intake coordinator.

Line-Count-Exception: backend/routers/users.py | 2435 -> 2436 | Derive stored voice readiness before replacing sample paths with playback URLs, so URL availability cannot misreport learning state.
Line-Count-Exception: app/lib/services/capture/capture_controller.dart | 2889 -> 2900 | Live labeling writes a speaker-wide default through the existing capture assign owner so later bubbles of the same speaker_id are named.

Review round 1

Adversarial review requested changes on live labeling scope, receipt size/protection, locked/unresolved wire details, merge-vs-receipt, labeled sync rows, matcher rollover, silence-flush payload, teaching candidate choice, people list/readiness, and app polish. Each finding maps to a local fix commit:

Finding Fix
Live first-bubble labeling stayed selected-only (P0-1) efc1d85f93 make live labeling speaker-wide including later speech
Receipt was a dense plaintext map (P1-1, P1-2, P2-10) 15e77e4194 store sparse protected speaker receipts
Locked assign was 403 and 409 dropped ids (P1-3, P2-2, P2-3) 467d95fd64 restore locked 402 and unresolved 409 details
Merge absorbed a labeled id without remapping (P1-4) be4d0ffc85 move receipts off absorbed merge identities
Labeled sync rows split later WAL chunks (P1-5) 0bebd03d75 append later chunks into labeled recordings
Matcher wrote after conversation rollover (P1-6, P2-4) 8c75f57fc3 drop matcher writes after conversation rollover
Silence flush sent the whole transcript (P1-7) bc6254a16e deliver only identity-changed silence-flush segments
Whole-speaker teaching used every cluster id (P2-1) cba75e10b9 teach from the longest bounded clips; 8abc0744e3 rank those clips from stored segments without dumping Conversation
People list/readiness/sample-delete holes (P2-5, P2-6, P2-8) c3486308c1 trust list deserialization and sample-delete readiness
Missing taggedSegment, reused summary copy, per-row people decode (P2-7, C3/C6/C8) f8a4925823 restore tagging analytics and resolve people once

Live enrollment remains best-effort as originally declared. No skip hatch or ratchet-baseline increase was used.

Review round 3

Coordinator review of fix round 1 required three production repairs. Local commit 7e4513376e:

Finding Fix
Empty-profile load_and_run exited the matcher loop for the whole socket session, so a first-use label plus later refresh_for_conversation never consumed the queue Keep the matcher loop alive; should_queue_speaker_embedding's has_person_embeddings is read live from speaker.person_embeddings; teardown with zero tasks still skips speaker_id_done
Absorbed merge ids traveled as a hidden .into on a list subclass, so list(...) / copies silently dropped the remap CombineSegmentsResult unpacks as the existing 3-tuple and carries absorbed_into as a named field; update_conversation_segments(..., absorbed_into=) is the explicit keyword
Flush backoff used getattr for fields already set in __init__ Direct attributes; flush tests construct TranscriptProcessor through __init__

Review round 4 (coordinator)

The pre-push typecheck rejected round 3: CombineSegmentsResult.__iter__ types as a union, so the three production unpack sites produced 13 pyright errors. e8ffb991ff reads the named fields at those call sites and makes the listen-runtime fake return the real result type. scripts/typecheck.sh — 0 errors; five affected backend files — 189 passed.

Independent coordinator verification of the final tree (not the delegates' reports): 19 backend files through backend/test.sh — 658 passed, 0 failed, including all five files that were red on the first CI run; seven touched Flutter test files — 127 passed.

Decode explicit speaker_id before the legacy label fallback and retain it through local reloads. Display numbers no longer change when a speaker is labeled as self.

Validation: flutter test --no-pub test/unit/transcript_speaker_identity_test.dart test/unit/local_segment_store_test.dart (9 passed).

Failure-Class: FC-split-mutation-authority
Hydrate the destination allocator inside atomic intake after deduplication. Scope provider IDs to retry-stable audio content without rewriting labels or historical segments.

Validation: pytest test_sync_cross_job_assignment.py test_stt_speaker_identity.py test_taught_speaker_persistence.py (45 passed).

Failure-Class: FC-split-mutation-authority
Persist MANUAL segment decisions and speaker defaults with generations; fence profile correction and overlay manual decisions on live and sync writes. Only acknowledged edits paint mobile state or wake best-effort teaching. Durable enrollment remains deferred.

Validation: 83 focused backend tests; 41 trust-boundary checks; 4 projection assignment tests; 102 capture/composition Flutter tests passed. Synthetic transactions and HTTP route teaching only; no remote or acoustic acceptance.

Failure-Class: FC-split-mutation-authority
Keep transcripts, sample version, and display color after an acknowledged rename. Validation: 3 PeopleProvider tests passed, including provider and persisted-cache metadata checks.

Failure-Class: FC-split-mutation-authority
Subscribe transcript and photo timeline names to PeopleProvider, derive readiness from stored sample/vector evidence, and refresh profiles at new conversation boundaries. Add one select localization key in all 49 locales via l10n.py. Generate schema and clients with repository generators.

Validation: 51 readiness/teaching/runtime tests, 46 lifecycle tests, and 23 Flutter transcript/people tests passed. No physical acoustic acceptance or durable enrollment worker.

Failure-Class: FC-split-mutation-authority
Show the existing reprocess action beside the transcript only after a changed acknowledged label on summarized completed content. Keep retry available on failure and deduplicate in-flight requests; guard conversation selection across awaits.

Validation: 16 Flutter provider/widget tests and one backend production formatter-to-stub-summary test passed. No LLM service called.
…ection

Wire name-only suggestions into the existing sheet without losing the proposed name or overwriting manual labels. Drop malformed and stale events; forward live/sync language. Share deterministic legacy segment IDs between reads and manual writes. Document best-effort enrollment and capability limits.

Validation: 107 capture/transcript tests and the name-sheet widget regression passed; 45 language/teaching/listen tests passed. Backend runner timing failures fixed by collection-time imports; legacy-ID read/write transaction regression included. Restore protected capture spine fixtures and use the production snapshot-install boundary for tests.

Failure-Class: FC-split-mutation-authority
@mintlify

mintlify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Sep 20, 2026, 7:39 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Git-on-my-level and others added 15 commits September 21, 2026 02:59
Live capture now opts into speaker-wide assignment as explicit sheet state so the first bubble names later same-speaker speech; detail stays selected-only unless the user checks the control.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Speaker-wide commands keep a constant-size speaker default, segment entries stay sparse overrides, and enhanced conversations encrypt the receipt the same way as the transcript.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Assign routes keep main's paywall and unresolved-target wire strings while still parsing is_user without treating "false" as true, and every selector invalidates projections through the real owner.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
When combine_segments swallows a bubble, its id is removed and any manual override moves onto the survivor so preserve_unseen cannot resurrect the unlabeled clone.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Manual speaker receipts no longer split a capture: later overlapping WAL still joins the labeled conversation, which stays the canonical survivor rather than a donor.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
In-flight match tasks keep their locks and re-check generation plus conversation id before mutating, and empty-profile sessions signal speaker_id_done without adding teardown wait.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
A successful live relabel now websocket-sends the changed bubbles instead of the whole transcript, and a failed persist backs off instead of spinning a full snapshot every 0.6s.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Speaker-wide assign still labels every matching segment, but extraction now receives at most three ids ranked longest-first so mixed diarization cannot pick the first cluster member.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
People list skips a malformed row instead of 500ing, response-shaped payloads keep a claimed voice_readiness, and deleting a sample no longer paints unknown while a refresh is in flight.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Acknowledged detail labeling emits taggedSegment again, the summary action has its own copy, and transcript/timeline rows receive Person from a single build-time lookup instead of decoding people per bubble.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Assign no longer dumps the Conversation model to pick extraction candidates, so the display-projection dump pin stays exact and ranking stays on the labeled transcript already returned by the owner.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Stubbed utils trees are not packages, so module-scope imports of the
receipt policy and allocator failed collection in CI. Register the real
modules and give fake listen hosts refresh_for_conversation plus an
empty speaker task set.

Failure-Class: none
Reason: test-harness isolation only; production import graph unchanged.
Co-authored-by: Cursor <[email protected]>
Decoding a missing receipt as {} and writing it back made unlabeled
recordings look labeled, so later connected chunks merged into the
first survivor instead of the earliest timeline.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
Empty-profile sessions must keep consuming the queue after a later
refresh, absorbed ids must travel as a named map, and flush backoff
must use the fields __init__ already sets.

Failure-Class: FC-split-mutation-authority
Co-authored-by: Cursor <[email protected]>
The tuple-unpacking __iter__ on CombineSegmentsResult types as a union, so
pyright rejected the three production unpack sites (13 errors) and the
pre-push typecheck refused the branch. Production callers now read the
named fields; the listen-runtime fake returns the real result type instead
of a bare tuple. Verified: scripts/typecheck.sh 0 errors; 189 tests passed
across the five affected files via backend/test.sh.

Failure-Class: none
Reason: type-level call-site repair for a result type introduced in this PR; no runtime behavior change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review September 21, 2026 02:24
@Git-on-my-level
Git-on-my-level merged commit e5b1539 into main Sep 21, 2026
71 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/mobile-cross-conversation-speakers branch September 21, 2026 03:40
Git-on-my-level added a commit that referenced this pull request Sep 21, 2026
…nting an empty stub (#15330)

* fix(backend): preserve protected rows during empty recording cleanup

Keep locks, deletion tombstones and sync revision ownership ahead of empty-live-row cleanup. Content continues to use the existing codec-aware transactional fence.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed, including 33 recording-session cases. Existing resume assertions stay unchanged; fixtures now include their real source/device/finished-at metadata.

Failure-Class: FC-split-mutation-authority

* fix(backend): reuse durable live continuations across reconnects

Keep an immutable original recording binding and transactionally adopt its compatible active continuation. Reconnects inside the shared silence boundary reuse the continuation; expired empty and unexposed losing generations use lifecycle-owned fenced cleanup before STT admission.

Reject deleted, discarded, locked and other-device rows. Keep existing explicit WAL targets authoritative. Tests reproduce newest-first/interleaved legacy hints, the remaining partial-flap limit, same-origin 35-second reconnects, exact 120-second rollover, protected content and legacy principals.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed. Hermetic E2E: 120 passed, 3 skipped, 2 xfailed. Sync Cloud Tasks emulator gauntlet passed. Live provider/client acceptance was not run; only hermetic service seams are authorized.

Failure-Class: FC-split-mutation-authority

* refactor(backend): keep reconnect eligibility in the pure continuity policy

Move the unchanged resumable-continuation predicate out of database storage and into the shared continuity module. Async callers now depend on the pure rule; transactional metadata access stays on the persistence executor. This addresses the installed pre-push async-boundary guard without an exemption.

Validation: BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-stt-selected-tests.txt bash backend/test.sh — 340 passed after the move.

* test(backend): keep listen resume coverage on the continuity-eligible path

The reconnect-continuity change now requires source/device/timeout on resume
and resolves a durable continuation before a rollover mint. The four skipped
tests still protect marker persistence, client-id reads, and the existence-read
skip; their hosts and fixtures needed those fields to reach that path.

Co-authored-by: Cursor <[email protected]>

* fix(backend): load speaker profiles when a listen reconnect resumes

#15247 refreshes conversation-scoped speaker profiles on mint. Continuity
makes resume the common reconnect path, so that load must happen there too
or a reused conversation would start a new socket with empty profiles.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 21, 2026
…t boundary (#15345)

* Protect labeled sync conversations during assignment

Exclude labeled donors before widening the interval; preserve an existing labeled anchor and treat explicit retargeting as terminal supersession.

Validation: BACKEND_UNIT_TEST_FILE_LIST=../.local/final-files.txt bash test.sh; test_sync_cross_job_assignment.py: 29 passed (full selected suite recorded in .local/REPORT.md).

Co-Authored-By: Claude Opus 5 <[email protected]>

* Plan live transcript merges against the committing manual receipt

Keep fresh STT input unmerged until the transaction reads current speech and receipt coverage. Protect selected IDs, speaker defaults, clears and opt-outs across every text-transfer branch. Return accepted client IDs and removals from the same attempt. Fix forward absorption and transitive remapping together with that protection.

Validation: BACKEND_UNIT_TEST_FILE_LIST=../.local/merge-files.txt bash test.sh passed, including all five required import-isolation suites. Native tests cover stale input, attempt replay, partial transfers and client/storage ID agreement. Existing remap tests that expected expanding a manual label were replaced by these production-boundary regressions, based on reproduced R3/R5(a) in merged PR #15247.

Latency: .local/benchmark_live_merge.py measured planner p95 0.091 ms at 1000 stored + 8 fresh segments; 12.245 ms at 10000 + the 1000-segment runtime buffer cap. SDK contention multiplies computation up to 5x; expiry restarts can combine to 15x. These are CPU/local wall measurements, not Firestore latency.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Preserve current manual speaker decisions in lifecycle commits

Both processing writers decode the committing receipt, overlay it on their encoded snapshot, and encode at the current stored protection level. Extend the existing lifecycle static tripwire to inventory transcript owners and reject an unguarded new snapshot writer.

Validation: BACKEND_UNIT_TEST_FILE_LIST=../.local/final-files.txt bash test.sh: 648 passed across 19 selected files, including 16 new lifecycle receipt cases and existing lifecycle/processing contracts. backend/scripts/check_conversation_lifecycle_writes.py passed. Summaries still require explicit refresh; stale non-sync processor content remains out of scope.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Migrate speaker receipts atomically with transcript protection

Read the current document in each migration transaction and re-encode its transcript and receipt together. Stored protection metadata outranks live caller hints. Reject non-object receipts at the write boundary while retaining tolerant reads for existing malformed shapes.

Validation: BACKEND_UNIT_TEST_FILE_LIST=../.local/final-files.txt bash test.sh passed; 11 storage regressions use real standard/enhanced codecs, both migration directions, legacy absence, an edit after the initial scan, repeat migration and malformed write inputs. No cloud migration was run; e2ee codec handling remains outside scope.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Handle speaker assignment transport failures through acknowledgement

Return false on assignment transport exceptions without painting optimistic identity or offering summary refresh. Remove the unused unassignConversationTranscriptSegment method instead of maintaining a second mutation path.

Validation: cd app && flutter test --no-pub test/providers/speaker_summary_refresh_test.dart: 4 passed. Transport failure leaves identity unchanged and an acknowledged retry succeeds. No strings or wire schema changed; device UI was not exercised.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Keep translation and inference patches from restoring retired segments

Field-only writers intersect their updates with current persisted IDs and preserve current speech text, spans and ordering. Translation publishes accepted results rather than the stale input. Remove the unused sync import and document the complete writer contract and deferred cache wake.

Validation: BACKEND_UNIT_TEST_FILE_LIST=../.local/resurrection-files.txt bash test.sh: 48 passed across nonowning writer, manual assignment and listen runtime suites. Full selected run: 648 passed. Lifecycle checker and async blocking scanner passed; no live service or customer data was used.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(tests): drop patches of the sync writer import this PR removed

Removing the dead `update_conversation_segments` import from utils/sync/pipeline.py made three
dedup tests fail at `mock.patch` setup: they patched it by that name and asserted it was never
called. The import was already dead at the merge base — imported, never invoked — so the
assertion could not have failed for a behavioural reason.

Replace it with a structural guard so the invariant those patches encoded survives: sync intake
must not acquire a second transcript writer that bypasses the manual-assignment receipt. The
guard reads the source instead of importing the module; importing the real module inside the
call phase cost 1.56s against the runner's 0.30s CPU budget, and a text check also catches a
reintroduced import that was never loaded.

Validation: the file passes via test.sh (46 passed, exit 0, no duration-guard failure), and a
sweep of all 37 test files that patch names on the modules this PR changes passes 1152 tests.

Failure-Class: FC-fixture-mock-signature-drift

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant