Skip to content

chore(pusher): reach LLM_GATEWAY_ACCOUNTING_ENABLED to both pusher charts - #13330

Merged
Git-on-my-level merged 3 commits into
mainfrom
feat/free-tier-pusher-ledger-env
Sep 11, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
feat/free-tier-pusher-ledger-env

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Reach LLM_GATEWAY_ACCOUNTING_ENABLED to both pusher charts

The pusher is the third host of process_conversation (routers/pusher.py → process_conversation_task) and the only serving identity whose chart never declared the managed-spend ledger switch. This closes that gap and makes it a gated invariant rather than a thing anyone can drop.

Premise, corrected by review — read this before citing the record

The direction review (local-models-free-tier, 2026-09-07 §2.3, Move 1) reads as if the pusher were losing ledger rows. It is not, and this PR does not recover any. The static import graph from backend/pusher/main.py (which mounts only routers.pusher and routers.metrics) reaches 321 modules and never reaches utils/llm/managed_spend_ledger.py, routers/desktop_proxy.py or routers/omni_relay.py — the ledger's only two callers. Pusher-hosted process_conversation spends through the LLM gateway, which writes llm_gateway_attempts under its own identity.

So this is pre-positioning plus a drift gate, with zero runtime effect today: the switch is declared and pinned so that (a) a direct-provider surface mounted on the pusher later cannot be silently ledger-blind, and (b) the co-host env diff fails instead of drifting. Move 1's evidence gate (a) — "≥1 llm_gateway_attempts row whose caller is a pusher-hosted finalization" — is therefore not the right falsification for this change and should be restated in the program record; there is no such caller to produce a row.

What changed and why

  • backend/charts/pusher/dev_omi_pusher_values.yaml, backend/charts/pusher/prod_omi_pusher_values.yaml: LLM_GATEWAY_ACCOUNTING_ENABLED: "true", byte-identical to backend-listen's declaration in the same environment. Quoted string, not YAML true — the manifest validator compares against the literal 'true' and the reader lowercases a string, so the quoting is load-bearing. backend-listen declares no accounting companions (LLM_GATEWAY_ACCOUNTING_WRITE_TIMEOUT_SECONDS, …_MAX_PENDING_TRACES exist only on the llm-gateway charts); both hosts ride the module defaults, so mirroring the one name is the complete mirror.
  • backend/deploy/runtime_env/dev.overlay.yaml and prod.overlay.yaml: declare the name on the pusher identity (category: rollout, matching the other seven declarations), plus the regenerated backend/deploy/runtime_env.yaml.
  • backend/scripts/verify_pusher_cohost_env_diff.py: name promoted to REQUIRED_IDENTICAL_LITERALS and removed from LISTEN_ONLY_ALLOWED in both env blocks (leaving it would trip the stale_listen check).
  • backend/tests/unit/test_verify_pusher_config_references.py: the dev pusher literal inventory gains the fifteenth key (review must-fix 1).

Delivery path — state this out loud

Dev does not auto-deploy this today. Auto Deploy Backend Pusher to GKE (Development) triggers on backend/charts/pusher/** but has failed on every run for two days, in the image dependency smoke: missing installed dependency modules: ['typesense', 'typesense.exceptions', 'typesense.exceptions.ObjectNotFound'] (run 34377986501, and six before it). typesense==0.21.0 is in backend/requirements.txt but not backend/pusher/requirements.txt, while the pusher's copied source closure now reaches utils/conversations/typesense_index.py. Recorded at data/run-2026-09-09-overnight-margins/blocked/free-tier-dev-pusher-typesense-image-smoke.md; not fixed here (different lane, and the honest alternative is that a pusher path should not be importing conversation search at all). Since the change is inert, nothing is lost by the delay — but the contract lands now, so the next successful pusher deploy carries it. Prod is a manual dispatch either way.

Product invariants affected

  • INV-MEM-4 — backend/deploy/runtime_env.yaml is touched only to declare the ledger switch name on the pusher identity; no memory intake, promotion, or consolidation path changes.

Automatic-or-dead check

Two independent gates, both exercised by mutation rather than asserted:

  • Co-host env diff (verify_pusher_cohost_env_diff.py, wired at .github/checks-manifest.yaml lanes local+ci on backend/charts/pusher/** and backend/charts/backend-listen/**, and in both pusher deploy workflows): absent on pusher ⇒ missing on {…}; different from backend-listen ⇒ disagrees. Loops both environments.
  • Manifest ↔ chart (runtime_env_validation/manifest.py::_validate_gke): removing the chart entry yields missing env LLM_GATEWAY_ACCOUNTING_ENABLED; changing the value yields value mismatch: expected 'true'.

The co-host gate enforces agreement, not truthiness — both charts flipped to "false" would pass it. That case is caught by the manifest pin instead; test_ledger_switch_off_on_pusher_fails is named for the one-host case it actually covers.

How it was verified

  • pytest tests/unit/test_verify_pusher_cohost_env_diff.py tests/unit/test_verify_pusher_config_references.py — 34 passed (12 + 22). The config-references suite is the one this change breaks without the inventory fix; it is the load-bearing suite here, not the chart lint.
  • verify_pusher_cohost_env_diff.py against the repo charts — OK; dev pusher=67 / listen=123 / required-identical=5, prod 72 / 119 / 5.
  • check_runtime_env_compose.sh — up to date. validate-backend-runtime-env.py --env dev|prod --check-workflows — both pass.
  • check_product_invariants.py over the changed-file list — INV-MEM-4 is the only matching invariant and the body names it.

Cut list

  • Establishing whether the S0 relay writer (desktop_chat_realtime, 0 prod rows all-time) is off-path — separate probe (one floating-bar PTT turn on dev must produce exactly one row).
  • Fixing the dev pusher image smoke (typesense) — different lane; blocked record above.
  • Wiring shutdown_managed_spend_ledger() into backend/pusher/main.py — it is wired in backend/main.py and backend/desktop_backend.py but not the pusher, so a future pusher-hosted direct surface would not drain scheduled writes on SIGTERM. That is the second half of "make pusher ledger-capable" and belongs with the surface that first needs it, not with a chart declaration.
  • Any change to what the pusher actually spends on.

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

  1. must-fix, fixed: test_verify_pusher_config_references.py::test_rendered_dev_pusher_direct_bindings_match_source_contract pins the dev pusher literal set derived from the manifest against a hardcoded 14-key dict; the new key made it 15 and CI's Backend unit suite had not reported yet. Reproduced locally (1 failed, 21 passed), fixed, now 22 passed. No prod counterpart exists — that suite spot-checks four keys — which is why only dev failed.
  2. should-fix, fixed (body + chart comment): the "dry pen for one of three hosts" framing implied lost rows. Corrected above and in the chart comment, from the reviewer's 321-module import-graph walk.
  3. should-fix, fixed (body): the "what changed" list named only prod.overlay.yaml; the diff also changes dev.overlay.yaml and the generated manifest. Listed.
  4. should-fix, fixed (body): "mirror backend-listen's literal (and its companions)" — backend-listen declares no companions. Corrected.
  5. should-fix, fixed (body): "Dev auto-deploys on merge" was false; the auto-deploy lane is red on the typesense image smoke. Stated plainly above with the run id and a blocked record.
  6. should-fix, fixed (body): "verified by chart lint" named the wrong suite. The verification section now names the suite that actually fails without this change.
  7. note, adopted into the cut list: shutdown_managed_spend_ledger() is not wired into backend/pusher/main.py.
  8. note, fixed: the 11-line chart comment had a stray wrap and buried its one load-bearing sentence. Rewritten to 7 lines that lead with "not mounted here today".
  9. verified sound (reviewer ran it): exact literal mirror in both environments including quoting; no companion/sink/credential var missing (SERVICE_ACCOUNT_JSON already bound on the pusher chart, collection is a module constant, so there is no "switch on, no sink" hazard); the gate is genuinely automatic-or-dead in both environments and does not block unrelated deploys; the pusher is a modelled GKE identity in the manifest so the overlay edit is on-target; INV-MEM-4 is the only matching invariant and the citation is sufficient; the ledger write path is fire-and-forget (2-worker executor, 1000 pending cap, 1 s shielded timeout), so there is no hot-path cost even if a surface is adopted.

Failure-Class: none

…arts

The pusher is the third host of process_conversation and the only one whose
chart never declared the managed-spend ledger switch. Its gateway-routed
spend was already ledgered by the gateway; the switch is what any direct-
provider surface hosted here would read (utils/llm/managed_spend_ledger.py).
Mirror backend-listen's literal on dev and prod, and promote the name to the
co-host gate's REQUIRED_IDENTICAL_LITERALS so a missing or drifted value on
either process_conversation host fails every pusher deploy workflow.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@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.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

…ect the chart comment

Adversarial review follow-up:

- test_verify_pusher_config_references.py derives the dev pusher literal set
  from runtime_env.yaml and pins it against a hardcoded dict; adding the
  fifteenth key broke it (1 failed, 21 passed) and CI's Backend unit suite had
  not reported yet. Add the key: 22 passed.
- The chart comment implied the pusher was losing ledger rows. It is not: the
  pusher entrypoint's import graph never reaches managed_spend_ledger, so this
  is pre-positioning plus a drift gate with no runtime effect today. Rewrite it
  to lead with that, and drop the stray wrap.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Config-consistency chore, not a bug fix (explicitly 'pre-positioning, not a fix for lost rows') — approve-only per confidence gate. Diff read in full: only adds an env flag + verifier/test coverage, no workflow/credential changes despite author's standing elevated-scrutiny flag.

@Git-on-my-level
Git-on-my-level merged commit 16b1f91 into main Sep 11, 2026
39 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/free-tier-pusher-ledger-env branch September 11, 2026 16:47
Git-on-my-level added a commit that referenced this pull request Sep 11, 2026
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 added a commit that referenced this pull request Sep 11, 2026
…very serving identity (#13285)

* chore(plan-catalog): D2 — delete the BASIC_TIER_* env overlays from every 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]>

* test(plan-catalog): lane the D2 retirement checks by cost

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]>

* fix(plan-catalog): strip the retired overlays in the backfill clone step 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.

* fix(plan-catalog): select the D2 retirement suite from the files it guards; 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]>

* chore: drop merge-hook Dart format noise from D2 overlay PR

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

* chore(plan-catalog): regenerate composed runtime_env after main merge

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

Failure-Class: none

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: David Zhang <[email protected]>
Git-on-my-level added a commit that referenced this pull request Sep 16, 2026
…ds, and eager extraction (#14165)

## Summary

Track B (SCA-482): fail-closed basic gate on the three remaining
omi-funded desktop spend surfaces — no `FREE_TIER_*` flag flip, no
`BASIC_TIER_*` overlay change.

- **`desktop_proactivity` completions** — route-level
`authorize_managed_compute` gate on `proactive_completion` via the
per-operation model-config lane (`desktop_proactive_extraction` /
`desktop_proactive_reasoning`). Basic + omi-funded → `402 plan_gated`
before any quota or provider work; authorization outage → `503`; a
validated BYOK key for the lane's provider funds the call unchanged
(existing JIT contract, no second pipeline).
- **`desktop_proxy` Gemini embeds (TBD-4 closed)** — `embedContent` /
`batchEmbedContents` join `_PLAN_GATED_PROXY_ACTIONS`, sharing
`screen_frame_judge`'s Gemini provider binding so the BYOK exemption
stays provider-exact. Same 402 mapping as generate/stream.
- **Eager extraction (`process_conversation`, flag-off)** — first-open
(`force_process`) and manual reprocess of desktop conversations now
consult `resolve_free_tier_processing_plan` through the same
`_managed_compute_decision_for` closure the flag-on branch uses. An
**identified** basic deny lands at the deterministic minimum (terminal
store, `terminal_no_derived_effects`); identification failure and
authorization outages fail open, matching
`should_defer_desktop_processing`'s documented contract. Non-desktop
sources untouched — the summary flip stays held.
- **Instrument (DEV pusher)** — new
`test_pusher_conversation_ledger_instrument.py` pins both ledger halves
hermetically: gateway attribution headers (`X-Omi-LLM-Feature`) on the
`conv_structure` lane client, and the caller-side `managed_spend_ledger`
write gated on `LLM_GATEWAY_ACCOUNTING_ENABLED`. The flag is already
checked-in **true on both pusher charts**
(`backend/charts/pusher/{dev,prod}_omi_pusher_values.yaml`, PR #13330) —
no chart change needed in this PR.

`FREE_TIER_LOCAL_PROCESSING` / `FREE_TIER_MEMORY_SUPPRESSION` remain OFF
on every identity. `BASIC_TIER_*` overlays untouched. No prod env
mutation in this PR.

Failure-Class: FC-shared-spend-gate-missing-on-sibling-producers

## Product invariants affected
- INV-MEM-4
- INV-TASK-2

Line-Count-Exception: backend/routers/desktop_proxy.py | 1689 -> 1692 |
embedContent/batchEmbedContents join _PLAN_GATED_PROXY_ACTIONS (TBD-4
closed); no logic added
Line-Count-Exception:
backend/utils/conversations/process_conversation.py | 3101 -> 3167 |
flag-off identified-basic eager-deny gate: one helper + one branch
reusing the existing S6 policy and deterministic-minimum store, no
second pipeline


## Evidence

### Fail-closed sabotage proof (gate removed → red, restored → green)

| Sabotage | Guard | Result without gate | Result with gate |
| --- | --- | --- | --- |
| drop `await _enforce_proactive_plan_gate(...)` from the route |
`test_proactive_completion_rejects_basic_before_quota_or_provider` |
FAILED (provider spy reached) | pass |
| remove embed actions from `_PLAN_GATED_PROXY_ACTIONS` |
`test_gemini_proxy_rejects_basic_embed_content` | FAILED (provider spy
reached) | pass |
| delete the flag-off eager-deny `elif` |
`test_flag_off_first_open_basic_is_deterministic_minimum` | FAILED
(`_get_structured` called) | pass |

### Tests run (Python 3.11 venv, worktree base `origin/main` @
`d36cdaff41`)

```
.venv/bin/pytest tests/unit/test_desktop_proactivity.py tests/unit/test_desktop_proxy.py \
  tests/unit/test_free_tier_entrypoint_matrix.py tests/unit/test_process_conversation_free_tier_branch.py \
  tests/unit/test_pusher_conversation_ledger_instrument.py -q
→ 387 passed
black --line-length 120 --skip-string-normalization --check <8 changed files> → clean
```

Matrix harness note: expectations are derived from a three-way
`_outcome` helper (`process` / `legacy_defer` / `terminal`) — flag-on
desktop basic is always the policy minimum; `_legacy_defers` only
applies flag-off. Eager-gate-consulting legacy tests patch the authorize
seam so no test waits out a real Firestore fail-open (was 265–284s each,
now sub-second).

### Ledger / serving-env evidence (read-only inspect, env names only)

- GKE `dev-omi-gke` / ns `dev-omi-backend`: deployment `dev-omi-pusher`
live env **includes** `LLM_GATEWAY_ACCOUNTING_ENABLED` and
`OMI_LLM_GATEWAY_URL` (63 env names total) — matches the checked-in dev
chart.
- GKE `prod-omi-gke` / ns `prod-omi-backend`: deployment
`prod-omi-pusher` (15 replicas) live env **omits**
`LLM_GATEWAY_ACCOUNTING_ENABLED` (`OMI_LLM_GATEWAY_URL` present; 68
names total) — the live prod workload lags the checked-in chart from
#13330. Residual operator item: next prod pusher rollout picks the flag
up; no prod write performed here.
- `desktop_chat_realtime`: 0 prod ledger rows all-time (reported fact
from the S14 ledger review; unchanged by this PR — realtime is not on
this fail-closed path).

## Product scope

Named change (transcripts + search free; insights paid): DEV/beta `402
plan_gated` on proactivity + proxy embeds + eager extraction **is** the
intended beta product. Prod stays ungated until a separate ask. No
iOS/macOS floor bumps. BYOK-basic keeps the user-key path exactly as the
JIT contract defines it.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/14165?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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.

2 participants