Repository navigation
Closed
Description
Context
PR #8393 extracts account deletion/export logic into user data services. Its review comments were resolved locally, but one review thread surfaces a broader architecture smell: account deletion cleanup is treated like best-effort post-processing even though users are told deletion has started and the workflow removes data across Firebase, Firestore, vector stores, storage, and Twilio.
Evidence
- In PR [codex] Extract user data services #8393, cubic identified an inline P1 on
backend/services/users/account_deletion.pythat the original implementation dispatched cleanup withthreading.Thread(..., daemon=True).start(). The comment called out that shutdown/redeploy could terminate the wipe mid-flight, leaving user data partially deleted after reporting deletion started: [codex] Extract user data services #8393 (comment) - The PR-local fix replaced the daemon thread with
submit_with_context(postprocess_executor, background_wipe_user_data, uid)inbackend/services/users/account_deletion.py. backend/utils/executors.pydocumentspostprocess_executoras best-effort post-processing, not durable job execution, and its shutdown path usesexecutor.shutdown(wait=False, cancel_futures=True). That is a meaningful improvement over a daemon thread, but it still does not give account deletion durable enqueue, retry, status tracking, or recovery across deploy/process shutdown.- The same PR also had review findings around GDPR/CCPA export completeness (
backend/services/users/data_export.py10,000-record caps and pagination termination). Those were fixed in the PR, but together they show that account export/deletion paths need explicit compliance-grade guarantees rather than incidental background behavior.
Proposed follow-up scope
- Move account deletion cleanup from the best-effort
postprocess_executorpath to a durable mechanism, e.g. Cloud Tasks / a persisted job record / another backend queue already used by this repo. - Make the deletion operation idempotent and safe to retry across all external stores: Twilio caller IDs, vector DB records, recordings/storage, and Firestore user data.
- Persist deletion status and last error so support/ops can identify and retry partial wipes.
- Return success to the API caller only after the durable job is created, or make the endpoint block through the full wipe if product requirements prefer synchronous deletion.
- Add tests that simulate worker/process shutdown or enqueue failure and assert that account deletion is not silently acknowledged without durable follow-through.
Non-goals
- Do not block PR [codex] Extract user data services #8393 on this broader architecture change if its local review comments remain resolved.
Oracle follow-up refinement - 2026-06-27
The PR #8393 oracle review agreed this belongs outside the refactor PR, but recommended that the durable deletion saga explicitly cover the whole account-lifecycle workflow, not only post-auth cleanup. Include these steps in the long-term design:
- Persist deletion feedback and requested reason/details as part of the deletion job.
- Cancel Stripe subscriptions with idempotent retry/status tracking, or record a retryable billing-cancellation failure.
- Revoke/delete Firebase Auth, treating already-missing users as completed while surfacing unexpected auth failures.
- Then run Twilio, vector DB, recording/storage, and Firestore cleanup as idempotent retryable steps.
- Return API success only after the deletion request is durably recorded and the worker job is durably enqueued.
Activity
Make account deletion cleanup durable (BasedHardware#9117)
fix: fail close account-deletion Cloud Tasks dispatch (#9768)