Skip to content

fix(backend): guard all conversation audio deletes against legal holds (SCA-4363) - #26316

Merged
Git-on-my-level merged 2 commits into
mainfrom
agent/m1-studio-codex-sol/c11e883d82a6
Nov 27, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
agent/m1-studio-codex-sol/c11e883d82a6

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What changed and why

SCA-4363 holds one audio_conversation_deletion gate 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-heavy with 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 preflight passed 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_delete attempts 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

View guided diff Turn on auto-fix

@Git-on-my-level
Git-on-my-level merged commit 850cc44 into main Nov 27, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m1-studio-codex-sol/c11e883d82a6 branch November 27, 2026 10:54
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]>
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