Repository navigation
fix(people): automatic naming of others is paid everywhere; voice evidence follows its label - #20320
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
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 withstale_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
| outcome = 'clip_not_clean' | ||
| return outcome | ||
| window = owner_clip_window(conversation, segment_ids) | ||
| authorized = authorized_owner_segments(conversation, segment_ids, card_generation=card_generation) |
There was a problem hiding this comment.
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>
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]>
a874e2d to
7962076
Compare
|
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 Left unresolved (no code change):
Verification: 409 tests across the 8 affected unit files via |
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]>
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 and deliberately not shipped:
Tests
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.pynow asserts a free plan can name a person on a served card.test_speaker_voice_matches.py: owner and duplicate-person competition.backend/test.sh; all four unit shards passed locally throughbackend/scripts/run-unit-ci.sh --allbefore the final review commit; backend typecheck reports 0 errors; the pusher import graph gains no torch or onnxruntime dependency.Rollout notes
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