Skip to content

feat(backend): route desktop-backend customer data through a data-plane Firestore seam - #12390

Merged
Git-on-my-level merged 2 commits into
mainfrom
feat/desktop-backend-data-plane-seam
Aug 29, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
feat/desktop-backend-data-plane-seam

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

The split-brain. The dev desktop-backend runs GOOGLE_CLOUD_PROJECT=based-hardware-dev
with bare ADC (its deploy workflow explicitly strips SERVICE_ACCOUNT_JSON), so
get_firestore_client() in backend/database/_client.py resolves to dev
Firestore there. But the user data plane for this deployment family is prod
Firestore (based-hardware): the dev python backend service and the
daily-memory-sweep-job already run with GOOGLE_CLOUD_PROJECT=based-hardware
under the same compute service account
([email protected]), proving IAM already
allows it. The mismatch meant JIT trigger-snapshot/ledger reads and
jit_proactivity writes on desktop-backend hit an empty dev Firestore while
the user's real ledger (memory_state/head, etc.) lives in prod, producing a
deterministic authoritative_snapshot_unavailable suppression. Screen-activity
sync and frame-request claiming had the same problem: writes landed in dev,
invisible to anything reading the prod plane.

The seam. backend/database/_client.py gains
get_data_plane_firestore_client(): when OMI_FIRESTORE_DATA_PLANE_PROJECT is
set and no Firestore emulator is active, it pins ADC to that project via
prepare_google_credentials() + firestore.Client(project=...); otherwise it
returns get_firestore_client() exactly. A data_plane_db lazy proxy mirrors
the existing db proxy for modules that bind a client as a default parameter
value.

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, and
services/conversation_keyframes.py (the frame-request claim path that
piggybacks on screen sync via desktop_screen_crisp.py).

memory_apply_store.py and frame_requests.py are shared with the python
backend, backend-sync, and the memory-maintenance/daily-sweep jobs. None of
those set OMI_FIRESTORE_DATA_PLANE_PROJECT, so get_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 using
get_firestore_client() directly — the docstring on the new function repeats
this. desktop_agent_vm.py, desktop_chat.py (chat sessions), desktop_proxy.py,
desktop_realtime.py, and desktop_tts_updates.py were not touched, per the
task'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.py
reading 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's
desktop_backend.env gains OMI_FIRESTORE_DATA_PLANE_PROJECT: '{data_plane_project}';
backend/deploy/runtime_env.yaml is regenerated
(python3 backend/deploy/compose_runtime_env.py, verified idempotent).
data_plane_project already existed as a compose placeholder
(dev.overlay.yaml: based-hardware, differs from compute_project: based-hardware-dev; prod.overlay.yaml: based-hardware, equal to
compute_project), so this is a no-op in prod by construction.

Both .github/workflows/desktop_backend_auto_dev.yml and
desktop_backend_prod.yml gained the matching env line — dev as the literal
based-hardware (it must diverge from vars.GCP_PROJECT_ID), prod as
${{ vars.GCP_PROJECT_ID }} (dynamic, since the manifest's rendered value for
prod 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]), which
already 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-output feeding
attach_cloud_run_gmp_sidecar.py --expected-env-state) would otherwise fail
the 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_proactivity writes, screen-activity sync,
and frame-request claiming start landing in prod Firestore (based-hardware)
instead of dev (based-hardware-dev). Old rows already written to
based-hardware-dev under those collections are not migrated or deleted by
this 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.py needed no code
    change
    . It takes db_client as a required parameter with no default and
    performs no client acquisition of its own — it already goes through
    whatever client its caller (jit_trigger_snapshot.py, now switched) passes
    in. Modifying it would have meant inventing a change that doesn't exist in
    the code.
  • backend/routers/jit_rollout.py also needed no direct code change. It
    owns no Firestore client itself; it calls reserve_jit_proactivity_event
    and read_authoritative_trigger_snapshot with no explicit client, so the
    seam reaches it entirely through its already-switched dependencies
    (jit_proactivity_store.py, jit_trigger_snapshot.py).
  • backend/services/conversation_keyframes.py was switched even though it
    isn'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 resolved
    client into enqueue_frame_request), so it's the same data path the spec
    described for screen_activity.py / frame_requests.py.
  • Two existing test fixtures constructed a bare database._client stub module
    and would otherwise break on collection with ImportError: cannot import name 'data_plane_db': the shared make_database_client_stub() helper in
    tests/unit/memory_import_isolation.py (used by ~25 other test files) and
    tests/unit/test_desktop_migration.py's own stub. Both now also expose
    data_plane_db / get_data_plane_firestore_client.
  • desktop_backend_prod.yml's new line had to be
    OMI_FIRESTORE_DATA_PLANE_PROJECT=${{ vars.GCP_PROJECT_ID }}, not the literal
    based-hardware the task text suggested — see the workflow note above.

Product invariants affected

  • INV-DATA-1 — preserves the existing authority, does not invoke the
    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-dt5lrfkkoa
    with 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 sweep
    job already use — it removes a split-brain, it does not create one.
  • INV-MEM-4 / INV-MEM-1 — matched only by path globs
    (backend/database/memory_*.py, backend/utils/memory/**,
    backend/deploy/runtime_env.yaml). No consolidation route, promotion
    admission, 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 the
touched 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's 1a76a28b68 — all green both times):

tests/unit/test_data_plane_firestore_client.py   5 passed
tests/unit/test_jit_ledger_snapshot.py           12 passed
tests/unit/test_memory_apply_store.py            5 passed
tests/unit/test_jit_proactivity_store.py         6 passed
tests/unit/test_jit_rollout.py                   46 passed
tests/unit/test_jit_trigger_snapshot.py          23 passed
tests/unit/test_screen_activity_evidence.py      21 passed
tests/unit/test_screen_activity_identity.py      45 passed
tests/unit/test_screen_activity_list_endpoint.py 4 passed
tests/unit/test_screen_activity_search_utc.py    8 passed
tests/unit/test_screen_activity_summary_endpoint.py 4 passed
tests/unit/test_screen_activity_tool_result_bound.py 8 passed
tests/unit/test_frame_requests.py                10 passed
tests/unit/test_conversation_keyframes.py        9 passed
tests/unit/test_firestore_di_seam.py             39 passed
tests/unit/test_desktop_migration.py             35 passed
tests/unit/test_render_backend_runtime_env.py    114 passed
tests/unit/test_ws_j_delete_privacy.py           7 passed
tests/unit/test_ws_i_hardening.py                8 passed
tests/unit/test_ws_k_layer_field.py              29 passed
tests/unit/test_ws_m_atom_keyword_index.py       13 passed
tests/unit/test_ws_n_graph_traversal.py          40 passed
tests/unit/test_memory_ledger.py                 41 passed
tests/unit/test_merge_validation.py              3 passed
tests/unit/test_review_queue_cascade_purge.py    55 passed
tests/unit/test_agent_vm_firebase_project_split.py 11 passed
tests/unit/test_desktop_proactivity.py           8 passed
tests/unit/test_desktop_screen_crisp.py          included above

(exit code 0, 0 files failed, both runs)

  • black --line-length 120 --skip-string-normalization --check over every
    changed Python file: clean.
  • bash backend/scripts/typecheck.sh (pyright, full project — the enforced
    lane 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.py run 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 fallback
behavior 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 the
pinned-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.py
is foundational) was not used for verification — it is documented as
segfault-prone in this environment; the focused lane above is the substitute.

Review in cubic

Git-on-my-level and others added 2 commits August 29, 2026 12:09
…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
Git-on-my-level marked this pull request as ready for review August 29, 2026 16:35
@Git-on-my-level
Git-on-my-level merged commit df91855 into main Aug 29, 2026
42 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/desktop-backend-data-plane-seam branch August 29, 2026 16:35
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
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