Repository navigation
fix(stt): scope and bound speaker identity - #12097
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Git-on-my-level
force-pushed
the
codex/stt-clustering
branch
from
August 23, 2026 18:01
f1f80d5 to
0c6dc79
Compare
Separate noisy short-clip clustering from enrolled voice verification, cap centroid growth with nearest-cluster merging, and allocate conversation-local IDs from provider epochs. Persist explicit speaker identity evidence so an enrollment no-match is no longer indistinguishable from a confident negative. Verified: 436 affected and adjacent tests passed in file isolation; the broad backend runner completed 890 of 892 files with no recorded failures before two unrelated action-item files failed to return. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
The epoch stamp overwrote each segment's stt_provider with the host's configured STT selection. A socket that knows which peer actually served the segment stamps that name itself, and the configured selection does not change across a fallback, so the overwrite erased exactly the transition the epoch exists to separate. Five hermetic e2e tests caught it: the wire contract observed 'parakeet' where the peer was 'parakeet-wire-peer', and streaming STT observed 'parakeet' where the fake socket had stamped 'e2e-streaming-stt'. Treat a segment's own provider as authoritative and fall back to the caller's name only when the segment carries none. The epoch now advances per segment, so a provider change inside one batch opens a new scope instead of being flattened. No registered failure class covers a coarse default overwriting a finer value the producer already stamped, and one occurrence does not warrant a new registry entry. Failure-Class: none Co-Authored-By: Claude Opus 5 <[email protected]>
…keys The conversation speaker allocator's _next_id had no sentinel exclusion, and provider transitions multiply (scope, speaker) keys, so a long session with repeated fallbacks could allocate 99 - the exact value onboarding stamps on Omi's question segments - to a real speaker. Reserve the value so the sentinel is unreachable no matter how many scopes one socket mints, and pin it to OnboardingHandler.OMI_SPEAKER_ID from a file that already owns that import chain (the fast-unit duration guard charges first-import CPU to the importing test). Allocator keys also used the raw speaker label. Providers disagree on zero padding (SPEAKER_02 vs SPEAKER_2) and the custom-STT wire contract accepts a bare speaker_id with no label, which assign() synthesized as an unpadded SPEAKER_2: one human inside one provider scope could split into two speaker IDs depending on which segment arrived first. Canonicalize SPEAKER_<digits> keys identically in hydrate() and assign(). Verified: both defect tests fail on the pre-fix code (split identity assert 3 == 2; unreserved sentinel) and pass after; full backend/test.sh green. Failure-Class: none - no registered class covers in-session speaker identity allocation; the registry's identity classes concern imports and signing.
… mean At the eight-centroid cap, select_speaker_cluster force-merges a threshold miss into the nearest centroid but returned create_new=False identically to a real match: callers could not tell a forced merge from an earned one, the merge was invisible to telemetry, and the missed embedding was folded into the winning centroid's running mean - dragging that centroid toward a different speaker and chaining further misattributions once the cap filled. The fallback-telemetry contract requires correctness-changing fail-open branches to be observable, and this one was structurally unobservable. Return a fourth `capped` value from both copies (the backend policy module and the Parakeet image mirror), report backend merges through the shared fallback telemetry (reason=capacity_full, outcome=degraded), log them in the standalone Parakeet image (separate deployment, no shared helper import), and keep the miss out of the running mean so capped speakers cannot drift someone else's centroid. ARCHITECTURE.md and the pusher pipeline doc now state the actual cap behavior. Also pins the strict threshold boundaries (exactly 0.60 clustering / 0.45 enrollment are NOT matches) and adds the conference-call shape test: a rarely-speaking owner among many speakers must not fragment across cluster IDs. Failure-Class: none - no registered class covers diarization cluster caps; this is observability plus centroid-drift prevention, not a recurrence of a known failure class.
SkipJsonSchema excludes speaker_id_scope and speaker_identity_status from the generated OpenAPI/Dart/Swift client schema only; model_dump still carries them into Firestore, REST response bodies, and the pusher transcript frames (which document both fields). The old comment claimed they were "not part of the first-party app wire contract", which is false for the wire surfaces that serialize model_dump - say what the annotation actually does. Failure-Class: none - documentation-only correction, no behavior change.
Git-on-my-level
force-pushed
the
codex/stt-clustering
branch
from
August 24, 2026 06:04
4a6684f to
0b56302
Compare
kodjima33
approved these changes
Aug 24, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Substantial speaker-identity/diarization rework (925+/66-, 19 files) -- well tested but reads as a hardening/refactor rather than a narrow bug fix, well over the scoped-diff bar. Approving only, not merging; flagging for a manual look given the size and scope.
This branch was successfully deployed
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.
Summary
0.60threshold while leaving enrolled-voiceprint verification at0.45(speaker_id_scope, speaker), so padded labels, provider changes, and reconnects cannot collidespeaker_identity_statusasuser,not_user,no_match, orunknown; a failed enrollment match is no longer represented only by the legacyis_user=falseprojectionFailure boundary
The authoritative boundaries are now explicit: clustering policy owns in-session centroid identity, provider epochs own provider-local numbering, the conversation allocator owns persisted integer IDs, and enrollment matching owns the evidence state behind
is_user. The Parakeet runtime image cannot import backend utility modules through its deployment source closure, so its existingspeaker_math.pyboundary mirrors the clustering defaults and bounded-nearest policy; tests pin both implementations.The memory consumer is intentionally outside this branch. It still reads a bare
is_userboolean today; the parallel memory change must treatspeaker_identity_statusvaluesno_matchandunknownas uncertain rather than confidently third-party.Verified diagnosis and corrections
stt_providerwith the host's configured STT selection. A socket that knows which peer actually served the segment stamps that name itself, and the configured selection does not change across a fallback, so the overwrite erased exactly the transition the epoch exists to separate. Five hermetic e2e tests caught it (parakeetobserved where the peer wasparakeet-wire-peer;parakeetwhere the fake socket had stampede2e-streaming-stt). A segment's own provider is now authoritative, the caller's name is a fallback, and the epoch advances per segment so a provider change inside one batch opens a new scope. This is also the correction to the bullet below: normal backend STT segments do reachenqueuecarrying a provider on the paths the hermetic harness exercises.0.45enrollment threshold was also reused bybackend/utils/stt/pre_recorded.pyandbackend/parakeet/transcribe.py, not only the two streaming paths named in the report.connect_stt_socket_with_fallbackchanges provider only while establishing a socket. A live provider failure terminates that connection; a resumed conversation can still acquire a colliding namespace on its next WebSocket connection, so the epoch is connection-scoped as well as provider-scoped.stt_provider; only the custom-STT payload path stamped it.External evidence for changed expectations
The account measurement supplied with this task covered 57 conversations, 4,047 segments, and 200 memories. It also identified conversation
30e9e5d6-e7fd-4f9c-91ad-f219e5b1952f, where unpadded and padded provider labels coexist and one integer speaker identity carries contradictoryis_uservalues. Those observed persisted shapes are the external basis for the new collision and reconnect regression expectations.Verification
SpeakerIdentityStatusdid not exist; the remaining regression files reported4 failed, 63 passed(explicit scoped ID overwritten, reconnect segments merged, and both backend and deployed-Parakeet clustering created a ninth speaker)436 passed39 passedacrosstest_transcript_segment.pyandtest_transcribe_speaker_id_queue_pii.py0 errors, 3752 warnings, 0 informationspython -m compileallfor the changed backend modules: passedspeaker_id_scopeandspeaker_identity_statusremain persistence-only backend fields:model_dumpincludes them, whileSkipJsonSchemakeeps the app-client OpenAPI and all generated client contracts unchanged105/105, app-client OpenAPI and generated-client snapshots were current, and Black reported 20 files unchangedbackend/test.sh: 890 of 892 isolated test files wrote successful status and none wrote a failure; the run was stopped after the two unrelated action-item files did not return.test_action_item_canonical_contract.pyhad already printed13 passed;test_action_item_vector_best_effort.pyhad reached 75%. This is not claimed as a completed full-suite pass.16/16alone; four Modulate retired-config failures passed94/94alone. Two real parity fixture mismatches were fixed and then passed2/2alone.bash backend/testing/e2e/run.sh):116 passed, 3 skippedafter the provider-preservation fix; before it, 5 failed105 passedProduct invariants affected
none
Failure class (fixes)
Failure-Class: none
Line-Count-Exception: backend/utils/stt/streaming.py | 1683 -> 1692 | Cap-forced merge fallback telemetry and centroid-drift guard required by docs/agents/fallback-telemetry.md; the +9 lines are the record_fallback branch that makes the eight-speaker cap observable.