Skip to content

feat(backend): add account deletion grace period - #23897

Merged
Git-on-my-level merged 41 commits into
mainfrom
lane/deletion-grace
Oct 29, 2026
Merged

Git-on-my-level merged 41 commits into
mainfrom
lane/deletion-grace

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Account deletion starts a restorable window only when a client explicitly opts in with ?grace=true and ACCOUNT_DELETION_GRACE_ENABLED is on with a positive window. Requests without the marker—including released apps that do not have restore UI—keep today’s immediate erasure. erase_now=true, a zero-day window, or the kill switch also selects immediate erasure. Opted-in grace cancels billing and revokes refresh tokens at admission, retains the existing Firebase UID, and fences ordinary account access; the durable reconciler dispatches the legal-hold-gated wipe after the deadline and immediate-action receipt.

The owner status API reports pending_deletion, wipe_at, the pre-delete grace_period_days policy, and metadata-only held-recording and processing-backlog counts. Restore preserves the existing UID and leaves billing cancelled.

Luna FIX-FIRST review resolutions

  1. A shared, fail-closed deletion predicate now gates per-user scheduled work and worker action boundaries, including X sync, integrations, agents, notifications, daily recaps, Dream, proactive work, sync and batch processing, cap-hold redrive, and related recovery jobs. Capture and processing paths use the same status-aware fence.
  2. Public conversation, chat, daily-summary, and public-app content is unavailable while its owner is pending deletion; shared-content routes return 404.
  3. Stripe webhook and checkout paths cannot restore paid access for a pending or deleted owner. The irreversible wipe rechecks billing cancellation and verifies the terminal Stripe state before completion.
  4. Final and immediate erasure remove creator-owned public apps, their nested data, and related app caches, matching the existing erase path.
  5. Conversation-index purge failures now fail the wipe and remain retryable; completion is recorded only after the Typesense purge succeeds.
  6. Restore clears the processing fence across capture, continuation, merge, keyframe, retention, and finalization paths. Regression tests cover restored writes and worker admission.
  7. A pending-deletion owner can call erase_now; the route allowlist matches status and restore access.

Product invariants affected

  • INV-MEM-1
  • INV-MEM-3
  • INV-MEM-4

Line-count exceptions

Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 3040 -> 3049 | Add restored-status checks to finalization worker admission and result publication.
Line-Count-Exception: backend/database/conversations.py | 4589 -> 4592 | Apply the shared deletion status decision at the final-pass promotion transaction.
Line-Count-Exception: backend/routers/chat.py | 1803 -> 1812 | Return 404 for public chat shares owned by a pending-deletion account.
Line-Count-Exception: backend/routers/conversations.py | 2492 -> 2501 | Return 404 for public conversation shares owned by a pending-deletion account.
Line-Count-Exception: backend/routers/payment.py | 1934 -> 1967 | Fence late entitlement webhooks and cancel subscriptions created during deletion.
Line-Count-Exception: backend/routers/sync.py | 4124 -> 4134 | Fence sync finalization and processing entrypoints during deletion.
Line-Count-Exception: backend/utils/apps.py | 1731 -> 1765 | Suppress public catalog results for apps whose creator is pending deletion.

How it was verified

  • On the original backend head, seven focused backend unit files passed through backend/test.sh under nice (1,014 passed; 1 deselected), covering account deletion, public shares, worker fences, Typesense/app erasure, and recap rollback.
  • Follow-up: the requested nice -n 10 env BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-account-deletion-tests.txt bash test.sh selection passed 461 tests across four files, covering missing opt-in immediate erasure, opted-in grace, the global kill switch, restore gating, and status policy.
  • Account-deletion Cloud Tasks E2E passed (5/5). The Sync Cloud Tasks stack gauntlet passed locally through the Firestore emulator after moving the lease-fencing gate to worker-pipeline entry; it is independent of transcript content, bounded, and reports sanitized worker diagnostics on timeout. GitHub CI for exact head 9c5bc288f307f69b9f2f4abf4bcc2beedc8b05a8 is green: all 67 checks completed with zero pending or failures. The branch currently conflicts with origin/main (b8ed4da0) in backend/testing/sync_cloud_tasks_stack/app.py and backend/testing/sync_cloud_tasks_stack/run.py; these base-branch changes are not included in this PR head.
  • The follow-up make preflight passed all 62 selected checks, including Firestore guards, backend typecheck, web tests, generated Swift DTO validation, Swift formatting, and SwiftLint.
  • The follow-up regenerated the app-client OpenAPI and Swift/TypeScript types; directional compatibility passed against origin/main. git diff --check passed.
  • Tests use local fakes; no production user data or production services were accessed.

Tests

Regression tests cover worker admission and notifications, public share-link access, late Stripe events and cancellation verification, creator-app erasure, Typesense retry behavior, restore on capture and processing paths, and erase_now authorization for pending owners.

UI evidence

UI-Evidence: none -- this PR has no app UI changes.

Failure class (fixes)

Failure-Class: new

Failure-class transition narrative

Violated contract: a user who requests deletion to take a break must be able to restore the same account and retain held or unprocessed recordings until the grace deadline, while pending deletion must stop further per-user work and public access. The admission marker, status-aware access policy, worker fences, provider cancellation checks, and retryable wipe now enforce that contract across request, background, public-share, and restore paths.

Canonical guard: account_deletion_blocks_user_work is shared by per-user workers; capture and processing paths treat pending markers as fences while allowing a restored status; public share routes check the owner; Stripe cancellation and Typesense purge must be verified before wipe completion. Regression coverage lives in the account-deletion, worker, public-share, billing, and restore test selections above.

Rollout and owner sign-off

Keep ACCOUNT_DELETION_GRACE_ENABLED=true; only clients that send ?grace=true receive the configured 14-day restorable window. Requests without opt-in remain immediate. Monitor deletion reconciliation and wipe completion/failure events; setting the kill switch to false restores immediate erasure for opted-in requests too. The new mobile client opt-in is in PR #23873. Product and privacy owners must sign off on the privacy-policy timing and account-deletion confirmation copy before the user-facing copy rollout.

🤖 Generated with Claude Code

@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 28, 2026, 10:59 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

Git-on-my-level and others added 11 commits October 28, 2026 23:46
Gate per-user background, public-share, Stripe, and capture paths on deletion
state; make wipe completion verify billing, app, and search-index cleanup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve legacy output while the shared media policy records shadow
admissions, then verify serving mode filters the matching rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the shared user id guard aligned with its string contract and remove
an unused local from the fenced day-3 worker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 29, 2026 01:24
@Git-on-my-level
Git-on-my-level merged commit cb39686 into main Oct 29, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/deletion-grace branch October 29, 2026 01:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T01:27:32.529332Z e4b1784 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Git-on-my-level added a commit that referenced this pull request Oct 29, 2026
#23873)

## What changed and why

Builds the approved delete-account safety screens. Server-held
processing audio is kept during a server-reported grace window; only
phone-only uploads warn of immediate loss. Without an authoritative
window the app uses immediate-deletion copy. Taking a break or technical
issues offers Pause Omi through the existing capture toggle, retaining
sign-in and billing.

Pending-deletion sign-in shows Restore my account and Finish deleting.
Product initialization and deep links wait for status. Restore needs a
successful server response. Tapping Erase my account now opens the final
warning confirmation before the app sends `erase_now: true`.

Depends on backend PR #23897 for the grace policy and recovery
endpoints. The backend now reports `grace_period_days` before deletion
and accepts `?grace=true` as an explicit opt-in; this new client adds
that query to the initial DELETE. Released clients that omit it keep
immediate erasure. Finish deleting continues to send `erase_now: true`
through the authenticated deletion-only owner route. Older 404/405
status endpoints retain normal sign-in and immediate-delete behavior;
fresh sign-ins and server failures offer Retry. A transport outage
preserves an existing onboarded startup UID only; previously confirmed
pending-deletion owners remain blocked, and this fallback never grants
grace copy. Restore/erase errors retain the decision screen. No
production access.

## Product invariants affected

INV-UI-1, INV-UI-3, INV-PERF-1. Uses OmiType, OmiColors, OmiButton and
existing icons.

## How it was verified

- Focused `deletion_safety_test.dart`: all 11 widget tests passed,
including 9-day, 1-day, under-one-day, unknown and expired `wipe_at`
cases, and the modal-only erase warning.
- Render harness: all 17 tests passed; the 20 light/dark PNGs at
1179×2796 were generated and visually inspected. Window/count fixtures
are synthetic; no real deletion is invoked.
- Focused Dart analysis found no issues. `python3 scripts/l10n.py check`
passed for 49 locales and 4,325 keys.
- `omi-l10n-fill stub` then `fill` translated the three changed/new
countdown and confirmation strings across 48 target locales; ICU
validation passed (5 batches, 6 calls, no retries, review approved three
fixes).
- `make preflight` passed all 45 checks; `actionlint` passed. The
workflow budget guard records the 35-minute Dart job ceiling after two
runs completed all 7,920 tests but hit the former 30-minute limit during
cleanup; p50 remains 17 minutes.
- Follow-up head `cc42da5eddb6d79ae0198fa0bec0986270fc643a` is green:
`ci-wait` completed with 45 checks, 0 pending, and 0 failures, including
Mobile Release Eligibility and all 7,920 Dart tests. The initial
deletion request sends `?grace=true`; older released clients omit it and
keep immediate erasure. Current origin/main is
`b8ed4da0d44f6ac7a17fb9fe4c91afc2d6532c82`; a read-only merge-tree check
confirms conflicts in generated localization files, after the green run
on this exact head.

No production account, device, API, or GCP tier was accessed. These are
hermetic widget/API tests and rasters; device acceptance remains
separate.

## Tests

`app/test/widgets/deletion_safety_test.dart`: deletion policy and pause
cases, plus remaining-day copy for 9 days, 1 day, under one day, unknown
and expired deadlines, and the final erase confirmation.
`app/test/unit/backend/http/deletion_contract_test.dart`:
optional/expired policy, UID-filtered WAL counts, status counts and
restore/erase payload, rejection of erase acknowledgements that remain
pending, and UID-bound offline fallback.

## UI evidence

![Grace warning,
light](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/002-mobile-ios-a-held-light.png)
![Grace warning,
dark](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/001-mobile-ios-a-held-dark.png)
![Restore with 9 days left,
light](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/020-mobile-ios-restore-light.png)
![Restore with 9 days left,
dark](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/019-mobile-ios-restore-dark.png)
![Final erase confirmation,
light](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/016-mobile-ios-finish-deleting-light.png)
![Final erase confirmation,
dark](https://raw.githubusercontent.com/BasedHardware/omi/8846c13f2906ca6415df4708033b6ece0f26b8e1/.agent-artifacts/ui-evidence/deletion-safety/015-mobile-ios-finish-deleting-dark.png)

20 tracked iOS widget rasters cover reason, feedback, pause, grace with
mixed/server-only/phone-only/empty counts, immediate deletion, restore,
and finish confirmation, each in light and dark. See the sibling
evidence manifest and harness.

## Failure class

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Git-on-my-level added a commit that referenced this pull request Oct 29, 2026
…23936)

## Summary

- Generate Dart wire models for the account deletion status, action, and
restore responses already defined in OpenAPI.
- Decode account deletion API responses through those generated types
while preserving legacy aliases and conservative normalization.
- Add coverage for generated-backed responses and preserve the existing
deletion behavior.

This is separate from #23935: it fixes an existing main-branch backend
unit failure after the account deletion API changes in #23873 and
#23897.
`test_app_client_schema_inventory.py::test_inventory_separates_generated_backed_adapters_from_raw_manual_dtos`
reported one remaining manual Dart response adapter,
`account_deletion.dart`.

## Verification

- `backend/test.sh` with
`BACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_app_client_schema_inventory.py`
under `nice`: 14 passed.
- `cd app && flutter test
test/unit/backend/http/deletion_contract_test.dart`: 6 passed.
- `cd backend && .venv/bin/python scripts/generate_dart_models.py
--group users --check`: passed.
- `cd app && dart run build_runner build --delete-conflicting-outputs`:
completed; no tracked generated-file changes.

## Metadata

Product invariants affected: none

Failure-Class: none

UI-Evidence: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/23936?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/23936?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23936&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. -->
Git-on-my-level added a commit that referenced this pull request Oct 29, 2026
The Sync Cloud Tasks concurrency gauntlet must hold paid STT inside the
upload worker lease. PR #23919 (merge `0dee519a`) deferred full note
processing until merge settlement, so waiting for that processor could
never enter the gate. Current main already moved the call to STT; this
finishes that fixture contract and makes the hold behavior executable.

- Rename the gate, evidence and diagnostics to STT throughout the
fixture and its callers.
- Pin `SYNC_PROCESSING_HOLD_ENABLED=true` for normal scenarios. The held
concurrency scenario verifies one STT call, Redis fencing before
pipeline work and during STT, completed upload/ledger readback, pending
conversation hold, and a durable deferred enrichment obligation with
zero full-processor calls.
- Run the same concurrency scenario with the hold disabled and require
exactly one eagerly persisted full-processing result. Terminal duplicate
delivery must repeat neither STT nor full processing in either mode.

Product behavior, worker budgets and CI timeouts are unchanged.

Failure-Class: none

This is test-fixture phase drift after a deliberate product scheduling
change; no existing semantic failure class describes it. Why isn't this
a shared primitive instead? Both hold modes use the same STT gate and
`_assert_full_processing_policy` verifier in the existing blocking
emulator gauntlet, rather than adding a separate guard. The regression
instance is merged PR #23919, with the supplied bisect showing its
parent passes and merge fails waiting for the processor gate.

## Product invariants affected

none (test harness and fixture only)

## Validation

- Related units: 154 passed across
`test_sync_cloud_tasks_stack_ci_wiring.py`,
`test_sync_stack_postgres_hook.py`, `test_sync_processing_hold.py` and
`test_sync_reprocess_coalesce.py` (separate pytest processes).
- Full gauntlet: passed via `nice -n 10
backend/testing/sync_cloud_tasks_stack/run.sh --state-dir
/Volumes/Ephemeral/scratch/gauntlet-holdfix-20261029/full`, under
`omi-heavy` (both hold modes, all legacy Sync and batch scenarios, plus
5 passing Firestore shard-spread integration tests).
- Preflight: `make preflight` passed all 33 selected checks;
`scripts/pr-preflight --pr-body-file` also passed all 33 checks on
commit `d3981e1de54`.
- GCP tier: none; all services are local emulators/fakes.

🤖 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/23935?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/23935?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23935&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. -->



## Main CI follow-up

The backend unit failure is independent of the Sync gauntlet: main
currently fails
`tests/unit/test_app_client_schema_inventory.py::test_inventory_separates_generated_backed_adapters_from_raw_manual_dtos`
because account deletion is the remaining manual Dart response adapter
after #23873/#23897. The fix is split into [PR
#23936](#23936). This PR
excludes the app change; its unit checks need a rerun after the
main-branch fix lands.
Git-on-my-level added a commit that referenced this pull request Oct 29, 2026
…e/firestore-reads-flagoff-people-1029: the shard-5/6 red is the main-side inventory break between #23873/#23897 and #23936 per its own commit message; fixes the failing test on our base
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