Repository navigation
fix(backend): drop a speaker profile when its teaching sample is deleted - #18881
Conversation
The expand delete removed the audio file and left the embedding, so tagging that person later did not build a new profile. Fixes BasedHardware#5084 Co-authored-by: Cursor <[email protected]>
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @apoorvdarshan — good diagnosis, and reusing the existing transactional invalidation (invalidate_person_speech_profile) instead of adding a new write path is exactly the right shape for this fix. I confirmed the mechanism: delete_user_person_speech_sample only removes the GCS blob, so speech_samples / speaker_embedding / speech_sample_source survived in Firestore and the stale embedding kept matching. I also ran the new suite plus the adjacent ones (test_speech_profile_deletion.py, test_taught_speaker_persistence.py, test_manual_speaker_assignments.py) against this head — 36 passed.
Per-file notes:
backend/utils/speech_profile_deletion.py— the guard matches the provenance shape written byreplace_person_speech_profile(conversation_id equality + segment_ids, database/users.py:1066) and is safe on a missing person/source/empty conversation id.backend/routers/speech_profile.py— reading the person before invalidation is fine because the actual fence (conversation + segment overlap) is re-checked inside the Firestore transaction (users.py:1082), so a concurrent teach or label correction can't be corrupted. Deleting blobs via the returnedspeech_samplespaths is also the correct cleanup: profiles with teaching provenance are uuid4-named (upload_person_speech_sample_from_bytes), so the legacy{memory_id}_segment_{segment_idx}.wavfilename delete is a no-op exactly where the new code fires.backend/tests/unit/test_speech_profile_deletion.py— covers the helper's three branches, but only the helper.
Two changes needed before merge:
-
CI is red on
PR Metadata PreflightandHygiene: afix:commit subject requires aFailure-Class:declaration in the PR body. Runscripts/pr-preflight --suggestfrom the repo root for paste-ready guidance, then add the accepted form (e.g.Failure-Class: new) to the PR description. -
Regression coverage at the endpoint: the original bug lived in
delete_extra_speech_profile_sample— blob deleted, Firestore profile untouched — so the regression test should exercise that handler, not only the new helper.tests/unit/test_speech_profile_status.pyalready shows the sanctioned pattern (importrouters.speech_profile,patch.objectits dependencies): assertinvalidate_person_speech_profileanddelete_speech_profile_blobare invoked when the deleted sample's conversation matches the teaching source, and not invoked when it doesn't. The helper-only test can't catch a re-break of the wiring.
Non-blocking observation: profiles created before teaching provenance existed have no speech_sample_source, so deleting their last sample still leaves the stored embedding in place. Migrating legacy data is out of scope here — just worth knowing when triaging #5084 reports from long-tenured users.
With the declaration and the endpoint test, this should be ready for maintainer merge review — the approach itself looks correct to me.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Cover delete_extra_speech_profile_sample directly so a re-break of the invalidation wiring is caught, not just the provenance helper.
|
Added the endpoint regression test. Also added the |
Dismissed: both concerns from this review are resolved on the current head — the Failure-Class declaration is in the PR description (PR Metadata Preflight / Hygiene green), and endpoint-level regression tests for delete_extra_speech_profile_sample were added and ran green in CI.
|
Both items from the earlier automated review are resolved on this head — thanks for the quick turnaround, @apoorvdarshan.
Re-checked the wiring on this head: Removed the now-stale by AI on behalf of David — if a reply is needed, please @Git-on-my-level. |
aryanorastar
left a comment
There was a problem hiding this comment.
85839331c84ba8ebf7b5a40a570e85d096f5d5dd delete_extra_speech_profile_sample deleting a sample leaves that conversation's teaching segments in place. test_speech_profile_deletion.py pins that hole. Backend unit suite passed.
|
Follow-up verification on the current head (8583933), complementing the earlier automated ack:
The ENCRYPTION_SECRET constant in the test is the repo's standard unit-test fixture value, so no concern there. Thanks @apoorvdarshan — this closes the exact gap from #5084 where the embedding outlived its deleted audio. This is AI-generated feedback on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Backend bug fix, fixes #5084: speaker profile embedding wasn't cleared when its teaching sample was deleted. Root cause stated, linked bug, scoped diff (124 lines), unit tests added, CI green (all backend shards pass), confirmed not already fixed on main. Confidence 5/5.
Summary
Fixes #5084
Test plan
PYTHONPATH=. python3 -cthe helper cases inbackend/tests/unit/test_speech_profile_deletion.py(pytest is not installed locally)Made with Cursor
Failure-Class: none