Repository navigation
fix(notes): stop persisting the 🧠 unset emoji default on deterministic and legacy paths - #23512
Conversation
…c and legacy paths #23389 repaired the v2 NotesOutput boundary, but every other writer that never received an emoji still persisted the Structured schema default 🧠: the sync-intake deterministic minimum, the short-clip quiet minimum (emoji=''), the media minimum, and the legacy StructuredExtraction / AgentNotesSubmission submissions. A stored default is indistinguishable from a chosen one, so users saw a deliberate brain badge no code chose. - Move the category fallback (DEFAULT_EMOJI/CATEGORY_EMOJI/fallback_emoji) to models/conversation_emoji.py and map category `other` to the neutral 💬, so every CategoryEnum member resolves to a non-brain emoji. - Deterministic/minimum builders set the category fallback explicitly; quiet_minimum no longer blanks the emoji (blank renders as the client's random pick, which includes 🧠). - StructuredExtraction/RichStructuredExtraction.to_structured apply the fallback, covering AgentNotesSubmission and EpisodeStructuredExtraction. - The Structured model's own default (SDK + backend mirror), the share projection, and the client display projection change 🧠 → 💬, so a forgotten field lands on the neutral emoji. The deliberate relevance-discard placeholder (🧠/🎉 on discarded rows) is untouched. - The app decodes a missing or blank emoji as 💬 and renders an empty emoji deterministically instead of a random pick containing 🧠; the app-client OpenAPI spec and generated dart wire schemas are regenerated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4641fdda2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| from models.conversation import Structured | ||
|
|
||
| return Structured(title=decision.title, emoji='', title_provenance='server_minimum') | ||
| from models.conversation_emoji import fallback_emoji |
There was a problem hiding this comment.
Move the emoji-policy import to module scope
The new import inside minimum_for_processing violates the explicit rule in backend/AGENTS.md: “All imports at module top level — never inside functions.” The new models.conversation_emoji module contains only constants and a pure helper, so this dependency does not need lazy initialization. Move this import to the module's import block.
AGENTS.md reference: backend/AGENTS.md:L161-L163
Useful? React with 👍 / 👎.
| emoji: str = Field(description="An emoji to represent the conversation", default="🧠") | ||
| # The neutral "nothing chose" default, matching backend models.conversation_emoji.NEUTRAL_EMOJI. | ||
| # 🧠 is the extraction schemas' unset sentinel and must never persist by accident of a forgotten field. | ||
| emoji: str = Field(description="An emoji to represent the conversation", default="💬") |
There was a problem hiding this comment.
Update raw-capture detection alongside the stored default
For a processing conversation persisted before deployment with the old empty Structured() value (emoji='🧠'), changing this default makes both equality checks in process_conversation.py (lines 2420 and 2542) return false. If funded batch processing denies that capture's budget, it is consequently treated as an already-enriched row: _store_budget_waiting is skipped, leaving the empty structure in processing status without the processing_deferred marker. Update those checks to recognize an empty capture independently of its display emoji, including the previously persisted default.
Useful? React with 👍 / 👎.
…23433 left red #23433 merged with all six backend unit shards failing, and every later main push has failed the same way, so no PR can go green. This carries the minimal repair; revert if the owning change lands its own fix. - The defensive None/junk guards in result_bounds and omi_tools trip pyright's reportUnnecessary* rules. Keep the runtime hardening exactly as merged and suppress per-line with the codebase's established "# type: ignore[...] # defensive" idiom, as memories.py already does. - generate_2025's seg.end None filter gets the same treatment instead of trusting the required-float annotation. - The spec_from_file_location fallbacks did not register the module in sys.modules before exec, so model_text's dataclasses crashed with AttributeError under test_omi_tools_resilience's stub_modules harness (the test never ran in CI: the shards died at pyright first). Register before exec, matching the load_module_fresh recipe. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e CPU guard test_payment_declined_proration lands 1.25-1.66s CPU per test on CI runners (the subscription/Stripe module graph amortizes into the calls under file isolation). The file never ran on main: every shard died at the #23433 pyright errors first, so the guard had not flagged it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the boundary-helper fixes now landed in main through #23512 so this focused quiet-lifecycle PR no longer carries competing versions of those files. Preserve published history with a normal follow-up commit. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]>
) * fix(backend): retire quiet checks at conversation lifecycle boundaries Retire merged, deleted and non-live conversation checks with a shared owner fence; register bounded replay workers and document recovery controls. Clear terminal replay indexes instead of renewing no-op debt. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): cover quiet retirement across terminal fallbacks Exercise actual near-ceiling, orphan, deferred and noise-close commits in the isolated Firestore emulator. Re-review the smart-merge query coverage digest for its post-commit document-only retirement. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(backend): retire quiet debt from terminal jobs and account erasure Close remaining indirect terminal paths and recursive account deletion through the same latest-owner fence. Register the bounded UID-only erasure scan and exercise terminal, merge rollback and multipage erasure behavior. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * harden(backend): preserve boundary contracts in required type checks Make the moved quiet-stop API an explicit export. Align nullable/coercible retrieval inputs with their existing runtime behavior, retain product-query validation without a redundant check, and preserve nullable Wrapped segment handling through the positive-duration filter. These five unchanged-main diagnostics blocked the mandatory full backend type gate. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(backend): retain normalized result type through truncation Keep the existing coercion behavior while separating the normalized string from the object input for the required type gate. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): load real rendering leaves in product tool fixtures Register the lightweight model-text and result-bound modules inside existing import-isolation scopes so dataclass annotation resolution works while network and heavy parent packages remain stubbed. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): include quiet custody in the wire transaction adapter Apply the strict hermetic transaction facade to quiet arm and post-admission retirement reducers. Assert finalization wire requests leave the prior quiet obligation retired and unindexed without weakening reconnect identity or terminal-response checks. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(backend): preserve owner commits when quiet cleanup is deferred Keep post-commit retirement failures from invalidating processing admission, terminal transitions or erasure. Log deferred cleanup and retain the indexed replay backstop. Inject read and write failures to prove admission success and subsequent quiet-debt repair. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): align lifecycle fixtures with SDK and call budgets Model actual due-field deletion for repeated BYOK claims, keep account-erasure outbox cleanup as an explicit collaborator in the tombstone unit seam, and construct isolated payment routers in fixture setup so the existing call CPU guard measures endpoint behavior. Preserve all assertions, thresholds and required suites. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(backend): align boundary helpers with current main Use the boundary-helper fixes now landed in main through #23512 so this focused quiet-lifecycle PR no longer carries competing versions of those files. Preserve published history with a normal follow-up commit. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(backend): restore quiet custody on processing rollback Restore an existing quiet obligation atomically with the successful processing-to-live CAS, with a new generation and immediate due index. Publish deferred cleanup through shared fallback telemetry without invalidating committed owner results. Guard restoration, stale deliveries, dependency failures and telemetry failures in unit and real Firestore tests. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(backend): load quiet retirement telemetry at module scope Keep telemetry failures isolated while complying with the backend import contract. Patch the resolved callable in the failure-injection guard. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): keep retirement metric imports at module scope Apply the same backend import rule to the shared fallback counter assertion. Failure-Class: new Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…test (#23537) ## What `tests/unit/test_payment_declined_proration.py` tripped the fast-unit CPU duration guard on CI run 40118719182 (Backend unit shard 6/6, a pyright-fix PR that does not touch this file): 2.15–2.48s per test against the 1.00s budget. Root cause: the three router tests each call `_load_payment_router()`, which re-imports `routers.payment` from scratch, and the autouse fixture wipes every module imported during a test out of `sys.modules` afterwards. Every test therefore re-paid the full real import graph inside its **call phase** — the exact signal the guard measures. Profiled under the same load: `import stripe` alone ≈ 2.1s CPU, `import fastapi`(+pydantic) ≈ 0.9s, `models.users` ≈ 0.05s. ## Change - Move the stub-module install and the `routers.payment` import into a **module-scoped fixture**: the import graph is paid once per file, in fixture setup. The duration guard measures call-phase CPU only by design ("shared class/file setup ... is not misattributed as a per-test regression" — `backend/tests/conftest.py`). - Add a per-test autouse fixture that resets the shared stub mocks' **call state** (`reset_mock(return_value=False, side_effect=False)`), so every test starts from uncalled mocks with the once-installed stub configuration intact — the same isolation the per-test reload provided. Test 2 asserts `update_user_subscription` called once; tests 3–4 assert it not called, so leaky state would fail loudly. - Assertions and stub semantics are unchanged. - Stub modules now **replace** `sys.modules` entries unconditionally instead of writing mock attributes onto already-imported real modules. In a batched (non-file-isolated) pytest session the old pattern permanently mutated real modules (`utils.subscription.get_plan_type_from_price_id` became a bare `MagicMock`, which breaks `test_subscription_lapsed_paid_heal.py::test_lapsed_paid_heals_from_stripe_subscription_id_directly` — reproduced with the pre-change file; that pre-existing hazard is owned by `test_payment_promotion_codes.py`, unchanged here). This file now leaves zero real-module mutations behind. - Remove the three stopgap entries this file gained in #23512 — the tests are now genuinely fast and stay guard-visible. ## Measured (backend/test.sh file-isolation runner, BACKEND_UNIT_TEST_FILE_LIST, nice -n 19) - Per-test call-phase CPU: 2.35s / 2.51s / 2.49s → **0.00s (<5ms)** for all three (warn limit 0.001s probe run). - File wall: 11.05s → 2.0–3.5s. Batched duo with `test_subscription_lapsed_paid_heal.py`: 10 passed, no stub leak. - No budget raise, no skip, no allowlist entry kept. Failure-Class: none UI-Evidence: none -- reason: backend test files only, no web/admin/app changes - Round-2 hardening (Luna P2): the module fixture now also pins the `utils` package attributes `stripe`/`subscription` to the stub modules for the fixture window (with teardown restore), so `from utils import stripe|subscription` inside `routers.payment` binds the stubs even in a batched session where the real submodules are already attached to the package.
…projections (#23538) Follow-up to #23512 for the two desktop siblings it left out. The macOS client stamped 🧠 into ClientProcessing whenever local inference produced no emoji (assemble, assembleMinimum) and rendered 🧠 for a projection without one, so free-tier locally projected conversations kept showing the brain as if a model had chosen it. - Desktop send: omit the emoji key when the draft has none or a blank; the backend stamps the category fallback (💬 for other). - Desktop render: a projection without an emoji renders 💬. - Backend: ProjectedStructure routes its emoji through the shared fallback_emoji at validation, so no client can store 🧠 (or empty) as an unset value at any intake — the late-bind and chunk-assembly paths validate through the same model. - Backfill docstring: under the post-#23512 mapping every category maps (other → 💬), so no affected row keeps 🧠; script not run. Co-authored-by: Claude Opus 5.5 <[email protected]>
…test Each of the three declined-proration tests re-imported the full real module graph (stripe SDK ~2s CPU, FastAPI/pydantic, models.users, config.*) inside its call phase because the per-test fixture wiped sys.modules after every test. That tripped the fast-unit duration guard at 2.15-2.48s against the 1.00s CPU budget (CI run 40118719182, Backend unit shard 6/6, on a PR that did not touch this file). Move the stub install + routers.payment import into a module-scoped fixture: paid once, in fixture setup, which the guard intentionally excludes from per-test CPU. Reset the shared stub mocks' call state per test so every test still starts from uncalled mocks -- the same isolation the per-test reload provided. Assertions unchanged. Stub modules now replace sys.modules entries unconditionally instead of writing mock attributes onto already-imported real modules, so a batched pytest session no longer carries those mutations past teardown. Measured call-phase CPU per test: 2.35-2.51s -> 0.00s (<5ms); file wall 11.05s -> ~2.4s in the file-isolation runner. Removes the three stopgap fast_unit_duration_allowlist entries this file gained in BasedHardware#23512: the tests are now genuinely fast and stay guard-visible.
What
Deterministic-minimum and legacy notes paths no longer persist the 🧠 "unset" emoji default. After #23389 fixed the v2 NotesOutput boundary, the sync-intake deterministic minimum (
sync/pipeline.py→build_deterministic_minimum_structured), the short-clip quiet minimum (emoji=''), the media minimum, and the legacyStructuredExtraction/AgentNotesSubmissionwriters still stored the schema default 🧠 — which the app then showed as a deliberate brain badge (2026-10-24 RCA, section 3).Changes
DEFAULT_EMOJI/CATEGORY_EMOJI/fallback_emojimove fromutils/llm/notes_output.pytomodels/conversation_emoji.py(re-exported for existing importers, including the backfill tool).CATEGORY_EMOJIgainsother → 💬, so everyCategoryEnummember maps to a non-brain emoji and the fallback's last resort is the neutral 💬 instead of 🧠.build_deterministic_minimum_structuredsets the category fallback emoji explicitly;notes_short_clip.quiet_minimumno longer blanks it (a blank renders as the client's random pick, which includes 🧠);relevance_media.minimum_for_processinguses the fallback instead ofemoji=''.StructuredExtraction.to_structuredandRichStructuredExtraction.to_structuredapplyfallback_emoji, which also coversAgentNotesSubmissionandEpisodeStructuredExtractionthroughsuper(). The extraction schemas' own default stays 🧠: it is the unset sentinel and is baked into prompt bytes.Structuredmodel's own default changes 🧠 → 💬 in the SDK (plugins/omi-plugin-sdk) and the backend mirror, so any future path that forgets the emoji lands on the neutral one.SharedStructured(public share projection) andProjectedStructure(client display projection) get the same neutral default. The deliberate relevance-discard placeholder (🧠/🎉 on discarded rows) is untouched.Structured.fromJsontreats a missing or blank emoji as 💬, andgetEmoji()returns 💬 for an empty emoji instead of a random pick containing 🧠. Wire schemas regenerated (app-client-openapi.json; dart/TS/Swift generators were rerun, only the dart conversation group changed).Deploy note: bare
Structured()is also used as an equality sentinel for "no structured yet" inprocess_conversation.py; the value shifts with the default, which only affects conversations created before the deploy and still in flight across it.Desktop's parallel copies (
ClientProcessingContract.defaultEmoji,ConversationProjectionRendering) still default 🧠 client-side; desktop is out of scope for this PR.Carried main repair (not part of the emoji fix)
Main has been red since #23433 merged with all six backend unit shards failing (5 pyright
reportUnnecessary*errors on the new defensive guards, plus aspec_from_file_locationfallback that never registered intosys.modulesand crashestest_omi_tools_resilienceunder the stub harness). Every later main push fails the same way, so this branch carries the minimal repair on top of a main merge: per-line# type: ignore[...] # defensivesuppressions in the codebase's established idiom (zero runtime change), and the canonical register-before-exec for the fallback loaders. Revert this commit if the owning change lands its own fix.Testing
test_structured_emoji_never_defaults_to_brain.pywalks every deterministic/minimum builder, every no-LLM default, and every extraction submission with an omitted emoji; asserts none persists 🧠 and that a chosen emoji survives. It also pins fullCategoryEnumcoverage ofCATEGORY_EMOJI.test.sh; plugin SDK tests pass; dart tests and analyzer pass; OpenAPI surfaces and generated client schemas are in sync (--check); the enforced pyright lane and the retrieval/wrapped unit files pass after the carried repair.Failure-Class: new
UI-Evidence: none -- schema decode fallback only; no new or changed visual UI state to capture
🤖 Generated with Claude Code