Repository navigation
fix(mcp): serve legacy memories when a legacy-cohort account has no rollout state - #10095
Merged
undivisible merged 1 commit intoJul 20, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jul 20, 2026
undivisible
force-pushed
the
fix/9892-mcp-memories-rollout
branch
from
July 20, 2026 07:10
d4e3bfc to
c3a84c4
Compare
…ollout state
The MCP REST routes and SSE tools for memory list and search return an
empty result set for any account whose users/{uid}/memory_control/state
doc is absent — the expected state for every account outside the
canonical-memory cohort whitelist. All four sites reach that branch only
after pin_memory_system resolved the account to LEGACY, where the legacy
memories collection is the authoritative read surface, so the silent
empty result hid real data from un-enrolled accounts — the MCP-surface
form of the Developer API bug (BasedHardware#9892, fixed for that route in BasedHardware#10094).
The four sites now route their legacy-fallback decision through one
shared helper, mcp_legacy_read_authorized: an explicit legacy-safe
decision or the never-enrolled missing_rollout_state case serves the
legacy surface (recorded via the shared record_fallback helper); every
other deny reason (malformed state, read failure, missing grant,
shadow-only) stays fail-closed with an empty result.
Regression tests: behavioral coverage of the helper's decision table,
and the four source-order tripwires updated to assert the routes gate
legacy reads through the helper.
Fixes BasedHardware#9892 for the MCP surface.
Co-Authored-By: Claude Fable 5 <[email protected]>
undivisible
force-pushed
the
fix/9892-mcp-memories-rollout
branch
from
July 20, 2026 07:28
c3a84c4 to
c832cf2
Compare
undivisible
approved these changes
Jul 20, 2026
undivisible
left a comment
Collaborator
There was a problem hiding this comment.
Rebased onto main after #10094. Ratchet conflict resolved (developer.py 2195 + mcp_sse.py 1858). Local unit gates green; CI green after rebase.
Shared mcp_legacy_read_authorized is the right owner for the four MCP list/search sites. Only USE_LEGACY_SAFE and DENY+missing_rollout_state open legacy; other denies stay empty/fail-closed. Telemetry via record_fallback.
Regular merge (no squash).
undivisible
added a commit
that referenced
this pull request
Jul 21, 2026
#10097) # Summary - `PATCH /v1/users/language` now derives `single_language_mode` from the live STT capability policy (`config.stt_provider_policy.supports_live_multilingual_mode`) instead of the retired Deepgram Nova-3 multi-language list. - The client mirror (`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. - Users whose language the live Modulate auto-detection supports but the old 19-locale Deepgram list did not — Vietnamese, Korean, Turkish, Arabic, Thai, and ~40 others — can now actually enter live multi-language mode. 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 in `utils/stt/streaming.py`), but the *preference gate* — the route that decides `single_language_mode` when a user picks a language — still consulted `deepgram_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 keeps `deepgram_nova3_multi_languages`: that code selects Deepgram serving parameters, the one place the Deepgram-specific vocabulary legitimately lives. - `migrations/006_auto_set_transcription_mode.py` is a historical migration; rewriting it would change what a past migration meant. # Product invariants affected none (verified with `scripts/pr-preflight --suggest`) # Validation - New coverage extends `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 derives `single_language_mode` from `supports_live_multilingual_mode` and that `deepgram_nova3_multi_languages` no longer appears in the route module. The tripwire fails on pre-fix code by construction. - The route wiring itself is one line; a full route-handler harness for `routers/users.py`'s heavy import graph would have required module-scope `sys.modules` stubbing, which the backend-module-isolation checker bans outside the frozen legacy allowlist — hence policy-seam behavioral tests + tripwire, per the repo's testing guidance. - Repo runner (file-isolated, as CI executes): `tests/unit/test_stt_provider_policy.py` → 20 passed. - Dart unit test (`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 discovers `app/test/unit/`. Backend coverage of the same decision did run locally. - `make preflight` (local lane, this PR body) → all selected checks pass. - `black` clean 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 - The duplicated client list still exists by necessity (Dart cannot import the Python policy); a follow-up could serve eligibility from the backend response instead of mirroring the set. The route response already returns `single_language_mode`, so clients that trust the server need no list at all — the mirror only affects optimistic local state. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10097?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. -->
aryanorastar
added a commit
to aryanorastar/omi
that referenced
this pull request
Jul 25, 2026
…BasedHardware#10203) GET /v1/dev/user/memories/vector/search failed closed with 403 missing_rollout_state for un-enrolled legacy-cohort accounts, while the sibling read paths recover: the memory list (BasedHardware#9892/BasedHardware#10094) and MCP (BasedHardware#10095) already serve the legacy `memories` collection for exactly these accounts. So an affected account could list its memories but not vector-search them — the remaining "another rollout-state path still failing closed" cohort BasedHardware#10203 asks about. (GET /v1/dev/user/memories itself is already fixed, so a user still hitting 403 on the list endpoint is a deploy-lag symptom, not this code path.) search_memories_vector even raised 403 on `should_use_legacy_fallback` (USE_LEGACY_SAFE) — the one signal that explicitly means "serve legacy." Fix: on a legacy-cohort signal (USE_LEGACY_SAFE, or a deny whose only reason is missing_rollout_state), search the legacy `memories` vector index and hydrate results, preserving vector-relevance order and redacting locked content exactly as the list route does. record_fallback marks the recovery. Any other deny reason keeps the fail-closed 403. This is the 4th instance of the same cause (a default-read surface failing closed for an un-enrolled legacy account instead of serving legacy). The enforceable guard landed here is the updated source tripwire asserting the vector route recovers on the shared signal; unifying all read surfaces behind one predicate ripples into the list route's fallthrough + its tripwire, so it is tracked as a follow-up rather than widened into this fix. Verify (.venv, python3.11): - test_dev_api_canonical_grant_ordering.py 9 passed, incl. 3 new vector cases (legacy fallback on missing_rollout_state + USE_LEGACY_SAFE, and other-deny-reason still 403); reverting the fix fails the 2 fallback cases and keeps the 403 case (mutation-checked). - 144 passed across every vector-referencing unit test. Failure-Class: none Co-Authored-By: Claude Opus 4.8 <[email protected]>
kodjima33
pushed a commit
that referenced
this pull request
Jul 25, 2026
…#10203) (#10485) GET /v1/dev/user/memories/vector/search failed closed with 403 missing_rollout_state for un-enrolled legacy-cohort accounts, while the sibling read paths recover: the memory list (#9892/#10094) and MCP (#10095) already serve the legacy `memories` collection for exactly these accounts. So an affected account could list its memories but not vector-search them — the remaining "another rollout-state path still failing closed" cohort #10203 asks about. (GET /v1/dev/user/memories itself is already fixed, so a user still hitting 403 on the list endpoint is a deploy-lag symptom, not this code path.) search_memories_vector even raised 403 on `should_use_legacy_fallback` (USE_LEGACY_SAFE) — the one signal that explicitly means "serve legacy." Fix: on a legacy-cohort signal (USE_LEGACY_SAFE, or a deny whose only reason is missing_rollout_state), search the legacy `memories` vector index and hydrate results, preserving vector-relevance order and redacting locked content exactly as the list route does. record_fallback marks the recovery. Any other deny reason keeps the fail-closed 403. This is the 4th instance of the same cause (a default-read surface failing closed for an un-enrolled legacy account instead of serving legacy). The enforceable guard landed here is the updated source tripwire asserting the vector route recovers on the shared signal; unifying all read surfaces behind one predicate ripples into the list route's fallthrough + its tripwire, so it is tracked as a follow-up rather than widened into this fix. Verify (.venv, python3.11): - test_dev_api_canonical_grant_ordering.py 9 passed, incl. 3 new vector cases (legacy fallback on missing_rollout_state + USE_LEGACY_SAFE, and other-deny-reason still 403); reverting the fix fails the 2 fallback cases and keeps the 403 case (mutation-checked). - 144 passed across every vector-referencing unit test. Failure-Class: none Co-authored-by: Claude Opus 4.8 <[email protected]>
kodjima33
added a commit
that referenced
this pull request
Jul 28, 2026
…rollout state (#10736) (#10752) Omi chat's memory tools returned "No memories available for this request." for accounts that were never enrolled in the canonical-memory rollout, so chat answered as though the user had no memories while the memories screen showed them normally. Prod logs show 23 such denials on 2026-07-27 alone. Root cause is the divergence already fixed for the Developer API (#10094, #10485) and MCP (#10095): pin_memory_system resolves every account outside the canonical whitelist to MemorySystem.LEGACY, where users/{uid}/memory_control/state is *expected* to be absent — but read_default_read_rollout reports that absent doc as DENY_MEMORY / missing_rollout_state. The chat sites reach that branch only after the cohort pin already said LEGACY, then refused to read the collection the selector had just declared authoritative. Fix: route all four chat sites through one shared decision owner, chat_legacy_read_authorized, mirroring mcp_legacy_read_authorized. It allows an explicit USE_LEGACY_SAFE decision and the never-enrolled missing_rollout_state case, records the mode change through the shared record_fallback helper, and keeps every other deny reason (malformed state, read failure, missing grant, shadow-only) fail-closed. Verify (backend/.venv, python3.11, repo runner): - new tests/unit/test_chat_memory_missing_rollout_fallback.py: 12 passed — invokes get_memories_tool / search_memories_tool / get_memories_text with the adapter denying on missing_rollout_state and asserts the legacy memory is served, plus the mirror cases asserting a missing-grant denial still returns the safe string and never touches the legacy read. - 81 memory/retrieval test files via test.sh: exit 0. - black clean on all changed files. Not exercised live: a production chat turn for a real un-enrolled account (no such credentials here). The fix point is the shared server-side decision helper the tests drive directly. Failure-Class: none Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
undivisible
pushed a commit
to Archit-lal/omi
that referenced
this pull request
Jul 29, 2026
…rollout state (BasedHardware#10736) (BasedHardware#10752) Omi chat's memory tools returned "No memories available for this request." for accounts that were never enrolled in the canonical-memory rollout, so chat answered as though the user had no memories while the memories screen showed them normally. Prod logs show 23 such denials on 2026-07-27 alone. Root cause is the divergence already fixed for the Developer API (BasedHardware#10094, BasedHardware#10485) and MCP (BasedHardware#10095): pin_memory_system resolves every account outside the canonical whitelist to MemorySystem.LEGACY, where users/{uid}/memory_control/state is *expected* to be absent — but read_default_read_rollout reports that absent doc as DENY_MEMORY / missing_rollout_state. The chat sites reach that branch only after the cohort pin already said LEGACY, then refused to read the collection the selector had just declared authoritative. Fix: route all four chat sites through one shared decision owner, chat_legacy_read_authorized, mirroring mcp_legacy_read_authorized. It allows an explicit USE_LEGACY_SAFE decision and the never-enrolled missing_rollout_state case, records the mode change through the shared record_fallback helper, and keeps every other deny reason (malformed state, read failure, missing grant, shadow-only) fail-closed. Verify (backend/.venv, python3.11, repo runner): - new tests/unit/test_chat_memory_missing_rollout_fallback.py: 12 passed — invokes get_memories_tool / search_memories_tool / get_memories_text with the adapter denying on missing_rollout_state and asserts the legacy memory is served, plus the mirror cases asserting a missing-grant denial still returns the safe string and never touches the legacy read. - 81 memory/retrieval test files via test.sh: exit 0. - black clean on all changed files. Not exercised live: a production chat turn for a real un-enrolled account (no such credentials here). The fix point is the shared server-side decision helper the tests drive directly. Failure-Class: none Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
undivisible
added a commit
to undivisible/omi
that referenced
this pull request
Sep 29, 2026
…ollout state (BasedHardware#10095) # Summary - MCP memory reads (`GET /v1/mcp/memories`, `GET /v1/mcp/memories/search`, and the SSE `get_memories` / `search_memories` tools) no longer return a silent empty result for accounts that were never enrolled in the canonical-memory rollout: they now serve the authoritative legacy `memories` surface. - All four sites route the decision through one shared helper, `mcp_legacy_read_authorized`, instead of four copies of the `!= USE_LEGACY_SAFE` comparison. Every other deny reason (malformed state, read failure, missing grant, shadow-only) stays fail-closed. - The mode change is recorded through the shared `record_fallback` helper — no new one-off counter. MCP-surface counterpart of BasedHardware#10094 (Developer API), same root cause. Fixes BasedHardware#9892 for the MCP surface. # Root cause Same divergence as BasedHardware#10094: `pin_memory_system` resolves every account outside the code-reviewed canonical whitelist to `MemorySystem.LEGACY`, where `users/{uid}/memory_control/state` is *expected* to be absent — but `read_default_read_rollout` treats the absent doc as `DENY_MEMORY` / `missing_rollout_state`. The MCP sites reach that branch only after the cohort pin already said LEGACY, then returned `[]` instead of reading the legacy collection the selector had just declared authoritative. The Developer API surfaced this as a 403; MCP hid it as an empty memories list. # Failure class Failure-Class: none Same call as BasedHardware#10094: no registered class covers a reader failing closed on state whose absence the authoritative cohort selector defines as normal, and FC-split-mutation-authority is scoped to mutable-state transition ownership, not read-side policy. # Durable guard - One shared decision owner: the four call sites can no longer drift apart — the narrow un-enrolled exception and its telemetry live in `mcp_legacy_read_authorized`, whose docstring names the contract. - The fallback is narrow: only `missing_rollout_state` (doc absent = never enrolled) qualifies; `malformed_rollout_state` and `rollout_read_failed` stay fail-closed because there the doc exists or its state is unknown. - The existing source-order tripwires (labeled as such) now assert all four routes gate legacy reads through the helper. # Product invariants affected - INV-MEM-1 (path-matched via `utils/mcp_memories.py`): no tier vocabulary change — the helper only decides legacy-vs-deny routing; tier semantics and the guard test are untouched. - INV-MEM-3 note: the new fallback runs only on the non-canonical branch (cohort pin already resolved LEGACY); canonical selection still never falls back to legacy. # Validation - Behavioral regression test of the helper's full decision table (`test_mcp_legacy_read_authorized_only_for_explicit_or_unenrolled`): explicit legacy-safe and never-enrolled pass; malformed/read-failed/no-grant/shadow-only fail closed — this test cannot pass on pre-fix code (the helper did not exist, and the old inline comparisons denied the un-enrolled case). - Repo runner (file-isolated, as CI executes): `tests/unit/test_mcp_memory_adapter.py` + `tests/unit/test_mcp_data_endpoints.py` → 27 passed. - `make preflight` (local lane, this PR body) → all selected checks pass. - `black` clean on all changed files. - `backend/routers/mcp_sse.py` frozen-size baseline raised 1857 → 1858 (one import line) with justification, per the ratchet's documented raise path. Not exercised live: a production MCP key against a real un-enrolled account (no credentials here). The fix point is the shared server-side decision helper driven directly by the tests. # Out of scope, named - `should_use_legacy_fallback` properties on the two result dataclasses remain for API compatibility; the routes now use the shared helper instead. - Chat/omi_chat consumer surfaces keep their existing rollout semantics — different consumer contract, untouched. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10095?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. -->
undivisible
pushed a commit
to undivisible/omi
that referenced
this pull request
Sep 29, 2026
…BasedHardware#10203) (BasedHardware#10485) GET /v1/dev/user/memories/vector/search failed closed with 403 missing_rollout_state for un-enrolled legacy-cohort accounts, while the sibling read paths recover: the memory list (BasedHardware#9892/BasedHardware#10094) and MCP (BasedHardware#10095) already serve the legacy `memories` collection for exactly these accounts. So an affected account could list its memories but not vector-search them — the remaining "another rollout-state path still failing closed" cohort BasedHardware#10203 asks about. (GET /v1/dev/user/memories itself is already fixed, so a user still hitting 403 on the list endpoint is a deploy-lag symptom, not this code path.) search_memories_vector even raised 403 on `should_use_legacy_fallback` (USE_LEGACY_SAFE) — the one signal that explicitly means "serve legacy." Fix: on a legacy-cohort signal (USE_LEGACY_SAFE, or a deny whose only reason is missing_rollout_state), search the legacy `memories` vector index and hydrate results, preserving vector-relevance order and redacting locked content exactly as the list route does. record_fallback marks the recovery. Any other deny reason keeps the fail-closed 403. This is the 4th instance of the same cause (a default-read surface failing closed for an un-enrolled legacy account instead of serving legacy). The enforceable guard landed here is the updated source tripwire asserting the vector route recovers on the shared signal; unifying all read surfaces behind one predicate ripples into the list route's fallthrough + its tripwire, so it is tracked as a follow-up rather than widened into this fix. Verify (.venv, python3.11): - test_dev_api_canonical_grant_ordering.py 9 passed, incl. 3 new vector cases (legacy fallback on missing_rollout_state + USE_LEGACY_SAFE, and other-deny-reason still 403); reverting the fix fails the 2 fallback cases and keeps the 403 case (mutation-checked). - 144 passed across every vector-referencing unit test. Failure-Class: none Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /v1/mcp/memories,GET /v1/mcp/memories/search, and the SSEget_memories/search_memoriestools) no longer return a silent empty result for accounts that were never enrolled in the canonical-memory rollout: they now serve the authoritative legacymemoriessurface.mcp_legacy_read_authorized, instead of four copies of the!= USE_LEGACY_SAFEcomparison. Every other deny reason (malformed state, read failure, missing grant, shadow-only) stays fail-closed.record_fallbackhelper — no new one-off counter.MCP-surface counterpart of #10094 (Developer API), same root cause. Fixes #9892 for the MCP surface.
Root cause
Same divergence as #10094:
pin_memory_systemresolves every account outside the code-reviewed canonical whitelist toMemorySystem.LEGACY, whereusers/{uid}/memory_control/stateis expected to be absent — butread_default_read_rollouttreats the absent doc asDENY_MEMORY/missing_rollout_state. The MCP sites reach that branch only after the cohort pin already said LEGACY, then returned[]instead of reading the legacy collection the selector had just declared authoritative. The Developer API surfaced this as a 403; MCP hid it as an empty memories list.Failure class
Failure-Class: none
Same call as #10094: no registered class covers a reader failing closed on state whose absence the authoritative cohort selector defines as normal, and FC-split-mutation-authority is scoped to mutable-state transition ownership, not read-side policy.
Durable guard
mcp_legacy_read_authorized, whose docstring names the contract.missing_rollout_state(doc absent = never enrolled) qualifies;malformed_rollout_stateandrollout_read_failedstay fail-closed because there the doc exists or its state is unknown.Product invariants affected
utils/mcp_memories.py): no tier vocabulary change — the helper only decides legacy-vs-deny routing; tier semantics and the guard test are untouched.Validation
test_mcp_legacy_read_authorized_only_for_explicit_or_unenrolled): explicit legacy-safe and never-enrolled pass; malformed/read-failed/no-grant/shadow-only fail closed — this test cannot pass on pre-fix code (the helper did not exist, and the old inline comparisons denied the un-enrolled case).tests/unit/test_mcp_memory_adapter.py+tests/unit/test_mcp_data_endpoints.py→ 27 passed.make preflight(local lane, this PR body) → all selected checks pass.blackclean on all changed files.backend/routers/mcp_sse.pyfrozen-size baseline raised 1857 → 1858 (one import line) with justification, per the ratchet's documented raise path.Not exercised live: a production MCP key against a real un-enrolled account (no credentials here). The fix point is the shared server-side decision helper driven directly by the tests.
Out of scope, named
should_use_legacy_fallbackproperties on the two result dataclasses remain for API compatibility; the routes now use the shared helper instead.