Skip to content

feat(backend): name numbered speakers from transcript evidence - #10954

Open
undivisible wants to merge 26 commits into
BasedHardware:mainfrom
undivisible:feat/speaker-resolution-from-evidence
Open

undivisible wants to merge 26 commits into
BasedHardware:mainfrom
undivisible:feat/speaker-resolution-from-evidence

Conversation

@undivisible

@undivisible undivisible commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator

What

Names the speakers diarization leaves as bare indices, using a single pass over the finalized transcript, and only when a name is actually spoken.

detect_speaker_from_text catches a person only when they announce themselves in one of a fixed set of regex shapes. It misses "thanks, Alex" two turns later, and it cannot prefer a name the user already has a Person record for.

Why the model is not trusted directly

A wrong name shown once is an annoyance. A wrong name that enrols a voiceprint writes the wrong person's voice into that Person's speaker_embedding and mislabels them in every later conversation, silently, with no path back — #10453 shows how hard a merely lost embedding already is to recover.

So no single model output can cause a write. Two independent things have to agree.

1. The gate: grounding only

utils/speaker_resolution.py checks only what a machine can settle without reading the language:

  • the quote appears verbatim inside one transcript segment (a quote stitched across two turns is rejected)
  • that quote contains the claimed name
  • the speaker index exists and is not already resolved by the user or by embedding matching
  • the name is not the account owner's, and is not one of the Auto Create Speakers Toggle Is Off But Feature Is Still Running #5223 stopwords
  • two names on one speaker, or one name on two speakers, drops both
  • confidence clears a floor

That is the whole gate. It deliberately does not judge whether the words mean the speaker is that person — "thanks, Alex" grounds identically whether Alex is the listener, someone being discussed, or a name read off a slide. Passing the gate is therefore not permission to write anything: ResolutionPlan has no assignments field, and everything it emits is a suggestion.

2. The refutation pass: what actually guards enrolment

Each surviving suggestion goes to a separate model call (utils/llm/speaker_verification.py) with the opposite job. It is shown one proposal, the transcript, and that speaker's own lines, and it is asked to break the identification — and to answer "refuted" whenever it is unsure. Only a suggestion the verifier fails to refute assigns segments and enrols a voiceprint.

Every failure mode resolves to refuted: a parse error, a timeout, an unreachable verifier, an unusable answer. A false refusal costs the user a tap on a suggestion; a false acceptance is unrecoverable, so the asymmetry runs that way on purpose.

An earlier revision of this PR did something else, and it was wrong. It asked the proposing model to also label its evidence (self_introduction / direct_address / …), auto-enrolled the top two labels, and used regexes to check the quote's grammar matched the label. That is circular — the label is just another output of the model being checked — and it pits hand-written patterns against a language model on the one question the model is better at. A self-audit found three ways through it. The taxonomy and the form checks are gone.

3. Reversibility, for when both are wrong anyway

An enrolment made from an inference is tagged llm_inferred — on the embedding and on the speech sample. Tagging only the embedding was not enough: SpeakerMatcher._recover_person_embedding rebuilds a missing embedding from samples[0], so clearing an inferred embedding meant the next listen session resurrected it from the same unvetted sample. Recovery now refuses inferred samples, and revoking clears both artifacts.

Reassigning a speaker away from a person whose enrolment came from an inference revokes it. Deliberately narrow: the person must be losing that speaker and hold no other segment in the conversation.

Also fixes speaker matching

The live matcher took the closest enrolled person inside SPEAKER_MATCH_THRESHOLD. As the roster grows the runner-up creeps inside the threshold too, and whichever of two similar voices scores marginally lower wins. select_best_match now requires the winner to beat the runner-up by SPEAKER_MATCH_MARGIN, and holds a lone candidate to a stricter distance, so a near-tie surfaces as an unlabelled speaker rather than a confidently wrong name.

Shape

File Role
utils/speaker_resolution.py the grounding gate — pure, no LLM, no I/O
utils/llm/speaker_resolution.py the proposal route (speaker_resolution, gpt-5-nano)
utils/llm/speaker_verification.py the refutation route (speaker_verification, gpt-5-nano)
utils/conversations/speaker_resolution.py side effects: Person, segments, enrolment
utils/stt/speaker_embedding.py select_best_match

SPEAKER_NAME_STOPWORDS lives in utils/speaker_names.py so the gate can reuse the #5223 stopword list without importing av, numpy and Firestore. SPEAKER_IDENTIFICATION_PATTERNS, patterns_to_check and detect_speaker_from_text stay where they were, in utils/speaker_identification.py; nothing in the gate needs them.

Every Firestore call and every LLM call — including one refutation call per suggestion — goes through run_blocking(db_executor / llm_executor, …), so none of it runs on the event loop.

Acting on a suggestion

  • POST /v1/conversations/{id}/speaker-suggestions/{speaker_id}/accept — resolves the Person, assigns every segment of that speaker, drops the suggestion, enrols.
  • DELETE /v1/conversations/{id}/speaker-suggestions/{speaker_id} — dismisses it.

Accept enrols as user_tagged, not llm_inferred. That is the point of the endpoint: an inferred sample is barred from rebuilding an embedding later, and a name the user tapped is a confirmation rather than a guess.

Resolve-or-create by name goes through get_or_create_person_by_name, which derives the document id from the normalized name so two conversations finishing at once contend for one record instead of coining two people for one human.

Rollout

Off by default behind SPEAKER_RESOLUTION_ENABLED. Runs once per conversation in post-processing, never in the live per-segment loop — #6901 was closed for adding weight to that path, and naming needs the whole conversation anyway. Enrolment is capped at 4 per conversation and refutation calls at 6, spent on the most confident suggestions first.

The pass runs as an async coordinator on its own loop rather than occupying a postprocess_executor thread across its awaits, is handed a deep copy so memory extraction is not reading segments it is mutating, and is scheduled after audio_files are durable because enrolment reads them back.

Tests

85 in test_speaker_resolution.py (grounding gate, refutation pass, write safety, usage attribution), 13 in test_speaker_label_suggestions.py (accept/dismiss/revoke), 10 in test_speaker_sample_attribution.py, 8 in test_person_identity.py (the create race), 8 in test_speaker_resolution_scheduling.py, 10 for the matching margin.

Notable ones: a refuted verdict assigns and enrols nothing; a verifier that raises degrades to suggestion-only; a failed segment write enrols nothing and leaves no orphan Person; a quote matching only inside a longer word ("I'm Annette" vs name "Ann") is rejected; an undiarized transcript resolves nothing; two concurrent resolvers of one unseen name yield one Person.

Review findings from Bugbot and Codex are actioned; see the comment thread. docs/doc/developer/backend/listen_pusher_pipeline.mdx is updated for the new pass and the real match-admission rule.

Refs #5565 items 6, 7 and 9.

Product invariants affected

None. Changes are confined to backend speaker identification and its post-processing entry point.

Failure-Class: none

No existing class covers "a ranked match accepted on an absolute threshold without requiring separation from the runner-up". Happy to add one if you think it is worth a definition.


Note

High Risk
Touches Firestore transaction boundaries for transcript segments, person records, and voiceprint enrolment/revocation—errors or races could mislabel speakers or corrupt embeddings across conversations.

Overview
Adds speaker label suggestions end-to-end: conversations can carry proposed names for diarized speakers (segment id references only, no quoted transcript on the wire), and the Flutter client now deserializes and round-trips speaker_label_suggestions.

Post-finalization naming (wired in process_conversation via background scheduling) persists unverified proposals; accept and dismiss HTTP routes settle them with single Firestore transactions so concurrent accepts/dismisses cannot resurrect suggestions or overwrite segment assignments from stale snapshots. Manual and bulk speaker assignment clears matching suggestions and can revoke llm_inferred enrolments when a person no longer speaks in that conversation.

Person identity moves to get_or_create_person_by_name (deterministic id + transactional create) for idempotent people creation and accept flows. Speech samples and embeddings gain llm_inferred attribution: inferred samples are excluded from embedding recovery, and revocation clears both marked samples and inferred embeddings without touching user-confirmed voiceprints.

Live speaker matching switches to select_best_match (threshold plus margin / stricter lone-candidate rule) to avoid near-tie mislabels. Supporting changes include executor loop registration for cross-thread background tasks, redaction tests for suggestion fields, QoS entries for speaker_resolution / speaker_verification, and ratchet baseline updates.

Reviewed by Cursor Bugbot for commit a322930. Bugbot is set up for automated code reviews on this repo. Configure here.

Line-Count-Exception: backend/database/conversations.py | 1728 -> 2121 | speaker-label suggestion persistence, dismissed-speaker fence, and transactional segment assignment
Line-Count-Exception: backend/database/users.py | 2131 -> 2502 | speaker name identity keys, probes, and person-identity helpers
Line-Count-Exception: backend/routers/conversations.py | 1508 -> 1750 | speaker suggestion accept/dismiss routes and evidence surface
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 1781 -> 1889 | finalization-time speaker resolution pass and suggestion persistence

Comment thread backend/utils/speaker_resolution.py Resolved

@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: 3bcac74ca0

ℹ️ 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 +357 to +358
views = _view_segments(segments)
known_speakers = {view.speaker_id for view in views if view.speaker_id is not None}

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Exclude undiarized speaker zero from resolution

When diarization is unavailable, TranscriptSegment.__init__ defaults every segment to speaker ID 0, and the existing assignment path deliberately refuses to map speaker 0 globally because it may contain multiple voices. Including 0 in known_speakers lets one introduction assign every unresolved segment in such a conversation to the same Person and then enroll a mixed or incorrect voiceprint. Restrict automatic resolution to actual diarized speaker IDs.

Useful? React with 👍 / 👎.

Comment thread backend/utils/speaker_resolution.py Outdated
Comment on lines +257 to +259
if claim.evidence_type == EvidenceType.SELF_INTRODUCTION:
if any(view.speaker_id == claim.speaker_id for view in candidates):
return None

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate self-introduction semantics before enrollment

When the model misclassifies a same-speaker third-party reference as self_introduction, this branch accepts it solely because the quote came from that speaker. For example, Speaker 1 saying “Alex will join tomorrow” with person_name="Alex" passes and auto-enrolls Speaker 1 as Alex. Because evidence_type is supplied by the same untrusted model, the gate must independently establish an introduction shape or downgrade the claim to a suggestion.

Useful? React with 👍 / 👎.

Comment thread backend/utils/speaker_resolution.py Outdated
Comment on lines +266 to +267
if any(_is_adjacent(view.index, speaker_indices, ADDRESS_ADJACENCY_SEGMENTS) for view in others):
return None

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require an unambiguous target for direct addresses

When multiple unresolved speakers occur within the two-segment window, proximity does not identify which one was addressed. For example, after the user says “Thanks Alex,” both of the next two numbered speakers independently satisfy this check, so whichever one the model guesses can be assigned and enrolled as Alex. Auto-assignment must require structural evidence that uniquely selects the addressee rather than accepting any nearby speaker.

Useful? React with 👍 / 👎.

Comment on lines +176 to +179
conversations_db.update_conversation_segments,
uid,
conversation_id,
[segment.dict() for segment in segments],

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve speaker edits made while the model is running

When a user manually assigns a speaker after this background pass takes its initial snapshot but before the LLM returns, this full-array write replaces the current Firestore segments with the stale in-memory copy and the inferred assignment. The subsequent enrollment can then train against the inference even though the user already supplied an authoritative identity. Re-read and conditionally update only segments that remain unresolved in durable state.

Useful? React with 👍 / 👎.

Comment on lines +88 to +92
person_id = str(uuid.uuid4())
try:
await run_blocking(
db_executor,
users_db.create_person,

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Create inferred people atomically by normalized name

When two conversations for the same user finish concurrently and both infer the same previously unknown name, each pass loads an independent known map, generates a different UUID, and unconditionally creates its document. This produces duplicate Person records for one human and may enroll separate voiceprints against both. Resolve-or-create needs a transactional or deterministic name identity boundary shared across concurrent passes.

Useful? React with 👍 / 👎.

Comment thread backend/utils/speaker_identification.py Outdated
Comment on lines +455 to +459
users_db.set_person_speaker_embedding,
uid,
person_id,
embedding_list,
attribution,

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Tag inferred speech samples as well as embeddings

When an inferred identity is later contradicted, clearing the llm_inferred embedding is insufficient because the preceding stored speech sample has no attribution. Since it is saved at speech_samples_version=3, SpeakerMatcher._recover_person_embedding will rebuild the supposedly cleared embedding from that same poisoned sample on the next session. Record attribution on the sample and remove both artifacts together so inferred enrollment is actually reversible.

Useful? React with 👍 / 👎.

Comment thread backend/utils/speaker_resolution.py Outdated
Comment on lines +220 to +224
def _quote_segments(views: Sequence[_SegmentView], quote: str) -> List[_SegmentView]:
normalized_quote = normalize_text(quote)
if not normalized_quote:
return []
return [view for view in views if normalized_quote and normalized_quote in view.normalized_text]

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Match grounded quotes on token boundaries

When the model returns a truncated name or quote, substring matching treats it as verbatim evidence even when those words never appeared independently. For example, a transcript containing “I'm Annette” accepts person_name="Ann" and evidence_quote="I'm Ann", after which the claim can auto-enroll the speaker as the wrong person. Match normalized token sequences with boundaries rather than arbitrary substrings.

Useful? React with 👍 / 👎.

Comment on lines +75 to +76
if isinstance(name, str) and name.strip() and isinstance(person_id, str):
known[name.strip().casefold()] = person_id

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject ambiguous existing-person name collisions

When a user has two Person records with the same case-folded name, this assignment silently overwrites one ID with the other; Firestore stream order is not an identity rule. Any later claim for that name is therefore bound to an arbitrary Person and may enroll the speaker's voiceprint against the wrong record. Detect duplicate normalized names and keep those claims as suggestions until the user selects the intended Person.

Useful? React with 👍 / 👎.

Comment on lines +101 to +102
except Exception as e:
logger.error('Speaker resolution could not create person %r: %s', name, e)

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize inferred names before logging failures

When Person creation fails, this error path writes the inferred person's raw name into backend logs. Names are PII, so provider or Firestore failures can leak conversation-derived identities into operational logging; pass the value through sanitize_pii() or omit it.

AGENTS.md reference: backend/AGENTS.md:L205-L211

Useful? React with 👍 / 👎.

Comment on lines +1725 to +1728
if not is_reprocess:
from utils.conversations.speaker_resolution import resolve_conversation_speakers_sync

submit_with_context(postprocess_executor, resolve_conversation_speakers_sync, uid, conversation)

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the documented listen and pusher pipeline

This change adds a new conversation-finalization speaker-identification pass and alters live embedding matching, but the commit does not update docs/doc/developer/backend/listen_pusher_pipeline.mdx. That leaves the documented ownership and ordering of speaker identification stale for future backend changes; update the pipeline document in the same change.

AGENTS.md reference: backend/AGENTS.md:L173-L177

Useful? React with 👍 / 👎.

ghost 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: 03470e8f1c

ℹ️ 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 +67 to +69
except Exception as e:
logger.error('Speaker resolution could not load people: %s', e)
return {}, []

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Abort resolution when the people roster cannot be loaded

When get_people transiently fails, returning an empty roster is indistinguishable from the user genuinely having no people. Any subsequently accepted claim therefore reaches _resolve_person_id as a new name, creating a duplicate Person and potentially enrolling a second voiceprint for someone who already exists. Fail this resolution pass instead of continuing without the authoritative identity roster.

Useful? React with 👍 / 👎.

Comment thread backend/utils/llm/speaker_resolution.py Outdated
Comment on lines +202 to +203
except Exception as e:
logger.error('Speaker resolution LLM call failed: %s', e)

ghost Jul 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize LLM failures before logging them

When output parsing or the provider fails with an exception containing the completion or response body, logging e verbatim can write transcript-derived names, quotes, or other user text into operational logs. Log only structural error details or pass the value through the appropriate sanitizer.

AGENTS.md reference: backend/AGENTS.md:L205-L210

Useful? React with 👍 / 👎.

Comment on lines +216 to +217
except Exception:
user_name = None

ghost Jul 31, 2026

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 Stop when the account-owner name lookup fails

When get_user_name raises, converting the failure to None disables the explicit NAME_IS_USER safeguard. If the owner's speech was left as an unresolved numbered speaker, a self-introduction can then create a separate Person for the owner and enroll that voiceprint. Distinguish a legitimate missing display name from a failed authoritative lookup and abort the pass on the latter.

Useful? React with 👍 / 👎.

Comment on lines +75 to +76
if isinstance(name, str) and name.strip() and isinstance(person_id, str):
known[name.strip().casefold()] = person_id

ghost Jul 31, 2026

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 Normalize roster names consistently before resolving identities

The roster is keyed with plain casefold(), while claim ambiguity, quote grounding, and owner-name checks use normalize_text. Consequently an existing José Person and an accepted Jose claim, or equivalent apostrophe/punctuation variants, miss this lookup and create a duplicate Person with a separate enrollment. Use the same canonical name normalization for both roster insertion and lookup.

Useful? React with 👍 / 👎.

Comment on lines +202 to +204
except Exception as e:
logger.error('Speaker resolution LLM call failed: %s', e)
return []

ghost Jul 31, 2026

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 Record the exhausted LLM fallback

When the speaker-resolution LLM or parser fails, returning [] makes the caller treat the pass as an ordinary empty result and continue without names, with no retry-visible or fallback metric. This is a correctness-degrading fail-open branch, so record it through the shared record_fallback helper with an exhausted outcome rather than relying only on an error log.

AGENTS.md reference: AGENTS.md:L91-L91

Useful? React with 👍 / 👎.

ghost 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: 279c1d216b

ℹ️ 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 thread backend/utils/speaker_resolution.py Outdated
normalized_detected = normalize_text(detected)
if not normalized_detected:
return False
return normalized_detected in set(normalize_text(name).split())

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind the full claimed name to the introduction

The newly added form check still accepts a multi-token claimed name when only one token was introduced: _name_in_quote merely requires every token to occur somewhere, while this line only requires the detected name to be one token in the claim. For example, I'm Alex, and Chen will join later with person_name="Alex Chen" passes as a self-introduction, auto-assigning and enrolling the speaker as Alex Chen. Require the complete normalized claimed name to be the contiguous name phrase introduced by the speaker.

Useful? React with 👍 / 👎.

Comment thread backend/utils/llm/speaker_resolution.py Outdated
for raw in response.claims:
evidence_type = _parse_evidence_type(raw.evidence_type)
if evidence_type is None:
logger.info('Speaker resolution dropped claim with unknown evidence_type=%r', raw.evidence_type)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize rejected evidence types before logging

When malformed model output places a transcript-derived name, quote, or other user text in evidence_type, it remains a valid string but misses the enum and is logged here verbatim. Because this value is generated from a sensitive transcript, omit it or pass it through sanitize_pii() before writing it to operational logs.

AGENTS.md reference: backend/AGENTS.md:L205-L210

Useful? React with 👍 / 👎.

@undivisible
undivisible force-pushed the feat/speaker-resolution-from-evidence branch from 279c1d2 to 8f858f6 Compare August 1, 2026 00:41

ghost 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: 8f858f6f6f

ℹ️ 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 thread backend/utils/llm/speaker_resolution.py Outdated
if getattr(segment, 'is_user', False):
label = 'The user'
else:
person_name = getattr(segment, 'person_name', None)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve bound person names before model verification

When a segment is already bound through person_id, TranscriptSegment has no person_name attribute, so this lookup falls through and renders it as Speaker N to both the proposer and verifier. If another unresolved speaker is proposed as that existing person's name, the verifier cannot apply its “another speaker fits the name” check, _resolve_person_id reuses the existing Person, and the second voice can be enrolled into that Person. Resolve person_id through the loaded roster when building the model transcript.

Useful? React with 👍 / 👎.

Comment on lines +153 to +156
'Speaker verification refuted speaker=%s name=%s reason=%s',
suggestion.speaker_id,
suggestion.person_name,
verdict.reason,

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Sanitize refutation details before logging

When a verifier refutes a claim, both suggestion.person_name and the model-generated verdict.reason can contain names or transcript excerpts, so this normal INFO path writes raw PII and user text to operational logs. Omit these values or pass them through sanitize_pii() before logging.

AGENTS.md reference: backend/AGENTS.md:L205-L210

Useful? React with 👍 / 👎.

return SpeakerResolutionOutcome()

try:
verified = await run_blocking(llm_executor, verify_suggestions, segments, plan.suggestions, user_name)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Offload each verification request separately

Fresh evidence in the final revision is that verify_suggestions now performs one synchronous LLM request per suggestion inside this single offload. With several claims per conversation, each pass monopolizes one of the six llm_executor workers across the whole serial loop, so six enabled conversations can prevent unrelated LLM work from running between requests; keep orchestration async and borrow the pool once per verification call.

AGENTS.md reference: backend/AGENTS.md:L283-L288

Useful? React with 👍 / 👎.

Comment on lines +156 to +158
except Exception as e:
logger.error('Speaker verification LLM call failed speaker=%s: %s', speaker_id, e)
return REFUTED_ON_ERROR

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Record exhausted verifier fallbacks

The newly added verifier introduces a second exhausted path: on a provider or parser failure this return changes the feature from automatic assignment to suggestion-only, but only emits a log, leaving the degradation invisible to fallback metrics and alerts. Record this correctness-changing branch with the shared record_fallback helper and an exhausted outcome.

AGENTS.md reference: AGENTS.md:L91-L91

Useful? React with 👍 / 👎.

@undivisible

ghost commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Actioned the Bugbot and Codex findings. Pushed as five commits on top of the redesign.

Fixed

  • Quote grounding matched inside words ("I'm Annette" accepted name "Ann"). Now compares contiguous whole-token slices.
  • An undiarized transcript is every segment at speaker_id 0, so one quote could bind the whole conversation to one Person. Resolution now requires more than one distinct speaker — not an exclusion of id 0, since SPEAKER_00 is real.
  • llm_inferred was only on the embedding, but _recover_person_embedding rebuilds from samples[0], so clearing it resurrected the enrolment next session. Attribution now travels with the sample, recovery refuses inferred samples, and revoking clears both.
  • The full-array write clobbered speaker assignments the user made while the pass was running. It now re-reads durable state and only touches segments still unresolved there.
  • update_conversation_segments' result was ignored, in-memory segments were mutated before the write, and Person records outlived a failed write. Assignment, mutation and enrolment now sit behind a confirmed write; people coined for a failed write are removed.
  • Colliding case-folded person names silently bound to whichever Firestore streamed last; they now stay suggestions.
  • Person name sanitised in the creation-failure log; both LLM calls wrapped in track_usage.
  • The pass no longer holds a postprocess_executor thread across awaits, is handed a deep copy so memory extraction isn't racing its mutations, and is scheduled after audio_files are durable.
  • Suggestions are persisted as speaker_label_suggestions on the conversation, with the model field and generated clients, so they can actually reach a client.
  • listen_pusher_pipeline.mdx updated for the finalization pass and the real match-admission rule.

Not fixed, deliberately

  • Concurrent duplicate Person creation across two conversations finishing at once is real but pre-existing to this pass; a deterministic or transactional name identity belongs with create_person, not here.
  • Revocation is wired to the enrolment-failure rollback. A user contradicting an already-enrolled inference happens outside this module and has no trigger here yet.
  • The tap-to-accept UI is not in this PR. The suggestions are persisted and typed; the client flow is follow-up work.

Two findings about self_introduction / direct_address semantics are moot — that taxonomy is gone. It was circular (the label came from the model being checked), and a self-audit found three ways through it, so naming is now grounding plus an independent refutation pass.

Comment thread backend/routers/listen/speakers.py Resolved

ghost 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: 895aadff5a

ℹ️ 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 +1427 to +1429
loop = asyncio.new_event_loop()
threading.Thread(target=loop.run_forever, name='speaker-resolution-loop', daemon=True).start()
_speaker_resolution_loop = loop

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route resolution through tracked background tasks

Fresh evidence in this revision is that the former long-lived executor job has been replaced with an ad-hoc daemon thread and event loop. Because this loop is not registered with backend startup/shutdown, an instance shutdown can abandon an in-flight resolution after creating a Person or updating segments, without draining the task or running its cleanup; exceptions outside _run_speaker_resolution are also held only by the discarded Future. Use the repository's tracked background-task lifecycle rather than creating a private thread.

AGENTS.md reference: backend/AGENTS.md:L283-L288

Useful? React with 👍 / 👎.

Comment on lines +335 to +342
try:
persisted = await run_blocking(
db_executor,
conversations_db.update_conversation_segments,
uid,
conversation_id,
stored_segments,
)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Make segment assignment conditional in the transaction

Fresh evidence in this revision is that apply_plan now rereads the conversation, but the protection still ends before this write: if the user assigns a speaker after the read at line 272 and before this call, update_conversation_segments transactionally replaces the current array with the already-stale stored_segments argument. That still erases the authoritative manual edit and can enroll the inferred identity; the transaction must verify that each target remains unresolved while applying the edits.

Useful? React with 👍 / 👎.

processingConversationId: _readFieldValue<String>(_readField(json, const ["processing_conversation_id"]), "processing_conversation_id", _readString, requiredField: false, nullable: true),
processingMemoryId: _readFieldValue<String>(_readField(json, const ["processing_memory_id"]), "processing_memory_id", _readString, requiredField: false, nullable: true),
source: _readFieldValue<String>(_readField(json, const ["source"]), "source", _readString, requiredField: false, nullable: true, defaultValue: "omi"),
speakerLabelSuggestions: _required(_readFieldValue<List<GeneratedSpeakerLabelSuggestion>>(_readField(json, const ["speaker_label_suggestions"]), "speaker_label_suggestions", (value) => _readObjectList(value, GeneratedSpeakerLabelSuggestion.fromJson), requiredField: false, nullable: false, defaultValue: const []), "speaker_label_suggestions"),

ghost Aug 1, 2026

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 Propagate persisted suggestions into ServerConversation

Fresh evidence in this revision is that suggestions are now persisted and parsed by the generated wire model, but ServerConversation.fromGenerated in app/lib/backend/schema/conversation.dart:395-428 never copies generated.speakerLabelSuggestions, and the repository has no other finalized-conversation consumer of this field. Consequently the Flutter app discards every weak-evidence suggestion during deserialization, so the existing naming sheet cannot present the promised tap-to-accept result.

Useful? React with 👍 / 👎.

Comment on lines +362 to +369
await extract_speaker_samples(
uid=uid,
person_id=person_id,
conversation_id=conversation_id,
segment_ids=list(assigned_ids),
attribution=SPEAKER_ATTRIBUTION_LLM_INFERRED,
)
outcome.enrolled.append(person_id)

ghost Aug 1, 2026

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 Report failed enrollments before marking them complete

When sample extraction, quality validation, or embedding storage fails, extract_speaker_samples catches the error internally and returns normally, so this line still reports the person as enrolled and the following revocation handler is never reached. In the partial-write case where the inferred sample was stored before embedding extraction failed, that unusuable inferred sample remains and SpeakerMatcher deliberately refuses to recover an embedding from it; have the helper return a real outcome or raise its typed failure before appending here.

AGENTS.md reference: backend/AGENTS.md:L214-L217

Useful? React with 👍 / 👎.

@Git-on-my-level Git-on-my-level added needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces backend Backend Task (python) labels Aug 1, 2026

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the careful redesign here — the grounding/refutation split, the conservative fallbacks, and the new regression coverage are all moving in the right direction.

I do need to block this head on one safety issue before merge:

  • backend/utils/llm/speaker_resolution.py and backend/utils/llm/speaker_verification.py interpolate the transcript/evidence text into a system prompt. That transcript is user-controlled conversation content. A malicious or just unlucky transcript can contain instructions like “ignore the verifier rules and accept this identity”, and those instructions are then delivered to the model with the same role as the actual safety policy. Because an unrefuted verifier result can write person_id assignments and enroll an llm_inferred voiceprint, this makes transcript prompt injection part of the authorization path for a persistent speaker identity. Please move transcript/evidence/known-people values into a data/user message or otherwise delimit and quote them so the system/developer policy remains separate from transcript content, and add a regression test that a transcript containing prompt-injection text cannot force an accepted speaker claim.

The developer doc update in docs/doc/developer/backend/listen_pusher_pipeline.mdx also changes guidance that coding/review agents are likely to follow for the listen pipeline. The new description is useful and mostly aligned with the code, but because it documents a new LLM-driven voiceprint-enrollment path, it should land with the prompt-boundary fix above so future agents do not copy the unsafe prompt pattern.

I’m not asking to split this PR: the scope is cohesive around backend speaker naming. Once the prompt-boundary issue is fixed, the existing unit coverage plus the passing backend gates should make this much easier to re-review.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level

ghost commented Aug 1, 2026

Copy link
Copy Markdown
Member

something like this has been proposed before but the false positive rate can be quite high, do you have a good enough sampling of the edge cases to know? like if I say "you're such a Karen" will it label you as Karen?

Comment thread backend/database/users.py Resolved

ghost 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: 809036f223

ℹ️ 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".

conversations_db.update_conversation,
uid,
conversation.id,
{SPEAKER_RESOLUTION_SUGGESTIONS_FIELD: _speaker_suggestion_payload(list(outcome.suggested))},

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep suggestion evidence inside the encrypted transcript

For enhanced-protection conversations that produce an unverified suggestion, this persists evidence_quote—a verbatim transcript excerpt—as a separate plaintext Firestore field. database/conversations.py::_prepare_conversation_for_write encrypts only transcript_segments, so direct Firestore reads now reveal transcript content that the protection level is meant to keep opaque; persist only segment IDs or encrypt the suggestion payload under the same boundary.

AGENTS.md reference: backend/AGENTS.md:L191-L193

Useful? React with 👍 / 👎.

Comment on lines +292 to +296
assigned_ids = tuple(
segment_id
for segment_id in resolved.segment_ids
if segment_id in segment_map and _durable_segment_is_unresolved(stored_map.get(segment_id))
)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Abort inference when any segment of the speaker was assigned

When a user labels only one segment of this diarized speaker while the LLM calls are running, this filter excludes that segment but still assigns every other segment for the same speaker to the inferred Person and enrolls their audio. The durable conversation can then bind one speaker ID to both the user's authoritative Person and the model's Person; if any target segment is already resolved, skip the entire resolved.speaker_id instead of filtering targets independently.

Useful? React with 👍 / 👎.

Comment thread backend/utils/llm/speaker_resolution.py Resolved
Comment thread backend/routers/conversations.py Resolved
Comment thread backend/utils/speaker_identification.py Resolved

ghost 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: b66745a84f

ℹ️ 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 thread backend/routers/conversations.py Outdated
Comment on lines +1193 to +1196
conversations_db.update_conversation_segments(
uid, conversation_id, [segment.model_dump() for segment in conversation.transcript_segments]
)
_drop_speaker_label_suggestion(uid, conversation, speaker_id)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply suggestion acceptance atomically

When two suggestions are accepted concurrently, both requests load the same conversation snapshot and each replaces the entire segment array here before separately replacing the suggestions array. The later segment write can erase the earlier speaker assignment, while the later suggestion write can resurrect the already accepted suggestion; both requests still schedule voice enrollment, so a Person may receive a voiceprint even though the durable transcript no longer references it. Update only the targeted speaker and remove its suggestion against the current document in one transaction.

Useful? React with 👍 / 👎.

Comment on lines +303 to +309
was_known = resolved.person_name.casefold() in known
person_id = await _resolve_person_id(uid, resolved.person_name, known)
if not person_id:
outcome.suggested.append(resolved)
continue
if not was_known:
created_person_ids.append(person_id)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not delete a person reused by another resolution

When two conversations concurrently resolve the same previously unknown name, one pass can create the deterministic Person and the other can receive that existing record from get_or_create_person_by_name; because _resolve_person_id discards the helper's created result, this stale was_known check marks the shared Person as created by both passes. If the second pass's segment write then fails, _discard_created_people deletes the Person already assigned or enrolled by the successful pass. Preserve creation ownership and make cleanup conditional so a concurrently reused Person cannot be removed.

Useful? React with 👍 / 👎.

Comment thread backend/database/users.py Outdated
Comment on lines +1352 to +1353
removed = [path for path in inferred if remove_person_speech_sample(uid, person_id, path)]
clear_person_speaker_embedding(uid, person_id)

ghost Aug 1, 2026

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 Preserve a later user-tagged embedding during revocation

When a Person still has an old inferred sample but has subsequently received a user-confirmed sample, the later enrollment overwrites speaker_embedding_attribution with user_tagged. Reassigning the earlier inferred conversation nevertheless reaches this unconditional clear and deletes the current trusted embedding merely because an inferred sample existed; matching then depends on a later recovery download and can leave the manually taught Person unavailable if recovery fails. Clear the embedding only when its current attribution is llm_inferred, while still removing the inferred samples.

Useful? React with 👍 / 👎.

Comment thread backend/database/users.py Outdated
Comment on lines +935 to +938
people_ref = db.collection('users').document(uid).collection('people')
for probe in range(PERSON_NAME_ID_PROBES):
person_ref = people_ref.document(person_name_document_id(uid, name_key, probe))
person, created = _resolve_person_by_name_transaction(db.transaction(), person_ref, normalized, name_key)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Inject the Firestore client into the identity helper

This new concurrency-sensitive identity primitive directly uses the legacy global db for both its collection and transaction, and exposes no keyword-only firestore_client seam. That prevents the strict Firestore transaction fake or an alternate runtime client from exercising the actual resolve-or-create boundary, even though the backend database contract requires clients to be obtained at call time and injectable in converted helpers; obtain one client via get_firestore_client() and use it consistently through the scan, transaction, and fallback creation.

AGENTS.md reference: backend/AGENTS.md:L193-L193

Useful? React with 👍 / 👎.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up work here — the redesign still looks cohesive, and the added guardrails/tests around grounding, verifier failure, inferred-sample revocation, and durable-segment re-read address a lot of the earlier safety surface.

I still need to keep this blocked on the prompt-boundary issue from the last automation review. On the current head, both LLM routes still build a single system message that contains user-controlled transcript/evidence data:

  • backend/utils/llm/speaker_resolution.py: ChatPromptTemplate.from_messages([('system', prompt_text)]), where prompt_text includes {transcript}, {known_people}, and {user_name}.
  • backend/utils/llm/speaker_verification.py: same pattern, with {transcript}, {evidence_quote}, {speaker_lines}, and {user_name}.

Those values come from conversation content / user data, and an unrefuted verifier result can persist person_id assignments plus an llm_inferred voiceprint enrollment. Please keep the actual policy/instructions in the system message and pass transcript/evidence/known-people as clearly delimited data in a lower-trust message (or an equivalent structured/data boundary), then add a regression test for prompt-injection text in the transcript/evidence not being able to force an accepted speaker claim.

The developer doc update in docs/doc/developer/backend/listen_pusher_pipeline.mdx is useful and agent-relevant: it documents the new LLM-driven speaker naming/enrollment flow and match-admission rules that future coding/review agents are likely to follow. Because of that maintainer consequence, it should land only after the prompt-boundary fix is reflected in both code and tests, so agents do not copy the unsafe prompt-shape into future listen-pipeline work.

I’m not asking to split this PR; the scope is cohesive around backend speaker naming. The existing labels (backend, security-review, needs-maintainer-review) still look appropriate, and the passing CI is a good sign once this blocker is closed.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

Comment thread backend/routers/conversations.py Resolved
Comment thread backend/routers/conversations.py Resolved
Comment thread backend/routers/conversations.py Resolved

ghost 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: b179f79ecc

ℹ️ 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 +1121 to +1123
still_speaking = {segment.person_id for segment in conversation.transcript_segments if segment.person_id}
for person_id in sorted(displaced_person_ids - still_speaking):
background_tasks.add_task(revoke_inferred_speaker_enrolment, uid=uid, person_id=person_id)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Revoke inferred enrolments from the bulk assignment route

When a user corrects an inferred identity through the active client flow, this revocation helper is never reached: Flutter (app/lib/backend/http/api/conversations.dart:357), macOS (Desktop/Sources/Services/APIClient/APIClient+People.swift:171), and web (web/app/src/lib/api.ts:1586) all call /segments/assign-bulk, while only the whole-speaker route and suggestion acceptance invoke _revoke_contradicted_inferences. The transcript is corrected, but the displaced Person retains the wrong llm_inferred sample and embedding, so later listen sessions can continue matching that voice to the rejected identity; collect displaced IDs and invoke this helper from the bulk route as well.

Useful? React with 👍 / 👎.

Comment thread backend/database/users.py
Comment on lines +943 to +946
people_ref = client.collection('users').document(uid).collection('people')
for probe in range(PERSON_NAME_ID_PROBES):
person_ref = people_ref.document(person_name_document_id(uid, name_key, probe))
person, created = _resolve_person_by_name_transaction(client.transaction(), person_ref, normalized, name_key)

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Route manual Person creation through this identity primitive

When /v1/users/people and speaker finalization concurrently create the same previously unseen name, both initial roster reads can miss, after which this helper claims a deterministic document while routers/users.py:618-630 still creates a random UUID document. That leaves duplicate People and separate voiceprint targets despite the new uniqueness boundary; migrate the in-tree creation route to get_or_create_person_by_name so every creator contends on the same identity.

AGENTS.md reference: AGENTS.md:L88-L88

Useful? React with 👍 / 👎.

Comment on lines +1134 to +1135
person, _ = users_db.get_or_create_person_by_name(uid, person_name)
return person['id']

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require a Person choice when accepting a colliding name

Fresh evidence in this revision is that the accept endpoint takes only speaker_id and resolves the suggestion through this name-only helper. If two existing Person records share the suggested case-folded name, get_or_create_person_by_name returns whichever matching document Firestore streams first; accepting the suggestion therefore assigns and user-tags the voiceprint to an arbitrary contact. Include the intended person_id in acceptance, or reject ambiguous names until the user selects one.

Useful? React with 👍 / 👎.

Comment on lines +1198 to +1205
if assigned_segment_ids:
background_tasks.add_task(
extract_speaker_samples,
uid=uid,
person_id=person_id,
conversation_id=conversation_id,
segment_ids=assigned_segment_ids,
attribution=SPEAKER_ATTRIBUTION_USER_TAGGED,

ghost Aug 1, 2026

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 Replace an inferred sample when the user accepts a suggestion

When the resolved Person already has the one llm_inferred sample allowed by this feature, scheduling extract_speaker_samples as user_tagged does not upgrade the enrolment: that helper returns SKIPPED at utils/speaker_identification.py:338-341 whenever any sample already exists. The accepted conversation is assigned, but the old inferred sample and attribution remain, so the user's confirmed audio is never stored and embedding recovery still refuses the only sample; remove or replace the inferred enrolment before scheduling the confirmed one.

Useful? React with 👍 / 👎.

Comment on lines +106 to +110
speaker_id: int
person_name: str
evidence_quote: str = ''
confidence: float = 0.0
segment_ids: List[str] = []

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Strip suggestion quotes from locked responses

When a locked conversation produces an unverified suggestion, this new response field carries a verbatim transcript excerpt, but utils/conversations/render.py:123-137 and :140-156 clear only transcript_segments and the pre-existing derived fields. Consequently /v1/conversations and the integration projections can return speaker_label_suggestions[].evidence_quote even though the same locked-content boundary removed the transcript; add this field to both redactors or omit its evidence payload from those projections.

Useful? React with 👍 / 👎.

Comment thread backend/utils/llm/speaker_resolution.py Outdated
Comment on lines +99 to +102
def build_known_people_context(known_names: Sequence[str]) -> str:
if not known_names:
return "None on record yet."
return "\n".join(f"- {name}" for name in known_names)

ghost Aug 1, 2026

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 Bound the known-people prompt context

When an account has a large People roster, this function inserts every display name into every speaker-resolution request without any count or character budget. The transcript is capped at 24,000 characters, but the roster can independently make the prompt exceed the model context limit or make finalization token cost grow without bound, causing resolution to fail consistently for the users with the largest rosters; truncate the roster to a documented prompt budget before building the chain input.

Useful? React with 👍 / 👎.

@undivisible

ghost commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Second review round actioned. Four commits.

Concurrency / data loss

  • Accepting a suggestion now assigns the speaker and removes that suggestion in one transaction, and enrols only the segments the transaction actually wrote. Dismiss had the same defect from the other side and got the same treatment. A suggestion a concurrent request already settled is a 404 that enrols nothing.
  • The pass's segment write is transactional and speaker-scoped: it refuses any speaker the user has touched, rather than filtering targets per segment. A partly-named speaker is left alone entirely instead of having its remaining segments bound to the inference.
  • Rollback no longer deletes a Person it did not create — the creation flag now comes from get_or_create_person_by_name instead of being inferred from the roster, which was false for the pass that reused a concurrently created record.
  • Bulk segment assignment revokes contradicted inferences too.

Enrolment truthfulness

  • extract_speaker_samples returns SpeakerEnrolmentOutcome and raises SpeakerEnrolmentError when a sample was written but enrolment failed, so outcome.enrolled stops reporting success it did not achieve and the rollback path actually runs.
  • Revocation clears the embedding only when its own attribution says it came from an inference, so a later user-confirmed voiceprint survives.
  • Recovery rebuilds from the first non-inferred sample instead of giving up when samples[0] is inferred.
  • Revoked sample blobs are deleted rather than orphaned.

Privacy

  • evidence_quote is no longer persisted. _prepare_conversation_for_write encrypts only transcript_segments, so storing it put a verbatim excerpt in a plaintext field. segment_ids already address the same words inside the encrypted transcript, so the client renders the evidence from what it holds.
  • The verifier's refutation prose is no longer logged — it is model free text that can quote the transcript, and sanitize_pii is name-shaped, not transcript-shaped. Raw provider exceptions in both LLM routes are sanitised too.

Contracts

  • The pass runs as tracked named tasks drained at process exit, not on an untracked daemon thread.
  • Verification borrows an llm_executor thread per call instead of holding one across the whole serial loop.
  • Speakers already bound to a Person are shown to both models by name instead of Speaker N — the code read a person_name attribute a finalized TranscriptSegment never has, which also blinded the verifier to the fact that another speaker already held the name.
  • The verifier's exhausted path is recorded through record_fallback.
  • get_or_create_person_by_name takes an injectable Firestore client.
  • ServerConversation now propagates speakerLabelSuggestions, which it previously discarded at deserialization.

Still open: no Flutter UI. The data and the endpoints exist; a client still needs the two API calls, provider state with rollback, and a surface in the transcript. Two findings against the dropped taxonomy revision are moot.

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

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit e3a1a0b. Configure here.

Comment thread backend/routers/conversations.py Resolved

ghost 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: e3a1a0b79f

ℹ️ 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".


SPEAKER_RESOLUTION_SUGGESTIONS_FIELD = 'speaker_label_suggestions'

SPEAKER_RESOLUTION_DRAIN_TIMEOUT_SECONDS = 20.0

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Drain identity resolution before forcing cancellation

Fresh evidence in the final revision is that the new shutdown drain force-cancels each pass after only 20 seconds, while one pass can serially perform a proposal, six verifications, and four audio enrolments. Cancellation while run_blocking is creating a Person does not stop the worker operation, so the create can finish after the coroutine is cancelled without the later assignment or orphan cleanup; a normal shutdown can therefore still leave partial identity state. Route this pipeline through the application-owned task lifecycle or make shutdown wait until a safe durable boundary.

AGENTS.md reference: backend/AGENTS.md:L283-L288

Useful? React with 👍 / 👎.

Comment thread backend/database/users.py Outdated
Comment on lines +1369 to +1370
if person_data.get('speaker_embedding_attribution') == SPEECH_SAMPLE_ATTRIBUTION_LLM_INFERRED:
clear_person_speaker_embedding(uid, person_id)

ghost Aug 1, 2026

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 Recheck embedding attribution when clearing it

Fresh evidence in the final revision is that the attribution guard uses the snapshot loaded before the inferred samples are removed. If another request enrols a user-tagged sample and embedding after the removal frees the sample slot but before this clear executes, the stale llm_inferred value still deletes that newly confirmed embedding. Make removal and the conditional embedding clear one transaction, with the attribution predicate evaluated against the current document.

Useful? React with 👍 / 👎.

otherwise have both requests miss and both coin a record, leaving two
contacts for one human.
"""
person, _ = users_db.get_or_create_person_by_name(uid, person_name)

ghost Aug 1, 2026

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 Create the Person only after the suggestion is claimed

When accepting a previously unseen name, this call creates the Person before the subsequent conversation transaction establishes that the suggestion still exists. If a concurrent dismiss wins between the initial conversation read and that transaction—or the transaction fails—the endpoint returns 404/500 while the newly created contact remains in the user's People roster with no assignment. Preserve creation ownership and settle creation with acceptance atomically, rather than discarding the helper's created result here.

Useful? React with 👍 / 👎.

startedAt: generated.startedAt,
finishedAt: generated.finishedAt,
transcriptSegments: generated.transcriptSegments.map(_transcriptSegmentFromGenerated).toList(),
speakerLabelSuggestions: generated.speakerLabelSuggestions.map(SpeakerLabelSuggestion.fromGenerated).toList(),

ghost Aug 1, 2026

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 Expose suggestion actions in the Flutter flow

Fresh evidence in the final revision is that suggestions are now copied into ServerConversation, but a repo-wide search finds speakerLabelSuggestions only in schema/provider copying and tests, while app/lib/backend/http/api/conversations.dart has no accept/dismiss request and no widget consumes the field. Consequently every refuted or unverified suggestion remains invisible and unactionable in the shipped Flutter app despite the intended tap-to-accept flow; wire the field into the naming UI and call the new endpoints.

Useful? React with 👍 / 👎.

Comment thread backend/utils/speaker_identification.py Outdated
Comment on lines +531 to +535
users_db.set_person_speaker_embedding,
uid,
person_id,
embedding_list,
attribution,

ghost Aug 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fence inferred enrolment against later corrections

When the user corrects an automatically assigned speaker while this asynchronous audio extraction is still downloading, transcribing, or embedding the sample, the correction's revocation can complete before these writes run. The enrolment task never rechecks the durable conversation assignment, so it can subsequently store an llm_inferred embedding after the user has moved every segment away from this Person, recreating the wrong voiceprint that the revocation was meant to remove. Fence the enrolment on the current conversation/person generation or make the artifact write conditional on the assignment still being authoritative.

Useful? React with 👍 / 👎.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for continuing to tighten this up. The current head keeps the feature cohesive and the CI/gate coverage is encouraging, but I still need to block merge on the same security boundary because it remains present in the code that will authorize durable speaker identity changes.

On the current head, both LLM routes still put user-controlled conversation/user data into the system message template:

  • backend/utils/llm/speaker_resolution.py builds ChatPromptTemplate.from_messages([('system', prompt_text)]), and that system template includes {transcript}, {known_people}, and {user_name}.
  • backend/utils/llm/speaker_verification.py uses the same single-system-message pattern with {transcript}, {evidence_quote}, {speaker_lines}, and {user_name}.

Those values come from transcript content and user/person data. Because a non-refuted verifier result can persist person_id assignments and enroll an llm_inferred voiceprint, transcript prompt injection is still in the authorization path for a lasting speaker identity. Please keep the invariant/policy instructions in the system message and pass transcript/evidence/known-people/user-name values across a lower-trust data boundary (for example a separate human/data message with explicit delimiters or equivalent structured input), then add a regression test where prompt-injection text in the transcript/evidence cannot force an accepted speaker claim.

The developer doc change in docs/doc/developer/backend/listen_pusher_pipeline.mdx is agent-relevant: it describes the new LLM-driven finalization-time speaker naming/enrollment path and match-admission rules that future coding/review agents are likely to follow. The doc direction looks useful, but it should land only after the prompt-boundary fix is reflected in the code and tests so future agents do not copy the unsafe single-system-message pattern.

I’m still not asking to split this PR; the scope is cohesive around backend speaker naming. Existing labels (backend, security-review, needs-maintainer-review) remain appropriate, and passing checks are a good sign once this blocker is fixed.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@cursor

ghost commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_e7822797-22f5-4bd4-b6d6-7aba86c4db0a)

ghost 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: 8a0edc5252

ℹ️ 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".


for person_id in person_ids:
try:
await run_blocking(db_executor, users_db.delete_person, uid, person_id)

ghost Aug 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent deleting a Person another pass has reused

Fresh evidence in the final revision is that rollback still calls delete_person unconditionally for the pass that originally created the deterministic record. If pass A creates Alex, pass B resolves that record with created=False and successfully assigns it, but A's segment write is then refused or fails, A reaches this line and deletes B's now-referenced Person, leaving a dangling person_id and potentially failing B's enrollment. Before deletion, atomically prove that no other resolution has adopted the record, rather than treating creation ownership as exclusive lifetime ownership.

AGENTS.md reference: AGENTS.md:L39-L45

Useful? React with 👍 / 👎.

Max Carter 祁明思 added 15 commits August 14, 2026 19:06
…ions

The naming pass computes speaker_label_suggestions from a snapshot taken
before the LLM and refutation work, then persists them with a plain
update_conversation write. If the user accepts or dismisses a suggestion
(or manually names a speaker) while the pass is still running, that write
re-reads nothing and hands back the stale array, resurrecting a
suggestion for a speaker the user already settled.

Persist through a new transactional persist_speaker_resolution_suggestions
that re-reads the conversation inside the write boundary and drops any
incoming suggestion whose speaker now carries a person_id or is marked
is_user - the same eligibility-and-write-in-one-transaction pattern
assign_conversation_segment_people uses from the inference side.

Regression tests cover a now-resolved speaker not being re-suggested, an
is_user speaker not being re-suggested, mixed settled/unsettled filtering,
the plain happy path, and a missing conversation writing nothing.
The merged assign_segments_bulk routes segment resolution through
_resolve_bulk_segment_indices, which reads conversation.status to decide
whether legacy positional targets are allowed. The bulk-assign test
fixture built a SimpleNamespace without a status, so those tests
crashed with an AttributeError after the rebase.
…ution rebase

The rebase onto current main merged the PR segment-assignment work with main's
_resolve_bulk_segment_indices_refactor. The single-target and bulk assign routes
now track settled_speaker_ids for the segment-write transaction and schedule an
inferred-enrolment revocation for a Person whose only segment a reassignment
takes away.

- _FakeSegment gains the speaker_id the settled_speaker_ids tracking reads.
- The bulk user-assignment test now expects the revocation it provokes, matching
  the PR-authored TestBulkAssignRevokesContradictedInferences coverage.
…edHardware#10954)

A dismiss removes the suggestion but leaves the segments unresolved, so the segment-based settle check alone would let the finalization pass write the dismissed speaker back. Record dismissed speaker ids as a settlement marker on dismiss and have persist_speaker_resolution_suggestions skip them.

Regression tests cover the dismissed-not-resurrected case and the marker being recorded on dismiss.
… (PR BasedHardware#10954)

conversations.py/users.py and router files grew with the speaker-resolution feature; raise their exact baselines with justification. process_conversation.py shrank below its baseline and is ratcheted down to the current count.
fake-firestore's FakeTransaction.create is a no-op, which silently dropped the
atomic create-if-not-exists used by database.users.get_or_create_person_by_name.
A created Person never appeared in get_people, so the hermetic people-CRUD E2E
failed its "created person shows up in the list" assertion. Patch the fake at
the same seam as the other Firestore-behaviour corrections so transaction.create
queues a set write, matching real Firestore semantics.
The speaker-naming work grew conversations.py, database/conversations.py,
database/users.py, and process_conversation.py past their frozen counts, so
their owning shards are raised to the exact changed source counts. The rebased
branch also let several files ratchet down (mcp_sse.py, sync.py, users.py,
streaming.py), which the checker applies. Baselines now exactly match the
rebased source and pass the ratchet against origin/main.
The merge of origin/main into feat/speaker-resolution-from-evidence
silently dropped `from database import users as users_db` from
database/conversations.py, leaving the transactional suggestion write and
person-name-probe helpers referencing an undefined name. Re-add the import;
the speaker suite is green again (290 passed).
@undivisible
undivisible force-pushed the feat/speaker-resolution-from-evidence branch from 2b4b89f to 49ea6a9 Compare August 14, 2026 11:26
@undivisible

ghost commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

Author-identity + merge fixes on this head

  • git-author-identity blocker. A branch commit in the PR range (fix(backend): keep speaker-naming policy static) was minted with the ratchet <[email protected]> fixture author — the same leftover-identity bug as PR feat(desktop): calm the Permissions settings page #11525. Rewrote that commit's author to the correct identity and rebuilt the 14-commit linear slice + merge + tip on top (tree identical, verified with check_git_author_identity.py → OK).
  • users_db import re-added (previous merge dropped it) — speaker suite green.
  • Applied dart format to the two drifted app files from the merged main.

Branch MERGEABLE. Backend checks re-running on the rewritten head.

ghost 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: 49ea6a91fe

ℹ️ 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 +1704 to +1705
if segment.get('speaker_id') != speaker_id:
continue

ghost Aug 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fence accepted suggestions to their original segment set

When an offline sync batch is appended after this suggestion was created, backend/utils/sync/pipeline.py:1224-1251 merges segments whose speaker IDs are batch-local into the existing transcript. This loop then assigns every current segment sharing the numeric ID and returns all of them for trusted user_tagged enrollment, even though the stored suggestion carries its original segment_ids; an unrelated voice from the later batch can therefore be permanently enrolled under the accepted Person. Fresh evidence beyond the already-flagged automatic-assignment path is that this separate accept transaction also lacks the segment-set/generation fence. Validate the current segments against the suggestion's stored scope before assigning them.

AGENTS.md reference: AGENTS.md:L43-L43

Useful? React with 👍 / 👎.

Comment on lines +257 to +261
quote_words = _normalized_tokens(quote)
name_words = _normalized_tokens(name)
if not quote_words or not name_words:
return False
return all(part in quote_words for part in name_words)

ghost Aug 14, 2026

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 Require multiword names to appear contiguously

When a known multiword name such as Mary Ann is proposed against a grounded quote like “Mary thanked Ann,” this check passes because it tests each token independently, even though the name was never spoken. If the verifier then fails to refute the claim, the pass can assign and enroll that Person despite violating the feature's spoken-name boundary. Use the same contiguous token-sequence check applied to evidence quotes rather than unordered membership.

AGENTS.md reference: AGENTS.md:L43-L43

Useful? React with 👍 / 👎.

dart format against the pub-resolved SDK single-lines the fromJson/fromGenerated
constructor args the branch touched. Matches the repo Formatting check.

ghost 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: c9d7e59b91

ℹ️ 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".

deadline = asyncio.get_running_loop().time() + timeout
graceful = list(_background_graceful_tasks)
if graceful:
await asyncio.wait(graceful, timeout=timeout)

ghost Aug 14, 2026

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 Preserve graceful tasks beyond the shutdown deadline

When a rollout begins while speaker resolution is in enrolment, this waits only ten seconds and then cancels the supposedly graceful task. Cancellation while awaiting run_blocking does not stop the executor operation, so a Person creation, sample upload, or Firestore sample write can still finish after the coordinator has been cancelled, bypassing its orphan and half-written-enrolment cleanup and leaving an unreferenced Person/object or an inferred sample without an embedding. Make this workflow durably resumable or prevent shutdown cancellation from splitting its write/cleanup boundary rather than relying on a bounded in-memory grace period.

Useful? React with 👍 / 👎.


assigned_segment_ids = list(applied.get('segment_ids') or [])
if assigned_segment_ids:
background_tasks.add_task(revoke_inferred_speaker_enrolment, uid=uid, person_id=accepted_person_id)

ghost Aug 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace the inferred enrolment atomically

When the accepted Person already has an inferred voiceprint from an earlier conversation, this task deletes that valid sample and embedding before attempting to create the trusted replacement. The following extraction can legitimately return SKIPPED because this conversation has no durable audio, no sufficiently long turn, or fails transcription quality checks, leaving the Person with no enrolment even though accepting the suggestion succeeded. Replace the old sample only after the new sample and embedding are ready, or restore it when conversion fails.

AGENTS.md reference: AGENTS.md:L43-L43

Useful? React with 👍 / 👎.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since my last review: addressed — (1) the prompt-boundary fix holds on this head: backend/utils/llm/speaker_resolution.py and speaker_verification.py both keep policy in a static system message with transcript/known-people/owner-name data in the delimited user data message; (2) the dismiss-resurrection fix holds: remove_conversation_speaker_suggestion records dismissed_speaker_ids and persist_speaker_resolution_suggestions re-reads inside the transaction and filters both settled and dismissed speakers. Still open — the two red desktop Swift checks (see CI note; inherited, not caused by this diff). Newly introduced — nothing blocking.

The core of this PR survives a very large main merge intact, and the design is right: no single model output can write a voiceprint. What I verified on this head:

  • backend/utils/speaker_resolution.py — the gate grounds each claim by token-sequence matching (_contains_token_sequence, so a truncated quote cannot ground against "I'm Annette"), rejects owner-name and stopword claims, drops non-one-to-one speaker/name mappings (_drop_ambiguous), and refuses wholesale a transcript that collapsed to a single diarization id (_has_diarization) — the exact shape that would enrol a mixed-voice transcript under one Person.
  • backend/utils/llm/speaker_verification.py — refute-biased second model; parse failure/timeout resolves to refuted (REFUTED_ON_ERROR), so a broken verifier degrades the pass to suggestion-only, never to unchecked enrolment.
  • backend/database/conversations.py — accept_conversation_speaker_suggestion, remove_conversation_speaker_suggestion and persist_speaker_resolution_suggestions all re-read inside one transaction, so concurrent accept/dismiss/finalization writes cannot resurrect each other; assign_conversation_segment_people refuses any speaker with an already-resolved segment; update_conversation_segments drops suggestions for speakers the user settled by hand (settled_speaker_ids).
  • backend/database/users.py — get_or_create_person_by_name (deterministic name-keyed document id + transactional create) closes the duplicate-Person race when two conversations finish at once; legacy uuid4-keyed people stay authoritative.
  • backend/utils/speaker_identification.py and routers/listen/speakers.py — inferred enrolments are tagged llm_inferred, embedding recovery refuses inferred samples, and revoke_inferred_speaker_enrolment removes sample + embedding + storage object.
  • backend/utils/conversations/process_conversation.py — the pass runs on a deep copy after audio files are durable, scheduled via submit_background_task on the registered app loop with cancel_on_shutdown=False so shutdown drains it; everything is behind SPEAKER_RESOLUTION_ENABLED, default off.

Cost: bounded and only when enabled — one naming call plus at most 6 refutation calls per finalized conversation that still has unresolved speakers, on a nano-class route.
Security/privacy: persisted suggestions carry person_name + segment_ids only; no transcript text crosses the encryption boundary (_speaker_suggestion_payload, and render.py strips evidence_quote defensively — locked-conversation redaction is tested).
CI: Desktop Swift Build & Tests / Static & Test Contracts are red, but the failing macOS tests (ChatCitationTests, ShellModalScrimTests/PageGlassLaneTests, ProactiveLaneClientTests, AgentPillLifecycleTests crashes) are surfaces this PR does not touch — the branch's merge point predates main's fixes for several of them. This PR's only desktop change is generated client code and Desktop Swift Release Compile passes. A rebase onto current main should clear these; worth doing before merge.
Docs: listen_pusher_pipeline.mdx matches the code, including the prompt-boundary invariant stated as a keep-it-that-way rule.

USER IMPACT: none until the server flag is enabled; once on, conversations where a name is actually spoken will offer "Speaker 2 → Alex" suggestions the user can accept or dismiss instead of staying numbered. A wrong guess never writes a voiceprint unless a second model fails to refute it. Clients in this PR only gain typed access — no accept/dismiss UI ships here yet.

What I would still want: (1) a rebase onto current main with green desktop Swift runs, (2) the client follow-up that consumes accept/dismiss, (3) maintainer sign-off on the LLM-derived person naming and enrolment policy itself — that is the product/privacy decision the existing review labels are queued for.

Housekeeping: trimmed the secondary category labels (flutter, macOS, desktop, docs-tooling, web, javascript) since the client-file changes here are generated types; kept backend.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level removed flutter flutter work macOS desktop docs-tooling Layer: Documentation, examples, dev tools web javascript JavaScript or TypeScript implementation work labels Nov 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app backend Backend Task (python) human Human-authored pull request mobile needs-maintainer-review Needs a human maintainer to sign off before merge privacy-review Touches user-data persistence, permissions, or privacy-sensitive surfaces security-review Touches auth, provider routing, secrets, or security-sensitive surfaces workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants