Repository navigation
fix(speakers): honor the manual-assignment receipt at every transcript boundary - #15345
Merged
Merged
Conversation
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]>
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]>
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]>
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]>
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]>
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]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
PR #15247 made cross-conversation speaker labeling viable on mobile. An external review of the merged
head then found that the manual-assignment receipt it introduced is not honored at every boundary. Three
independent verification passes plus executed reproductions confirmed the core of it. This PR closes those
gaps.
The headline defect is not cosmetic: a live merge could widen a labeled segment's span, and the voice
enrollment window is cut from the centre of a segment's current bounds
(
utils/speaker_identification.py,SPEAKER_SAMPLE_WINDOW_HALF = 5.0). A 1-second label absorbed into a10-second span therefore fed another person's voice into the labeled person's profile.
What was wrong, and what this changes
Live merging ignored the receipt (R3 + R5a).
combine_segmentshad no identity guard at all —person_idappeared zero times in it. The forward-merge branch also emptied the accumulator withoutrecording the absorption, so a label applied to a live bubble was silently lost and its enrollment
silently skipped (
Segment ... not found→continue).Fresh STT input is no longer merged before persistence. The live call passes it through to the existing
transcript transaction, which decodes the current persisted transcript and receipt and plans the merge
there via
merge_live_segments. Any merge or partial transfer touching covered speech is refused — selectedids, speaker-wide defaults, clears, opt-outs, and legacy receipts that carry ids but no newer fields. The
transaction returns the accepted transcript plus removal/absorption metadata, so the client and storage
cannot disagree about which ids exist.
A cache-based guard was designed first and rejected: the live
ConversationCacheholds a snapshot for30 s and
assign_conversation_speakerinvalidates only the client projection, so the guard read an emptyreceipt in exactly the dangerous window. A cache guard can be an optimization; it cannot be the correctness
boundary.
Sync could absorb and tombstone a labeled conversation (R2). The labeled-donor protection in
utils/sync/assignment.pywas gated onnot target_id, so the routine offline path(
/v2/sync-local-files?conversation_id=…) bypassed it.auto_mergeabledoes not considermanual_speaker_assignments, so a labeled row was still auto-mergeable. Labeled donors are now excludedbefore they widen the search extent, and a labeled retry anchor cannot be retargeted — raising
SyncAssignmentSuperseded, notSyncAssignmentConflict, because the latter is a loud retryable errorand this condition is permanent.
Two of three transcript writers dropped the receipt (R1).
upsert_conversation_with_lifecycleandpersist_processing_result_with_lifecyclere-read inside their transaction and preserve title/folder, butnever re-applied manual decisions;
sync_content_revisionnever arms for listen/desktop rows. A processorholding a pre-label snapshot reverted the user's label while the receipt sat orphaned, which also
de-authorized teaching via
acknowledged_teaching. Both writers now overlay the current stored receipt, andscripts/check_conversation_lifecycle_writes.pywas extended so a fourth writer cannot reintroduce theasymmetry.
Storage (R6a, R6b, R4). Protection migration now moves the receipt with the transcript under one
transactional document decision.
update_conversation_segmentstakes the stored protection level over acaller hint. A non-dict receipt is rejected at the write side — deliberately not by making the read
decoder raise, which would have turned an unreachable silent bug into a reachable outage in the ~0.6 s live
persistence loop.
Retired ids could be resurrected (R5b). Translation and speaker-flush writers shipped whole segment
lists they did not own. They now patch only their own fields, intersected with current persisted ids.
Client (R8).
unassignConversationTranscriptSegmenthad zero call sites; deleted rather than patched. Atransport exception in
assignSpeakernow returns false instead of propagating.Latency
Merge planning moved inside a transaction, so it runs under retry amplification. Measured
(
.local/benchmark_live_merge.py, 60 samples/case), planner computation only:Against the 600 ms live interval this is immaterial in the realistic case. Worst case with the SDK's 5
contention attempts and up to 3 expiry restarts is a computed ceiling of ~184 ms (~31% of the interval) —
disclosed, not measured under real contention. Mitigated by hydrating only the mutable tail and fresh batch;
no additional transaction read was introduced.
Verification
backend/test.sh(coordinator's independent run);648 across 19 files in the implementer's run. Includes all five suites that stub
utilsas a non-packageand reddened all four CI shards on fix(speakers): make cross-conversation speaker labeling viable on mobile (canonical identity, one manual-assignment owner, live names, summary refresh) #15247.
backend/scripts/typecheck.sh: 0 errors. Lifecycle checker, async-blocker scan and test-discovery: pass.Not verified: physical-device acoustic acceptance, real STT/embedding/LLM, real Firestore contention,
dev/prod backend. No recognition-quality claim is made by this PR. Matcher thresholds, embeddings and
recognition policy are untouched.
Deliberately not in this PR
registry.pyonly subscribes toproactive_message:listenand always builds aProactiveMessageEvent, so a distributed assignment wake needs new typed dispatch — and it cannot makemerging correct. Consequence: a label saved elsewhere may look stale in the live view until a reload,
socket notification, or covering update. The transaction still protects the saved span throughout.
speaker_id; processor snapshotsstaleness in content for non-sync rows; the
e2eecodec level; R7 same-conversation profile refresh(an intentional scope decision, not a defect).
Line-Count-Exception: backend/database/conversations.py | 2695 -> 2788 | Receipt overlay helper shared by both lifecycle writers, transactional migration reread, and the live merge planner entry point stay with the transaction owner.
Failure-Class: FC-fixture-mock-signature-drift
Removing the dead
update_conversation_segmentsimport fromutils/sync/pipeline.pybroke threetests that monkeypatched it by that name — the limiting case of a mock site drifting from
production. That class's canonical prevention is to grep the test tree for monkeypatch sites of a
symbol the PR changes and update them in the same PR; the fix does that, and the invariant those
patches encoded is now a structural source check rather than a patch on a name that no longer
exists.
🤖 Generated with Claude Code