Repository navigation
fix(backend): account-deletion fence reads the data plane the marker is written on - #12667
Conversation
…is written on
The Beta serving plane's compute Firestore is empty for account_deletions/{uid};
the marker lives on the data plane. A compute-plane fallback was a clean miss
that reopened a deleting account. Pin readers and writers to one accessor.
Co-Authored-By: cursor grok-4.6 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Passing None into the deletion fence made Typesense upserts fail open and broke isolation stubs that load users/conversations after the plane pin. Co-Authored-By: cursor grok-4.6 <[email protected]> Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
5 issues found across 28 files
Confidence score: 2/5
backend/services/users/account_deletion.pycan purge canonical state on the data plane while deletingusers/{uid}through the compute-plane database when projects differ, risking incomplete or inconsistent account deletion; ensure all deletion reads and writes use the data-plane client and strengthen the regression test inbackend/tests/services/users/test_account_deletion.pyto assert that exact client.backend/database/account_cutover.pyraisesRuntimeErrorwhen the data-plane client cannot be resolved before callers can map the condition to 503, exposing an unexpected server error instead of the intended unavailable response; convert this failure to the typed unavailable state at the boundary.backend/database/legal_holds.pyperforms data-plane resolution outside its fail-closedtryblock, so account-deletion admission can reach the generic HTTP 500 handler rather than returning a retryable 503; move resolution into the guarded path or normalize the exception.backend/database/memories.pyresolves the write fence against the data plane while the wrapped memory write still uses another client, which can allow the fence and write to observe different stores; align the memory write client with the data-plane fence or explicitly verify the intended client pairing.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/services/users/test_account_deletion.py">
<violation number="1" location="backend/tests/services/users/test_account_deletion.py:1522">
P3: The regression guard only asserts that a `db_client` kwarg is present, not that it is the data-plane client. Because the PR's fix is specifically about pinning deletion reads/writes to `get_data_plane_firestore_client()`, this assertion would still pass if the call regressed to the compute-plane `get_firestore_client()`. Verify the kwarg value equals `database_client.get_data_plane_firestore_client()` (mocking that accessor in the test) so the test actually guards the seam it is meant to protect.</violation>
</file>
<file name="backend/services/users/account_deletion.py">
<violation number="1" location="backend/services/users/account_deletion.py:216">
P1: When the data-plane and compute-plane projects differ, this worker now purges canonical state on the data plane but still deletes `users/{uid}` through `users_db.delete_user_data`, which uses the compute-plane `db`; the account can therefore retain user documents or have only part of its data wiped. Resolve one pinned client before the worker starts and thread it through the user-data deletion and every Firestore inventory read in this flow.</violation>
</file>
<file name="backend/database/legal_holds.py">
<violation number="1" location="backend/database/legal_holds.py:132">
P2: When the data-plane client cannot be resolved, this new call raises before the fail-closed `try` block, so account-deletion admission reaches the route's generic HTTP 500 handler instead of returning the retryable 503 promised for this fence. Resolve the client inside the authority-error wrapper and map that typed failure to 503 at the deletion endpoint.</violation>
</file>
<file name="backend/database/account_cutover.py">
<violation number="1" location="backend/database/account_cutover.py:25">
P2: When the data-plane client cannot be resolved, this new default raises `RuntimeError` before the cutover callers can map the state to 503. Handle data-plane resolution failures as the same typed unavailable state at the database/HTTP boundary so `/v1/account/cutover/control` and the cutover auth fence return a retryable 503 rather than an unhandled 500.</violation>
</file>
<file name="backend/database/memories.py">
<violation number="1" location="backend/database/memories.py:45">
P2: In _account_write_gated/_destination_account_write_gated, the fence now resolves to the data plane (via account_deletion_firestore_client -> get_data_plane_firestore_client) while the wrapped memory write still resolves its own client via _get_db -> get_firestore_client (compute plane) when no firestore_client is injected. The deletion-marker fence and the write it guards now run on different planes by default, which is the same read/write plane seam the PR is meant to close. Resolve one shared client in the decorator and pass it to both the fence and the wrapped write so they stay on the same plane.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| try: | ||
| canonical_result = purge_canonical_derived_user_data(uid) | ||
| canonical_result = purge_canonical_derived_user_data( |
There was a problem hiding this comment.
P1: When the data-plane and compute-plane projects differ, this worker now purges canonical state on the data plane but still deletes users/{uid} through users_db.delete_user_data, which uses the compute-plane db; the account can therefore retain user documents or have only part of its data wiped. Resolve one pinned client before the worker starts and thread it through the user-data deletion and every Firestore inventory read in this flow.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/services/users/account_deletion.py, line 216:
<comment>When the data-plane and compute-plane projects differ, this worker now purges canonical state on the data plane but still deletes `users/{uid}` through `users_db.delete_user_data`, which uses the compute-plane `db`; the account can therefore retain user documents or have only part of its data wiped. Resolve one pinned client before the worker starts and thread it through the user-data deletion and every Firestore inventory read in this flow.</comment>
<file context>
@@ -213,7 +213,9 @@ def require_vector_index(operation: str):
try:
- canonical_result = purge_canonical_derived_user_data(uid)
+ canonical_result = purge_canonical_derived_user_data(
+ uid, db_client=database_client.get_data_plane_firestore_client()
+ )
</file context>
| if not uid: | ||
| raise LegalHoldAuthorityUnavailable("account deletion legal-hold lookup requires a uid") | ||
| client = firestore_client or get_firestore_client() | ||
| client = account_deletion_firestore_client(firestore_client=firestore_client) |
There was a problem hiding this comment.
P2: When the data-plane client cannot be resolved, this new call raises before the fail-closed try block, so account-deletion admission reaches the route's generic HTTP 500 handler instead of returning the retryable 503 promised for this fence. Resolve the client inside the authority-error wrapper and map that typed failure to 503 at the deletion endpoint.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/legal_holds.py, line 132:
<comment>When the data-plane client cannot be resolved, this new call raises before the fail-closed `try` block, so account-deletion admission reaches the route's generic HTTP 500 handler instead of returning the retryable 503 promised for this fence. Resolve the client inside the authority-error wrapper and map that typed failure to 503 at the deletion endpoint.</comment>
<file context>
@@ -129,7 +129,7 @@ def assert_account_deletion_permitted(uid: str, *, firestore_client: Any | None
if not uid:
raise LegalHoldAuthorityUnavailable("account deletion legal-hold lookup requires a uid")
- client = firestore_client or get_firestore_client()
+ client = account_deletion_firestore_client(firestore_client=firestore_client)
try:
snapshot = _document(client, f"{LEGAL_HOLDS_COLLECTION}/{uid}").get()
</file context>
|
|
||
| def _control_ref(uid: str, *, firestore_client: Any = None): | ||
| client = firestore_client if firestore_client is not None else _client.get_firestore_client() | ||
| client = firestore_client if firestore_client is not None else _client.get_data_plane_firestore_client() |
There was a problem hiding this comment.
P2: When the data-plane client cannot be resolved, this new default raises RuntimeError before the cutover callers can map the state to 503. Handle data-plane resolution failures as the same typed unavailable state at the database/HTTP boundary so /v1/account/cutover/control and the cutover auth fence return a retryable 503 rather than an unhandled 500.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/account_cutover.py, line 25:
<comment>When the data-plane client cannot be resolved, this new default raises `RuntimeError` before the cutover callers can map the state to 503. Handle data-plane resolution failures as the same typed unavailable state at the database/HTTP boundary so `/v1/account/cutover/control` and the cutover auth fence return a retryable 503 rather than an unhandled 500.</comment>
<file context>
@@ -22,7 +22,7 @@ def __init__(self, message: str = 'cutover concurrency conflict', *, code: str =
def _control_ref(uid: str, *, firestore_client: Any = None):
- client = firestore_client if firestore_client is not None else _client.get_firestore_client()
+ client = firestore_client if firestore_client is not None else _client.get_data_plane_firestore_client()
return client.collection('users').document(uid).collection(CONTROL_COLLECTION).document(CONTROL_DOCUMENT)
</file context>
| def wrapped(uid: str, *args: Any, **kwargs: Any) -> Any: | ||
| database = _get_db(kwargs.get("firestore_client")) | ||
| with external_write_fence(uid, firestore_client=database): | ||
| with external_write_fence(uid, firestore_client=kwargs.get("firestore_client")): |
There was a problem hiding this comment.
P2: In _account_write_gated/_destination_account_write_gated, the fence now resolves to the data plane (via account_deletion_firestore_client -> get_data_plane_firestore_client) while the wrapped memory write still resolves its own client via _get_db -> get_firestore_client (compute plane) when no firestore_client is injected. The deletion-marker fence and the write it guards now run on different planes by default, which is the same read/write plane seam the PR is meant to close. Resolve one shared client in the decorator and pass it to both the fence and the wrapped write so they stay on the same plane.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/database/memories.py, line 45:
<comment>In _account_write_gated/_destination_account_write_gated, the fence now resolves to the data plane (via account_deletion_firestore_client -> get_data_plane_firestore_client) while the wrapped memory write still resolves its own client via _get_db -> get_firestore_client (compute plane) when no firestore_client is injected. The deletion-marker fence and the write it guards now run on different planes by default, which is the same read/write plane seam the PR is meant to close. Resolve one shared client in the decorator and pass it to both the fence and the wrapped write so they stay on the same plane.</comment>
<file context>
@@ -42,8 +42,7 @@ class FirestoreNotFound(Exception):
def wrapped(uid: str, *args: Any, **kwargs: Any) -> Any:
- database = _get_db(kwargs.get("firestore_client"))
- with external_write_fence(uid, firestore_client=database):
+ with external_write_fence(uid, firestore_client=kwargs.get("firestore_client")):
return function(uid, *args, **kwargs)
</file context>
| account_deletion.purge_canonical_derived_user_data.assert_called_once() | ||
| purge_args, purge_kwargs = account_deletion.purge_canonical_derived_user_data.call_args | ||
| assert purge_args == ('uid1',) | ||
| assert 'db_client' in purge_kwargs |
There was a problem hiding this comment.
P3: The regression guard only asserts that a db_client kwarg is present, not that it is the data-plane client. Because the PR's fix is specifically about pinning deletion reads/writes to get_data_plane_firestore_client(), this assertion would still pass if the call regressed to the compute-plane get_firestore_client(). Verify the kwarg value equals database_client.get_data_plane_firestore_client() (mocking that accessor in the test) so the test actually guards the seam it is meant to protect.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/tests/services/users/test_account_deletion.py, line 1522:
<comment>The regression guard only asserts that a `db_client` kwarg is present, not that it is the data-plane client. Because the PR's fix is specifically about pinning deletion reads/writes to `get_data_plane_firestore_client()`, this assertion would still pass if the call regressed to the compute-plane `get_firestore_client()`. Verify the kwarg value equals `database_client.get_data_plane_firestore_client()` (mocking that accessor in the test) so the test actually guards the seam it is meant to protect.</comment>
<file context>
@@ -1516,7 +1516,10 @@ def test_purge_derived_user_data_continues_after_each_failure(monkeypatch):
+ account_deletion.purge_canonical_derived_user_data.assert_called_once()
+ purge_args, purge_kwargs = account_deletion.purge_canonical_derived_user_data.call_args
+ assert purge_args == ('uid1',)
+ assert 'db_client' in purge_kwargs
assert [failure['operation'] for failure in result['required_failures']] == [
'conversation_vectors',
</file context>
… plane splits (#12674) ## What changed and why Follow-up to merged #12667. The deletion fence itself is on `main`. The adversarial review of that PR found no blocking defect; this change lands the two remaining should-fix guards and stops creating dormant plane splits. Writers and readers of `account_deletions/{uid}` already share `account_deletion_firestore_client()` → `get_data_plane_firestore_client()`. A resolved-client Firestore **read** error (timeout, `ServiceUnavailable`) already propagated to HTTP 503, but swallowing only `snapshot.get()` into `None` left every fence test green. This PR drives `enforce_account_deletion_http_access` through the real `get_user_deletion_wipe_status` with a resolved data-plane client whose `.collection().document().get()` raises, and asserts 503. `grants_cloud_screen_vectors` already called `get_user_valid_subscription(..., firestore_client=get_customer_firestore_client(), provision=False)`. Flipping `provision` back to `True` JIT-writes `plan: basic` onto a missing customer subscription doc, and no test failed on that flip. This PR adds a source pin and a behavioral test: a missing subscription doc with the customer client must not call `user_ref.set` and must resolve to basic. Lookup exceptions still fail open. #12667 also pinned `first_open_obligations.py`, `goals.py`, and the three `get_data_plane_firestore_client()` injections in `knowledge_ledger_tools.py`. Those modules are unreachable from desktop-backend, and their sibling readers/writers of the same collections still default to the compute client. This PR restores their `origin/main` (pre-#12667) behaviour exactly, including the test-stub exports that existed only for those pins, so those three do not land as dormant `FC-plane-seam-adopted-by-reader-not-writer` splits. Every other pin from #12667 stays. ## Product invariants affected none ## How it was verified - `test_auth_fence_fails_closed_when_the_resolved_data_plane_read_raises` drives `enforce_account_deletion_http_access` → the real `get_user_deletion_wipe_status` in `account_deletion_marker.py` with a resolved data-plane client whose `.get()` raises, and asserts HTTP 503. Baseline with the new test: `16 passed`. - Red-proof (review §6 mutation a2: wrap only `snapshot.get()` in `except Exception: return None`): ``` FAILED tests/unit/test_account_deletion_auth_fence.py::test_auth_fence_fails_closed_when_the_resolved_data_plane_read_raises Failed: DID NOT RAISE <class 'fastapi.exceptions.HTTPException'> 1 failed, 15 passed in 0.29s ``` The other 15 fence tests stay green on that swallow. Restoring the uncaught `.get()` returns `16 passed`. - `test_screen_vector_entitlement_does_not_write_when_customer_subscription_doc_is_missing` drives `grants_cloud_screen_vectors` with a customer client whose `users/{uid}` doc is missing; `user_ref.set` is not called and the in-memory plan is `PlanType.basic` (not entitled). `test_screen_vector_entitlement_reads_customer_firestore_without_provisioning` source-pins `get_customer_firestore_client()` and `provision=False`. Flipping `provision=False` back to `True`: ``` FAILED test_screen_vector_entitlement_reads_customer_firestore_without_provisioning assert 'provision=False' in source FAILED test_screen_vector_entitlement_does_not_write_when_customer_subscription_doc_is_missing AssertionError: Expected 'set' to not have been called. Called 1 times. 2 failed in 1.94s ``` Lookup exceptions still fail open (`test_the_entitlement_gate_fails_open`). - CI-shaped backend unit run: `cd backend && BACKEND_PYTEST_FILE_ISOLATION=1 bash scripts/run-unit-ci.sh --changed-files <changed-files>`. `first_open_obligations.py` selects the full backend unit suite. `test_mentor_notifications.py::test_process_mentor_proactive_notification_sends` hangs past 90s on this branch **and** on current `origin/main` `77575a8f7f` (unmocked `current_date_for_uid` → live `db.collection('users')` with ADC); it is not this change. - Pyright on the changed backend production files: 0 errors. - Line-count ratchet: `OK: no unapproved line-count increase across 3 changed product source file(s).` No `Line-Count-Exception` (the #12667 `subscription.py` 1680→1682 growth is already on `main`). Could not exercise a live Beta request against production Firestore (no production access). The two-plane unit test remains the behavioral stand-in for that path. ## Tests - `test_auth_fence_fails_closed_when_the_resolved_data_plane_read_raises` - `test_screen_vector_entitlement_reads_customer_firestore_without_provisioning` - `test_screen_vector_entitlement_does_not_write_when_customer_subscription_doc_is_missing` Existing fence, cutover, BYOK, goals, first-open, and knowledge-ledger tests keep their importer-binding patches. The goals / first-open / knowledge-ledger isolation stubs no longer export `get_data_plane_firestore_client` because those modules no longer import it. ## Failure class (fixes) Failure-Class: FC-plane-seam-adopted-by-reader-not-writer ## Rollback hazards - Reverting the three unreachable pins restores pre-#12667 compute defaults for first-open, goals, and knowledge-ledger **read** tools. On GKE with `SERVICE_ACCOUNT_JSON` those accessors still coincide with the data plane. On a split plane they again match their compute-default siblings (`conversations.py` CRUD, `action_items.py` / `task_intelligence_control.py`, `MemoryService` / canonical adapter). - Mixed desktop-backend fleet (from #12667, still true): during a mixed desktop-backend rollout, old revisions read BYOK and assistant settings on the compute plane and will miss values the new revision wrote. That is mixed-fleet degradation (BYOK looks unenrolled; web-search opt-out looks absent/allowed), not a deleting account reopening. Old Cloud Run `backend` sees the same data plane because its accessors coincide. - Screen-vector entitlement stays at `provision=False` plus the customer Firestore client. A miss defaults to basic (no cloud screen vectors) instead of JIT-creating a subscription doc. Lookup exceptions still fail open and write vectors. - Rolling this follow-up back re-introduces the three dormant reader/writer splits on first-open, goals, and knowledge-ledger tools. It does not reopen the Beta deletion-fence miss. ## Named sibling seams | Seam | Verdict | |---|---| | BYOK key lookup (`utils/byok.py` → `users.get_byok_state`) | **Fixed in #12667.** `get_byok_state` / `set_byok_active` / `clear_byok_active` use `get_data_plane_firestore_client()` (`users.py:285`, `:331`, `:337`). | | Screen-vector entitlement with `provision=True` | **Fixed in #12667; ratcheted here.** `grants_cloud_screen_vectors` calls `get_user_valid_subscription(..., firestore_client=get_customer_firestore_client(), provision=False)` (`subscription.py:144-146`). A missing customer subscription doc does not call `user_ref.set`. Lookup exceptions still fail open. | | Web-search opt-out | **Fixed in #12667.** `get_assistant_settings` / `_get_raw_assistant_settings` / `update_assistant_settings` read and write `users/{uid}` through `get_data_plane_firestore_client()` (`users.py:2204`, `:2217`, `:2249`). | | Pinecone / Typesense wipe fence | **Fixed in #12667.** `vector_db.py` defaults to `data_plane_db`; `atom_keyword_index.py` imports `data_plane_db as default_db_client`. | | Deletion marker, legal holds, cutover, memory ledger, MCP OAuth | **Fixed in #12667; kept.** Reachable from desktop-backend, or no compute-default sibling on the same collection. | ## Follow-ups Next instances of `FC-plane-seam-adopted-by-reader-not-writer`. Move each module together with its sibling(s) in one change; do not pin the reader (or writer) alone. - `backend/database/first_open_obligations.py` — sibling `backend/database/conversations.py:561` (CRUD defaults at `:795`, `:835`, `:919`, `:1624` also `get_firestore_client()`). Same `users/{uid}/conversations/{id}` family (`jit_first_open` lives on the conversation). Not reachable from desktop-backend. - `backend/database/goals.py` — siblings `backend/database/action_items.py:53` (`firestore_client or db`) and `backend/database/task_intelligence_control.py:20` (`from database._client import db`). Same `users/{uid}/goals` and `task_intelligence_control` collections. `/v1/goals` is a 410 on desktop-backend. - `backend/utils/retrieval/tools/knowledge_ledger_tools.py` — siblings `backend/utils/memory/memory_service.py:19` and `backend/utils/memory/canonical_memory_adapter.py:18` (both default `db`). Same `users/{uid}/memory_items` / apply-control collections. Desktop-backend JIT snapshots already inject the data plane; the read tools are not invoked from `desktop_chat.py`. - `backend/routers/mcp_sse.py` authorize path (`:1788-1801`) does not call `enforce_account_deletion_http_access`. It relies on `create_grant_and_authorization_code_if_allowed` reading `account_deletions` through `data_plane_db` (`mcp_oauth.py:575-590`). An unresolvable data-plane client raises out of the grant write as HTTP 500, not mapped to 503. Fail-closed, different status. MCP is not mounted on desktop-backend. Subsequent MCP data calls do use the HTTP fence. - Field-disjoint `users/{uid}` telemetry writers still on compute: `record_client_device` / `record_user_platform` (`users.py:135`, `:178`) merge-write the compute copy while BYOK and `assistant_settings` now live on the data plane. Field-disjoint, so it does not reopen deletion or clobber `byok`. Pre-existing telemetry-to-empty-dev-Firestore. The `.get()`-swallow guard named in the #12667 review is fixed in this PR. ## New guards The resolved-client `.get()` raise test is the recurrence guard for swallowing a deletion-marker read error into a clean miss. The `provision=False` behavioral test is the recurrence guard for JIT-writing Free onto a missing customer subscription doc from screen-vector entitlement. They are not a repo-wide plane-seam checker because the plane is a runtime client identity, not a static import graph. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12674?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. -->
What changed and why
The account-deletion auth fence read
account_deletions/{uid}throughget_firestore_client()(compute plane). The deletion executor writes that marker on the customer data plane. On Omi Beta (desktop-backend) the planes differ, so the lookup missed cleanly, returnedNone, and a user whose deletion was in progress kept reading and writing production data. HTTP 503 only fired on an exception, never on a clean miss.Writers and readers now share one accessor,
account_deletion_firestore_client()inbackend/database/account_deletion_marker.py, which pinsget_data_plane_firestore_client(). If that client cannot be resolved, the fence fails closed (503). Sibling per-user markers that had the same reader/writer split are pinned the same way.Product invariants affected
How it was verified
backend/tests/unit/test_account_deletion_auth_fence.py::test_auth_fence_refuses_when_the_deletion_marker_is_only_on_the_data_planeruns the production fence (enforce_account_deletion_http_access→get_user_deletion_wipe_status) with two fake Firestore clients (compute empty, data plane holdingwipe_status=running) and asserts HTTP 403.test_auth_fence_fails_closed_when_the_data_plane_client_cannot_be_resolvedasserts HTTP 503 when the data-plane client cannot be resolved.account_deletion_firestore_clienttoreturn get_firestore_client():Restoring the data-plane accessor:
15 passed in 0.69s. Reintroducing the same fallback:Failed: DID NOT RAISE HTTPExceptionagain (1 failed in 0.65s).load_module_freshdatabase.users/database.conversationsnow exportget_data_plane_firestore_clientso the new import does not die at collection time. Typesense upserts default todata_plane_db(matching Pinecone) instead of passingNoneinto the fence.cd backend && BACKEND_PYTEST_FILE_ISOLATION=1 bash scripts/run-unit-ci.sh --changed-files <changed-files>.test_mentor_notifications.py::test_process_mentor_proactive_notification_sendshangs past 90s on this branch and onorigin/maine37febd0b3(unmockedcurrent_date_for_uid→ livedb.collection('users')with ADC); it is not this fence change.Could not exercise a live Beta request against production Firestore (no production access). The two-plane unit test is the behavioral stand-in for that path.
Tests
Regression that would have caught the bug:
test_auth_fence_refuses_when_the_deletion_marker_is_only_on_the_data_plane. Existing fence, cutover, and BYOK tests keep their importer-binding patches.Failure class (fixes)
Failure-Class: FC-plane-seam-adopted-by-reader-not-writer
Line-Count-Exception: backend/utils/subscription.py | 1680 -> 1682 | screen-vector entitlement pins customer Firestore with provision=False
Rollback hazards
OMI_FIRESTORE_DATA_PLANE_PROJECTfails closed (HTTP 503) on every authenticated request instead of serving. That env var is already required on desktop-backend; this makes the deletion fence honor it.OMI_FIRESTORE_DATA_PLANE_PROJECTmismatch still raises (existing_build_data_plane_firestore_clientbehavior) and now maps to 503 on the fence.provision=Falseplus the customer Firestore client. A miss now defaults to basic (no cloud screen vectors) instead of JIT-creating a subscription doc. Lookup exceptions still fail open and write vectors (existing fail-open).database_client.db. On a split plane the gate and the marker stay on the data plane together; rolling back re-splits them.data_plane_db(same as Pinecone) and pass that client into the fence. If the data plane cannot be resolved, those writes fail closed instead of proceeding.SERVICE_ACCOUNT_JSONthat coincides with the old client.Named sibling seams
utils/byok.py→users.get_byok_state)get_byok_state/set_byok_active/clear_byok_activeuseget_data_plane_firestore_client()(users.py:285,:331,:337).provision=Truegrants_cloud_screen_vectorsnow callsget_user_valid_subscription(..., firestore_client=get_customer_firestore_client(), provision=False)(subscription.py:144-146). Entitlements stay on the customer client, not the data-plane user-doc client.get_assistant_settings/_get_raw_assistant_settings/update_assistant_settingsread and writeusers/{uid}throughget_data_plane_firestore_client()(users.py:2204,:2217,:2249).vector_db.pydefaults todata_plane_dbandexternal_write_fenceuses that client (vector_db.py:15,:50).memories.py:46/:54omit an injected client so the shared accessor resolves the data plane.atom_keyword_index.pyimportsdata_plane_db as default_db_clientand passes that resolved client into the fence (atom_keyword_index.py:16,:297), matching Pinecone.Also pinned in this sweep (same reader/writer class):
account_deletion_firestore_client()imported byusers.py,legal_holds.py.firestore_client=database_client.dbso the accessor owns the plane (account_deletion.pybackground_wipe_user_data).get_data_plane_firestore_client().get_data_plane_firestore_client()(account_cutover.py:25,:180).get_data_plane_firestore_client()(first_open_obligations.py:13,:94)._get_dbprefersget_data_plane_firestore_client(goals.py:60).data_plane_db(memory_ledger.py:22).data_plane_db(mcp_oauth.py:15).get_data_plane_firestore_client()(knowledge_ledger_tools.py:325+). Write tools already threaded a data-plane client.Remaining
get_firestore_client()readers of deletion / JIT / cutover collectionsVerified against a backend-wide grep of
get_firestore_client()after the sweep.account_deletion_transitions.py:21read_agent_vm_migration_journalsusers/{uid}/agentVmMigrationsis compute-local (GCE /agentVm). Must keepget_firestore_client().users.py:2110get_agent_vmagentVmondb.users.py:1751,:1796location-context consentget_firestore_client(); there is no reader/writer split. On GKE,SERVICE_ACCOUNT_JSONmakes this the data plane.users.py:1678get_user_subscriptiondb; screen-vector now injectsget_customer_firestore_client(). Quota/paywall callers that need production entitlements already pass the customer client.users.py:1304delete_user_dataSERVICE_ACCOUNT_JSONmakesdbthe data plane. Not the Beta serving-plane split.account_deletion_projection_fence.py:22db_client. Callers (memory_system.py:52,canonical_memory_adapter.py:3545,daily_memory_sweep.py:2853,jit_proactivity_storeviadata_plane_db) pass the data-plane client.jit_proactivity_store.py:83data_plane_db; readsaccount_deletions/{uid}on that client.knowledge_ledger_writer_transition.py:399_client_or_defaultget_firestore_client(), but productionknowledge_ledger_migration.py:344always threadsdb_client.canonical_graph.py:89,routers/knowledge_graph.py:73,:258SERVICE_ACCOUNT_JSONmakesget_firestore_client()the data plane. Not served on desktop-backend.memories.py:125_get_dbget_firestore_client(); GKE coincides.mcp_api_key.py:41,dev_api_key.py:34SERVICE_ACCOUNT_JSONis the data plane.conversations.py,action_items.py,recording_sessions.py, and otherget_firestore_client()user-subtree modulesusers/{uid}throughdelete_user_dataon GKE (db== data plane). These are not the Beta auth-fence path. Migrating every user-doc default is a follow-up, not this fence fix.New guards
The two-plane auth-fence unit test is the recurrence guard for this class on the deletion marker. It is not a repo-wide plane-seam checker because the plane is a runtime client identity, not a static import graph; a shared primitive that grepped
get_firestore_client()would false-positive every compute-localagentVmpath. The real merged instance this would have caught is the 2026-08-30 adversarial finding (same class as PR #12402).