Repository navigation
feat(speakers): auto-enroll retained voices from explicit tags - #23625
Conversation
Reuse manual receipts and durable learning jobs for quality-gated vector-only enrollment. Fence retained consent, source authority and deletion at publication; retract corrections and privacy opt-outs atomically. Reuse the encrypted pool through live, sync and finalized voiceprint readers with bounded decay.
Integrate the approved transient sync-off centroid contract from #23607 while keeping durable person enrollment restricted to retained private-cloud sync.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29bcd9068c
ℹ️ 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".
| low, high = placement.window | ||
| if high - low > 10: | ||
| center = (low + high) / 2 | ||
| low, high = center - 5, center + 5 | ||
| result[keys[segment.id]] = {'binding': binding(data), 'window': [low, high]} |
There was a problem hiding this comment.
Bind enrollment evidence to the actual extracted PCM window
When a segment crosses an audio-chunk boundary, _embed_missing first intersects its placement window with the midpoint chunk and then center-crops that intersection. This function instead center-crops the original placement: for a segment spanning [0, 30] and a midpoint chunk spanning [0, 20], the actual embedding covers [5, 15] but the recorded binding claims [10, 20]. Consequently, candidate can treat overlapping PCM as disjoint evidence and assign incorrect pooling weights. Record the actual extraction coordinates alongside each newly measured embedding rather than reconstructing them from placement.
Useful? React with 👍 / 👎.
| except Exception as error: | ||
| logger.warning('speaker_auto_enroll failed exception_type=%s', type(error).__name__) | ||
| vector_outcome = None |
There was a problem hiding this comment.
Instrument the exception-driven audio fallback
When vector enrollment raises, this handler changes modes to verified audio extraction, potentially retaining an audio sample instead of publishing a vector-only profile, but emits only a warning. backend/AGENTS.md requires new fallback paths to call the shared record_fallback helper; without it, this degradation is absent from the repository's fallback telemetry. Instrument this exception branch separately from the expected absent-evidence path.
AGENTS.md reference: backend/AGENTS.md:L318-L318
Useful? React with 👍 / 👎.
| from database.speaker_auto_enroll import allowed | ||
| from utils.speakers.auto_enroll import usable |
There was a problem hiding this comment.
Move the newly added imports to module scope
The new imports execute inside project_person_learning, contrary to the explicit module-scope import requirement in backend/AGENTS.md. The new retract_conversation import inside database/conversations.py::delete_conversation has the same issue. Move these imports to module scope, restructuring the dependency seam if necessary rather than extending the existing deferred-import pattern.
AGENTS.md reference: backend/AGENTS.md:L165-L165
Useful? React with 👍 / 👎.
| pooled = unit(np.average(vectors, axis=0, weights=weights)) | ||
| return {'vector': pooled.tolist(), 'segment_ids': ids, 'seconds': sum(weights), 'model': MODEL} |
There was a problem hiding this comment.
Recheck owner exclusion on the normalized pooled vector
When multiple clips individually sit just outside the owner-exclusion boundary, normalizing their average can move the resulting voiceprint inside that boundary despite passing the pairwise consistency check. For example, two equally weighted unit vectors can each have owner distance 0.51 and mutual distance 0.34, yet their normalized average has owner distance approximately 0.462. Both clips pass the current checks, and publish then stores this owner-like vector as another person's profile without another owner comparison. Apply the owner-exclusion check to the pooled vector before returning it, and preserve that check when combining contributions.
Useful? React with 👍 / 👎.
Check normalized candidate and decayed roster averages against the current owner. Keep explicit-source, retention and owner publication guards active for audio fallback regardless of the pool switch. Revalidate cached derived identities before live projection and final matching, retracting automatic maps after opt-out, and recheck cached sync vectors before use. Bind versioned evidence metadata to the actual extracted PCM coordinates, including chunk intersections and sample rounding, and instrument the exception-driven audio fallback through the shared telemetry helper. Add adversarial pooling, carried-receipt race, switch-off privacy and real live client/persistence regressions. Keep imports at module scope through module attribute seams so unrelated migration imports remain narrow.
|
Addressed the required Luna round-1 findings and the automated review findings in
Local validation: 1,246 distinct unit tests across 31 targeted files (including all nine files that failed the first CI run); corrected 67-test policy file green; zero backend type errors; backend E2E; listen/pusher stack and 13 real Firestore concurrency proofs; four real retention integration tests; full sync stack. The documented Luna's single full review was FIX-FIRST on the earlier |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70866ba03b
ℹ️ 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".
| if not auto_enroll.retained(context) | ||
| or row.get('enrollment_privacy_version') != context.get(auto_enroll_db.PRIVACY_VERSION, 0) | ||
| or not auto_enroll.owner_safe(row.get('embedding'), context.get('speaker_embedding')) |
There was a problem hiding this comment.
Invalidate cached voiceprints when their contributions are retracted
If a source conversation is deleted or its speaker tag is corrected while a listen session is open, retract_conversation and persist_assignment_effects remove the corresponding pool contribution without changing the user's privacy version. This refresh only checks user settings, privacy version and owner distance, so the cached vector and its automatic mappings remain valid even when the person's pool is now empty. Subsequent transcript batches and final matching can therefore continue assigning the identity using explicitly retracted evidence; the sync cache has the same gap. Revalidate the current person pool or track a pool revision that changes on retraction before reusing these vectors.
Useful? React with 👍 / 👎.
| def evidence_bindings(segments: Any, keys: Mapping, placements: Mapping, measured: Mapping, prior: Mapping) -> dict: | ||
| result = {} | ||
| for segment in segments: | ||
| data = segment.model_dump(mode='json') |
There was a problem hiding this comment.
Preserve capture coordinates when computing evidence bindings
For segments with audio_capture_start/audio_capture_end, TranscriptSegment._serialize_internal_evidence deliberately excludes those fields from JSON-mode dumps but includes them in Python-mode storage dumps. Consequently, this call computes binding(data) with null capture coordinates, whereas candidate hashes the stored segment with its actual coordinates, so freshly measured evidence never matches those segments—even during the publication transaction's authoritative reread. Enrollment then falls through to audio extraction or fails instead of using the vector-only evidence. Compute the binding from the internal Python-mode representation so its capture coordinates match the stored transcript.
Useful? React with 👍 / 👎.
|
The lead has subsequently required one scoped Luna round-2 delta review of the four privacy fixes plus opt-out/revocation paths. It is now running read-only against |
|
Luna round 2 returned FIX-FIRST (P0=0, P1=1): cached live/sync derived vectors could outlive source correction/deletion because those operations did not change the privacy generation. I accepted the finding. The corrective delta uses per-person encrypted-pool tokens in the owner authority document, atomically updated with publication/retraction/dismissal/person-deletion fencing. Cached profiles require that exact token and expire at their earliest contribution expiry. Live checks follow continuity IO; sync checks repeat after embedding IO. Regression tests exercise actual live/sync consumers, stale people snapshots, partial retraction, all revocation paths in both kill-switch states, expiry, and revocation during IO. All 1,276 tests across 33 targeted files pass locally; type and hermetic checks are in progress before publication. The old head's single CI-failed archive fixture now uses an explicit isolated IO dependency seam and passes locally. Lead ruling c6cb20 explicitly authorizes ONE Luna round 3 delta, requiring zero P0/P1, and moves this PR to the next release train. That review has not started yet. The lane does not merge or deploy. Evidence: |
Bind each derived pool to a per-person owner-authority token updated in the same transaction as publication, correction, deletion and dismissal. Validate the token and contribution expiry at cache load/use, fence person deletion, and check after slow embedding or continuity IO before final matches. Add actual live/sync revocation regressions, a loopback Firestore proof, and isolate the archive contract fixture's database IO dependency. Failure-Class: none
Text detection may perform IO after voice matching. Remove revoked derived voice decisions immediately before applying labels, including undiarized speaker IDs, while keeping independent text and manual authority. Failure-Class: none
|
The round-2 cached-profile revocation P1 is corrected in published head Each encrypted person pool now has a bounded owner-authority token updated atomically with publication, source correction/deletion, privacy opt-out, dismissal and person-deletion fencing. Pool loads and cached use require the exact token, privacy generation, retention, owner exclusion and contribution expiry. Live final checks follow continuity IO; sync rechecks after embedding IO and again before applying labels after text IO, removing revoked voice decisions/suggestions while preserving independent text/manual authority. Local evidence: 1,308 distinct targeted unit tests across 35 files, zero type errors, backend E2E, full listen/pusher plus 13 Firestore concurrency proofs, nine loopback Firestore integration cases, and full sync pass. Final sync two-workers passed in 28.9s without retry. Normal pre-push hooks also pass, including runtime-image and OpenAPI contracts. The old head's only CI-failed archive fixture passes with an explicit isolated database IO seam. The lead-authorized Luna round 3 delta ( |
|
Luna round 3 (explicitly authorized by lead ruling The reviewer inspected the delta from |
|
Final handoff at 2026-10-25 22:00Z: exact head Lead-authorized read-only Luna round 3 returned SHIP, P0=0 / P1=0 on this same head. Local validation, review and CI receipts are recorded in the lane evidence report; no source changes followed review. Subsequent GitHub state records an external merge at 22:00:30Z as Lead ruling |
…wn deletion gate (#24988) ## Problem (P0, privacy) `DELETE /v1/conversations/{id}?cascade=true` answers `409 account_gate_busy` for everyone. Prod (Cloud Run `backend`), 2026-11-09 09:00 to 11:35 UTC: **371 of 374** such DELETEs returned 409, **0 returned 204** (the other 3: 2×504, 1×401), across 31 client IPs and 186 distinct conversations. Memory deletes look the same: `DELETE /v3/memories*` since 06:00 UTC, **1487 of 1491** returned 409. The route turns the gate exceptions into a 409 without logging, so these requests leave no traceback. The evidence below comes from Firestore and the code path: - `legal_hold_deletion_gates` (one doc per uid, read-only query): `explicit_memory_deletion` gates ending in `failed` (acquired, then the body raised) go from **0 on 2026-10-26** to **49 on 10-27** and 80–170/day since. Today: 80 failed vs 12 completed. Only 7 gates are `running`, so stale gates across accounts are not the cause. - 272 of the 371 conversation 409s return in under 0.2 s. These are retries hitting a gate held by the same account. About 99 run longer: those acquired the gate and failed inside the body. ## Root cause: the request blocks on its own gate 1. `delete_conversation` takes `destructive_operation_gate(uid, kind='explicit_memory_deletion')` for the whole cascade body. Introduced by **#23783** (David Zhang, commits fe4499a + 1bba122, merged **2026-10-27 06:38 UTC**). The analyst found the last normal success at 2026-10-27 16:57 UTC. 2. Inside the body, `delete_conversation_and_frame_evidence` → `delete_conversation_with_sync_sources` → `conversations_db.delete_conversation` starts with `speaker_auto_enroll.retract_conversation` (#23625, 2026-10-26), which runs `external_write_fence(uid, transaction=...)`. `delete_transcript_chunk_vectors` is fenced the same way without a transaction (#22835, 2026-10-20). 3. `external_write_fence` reads `legal_hold_deletion_gates/{uid}`, sees the request's **own** running gate, and raises `DestructiveOperationInProgress: external data write blocked by destructive operation`. The `_EXTERNAL_TRANSACTION` reuse only covers writes nested inside another transactional fence, not writes under a gate the request owns. Effect: the tombstone is written and memories and action items are retracted, but the conversation doc, its vectors and its audio stay. The client retries and gets 409 every time. One Windows client retried 144 times. ## Fix `external_write_fence` now lets a write through only when the running gate is the one **this context** acquired: `_ACTIVE_GATE == (uid, gate.kind, gate.token)` and `gate.uid == uid`. Unchanged: - other requests (they have no `_ACTIVE_GATE`), other accounts, and a holder displaced by a stale takeover (its token no longer matches) are still blocked; - account deletion (`account_deletions/{uid}`) still blocks, including the gate owner; - a pass through the owner's own gate sees a running gate, so `reusable` stays false and the result is never cached for other writers; - canonical intake (`assert_no_destructive_operation_transaction`) stays strict even inside the owner's context. `test_ws_j_delete_privacy::test_delete_all_final_rescan_tombstones_concurrent_write` still proves an inline intake write is refused. ## Tests - New: `test_legal_holds.py::test_gate_owner_nested_writes_are_not_blocked_by_their_own_gate[False|True]`, `…exemption_never_reaches_other_requests_or_accounts`, `…exemption_ends_after_peer_takeover_and_never_skips_account_deletion`. - New, route level with the real gate on a fake Firestore: `test_conversation_delete_wire_contract.py::test_cascade_delete_nested_fenced_writes_do_not_hit_their_own_gate`. Before the fix it fails with `409 != 204`. The existing wire tests replaced the gate with `nullcontext()`, which is why they never caught this. - Without the fix, the 3 new reproduction tests fail. With it, all 83 unit test files that reference the gate or fences pass (3128 tests). ## Not proven - Which nested call blocks **memory** deletes (`MemoryService.delete` / `delete_batch` under `_legal_hold_gated_deletion`). The fix covers any nested `external_write_fence` in that path. If a memory-path self-block goes through `assert_no_destructive_operation_transaction` instead, this PR does not fix it. Check memory DELETE 409 rates after deploy. - Conversations left half-deleted between 2026-10-27 and the deploy (tombstoned but still stored) need a cleanup pass. Not in this PR. ## Scope after review This fixes cascade **conversation** deletes only. Memory deletes (`routers/memories.py`) never reach a nested `external_write_fence`; their 409s are tracked separately (likely #24886, which made stale memory-vector cleanup on read paths take the exclusive account gate). About 272 of the 371 conversation 409s sampled today fail before the delete body runs (gate acquisition), which this PR does not change; check the 204 rate after deploy. Added after review: `test_gate_owner_pass_is_never_cached_for_other_writers` (privacy_ttl60 on): the owner passes its own fence, a writer in a fresh context still raises and re-reads live authority every time. It fails if the owner pass is made reusable (`legal_holds.py:534`). ## Product invariants affected none Failure-Class: FC-destructive-gate-keyed-on-proxy-for-intent UI-Evidence: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24988?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24988?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24988&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Explicit speaker tags and confirmations now try quality-gated, vector-only voice enrollment through the existing durable learning jobs. Future live/sync/finalized naming can reuse that pool without retaining another audio sample. Automatic/carried labels and training opt-outs cannot enroll.
Durable publication requires retained private-cloud sync AND save_other_voice_profiles at execution and commit (lead ruling 65d10d). Owner/person-bound AES-GCM pools hold at most five source-conversation contributions with decay; receipt corrections, deletion and privacy opt-out retract contributions atomically. A privacy generation fences off/on races. Quality/authority rejections cannot bypass these gates through audio; an absent-evidence fallback rechecks owner exclusion, retention, privacy generation, source and deletion fences. SPEAKER_AUTO_ENROLL_ENABLED defaults on and disables publication/use while retraction remains active.
Validation: 1,308 distinct targeted unit tests across 35 files pass through backend/test.sh with explicit lists and four workers, including all prior CI-failed files. The final sync assignment fence passes 327 affected tests, including 83 policy cases. Full backend typecheck has zero errors. Backend E2E, listen/pusher plus 13 real Firestore concurrency proofs, nine real loopback integration cases (five new pool-authority and four transient-retention), and the full sync harness pass. The final sync run passes batch-two-workers in 28.9 seconds with no retry. One earlier source run hit the documented ordering flake; its single permitted rerun passed. Exact-head GitHub CI is required before final handoff.
Luna round 1 returned four P1s, now addressed: owner checks on candidate/roster/decayed averages, explicit-only audio fallback including carried-receipt races, switch-independent privacy guards, and fresh live/sync cached-profile authority. Automated review's actual-PCM binding, shared fallback telemetry and module-scope import findings are addressed too. Round 2 found one remaining P1: cached vectors survived source retraction. The corrective delta atomically binds each person's encrypted pool to an owner-authority token, validates that token at load/use, expires cached authority, fences person deletion, and rechecks after embedding/continuity IO and before sync label application after text IO. Regression tests cover actual live/sync consumers, all revocation paths in both switch states, stale snapshots, partial retraction, expiry and IO races. Lead-authorized Luna round 3 (c6cb20) reviewed exact head 1a5463f and returned SHIP, P0=0/P1=0, with no concrete findings. It was read-only and ran no tests. Lead owns merge and the next release train; current CI state belongs to this head's GitHub checks.
Expected-effect simulation: frozen qworker five-crop Gate T words/turns; first 40% for simulated tags, later speech for evaluation with a two-second gap and separately extracted Omi-v2 embeddings. On 5,112 matched labeled held-out words, top-1 tagging improves name accuracy 38.4% -> 50.2% (+11.8pp, +602 correct); named share 39.1% -> 50.9%. Strict quality gates accept one contribution; top-2/3/5 tagging yields no additional gain in this split. This is a small local expected-effect simulation using direct qworker naming thresholds, not production acceptance. The frozen original naming is 39.0% on this held-out subset; its published 41.2% uses a different, full-crop denominator.
This PR remains unmerged. Lead owns merge and deployment of API/sync/enrichment/listen/pusher consumers; no GPU or client release is needed. Qualfix2 PR #23607 owns the transient sync-off evidence contract. No production access, account reads, data mutation, notifications or historical repair occurred.
Failure-Class: none
Product invariants affected: none (metadata suggestion).
Line-Count-Exception: backend/database/conversations.py | 4480 -> 4481 | Connect the existing speaker authority to bounded helpers; pool policy and persistence live in separate new modules.
Line-Count-Exception: backend/database/users.py | 2507 -> 2525 | Connect the existing speaker authority to bounded helpers; pool policy and persistence live in separate new modules.
Line-Count-Exception: backend/routers/listen/speakers.py | 1499 -> 1540 | Connect the existing speaker authority to bounded helpers; pool policy and persistence live in separate new modules.
Line-Count-Exception: backend/routers/listen/transcripts.py | 1673 -> 1678 | Connect the existing speaker authority to bounded helpers; pool policy and persistence live in separate new modules.
Line-Count-Exception: backend/utils/conversations/speaker_resolution.py | 1551 -> 1595 | Connect the existing speaker authority to bounded helpers; pool policy and persistence live in separate new modules.