Skip to content

fix(stt): scope and bound speaker identity - #12097

Merged
Git-on-my-level merged 5 commits into
mainfrom
codex/stt-clustering
Aug 24, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
codex/stt-clustering

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • give short, noisy in-session speaker clustering its own 0.60 threshold while leaving enrolled-voiceprint verification at 0.45
  • cap each clustering session at eight centroids and merge later misses into the nearest running centroid without dropping transcript text
  • stamp provider/connection epochs before persistence and allocate conversation-local speaker IDs from (speaker_id_scope, speaker), so padded labels, provider changes, and reconnects cannot collide
  • persist speaker_identity_status as user, not_user, no_match, or unknown; a failed enrollment match is no longer represented only by the legacy is_user=false projection

Failure 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 existing speaker_math.py boundary 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_user boolean today; the parallel memory change must treat speaker_identity_status values no_match and unknown as uncertain rather than confidently third-party.

Verified diagnosis and corrections

  • The epoch stamp initially 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 (parakeet observed where the peer was parakeet-wire-peer; parakeet where the fake socket had stamped e2e-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 reach enqueue carrying a provider on the paths the hermetic harness exercises.
  • The 0.45 enrollment threshold was also reused by backend/utils/stt/pre_recorded.py and backend/parakeet/transcribe.py, not only the two streaming paths named in the report.
  • connect_stt_socket_with_fallback changes 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.
  • Normal backend STT segments previously did not persist stt_provider; only the custom-STT payload path stamped it.
  • Ordinary processed short-term memories expire after 48 hours, but pending-required-processing rows have an explicit eligibility exception. This does not remove the identity-loss path for ordinary rows.

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 contradictory is_user values. Those observed persisted shapes are the external basis for the new collision and reconnect regression expectations.

Verification

  • red-before runs: the new model test initially failed at collection because SpeakerIdentityStatus did not exist; the remaining regression files reported 4 failed, 63 passed (explicit scoped ID overwritten, reconnect segments merged, and both backend and deployed-Parakeet clustering created a ninth speaker)
  • affected and adjacent test files, each named directly and run in isolation: 436 passed
  • final persistence-only schema rerun: 39 passed across test_transcript_segment.py and test_transcribe_speaker_id_queue_pii.py
  • proper backend typecheck: 0 errors, 3752 warnings, 0 informations
  • python -m compileall for the changed backend modules: passed
  • speaker_id_scope and speaker_identity_status remain persistence-only backend fields: model_dump includes them, while SkipJsonSchema keeps the app-client OpenAPI and all generated client contracts unchanged
  • final pre-push gate: 24 PR checks passed, runtime-image closure passed for 10 images, eight selected backend files passed 105/105, app-client OpenAPI and generated-client snapshots were current, and Black reported 20 files unchanged
  • broad backend/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.py had already printed 13 passed; test_action_item_vector_best_effort.py had reached 75%. This is not claimed as a completed full-suite pass.
  • combined direct pytest runs exposed known cross-file pollution: the Parakeet builtin-embedding file raised a missing-NeMo collection error only in combination and passed 16/16 alone; four Modulate retired-config failures passed 94/94 alone. Two real parity fixture mismatches were fixed and then passed 2/2 alone.
  • full hermetic e2e suite (bash backend/testing/e2e/run.sh): 116 passed, 3 skipped after the provider-preservation fix; before it, 5 failed
  • eight affected unit files run together in one process (not file-isolated): 105 passed
  • live provider/embedding services were not exercised because this worktree has no hermetic owner-account or provider-credential path; the production assignment and persistence seams were exercised with controllable embeddings and transcript payloads.

Product 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.

@mintlify

mintlify Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Aug 23, 2026, 5:38 PM

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

Git-on-my-level and others added 5 commits August 24, 2026 00:58
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.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

1 active deployment
staging - docs — 0b563029 Deployed Aug 24, 2026 by mintlify[bot]
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.

2 participants