Skip to content

fix(people): automatic naming of others is paid everywhere; voice evidence follows its label - #20320

Merged
Git-on-my-level merged 14 commits into
mainfrom
lane/voiceprint-quality
Oct 2, 2026
Merged

Git-on-my-level merged 14 commits into
mainfrom
lane/voiceprint-quality

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #20190 and #20252. A review of the speaker-label work found that learned voice evidence could outlive the decision that authorised it, and that automatic naming of other people was plan-gated on some surfaces and not others. This PR closes those gaps and makes "earlier matches" compete against every known voice. It changes no routes, wire models, thresholds, flags or stored-data format requiring migration.

Product ruling applied (David, 2026-10-02): automatically naming other people is a paid feature on every surface; free plans get automatic identification of the account owner only. Naming, correcting and rejecting labels by hand stays free, and a free manual tag may still teach a voiceprint.

Change

  • Entitlement at candidate selection. Live matching, sync speaker identification, conversation-wide resolution, the transcription shadow, spoken-introduction detection and earlier matches no longer load or score non-owner voiceprints for a free plan. Owner recognition, manual edits, same-stream carry of a manual label and every answer to an already-served card, including one that names a person, are unaffected. The plan is read once per live conversation or sync batch; a plan change is observed at the next conversation or batch. A failed read stays closed for that call and is retried.

  • A wrong "this is me" can be undone. Owner confirmations now record their source segments and decision generation. Correcting or rejecting those segments removes the contribution and rebuilds the owner voiceprint in the same transaction. Older confirmations, which only record their conversation, are removed for that conversation on correction. One conversation holds at most one of the five slots.

  • Delayed teaching honours the current decision. An owner-teaching task that runs after the user re-tagged the same segments with training turned off no longer publishes.

  • Person samples are fenced to their source. Publication rereads the conversation inside the transaction and refuses if it was deleted, the label changed, or training consent was withdrawn. An unrelated edit elsewhere in the conversation (tagging a second speaker) does not void the attempt.

  • Earlier matches compete. A cached voice is offered for a person only when that person beats the owner and every other usable voiceprint under the existing threshold and margin; near-ties abstain.

  • Owner clip download moved off the storage pool its own child downloads use.

  • Audit follow-ups (2026-10-03). Naming a person on a served card is free: the answer route no longer refuses a free plan (ruled by David; automatic suggestions stay paid). A speaker-level receipt entry stamped with a capture scope governs teaching only inside that scope, for people and for the owner, so a label carried in one scope cannot authorize another scope's audio in a merged conversation. Owner publication rechecks its own contributing segments in the transaction instead of requiring an unchanged receipt generation, so tagging another voice no longer discards valid owner teaching. A plan change taking effect at the next conversation is the ruled behaviour, not a gap.

Evidence

Offline replay on one hand-labeled account (aggregates only; the production embedding model's stored vectors; real backend policy functions). It is one account with few repeat people, so none of this is a population false-accept rate.

Measured Baseline Candidate
Earlier-match offers, 26,243 candidate/query pairs 584 offered, 453 wrong 136 offered, 41 wrong (36 correct offers lost)

Measured and deliberately not shipped:

  • Pooling separated owner turns: 56 of 61 selections usable against 52 of 61; too small a gain to change the rule without acoustic validation of the four new clips.
  • A voiced-speech floor: 58 of 62 ten-second plans hold under ten seconds of voiced audio, so adding the floor alone would reject nearly everything.
  • Several exemplars from different conversations: owner recall 85.3% against 73.5% at the current threshold with equal retained audio, but impostor accepts rise from 8.8% to 11.5%; needs calibration on more than one account.
  • Replacing the transcript check with acoustic consistency: 12 of 54 uniformly wrong-voice pairs pass, so it cannot stand in for placement.
  • Corrected audio placement: transcript-check passes rise from 134 to 251 of 882 windows; still too low to ship a recovery rule.
  • Pooling short live fragments: 719 against 694 of 1,426 speaker groups reach five seconds, on a stored-segment proxy without real event timing.

Tests

  • New backend/tests/unit/test_voiceprint_authority.py: free/paid/downgrade matrix across live, sync and resolution; delayed opt-out; correction and rejection retracting owner evidence; duplicate delivery; publication after delete, tombstone, label change and consent change; publication surviving an unrelated edit; entitlement read failure; carried-label teaching inside and outside its capture scope; owner publication surviving a tag on another voice and denied on revocation, opt-out and rejection. test_speaker_tag_prompts_service.py now asserts a free plan can name a person on a served card.
  • test_speaker_voice_matches.py: owner and duplicate-person competition.
  • 27 affected unit files pass through backend/test.sh; all four unit shards passed locally through backend/scripts/run-unit-ci.sh --all before the final review commit; backend typecheck reports 0 errors; the pusher import graph gains no torch or onnxruntime dependency.
  • Not run: anything against a live backend or device, Firestore contention, or a Docker image build.

Rollout notes

  • Behaviour change for free plans: other people stop being named automatically in live, sync and reprocessed conversations. Existing labels are not removed, and manual tags keep working.
  • Backend only; deploy Cloud Run, listen and pusher together so all three apply the same rule.

Product invariants affected

none

Failure class

Failure-Class: FC-stale-selection-used-as-write-authority

Teaching read a label, did slow audio work, then wrote a voiceprint without re-reading the label's authority. The publication and correction transactions now reread the source and write only for still-authorised segments. Guard: backend/tests/unit/test_voiceprint_authority.py.

🤖 Generated with Claude Code

Review in cubic

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 36 files

Confidence score: 4/5

  • In test_desktop_migration.py, the module-level stub can leak into later speaker-profile tests and make them use the always-false authority check. Scope or restore the stub.
  • In add_owner_voice_confirmation, an unrelated edit between the read and pool transaction can still abort owner publication with stale_assignment. Review whether the fence should distinguish unrelated edits.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/unit/test_desktop_migration.py">

<violation number="1" location="backend/tests/unit/test_desktop_migration.py:172">
P2: This module-level stub replaces the authority check for the rest of a shared pytest process, so later speaker-profile tests can reuse the always-false mock instead of the production function. Scope or restore the stub rather than leaving it registered globally.</violation>
</file>

<file name="backend/utils/speaker_tag_prompts/service.py">

<violation number="1" location="backend/utils/speaker_tag_prompts/service.py:766">
P3: An unrelated edit that lands after this read but before the pool transaction still aborts the owner publication with `stale_assignment`. The transactional fence in `add_owner_voice_confirmation` compares the conversation's current receipt generation (strict equality) against `expected_receipt_generation`, which here is re-read from the *same* initial `conversation` snapshot — not the `card_generation` that authorized these segments. So the PR invariant "unrelated edits do not invalidate publication" only holds for edits that predate this read: any assignment edit (e.g., tagging a different speaker) during the multi-second window between this read and the commit bumps the receipt generation and the fence returns 0. The segment-level `authorized_owner_segments(..., card_generation=...)` check cannot catch this because the owner decisions are unchanged.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/routers/listen/speakers.py Resolved
Comment thread backend/utils/owner_voice_evidence.py Resolved
Comment thread backend/database/voice_profiles.py Resolved
Comment thread backend/tests/unit/test_sync_v2.py Resolved
Comment thread backend/routers/listen/speakers.py Resolved
outcome = 'clip_not_clean'
return outcome
window = owner_clip_window(conversation, segment_ids)
authorized = authorized_owner_segments(conversation, segment_ids, card_generation=card_generation)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: An unrelated edit that lands after this read but before the pool transaction still aborts the owner publication with stale_assignment. The transactional fence in add_owner_voice_confirmation compares the conversation's current receipt generation (strict equality) against expected_receipt_generation, which here is re-read from the same initial conversation snapshot — not the card_generation that authorized these segments. So the PR invariant "unrelated edits do not invalidate publication" only holds for edits that predate this read: any assignment edit (e.g., tagging a different speaker) during the multi-second window between this read and the commit bumps the receipt generation and the fence returns 0. The segment-level authorized_owner_segments(..., card_generation=...) check cannot catch this because the owner decisions are unchanged.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/speaker_tag_prompts/service.py, line 766:

<comment>An unrelated edit that lands after this read but before the pool transaction still aborts the owner publication with `stale_assignment`. The transactional fence in `add_owner_voice_confirmation` compares the conversation's current receipt generation (strict equality) against `expected_receipt_generation`, which here is re-read from the *same* initial `conversation` snapshot — not the `card_generation` that authorized these segments. So the PR invariant "unrelated edits do not invalidate publication" only holds for edits that predate this read: any assignment edit (e.g., tagging a different speaker) during the multi-second window between this read and the commit bumps the receipt generation and the fence returns 0. The segment-level `authorized_owner_segments(..., card_generation=...)` check cannot catch this because the owner decisions are unchanged.</comment>

<file context>
@@ -760,12 +763,16 @@ async def store_owner_voice_sample(uid: str, conversation_id: str, segment_ids:
             outcome = 'clip_not_clean'
             return outcome
-        window = owner_clip_window(conversation, segment_ids)
+        authorized = authorized_owner_segments(conversation, segment_ids, card_generation=card_generation)
+        if set(authorized) != set(segment_ids) or not authorized:
+            outcome = 'stale_assignment'
</file context>

Git-on-my-level and others added 7 commits October 2, 2026 18:09
Bind owner and person teaching to current consent and source authority, retract corrected owner evidence, and resolve paid automatic naming at candidate selection. Keep owner recognition and manual corrections free.

Co-authored-by: Codex Astra <[email protected]>
Require a requested person to beat the owner and other usable prints before offering an earlier match. Document entitlement timing and reversible teaching authority.

Co-authored-by: Codex Astra <[email protected]>
Pair stale-source rejection tests with current-receipt and legacy-label success cases using the strict transaction harness.

Co-authored-by: Codex Astra <[email protected]>
…nt read failures

Publishing a person's voice sample required the conversation's receipt
generation to be unchanged, so tagging a second speaker while the first
sample was still being verified discarded it. The per-segment authority
check already rejects a changed label, a revoked consent and a deleted
source; require only that the receipt has not gone backwards.

A failed subscription read on the live path now stays closed for that call
and is retried, instead of raising into transcript processing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The entitlement is now read before the person, so the test must supply it
instead of reaching for a real subscription.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…path

The plan check imported utils.subscription, which loads the billing SDK;
live and sync matching now import that check, so every importer paid for
it (about 0.1 s of CPU, enough to trip the unit suite's duration guard).
Read the paid-plan set from the plan catalog instead. A sync segment with
no voiceprint snapshot is owner-only rather than reading the plan itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups, no product ruling changes:

- A manual whole-voice label maps without a loaded profile: the name is
  resolved from the person row (one read) so free plans keep the manual
  mapping while non-owner profiles stay unloaded; a post-read staleness
  check preserves rotation safety.
- Speaker-level owner receipts are scope-qualified: a merged conversation
  reusing numeric speaker ids cannot authorize another capture scope's
  owner audio, and owner confirmations record only the selected run's
  segment ids so a later edit in another scope retracts only its own.
- Owner-contribution retraction covers merged-away donor conversations in
  one cumulative transaction update.
- Entitlement read failures fail closed for person prints only: owner
  recognition survives in resolution and sync cache construction.
- Person voice-match route resolves the person (404 contract) before the
  paid gate, and one unusable stored embedding no longer 500s the scan.
- Publication fences deny locked/discarded conversations, malformed
  receipt generations, and undecodable transcript blobs instead of
  raising inside the write transaction; embedding recovery revalidates
  save_other_voice_profiles.
- Legacy-tolerant timestamp parsing in owner pooling/retraction.
- Tests: free-plan paths assert no suggestion event and owner-only sync
  cache; the failover-clip fake asserts the published segment ids and
  receipt generation; paid fixtures scoped or pinned explicitly.

Verification: BACKEND_UNIT_TEST_FILE_LIST across 21 affected unit files
(425 passed, 0 failed) via backend/test.sh; pyright 0 errors via
scripts/typecheck.sh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the lane/voiceprint-quality branch from a874e2d to 7962076 Compare October 2, 2026 12:52
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Addressed the review round in 7962076 — verification below; two notes on threads deliberately left unresolved, plus one factual correction.

Fixed (21 threads): manual whole-voice labels now resolve the person row directly so free plans keep manual mapping without loading non-owner profiles (with a post-read staleness check); speaker-level owner receipts are scope-qualified so merged conversations reusing numeric speaker ids cannot authorize another capture scope's owner audio; owner confirmations record only the selected run's segments; owner-contribution retraction covers merged-away donor conversations; entitlement-read failures fail closed for person prints only — owner recognition survives in resolution and sync cache construction; the person voice-match route resolves the person (404 contract) before the paid gate and no longer 500s on one unusable stored embedding; publication fences deny locked/discarded conversations, malformed receipt generations, and undecodable transcript blobs instead of raising inside the write transaction; embedding recovery revalidates save_other_voice_profiles; legacy-tolerant timestamp parsing in owner pooling/retraction. Tests: free-plan paths assert no suggestion event and owner-only sync cache; the failover-clip fake asserts the published segment ids and receipt generation; paid fixtures scoped or pinned explicitly.

Left unresolved (no code change):

  • test_desktop_migration.py stub leak: the backend runner is file-isolated by default (BACKEND_PYTEST_FILE_ISOLATION=1 in backend/test.sh) — each test file runs in its own pytest process, so a module-level stub cannot reach later speaker-profile tests. The parallel shared-session mode that would make this real is opt-in (BACKEND_PYTEST_PARALLEL_SESSION) and documented as not shippable as default due to dense sys.modules contamination.
  • named_speakers_allowed retry rate-limit: the entitlement read is already serialized per conversation under _entitlement_lock and the comment in the code documents "Unresolved is not denied" — the retry is the deliberate recovery path so a transient Firestore outage self-heals at the next introduction; adding a cooldown would delay legitimate plan changes from taking effect.
  • store_owner_voice_sample fence window: the strict-equality receipt-generation fence is the safety fence this PR adds — an unrelated edit that lands in the read→commit window bumps the generation and correctly aborts the publication (stale_assignment); the segment-level authority check cannot weaken that fence for unrelated edits, and the window is seconds.

Verification: 409 tests across the 8 affected unit files via BACKEND_UNIT_TEST_FILE_LIST ... backend/test.sh (all green); black --check clean on the 16 changed files; full repo pre-push preflight passed (firestore-index-guard, feature-flag-registry, product-invariants, failure-class-protocol via OMI_PR_BODY_FILE, and the rest).

Git-on-my-level and others added 7 commits October 3, 2026 00:54
Conflict in backend/utils/speaker_tag_prompts/service.py: main attributes the
owner clip read with caller='owner_confirmation'; this branch unpacks the
window's scope and speaker key for contributor filtering. Both are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cross unrelated edits

Audit follow-ups on the paid-naming ruling (automatic naming of other people
is paid; naming by hand is free on every plan):

- A card answer that names a person is no longer refused on a free plan.
  Automatic suggestions stay withheld at get_prompts; a card served before a
  downgrade, or an owner check answered with who it is, now applies.
- A speaker-level receipt entry stamped with a capture scope governs teaching
  only inside that scope. A merged conversation reuses numeric speaker ids, so
  a carried label could authorize another scope's audio. The rule moves into
  winning_receipt_decision so person and owner teaching share it.
- Owner publication rechecks its own contributing segments inside the
  transaction instead of requiring an unchanged receipt generation, so tagging
  another voice no longer discards valid owner teaching. Revocation,
  opt-out, deletion, lock and discard still deny. Person and owner fences
  share one source reader.

A plan change takes effect at the next conversation (ruled 2026-10-03); the
per-conversation entitlement read is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
These tests arrived from main (#19009) and exercise naming other people in
sync, which this branch gates on the plan. Without a declared plan they read
the subscription and hit the blocked network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t speech out of owner clips

Independent review follow-ups:

- A hand-made speaker-level label stamped with a capture scope still governs
  teaching after conversation-wide resolution rewrites segments to a
  conversation scope. Only a carried entry, or a mismatch between two capture
  scopes, is refused. The previous rule discarded valid manual teaching for
  people and for the owner once a conversation was resolved.
- An owner clip window is rejected when an owner segment outside the
  authorized set overlaps it in the same scope, so opted-out or unconfirmed
  speech cannot ride inside a clip and escape retraction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…every contributor

Re-review follow-up. The overlap rule compared against the job's own segment
ids, so a clip overlapping another confirmed owner segment was refused
(segment tags and some card answers stopped teaching). The window is now
judged against every segment the owner currently allows teaching from; an
opted-out or unconfirmed owner segment still rejects it. Publication records
every consented segment inside the window so a later correction or opt-out
of any of them retracts the contribution.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Third review pass. The widened contributor list named zero-duration provider
points and unplaced text inside the clip window. They contribute no audio,
so editing that text could retract a valid owner sample or block its
publication. Contributors must now be placed and have positive duration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Also brings two tests in line with intended changes already on main:
- test_rate_limiting pins the developer conversation-list cap that #13955
  unified at 200 (was 25 with transcripts / 100 without).
- test_selfheal_recovery expects the bounded structure_reason field that
  #20359 added to the selfheal_guard refusal event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 9be8225 into main Oct 2, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/voiceprint-quality branch October 2, 2026 21:10
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