Skip to content

feat(observability): count live unnamed speaker ordinals per session - #23556

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/live-ordinals-metric
Oct 25, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/live-ordinals-metric

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

Why

David saw consecutive live lines labelled Speaker 4, 5, 6, 7, 8. #23533 (85f080f) defers live ordinals for short unnamed voices, but we had no metric showing whether per-session "Speaker N" churn actually fell after the listen roll.

What

  • omi_live_speaker_ordinals_per_session — a label-free histogram observed once per listen session at teardown. The value is the number of distinct visible unnamed speaker ordinals the session minted after fix(speakers): defer short live epoch labels and gate owner evidence #23533's deferral: LiveSpeakerOrdinalTracker observes the same final live segment stream the collapse monitor sees (routers/listen/transcripts.py::_speaker_detection, after scope stamping and speaker-id assignment) and applies the display deferral's own qualification — a voice key (speaker_id_scope, speaker_id) mints one ordinal at MIN_EVIDENCE_SECONDS (5 s) of unioned, non-overlapping placed speech; voices the session named (owner or person — per-segment or through the matcher's final map) mint none.
  • omi_live_speaker_scope_rotations_total — companion counter of scope/epoch rotations (provider transitions, reconnect epochs) over the same sessions, so churn is separable from real multi-speaker conversations.
  • Tracker is bounded (128 voices, 512 merged intervals per voice), event-loop confined like the collapse monitor, display bookkeeping only — it never feeds speaker decisions. Recording never raises into teardown (routers/listen/runtime.py::_teardown_components, after the transcript loop drains and before the matcher's maps clear).
  • Runbook: backend/docs/listen_pusher_pipeline.mdx live-speaker-epochs section names the PromQL to watch after listen rolls.

PromQL

  • Mean ordinals/session: rate(omi_live_speaker_ordinals_per_session_sum[1h]) / rate(omi_live_speaker_ordinals_per_session_count[1h])
  • p95: histogram_quantile(0.95, rate(omi_live_speaker_ordinals_per_session_bucket[1h]))
  • Rotations/session: rate(omi_live_speaker_scope_rotations_total[1h]) / rate(omi_listen_ws_close_total[1h])

Success after the listen roll: ordinals fall while rotations/session holds flat — that is the deferral working, not conversations gaining fewer speakers.

Tests

tests/unit/test_live_speaker_ordinals_metric.py — deferral floor and union semantics (overlap/replay never double-count), named-voice exclusion (segment flags + matcher map at close), scope-rotation counting, unplaced/malformed/id-less segments, bounded inventory, histogram/counter observation, teardown-safe recording, and the _speaker_detection feed through a real TranscriptProcessor.

Run: BACKEND_UNIT_TEST_FILE_LIST=<list file> bash test.sh in backend/ — new file (11 tests) plus the focused neighbors (test_listen_runtime_regressions, test_listen_ws_close_metric, test_live_speaker_epochs, test_live_transcript_merge, test_audio_timeline_round4, test_speaker_display_no_raw_ids, test_episodes_incremental_live, test_live_speaker_collapse, test_live_speaker_carry): all pass. scripts/typecheck.sh clean; scan_async_blockers and check_speaker_label_interpolation.py clean.

Line-Count-Exception: backend/routers/listen/transcripts.py | 1670 -> 1673 | three-line ordinal-tracker feed at the existing final-segment observation loop (same choke point the collapse monitor uses)

🤖 Generated with Claude Code

#23533 (85f080f) defers a live "Speaker N" ordinal until an unnamed voice
holds five seconds of non-overlapping placed speech, but nothing measured
whether per-session ordinal churn actually fell after the listen roll -
David's consecutive Speaker 4-8 lines had no metric.

Add omi_live_speaker_ordinals_per_session, a histogram observed once per
listen session at teardown. LiveSpeakerOrdinalTracker rides the same final
segment stream the collapse monitor sees (routers/listen/transcripts
_speaker_detection, after scope stamping and speaker-id assignment) and
applies the display deferral's own qualification: a voice key
(speaker_id_scope, speaker_id) mints one ordinal at MIN_EVIDENCE_SECONDS of
unioned placed speech, and a voice the session named (owner or person,
per-segment or in the matcher's final map) never mints one. The companion
omi_live_speaker_scope_rotations_total counts scope/epoch rotations over the
same sessions, so ordinal churn is separable from real multi-speaker
conversations. Both metrics are label-free; the tracker is bounded (128
voices, 512 intervals per voice), never feeds speaker decisions, and its
recording never raises into teardown.

The pipeline doc's live-speaker-epochs section names the PromQL to watch
after listen rolls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T02:26:21.373492Z ac6a7ee PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac6a7ee7ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1451 to +1453
# After the transcript loop drained and before the matcher's maps clear:
# the ordinal ledger needs both the final segments and final naming.
record_live_speaker_ordinals(getattr(self, 'speaker_ordinal_tracker', None), self.speakers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Capture named voices before each matcher generation is cleared

When one listen connection spans multiple conversations, names learned in an earlier conversation can be lost from this metric. SpeakerMatcher.initialize_profiles() calls clear() on a conversation change, which empties both speaker_to_person and _voice_scopes. Since the tracker observes incoming segments before asynchronous matching and only folds in the matcher map here at session teardown, an earlier voice that was subsequently named can remain in _qualified without entering _named. The histogram then counts that named voice as an unnamed ordinal. Snapshot naming before each matcher reset, or notify the tracker when an identity is published.

Useful? React with 👍 / 👎.

Comment on lines +117 to +121
intervals = self._intervals.get(key)
if intervals is None:
if len(self._intervals) >= MAX_TRACKED_VOICES:
return
intervals = self._intervals[key] = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply the voice limit to the complete tracked inventory

In long-running sessions with repeated provider epochs or new speaker IDs, this guard does not enforce the advertised 128-voice ceiling: it counts only voices still accumulating evidence, and qualification immediately removes each voice from _intervals while retaining it in _qualified. Feeding 1,000 distinct six-second voices therefore retains and reports all 1,000. _named and _scopes also grow before this guard runs. Bound the complete voice/scope inventory rather than just pending intervals so session telemetry cannot grow indefinitely with churn.

Useful? React with 👍 / 👎.

scope = scope if isinstance(scope, str) else ''
if scope:
self._scopes.add(scope)
key = (scope, speaker_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep display qualification separate across conversations

When a listen connection rolls over to another conversation without changing provider scope, the allocator retains the same speaker ID, but this key combines speech from both conversations using their conversation-relative offsets. For example, three seconds at offsets 10–13 in the first conversation and three seconds at offsets 0–3 in the next qualify as six seconds here, although neither conversation displays an ordinal: Flutter's SpeakerNames.forSegments() applies the five-second floor to the current conversation's segments, and CaptureController replaces that segment list when the conversation changes. Track qualification per conversation/presentation scope before aggregating the session result; otherwise conversation rollovers can increase the reported ordinal count without any visible label being minted.

Useful? React with 👍 / 👎.

Comment on lines +94 to +96
speaker_id = segment.get('speaker_id')
if isinstance(speaker_id, bool) or not isinstance(speaker_id, int):
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exclude Omi's reserved speaker ID from unnamed ordinals

During onboarding, OnboardingHandler.send_current_question() injects synthetic question segments through self.transcripts.enqueue with speaker ID 99, is_user=False, and no person_id. The three current questions together exceed the five-second floor, so this tracker counts Omi itself as an unnamed ordinal even without any qualifying human voice. Both display_participants() and Flutter's SpeakerNames explicitly render this reserved ID as Omi rather than allocating an anonymous label. Exclude OMI_SPEAKER_ID_SENTINEL from qualification so onboarding sessions do not inflate the churn histogram.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 332f52d into main Oct 25, 2026
58 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/live-ordinals-metric branch October 25, 2026 02:34
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