Skip to content

feat(backend): plumb the free-tier on-device summary cohort through the deploy path (dev only, inert on merge) - #15334

Merged
Git-on-my-level merged 5 commits into
mainfrom
feat/free-tier-local-processing-deploy-plumbing
Sep 21, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
feat/free-tier-local-processing-deploy-plumbing

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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)

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

Git-on-my-level and others added 4 commits September 21, 2026 11:00
… deploys

Declare the dev-on/prod-off processing switch, empty-by-default Actions
variable cohort, and explicit emergency-stop value on listener, pusher,
backend, sync, sync-backfill, integration, and desktop-backend. Integration
was added after tracing main:app and its process_conversation caller.
Keep memory suppression unplumbed and unset.

Use the development environment variable FREE_TIER_LOCAL_PROCESSING_COHORT.
Shared UID-only deploy validation rejects malformed or percentage cohorts;
render escaped Cloud Run values and an optional GKE ConfigMap binding.
Preserve the validator import closure in immutable desktop prod controls.
Extend #14316 deployment tests and the existing CI capability checks.

Verification (repository-only, no network or deployment):
- Offline uv venv + uv pip sync backend/pylock.macos.toml: successful.
- make -o setup-main -o setup-backend setup: installed hooks; intentionally
  skipped network refresh and dependency re-sync after the offline setup.
- PATH="$PWD/backend/.venv/bin:$PATH" bash backend/scripts/pre-deploy-check.sh:
  252 pytest passed, 30 source-admission fixtures passed, dev/prod workflow,
  bucket, source-admission and OAuth contracts passed.
- BACKEND_UNIT_TEST_FILE_LIST=/tmp/free-tier-final-test.txt
  BACKEND_PYTEST_WORKERS=1 bash backend/test.sh: 137 rollout tests passed.
- Selected component run: all 220 assertions passed; one unchanged cohort
  sweep test exceeded CPU guard (0.48s/0.30s). Isolated same-runner retry:
  test_free_tier_cohort.py, 55 passed with unchanged timing guard.
- Other selected test.sh files: processing policy 30 passed; GKE renderer
  6 passed; conversation-notes rollout 6 passed.
- Real renderer/validator CLI smoke: 4 passed (dev/prod x empty/multi-UID),
  including Cloud Run state and ConfigMap output; synthetic identifiers only.
- bash backend/scripts/check_runtime_env_compose.sh: up to date.
- python .github/scripts/check_deployment_secret_boundary.py --base origin/main:
  passed.
- python backend/scripts/verify_pusher_cohost_env_diff.py: dev/prod passed.
- python .github/scripts/check-desktop-backend-release-policy.py: passed.
- python .github/scripts/test_check_desktop_backend_release_policy.py:
  37 passed.
- scripts/backend-python-format --check (13 changed Python files): passed.
- git diff --check: passed.

Not verified: live deployment, GitHub variable state, AFM product acceptance,
full backend suite, or Helm-dependent pusher tests (Helm explicitly forbidden).
The updated pusher literal expectation is additionally covered by static
chart/manifest tests. No assertions weakened or removed; no push performed.
…ction, and start dark when a pod races the ConfigMap

Independent review of the plumbing commit found two hazards before merge.
GitHub's vars context falls back from environment to repository scope, so the
production workflow no longer reads any cohort variable and the development one
is named DEV_FREE_TIER_LOCAL_PROCESSING_COHORT. The pusher/listener
configMapKeyRef is now optional: a rollout that starts before the backend lane
has written the key gets an unset value, which the cohort module treats as
admit-nobody, instead of failing to start.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…gistry, not AGENTS.md

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review September 21, 2026 04:34
test_verify_pusher_cohost_env_diff splices a probe key after 'env:' using that
entry as its anchor; inserting the free-tier keys above it broke the anchor.
Order within the list has no runtime meaning, so move the new entries below it
and leave the test alone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit f2320d8 into main Sep 21, 2026
61 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/free-tier-local-processing-deploy-plumbing branch September 21, 2026 05:28
Git-on-my-level added a commit that referenced this pull request Sep 21, 2026
…er cohort as an input (#15348)

## Summary

**Unbreaks every backend deploy from `main`.** #15334 (mine, merged 2026-09-21T05:28Z as `f2320d8762`) referenced `${{ vars.DEV_FREE_TIER_LOCAL_PROCESSING_COHORT }}` inside the composite action `.github/actions/deploy-backend-stack`. A composite action cannot read the `vars` context, so GitHub rejects the action at load time:

```
action.yml (Line: 543, Col: 44): Unrecognized named-value: 'vars'
Failed to load ./.github/actions/deploy-backend-stack/action.yml
```

Observed on "Auto Deploy Backend to Development" run 35565085049 for `8169b2eb88`. The same action is used by `gcp_backend.yml`, so a **production** backend deploy from `main` would fail the same way. It fails closed — nothing wrong was deployed — but nothing can be deployed either.

### Fix
The cohort becomes an action **input** (`dev_free_tier_local_processing_cohort`, default empty). Only the calling workflows read the variable: `gcp_backend_auto_dev.yml` passes it; `gcp_backend.yml` passes it only when the dispatch is for `development`, so a production run never carries it. The prod overlay still renders a literal empty regardless.

### Why it got through
The file is valid YAML; the wiring test asserted the exact `vars.…` string it should never have contained; an independent model review checked scope fallback and injection but not context availability; and nothing in preflight executes or context-checks a composite action. New test `test_no_composite_action_reads_a_context_it_cannot_access` scans every composite action's expressions for `vars.`/`secrets.`. **Verified red against `origin/main`** (3 offenders, lines 543/568/960) and green here.

Also verified: every job that reads the variable declares `environment:`, which an environment-scoped variable requires in order to resolve at all.

## Product invariants affected

- INV-DATA-1 — touched by path only (deploy workflow + composite action). No routing, endpoint, or data-plane selection changes.

Failure-Class: new

New class `FC-composite-action-reads-unavailable-context`, defined in this PR.

## Verification

Layer: **repository checks and unit tests. Not yet verified by a live deploy** — the first "Auto Deploy Backend to Development" run after merge is the real proof, and I will report its result on this PR.

- `actionlint` on both calling workflows — clean.
- `test_free_tier_basic_gates.py` — 138 passed, including the new context test and the updated caller-wiring assertions.
- `scripts/pr-preflight --pr-body-file …` — **passed, 42 checks**.

🤖 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