Repository navigation
fix(users): gate multi-language mode by the live STT capability policy - #10097
undivisible merged 3 commits into
Conversation
PATCH /v1/users/language derived single_language_mode from the retired Deepgram Nova-3 multi-language list (19 locales), while live serving admits the much broader Modulate auto-detection set via supports_live_multilingual_mode. A user picking a supported language outside the old list — Vietnamese, Korean, Turkish, Arabic, Thai, and ~40 others — was silently forced into single-language mode and could not use live multi-language transcription (BasedHardware#10022). The route now derives the gate from the policy boundary (config.stt_provider_policy.supports_live_multilingual_mode), which also normalizes regional variants. The client mirror in home_provider.dart is updated to the same base-code set with the same normalization, replacing its stale Deepgram list, and links the policy file it mirrors. The Deepgram-specific runtime branch in utils/stt/streaming.py keeps its own list: that code selects Deepgram serving parameters and is the one place the Deepgram vocabulary legitimately lives. Tests: policy-boundary behavioral coverage for the newly admitted and still-rejected languages plus a labeled static tripwire that the route derives from the live policy and the retired list is gone from the route module; Dart unit coverage for the client mirror's eligibility and normalization. Fixes BasedHardware#10022. Co-Authored-By: Claude Fable 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Verified the core invariant of this fix: the new client Nice touches:
One observation (non-blocking): the duplicated client list is unavoidable today since Dart can't import the Python policy, but the route already returns Not formally approving because this sits on the STT provider-routing / user-preference-persistence boundary; flagging for a maintainer's final call. The fix itself looks correct and well-tested. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Reviewed by automated PR reviewer — approving; holding merge (see notes).
|
@Git-on-my-level @undivisible This PR is fully approved and ready to merge. Could you please trigger the merge when you have a moment? Thank you! |
|
looks good ty :)) |
|
holy em dash |
…on (#10074) (#10170) # Summary The regression test #10100 deferred. #10100 fixed the quick-template sheet so a failed install is surfaced as an **error** instead of a false success (#10074), but shipped **without a regression test** — the decision lived inline in the widget's post-`await` branch, unreachable by a hermetic test without a full widget harness (five stubbed API calls plus `path_provider` platform channels). This extracts **only that decision** — the success/error polarity of the terminal outcome — into `templateCreationOutcomeIsError`, a pure function the sheet now derives its install-branch snackbar from. Everything else is byte-identical to #10100. - New `TemplateCreationOutcome` enum + `templateCreationOutcomeIsError` (one pure file, no Flutter deps). - The sheet's install branch sources its success/error choice from the classifier instead of an inline `bool`; the arm order flips (error-first) but the behavior is identical. - Unit tests pin the full outcome table, including `installFailed → error` — the #10074 guarantee — so the failed-install-reads-as-success regression cannot be silently reintroduced. ## Behavior identity (verified line-by-line) Diff is the import line + the install-branch arm-swap; **nothing else in `_createTemplate` changed**. Confirmed unchanged vs the #10100 baseline: `quickTemplateCreated` analytics timing (still fires on submit success, before install), `getApps()` ordering (still before install), the `if (mounted && createdApp != null)` gating (so a mid-flow sheet dismissal still cancels install exactly as before), the `createdWithoutInstall`/`submitFailed` branches, and the catch block. - `success → installed → not error → appCreatedAndInstalled + summarized-apps sheet` - `!success → installFailed → error → failedToInstallApp` (provider already showed its dialog) ## Failure class Failure-Class: none `test:` commit — adds the regression coverage a prior `fix:` (#10100) deferred; no new triggering defect. ## Product invariants affected none (verified with `scripts/pr-preflight --suggest`) ## Validation - Five hermetic unit tests (`app/test/unit/template_creation_outcome_test.dart`) pin the table: `installFailed → true` and `submitFailed → true` (errors); `installed → false` and `createdWithoutInstall → false` (success); plus an exhaustiveness assertion that exactly `{submitFailed, installFailed}` read as errors. Each calls the exact function production calls — flipping the classifier fails the test. - **Not run locally — no Flutter SDK on this machine** (same stated constraint as #10097/#10100/#10126, all merged/approved); tests are hermetic and the app CI lane runs them. - Behavior identity and analyzer-cleanliness (imports used, exhaustive switch, no `use_build_context_synchronously` regression, `createdApp.name` non-null promotion intact) independently reviewed against the #10100 baseline before opening. - `make preflight` (local lane, this PR body) → all selected checks pass. ## Out of scope, named - The `submitFailed`/`createdWithoutInstall` outcomes are classified and tested but the sheet's other two branches still snackbar inline (they were never the #10074 surface and have a single, unconditional polarity). Routing them through the classifier too would be ceremony, not safety. - A broader flow-orchestration extraction was considered and dropped: it drifted analytics timing, `getApps()` ordering, and mid-dismiss install behavior for no gain over this focused pin. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10170?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. -->
…nt mirror Follow-up to #10097, doing what its out-of-scope note and review both pointed at: PATCH /v1/users/language already returns the single_language_mode the server derived from the live STT capability policy, so the client list mirroring MODULATE_SUPPORTED_LANGUAGES — and the drift risk that comes with every future policy change — is deleted. setUserPrimaryLanguage now returns the server-decided mode (null on failure) and updateUserPrimaryLanguage syncs local state from that response. No eligibility decision remains client-side. The mirror's unit test is replaced by a wire-contract test pinning that the response carries single_language_mode and fails loudly when absent — the property that makes trusting the server safe. Not run locally (no Flutter SDK on this machine); hermetic, app CI lane compiles and runs it. Depends on #10097 (stacked on its branch). Co-Authored-By: Claude Fable 5 <[email protected]>
…nt mirror (after #10097) (#10126) # Summary Follow-up to #10097, doing exactly what its out-of-scope note and Git-on-my-level's review both pointed at: the client-side mirror of `MODULATE_SUPPORTED_LANGUAGES` is deleted, and the app trusts the `single_language_mode` the server already returns from `PATCH /v1/users/language`. - `setUserPrimaryLanguage` now returns the server-decided mode (`bool?`, null on any failure) instead of discarding the parsed field; `updateUserPrimaryLanguage` syncs local state from that response. - No eligibility decision remains client-side — future policy changes (new languages, provider swaps) reach the app with zero client releases and zero drift risk. - **Stacked on #10097** (its branch is the base of this diff; merge it first — this PR then shows only the one commit). # Why now #10097 made the mirror byte-for-byte correct; the review verified that equality manually. That manual verification is exactly the maintenance burden this removes: the wire response is the contract, so the list and its normalization helper go away entirely. # Failure class Failure-Class: none This PR's own commit is a `refactor:` with no triggering defect; the declaration covers the stacked #10097 `fix:` commit in this diff range (same call as #10097's own body — divergent read-side policy copies, no registered class). # Product invariants affected none (verified with `scripts/pr-preflight --suggest`) # Validation - The mirror's unit test is replaced by a wire-contract test (`app/test/unit/language_update_response_test.dart`): the response carries `single_language_mode`, both values round-trip, and a response missing the field **fails loudly instead of defaulting** — the property that makes trusting the server safe. - **Not run locally — no Flutter SDK on this machine** (same stated constraint as #10097/#10100, both since approved/merged); the test is hermetic and the app CI lane compiles and runs it. - Call-site sweep: `setUserPrimaryLanguage` has exactly one consumer (`updateUserPrimaryLanguage`); `supportsLiveMultilingualMode`/`multiLanguageSupported` have zero remaining references after deletion. - `make preflight` (local lane, this PR body) → all selected checks pass. # Out of scope, named - Offline-set language: with no client list, local `single_language_mode` state updates only on a successful server response — identical to today's behavior for the persisted preference (the server was already the only writer of the durable value; the mirror only fed optimistic local state). <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10126?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. -->
Summary
PATCH /v1/users/languagenow derivessingle_language_modefrom the live STT capability policy (config.stt_provider_policy.supports_live_multilingual_mode) instead of the retired Deepgram Nova-3 multi-language list.app/lib/providers/home_provider.dart) is updated to the same base-code set with the same regional-variant normalization, and documents which policy file it mirrors.Fixes #10022.
Root cause
Two stale copies of a capability decision. #10023 moved live multi-language capability to the policy boundary (
supports_live_multilingual_mode, consumed by the serving path inutils/stt/streaming.py), but the preference gate — the route that decidessingle_language_modewhen a user picks a language — still consulteddeepgram_nova3_multi_languages, as did its client-side mirror. A supported user was silently locked into single-language mode at preference-set time, before serving policy ever ran.Failure class
Failure-Class: none
The nearest theme is again divergent read-side policy copies rather than mutable-state transition ownership (FC-split-mutation-authority's scope) — same call as #10094/#10095.
What stays untouched, and why
utils/stt/streaming.py's Deepgram runtime branch keepsdeepgram_nova3_multi_languages: that code selects Deepgram serving parameters, the one place the Deepgram-specific vocabulary legitimately lives.migrations/006_auto_set_transcription_mode.pyis a historical migration; rewriting it would change what a past migration meant.Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Validation
tests/unit/test_stt_provider_policy.py(the guard surface for this policy boundary): behavioral checks that the live policy admits the newly eligible languages (vi,vi-VN,ko,tr,ar,th,pt-BR,en) and rejects unsupported ones (my,am,lo), plus a labeled static tripwire that the route derivessingle_language_modefromsupports_live_multilingual_modeand thatdeepgram_nova3_multi_languagesno longer appears in the route module. The tripwire fails on pre-fix code by construction.routers/users.py's heavy import graph would have required module-scopesys.modulesstubbing, which the backend-module-isolation checker bans outside the frozen legacy allowlist — hence policy-seam behavioral tests + tripwire, per the repo's testing guidance.tests/unit/test_stt_provider_policy.py→ 20 passed.app/test/unit/multilingual_eligibility_test.dart) covers the client mirror's eligibility set and normalization. Not run locally — this machine has no Flutter SDK; the test is hermetic and the app CI lane discoversapp/test/unit/. Backend coverage of the same decision did run locally.make preflight(local lane, this PR body) → all selected checks pass.blackclean on changed backend files.Not exercised live: the full app→backend language-selection flow on a device (no Flutter toolchain here). The behavior change is the server-side gate, covered by the policy-seam tests and tripwire above.
Out of scope, named
single_language_mode, so clients that trust the server need no list at all — the mirror only affects optimistic local state.