Repository navigation
perf(episodes): build one-conversation episodes from notes, add notes gist - #25057
Git-on-my-level wants to merge 1 commit into
Conversation
… gist A single-member episode no longer pays the composer model: its title, lede, chapters and follow-ups are built from that conversation's own notes in code. The mapping is explicit so the episode page and the conversation detail agree: title/emoji from the notes, lede from the new gist (or the overview when the notes have no sections), one chapter per section with its bullets as points and times from the cited segments, follow-ups from open action items, people from participants. The shortcut writes the same composed stamps as the model path, so a later member or transcript change recomposes normally. Kill switch EPISODE_SINGLE_MEMBER_COMPOSE (default on). The notes call gains one field, gist (at most 12 words), clipped server-side and persisted on Structured. It rides the episode-member wire with home_step so #25022 can consume both. No new model call.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
…en (#25065) ## What/why L8b keeps paid composer results, maps eligible single-member notes without another call, labels compose triggers, and composes late deferred episodes on first open. It preserves paid notes while a newly joined member is processing and retains the guarantee that late members eventually appear in episode notes. L8a #25073 is merged into main as 7ec9a04. Under lead2 1c606e, this branch merges origin/main without rebasing and preserves main’s L8a dependency-version fencing alongside L8b. L9 #25075 remains separate. No PR is merged or closed by this work. ## Flags and defaults - `EPISODE_COMPOSER_THRIFT`: default ON, unset=on. Controls keep-paid/repair, single-member mapping and late deferral/read trigger. Off restores paid single-member composition, discard/retry and finalize scheduling; detail reads schedule no compose. Durable deferrals still drain through ordinary recovery. - Dependency `EPISODE_COMPOSER_REUSE`: independently default ON; its deploy/rollback compatibility preserves successful notes/L1 work. Thrift rollback never changes reuse keys or L1 admission. - L9's `EPISODE_COMPOSER_NOTES_FIRST` is absent from this PR's final tree and stays default OFF in its separate PR until David's side-by-side verdict. Numeric late age/grace settings remain tuning. Late age means episode recorded-start age (48h), not individual member upload age. Read recovery exits after seven days. Notes gain an additive bounded gist in their existing call; older successful notes remain eligible without buying gists in a regeneration wave. ## Ramp L8b may serve after normal gates. Refactor-lead watches failures/conflicts, paid logical calls/repairs, input/output tokens, waiting-member retention, deferred/open/grace completion and notes freshness. Roll back on a regression. L9 stays OFF until David compares content and cumulative billed input/output, retries and failures on the same episodes; no paid side-by-side or deployment is run here. No variable-margin attainment claim. ## Product invariants INV-MEM-4: canonical memory promotion stays the authority; the L8a dependency only avoids extraction. INV-TASK-2: episode follow-ups show existing open actions and create no tasks. INV-UI-1 / INV-UI-3: existing mobile primitives and styling retained. Visibility fences discard a paid result if an original member is hidden/removed, including during a waiting-member race. Ownership tokens fence stale paid writes and lease release. ## Dispositions - Tests/merge P0-1: normal main merge, preserved HOME_EMPTY_OUTPUT_NOISE, exact live flag-budget count. Separate helper entries for reuse and thrift. - Tests/merge P0-2: removal is checked against retained episode ids and original-member visibility, not the empty waiting-member result. A present processing member keeps paid output pending; regression asserts one paid call and later waiting without re-buy. - Cost P1 lease: size for both 90s provider attempts plus retry headroom for every permitted turn and repair, plus final-write margin. Refuse a turn without remaining headroom; fence completion and release by claim token. Two-replica repair regression crosses 240s. L9 extends/tests this bound for tool turns. - Correctness P1-1: shortcut fingerprint includes complete structured notes, action completion, cited segment ids/end times and recorded span; member-final notes-only changes reach the shortcut. - Correctness P1-2: shortcut requires a readable lede or points; title-only and previously stamped empty bodies fall through to paid composition and later notes can refresh. - Correctness P1-3 / tests P1-5: schedule_opened requires THRIFT on and a durable deferral. Ordinary processing pages cause one detail read, without foreground paid work or extra polling. - Tests P1-1/P1-2: close and member-final regressions cover re-deferral after a new member; deferral write faults emit fallback telemetry and fall through to normal scheduling. - Tests P1-3 / siblings: supersedes #25062. #25053's attach-time guarantee is preserved through the same two attach funnels, under THRIFT, with durable deferral plus first-open/grace recovery even if finalization is memoized. Keep #25053 open for lead reconciliation; do not merge both implementations blindly. #25022 lands second and must resolve its page/provider overlap by retaining this small refresh contract. No page redesign or task affordance is added here. - Waiting first open: persist the opened deferral epoch. A member completing after the bounded client poll schedules normally on any replica and bypasses the seven-day unopened hold; completing compose clears the epoch. A read that finds waiting members releases its local read throttle so a later bounded poll can finish. - Client polling: server `compose_deferred` signal; one initial read plus at most eight 5s polls, each read <=4s and total deadline 45s. Concurrent opens coalesce; page exit/account change/disposal fence results and stop further reads. Home retains its filtered membership; opened cache is invalidated with Home/delete visibility. - Correctness P2-2/P2-11/P2-12: kept-pending output waits for the settle timer; trigger stamping clears deferral; unused call label removed. - Correctness P2-4/P2-5/P2-9: detail cache is separate from Home, invalidated on delete, bounded and refreshed on open; only explicit deferrals poll. Cache eviction remains insertion order with a cap of 16, acceptable bounded storage rather than an LRU promise. - Tests P2: unknown duration cannot justify short sectionless output; positive/finite grace settings and single-member window-refusal retry are tested. Prompt digest guard remains live. Gist is an additive prompt/schema capability, not an extra paid call or rollback gate (correctness P2-6). - Metrics: reported billed input/output is counted on every reply, including terminal malformed/repair outcomes; logical paid calls, repairs and failures are labeled. Hidden SDK retry attempts/billing remain an explicit usage-ledger follow-up. Update dashboard/recording-rule aggregations for `trigger`; refresh the measured production inventory after these families serve. The inventory is not fabricated from unserved code. L9 enablement requires the authoritative ledger, not these counters alone. - Remaining L9 tool/failure findings are disposed in its PR. No test is skipped or weakened. ## Tests At earlier head d7a1112, merge-main validation passed: backend/test.sh passed 1,398 tests across 43 files, covering every episode/composer suite, test_flag_budget.py and the seven L8a unit suites (dedupe, dependency upgrades and aliases, prompt versions, L1 admission, usage context, short-clip rollout and owner-memory admission). Tests use file isolation and BACKEND_UNIT_FILE_BUDGET_SECONDS=3600. backend/scripts/typecheck.sh reports zero errors. make preflight passes all 75 selected checks on the clean merge commit. Regenerated with owning scripts: scripts/render_feature_flag_registry.py, backend/scripts/generate_firestore_indexes.py --write, backend/scripts/openapi_runner.sh with export_openapi.py --surface app-client --write, generate_dart_models.py --all and generate_swift_openapi_types.py. All outputs reproduce the merged tree. At earlier head 78a6c22, the full hook and the original backend/Flutter/render verification passed. At earlier head bb6907c, the copyWith regression, 108 Flutter episode tests, 138 spine tests, backend typing, preflight and the full hook passed; CI was terminal green. Those are historical receipts, not validation claims for this merge. ## UI-Evidence Real Flutter widget renders from app/test/widgets/episode_composed_render_test.dart, fictional fixtures, light/dark composed pages and lede-only detail result. Client layout is unchanged by the split; refresh behavior is exercised by provider/widget regressions.    UI-Evidence: .agent-artifacts/ui-evidence/composer-thrift/ (tracked PNGs and evidence.json). Failure-Class: none ## Rollback `EPISODE_COMPOSER_THRIFT=off` independently restores finalize composition; existing deferrals drain through ordinary read recovery. `EPISODE_COMPOSER_REUSE=off` restores source-key writes/L1 admission while compatibility reads avoid buying stored work. L9's separate switch restores full-transcript input. No data migration. Salvage: restored composed-episode re-deferral with an explicit client signal; completed the stamp-fault and client lifetime gaps. Dropped only redundant late-compose and L9-percentage switches, replaced by the independent stack controls. No incomplete salvage feature remains. Supersedes #25039 #25046 #25048 #25057 #25062 (L9 source #25039 moves to the separate L9 PR; #25046 moves to #25073). Line-Count-Exception: backend/utils/episodes/composer.py | 1105 -> 1734 | Preserve the existing canonical lifecycle, CAS, visibility and lease authority; scoped additions delegate admission/attach signaling to small helpers. Line-Count-Exception: backend/utils/episodes/service.py | 2222 -> 2223 | Preserve the existing canonical lifecycle, CAS, visibility and lease authority; scoped additions delegate admission/attach signaling to small helpers. Luna FIX-FIRST disposition (earlier head 78a6c22): fixed the stale single-member write and the same empty-result clearing race with an atomic episode/member revision fence; newer member or episode snapshots return superseded without retrying the stale payload. Both the normal write and window-only fallback retain the guard. Regression tests exercise real episode persistence with StrictFirestore. At that earlier head, other pre-read writes (paid compose gap, provisional deferral title, scheduling stamps) were explicitly listed in backend/docs/listen_pusher_pipeline/changes/2026-11-10-composer-snapshot-fence.md; the paid gap is closed by the disposition below. Validation at that earlier head: all 36 episode suites passed through backend/test.sh; the final focused rerun passes 33 single-member tests and 126 composer tests; make preflight passes all 77 selected checks; the full hook and CI results are reported separately. Luna #25075 review disposition (earlier head fa02849, L8b-owned schema): added an optional composeDeferred override to Episode.copyWith. Omitted overrides preserve the current value; an explicit false clears a deferred episode. app/test/unit/episode_schema_test.dart covers both behaviors. Validation at earlier head bb6907c: app/test.sh passes all 108 selected episode tests plus its 138 spine tests; backend scripts/typecheck.sh passes with zero errors; make preflight passes all 77 selected checks. The stale single-member/empty-result transactional fence and regression coverage are included at that earlier head and preserved in the merge. L8a and L9 branches are untouched. Merge-main disposition (lead2 1c606e): merged origin/main at 9ca056a, including L8a merge 7ec9a04, without rebasing. The sole conflict was adjacent appended tests in backend/tests/unit/test_conversation_llm_input_dedupe.py: retained main’s dependency-version tests verbatim and L8b’s additive-gist checkpoint test. Main’s installed-dependency compatibility guard remains in place; the L8b notes-2/gist aliases remain inside that guard. No new scope or L9 branch changes. David authorized one full-hook fast-forward push for this merge; the PR remains unmerged. Luna FIX-FIRST disposition (earlier head d7a1112): paid multi-member completion and its window-only fallback now pass canonical member revisions captured at the final visibility reads to the existing episode/member transaction fence. Any subsequent member revision change or deletion refuses publication; the episode CAS guard also rejects original-member removal. Hidden originals refuse unconditionally, including a hide during the final visibility pass after the evidence fingerprint check. Refused paid notes are discarded, never published or stamped current, and the lease is released under its ownership token. Existing superseded scheduling provides bounded recomposition: background settling buys one call before the quiet timer; settling rollback remains capped at three attempts. No L8a or L9 branch changes, new flags, or paid retry loop. The snapshot-fence change doc now describes the closed paid-write gap. At earlier head ef71cfa, validation: backend/test.sh passed every episode/composer suite plus flag-budget and the seven L8a suites: 1,413 tests across 44 files (43 files passed initially; the flag-budget file passed after the merge-count reconciliation). The 15 new strict-transaction regressions cover hard/soft deletion, discard, merge-away, revision changes, unchanged publication, both paid-write variants, hiding during the final visibility pass, and bounded recompose scheduling with settling on/off. backend/scripts/typecheck.sh passed with zero errors. make preflight passed all 75 selected checks on the clean commit. No live account data or production calls were used. Main reconciliation at earlier head ef71cfa: merged origin/main at 4e9c704 without rebasing. The sole conflicted file was backend/tests/unit/test_flag_budget.py; retained main's projection-debt entry and L8b's thrift entry, with the shared owner checks. Reconciled the declared count to the actual merged inventory (269). Regenerated feature-flag-registry.md and firestore.indexes.json with their owning scripts. No OpenAPI/wire sources changed in this fix or main reconciliation. The PR remains unmerged. Luna FIX-FIRST disposition (earlier head ef71cfa): removed the visibility loop's revision overwrite. The post-call _members fingerprint snapshot supplies the only expected revisions. The visibility pass now compares against that unchanged map; a revision difference, a missing snapshot entry, or a missing/hidden/discarded member refuses publication before the notes write. Both normal and window-only publishing transactions continue to validate the same snapshot map. The unsafe paid result is discarded, its lease is released under the existing token guard, and superseded uses the existing bounded recompose scheduling. No new retry path, scheduler, flag, or unrelated production change. Current validation: backend/test.sh passed 1,416 tests across 44 files (all episode/composer suites, flag budget, and the seven L8a suites). The three added cases failed against the earlier implementation and pass with this fix: visible notes changing between the fingerprint snapshot and visibility reread never publish, and recompose remains bounded with settling on/off. Existing unchanged-member and fallback transaction tests still pass. backend/scripts/typecheck.sh passed with zero errors. make preflight passed all 75 selected checks on the clean commit. Full hook and CI results are reported separately. The snapshot-fence change doc describes the immutable snapshot revision rule. GitHub reported CONFLICTING/DIRTY before this work, so origin/main at 6d45be4 was merged without rebasing. The sole conflict was the flag-budget count: main declares 268 entries, while this branch includes the thrift entry and correctly declares 269; retained 269, verified against the actual entries and test_flag_budget.py. The merge has no other tree changes. No generated sources or registry inputs changed. L8a/L9 branches are untouched; this PR remains unmerged.
|
When this PR returns to the merge queue, please update its branch against current |
|
Closed from SCA-4838 on the Margin owner's call of 2026-11-26 (R38: a lever must be worth at least $20/day net, and this PR's evidence does not establish that). Dropped as a savings PR, not because the code is wrong. Reopen on: Measured eligible single-member share and net savings after gist tokens. The PR models $5.70-17/day gross at 10-30% eligibility. If fresh data supports a combined composer lever, bring back #25062, #25057 and #25048 together. |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
What changed and why
Two Fable LLM-efficiency items, one PR (relay-cl1 bc0505, lead refactor-lead).
#2 — no composer call for a one-conversation episode.
utils/episodes/composer.pynow builds a single-member episode's title, lede, chapters and follow-ups from that conversation's own notes in code. The mapping is explicit so the episode page and the conversation detail agree:title/emojifrom the conversation's notes.ledefrom the notesgist(the new field below). When the notes have no sections, the conversation'soverviewis the lede; when they do, the overview is the section render, so it is not repeated as a lede.headingfrom the section heading,pointsfrom the section body (top-level bullets are points, nested bullets are their details, prose paragraphs become points). Chapter times come from the section's citedsource_segment_ids; a section with no usable citation inherits the gap between its neighbours, so the sections partition the conversation once instead of overlapping or inventing time.follow_upsfrom the open action items,peoplefrom the participants.The shortcut runs only when the episode has exactly one retained, visible, completed member with usable notes. It writes the same composed stamps as the model path (
composed_fingerprint,composed_member_ids,composed_evidence,composed_notes,composer_version), so a later member, transcript upgrade or discard recomposes normally. It takes no lease, settle window or failure backoff because nothing is paid. A member with no usable notes falls through to the paid composer.#6 —
gistin the existing notes call.gist(at most 12 words) is one more field in the existing notes schema (NotesOutputand the legacyStructuredExtraction), asked for in the existing static instructions, clipped server-side to 12 words, and persisted onStructured. No new call. It is also on the episode-member wire.Wire fields for #25022 (m1 lane)
EpisodeMembernow carries, additively:gist: str— the conversation's one-line gist;""on legacy notes.home_step: str | null— the existingutils/conversations/home_step.pyclassification (ready | transcribing | writing_notes | failed | noise), read-time only,nullwhen the projection is off or the row has no step.Both are in
docs/api-reference/app-client-openapi.jsonand the generated Dart/TS/Swift models. The FlutterEpisode.fromGeneratedadapter is unchanged; #25022 can readm.gist/m.homeStepfromGeneratedEpisodeMember.Rollback and tuning
Default-on operational kill switch:
EPISODE_SINGLE_MEMBER_COMPOSE(unset/blank/on = on;false/0/off/no= off). Off restores the paid composer for single-member episodes. Registered inconfig/feature-flags.yaml(ops_kill, fail open, owner refactor-lead) and as an owned registry entry inbackend/config/flag_budget.jsonwithreview_by: 2026-12-10. No deployment or cohort change in this PR.Tuning (before → after, per the 2026-11-10 report):
omi_episode_compose_total{outcome="composed_single"}againstoutcome="composed".gistadds ~15 output tokens per conversation. At 70.8k notes requests/day that is ~1.06M output tokens/day, ~$0.64/day at the placeholder card. It avoids a future gist call.New state and its exit:
composed_singleonomi_episode_compose_totalis a terminal success, the same composed state ascomposed; its exit is a membership or evidence change, which recomposes through the normal path.home_stepon the member wire is a read-time projection with no stored state; its exit is the existingHOME_STEP_PROJECTIONswitch.Product invariants affected
The selector requires no explicit invariant citation for these paths. The change is server-side notes/episode composition and an additive wire field; it does not touch memory tiers, task authority, chat continuity, or UI tokens.
gistis a display label only and never an input to memory or task decisions.Failure-Class: none
Verification
All heavy commands through the managed
omi-heavyrunner (host load high; waited for slots).backend/tests/unit/test_episode_single_member_compose.py(new): no model call, field mapping, chapter timing from citations, uncited partition, no-sections lede, kill switch, two-member fallback, second-member recompose.backend/tests/unit/test_notes_gist.py(new): 12-word clip, persistence on both schemas, absent when unset, prompt and submit-tool exposure.backend/tests/unit/test_episode_home_read.py: member wire carriesgistandhome_step; both absent/empty on legacy notes and with the projection off.backend/tests/unit/test_episode_composer.py,test_flag_budget.py,test_episode_evidence.py,test_conversation_title_people.py,test_notes_packet_v2.py,test_structured_extraction_partial_content.py,test_structured_emoji_never_defaults_to_brain.py,test_open_loops_schema.py,test_home_step.py,test_home_transcribing_hold.py,test_client_processing_trust_boundary.py,test_episodes_router.py,test_episodes_service.py,test_episode_notes_eval.py,test_meeting_notes_rich_context.py,test_action_item_extraction_policy.py, and the app-client OpenAPI/Dart/TS/Swift generator and inventory tests.python3 scripts/check_feature_flag_registry.py→ OK;python3 scripts/render_feature_flag_registry.pyregenerated the registry doc.scripts/export_openapi.py --surface app-client --writeand the Dart/TS/Swift generators regenerated the committed artifacts.Render evidence
UI-Evidence: none -- backend-only change; the
app/libdiff is regenerated wire DTOs (gist,home_step), no UI source, layout or copy changed.The current beta episode page does render the difference (lede + one section per moment), so a widget render is the right evidence. It could not be produced in this lane: app dependencies are not resolved here and
flutter pub getdid not complete under the current host load, so the render test (app/test/widgets/episode_composed_render_test.dart) could not run. This PR therefore ships a before/after JSON of the episode payload as the substitute; #25022's m1 lane has the Flutter toolchain and can render the same fixture.The payloads are below (also at
.agent-brief/single-member-before-after.jsonin the lane worktree): the same conversation, once through the model composer and once through the code-built path. The title, follow-ups, people and emoji match; the lede becomes the 12-word gist; the chapters become the conversation's own sections with the same headings and bullets, and their times come from the cited segments.Before/after episode payload