Skip to content

chore(plan-catalog): D2 — delete the BASIC_TIER_* env overlays from every serving identity - #13285

Merged
Git-on-my-level merged 8 commits into
mainfrom
chore/d2-drop-basic-tier-env-overlays
Sep 11, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
chore/d2-drop-basic-tier-env-overlays

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

D2 — delete the BASIC_TIER_* env overlays; plan_catalog.json is the only source of plan quotas

Program: plan-source-of-truth ruling carried by NOW.md item 4; free-tier direction review (omi-knowledge-base/projects/local-models-free-tier/evidence/2026-09-07-direction-review.md) §4 and §6 Move 3. Overnight run data/run-2026-09-09-overnight-margins (free-tier lane). Ratified product number: P9 — basic = 300 transcription minutes/month (basic.allocations.transcription = finite 18000 s in backend/config/plan_catalog.json).

Premise, re-verified live 2026-09-09 (read-only bots; env names + numeric literals only)

  • prod Cloud Run backend: BASIC_TIER_MINUTES_LIMIT_PER_MONTH=600, words/insights/memories =0; prod GKE backend-listen and pusher: 300, 0, 0; dev backend / backend-listen / pusher: 1000000, 0, 0. So B1 is still live: prod GET /v1/users/me/subscription advertises 600 free minutes while the listen plane enforces 300 and the catalog says 300.
  • The env overlay outranks the catalog at runtime by design (utils/subscription.py:_basic_transcription_overlay, _catalog_or_legacy_basic_limit), which is exactly the bridge whose docstring names D2 as its deletion.
  • The Cloud Run values are not in the repository: backend/deploy/runtime_env.yaml never declared them, and deploy-cloudrun env_vars merges rather than replaces, so a legacy variable survives every deploy until it is named in --remove-env-vars. A fourth name, BASIC_TIER_MEMORIES_CREATED_LIMIT_PER_MONTH, is live on both Cloud Run backend services and read by no code; it is retired with the other three.

What changed

  • backend/charts/backend-listen/{dev,prod}_omi_backend_listen_values.yaml, backend/charts/pusher/{dev,prod}_omi_pusher_values.yaml: the three BASIC_TIER_* entries deleted.
  • backend/deploy/runtime_env/_base.yaml (+ dev.overlay.yaml, which redefines forbidden_env for three services; + regenerated runtime_env.yaml): the four names declared forbidden_env on backend, backend-sync, backend-sync-backfill, backend-integration in both environments. The existing runtime-env validator turns that into (a) a required --remove-env-vars entry in the deploying composite action at validation time and (b) an absence check against the live service state.
  • .github/actions/deploy-backend-stack/action.yml (3 deploy blocks) and .github/actions/sync-backfill-lifecycle/action.yml: the four names appended to --remove-env-vars.
  • .github/agent-docs/plan-source-of-truth.md: D2 paragraph.
  • Code is unchanged. _legacy_overlay / _basic_transcription_overlay stay until the prod dispatch has removed the deployed values and the live check has proved it; then the bridge and its tests go in one follow-up. Deleting code that still guards a deployed 0 would be the inversion the docstring warns about.

Automatic-or-dead check

backend/tests/unit/test_plan_quota_env_retirement.py (15 cases):

  • re-adding any BASIC_TIER_* name to any of the four GKE charts fails the chart scan;
  • dropping forbidden_env from any of the four Cloud Run services in either environment fails the manifest pin;
  • dropping a name from a deploy action's --remove-env-vars (or from the backfill clone step's REMOVE_ENV_VARS) fails the real workflow validator (_validate_cloud_run_workflows driven over the repository's manifest and composite actions) — this is the behavioural check; the action-text scan next to it is a labelled static tripwire;
  • with no overlay present, utils.subscription resolves basic to 300 min / 18000 s and words/insights to catalog-unlimited (None), never to a finite zero.

Two lanes had to be fixed for those to be automatic rather than aspirational (review round 2):

  • the last case is @pytest.mark.slow, and the slow lane runs only files listed in backend/tests/slow_guardrail_manifest.txt — so the one behavioural assertion in the suite ran nowhere. The file is now listed.
  • select_backend_unit_tests.py returns False for backend/charts/**, so an edit to a chart, to either composite deploy action, or to runtime_env.yaml did not select this suite; only the unmapped-path full-suite fallback ran it, incidentally. The suite is now registered in backend/testing/workflow_contracts.json under backend_cloud_run_deploy and rendered_gke_deployment_identity, .github/actions/sync-backfill-lifecycle/** is a source there, and that path is in backend-unit-tests.yml (it was absent, so a PR touching only that action never started the backend unit job). Verified by running the real selector on all five paths: 5/5 now select it, 0/5 did before.

Standing limit, stated rather than papered over: the GKE plane has no deploy-time backstop — _validate_gke does not read forbidden_env — so for backend-listen and pusher the CI selection above is the only guard. The Cloud Run half is additionally enforced at deploy time (validate-backend-runtime-env.py --check-workflows inside deploy-backend-stack, and pre-deploy-check.sh), which the reviewer confirmed by mutation in both environments.

Proof

  • backend/.venv/bin/python -m pytest tests/unit/test_plan_quota_env_retirement.py -q — 15 passed
  • validate-backend-runtime-env.py --env dev|prod --check-workflows — both pass (and fail when a name is dropped from an action list; that is how the dev overlay's list-replacement was found and fixed)
  • verify_pusher_cohost_env_diff.py — OK (the names left both co-hosts together, so no allowlist entry was needed)
  • check_runtime_env_compose.sh — up to date

What happens on deploy (state this out loud)

  • Enforcement does not move on either plane (corrected by review): resolve_transcription_allowance reads transcription_allowance_seconds, which is catalog-only (utils/subscription.py:1640-1651), and every socket/credit check routes through it (:1741-1757, routers/listen/runtime.py:563). Dev and prod already enforce 300. What the overlay still controlled was the advertised number (get_plan_limits → _effective_plan_limit, :979-988, :1314-1316) and the plan copy (:1362-1376).
  • dev (auto on merge): GET /v1/users/me/subscription for a basic account reports 300 instead of 1,000,000; nothing else changes.
  • prod (David's dispatch, gcp_backend.yml + listen/pusher Helm): the API stops advertising 600 and reports the 300 the listen plane already enforced. This closes B1. Expect backend/scripts/pre-deploy-check.sh --live (the prod hotfix runbook's pre-step) to fail once on the forbidden-env check until that dispatch has removed the live variables — that is the check working, not a regression.
  • Scope of the live read: nine serving identities — four Cloud Run services, four GKE deployments, and Cloud Run desktop-backend (added in round 2). desktop-backend runs the same backend/ tree and imports utils.subscription, but it is not in the cloud_run.services manifest and its manifest section has no forbidden_env support, so it is covered by evidence, not by a gate: read live on 2026-09-09 in dev and prod, it carries none of the four names, and no desktop router reads a plan transcription limit. The six Cloud Run jobs were not read and declare no forbidden_env for these names; if a job carries one it is inert (no reader).
  • Rollback = re-adding the variable to the chart / manifest; the catalog itself is unchanged.

Cut list

  • Deleting _legacy_overlay and the PLUS_TIER_MINUTES_LIMIT_PER_MONTH / *_CHAT_QUESTIONS_PER_MONTH chat overlays (not deployed anywhere read this pass; separate follow-up with the bridge)
  • is_overage_plan removal (P11) and wire_plan_for_client (Q6)
  • Any change to plan_catalog.json values
  • Prod dispatch

Adversarial review (opus reviewer, 2026-09-09) — every finding fixed or rebutted

  1. should-fix, fixed (body): the headline claimed dev/prod basic minutes change; enforcement is catalog-only already, only the advertised number and copy change — rewritten above.
  2. verified sound: no independent os.getenv reader of the four names survives (_legacy_overlay only; reset_transcription_usage.py mentions one in a docstring, which goes stale after the prod dispatch — noted for the bridge-deletion follow-up).
  3. verified sound: no API shape change (0→None was already the legacy mapping; routers/users.py:1218,1312 emit 0 either way; routers/users.py:1274 recomputes limits per request, so no persisted 600 survives).
  4. verified sound: no other plan-quota overlay is deployed anywhere.
  5. verified empirically by the reviewer: dropping a name from either composite action fails _validate_cloud_run_workflows for the right service in both environments (sync-backfill-lifecycle is expanded via _load_local_composite_action).
  6. note, added to the body: the live forbidden-env check runs post-deploy in CI; the operator-run pre-deploy-check.sh --live fails once on prod until the dispatch.
  7. note, stated: Cloud Run jobs are outside the manifest pin; only the eight serving identities were read.
  8. verified: 234 tests across the retirement suite and its neighbours pass; module state restored.
  9. verified sound: an over-quota basic account resolves on_device, never an error; omi-release-probe has no transcription exemption before or after (unchanged).

Product invariants affected

  • INV-MEM-4 — backend/deploy/runtime_env.yaml is touched only to declare four retired BASIC_TIER_* plan-quota names as forbidden_env; no memory intake, promotion, or consolidation path changes.

How it was verified

Unit suite, runtime-env validators (manifest + workflows) for both environments, cohost gate, compose check; live env names on eight serving identities read with the read-only bots.

Tests

  • backend/tests/unit/test_plan_quota_env_retirement.py — 15 passed

Adversarial review round 2 (opus reviewer, 2026-09-09) — findings and resolutions

The reviewer's verdict was that the configuration change is correct and complete for the identities it names, and that the defects were in the automatic-or-dead layer: three of its four bullets described checks CI does not run on the change that would break them.

  1. must-fix, fixed in the head before this round (cubic follow-up) and confirmed: test_catalog_is_the_only_source_when_no_overlay_is_present is slow-marked and the slow lane runs only manifest-listed files, so it executed in no lane. Listed.
  2. must-fix, fixed: the chart scan and deploy-action scan were not selected by the files they guard, so re-adding BASIC_TIER_MINUTES_LIMIT_PER_MONTH to a GKE chart passed CI and the deploy. Fixed via workflow_contracts.json + backend-unit-tests.yml; verified with the real selector (5/5 paths now select the suite, 0/5 before). See "Automatic-or-dead check".
  3. note, fixed: desktop-backend is a ninth serving identity that neither the enumeration nor plan-source-of-truth.md's absolute sentence accounted for. Read live in both environments (clean) and the doc now states the covered scope instead of the absolute.
  4. note, accepted, not fixed here: test_deploy_action_remove_lists_name_every_overlay requires every --remove-env-vars= occurrence in both action files to carry all four names, so an unrelated future Cloud Run deploy block will be forced to carry them. It is a labelled static tripwire; loosening it belongs with the bridge-deletion follow-up that removes the names entirely.
  5. note, folded into the bridge-deletion follow-up: a second stale doc reference beyond reset_transcription_usage.py — app/test/unit/l10n_free_tier_minutes_test.dart:8-12 says "the backend env remains the source of truth". The number (300) stays right; the attribution goes stale after the prod dispatch.
  6. verified sound (reviewer ran each): all four GKE charts stripped and no chart/template/ConfigMap declaration remains; forbidden_env reaches the generated manifest for all four Cloud Run services in both environments and the dev overlay's list-replacement re-lists HOSTED_PUSHER_API_URL correctly; deleting a name from either composite action fails _validate_cloud_run_workflows for the right service in both environments (mutation-tested); the complete reader set is _basic_transcription_overlay and _catalog_or_legacy_basic_limit and nothing else, so removing the env cannot flip finite-zero ↔ unlimited in either direction; resolve_transcription_allowance is catalog-only and every socket/credit check routes through it, so enforcement does not move; routers/users.py:1274 recomputes limits per request so no persisted 600 survives; no other service sets the four names and no Cloud Run job reads them; the pre-deploy validation is fed from the manifest, not from gcloud, so there is no deadlock before the dispatch; 226 checks in pre-deploy-check.sh, 142 in the plan/subscription neighbours and 200 in the deploy/runtime-env neighbours pass.

Round-2 proof: retirement suite 15 passed; retirement + runtime-env + rendered-contract + preflight neighbours 183 passed; test_workflow_contracts.py 26 passed; desktop-backend live env read in dev and prod (names only).

Failure-Class: none

🤖 Generated with Claude Code

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 12 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level
Git-on-my-level force-pushed the chore/d2-drop-basic-tier-env-overlays branch from 527da25 to 03e3d3d Compare September 9, 2026 11:21
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor follow-up for the two unresolved Cubic threads on this PR (both addressed in 03e3d3d, threads resolved):

1. Backfill clone step re-set the retired overlays (sync-backfill-lifecycle/action.yml, PRRT_...kpMO)
The four BASIC_TIER_* names were on the deploy --remove-env-vars flag but missing from the clone step's REMOVE_ENV_VARS, so the worker's env cloned from live backend-sync (which still carries them) would re-set them on backend-sync-backfill in the same deploy, nullifying the removal. Fixed by adding the four names to REMOVE_ENV_VARS, and the static tripwire (test_deploy_action_remove_lists_name_every_overlay) now also asserts REMOVE_ENV_VARS: entries carry the full retired set, so a future drop fails the unit lane.

2. Catalog-only check ran in no lane (test_plan_quota_env_retirement.py, PRRT_...kpMT)
test_catalog_is_the_only_source_when_no_overlay_is_present is @pytest.mark.slow, but the slow-guardrail lane only runs files listed in tests/slow_guardrail_manifest.txt — the file was absent, so the check executed nowhere. Listed it; the lane now runs it (verified locally: slow lane selects 1/1, unit lane deselects it).

Verification: full file 15 passed; black --check clean; repo pre-push gate passed (CI is the full authority).

Git-on-my-level and others added 4 commits September 10, 2026 03:03
…very serving identity

plan_catalog.json is now the only source of plan quotas. The legacy
overlays outranked the catalog at runtime (utils/subscription.py
_basic_transcription_overlay), which is how the prod API plane advertised
600 free minutes while the listen plane enforced 300. Remove them from both
backend-listen charts and both pusher charts; declare them forbidden_env on
the four Cloud Run conversation services so the deploy strips them
(--remove-env-vars in deploy-backend-stack and sync-backfill-lifecycle) and
the live check finds them absent. The _legacy_overlay bridge stays until the
prod dispatch proves the deployed values gone.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The subscription-reload case is a per-test fresh module reload and belongs
in the slow-guardrail lane; the two cases that drive the real workflow
validator over the repository manifest and composite actions stay in the
unit lane under a duration-allowlist entry with the reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…tep and run the catalog check in CI

Cubic review follow-up on the D2 retirement:

- The backfill-runtime clone step reads live backend-sync (which still
  carries the BASIC_TIER_* overlays) and strips vars via REMOVE_ENV_VARS;
  the four retired names were missing there, so the clone would re-set
  them on backend-sync-backfill in the same deploy that removes them,
  nullifying the removal. Add the four names to REMOVE_ENV_VARS and
  extend the static tripwire to cover REMOVE_ENV_VARS entries.
- test_catalog_is_the_only_source_when_no_overlay_is_present is
  @pytest.mark.slow, but the slow-guardrail lane only runs files listed
  in tests/slow_guardrail_manifest.txt, so the check executed nowhere.
  List the file so the lane runs it.

Verified: 15 passed (full file); slow lane selects 1/1, unit lane
deselects it; black --check clean.
…uards; state the scope it actually covers

Adversarial review follow-up (2026-09-09):

- The chart scan and the deploy-action scan were not selected by the changes
  they guard. select_backend_unit_tests.py returns False for backend/charts/**
  except monitoring sources, so re-adding BASIC_TIER_MINUTES_LIMIT_PER_MONTH to
  a GKE chart passed CI, and the GKE plane has no forbidden_env backstop at
  deploy time either. Register tests/unit/test_plan_quota_env_retirement.py in
  workflow_contracts.json under backend_cloud_run_deploy and
  rendered_gke_deployment_identity, add .github/actions/sync-backfill-lifecycle
  as a source there, and add that path to backend-unit-tests.yml (it was not in
  the workflow's paths at all, so a PR touching only that action never started
  the backend unit job). Verified with the real selector: all four charts, both
  composite actions and runtime_env.yaml now select the suite; before, none did.
- plan-source-of-truth.md claimed flatly that no serving identity carries an
  overlay. Cloud Run desktop-backend is a ninth serving identity, is not in the
  cloud_run.services manifest and has no forbidden_env support, so it is covered
  by evidence not by a gate. Read live (dev + prod, read-only bots): it carries
  none of the four names, and no desktop router reads a plan transcription
  limit. Doc now says that instead of the absolute.

Tests: retirement suite 15 passed; retirement + runtime-env + rendered-contract
+ preflight neighbours 183 passed; test_workflow_contracts.py 26 passed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the chore/d2-drop-basic-tier-env-overlays branch from 06bdbbc to b4e9326 Compare September 9, 2026 20:14
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor follow-up (D2 plan-catalog):

  • The failing Listen Pusher Stack Gauntlet / Backend Hermetic Merge Gate on the previous head were a hermetic-harness port race, not a diff defect: in the cloud-memory-fence scenario the pusher app failed to bind ([Errno 98] address already in use) so the backend's trigger WS never answered and the harness timed out waiting for ready. Nothing in this diff touches the harness or port allocation; the same workflow was green on ~15 other branches in the same window.
  • Action taken: pushed the monitor's rebased branch (44 commits of upstream/main picked up; force-with-lease from 06bdbbc → b4e9326) to re-run the suite on a current base. The PR's test_plan_quota_env_retirement.py (15 tests) passes locally on the rebased head; full pre-push gate passed.
  • Post-push re-scan: all checks green on the final head (b422bfe, which also carries the origin/main merge); no new review threads.

…ier-env-overlays

# Conflicts:
#	backend/charts/pusher/dev_omi_pusher_values.yaml
The main merge ran the Dart formatter on incoming app files and made
this branch look like it touched INV-DATA-1 paths. Restore those files
to origin/main so the PR stays quota-overlay-only.

Failure-Class: none
Keep LLM_GATEWAY_ACCOUNTING_ENABLED from #13330 and the D2 BASIC_TIER
overlay retirement, then compose the checked-in manifest.

Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit 3d7d139 into main Sep 11, 2026
46 checks passed
@Git-on-my-level
Git-on-my-level deleted the chore/d2-drop-basic-tier-env-overlays branch September 11, 2026 17:04
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