Skip to content

fix: enforce occasion span and moment quality - #23920

Merged
Git-on-my-level merged 11 commits into
mainfrom
lane/episode-fixes
Oct 29, 2026
Merged

Git-on-my-level merged 11 commits into
mainfrom
lane/episode-fixes

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Enforce the three-hour hard cap across every member conversation. Close the old episode at the cap and start the successor at the boundary while preserving the running summary, transcript receipts, and unresolved provisional items for finalization reconciliation.
  • Carry pending speech across same-occasion conversation rollovers and pusher session ends. A 45-second session-end fence lets a reconnect reuse the buffer; if none arrives, flush the remaining tail, including short speech.
  • Reject moment bullets only when they start with a speaker label or are mostly verbatim: at least 10 words with 80% ordered overlap. Allow short quotes and concise summaries; after a quality error, retain the previous “So far”.
  • Keep the Home live timer anchored during the empty rotation gap, then adopt the successor's server start once it is written. Keep episode metric collectors registered with bounded labels.
  • Register the three independent helper-backed episode kill switches in the owned flag budget and validate them against the central default-on registry.

Product invariants affected

none

UI-Evidence: none
Failure-Class: new
Line-Count-Exception: backend/utils/episodes/service.py | 1589 -> 1824 | The episode-wide cap, same-episode carried receipts, successor state transfer, and explicit flush share one transactional service path.
Line-Count-Exception: backend/utils/metrics.py | 1594 -> 1595 | This import registers episode collectors before the shared listen and pusher metrics endpoint is built.

Verification

  • Merged origin/main (bf20dbf26b6d) with normal merge commit 106680f1604, then merged current origin/main (b8ed4da0d44f) with normal merge commit fabd47219d88, and merged the Firestore transaction retry updates on origin/main (d60cd2eab6e6) with normal merge commit 944c940b8101.
  • backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST for six episode/background-task files plus the flag-budget contract: seven files passed.
  • flutter test test/unit/live_start_anchor_test.dart: 16 tests passed.
  • python3 scripts/check_feature_flag_registry.py: passed.
  • scripts/pr-preflight --pr-body-file /tmp/omi-23920-pr-body.md: 49 checks passed on current origin/main.
  • OMI_PR_BODY_FILE=/tmp/omi-23920-pr-body.md make preflight: 49 checks passed.

Rollout and rollback

Ships on by default with the existing beta client-capability cohort. Three independent default-on environment kill switches are registered in config/feature-flags.yaml and in backend/config/flag_budget.json as owned helper-backed entries (review by 2026-11-28): set EPISODE_HARD_CAP_ACROSS_CONVERSATIONS=off to restore the prior cap behavior, EPISODE_CARRY_ON_SESSION_END=off to restore carry-until-next-moment/finalization, or EPISODE_MOMENT_OUTPUT_VALIDATOR=off to restore the prior single-call output path. The existing EPISODES_ENABLED=off remains the full episode rollback. Monitor omi_episode_moment_updates_total, omi_episode_moment_cost_usd_total, quality_error outcomes, and omi_episode_provisional_items_total kept/(kept+dropped).

Failure-class prevention

The episode cap was bypassed on same-member continuation and across multi-conversation spans. The shared boundary and attach checks compare against the episode's original start. Service tests prove exact-cap rotation, preservation of the prior summary, transfer and finalization reconciliation of provisional items, and continued speech in the successor. Session-end, validator, timer-gap, and independent kill-switch tests cover the other review findings.

🤖 Generated with Claude Code

Git-on-my-level and others added 11 commits October 29, 2026 03:15
Flush terminal session tails after the reconnect window and fence resumed sessions.
Carry unresolved tasks across hard-cap rotation, relax transcript-overlap checks, and retain prior notes on quality errors.
Keep the Home timer stable until the successor episode is written.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Register the three episode rollback toggles as owned helper-backed entries and assert their default-on registry contract.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	backend/config/flag_budget.json
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 29, 2026 01:22
@Git-on-my-level
Git-on-my-level merged commit 06ada78 into main Oct 29, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/episode-fixes branch October 29, 2026 01:22
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T01:22:41.606060Z 944c940 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Git-on-my-level added a commit that referenced this pull request Oct 29, 2026
A silence-split conversation currently buys full notes before Jev
decides to absorb it. This moves automatic absorption to the shared
relevance-to-notes boundary, so raw donors never buy
notes/title/tasks/memories or run their derived effects. Late sync
bridges also keep every already-processed identity instead of deleting a
summarized donor after its maximum hold expired.

Failure-Class: FC-sync-enrichment-before-merge-settles

This is occasion architecture step 2 following #23919 and #23920. The
fix extends the existing shared processing/hold primitive with a
pre-notes absorption boundary and transactional donor fence. Historical
generated title-only results without rich-note receipts keep their
identity; known-owner deterministic minima receive raw-title provenance
independently of the first-summary cohort and remain mergeable before
full notes.

Product invariants: INV-MEM-4, INV-TASK-2. Existing memory promotion and
task-authority rules remain; donor intelligence is suppressed and
canonical processing uses the same authorities.

### Design and path audit

- **Live smart/Jev merge:** budget and relevance gates run first, then
the bounded existing Jev decision, then full notes only if the row
survives. The absorb transaction rechecks live job ID/revision, dispatch
generation, lease epoch/expiry, deletion and both content revisions. A
completed rich row cannot newly become a donor. The donor's committed
cleanup resumes under the existing durable job after errors or rollback.
- **Canonical refresh:** before-notes absorbs delegate to the existing
durable enrichment outbox. Further absorbs share the 600-second quiet
window and 3,600-second maximum hold. A processed survivor supplies the
baseline; at least 30 seconds of new speech or 80 words permits one
automatic late run. A donor that has never completed derived processing
bypasses the immaterial cutoff and forces a full survivor refresh,
preserving its action items and memories. Ordinary unchanged/immaterial
work settles without paid notes or vectors. A budget denial at the
maximum hold settles the hold and merge ledger without re-arming;
earlier denials keep their outbox wake. Raw survivors still pass
relevance on their first full run.
- **Offline sync / late bridges:** intake already assigns content before
enrichment. Beyond step 1's hold, assignment now prefers a processed
canonical and replans excluding any other processed would-be donors, so
late content cannot merge away existing notes. Explicit live targets and
manual speaker owners retain priority; incoming content remains
appendable.
- **Untitled self-heal:** recovery currently does not merge. Raw/minimum
recovery now uses the same pre-notes decision; rich recovery rows and
explicit user-ended rows retain their identities.
- **`sync_merged_into` chains:** workers resolve to the canonical row
and transfer durable custody before acknowledging the donor. Cycles,
deletion, leases, privacy and revision fences remain. No donor full run
is used to resolve a chain.
- **Desktop/pendant capture groups:** these are shared-speech metadata
associations, not destructive transcript merges. Both transcripts can
contain unique speech and retain independent relevance/processing.
Existing primary identity-evidence refreshes remain
fingerprint-deduplicated and capped at three attempts per group.
Collapsing these independent transcripts is not introduced here.
- **Cross-device duplicates:** overlap hints do not delete, discard or
append secondary transcripts; coverage grouping also remains
metadata-only. No unproven speech is suppressed. Home row absorption
remains step 3b; no UI change.
- **Other owners:** batch record lanes retain their
merge-before-projection authority; the legacy merger never claims their
rows. Manual merges remain explicit user intent over completed sources
with the existing durable merge job.
- **Explicit ends:** client finalize, first open, user reprocess, funded
backlog choice and manual merge stay immediate, and successful explicit
processing satisfies an outstanding hold without consuming its late-run
allowance.

### CI integration repair

Retry routing follows the canonical shared persistence-fence exception
so a handled retryable 409 stays retryable after the helper extraction.
Current main now supplies the generated account-deletion wire adapter
(#23936); this PR carries no duplicate client adapter.

UI-Evidence: none -- this PR changes backend processing only; no
widgets, navigation, copy, layout or user-visible behavior changed.

### Aggregate production baseline (read only)

Tier: **ro-prod**, only in a subshell sourced with
`~/.local/bin/gcp-agent-env.sh ro-prod`. No production writes,
account/document reads, API calls to api.omi.me or secrets output. Fixed
window: **2026-10-28 01:35:36.946711 UTC through 2026-10-29
01:35:36.946711 UTC**. GKE in-cluster Prometheus
`sum(increase(...[24h]))` estimates, rounded below; counters count
events/attempts, not unique conversations. Re-querying the fixed window
can shift counter estimates slightly as scrape samples settle.

| Path | Observed 24h aggregate | Already-processed-then-merged evidence
|
| --- | ---: | --- |
| Smart/Jev | 1,269.55 absorbs; 1,278.54 successful survivor refreshes |
Existing code places all new decisions after `_get_structured`/completed
persistence. Exact rich-note donor count is unavailable from the old
metric. |
| Desktop/pendant groups | 218.59 applied joins | 0 destructive merges
by code; grouping happens after member processing and retains both
transcripts. |
| Cross-device hints | 663.74 hints | 0 destructive merges by code;
hints do not suppress either transcript. Coverage-fold metric has no
series (unknown activity). |
| Untitled self-heal | 0 merges by code | `SERVER_RECOVERY` was excluded
by the old `capture_end` gate. Recovery volume is not measured by a
merge counter. |
| Sync assignment / bridge | ~945.6K merged intake operations; ~51.4K
creates | Includes appends, not a count of processed donors. The old
metrics cannot isolate processed-donor absorbs. |
| Redirect chains / flatten | 1,350.56 absorbed flatten events | Not a
chain-depth histogram or count of processed donors; redirects are
followed before callback processing. |

Queries:
`sum(increase(omi_conversation_smart_merge_decision_total{mode="merge",decision="merge",reason="absorbed"}[24h]))`;
refresh and flatten equivalents grouped by outcome/reason; `sum
by(event,outcome)(increase(omi_product_event_total{event=~"capture_group_joined|duplicate_capture_detected"}[24h]))`;
`sum by(outcome)(increase(omi_sync_intake_total[24h]))`. Sync hold and
bridge-retraction series were absent. GKE and Cloud Run scrape coverage
differs; do not infer zero or fleet totals from missing series.

Two metadata-only Firestore COUNT aggregations (smart donor `merged_at`
window, with/without `summary_output_present=true`) returned
`FailedPrecondition`; no index was created or document fetched. The new
bounded
`omi_conversation_merge_processing_stage_total{stage,donor_notes}`
measures actual note-bearing donors separately after rollout. This PR
does not invent an exact rich-note waste rate or dollar estimate from
event counts.

Planning estimate for the same 24h baseline: about **1,279 added
pre-notes Jev calls/day**, using 1,278.54 successful survivor refreshes
as a proxy for eligible candidate volume; there is no direct eligible
`SYNC_UPDATE` Jev-call counter. About **1,270 donor notes runs/day** are
avoided, using the 1,269.55 absorbs as a proxy. Jev's rate card is
$42,000 micro-USD per million input tokens ($0.000042 per 1,000 input
tokens; output is unpriced). At an assumed 1,000 input tokens/call,
1,279 calls cost about **$0.054/day**; actual mean input tokens are
unavailable in this aggregate, so spend scales linearly with token
usage. The refresh and absorb counters describe adjacent outcomes in
this flow and are not added together.

### Verification

Line-Count-Exception: backend/utils/sync/pipeline.py | 3919 -> 3935 |
mirror max-hold terminal settlement in the frozen legacy callback so
both callback bodies remain structurally identical.

#### Review follow-up (2026-10-29; head
`440544dbe2eccb98eaf7a11657447ae038071964`)

- A funded refresh denied at the one-hour maximum now settles the
processing hold and merge refresh without re-arming a quiet-window wake.
The frozen sync callback mirrors this behavior to preserve callback
parity.
- A donor with no completed derived processing bypasses the immaterial
cutoff and uses the existing full survivor refresh, which extracts its
derived effects. This is the cheaper correct path versus a separate
donor extraction run; the regression test uses a 40-word, 20-second
donor.
- Focused verification:
`BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-23931-review-followup-tests.txt
nice -n 10 bash test.sh` from `backend/` passed the callback-parity,
occasion-merge, and process-usage files. The tests cover max-hold budget
denial and the 40-word donor.
- Push preflight passed all 40 checks against
`f60de9b011ec70cfcab05fde0a6c2669a652ab02`; backend typecheck had 0
errors; runtime-image contracts passed; all 15 selected backend unit
test files passed. GitHub CI returned **GREEN OPEN CLEAN MERGEABLE** on
this exact head with **0 pending, 0 failed**.

- Prior review head `080863f6e46`:
`BACKEND_UNIT_TEST_FILE_LIST=/tmp/occasion-focused-49.txt nice -n 10
bash backend/test.sh` through `omi-heavy` exited **0** across **49
selected backend unit files** (**513 passed, 1 deselected; 13 dependency
warnings**), covering smart/Jev merges, sync assignment and redirects,
capture groups, holds, leases, deletion fences, explicit ends,
retry/rollback and the kill switch.
- The standalone flag-budget suite passed **21 tests** with the
one-second fast-unit guard active. Replacing the Python YAML loader with
the safe C loader preserves safe parsing and removes the timing overrun;
the duration exception added by newer `origin/main` was removed as
unnecessary.
- Occasion-specific suite: **56 cases passed** for historical title-only
receipt protection, raw-minimum provenance, real structuring/finalizer
boundaries, late-bridge protection, donor ancestry and SDK contention.
- CI regression follow-up: **524 passed across 11 files**; the shared
generated account-deletion adapter test also passed locally (**6
tests**). No workflow, timeout, skip or test-duration exception was
added.
- `make preflight`: **40 checks passed** against current main
`e0cc9e13096f` on head `080863f6e46`.
- Backend typecheck: **0 errors**; async blocker gate: **0 findings**.
No live endpoint or production canary was run.
- The first exact-head GitHub run exposed the flag-budget test exceeding
its one-second fast-unit guard (21 assertions still passed). The safe C
loader fixes the runtime without a duration exception. GitHub CI passed
all **57 checks** on prior head `80f52633746`. Integrated head
`ffb346aefd3` passed all **58 checks** on retry after its first attempt
had no assertion failures but exceeded the shard-5 720-second budget by
8 seconds. Prior review head `080863f6e465` passed **58 GitHub checks**:
0 pending and 0 failed. `~/.local/bin/ci-wait 23931 BasedHardware/omi
90` returned **GREEN OPEN CLEAN MERGEABLE**. The review follow-up below
records the current head separately.

### Rollout and rollback

Default **on for every processing host**. Independent
`CONVERSATION_MERGE_BEFORE_PROCESSING` ops kill switch is registered in
`config/feature-flags.yaml` and the backend flag budget; owner
rollout-meetings; review 2026-11-28. Coordinator deploy train owns
production promotion; this draft does not deploy.

After deployment, observe the new stage/note-presence counter,
smart-merge rejects/failures, finalization failures and summary
debt/max-hold outcomes for one full hold window. Verify no automatic
`before_notes` donor has notes and no held canonical loses its wake. Jev
now sees transcript excerpts without a generated donor summary; merge
precision/recall must be checked on the rollout train before claiming
product acceptance.

Rollback: set `CONVERSATION_MERGE_BEFORE_PROCESSING=false` on every
processing host. It restores post-notes live merging, legacy sync donor
selection and immediate live survivor refresh; live-only merge holds
drain through their stored wakes/repair sweep; mixed sync work retains
the independent step-1 window and committed donor cleanup remains
retryable. `SYNC_PROCESSING_HOLD_ENABLED` is independent. No historical
data rewrite.

Unverified: production deployment/behavior, rich-note waste percentage,
Cloud Run-only events, Jev accuracy with an empty donor summary, and
destructive unification of metadata-only capture-group transcripts.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/23931?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="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/23931?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23931&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant