Repository navigation
feat(backend): route desktop-backend customer data through a data-plane Firestore seam - #12390
Merged
Merged
Conversation
…ne Firestore seam
The dev desktop-backend runs GOOGLE_CLOUD_PROJECT=based-hardware-dev with bare
ADC, so get_firestore_client() resolves to dev Firestore there. But the user
data plane for this deployment family is prod Firestore (based-hardware): the
dev python backend and the daily-memory-sweep-job already write there under
the same compute service account, proving IAM allows it. The mismatch left
JIT trigger-snapshot/ledger reads and jit_proactivity writes on desktop-backend
hitting an empty dev Firestore while the real ledger lives in prod, producing
deterministic authoritative_snapshot_unavailable suppression, and left
screen-activity sync / frame-request claiming writing into dev where nothing
reads them back.
Add get_data_plane_firestore_client() to database/_client.py: pins to
OMI_FIRESTORE_DATA_PLANE_PROJECT when set (and no Firestore emulator is
active), otherwise falls back to get_firestore_client() byte-identically.
Switch the memory ledger / JIT proactivity / screen+frame sync modules to
this seam at their module import boundary. memory_apply_store.py and
frame_requests.py are shared with the python backend and jobs; since they
never set the var, this is a no-op for them. agentVm/GCE compute-local state
keeps using get_firestore_client() directly, unchanged.
Wire OMI_FIRESTORE_DATA_PLANE_PROJECT into the deploy manifest and both
desktop-backend workflows (dev: literal based-hardware, since it differs from
compute; prod: ${{ vars.GCP_PROJECT_ID }}, since data-plane == compute there
by construction).
Co-Authored-By: Claude Fable 5 <[email protected]>
…nt setting The deployment-secret-boundary preflight check ratchets every new runtime_env.yaml binding against config/deployment-setting-classification.json; this var is a non-secret project id, same kind as GOOGLE_CLOUD_PROJECT/GCP_LOCATION. Co-Authored-By: Claude Fable 5 <[email protected]>
Git-on-my-level
marked this pull request as ready for review
August 29, 2026 16:35
3 tasks done
Git-on-my-level
added a commit
that referenced
this pull request
Aug 29, 2026
…e account (#12392) ## What Follow-up to #12390. The seam's ADC-pinned client 403s in dev (`google.api_core.exceptions.PermissionDenied: 403 Missing or insufficient permissions` on `POST /v1/screen-activity/sync`, first observed 2026-08-29T16:41:25Z on revision `desktop-backend-df918555e98b`): the dev compute SA has no Firestore IAM on `based-hardware`. The daily-memory-sweep-job writes prod through the mounted `SERVICE_ACCOUNT_JSON` credentials, not ADC — the seam now does the same via `customer_entitlement_service_account()` (env on listen/Python/jobs, `FIREBASE_AUTH_CREDENTIALS_PATH` file on desktop-backend), and fails closed with a RuntimeError if the mounted SA's project does not match `OMI_FIRESTORE_DATA_PLANE_PROJECT` instead of writing user data cross-plane. No workflow or manifest changes: the credential file is already mounted on desktop-backend in both environments. ## Failure class (fixes) Failure-Class: new ## Test plan - [x] `tests/unit/test_data_plane_firestore_client.py` — 9 passed (3 new: mounted-credentials path, project-mismatch refusal, ADC fallback) - [x] `test_jit_ledger_snapshot.py`, `test_jit_proactivity_store.py`, `test_memory_apply_store.py`, `test_firestore_di_seam.py` — all passed - [x] black clean on touched files 🤖 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/12392?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. -->
Git-on-my-level
added a commit
that referenced
this pull request
Aug 30, 2026
…pshot reads (#12402) ## 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 <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12402?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. -->
pull Bot
pushed a commit
to AmirulAndalib/omi
that referenced
this pull request
Aug 30, 2026
…pshot reads BasedHardware#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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
The split-brain. The dev desktop-backend runs
GOOGLE_CLOUD_PROJECT=based-hardware-devwith bare ADC (its deploy workflow explicitly strips
SERVICE_ACCOUNT_JSON), soget_firestore_client()inbackend/database/_client.pyresolves to devFirestore there. But the user data plane for this deployment family is prod
Firestore (
based-hardware): the dev pythonbackendservice and thedaily-memory-sweep-jobalready run withGOOGLE_CLOUD_PROJECT=based-hardwareunder the same compute service account
(
[email protected]), proving IAM alreadyallows it. The mismatch meant JIT trigger-snapshot/ledger reads and
jit_proactivitywrites on desktop-backend hit an empty dev Firestore whilethe user's real ledger (
memory_state/head, etc.) lives in prod, producing adeterministic
authoritative_snapshot_unavailablesuppression. Screen-activitysync and frame-request claiming had the same problem: writes landed in dev,
invisible to anything reading the prod plane.
The seam.
backend/database/_client.pygainsget_data_plane_firestore_client(): whenOMI_FIRESTORE_DATA_PLANE_PROJECTisset and no Firestore emulator is active, it pins ADC to that project via
prepare_google_credentials()+firestore.Client(project=...); otherwise itreturns
get_firestore_client()exactly. Adata_plane_dblazy proxy mirrorsthe existing
dbproxy for modules that bind a client as a default parametervalue.
The memory-ledger / JIT-proactivity / screen+frame sync modules switch to this
seam at their module import boundary (not per-call):
routers/jit_ledger_snapshot.py,database/jit_proactivity_store.py,database/memory_apply_store.py,utils/memory/jit_trigger_snapshot.py,database/screen_activity.py,database/frame_requests.py, andservices/conversation_keyframes.py(the frame-request claim path thatpiggybacks on screen sync via
desktop_screen_crisp.py).memory_apply_store.pyandframe_requests.pyare shared with the pythonbackend,
backend-sync, and the memory-maintenance/daily-sweep jobs. None ofthose set
OMI_FIRESTORE_DATA_PLANE_PROJECT, soget_data_plane_firestore_client()falls back to
get_firestore_client()for them — byte-identical behavior,verified by a dedicated fallback-identity test, not just "should be a no-op."
Deliberately untouched.
agentVm/ GCE compute-local state keeps usingget_firestore_client()directly — the docstring on the new function repeatsthis.
desktop_agent_vm.py,desktop_chat.py(chat sessions),desktop_proxy.py,desktop_realtime.py, anddesktop_tts_updates.pywere not touched, per thetask's exclusion list; their own client handles are untouched (though some of
them may transitively reach the now-switched shared modules, e.g.
desktop_chat.pyreading the same memory ledger — that is correct: the seam is a data-plane
selection for the whole process's Firestore access, not a per-router
allow-list).
Manifest + workflows.
backend/deploy/runtime_env/_base.yaml'sdesktop_backend.envgainsOMI_FIRESTORE_DATA_PLANE_PROJECT: '{data_plane_project}';backend/deploy/runtime_env.yamlis regenerated(
python3 backend/deploy/compose_runtime_env.py, verified idempotent).data_plane_projectalready existed as a compose placeholder(
dev.overlay.yaml:based-hardware, differs fromcompute_project: based-hardware-dev;prod.overlay.yaml:based-hardware, equal tocompute_project), so this is a no-op in prod by construction.Both
.github/workflows/desktop_backend_auto_dev.ymlanddesktop_backend_prod.ymlgained the matching env line — dev as the literalbased-hardware(it must diverge fromvars.GCP_PROJECT_ID), prod as${{ vars.GCP_PROJECT_ID }}(dynamic, since the manifest's rendered value forprod deliberately equals the compute-project literal there). The dynamic form
for prod was required by an existing test
(
test_desktop_manifest_env_matches_what_the_workflow_deploys[prod]), whichalready enforces "a manifest value that coincides with the compute-project
literal must be sourced dynamically, not hardcoded" — the render-and-compare
drift guard (
render_backend_runtime_env.py --desktop-state-outputfeedingattach_cloud_run_gmp_sidecar.py --expected-env-state) would otherwise failthe deploy in both environments once it started asserting the new variable's
presence.
Dev rollout note. Once this deploys to dev desktop-backend, JIT
trigger-snapshot/ledger reads,
jit_proactivitywrites, screen-activity sync,and frame-request claiming start landing in prod Firestore (
based-hardware)instead of dev (
based-hardware-dev). Old rows already written tobased-hardware-devunder those collections are not migrated or deleted bythis change — they stay where they are, orphaned. This is intended to be a
forward-only cutover: any dev-desktop-backend user's history since dev
deployment predates this fix.
Spec deviations (flagged, not improvised around)
backend/utils/memory/v3/account_generation_source.pyneeded no codechange. It takes
db_clientas a required parameter with no default andperforms no client acquisition of its own — it already goes through
whatever client its caller (
jit_trigger_snapshot.py, now switched) passesin. Modifying it would have meant inventing a change that doesn't exist in
the code.
backend/routers/jit_rollout.pyalso needed no direct code change. Itowns no Firestore client itself; it calls
reserve_jit_proactivity_eventand
read_authoritative_trigger_snapshotwith no explicit client, so theseam reaches it entirely through its already-switched dependencies
(
jit_proactivity_store.py,jit_trigger_snapshot.py).backend/services/conversation_keyframes.pywas switched even though itisn't named explicitly in the file list — it owns the "frame-request claim
path that piggybacks on" screen sync (called directly from
desktop_screen_crisp.py's sync handler, and it threads its resolvedclient into
enqueue_frame_request), so it's the same data path the specdescribed for
screen_activity.py/frame_requests.py.database._clientstub moduleand would otherwise break on collection with
ImportError: cannot import name 'data_plane_db': the sharedmake_database_client_stub()helper intests/unit/memory_import_isolation.py(used by ~25 other test files) andtests/unit/test_desktop_migration.py's own stub. Both now also exposedata_plane_db/get_data_plane_firestore_client.desktop_backend_prod.yml's new line had to beOMI_FIRESTORE_DATA_PLANE_PROJECT=${{ vars.GCP_PROJECT_ID }}, not the literalbased-hardwarethe task text suggested — see the workflow note above.Product invariants affected
migration exception. This PR does not change desktop-backend's serving
endpoint, OAuth/Firebase Auth authority, or which artifact talks to which
API (Beta still resolves
api.omiapi.com/desktop-backend-dt5lrfkkoawith production Firebase Auth, unchanged). It changes only which Firestore
project desktop-backend's own server-side Firestore reads/writes for the
memory ledger and screen/frame data pin to, correcting them onto the same
single canonical customer data plane (
based-hardware) that Firebase Auth,get_customer_firestore_client(), the python backend, and the daily sweepjob already use — it removes a split-brain, it does not create one.
(
backend/database/memory_*.py,backend/utils/memory/**,backend/deploy/runtime_env.yaml). No consolidation route, promotionadmission, tier, or Archive-access semantics changed; this PR changes
Firestore client acquisition only, not memory lifecycle logic.
Verification
Focused pytest lane (
BACKEND_UNIT_TEST_FILE_LIST,bash test.sh) over thetouched modules and every dependent test file found by tracing client
acquisition through the codebase (28 files, run both pre- and post-rebase onto
origin/main's1a76a28b68— all green both times):(exit code 0, 0 files failed, both runs)
black --line-length 120 --skip-string-normalization --checkover everychanged Python file: clean.
bash backend/scripts/typecheck.sh(pyright, full project — the enforcedlane doesn't accept file scoping): 0 errors both before and after rebase
(pre-existing warning count unaffected; no new warnings on any changed
symbol).
python3 backend/deploy/compose_runtime_env.pyrun twice back-to-back:second run produces no diff (idempotent).
Not run: a live desktop-backend serve against real dev GCP credentials (no
SERVICE_ACCOUNT_JSON/ADC available in this environment) — the fallbackbehavior when the env var is unset is instead covered by a dedicated identity
test (
test_falls_back_to_get_firestore_client_when_var_is_unset), and thepinned-project path by
test_pins_project_when_var_is_set_and_emulator_is_not.The full ~996-file selector-driven suite (triggered because
database/_client.pyis foundational) was not used for verification — it is documented as
segfault-prone in this environment; the focused lane above is the substitute.