Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks @aryanorastar — narrow, well-targeted change. The lane isolation is real and correctly wired:
Two things for a human maintainer before merge:
No gating or billing semantics change here. Core stack gauntlets (Listen Pusher, Hermetic Backend E2E, Sync Cloud Tasks, Public Developer API contract) pass. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level CI is running now since I pushed the test timebomb fix earlier. |
|
Thanks — on your two notes: (1) agreed the accounting-vs-cap sequencing is a product call. This PR is accounting-only (no gating, no billing change), so it can land independently and leaves the cap as #7690's open decision. (2) Backend unit suite is green on this head; the earlier cancelled/skipped preflight/hygiene runs were fork-workflow gating rather than failures. |
kodjima33
left a comment
There was a problem hiding this comment.
Backend fair-use metering for custom-STT (isolated lane) — approve only; failing Desktop Swift checks + more feature than bug, needs green CI
|
Follow-up verification on the two open items from the earlier pass — both resolve cleanly. 1. CI status (was: "worth confirming preflight/hygiene are green"). Confirmed. The 2. Safe reuse of the VAD delta API. Two smaller confirmations, for the record:
Net: accounting-only, no gating/billing semantics change, isolation is real, tests are strong. Still a positive signal rather than a formal approval — this touches the fair-use metering surface and is the accounting half of an open product/policy issue (#7690), so the accounting-vs-cap sequencing call belongs with a human maintainer before merge. by AI on behalf of David — if you need David's attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level need human response — kodjima33 approved; accounting-only change with real lane isolation and strong tests. Ready for a maintainer to merge. |
Custom-STT sessions are exempt from transcription billing and live caps by design — but _flush_usage returned early for them before any recording, so their speech never reached the fair-use meter at all, while everything downstream (conversation structuring, memory extraction) still runs on Omi-paid LLM post-processing with no accounting (BasedHardware#7690). The speech now records into a new 'custom_stt' fair-use lane: valid in _VALID_SPEECH_SOURCES (an unknown source would coerce to 'realtime' and gate exempt users), excluded from LIVE_SPEECH_SOURCES so live enforcement never reads it — the same isolation contract sync_backfill already uses. Transcription usage recording stays skipped: no billing semantics change, nobody gets gated. Quantifying and capping the spend (the issue's policy questions) read this lane and are deliberately separate decisions. Regression tests (3 fail on old code): the lane records under its own Redis keys; the source is valid and outside live enforcement; a custom-STT session's flush meters speech into the lane and only the lane — recording transcription usage for one asserts a failure. Addresses the accounting half of BasedHardware#7690; capping policy remains open there. Failure-Class: none Co-Authored-By: Claude Fable 5 <[email protected]>
f68abeb to
9f9aab9
Compare
|
@Git-on-my-level need human response — this PR is approved, rebased onto latest |
## What changed and why Reverts the Omi-paid LLM post-processing gate from #7690 (commit `3c998bf`, PR #10962). Custom-STT users bring their own STT key. The gate skipped **all** LLM enrichment for their conversations — title, overview, memories, action items, embeddings, app results — unless they *also* carried an OpenAI/Anthropic BYOK key on the request. Bringing an STT key is not a request to lose summaries, and almost nobody carries a second LLM key, so in practice the cost cap read as "summarization is off" for the entire custom-STT population. Same story on the live photo path: `_process_photo` stored the literal string `Custom STT: photo description skipped (no LLM BYOK key).` instead of calling `describe_image`. ## Removed - The `process_conversation` gate and its deferred `is_byok_active` lookup. - The `_process_photo` gate in `routers/listen/receiver.py`. - `should_skip_custom_stt_postprocessing`, now unreferenced. ## Kept `Conversation.uses_custom_stt` and its creation / resume / merge plumbing. It is provenance only now — it keeps custom-STT spend queryable and feeds the isolated fair-use lane (#10127) — so the API contract and the generated Dart/OpenAPI clients are unchanged. Comments that described it as a cost gate were corrected to match. Cost visibility therefore survives the revert; only the enforcement is gone. If a cap is wanted later it belongs in the fair-use lane that already meters this traffic, keyed on actual spend rather than on a BYOK key almost no gated user holds. ## Product invariants affected - INV-MEM-4 - INV-TASK-2 Neither changes behavior here. The diff removes an early return, so custom-STT conversations now reach exactly the promotion and task-capture paths every other conversation already takes. No guard test needed updating. ## Failure class (fixes) Failure-Class: none The gate did what it was written to do; the policy behind it was wrong for the population it selected. This is a product-policy revert, not the repair of a violated code contract, so no class is declared and none is opened. ## Tests The two gate assertions are inverted into regression tests: a custom-STT conversation with no LLM BYOK key must run structuring, and a custom-STT photo must reach `describe_image`. The "hot path never reads BYOK state" deferral tests are dropped along with the deferral they guarded. ## Verification `cd backend && pytest tests/unit/<file>.py` (one file at a time): | File | Result | |---|---| | `test_process_conversation_usage_context.py` | 53 passed | | `test_listen_multichannel_mix_buffer_leak.py` | 5 passed | | `test_transcribe_decisions.py` | 25 passed | | `test_listen_process_pending_shutdown.py` | 13 passed | | `test_merge_audio_chunk_copy_failure.py` | 5 passed | | `test_shared_conversation_field_exposure.py` | 8 passed | | `test_byok_security_enrollment.py` | 34 passed | | `test_new_usage_tracking_gaps.py` | 45 passed | `make preflight` — all manifest checks pass. Not exercised against a live custom-STT session: that needs a real third-party STT key bound to an account. The behavior is covered at the `process_conversation` and `_process_photo` seams instead. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12663?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. -->
Revert the Omi-paid LLM post-processing gate from BasedHardware#7690 (commit 3c998bf). Custom-STT users bring their own STT key, and the gate skipped ALL LLM enrichment for their conversations unless they ALSO carried an LLM BYOK key: no title, no overview, no memories, no action items, no app results. Bringing an STT key is not a request to lose summaries, and almost nobody carries a second OpenAI/Anthropic key, so in practice the gate silently turned summarization off for every custom-STT user. Removed: - the process_conversation gate and its deferred BYOK lookup - the live-session photo gate that stored "Custom STT: photo description skipped" instead of calling describe_image - should_skip_custom_stt_postprocessing, now unreferenced Kept: the durable Conversation.uses_custom_stt marker and its creation/resume/merge plumbing. It is provenance only now — it keeps custom-STT spend queryable and feeds the isolated fair-use lane (BasedHardware#10127) — so the API contract and generated clients are unchanged. Comments that described it as a cost gate were corrected to say so. Tests invert the two gate assertions into regression tests: a custom-STT conversation with no LLM BYOK key must run structuring, and a custom-STT photo must reach describe_image. The now-moot "hot path never reads BYOK state" deferral tests are dropped with the deferral. Verification: cd backend && pytest tests/unit/<file>.py # one file at a time test_process_conversation_usage_context.py 53 passed test_listen_multichannel_mix_buffer_leak.py 5 passed test_transcribe_decisions.py 25 passed test_listen_process_pending_shutdown.py 13 passed test_merge_audio_chunk_copy_failure.py 5 passed test_shared_conversation_field_exposure.py 8 passed test_byok_security_enrollment.py 34 passed test_new_usage_tracking_gaps.py 45 passed Failure-Class: none
Summary
custom_sttlane that live enforcement never reads. Previously_flush_usagereturned early for these sessions before any recording, so the speech driving Omi-paid LLM post-processing (structuring, memory extraction) was invisible to every meter (Custom STT (BYOK) users: uncapped LLM/post-processing spend (no limit or accounting) #7690).LIVE_SPEECH_SOURCES— the same isolation contractsync_backfillalready uses ("metered, never live-enforced").get_rolling_speech_ms(uid, sources=('custom_stt',))— the reader already takes a sources tuple); whether to cap is the issue's open policy question and deliberately not decided here.Addresses #7690 (accounting); capping policy remains open there.
Root cause
use_custom_sttshort-circuits_flush_usagebefore bothrecord_speech_ms(fair-use meter) andrecord_usage(usage stats). The exemption was designed for transcription billing but silently swallowed all speech accounting with it — so the existing fair-use machinery never sees these users at all, exactly as #7690 describes.Why a lane, not a flag
The fair-use engine already models this: sources are lane-isolated by key (
fair_use:v2:*:{source}:{uid}), live enforcement reads onlyLIVE_SPEECH_SOURCES, andsync_backfillis the precedent for "metered but never live-enforced". One frozenset entry gives custom-STT the same contract. Critically, an unregistered source coerces to'realtime'in_normalize_speech_source— which would have put exempt users into the live-enforced lane and gated them; the tests pin that trap.Failure class
Failure-Class: none
No registered class covers an exemption swallowing adjacent accounting; single instance, decision extracted to the existing lane model rather than a new mechanism.
Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Validation
realtime, and the custom-STT flush records nothing; with the fix all pass.fair_use:v2:bucket:custom_stt:*);custom_sttis a valid source and absent fromLIVE_SPEECH_SOURCES(with the unknown-source-coerces-to-realtime trap pinned); a runtime-level test drives the real_flush_usagefor a custom-STT session and asserts speech reaches the lane and only the lane — anyrecord_usagecall raises.tests/unit/test_fair_use_engine.py→ 61 passed,tests/unit/test_listen_runtime_regressions.py→ 12 passed.make preflight(local lane, this PR body) → all selected checks pass.blackclean on all changed files.Not exercised live: a real custom-STT device session (no BYOK credentials here). The flush seam is driven directly by the runtime test; the engine's lane isolation is driven by the key-shape tests.
Out of scope, named