Repository navigation
fix(backend): guard all conversation audio deletes against legal holds (SCA-4363) - #26316
Merged
Merged
Conversation
Git-on-my-level
added a commit
that referenced
this pull request
Nov 29, 2026
Brings the reland onto current main, which now carries the #26219 revert and #26316 (SCA-4363 audio legal-hold gate). Conflict resolutions: - storage: delete_privacy_conversation_audio holds the account's audio_conversation_deletion gate across every step (main's SCA-4363 contract, also relied on by the v3 purge); the steps moved to _delete_conversation_audio_steps. The gate is re-entrant, so the durable obligation (erase_conversation_audio) and the kill-switch sweep (delete_conversation_audio_under_gate) still hold one gate. - routers/conversations: the kill-switch after-response sweep keeps main's LegalHoldActive -> defer_audio_erasure durable follow-up; other gate refusals are retained and reported as before. _delete_conversation_under_gate takes both audio_source_ids and expected_exists. - conversation_batch_purge_jobs.finish_run: keeps the audio obligation's detail, arm_revision, retry_after and count_attempt handling together with main's erased_audio_source_ids donor check and post-window _schedule. - Tests: main's shared fake now seeds a live c1 row and applies DELETE_FIELD; the audio fixtures delete the row as the route would. Main's hold-gate route tests run with the obligation switched off (the path they cover); donor prefixes are now erased with the recording. Episodes driver entries stay deleted with the engine; flag registry regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
SCA-4363 holds one
audio_conversation_deletiongate across canonical pack erasure and every conversation audio prefix delete. Both the post-response cleanup and the accepted-delete worker use the shared helper, including when the canonical bucket is disabled. This applies the gate pattern from the v3 purge fix.If a hold arrives between the request and audio gates, post-response cleanup records a durable erasure job and marks the tombstone for hold-release follow-up. The worker preserves merge donor IDs and retries after release. A worker that claimed the job before the donor IDs were recorded leaves it queued for another pass.
Full review requested for the custody and privacy change. No rollout flag is required. Roll back by reverting the PR.
Product invariants affected
none
How it was verified
202 tests passed on M1 in six focused backend suites, run in separate pytest processes through
omi-heavywith a 180-second timeout. The suites cover accepted deletes, storage purge, record WAL erasure, v3 transactions, delete gate waits, and the delete wire contract. The regression exercises the actual FastAPI delete route with hermetic storage and Firestore interfaces. Production Backend serving verification is pending release.make preflightpassed with this PR body supplied. The local failure-class history check skipped its 90-day scan because the managed checkout is shallow.Tests
test_delete_holds_one_audio_gate_through_every_blob_deleteattempts hold placement just before the first prefix delete. It checks every blob delete uses the same running gate token and covers both route cleanup and accepted erasure with canonical storage on and off. The accepted-delete cases reproduced the missing protection on the original code.The follow-up passed 257 focused backend tests on an Apple M1 Max through
omi-heavy. The deterministic test reaches the FastAPI delete route, places the hold after the request gate, verifies that no audio is deleted while held, and exercises the release scan and erasure retry. A second test verifies that completion preserves donor IDs added after a worker has claimed the job.Run from
backend/on M1:omi-heavy run --wait 120 --timeout 120 -- .venv/bin/python -m pytest -q tests/unit/test_conversation_delete_accept.py -k 'hold_between_request_and_response_audio_gates or completion_keeps_donors'Line-Count-Exception: backend/routers/conversations.py | 3203 -> 3208 | Handle legal-hold refusal at the post-response cleanup boundary.
UI evidence
UI-Evidence: none -- backend-only legal-hold change
Failure class (fixes)
Failure-Class: none