Skip to content

fix(backend): put the three basic-plan gates from #14165 behind default-off switches - #14316

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/free-tier-basic-gate-switches
Sep 17, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/free-tier-basic-gate-switches

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

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 main would 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.

Switch Gate Hosts
BASIC_PLAN_GATE_PROACTIVITY_ENABLED 402 plan_gated on desktop proactivity completions desktop-backend
BASIC_PLAN_GATE_PROXY_EMBED_ENABLED 402 on Gemini proxy embedContent / batchEmbedContents desktop-backend, Cloud Run backend
BASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLED identified-basic desktop first-open / reprocess lands on the deterministic minimum Cloud Run backend, backend-sync, backend-sync-backfill, backend-listen, pusher

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-backfill was missing the eager-extraction switch. That worker reprocesses existing desktop conversations with force_process=True, is_reprocess=True, so in dev it would have silently run ungated. It now declares the switch in both environments.
  • The deploy validator accepted spellings the reader treats as off (on, 1, ' true '). Admission now accepts only exact true / false for this switch, with a parametrized test.
  • The isolated JIT QA plane does not declare the switches, so they default off there. Left as is on purpose: that plane qualifies JIT against the behaviour it was provisioned with, its environment is pinned by a reviewed contract, and free-tier gating is qualified on the regular dev plane.

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

  • INV-DATA-1
  • INV-MEM-4
  • INV-TASK-2

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 to main before #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:

tests/unit/test_free_tier_basic_gates.py                      36 passed
tests/unit/test_desktop_proactivity.py                        61 passed
tests/unit/test_desktop_proxy.py, test_free_tier_entrypoint_matrix.py,
test_process_conversation_free_tier_branch.py, test_backend_runtime_env_validator.py,
test_conversation_notes_v2_beta_rollout.py, test_verify_pusher_config_references.py
                                                              458 passed, 1 deselected

The deselected test, test_desktop_proxy.py::test_proxy_dispatches_server_paid_bodies_with_the_2048_cap, hangs locally on unmodified origin/main as 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_structured and 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

Review in cubic

Git-on-my-level and others added 3 commits September 17, 2026 14:08
…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
Git-on-my-level merged commit ff99d74 into main Sep 17, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/free-tier-basic-gate-switches branch September 17, 2026 08:24
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)
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