Skip to content

feat(backend): fold free-tier gates into ladder capabilities - #22238

Merged
Git-on-my-level merged 13 commits into
mainfrom
feat/ladder-free-tier-fold
Oct 19, 2026
Merged

Git-on-my-level merged 13 commits into
mainfrom
feat/ladder-free-tier-fold

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Folds the backend free-tier gates into ladder-v1 entitlements and client-capability contracts, per David's 2026-10-18 DEC-FREE-004/005 ruling. Builds on #21488 and #22141.

Gemini embedContent/batchEmbedContents return 402 plan_gated with Pro upsell only when the request sends X-Omi-Local-Embeddings: 1, the account lacks cloud_screen_vectors, and the refusal switch is on. Free and ladder Plus lack the capability; Pro/Architect and all recognized grandfathered paid legacy prices retain it. Old clients without the header retain pass-through behavior; validated request-owner Gemini BYOK stays exempt. Catalog revision 10 owns the capability, including the additive subscription response signal.

At ladder-budget or halt-at-cap denial, accepted schema-v1 client summaries remain display-only projections. The raw capture stays processing_deferred in the user-controlled backlog, with no Omi provider calls, memory/task fan-out, summary-vector replay or automatic smart merge. Reset does not authorize backlog processing. Explicit later processing can enrich the capture and clear the old no-effects marker. No-summary and summary-switch-off cases retain the raw backlog. The eager-extraction and local-processing terminal-minimum policy is removed.

Proxy, subscription signal and screen-vector persistence share read-only billed identity authority. In mixed ladder configuration, Stripe-backed rows require the actual subscription price, including stale/missing stored prices; unknown authority yields temporary unavailable instead of inventing a legacy grant or Free upsell. Vector-bearing sync returns retryable 503 without successful batch acknowledgement when authority is unavailable. OCR-only sync needs no billing read. Bounded identity caching uses 60-second success/5-second failure TTLs, a 5-second provider timeout and no retries. Legacy-only hot paths require no provider read or new credential. Explicit GET subscription refresh retains the previous Stripe price refresh, including unknown legacy IDs, before old-client wire remapping. Optional signal outages preserve the subscription response.

Both replacement flags ship on by default; exact false disables:

Added runtime env key Controls
CLOUD_SCREEN_VECTORS_EMBED_REFUSAL_ENABLED Header-conjoined embed refusal
CLIENT_SUMMARIES_AT_CAP_ENABLED Acceptance of new client summary projections
SCREEN_VECTOR_STRIPE_API_KEY Optional restricted subscription-read key preferred by shared billing identity reads; a credential, not a feature flag

Removed runtime env keys (code, startup/deploy validators, charts, runtime_env*, existing workflow lines, registry/config):

  • BASIC_PLAN_GATE_PROXY_EMBED_ENABLED
  • BASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLED
  • FREE_TIER_LOCAL_PROCESSING
  • FREE_TIER_LOCAL_PROCESSING_COHORT
  • FREE_TIER_EMERGENCY_STOP (backend plumbing only; no surviving backend consumer after main cleanup)

The six existing LADDER_V1_{PLUS,PRO,ARCHITECT}_{MONTH,YEAR}_PRICE_ID runtime references now reach every API host, including backend-listen/pusher through the existing shared ConfigMap and desktop-backend. Omitted values preserve operator-owned existing values in both Cloud Run and GKE; they never render implicit empty assignments. Environment-bound GitHub values are resolved at deployment steps.

Desktop selects customer-billing-realm references separately from ordinary main-dev billing. Added selected-environment GitHub variable names:

  • DESKTOP_LADDER_V1_PLUS_MONTH_PRICE_ID
  • DESKTOP_LADDER_V1_PLUS_YEAR_PRICE_ID
  • DESKTOP_LADDER_V1_PRO_MONTH_PRICE_ID
  • DESKTOP_LADDER_V1_PRO_YEAR_PRICE_ID
  • DESKTOP_LADDER_V1_ARCHITECT_MONTH_PRICE_ID
  • DESKTOP_LADDER_V1_ARCHITECT_YEAR_PRICE_ID
  • DESKTOP_SCREEN_VECTOR_STRIPE_READ_SECRET

The last maps to renderer-only SCREEN_VECTOR_STRIPE_READ_SECRET, a validated Secret Manager resource name, and mounts runtime SCREEN_VECTOR_STRIPE_API_KEY. Desktop never receives the main write-capable Stripe key. Supplied desktop ladder price references require the restricted read-secret reference before rendering. The renderer cannot inspect retained live settings: before any effective mixed-ladder desktop deployment, including retained bindings, an operator must separately provision and authorize a subscription-read-only key in the correct customer billing realm. The renderer validates the selected resource reference before deployment. The existing deploy step binds that same immutable selected-environment variable directly, omitting the whole assignment when empty; resource-reference mappings are not copied through GITHUB_OUTPUT. This PR defines source plumbing only; no actual price/key/reference, IAM or live configuration was created or changed.

After the overlapping cleanup on main removed its last backend consumer, unused FREE_TIER_EMERGENCY_STOP backend declarations and cohort plumbing are removed too. The separate macOS remote-stop registry surface and desktop OMI_FREE_TIER_LOCAL_PROCESSING override remain. The macOS API client currently does not consume the additive cloud_screen_vectors field; wiring its legacy-Plus screen policy to that signal remains a separate desktop follow-up. This PR keeps the requested backend boundary.

Later operator cleanup: env merge never removes retired keys. Remove the original four retired runtime keys above wherever retained, plus unused backend FREE_TIER_EMERGENCY_STOP where present. Previously declared hosts in both dev/prod were backend (all four), backend-sync/backend-sync-backfill (eager/local/cohort), backend-integration (local/cohort), desktop-backend (proxy/local/cohort), backend-listen/pusher (eager/local/cohort); dev shared ConfigMap also held the cohort. DEV_FREE_TIER_LOCAL_PROCESSING_COHORT and action input dev_free_tier_local_processing_cohort are retired too. A read-only Cloud Run env-name audit on 2026-10-19 confirmed the following leftovers in BOTH based-hardware (ro-prod) and based-hardware-dev (ro-dev), all in us-central1. Only env names were read; no env values, account data or Secret Manager payloads were read, and no live cleanup occurred:

Live Cloud Run service (dev and prod) Retired keys still present
backend All five retired runtime keys above
backend-sync, backend-sync-backfill BASIC_PLAN_GATE_EAGER_EXTRACTION_ENABLED, FREE_TIER_LOCAL_PROCESSING, FREE_TIER_LOCAL_PROCESSING_COHORT, FREE_TIER_EMERGENCY_STOP
backend-integration FREE_TIER_LOCAL_PROCESSING, FREE_TIER_LOCAL_PROCESSING_COHORT, FREE_TIER_EMERGENCY_STOP
desktop-backend BASIC_PLAN_GATE_PROXY_EMBED_ENABLED, FREE_TIER_LOCAL_PROCESSING, FREE_TIER_LOCAL_PROCESSING_COHORT, FREE_TIER_EMERGENCY_STOP

GKE/backend-listen/pusher and the shared ConfigMap entries above are source declaration inventory; their live state was not queried. Missing old keys cannot break startup; stale values cannot restore removed policy.

Rollback: set either replacement flag to false in a separately authorized config change, or revert the PR. No PR merge, deployment, production flag changes or production account data access. GCP tiers: ro-prod and ro-dev for the env-name-only audit; no operator or human tier used. No task Firestore index changes and no new workflows.

Validation: serial backend/test.sh focused suites, including flag-off/legacy parity, proxy admission, projection/backlog consent, authority/cache/error/retry behavior, runtime rendering and all-API-host bindings. Catalog/runtime/registry/generated-contract checks and typecheck pass (zero errors). Offline loopback HTTP smoke covered proxy and cap-summary/raw-backlog paths with outbound networking blocked. Validation at 719a308: full PR preflight passed all 81 selected checks; 431 focused tests passed serially through backend/test.sh under nice, including the two previously failing CI files and subscription-router parity. Loopback proxy and from-segments HTTP smoke re-ran successfully with outbound networking blocked. The deployment binding follow-up at 792aa0c passed 323 focused config assertions, plus the final 103 renderer/GKE assertions, actionlint, dev/prod workflow validators and deployment-secret-boundary checks. No thresholds, exemptions or allowlists were widened. Targeted Flutter storefront test passed after aligning its catalog revision assertion; pricing/copy remain unchanged. Current-head functional/platform suites passed; the CI gate remains non-green because CodeQL fails. GitHub owns the live check state, including metadata refreshes after description edits. Backend unit suite, hermetic backend tests, desktop contracts, Dart tests, Swift contracts, iOS compile and Android emulator acceptance all passed. CodeQL alert #462, py/clear-text-storage-sensitive-data in the shared runtime renderer, is also open on main 88a53a140308; main analysis 1977408925 and head analysis 1977549324 have the same rule, path and primaryLocationLineHash=f0506294151592aa:1. The desktop-specific output copy was removed; the remaining shared finding is not dismissed or suppressed, and CI remains non-green. No skip hatch or check weakening was added. Independent Grok-family review via agentctl approved exact head 792aa0c0d676b7260da77f9ab0ee942a512683b4, found no verified product/deploy defect and reported 667 targeted tests passing serially (12 files) with ambient Google credentials disabled. Review did not edit source or reclassify the CI failure. No hosted-provider or deployed-runtime acceptance claimed.

INV-MEM-4: Client summaries and screen vectors remain derived views, with no new canonical intake or promotion authority.
INV-MEM-1: Display-only client summaries do not become canonical memory input.
INV-TASK-2: At-cap captures run no task writer or proposal fan-out; existing funded processing authority is preserved.
INV-AUTH-1: BYOK requires validated request-owner authority; subscription capability comes from read-only account billing identity.
INV-DATA-1: No account writes, credential provisioning, deployment or storage-authority changes; unknown vector authority is retryable without false delivery acknowledgement.
INV-CHAT-1: Generated contract changes are additive; no chat timeline behavior changes.
Failure-Class: none
UI-Evidence: none -- backend admission, projection persistence and generated optional subscription contracts; no rendered UI changes.

Line-Count-Exception: backend/routers/conversations.py | 2365 -> 2366 | Import shared summary acceptance at the existing validation boundary; policy stays in its utility.

Line-Count-Exception: backend/routers/developer.py | 2759 -> 2760 | Use the shared summary acceptance predicate at developer ingress without copying policy.

Line-Count-Exception: backend/routers/users.py | 2679 -> 2715 | Return the additive catalog capability from shared real-price authority before old-client remapping; keep existing route and response resilience.

Preserve paid legacy cloud vectors and header-gate capable local clients. Keep client summaries as consent-bound budget backlog projections, including reset, retry, vector and merge paths.

Failure-Class: none
@mintlify

mintlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
omi 🟢 Ready View Preview Oct 19, 2026, 12:03 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T01:08:54.952556Z 792aa0c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f2127ea281

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/routers/desktop_proxy.py Outdated
subscription = users_db.get_user_valid_subscription(
uid, provision=False, firestore_client=get_customer_firestore_client()
)
return resolve_subscription_entitlements(subscription or {'plan': 'basic'})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Supply ladder price bindings to desktop-backend

When this gate handles a ladder-v1 subscriber, resolve_subscription_entitlements can recognize the price only through the six LADDER_V1_*_PRICE_ID environment variables, but neither inspected desktop deployment (desktop_backend_auto_dev.yml nor desktop_backend_prod.yml) supplies any of them. Because desktop-backend is deployed separately, a ladder Plus price therefore falls through as unknown and receives legacy Plus capabilities, where cloud_screen_vectors is true; requests with X-Omi-Local-Embeddings: 1 consequently bypass the intended 402 gate. Pass the ladder bindings into both desktop-backend workflows or persist an entitlement version that this service can resolve independently.

AGENTS.md reference: backend/AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

Comment thread backend/routers/users.py Outdated
Comment on lines +1253 to +1255
response.cloud_screen_vectors = resolve_subscription_entitlements(
already_read.get('subscription') or {'plan': 'basic'}
)['capabilities']['cloud_screen_vectors']

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use the refreshed price for the capability response

When Firestore has a missing or stale current_price_id, _user_subscription_response copies that record into already_read before retrieving the current Stripe price and updates only the separate response object afterward. These added lines therefore resolve cloud_screen_vectors from the stale copy: for example, a Plus account whose current Stripe price is ladder-v1 is reported with legacy Plus's true capability instead of ladder Plus's false, even though this request has already fetched the authoritative price. Update the entitlement snapshot after the Stripe refresh, or resolve this field from the refreshed subscription before any legacy fallback.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9355eae61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread backend/routers/desktop_proxy.py Outdated
Comment on lines +1418 to +1421
subscription = users_db.get_user_valid_subscription(
uid, provision=False, firestore_client=get_customer_firestore_client()
)
return resolve_subscription_entitlements(subscription or {'plan': 'basic'})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve ladder prices before granting legacy vector access

When a ladder Plus subscriber's Firestore row has a missing or stale current_price_id, this gate reads only that row and resolve_subscription_entitlements falls back to the stored Plus plan's legacy cloud_screen_vectors: true capability. Consequently, requests with X-Omi-Local-Embeddings: 1 bypass the intended 402 indefinitely; the subscription endpoint's Stripe refresh updates only its in-memory copy and does not repair the row used here. Persist an authoritative price/entitlement version or avoid granting the legacy capability when price identity is unresolved.

Useful? React with 👍 / 👎.

Comment on lines +270 to +271
- name: CLIENT_SUMMARIES_AT_CAP_ENABLED
value: "true"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Supply ladder price bindings to backend-listen

The Cloud Run and desktop-backend manifests now receive all six ladder price IDs, but neither backend-listen Helm values file nor its shared ConfigMap carries them. Since api.omi.me is served by backend-listen and desktop_screen_crisp calls grants_cloud_screen_vectors there, even a correctly persisted ladder Plus price is unknown on this host and falls back to legacy Plus's cloud_screen_vectors: true, allowing uploaded vectors to be stored; the subscription route served there also reports the wrong capability. Add the ladder bindings to both backend-listen environments and keep them aligned with the runtime manifest.

AGENTS.md reference: backend/AGENTS.md:L153-L153

Useful? React with 👍 / 👎.

Comment thread backend/models/users.py
Comment on lines +277 to +278
# Server catalog capability, independent of BYOK and usage-budget availability.
cloud_screen_vectors: Optional[bool] = None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Consume the screen-vector capability in the macOS client

Although this adds cloud_screen_vectors to the subscription response, the macOS UserSubscriptionResponse decoder in APIClient+Settings.swift has no corresponding field and ScreenEmbeddingPolicy still derives authorization solely from the plan. A legacy Plus subscriber therefore ignores the server's new true capability and remains in the policy's default no-Gemini branch, losing the cloud vectors that this catalog explicitly preserves for legacy paid prices. Add the optional field to the macOS response and make the entitlement cache/policy use it, while treating absence from older servers as untrusted.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit def12bf into main Oct 19, 2026
76 of 77 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/ladder-free-tier-fold branch October 19, 2026 01:38
Wizard815 pushed a commit to Wizard815/omi-local that referenced this pull request Nov 25, 2026
scripts/failure-class fails closed when a changed definition has a
scope_hint matching no tracked file. The upstream sync adds every
upstream definition at once, so it trips on four hints whose files
upstream itself has since removed:
- desktop/windows/src/main/jit/** (BasedHardware#20494, BasedHardware#22209), in
  FC-client-rederives-authority-verdict and FC-sync-gated-on-consumer-trigger;
- backend/utils/free_tier_cohort.py (BasedHardware#22238) and free_tier_memory_policy.py
  (BasedHardware#22209), in FC-cohort-gate-consulted-without-its-subject;
- backend/utils/task_intelligence/rollout.py (BasedHardware#18722), in
  FC-gate-principal-outside-consolidated-entitlement.

Each definition keeps its remaining, live hints.

Verification: scripts/pr-preflight --suggest reported exactly these four
scope_hint_matches_nothing errors before; git cat-file confirms none of
the paths exist on upstream/main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0148HLrpWR8Mimn43rkNvGKg
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