Skip to content

fix(backend): merge raw conversations before full processing - #23931

Merged
Git-on-my-level merged 30 commits into
mainfrom
lane/merge-first
Oct 29, 2026
Merged

Git-on-my-level merged 30 commits into
mainfrom
lane/merge-first

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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.

View guided diff Turn on auto-fix

🤖 Generated with Claude Code

Git-on-my-level and others added 30 commits October 29, 2026 08:55
Decide automatic absorption after relevance and before notes, preserve already-processed sync identities, and debounce material canonical refreshes through durable custody. Keep explicit user ends immediate and provide an independent default-on kill switch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the oversized processing coordinators at their current line budgets by sharing custody rejection, budget deferral and deferred webhook primitives. Preserve legacy callback parity without line-count exceptions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Track each pending producer and reset that provenance for new epochs. Rollback drains live-only debt while mixed obligations retain the separately enabled sync window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Protect old generated title-only captures that lack rich-summary receipts, while allowing proven server-minimum titles to enter pre-notes merging.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Stamp deterministic title provenance for known owners whenever merge-before-processing is enabled, independently of the first-summary cohort. Preserve the no-LLM minimum and unknown-owner behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve conservative legacy policy defaults while satisfying the inherited schema inventory gate; no UI behavior changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Skip ineligible short captures before loading merge dependencies and migrate raw-donor fixtures to explicit minimum provenance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assert an actual committed donor before testing terminal retries, avoiding unrelated derived-effect work under the new default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the equivalent C safe YAML loader when available so the full registry check stays within the fast-unit CPU budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The helper inventory now uses the equivalent C safe loader and stays below the fast-unit CPU guard, so keep the duration assertion active.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level marked this pull request as ready for review October 29, 2026 07:41
@Git-on-my-level
Git-on-my-level merged commit f95b73c into main Oct 29, 2026
76 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/merge-first branch October 29, 2026 07:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

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 ✅ Completed 2026-10-29T07:44:33.025574Z 440544d 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
Second sync: main advanced past ce20e1b with #23931 (occasion
merge-first) and the adapter lane; GitHub reported mergeStateStatus
DIRTY at 07:43Z. Merge commit, no rebase, per lead rules.
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