Repository navigation
fix(backend): put the three basic-plan gates from #14165 behind default-off switches - #14316
Merged
Merged
Conversation
…lt-off switches #14165 merged a 402 on desktop proactivity completions, a 402 on Gemini proxy embeds, and a deterministic-minimum landing for flag-off desktop first-open and reprocess, all unconditional, while its description said production would stay ungated. The next routine production deploy would have switched all three on before any on-device replacement had shipped. Each gate now reads its own call-time env switch (default off, explicit true in dev, explicit false in prod, declared on every host of its code path). Off performs no authorize call and writes no marker. The S14 generate/stream proxy gate that is already live in production is unchanged. Failure-Class: new Co-Authored-By: Claude Fable 5.1 <[email protected]>
…kfill and admit only exact true/false Review follow-up. The backfill worker reprocesses existing desktop conversations through the gated branch and had no declaration, so dev would have run it ungated. The deploy validator also accepted 'on', '1' and padded literals that utils.free_tier_basic_gates reads as off. Failure-Class: new Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ployment config Failure-Class: new Co-Authored-By: Claude Fable 5.1 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Sep 21, 2026
…he deploy path (dev only, inert on merge) (#15334) ## Summary Plumbs the free-tier **on-device summary** rollout switch through the backend deploy path, so Stage 1 (Omi Beta, explicit accounts, Apple Foundation Models only) can be lit by setting one GitHub Actions variable instead of an out-of-band `gcloud` edit. **Merging this widens exposure to nobody.** Production is dark by construction. In development the cohort is one test account that was already admitted (see "State found before merge"). Decision this implements (David, 2026-09-21): desktop on-device summarization ships on AFM only; no second local engine. Record: `omi-knowledge-base:projects/local-models-free-tier/evidence/2026-09-21-afm-only-decision-and-ship-packet.md`. | Key | dev | prod | | --- | --- | --- | | `FREE_TIER_LOCAL_PROCESSING` | `true` | `false` | | `FREE_TIER_LOCAL_PROCESSING_COHORT` | from Actions variable `DEV_FREE_TIER_LOCAL_PROCESSING_COHORT`; **empty when unset** | literal empty | | `FREE_TIER_EMERGENCY_STOP` | `false` | `false` | `FREE_TIER_MEMORY_SUPPRESSION` is deliberately **not** plumbed: it has no on-device replacement, so lighting it would be takeaway without replacement. ### State found before merge (2026-09-21) The dev Cloud Run `backend` service already carried `FREE_TIER_LOCAL_PROCESSING=true` and a one-uid cohort (the basic-plan test account), set out-of-band by an earlier session and preserved by CI's merge-style env updates; no other host had it. Deploying this PR with the variable unset would have silently de-admitted that account, so `DEV_FREE_TIER_LOCAL_PROCESSING_COHORT` was set at `development` scope to that same single uid first (repo scope verified empty). Net effect of the merge: the same one account, now admitted consistently on all seven hosts, reviewable in config, with `FREE_TIER_EMERGENCY_STOP` available as a rollback. ### Why merging is otherwise inert `utils/free_tier_cohort` makes a lit flag mean "lit for the configured cohort" and admits **nobody** when the cohort is unset, empty or malformed. The only production call site passes a uid, and no metric or alert reads the boolean. ### Why production cannot be reached - All seven hosts render **literal** `false` / empty / `false` in `prod.overlay.yaml`; the renderer takes a literal `value` before it consults any environment source. - The production desktop workflow does not read a cohort variable at all. GitHub's `vars` context falls back from environment to repository scope, so "only set it on the `development` environment" is a convention, not a boundary; not reading it is the boundary. A test asserts the prod workflow contains no such reference. - `validate_free_tier_deploy_contract('prod', …)` rejects activation on any host, parametrized over every host path. ### Hosts `backend`, `backend-sync`, `backend-sync-backfill`, `backend-integration`, `backend-listen`, `pusher` (all reach `process_conversation`), plus `desktop-backend` (shares the emergency-stop reader). `backend-integration` was found by tracing importers; it is not in #14316's roster. ### Deploy-boundary validation The cohort is validated at render time for both transports (Cloud Run env and GKE ConfigMap): empty, or comma-separated `uid:<non-empty>`. **Percentages are rejected at deploy** even though the runtime parser supports them — Beta serves through the development plane on the production data plane, so a percentage would select real people by hash with no way to know whose Mac can run AFM. Newlines, CR, U+2028/2029 and NUL are rejected; commas are escaped for `deploy-cloudrun`; the GKE path writes an env file consumed by `kubectl --from-env-file`, so the value is never shell-evaluated. ### Found in independent review and fixed here A second-model adversarial review (read-only) confirmed production is dark under every input and flagged two hazards, both fixed in the second commit: 1. **Variable scope fallback** → production no longer reads the variable; the development one is named `DEV_…`. 2. **Pusher racing the ConfigMap key** → the `configMapKeyRef` is `optional: true`, so a pod that starts first starts dark rather than failing. Known and accepted: co-hosts snapshot the cohort at pod start, so after the variable changes, listener and pusher can briefly differ. At Stage 1 both directions are safe — the stale side simply summarizes in the cloud as today. The runbook redeploys the backend stack, then pusher. Also accepted: the multi-uid Cloud Run escaping test asserts the renderer's own transformation rather than gcloud's grammar; the backend and desktop deploy paths have a live post-deploy env readback. ## Product invariants affected - INV-DATA-1 — touched by path only (deploy workflows and the runtime-env manifest). No routing changes: no artifact is pointed at a different API, Auth, Firebase or Firestore endpoint, and no build define, CI variable or env value selects a data plane. The added keys gate summarization compute for an explicit cohort on the plane each artifact already uses. - INV-MEM-4 — touched by path only. `FREE_TIER_MEMORY_SUPPRESSION` is deliberately left unplumbed and unset, so memory formation is unchanged for every user in every environment. ## Verification Layer: **repository checks and unit tests only. Nothing was deployed and no live service was contacted.** - `bash backend/scripts/pre-deploy-check.sh` — 252 passed, plus source-admission fixtures. - Targeted: `test_free_tier_basic_gates` 137, `test_backend_runtime_env_validator` 42, `test_render_backend_runtime_env` 22, `test_render_gke_backend_config` 6, `test_verify_pusher_config_references` 119 — all pass. - `check_runtime_env_compose.sh` — generated `runtime_env.yaml` is current. `verify_pusher_cohost_env_diff.py` — dev and prod pass. `check_deployment_secret_boundary.py`, desktop-backend release policy (37) — pass. - `scripts/pr-preflight --pr-body-file …` — **passed, 54 checks**. CI: all checks green on `9de7e5ff9f`. One real failure was found by CI and fixed (`test_verify_pusher_cohost_env_diff` anchors on `REFERRAL_PUBLIC_BASE_URL` being the first listen env entry; the new keys were moved below it, the test untouched). Not verified: a live deployment, Helm rendering against a cluster, the full backend suite. ## To light Stage 1 after merge (not done by this PR) ```bash gh variable set DEV_FREE_TIER_LOCAL_PROCESSING_COHORT --repo BasedHardware/omi --env development --body 'uid:<uid-on-an-AFM-capable-Mac>' ``` then redeploy the development backend stack, then pusher. Success is the backend log line `free-tier: stored projected conversation … mode=store_projection` with `client_processing.provenance.model_id == "afm"`; `mode=deterministic_minimum` for a real user is the alarm. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Summary
PR #14165 merged three fail-closed basic-plan gates with no switch, while its body said "Prod stays ungated until a separate ask." Nothing enforced that: the next routine production deploy from
mainwould have turned all three on. This PR puts each gate behind its own default-off switch so the promise is a property of the runtime manifest, not of deploy timing.BASIC_PLAN_GATE_PROACTIVITY_ENABLEDplan_gatedon desktop proactivity completionsBASIC_PLAN_GATE_PROXY_EMBED_ENABLEDembedContent/batchEmbedContentsBASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLEDbackend/utils/free_tier_basic_gates.py, read env at call time, and use the same truthiness asFREE_TIER_LOCAL_PROCESSING(onlytrue).FREE_TIER_EMERGENCY_STOPforces all three off.authorize_managed_computecall, no new Firestore read, no terminal marker. Behaviour for that surface is whatmaindid before feat(desktop): fail-closed basic plan gate on proactivity, proxy embeds, and eager extraction #14165.desktop_backend_auto_dev.ymlset the switchestrue, so the Beta product (feat(desktop): fail-closed basic plan gate on proactivity, proxy embeds, and eager extraction #14165's intent) keeps its gates.falsein the prod overlay, prod Helm values, anddesktop_backend_prod.yml.generateContent/streamGenerateContentgate (free-tier S14, already live in production) is untouched and stays unconditional.Review
An independent adversarial review (Codex, read-only) found no defect in the off guards, the unchanged generate/stream gate, malformed or out-of-set proxy paths, the default-off test coverage, the preserved #14165 tests, or the emergency-stop interaction. It found three things, handled as follows:
backend-sync-backfillwas missing the eager-extraction switch. That worker reprocesses existing desktop conversations withforce_process=True, is_reprocess=True, so in dev it would have silently run ungated. It now declares the switch in both environments.on,1,' true '). Admission now accepts only exacttrue/falsefor this switch, with a parametrized test.Why now
Product ruling (2026-09-17): a free user gets the on-device replacement before a capability is taken away. On-device screen embeddings (#13456 / #13473) and an on-device summary engine have not shipped to a stable desktop release, so the embed and eager-extraction gates must not reach production yet. Each switch is flipped separately once its replacement is in users' hands.
Failure-Class: new
Product invariants affected
All three are cited because the change edits paths those invariants lock (
process_conversation.py, the desktop proactivity route, deploy/runtime configuration). No invariant's behaviour changes: with a switch on, the code path is byte-identical to #14165; with it off, it is identical tomainbefore #14165.Line-Count-Exception: backend/routers/desktop_proxy.py | 1692 -> 1699 | split the gated-action set so embed actions consult the rollout switch; generate/stream unchanged
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3167 -> 3171 | one extra condition on the existing flag-off eager-deny branch
Evidence
Hermetic local run (Google credentials blanked), Python 3.11:
The deselected test,
test_desktop_proxy.py::test_proxy_dispatches_server_paid_bodies_with_the_2048_cap, hangs locally on unmodifiedorigin/mainas well (same command, same timeout), so it is not introduced here; CI is the verdict for it.Coverage per gate: switch off → a basic non-BYOK caller reaches the provider /
_get_structuredand the authorize seam is never called; switch on → every #14165 test still passes (those tests now set the switch explicitly rather than being weakened); plus one test that the three switches are independent and one that the emergency stop overrides them. The runtime-env validator and the co-host contract assert the explicit per-environment values on every host of each code path.Layer measured: unit and manifest-composition tests only. No deployed revision has been observed; after merge, dev should show the gates still on and the next production deploy should show all three off.
🤖 Generated with Claude Code