Repository navigation
refactor(desktop): replace Rust cloud backend with Python - #10686
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for taking on the Rust-to-Python desktop backend migration. This is directionally useful, but I’m going to request changes before maintainer/product review because one of the production-routing guardrails is currently red.
Blocking:
Hygienefails inproduction-data-plane-routing. I reproduced the failing check locally withpython3 .github/scripts/test_check_mobile_production_routing.py; it reports both.github/workflows/desktop_backend_prod.ymland.github/workflows/desktop_backend_auto_dev.ymlas declaring retired GKE desktop-backend ownership. From the diff this looks like the guard is matching the new Cloud Run image steps via the broadgcloud containermarker, so either the workflow text or the guard needs to distinguishgcloud container imagesfrom retired GKE ownership. Please get this guard passing before merge.
Maintainer review needed:
- This PR replaces a large security/workflow/dependency-sensitive surface: desktop backend routing, Cloud Run deploy workflows, agent VM provisioning, server-side model proxying, and a new agent VM image/runtime. Even after CI is green, this should get explicit human maintainer review for architecture, rollout, and operational risk before merge.
- Agent/coding-agent behavior is materially changed.
desktop/macos/AGENTS.md, desktop backend docs/runbooks, and the newbackend/agent_vmruntime/docs move the desktop backend guidance from Rust to Python and introduce a Claude agent VM withBash/file-edit/web tools underpermission_mode="bypassPermissions". That may be intended for an isolated user VM, but maintainers should verify the safety model, update path, secret handling, and user-data boundaries match the product intent.
I did not see evidence of a malicious supply-chain attempt, but because this touches secrets, public Cloud Run/GCE provisioning, Docker images, dependencies, and agent behavior, I would not auto-approve it under the maintainer policy until the guard failure is fixed and a human owner signs off.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Bring #10686 onto current main and account for features that landed after the branch diverged: - Keep the Python Cloud Run / agent_vm cutover; retire Node agent-cloud and the agent-cloud-tests preflight entry that #10256 reintroduced. - Preserve SCA-194 DESKTOP_* production secret bindings, Pinecone removal, image-lineage verification, and Firestore probe signer mounts from main. - Point desktop-backend-release-boundary triggers at backend/Dockerfile.desktop_backend and desktop_chat.py while retaining verify_desktop_backend_image_lineage.py. - Align the production secret-bridge ordered step with the Python image build step name so release-policy checks stay green after the cutover. - Drop the stale agent-cloud path comment from agent-proxy resilience helpers. Failure-Class: none
Post-merge residual cleanup (tracked)Ops/DNS leftovers for after this PR merges are checklisted in the private Omi Knowledge hub (not a second issue tracker):
Already done (do not redo): GKE Helm/Ingress/cert for old Still open after merge (high signal):
This comment is tracking only — not merge/deploy authorization. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for continuing this migration. The earlier Hygiene/production-routing guard looks resolved on the current head, but I still need to keep this in changes-requested because there are remaining merge blockers and a couple of safety/docs issues that should be addressed before human architecture review.
Blocking before merge:
- CI is still red:
Desktop Swift Build & TestsandDesktop Swift Static & Test Contractsare failing on this head. Please get those green before this is considered merge-ready. desktop/macos/AGENTS.mdstill contains stale Rust-backend guidance after the migration. For example it still says the macOS folder contains a Rust backend, names development/production “Rust delivery” as owned bydesktop_backend_auto_dev.yml/desktop_backend_prod.yml, and tells agents to look for the local Rust backend log path. Because this file directly controls coding-agent behavior in the desktop tree, stale guidance here can send future agents/reviewers down the wrong build, deploy, and debugging path. Please update the affected agent instructions to describe the Python desktop backend and its actual local/CI/deploy ownership.- The new agent VM runtime executes/upgrades code from GCS at runtime (
startup.shis fetched/executed from the bucket during VM boot, andmain.pyself-updates from the bucket). Given that this VM runs with user data plus Claude tools underpermission_mode="bypassPermissions", please add/describe an integrity/rollout control for those artifacts (for example immutable versioned object names plus checksum/signature verification and rollback/audit expectations) before treating this as production-safe.
Maintainer review still needed:
- This remains a large security/workflow/dependency-sensitive replacement of the desktop backend, Cloud Run deploy flow, GCE agent VM provisioning, model proxying, and agent behavior. I don’t see evidence of a malicious supply-chain attempt, but this should still get explicit human sign-off for architecture, rollout, secret handling, and the user-data boundary after the blockers above are fixed.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
f756b33 to
34f5954
Compare
|
Addressed the requested follow-ups and rebased onto current
The earlier PTT test hardening was not replayed because current Fresh GitHub Actions checks are now queued for this rebased head. |
Failure-Class: none
Failure-Class: none
Failure-Class: none
Failure-Class: none
Failure-Class: FC-nonrecoverable-promotion
Failure-Class: none Co-authored-by: multica-agent <[email protected]>
8a5a5b6 to
0a02207
Compare
## Summary - install `git` in the desktop-backend builder before syncing the runtime lock - unblock the Git-sourced `pyogg` dependency introduced by #10686 ## Context Follow-up to #10686. The dev deployment failed during its image build: https://github.com/BasedHardware/omi/actions/runs/30405177980 The slim Python builder ran `uv pip sync` without Git, while `pyogg` is locked from `git+https://github.com/TeamPyOgg/PyOgg`. The agent-VM lock has no Git-sourced dependency, so its Dockerfile is unchanged. ## Verification - `make setup` - `make preflight` - `docker build -f backend/Dockerfile.desktop_backend .` (blocked before build layers because the local Docker daemon lacks authentication to pull `gcr.io/based-hardware-dev/python:3.11-slim-forky`; GCR returned 403) - confirmed `pylock.runtime.toml` retains the Git VCS entry for `pyogg`, and the Dockerfile installs Git before `uv pip sync` ## Residual risk The full image build remains to be exercised by authenticated CI. This change deliberately adds only Git, not compilers or unrelated build tooling. Failure-Class: none Closes SCA-235 <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10807?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. -->
… build (#10816) ## Summary - Add `gcc` to `backend/Dockerfile.desktop_backend` apt-get install line - Unblocks `webrtcvad==2.0.10` C extension build during `uv pip sync` ## Context Follow-up to #10686 (replace Rust cloud backend with Python) and #10807 (add git for pyogg VCS source). The dev deployment has failed on every post-merge run since #10686 landed. The error: ``` webrtcvad==2.0.10 → gcc: No such file or directory error: command 'gcc' failed: No such file or directory ``` `webrtcvad` compiles a C extension (`_webrtcvad`) and needs a C compiler in the builder image. The slim Python base image ships no compiler toolchain. ## Verification - Confirmed `pylock.runtime.toml` locks `webrtcvad==2.0.10` which requires C compilation - Diff adds only `gcc` to the existing apt-get line (no other changes) - CI auto-dev workflow will exercise the full Docker build on next push Failure-Class: none
… cutover) (#10391) ## Summary Phase-1, low-blast-radius harden for agent VM public `:8080` exposure (#7326) — **without** removing public NAT or applying a public DENY firewall (those break prod today). **Why not private-only yet:** agent VMs are on VPC `default`; `agent-proxy` is on GKE `omi-prod-vpc-1` with **no peering**. Desktop still calls `http://{vmIP}:8080` for upload/sync. Removing NAT or denying `0.0.0.0/0` would break chat + DB sync. ### This PR (safe to merge) - Keep `ONE_TO_ONE_NAT` / public IP provisioning - Keep / contract-test `omi-agent-vm` network tag - Auth-gate VM `/health` (was publicly readable `databaseReady`); update desktop + agent-proxy callers - Land deferred phase-3 firewall IaC with **apply refuse-by-default** (`AGENT_VM_FIREWALL_APPLY_PHASE3` gate) - Deferred cutover docs live in `backend/charts/agent-vm-firewall/firewall-rule.yaml` + apply script (refuse-by-default) ### Explicitly deferred (do not apply yet) | Step | Follow-up | |------|-----------| | Route desktop upload/sync through agent-proxy | **PR10c** (required before firewall cutover) | | Allowlist reserved Cloud NAT egress for proxy (or peer/move VMs) | infra | | Apply public DENY / remove NAT | phase 3 after the above are proven | | Terminated-disk / storage cost leak | later slice of #7326 | **Partial progress on #7326** (auth harden + prepare surface; not full network isolation or cost fix). **Supersedes #9261** (stale/CONFLICTING since Jul 12). ## Product invariants affected - INV-AUTH-1 (path-matched via `AgentSyncService.swift`; this PR only adds Bearer/`?token=` on VM `/health` probes — no Firebase session-death policy change) ## Failure-Class Failure-Class: new Registers `FC-agent-vm-public-health-unauth`: public agent VM `/health` must not expose readiness metadata without the VM auth token. Evidence: #9261 / #7326. ## Manual steps (post-merge; current Python runtime) This is a **phase-1 health-auth rollout only**. Keep public `ONE_TO_ONE_NAT` / public IP provisioning. Do not remove NAT, apply a public DENY firewall, or run the deferred phase-3 firewall script. PR #10686 retired the Node `agent.mjs` and Rust agent runtime in favor of the Python Agent VM image. Do **not** publish `agent.mjs` or update `version.txt` as the rollout mechanism. Use the current versioned image/startup workflow on merged `main`. **Safe order (callers before gate):** 1. **Deploy `agent-proxy` from merged `main` first.** Dispatch `.github/workflows/gcp_backend_agent_proxy.yml` with `environment=prod`. The workflow checks out `main`, builds/pushes `agent-proxy`, deploys it to `prod-omi-gke`, and waits for the GKE rollout to complete. 2. **Ship a desktop build with the Swift health-auth callers.** Use a beta/candidate containing the `AgentSyncService.swift` and `AgentVMService.swift` changes from this PR. Do not let VMs enforce the new health gate before this caller is available; otherwise desktop health checks receive `401` and may false-trigger DB re-upload paths. 3. **Choose the VM-image publication path deliberately.** The current `.github/workflows/desktop_backend_prod.yml` is a **combined desktop-backend production release**: in addition to building/publishing `gcr.io/based-hardware/agent-vm:<first-12-of-release-sha>` and `gs://based-hardware-agent/startup.sh`, it deploys and probes a desktop-backend candidate, then routes 100% of production traffic and can roll back. **Do not dispatch it solely to publish the VM image.** Use it only after separately approving that combined desktop-backend release, with the exact merged `release_sha`, normal release-eligibility proof, `confirm=deploy-desktop-backend-prod`, and a non-empty operator `reason`. There is no dedicated VM-only publisher currently; create and approve that path before a VM-only rollout. 4. **Verify before declaring the rollout complete:** - `curl -sS -i http://<vm-public-ip>:8080/health` returns `401` and no readiness metadata. - `curl -sS -i -H "Authorization: Bearer <vmToken>" http://<vm-public-ip>:8080/health` returns `200` with the expected `databaseReady` field. - Confirm the `agent-proxy` GKE rollout, the VM runtime/image identity, and desktop provision → upload/sync plus chat via `wss://agent.omi.me`. 5. **Stop and roll back** if unauthenticated health returns readiness data, an authenticated caller receives `401`, or upload/sync/chat regresses. Do not change firewall or NAT state while investigating. **Do not run** `backend/scripts/apply-agent-vm-firewall.sh`, remove public NAT, or use `--live` reachability against production until PR10c plus private reachability and the reserved Cloud NAT allowlist are proven. ## Test plan - [x] `cd backend && python3 -m pytest tests/unit/test_agent_vm_firewall_contract.py tests/unit/test_agent_vm_health_auth_contract.py tests/unit/test_agent_vm_protocol.py -v` → PR-specific backend contract tests pass - [x] `bash backend/scripts/apply-agent-vm-firewall.sh` → exit 1 `REFUSED` - [x] `bash backend/scripts/agent-vm-reachability-check.sh` → passed (hermetic; no production `--live` check) - [x] Swift recovery test asserts `/health` sends Bearer + `?token=` (`AgentSyncBatchQueryTests`) Merge with a **regular merge** (no squash). Do not auto-merge — coordinate the caller-before-gate deployment order above. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10391?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. -->
…11823) ## What this does Routes the two Gemini paths we pay on-demand for onto `gemini-3.1-flash-lite`, and makes the pending Provisioned Throughput migration cut over by itself. | Path | Billed today | After | | --- | --- | --- | | Server-paid `gemini-2.5-pro` | on-demand $10.00/1M out | `gemini-3.1-flash-lite`, $1.50/1M out | | `gemini-2.5-flash` **spillover** | on-demand $2.50/1M out | `gemini-3.1-flash-lite`, $1.50/1M out | | `gemini-2.5-flash` **dedicated** | prepaid, flat ~$290.32/day | unchanged until the new reservation is observed live | ## Prices (Vertex list, captured 2026-08-18) | Model | Input $/1M | Output $/1M | | --- | ---: | ---: | | `gemini-2.5-flash-lite` | 0.10 | 0.40 | | `gemini-3.1-flash-lite` | 0.25 | 1.50 | | `gemini-2.5-flash` | 0.30 | 2.50 | | `gemini-2.5-pro` | 1.25 | 10.00 | `gemini-3.1-flash-lite` is **not** the same price class as `gemini-2.5-flash-lite` — it is 2.5x input and 3.75x output. It is cheaper than what it replaces on both paths above, but that makes the client-pinned Lite lanes a trap: promoting `ModelQoS.lightweight` (macOS) or the Windows `memory`/`goals`/`insight` pins onto it would raise their output cost 3.75x. Those pins are deliberately untouched and `test_client_pinned_flash_lite_is_never_promoted` holds the boundary. ## Spillover was not previously controllable The proxy sent no capacity header, so Vertex silently spilled over-cap requests onto pay-as-you-go. This adds `X-Vertex-AI-LLM-Request-Type: dedicated` for the reservation, which turns an over-cap request into a 429 `Exceeded the Provisioned Throughput` that the proxy can route deliberately. Everything else is pinned `shared` so it can never draw down the reservation. Generic per-project 429s are explicitly *not* treated as overflow — buying on-demand capacity to work around backpressure would be a cost bug. `test_generic_rate_limiting_is_not_converted_into_extra_spend`. ## The migration needs no deploy, flag, or date When the `gemini-3.1-flash-lite` PT order provisions (~10 business days), the first overflow attempt asks it for `dedicated` capacity. That single request *is* the detection: if the order exists it succeeds and the proxy latches the promotion permanently; if not it 429s and falls through to the same on-demand call it would have made anyway. Detection therefore costs no extra request and only happens when the old reservation is already full. `test_a_successful_dedicated_probe_promotes_the_reservation` covers the whole mechanism. ## Why dedicated traffic is gated rather than moved now Moving `gemini-2.5-flash` onto an on-demand model before the replacement order is live would pay the flat ~$290.32/day for idle capacity **and** full on-demand for ~597M tokens/day — strictly worse than either alone. `test_flash_stays_on_the_current_reservation_until_target_capacity_exists`. **Operator follow-up:** promotion is the code-side cutover only. The 5 GSU `gemini-2.5-flash` order bills until ~2027-05-28 regardless, so converting or cancelling it in Cloud Console is a separate commercial action — until that happens, both are billed. ## Failure class `FC-degraded-fallback-consumes-protected-budget` (PR #10686) applies with a new edge: once `gemini-3.1-flash-lite` *is* the reservation, pinning overflow to it would dump degraded traffic onto the protected budget. `resolve_overflow_model()` is therefore a ladder resolved against the live reservation and structurally cannot return it, for this migration or any future one. `test_overflow_never_targets_the_live_reservation` asserts both states. ## Gemini 3.x changed the thinking contract 2.5 takes `thinkingConfig.thinkingBudget`; 3.x takes `thinkingConfig.thinkingLevel` and **cannot disable thinking** (floor `minimal`). Thinking tokens bill as output, and `thinkingBudget` stays schema-valid on 3.x — so a stale budget is accepted and then ignored, uncapping reasoning at $1.50/1M. `thinking_config_for()` selects by family prefix (same approach as `_CACHE_KEY_MODEL_PREFIXES`), and `_retarget_thinking()` rewrites the body when overflow crosses families. **Unverified:** whether 3.x hard-errors on `thinkingBudget` or silently ignores it could not be settled — `aiplatform.endpoints.predict` is denied to the read-only service account and no human ADC was live. The code is correct under either behaviour, but the real token counts are still worth capturing. `backend/scripts/probe_gemini_thinking_contract.py` reports `thoughtsTokenCount` per configuration; run it with credentials that can call `generateContent`. ## Overrides Read per request, so a bad promotion is correctable without shipping code. | Env | Effect | | --- | --- | | `OMI_VERTEX_PT_MODEL` | Pins the reservation model, beating auto-detection both ways | | `OMI_GEMINI_OVERFLOW_MODEL` | Pins overflow; rejected if it equals the reservation | | `OMI_GEMINI_OVERFLOW_ENABLED` | `false` disables overflow; a full reservation then 429s to the client | ## Testing - 18 new policy tests (`test_vertex_pt_routing.py`) and 18 new proxy tests - `test_desktop_proxy.py` + `test_vertex_pt_routing.py`: **77 passed** - Streaming ladder asserts every refused attempt is closed and its provider slot released (`test_streaming_overflow_falls_back_and_leaks_no_provider_slot`) — a leak there would drain the concurrency pool whenever the reservation saturated - `test_a_new_instance_probes_immediately_regardless_of_uptime` covers a bug CI caught that a dev machine cannot: `time.monotonic()` has an arbitrary origin, so seeding the last-probe time with `0.0` suppressed the first capacity probe for the first 10 minutes of process uptime. That is invisible on a laptop with days of uptime and would have applied to **every new Cloud Run instance**, which is most of an instance's life. The last-probe time is now an explicit `None` sentinel meaning "never probed". - Unrelated pre-existing failures, reproduced on base `d3b26f003f` without this change: `test_byok_security.py` fails only when run after other files (39F/4E; passes alone), and `test_prompt_caching.py` cannot import (`langchain_core.prompts` missing from the venv)
Summary
Product invariants affected
Failure-Class: none
Verification
bash backend/test.shbash desktop/macos/test.shmake preflight(20 checks passed)