Skip to content

fix(backend): resolve trigger feedback on the same data plane the snapshot reads - #12402

Merged
Git-on-my-level merged 2 commits into
mainfrom
jit-feedback-plane
Aug 30, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
jit-feedback-plane

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

What

POST /v1/jit/trigger-feedback resolves the customer data plane the same way the trigger snapshot on the same router already does.

Why

#12390 introduced OMI_FIRESTORE_DATA_PLANE_PROJECT and adopted it across the JIT surface, including jit_trigger_snapshot, which is what publishes a user's trigger watchlist. It missed the sibling writer: apply_canonical_trigger_feedback was called without a db_client, so it fell back to canonical_memory_adapter's compute-plane default.

jit_rollout.router is mounted on desktop_backend, which is the one deployment where those two projects differ — dev desktop-backend runs compute on based-hardware-dev while the ledger lives in based-hardware. The result: the snapshot serves a trigger from the data plane, the user hits snooze / not-useful / disable, the feedback path looks for that trigger row in the compute plane, does not find it, and the route returns 409 Trigger feedback authority changed or is unavailable — permanently, while the trigger keeps firing.

That route's own docstring says it "intentionally remains available while the proactive rollout is disabled or killed," because it is the user's authority path. With the rollout flag off, notification feedback is the only way to retract a standing trigger — there is no close_trigger chat verb — so this made the off switch the one broken verb.

Invisible in production, where the compute project and the data plane are the same project. That is the whole difficulty of this class: deploying and watching for errors cannot find it.

Test

test_trigger_feedback_writes_through_the_same_data_plane_the_snapshot_reads asserts the resolved data-plane client is threaded into the canonical call, not merely that the handler was invoked. Verified it fails without the one-line change and passes with it. Full file: 47 passed.

Failure class

Registering a new one. The existing FC-ambient-credentials-assumed-cross-plane covers credentials for a cross-plane client; FC-customer-data-plane-divergence covers client artifacts binding to the wrong plane. Neither covers a seam adopted by a reader but not its sibling writer, which is what happened here and is the generalizable mistake: the adoption sweep enumerated the files the seam touched rather than the call sites on the surface.

Failure-Class: new

Review in cubic

…pshot reads

#12390 adopted the OMI_FIRESTORE_DATA_PLANE_PROJECT seam across the JIT
surface but missed the sibling writer on this router. jit_rollout.router is
mounted on desktop_backend, the one deployment where the compute project and
the customer data plane differ, so the snapshot served a trigger from the data
plane while feedback looked for that row in the compute plane and 409'd every
retraction -- the user's only off switch for a standing trigger while the
rollout flag is off.

The new test asserts the resolved client is threaded into the canonical call
rather than that the handler ran; it fails without the fix.

Failure-Class: new
@Git-on-my-level
Git-on-my-level merged commit ff39904 into main Aug 30, 2026
36 checks passed
@Git-on-my-level
Git-on-my-level deleted the jit-feedback-plane branch August 30, 2026 00:48
Git-on-my-level added a commit that referenced this pull request Sep 3, 2026
…is written on (#12667)

## What changed and why

The account-deletion auth fence read `account_deletions/{uid}` through
`get_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, returned `None`, 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()` in
`backend/database/account_deletion_marker.py`, which pins
`get_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

- INV-MEM-1
- INV-MEM-3
- INV-MEM-4
- INV-CUTOVER-1

## How it was verified

- Guard test:
`backend/tests/unit/test_account_deletion_auth_fence.py::test_auth_fence_refuses_when_the_deletion_marker_is_only_on_the_data_plane`
runs the production fence (`enforce_account_deletion_http_access` →
`get_user_deletion_wipe_status`) with two fake Firestore clients
(compute empty, data plane holding `wipe_status=running`) and asserts
HTTP 403.
- Fail-closed:
`test_auth_fence_fails_closed_when_the_data_plane_client_cannot_be_resolved`
asserts HTTP 503 when the data-plane client cannot be resolved.
- Red-proof: mutating `account_deletion_firestore_client` to `return
get_firestore_client()`:

```
FAILED test_auth_fence_refuses_when_the_deletion_marker_is_only_on_the_data_plane
FAILED test_auth_fence_fails_closed_when_the_data_plane_client_cannot_be_resolved
Failed: DID NOT RAISE <class 'fastapi.exceptions.HTTPException'>
2 failed in 0.59s
```

Restoring the data-plane accessor: `15 passed in 0.69s`. Reintroducing
the same fallback: `Failed: DID NOT RAISE HTTPException` again (`1
failed in 0.65s`).
- Isolation stubs that `load_module_fresh` `database.users` /
`database.conversations` now export `get_data_plane_firestore_client` so
the new import does not die at collection time. Typesense upserts
default to `data_plane_db` (matching Pinecone) instead of passing `None`
into the fence.
- CI-shaped backend unit run: `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_sends`
hangs past 90s on this branch **and** on `origin/main` `e37febd0b3`
(unmocked `current_date_for_uid` → live `db.collection('users')` with
ADC); it is not this fence change.
- Pyright on the changed backend files: 0 errors.

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

- Desktop-backend without `OMI_FIRESTORE_DATA_PLANE_PROJECT` fails
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.
- A data-plane service-account / `OMI_FIRESTORE_DATA_PLANE_PROJECT`
mismatch still raises (existing `_build_data_plane_firestore_client`
behavior) and now maps to 503 on the fence.
- Screen-vector entitlement uses `provision=False` plus 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).
- Legal-hold acquire/finish on the wipe executor no longer injects
compute `database_client.db`. On a split plane the gate and the marker
stay on the data plane together; rolling back re-splits them.
- Memory write fences that used to pass a compute-default client now
omit it so the shared accessor resolves the data plane. Typesense
upserts default to `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.
- Rolling this PR back reopens the Beta deletion-fence miss: a deleting
account keeps access.
- Goals, memory ledger, MCP OAuth, first-open obligations, and
knowledge-ledger **read** tools now default to the data plane. On GKE
with `SERVICE_ACCOUNT_JSON` that coincides with the old client.

## Named sibling seams

| Seam | Verdict |
|---|---|
| BYOK key lookup (`utils/byok.py` → `users.get_byok_state`) |
**Fixed.** `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.**
`grants_cloud_screen_vectors` now calls
`get_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. |
| Web-search opt-out | **Fixed.** `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 wipe fence | **Fixed.** `vector_db.py` defaults to
`data_plane_db` and `external_write_fence` uses that client
(`vector_db.py:15`, `:50`). `memories.py:46` / `:54` omit an injected
client so the shared accessor resolves the data plane.
`atom_keyword_index.py` imports `data_plane_db as default_db_client` and
passes that resolved client into the fence (`atom_keyword_index.py:16`,
`:297`), matching Pinecone. |

Also pinned in this sweep (same reader/writer class):

- Deletion marker R/W: `account_deletion_firestore_client()` imported by
`users.py`, `legal_holds.py`.
- Wipe executor legal-hold acquire/finish: dropped
`firestore_client=database_client.db` so the accessor owns the plane
(`account_deletion.py` `background_wipe_user_data`).
- Canonical derived purge and maintenance-registry delete:
`get_data_plane_firestore_client()`.
- Account cutover control docs: `get_data_plane_firestore_client()`
(`account_cutover.py:25`, `:180`).
- First-open obligations: `get_data_plane_firestore_client()`
(`first_open_obligations.py:13`, `:94`).
- Goals: `_get_db` prefers `get_data_plane_firestore_client`
(`goals.py:60`).
- Memory ledger: `data_plane_db` (`memory_ledger.py:22`).
- MCP OAuth: `data_plane_db` (`mcp_oauth.py:15`).
- Knowledge-ledger **read** tools: `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 collections

Verified against a backend-wide grep of `get_firestore_client()` after
the sweep.

| Site | Why it is already correct, or remaining |
|---|---|
| `account_deletion_transitions.py:21`
`read_agent_vm_migration_journals` | **Verified-safe.**
`users/{uid}/agentVmMigrations` is compute-local (GCE / `agentVm`). Must
keep `get_firestore_client()`. |
| `users.py:2110` `get_agent_vm` | **Verified-safe.** Reads
compute-local `agentVm` on `db`. |
| `users.py:1751`, `:1796` location-context consent | **Verified-safe
for this class.** Reader and writer share `get_firestore_client()`;
there is no reader/writer split. On GKE, `SERVICE_ACCOUNT_JSON` makes
this the data plane. |
| `users.py:1678` `get_user_subscription` | **Verified-safe for the
named seam.** Defaults to `db`; screen-vector now injects
`get_customer_firestore_client()`. Quota/paywall callers that need
production entitlements already pass the customer client. |
| `users.py:1304` `delete_user_data` | **Verified-safe.** Wipe runs on
GKE, where `SERVICE_ACCOUNT_JSON` makes `db` the data plane. Not the
Beta serving-plane split. |
| `account_deletion_projection_fence.py:22` | **Verified-safe.**
Requires an injected `db_client`. Callers (`memory_system.py:52`,
`canonical_memory_adapter.py:3545`, `daily_memory_sweep.py:2853`,
`jit_proactivity_store` via `data_plane_db`) pass the data-plane client.
|
| `jit_proactivity_store.py:83` | **Verified-safe.** Defaults to
`data_plane_db`; reads `account_deletions/{uid}` on that client. |
| `knowledge_ledger_writer_transition.py:399` `_client_or_default` |
**Verified-safe.** Default is `get_firestore_client()`, but production
`knowledge_ledger_migration.py:344` always threads `db_client`. |
| `canonical_graph.py:89`, `routers/knowledge_graph.py:73`, `:258` |
**Remaining default, GKE-coinciding.** Graph routes run on the GKE
backend, where `SERVICE_ACCOUNT_JSON` makes `get_firestore_client()` the
data plane. Not served on desktop-backend. |
| `memories.py:125` `_get_db` | **Remaining default for memory
**writes**.** The deletion **fence** no longer uses this client. Memory
document CRUD still defaults to `get_firestore_client()`; GKE coincides.
|
| `mcp_api_key.py:41`, `dev_api_key.py:34` | **Verified-safe.**
Credential wipe runs on GKE; `SERVICE_ACCOUNT_JSON` is the data plane. |
| `conversations.py`, `action_items.py`, `recording_sessions.py`, and
other `get_firestore_client()` user-subtree modules | **Remaining
GKE-coinciding defaults.** The deletion executor wipes `users/{uid}`
through `delete_user_data` on 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-local `agentVm` path. The real merged
instance this would have caught is the 2026-08-30 adversarial finding
(same class as PR #12402).


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/12667?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. -->
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