Repository navigation
SCA-91: make account deletion durable before auth removal - #10444
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 558e826240
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Independent exact-head review of PR #10444 ( 1. P1: repeat request moves a live wipe backwards and dispatches a duplicate task
I proved this on the exact PR head with a production-shaped route test:
Fix the shared transition atomically/job-id-conditionally. A repeated API request must join the existing authority without moving 2. P1: enqueue failure returns 500 but remains authorized for later destructive deletionThe new queue-NotFound E2E explicitly expects HTTP 500, leaves marker Choose one coherent contract and test it end to end:
Do not keep 3. CI is red on PR-specific pyright
Verified positives
Do not merge or deploy. Preserve the same focused PR and failure class |
|
Both trusted review threads were verified as already addressed by commit
Verified locally: 34 The two failing CI checks ( |
kodjima33
left a comment
There was a problem hiding this comment.
SCA-91 make account deletion durable before auth removal — approve only (DIRTY + auth-sensitive)
Reconstructed clean from PR diff onto origin/main (original branch had unrelated history with no merge base).
deaae3a to
b9ea539
Compare
|
Rebased onto latest All checks green: backend unit suite, OpenAPI contract, static contracts. |
…ks (#11029) ## Summary - Make the durable `account_deletions/{uid}` marker a single fail-closed admission policy across Firebase, developer/MCP keys, OAuth issuance, HTTP/WebSocket entry points, Agent proxy sessions, and Agent VM provisioning. Completed and unknown markers remain fenced so an old token cannot revive a deleted UID. - Make deletion admission atomic at `pending`, revoke UID-bearing API/OAuth credentials, delete the account's GCE Agent VM before its Firestore pointer disappears, and transactionally fence late proxy/VM writes so in-flight work cannot recreate owner data. - Make accepted macOS cleanup durable across restart, drain owner-bound VM/sync work before deleting storage, remove the legacy anonymous fallback, upload a consistent SQLite snapshot with cancellable compression and bounded retries, and preserve typed startup errors in Flutter. Repeated delete requests during `pending`/`running` intentionally receive typed `403 account_deletion_in_progress` responses without marker rollback or requeue. The deletion fence is preserved. Canonical project: [BasedHardware Project #15](https://github.com/orgs/BasedHardware/projects/15) ## Sanitized incident evidence - A delete confirmation preceded a later same-provider sign-in/onboarding sequence by nine days. - The deleted UID's user document and GCE instance were gone, while its durable deletion marker completed after retried queue acceleration failures. - No verified event proves old server memory reads after deletion. This PR treats legacy local-database migration, still-valid old credentials, and late owner-scoped work as identity-isolation risks; typed readiness failures remain timeout-class evidence rather than proof of server data disclosure. Related lineage: #10444, #7696, #9632, #10597, #9821, #6891, #6892, #10600, and #10694. ## Failure class Failure-Class: none This is an audit-driven hardening sweep across durable deletion admission, credential revocation, local owner-data disposal, and Agent VM/proxy lifecycle safety. The reusable prevention surfaces are the shared fail-closed policy, transactional admission/CAS writers, the durable local cleanup journal, the effective-owner generation fence, and behavioral regression tests. ## Product invariants affected - INV-AUTH-1 — preserves the exclusive effective-owner transition, clears accepted-deletion storage before credential/session publication, blocks every credential family after durable admission, and rejects late owner-bound Agent VM continuations. - INV-CHAT-1 — drains Agent VM/sync work at the existing owner transition, transactionally fences late proxy message/session writes, and preserves typed startup failures without changing canonical transcript ownership. ## Changed paths - `.github/scripts/product_file_line_count_ratchet_baseline/backend-database.json` - `.github/scripts/product_file_line_count_ratchet_baseline/backend-routers.json` - `.github/scripts/product_file_line_count_ratchet_baseline/desktop-swift-root.json` - `app/lib/services/agent_chat_service.dart` - `app/test/services/agent_chat_service_test.dart` - `backend/agent-proxy/Dockerfile` - `backend/agent-proxy/main.py` - `backend/database/account_deletion_projection_fence.py` - `backend/database/mcp_oauth.py` - `backend/database/users.py` - `backend/dependencies.py` - `backend/routers/apps.py` - `backend/routers/desktop_agent_vm.py` - `backend/routers/mcp_sse.py` - `backend/routers/oauth.py` - `backend/routers/transcribe.py` - `backend/services/users/account_deletion.py` - `backend/testing/e2e/test_account_deletion_cloud_tasks.py` - `backend/tests/services/users/test_account_deletion.py` - `backend/tests/unit/test_account_deletion_auth_fence.py` - `backend/tests/unit/test_agent_proxy_async_boundaries.py` - `backend/tests/unit/test_agent_proxy_startup_client_gone.py` - `backend/tests/unit/test_byok_security.py` - `backend/tests/unit/test_dependency_async_boundaries.py` - `backend/tests/unit/test_desktop_agent_vm.py` - `backend/tests/unit/test_mcp_api_key_auth_context.py` - `backend/tests/unit/test_mcp_oauth.py` - `backend/tests/unit/test_oauth_token_async_boundaries.py` - `backend/utils/account_deletion_access.py` - `backend/utils/other/endpoints.py` - `desktop/macos/Desktop/Sources/AgentSyncService.swift` - `desktop/macos/Desktop/Sources/AgentVMService.swift` - `desktop/macos/Desktop/Sources/AuthService.swift` - `desktop/macos/Desktop/Sources/Chat/RuntimeOwnerIdentity.swift` - `desktop/macos/Desktop/Sources/DefaultsKey.swift` - `desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift` - `desktop/macos/Desktop/Sources/MainWindow/Pages/Settings/Components/SettingsContentView+SettingsUpdates.swift` - `desktop/macos/Desktop/Sources/Rewind/Core/RewindDatabase+AccountDeletion.swift` - `desktop/macos/Desktop/Tests/AgentSyncBatchQueryTests.swift` - `desktop/macos/Desktop/Tests/AgentVMLifecycleFenceTests.swift` - `desktop/macos/Desktop/Tests/AuthSessionCoordinatorTests.swift` - `desktop/macos/Desktop/Tests/OnboardingPersistenceClearingTests.swift` - `desktop/macos/Desktop/Tests/RewindDatabaseLifecycleTests.swift` - `desktop/macos/changelog/unreleased/20260802-account-deletion-local-data.json` - `desktop/macos/e2e/flows/logout.yaml` ## Verification - Focused backend deletion/auth/proxy/VM suite: `194 passed`. - Hermetic Cloud Tasks deletion suite: `5 passed`; repeated pending/running requests are asserted as typed `403` without requeue. - Focused macOS deletion, owner-fence, snapshot, and sync suite: `32 tests`, `0 failures`. - Focused Flutter Agent Chat suite: `2 passed`. - Follow-up MCP OAuth consent suite: `37 passed`. - Follow-up macOS cleanup/bridge compile suite: `17 tests`, `0 failures`. - Python runtime sources compile cleanly; pinned Python/Dart/Swift formatters and `git diff --check` are clean. - Required CI-lane PR-body preflight: `34 checks passed` in `108.01s`. Backend Hermetic Merge Gate: in scope because backend runtime and hermetic contract code changed. ## Limitations - No production Firebase/Auth, Firestore, Cloud Tasks, GCE, deployment, release, or customer-data mutation was performed. - Same-provider recreation is covered hermetically at the UID/auth boundary; no live Google sign-in was attempted. - Agent readiness and teardown are covered through backend state-machine, proxy protocol, owner-generation, snapshot/upload, credential cleanup, and stale-pointer tests; no live GCE VM was provisioned. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/11029?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…are#10444) ## Summary Account deletion now has one durable, fenced authority. The request persists intent before queue acceleration and makes no irreversible billing or Firebase Auth mutation. The claimed worker owns billing cancellation, Auth deletion, external purges, Firestore deletion, and completion. Only the matching `wipe_job_id` can transactionally promote `deleting_auth` to `pending` and enqueue. Repeat requests preserve `pending`, `retrying`, `running`, `failed`, and `completed` state and do not create another task. A retry can recover the narrow `deleting_auth` handoff; concurrent promotions are fenced so only one dispatches. After durable intent is committed, queue failure returns the existing compatible 200 acceptance response, marks the intent `failed`, and relies on reconciliation for eventual completion. It no longer returns 500 while retaining actionable deletion authority. ## Failure class (fixes) Failure-Class: FC-split-mutation-authority The request handler previously split destructive authority across itself and the queue worker. This change converges destructive transitions behind the claimed worker and persisted job-scoped marker. ## Authority ordering Request → create/join durable intent → atomically promote matching job to `pending` → queue acceleration. Claimed worker → `running` → billing → Firebase Auth → external purge → Firestore wipe → `completed`. ## Product invariants affected These IDs are named solely for the older, unrelated desktop paths in this PR’s full merge-base diff; this deletion follow-up does not alter them. - INV-AGENT-* - INV-AUTH-1 - INV-CHAT-1 - INV-VOICE-1 ## Verification - RED: the production-shaped Cloud Tasks route test reproduced `running → pending` plus a duplicate task; queue NotFound returned 500 with an actionable marker. - GREEN: `backend/.venv/bin/python -m pytest backend/tests/services/users/test_account_deletion.py backend/tests/routers/test_users.py backend/tests/unit/test_delete_account_stripe_cancel.py backend/testing/e2e/test_account_deletion_cloud_tasks.py -q` — 59 passed. - GREEN: `backend/.venv/bin/pyright backend/services/users/account_deletion.py` — 0 errors, 0 warnings. - GREEN: `OMI_PR_BODY_FILE=pr-body.md make preflight` — local selected checks passed (advisory size warnings only). - CI at `deaae3a4889751faa65d65f135303aaa14f14c73`: deletion-specific and metadata/stack checks passed, but the full PR remains red on unrelated merge-base coverage: `tests/unit/test_action_item_date_validation.py` and `tests/unit/test_lock_bypass_fixes.py` have pre-existing `langchain_core.messages` test-isolation/import failures; `Desktop Swift Build & Tests` is also red in the older desktop diff. This follow-up intentionally does not broaden FC-split-mutation-authority scope to modify those subsystems. ## Rollback Revert the two account-deletion commits. No schema, queue, IAM, deployment, or production-data change is included. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10444?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Summary
Account deletion now has one durable, fenced authority. The request persists intent before queue acceleration and makes no irreversible billing or Firebase Auth mutation. The claimed worker owns billing cancellation, Auth deletion, external purges, Firestore deletion, and completion.
Only the matching
wipe_job_idcan transactionally promotedeleting_authtopendingand enqueue. Repeat requests preservepending,retrying,running,failed, andcompletedstate and do not create another task. A retry can recover the narrowdeleting_authhandoff; concurrent promotions are fenced so only one dispatches.After durable intent is committed, queue failure returns the existing compatible 200 acceptance response, marks the intent
failed, and relies on reconciliation for eventual completion. It no longer returns 500 while retaining actionable deletion authority.Failure class (fixes)
Failure-Class: FC-split-mutation-authority
The request handler previously split destructive authority across itself and the queue worker. This change converges destructive transitions behind the claimed worker and persisted job-scoped marker.
Authority ordering
Request → create/join durable intent → atomically promote matching job to
pending→ queue acceleration. Claimed worker →running→ billing → Firebase Auth → external purge → Firestore wipe →completed.Product invariants affected
These IDs are named solely for the older, unrelated desktop paths in this PR’s full merge-base diff; this deletion follow-up does not alter them.
Verification
running → pendingplus a duplicate task; queue NotFound returned 500 with an actionable marker.backend/.venv/bin/python -m pytest backend/tests/services/users/test_account_deletion.py backend/tests/routers/test_users.py backend/tests/unit/test_delete_account_stripe_cancel.py backend/testing/e2e/test_account_deletion_cloud_tasks.py -q— 59 passed.backend/.venv/bin/pyright backend/services/users/account_deletion.py— 0 errors, 0 warnings.OMI_PR_BODY_FILE=pr-body.md make preflight— local selected checks passed (advisory size warnings only).deaae3a4889751faa65d65f135303aaa14f14c73: deletion-specific and metadata/stack checks passed, but the full PR remains red on unrelated merge-base coverage:tests/unit/test_action_item_date_validation.pyandtests/unit/test_lock_bypass_fixes.pyhave pre-existinglangchain_core.messagestest-isolation/import failures;Desktop Swift Build & Testsis also red in the older desktop diff. This follow-up intentionally does not broaden FC-split-mutation-authority scope to modify those subsystems.Rollback
Revert the two account-deletion commits. No schema, queue, IAM, deployment, or production-data change is included.