Repository navigation
feat(dev-api): accept folder_id and calendar meeting context in from-segments - #21265
undivisible merged 3 commits into
Conversation
…segments Integrations that send their own transcripts often already know which folder a conversation belongs to and which calendar meeting it was, but from-segments has no way to say so: the AI folder assignment guesses from the generated title, and the summary only sees the one calendar connected in the app. folder_id files the conversation in one of the user's folders (unknown IDs get a 422). Processing already skips AI assignment when a folder is set, so the handler refreshes that folder's count itself. calendar_meeting_context takes a bounded subset of CalendarMeetingContext and stores it where process_conversation already reads it on both the idempotent and the plain path. calendar_source is fixed to developer_api so a caller cannot claim screen_activity.
|
Reviewed end to end, including the downstream code this hooks into. The implementation checks out; the open items are product-semantics calls, not defects. Verified against code on this head:
Two items for a maintainer before merge:
Leaving for human maintainer review on those two points — good, well-scoped contribution overall. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…red meeting From the review: the from-segments calendar context is the direct source in resolve_meeting_context. A stored meeting for the same window keeps the scalar fields and the uploaded invitees it missed are kept (deduplicated); without one, the uploaded context wins and is never read as a screen listing.
|
Thanks for the thorough review. Both points: Merge test. Added in f37b6d8, in
Both pass locally, alongside the from-segments and trust-boundary suites.
If you would rather treat an explicit API folder like a manual move, it is a one-line change: stamp |
kodjima33
left a comment
There was a problem hiding this comment.
avaldini feat(dev-api) folder_id/calendar context -- feature, approve-only
|
Reviewed the from-segments folder_id + calendar_meeting_context change end to end against the current backend. Verification notes: (1) backend/routers/developer.py — the folder_id ownership check (folders_db.get_folder(uid, folder_id) -> 422) runs before any processing and get_folder is scoped to users/{uid}/folders, so no cross-tenant exposure; the post-ingest update_folder_conversation_count is wrapped in try/except and logged, matching the existing pattern for count refreshes. (2) backend/models/calendar_context.py — DevCalendarMeetingContext.to_context() stamps calendar_source='developer_api'; since CalendarMeetingContext.calendar_source is free-form and resolve_meeting_context only special-cases screen_activity, the uploaded context merges with a stored meeting exactly as the tests describe (stored meeting wins scalars, uploaded invitees are kept deduplicated). (3) backend/models/conversation.py + process_conversation — folder_id on CreateConversation survives the final persist via the conversation.dict() spread, and the existing not conversation.folder_id guard skips AI assignment; the idempotent path stores the context in external_data, which process_conversation already hoists into the summary context, so both paths are covered. (4) backend/tests/unit/test_developer_from_segments_idempotency.py and test_meeting_context_resolution.py — good coverage of the 422, both ingest paths, the no-folder default, and merge semantics. (5) docs + generated TS/OpenAPI artifacts (omiApi.generated.ts x4, openapi.json x2, conversations.mdx) are consistent downstream updates. The choice not to stamp folder_user_set (explained in the PR body) is a sound call given it gates relevance discard. A human maintainer has already approved this head; remaining step before merge is a green CI run. Thanks for the careful PR body and tests. (Automated maintainer review on behalf of the Omi maintainers; the merge decision stays with a human maintainer.) by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for the approval! CI hasn't run on this branch yet: the workflow runs are waiting on "Approve and run workflows" (first-time contributor from a fork). Could a maintainer approve them so the checks can run? |
kodjima33
left a comment
There was a problem hiding this comment.
Clean, well-scoped dev-API feature (folder_id + calendar meeting context on from-segments). Feature, not a bug fix, so approve-only per policy — no merge.
|
Verified this end to end against the current head — the wiring holds together nicely:
Thanks for the thorough PR description — the rationale for skipping by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks! On the Generated Files note: that job is the Flutter codegen check ( |
kodjima33
left a comment
There was a problem hiding this comment.
New optional dev-API fields - new capability, not bug fix - approve-only; CI green.
Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
) * fix(backend): restore pyright-clean main after #22207 and #22326 Main's backend unit shards fail the enforced pyright lane: - database/desktop_previews.py (#22207): 16 reportUnnecessaryIsInstance errors. The runtime guards stay; they move into validators that take `object` (_payload, _string, _expected_generation, _datetime), so the checks are meaningful to pyright. Public signatures, error messages and check order are unchanged. - utils/sync/pipeline.py:process_segment (#22326 on top of #22452): "code is too complex to analyze". Behaviour-neutral split: the two identical cap-hold defer blocks become one hold_for_cap closure, and the final-pass / speaker-identification block moves to _assign_segment_speakers with the same exception handling. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): repair unit tests that drifted from main across merges Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What changed and why
POST /v1/dev/user/conversations/from-segmentsnow accepts two optional fields:folder_id: files the conversation in one of the user's folders.calendar_meeting_context: the calendar meeting the conversation belongs to.Integrations that upload their own transcripts often know both already, but today they have no way to pass them:
GET /v1/dev/user/foldersis read-only and the conversationPATCHonly changestitleanddiscarded._enrich_meeting_context, source 3). Someone who works across several companies has several calendars. The integration can read all of them, but cannot hand Omi the meeting it found.My setup is the same as in #21250: a self-hosted STT server transcribes the phone's audio and uploads each finished conversation through from-segments. It reads four calendars (personal plus three work accounts), so it knows the meeting and the folder before the upload.
How it works:
folder_idfolders_db.get_folder); otherwise the request gets a 422 before anything is processed.Conversationfor the idempotentclient_session_idpath, and onCreateConversation(new optional field) for the plain path.process_conversationalready skips AI assignment whenconversation.folder_idis set (not conversation.folder_idguard). That also skips the count refresh the AI path does, so the handler callsupdate_folder_conversation_countafter a successful ingest. A failure there is logged, not raised.folder_user_set. That marker means "a user acted" and protects a row from relevance discard (is_user_curated). A non-nullfolder_idis already preserved by the processing upsert.calendar_meeting_contextIt is a bounded input model,
DevCalendarMeetingContextinmodels/calendar_context.py, with:calendar_event_id,title,start_timeandduration_minutes;participants(MeetingParticipant);platform,meeting_linkandnotes.Strings, the participant list and the duration have length or range limits.
It is converted to
CalendarMeetingContextand stored whereprocess_conversationalready reads it:CreateConversation.calendar_meeting_contexton the plain path;external_data['calendar_meeting_context'](asmodel_dump(mode='json'), likestore_meeting_context) on the idempotent path.calendar_sourceis fixed todeveloper_api, so a caller cannot claimscreen_activity, which has its own merge rules.participant_sourcesis not exposed.The Firebase-authed
POST /v1/conversations/from-segmentsshares the request model, so it gains the same two optional fields.Docs and generated artifacts:
docs/doc/developer/api/conversations.mdx;docs/api-reference/openapi.jsonandapp-client-openapi.json, regenerated withexport_openapi.py --write;omiApi.generated.tsfiles, regenerated withgenerate_ts_openapi_types.py.Product invariants affected
none
How it was verified
backend/tests/unit/test_developer_from_segments_idempotency.py: 65 passed, including 4 new tests.tests/unitandtests/routersfile that mentionsCreateConversation,routers.developer,folder_idorcalendar_meeting_contextpasses: 86 files, each run on its own.tests/unit/test_developer_key.py, which errors withModuleNotFoundError: No module named 'fake_firestore'both on this branch and onmainin my local environment. That is unrelated to this change.tests/unit/test_client_processing_trust_boundary.pypasses (51).DevCalendarMeetingContext.to_contextbuilds the context field by field, so no newmodel_dumpsite was added.export_openapi.py --checkpasses for the public, app-client and integration-public surfaces.check_app_client_openapi_compatibility.py --base-ref origin/mainpasses.generate_ts_openapi_types.py --check,generate_swift_openapi_types.py --checkandgenerate_dart_models.py --all --checkpass.check_product_invariants.py: no locked invariant requires naming.scripts/backend-python-format --checkis clean on the changed files.ruffreports the same 3 pre-existing F401s inrouters/developer.pyas onmain.Tests
In
backend/tests/unit/test_developer_from_segments_idempotency.py:test_unknown_folder_id_is_rejected_before_processing: a folder that is not the user's gives a 422, andprocess_conversationis never called.test_folder_and_calendar_reach_create_conversation: goes through the real FastAPI route with a JSON body. It asserts:CreateConversationhanded to processing carriesfolder_idand the calendar context (title, participant email, parsedstart_time,calendar_source == 'developer_api');test_folder_and_calendar_reach_idempotent_conversation: on theclient_session_idpath, the processing claim and theConversationcarryfolder_id, andexternal_data['calendar_meeting_context']holds the context.test_without_folder_id_ai_assignment_stays_in_charge: without the new fields, nothing changes. There is no folder lookup and no count refresh, andfolder_idand the context stayNone.In
backend/tests/unit/test_meeting_context_resolution.py, added after the first review:test_developer_api_context_merges_with_a_stored_meeting: an uploaded context is thedirectsource. A stored meeting for the same window keeps the scalar fields, and the uploaded invitees it missed are kept, deduplicated by name and email. They are counted as expected calendar participants.test_developer_api_context_is_used_when_no_stored_meeting_exists: without a stored meeting, the uploaded context wins (event id, title,developer_apisource). It is never treated as a screen listing.UI evidence
UI-Evidence: none -- backend-only change
Failure class (fixes)
Failure-Class: none
Scoped cleanups (optional)
Line-Count-Exception: backend/routers/developer.py | 2655 -> 2690 | two optional request fields and their validation and wiring in the shared from-segments handler; the new input model lives in models/calendar_context.py