Skip to content

fix(conversations): start summary-only notes after quiet - #25548

Closed
kodjima33 wants to merge 16 commits into
mainfrom
fix/quiet-summary-snapshot
Closed

kodjima33 wants to merge 16 commits into
mainfrom
fix/quiet-summary-snapshot

Conversation

@kodjima33

@kodjima33 kodjima33 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

V3 currently waits for the five-minute conversation boundary before starting automatic notes. Schedule a summary-only snapshot after 30 seconds of accepted speech quiet while the conversation stays live. The existing five-minute boundary, two-hour cap and final processing remain unchanged.

Reuse the existing notes writer and renewable summary lease. Durable content-specific obligations survive interrupted dispatch; transactional input, source, privacy and account fences reject stale results. Photo evidence and speaker attribution use the same normalized authoritative inputs for generation, persistence and freshness. Automatic attempts use a bounded, non-evicting fingerprint ledger; explicit foreground Try Again retains its existing admission. Final processing recomputes provisional notes and remains the only owner of derived memories, tasks and webhooks.

Independent source review 8 approved all production bytes at 87ec62f53e8204a5ff423ab8f68c6186299a05da; review 9 approved the subsequent test-only timing changes at d6a8c0707bf08a849469246091c9b14791ecd7fb, whose CI completed green. Current candidate ffca89c252232112e70acc6e92af764a5251abef merges main 8a3e4bd78b57e3327c0d0ae0085140a907e0dbd1: both conflicting test files retain the incoming tests and reviewed timing setup; the index merge retains main's six terminal __name__ declarations plus the quiet field index. Quiet implementation bytes are unchanged. Fresh independent merge review 10 approved exact head ffca89c252232112e70acc6e92af764a5251abef, with no merge-specific must-fix. Both required checks pass; the remaining CI on this head must finish before merge.

Validation

  • After resolving the main conflict, all 17 focused unit files passed (693 passed; 22 optional chat-Firestore cases skipped), the real quiet Firestore emulator passed 68 cases, and full preflight passed all 45 checks in 70.82 seconds. The owned emulator was stopped and its loopback port verified closed. These are local synthetic-provider results.
  • All 16 affected unit files completed successfully (656 passed; 22 chat-Firestore cases skipped without their explicit emulator environment). The exact committed, post-format quiet-summary emulator passed 68 cases; the canonical Firestore guards passed 894 cases. Regression failures were reproduced before their fixes.
  • The emulator exercises the real processor/persistence around synthetic provider/effect seams, including photo-subcollection final processing, photo races, 129-photo pagination, speaker-authority and resolution-availability corrections, translated/unplaced turn selection, ordered owner corrections, frame-member selectors, desktop reminder clocks, a pre-stamped correction/undo ABA race followed by real automatic recovery, shared leases, durable recovery, pending tails, exact cache and foreground retry. These are not live model or customer timing results.
  • 56 client-processing trust-boundary tests passed, including server-only summary stamp classification, request rejection of those fields, serialization exclusion and preservation across display-projection invalidation.
  • The old database writer is excluded by the repository typecheck. A forced-include baseline/candidate comparison found the same 44 errors and 1,462 warnings, with no new diagnostics and none on the six added lines. Normal pre-push passed for this final head; full CI remains pending.
  • The two CI timing files passed all 63 cases after moving the real commit dependency to collection, validating each page with one compiled schema, and memoizing real speaker projections only for identical full inputs within the 1,200-segment fixture. All 1,200 rows, schemas, cursor/speaker/read-count assertions, CPU budgets and allowlists remain unchanged. No production cache was added.
  • All 81 terminal-family tests passed after moving cold dependency imports from the timed test body to collection; the assertions, CPU limit and allowlist remain unchanged.
  • Fifteen existing mobile live-summary widget tests passed separately. No app production code changed. Merged fix(conversations): preserve recorded silence and canonical transcript windows #25540 has separate three-window iPhone simulator Home/detail/Select/export proof.

The identity covers persisted conversation evidence and transcript-selection inputs. Mutable external speaker evidence, raw capture-group provenance/member frame reads, profile/contact names, derived title/overview retrieval seeds, runtime cohort settings and prompt versions are not newly versioned here; this is not a hash of every effective provider-request dependency.

A normal processor replacement now invalidates prior summary coverage/input/snapshot checkpoints inside the same transaction that writes the replacement, in both serving modes. Only successful final settlement certifies the new result; the snapshot writer retains its existing atomic result/stamp behavior.

Thirty seconds is quiet dispatch, not measured end-to-notes latency. Final recomputation adds a notes call after a successful provisional snapshot. Production model availability, cost and physical-device timing remain unverified. Release qualification requires the new quiet field index, Cloud Tasks binding, v3 gateway lanes and all serving roles; the earlier authenticated outline probe returned model_not_found. No rollout, flags or historical customer data changed.

One additional explicit legacy chat-Firestore run returned 21 passes and one restore-equality failure involving Home bookkeeping. The same failure reproduces on the unchanged 4f62241 baseline; it is recorded separately and is not reported as passing.

Product invariants affected

  • INV-MEM-4: summary-only snapshots never enter memory intake or promotion.
  • INV-TASK-2: early notes do not propose or synchronize derived tasks; normal final processing remains the owner.

Failure class

Failure-Class: FC-split-mutation-authority
Failure-Class-Guard: backend/tests/integration/test_conversations_v3_quiet_emulator.py

UI-Evidence: none (backend summary scheduling only)

Line-Count-Exception: backend/database/firestore_index_registry.py | 2396 -> 2397 | Register the new quiet obligation field index alongside the existing v3 obligation indexes.

Line-Count-Exception: backend/database/conversations.py | 5225 -> 5231 | Atomically invalidate prior summary checkpoints when normal processing replaces their structured output in either serving mode.

@kodjima33
kodjima33 marked this pull request as ready for review November 17, 2026 00:47
kodjima33 added a commit that referenced this pull request Nov 17, 2026
…lands (#25635)

## What changed and why

Goal: a recording's summary within about a minute of it ending, with the
existing Processing row shown meanwhile. For a batch-owned mobile live
recording (`batch_live_v1`, `server_batch_only`), four things held the
first summary back or hid the row. This PR removes all four. It adds no
new user-visible concept and no flag; it shares the
`SYNC_UPLOAD_WATERMARK_ENABLED` kill switch with #25538.

1. **Deadline wait after a complete transcript.** Production runs with
`RECORD_NOTES_EAGER_ENABLED=false` (backend-integration and
backend-sync, read back today). So the record's units marked notes on
the main settle path (`database/batch_pipeline_projection.py:483`, due
+600 s). Dispatch then waited for the 120 s first-summary deadline
(`utils/enrichment/outbox.py:475`), even after the record's last unit
landed.
- Fix: when the record binding completes, `ProjectionStore.complete`
moves the row's existing open notes obligation to due now, inside the
completion's commit transaction. After that commit it writes the
ledger's `transcribed`, and only then wakes the obligation.
- This also fixes a latent ordering race: the old code woke notes before
writing the `transcribed` stage that the woken callback's seal proof
reads.
2. **One held unit blocked the first notes for about an hour.** A unit
whose ASR came back empty is quarantined for recovery. That keeps the
binding's `complete()` open (`batch_pipeline_projection.py:849`), so the
ledger never gets `transcribed`, and #25538's seal proof
(`utils/sync/capture_end.py:248-255`) returns `units_pending`. The
callback (`utils/enrichment/callback.py:125`) then fell back to the 600
s sync quiet wait (`utils/sync/processing_hold.py:20,201`). That wait
restarts whenever a phone copy or a released bridge piece merges in
(`utils/sync/assignment.py:980`).
- Fix: `hold_for_quarantine` already reads every sibling in one
transaction. When every unit is projected or held for recovery and the
row passes `seal_barrier`, it:
- stamps `sync_processing_hold.units_settled_seal_at =
record_sealed_at`, and only on rows that already have a hold state;
- moves the obligation to now in the same transaction, and wakes it
after commit.
- Both wakes (here and in `complete()`) are fail-open, like `_rearmed`.
An exception is logged and left to the outbox sweep. It never fails the
unit job, and in `complete()` it never skips `_mirror` or
`_settle_allowance` after the durable commit.
- `seal_proof` returns `units_held` while the stamp equals
`record_sealed_at`; the metric outcome is `sealed_held`. A reseal
invalidates the stamp.
- A unit that is still transcribing (not quarantined) keeps the existing
wait, so the first summary never fires halfway through a projection.
- **Accepted tradeoff:** a held unit that recovers after the first notes
is late content and follows the existing late-run rules (`immaterial`,
`late_cap`, at most one material late run). So its text can land in the
transcript while staying out of the notes. In `debba5b8` that unit held
4 words.
3. **Summarized rows hidden for up to 2 h.** The processing write merges
maps (`database/conversations.py:1378,1745,1747`), so the stand-in's
`structured.title_provenance='server_minimum'` outlived the real notes.
`is_settling_fragment`
(`utils/conversations/fragment_visibility.py:196`) then kept the
summarized row off `GET /v1/conversations` until 2 h after its end. This
was reproduced on a sync piece reprocessed today.
- Fix: when a processing write carries real notes and omits the marker,
`summary_delivery.merge_result` (called by both writers) deletes it
(`retires_title_marker`).
4. **Home: a row with speech never disappears, and every read agrees.**
- **Where prod Home reads today:** the prod `backend` service runs
`HOME_FEED_ENABLED=false` and no `OMI_INDEXED_LIST_READS_ENABLED`, and
`EPISODES_ENABLED=off`. So prod Home is `GET /v1/conversations`
(`routers/conversations.py:1164-1189`), which classifies full rows. That
path already saw the row-level `summary_title_provenance`. The compact
feed (`database/home_feed.py:338`), the slim list select and the episode
member read classify a field mask that never loaded it
(`utils/conversations/home_titles.py:26`).
- **Change 1:** that field is now loaded, so those paths match the
full-row list. For example, a projected batch row that owes notes shows
the existing "Processing… · Writing notes…" row. No effect in prod until
one of those paths is enabled.
- **Change 2, the settled Home rule:** a row whose only stand-in marker
is the row-level one, with no debt, no summary and **no
`summary_blocked_reason`**, is now classified `ready` (a finished card),
not `noise` (which both app paths hide: `home_rows.dart:376`,
`home_card_rows.dart:29`).
- Only `stamp_projection_debt` marks the row alone, and only when
projected transcript text landed (`live_projection.py:150-157`). So
these rows always carry speech.
- They occur when the projection lands past the repair age gate, or when
a later write clears the debt.
- Rows that truly owe notes still show Writing notes. A row with real
notes is `ready`.
     - These stay `noise`:
- an intake stand-in (`structured.title_provenance`, e.g. "Mm-hmm.")
with no debt;
- a blocked row: `local_only` (including `terminal_no_derived_effects`
and deferred), `blocked_byok`, and `empty_output_exhausted` even with
`HOME_EMPTY_OUTPUT_NOISE=false`.
- **This reverses the "hide" half of 50d85f5's expectation**, limited
to unblocked rows carrying projected speech. The other half, never
presenting "Writing notes" forever, is kept. The `stamp_projection_debt`
docstring and the renamed age-gate test now say this.
- **Measured, read-only:** last 7 days, Nik plus 30 randomly sampled
batch owners, 10,540–11,350 non-deleted rows, current prod flags. **0
rows** flip from visible to `noise` with the new field mask, and **0
rows** reach the provisional branch's `noise`.
- **Limits of that measurement:** it covers only those sampled owners,
not every user. It also cannot cover a flag flip, such as enabling the
feed, the indexed list reads, or setting
`HOME_EMPTY_OUTPUT_NOISE=false`. The blocked-row tests pin the
classification for those cases instead.
- **Not changed here:** prod rows that are `noise` today all come from
other branches. 1,128 are `empty_output_exhausted` (16 of them with a
nonzero word count; Nik's 12 have none) and 24 are below the content
floor. Those are a separate "missing from Home" candidate.

## Prod timeline (read-only Firestore, ledger, batch job docs and Cloud
Run logs, 2026-11-17 UTC)

`debba5b8` (36 min recording, 8 record units, sync live target with one
phone piece merged):

| Step | Time | Wait | Where |
|---|---|---|---|
| Cut (end observed) / audio end | 18:06:05 / 18:06:07 | | listen |
| Record sealed | 18:06:11 | 6 s | `record_sealed_at` |
| Intake claimed → compute admitted | 18:06:15 → 18:06:54 | 43 s | batch
jobs `record_intake_claimed_at`, `compute_decision.at` |
| STT ready, 7 of 8 units | 18:07:11 | 17 s | job `ready_at` |
| Unit `d7ce8acf` (92 s audio, 3.5 s VAD speech)
`worker_failed`/`empty_asr`, quarantined | 18:07:11 | | job
`quarantine_reason` |
| Results committed (ordered merge) | 18:09:03-06 | 114 s | result
`committed_at` |
| Text persisted on the row | 18:09:57-18:10:25 | 52-80 s |
`projection.persisted_at` |
| Notes obligation opened (per-unit marks) | 18:10:52 | 27 s |
`summary_first_pending_at` |
| Released bridge piece / phone copies merged; quiet clock restarted |
18:06:26, 18:12:38 | | `sync_merged_from`, hold `last_content_at` |
| First-summary deadline run → deferred `quiet_wait` (seal proof
`units_pending`, no ledger `transcribed`) | 18:13:09 | 137 s | outbox
`deferred_since`/`deferred_reason` |
| Quiet due | 18:22:38 | 569 s | `processing_hold.py:201` |
| Enrichment request started → summary written | 18:23:26 → 18:24:54 |
48 s dispatch + **88 s processing** | backend-integration request log |
| Held unit's recovery started → projected → binding complete | 19:08:56
→ 19:12:15 | ~62 min held | job `recovery.prepared_at` |

- Before: cut → summary **18.8 min**.
- After (same row, projected): the last unit's mark at 18:10:52 stamps
the seal and wakes notes now, so the summary lands at about 18:12:20
(dispatch plus the 88 s processing). That is about **6.3 min** from cut,
and about 90 s after the transcript became complete on the row.
- A row with no held unit gains the 120 s deadline back. Measured on
`6c2a7917`, ledger `noted − transcribed` = 137 s before this change; it
becomes processing time only.

Other rows:
- `604bd874`: summary at 17:25:54, 18 s after its seal at 17:25:36. The
cut came at 17:25:34, 2 min after audio end at 17:23:35, from the listen
silence cut that a parallel listen PR shortens. Because of that 2-minute
lag, the quiet window had already passed by the seal. This summary was
built from merged phone content; notes were rewritten at 17:45:32 after
the record landed.
- `6ccc2ca6` (pure `sync_vad` piece): summary at 17:40:52, which is
quiet due (last content 17:29:41 + 600 s) plus 71 s. That is the
phone-upload quiet rule, unchanged here.
- Sync pieces `5731e148` / `c35a2059`: held by `pending_live_bridge` for
as long as live target `c92384c3` is `in_progress`.
- The callback re-polls every 30 s (`utils/sync/bridge.py:395-433`), and
hourly after 6 h (`utils/enrichment/outbox.py:69`).
- On the first poll after the target leaves `in_progress`,
`_finish_pending_live_bridge` (`bridge.py:196-244`) merges a piece into
the live row when `choose_live_overlap` picks it and the piece has no
notes. Otherwise the piece is summarized on its own, under its own hold.
- A merge restamps the live row's quiet clock. That restamp is exactly
what this PR's seal proof now overrides for the first notes.
  - So bridge release adds at most about 30 s plus one dispatch.

## Not changed / not verified

- **Batch STT pipeline time.** Seal → transcript complete on the row
took 4 min 41 s here: 43 s intake and admission, 114 s ordered merge,
52-80 s projection, 27 s finish. "Summary under 1 min after the
recording ends" is not reachable until those stages shrink.
- **Processing time.** The LLM notes step alone took 88 s (this 36-min
recording) and about 100 s (a 21-min reprocess). That bounds what
"within a minute of transcript ready" can mean.
- **Quarantine recovery.** Recovery of an empty-ASR unit took about 62
min to start. Untouched here; the held unit now only arrives as late
content.
- **Phone tail upload.** The phone's own upload of the record tail got
`503` for over an hour (`sync_record_upload outcome=pending
reason=audio_coverage_unproven`). It does not gate the summary; not
investigated further.
- **Conversations v3** is untouched (#25548 owns its quiet snapshots).
- **Listen lifecycle** (`routers/listen`) is untouched.
- **Verification level.** Unit tests only. No emulator or prod run, no
deploy, no flag change. Existing stale `structured.title_provenance`
leaves on already-summarized rows clear on their next processing write;
nothing is backfilled.

## Product invariants affected

none

## How it was verified

- Read-only prod evidence: Firestore conversations, `pipeline_ledger`,
`batch_pipeline_prod_jobs`/`_results`, `sync_reprocess_outbox`; Cloud
Run request and app logs.
- Targeted suites, one pytest process per file:
  - `test_record_complete_notes` 46 passed
  - `test_sync_capture_end` 57
  - `test_outbox_firestore` 30
  - `test_summary_delivery` 65
  - `test_home_step` 128
- Every new test fails with its source change reverted. Tests that
assert "unchanged" behavior pass both ways.
- Read-only prod Home measurement (above), with the real
`home_step.classify` under prod's Home env values.
- Follow-up commit: all 156 suites the selector and a grep tie to the
changed files pass, one process each.
- Changed-file selector (`scripts/select_backend_unit_tests.py`): all
selected files, each in its own process. That run caught a decorator
misplacement in an intermediate revision (3 suites), fixed before this
commit. `test_pusher_storage_pcm_saturation` fails its RSS bound on this
Mac on the base commit too.
- Lints: `scan_async_blockers` 0 findings;
`scan_import_time_side_effects` and `check_module_stub_pollution` 0
violations.
- `make preflight` and `scripts/pr-preflight --pr-body-file`.

## Tests

- `test_record_complete_notes.py`:
- eager-off completion makes notes due now, and the ledger write
precedes the wake;
- notes already written, an unsealed record and the kill switch each
leave the obligation alone;
- a held unit stamps the seal and wakes notes, while a
still-transcribing unit does not;
  - a held unit after first notes changes nothing.
- `test_sync_capture_end.py`: the `units_held` truth table (reseal,
barrier); the stamp proves with no ledger read; the kill switch.
- `test_outbox_firestore.py`: `expedite_update` never creates, reopens,
unparks, re-leases or touches blocked or already-due rows.
- `test_summary_delivery.py`: real notes delete the marker through the
production leaf mask, and the stored row is no longer a settling
fragment. A stand-in, empty output and new rows keep or skip it.
- `test_home_step.py`:
- a projected batch row read through `CONVERSATION_FIELDS` classifies
`writing_notes`;
- a past-age-gate stamped row (built with the real
`stamp_projection_debt`) classifies `ready` on both the field-masked
feed read and the full row;
  - a no-debt intake stand-in stays `noise`;
- parametrized `local_only`, `blocked_byok`, and
`empty_output_exhausted` with `HOME_EMPTY_OUTPUT_NOISE=false` stay
`noise`.
- `test_batch_pipeline_live.py`: the age-gate projection test (renamed
`..._stamps_no_debt_and_stays_on_home`) now expects `ready`; it had
pinned `noise`.
- `test_record_complete_notes.py`:
  - the held-unit wake carries the rotated token;
- a raising wake does not fail `hold_for_quarantine` (the row stays due
now);
- a raising wake in `complete()` still returns the result and runs
`_mirror` and `_settle_allowance`.
- Each new test fails with its fix reverted.

UI-Evidence: none -- backend projection fields only; the app renders the
existing server step unchanged.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Change note:
`backend/docs/listen_pusher_pipeline/changes/2026-11-17-sealed-record-first-notes-latency.md`.
Related classes for parts 3 and 4:
`FC-read-projection-omits-visibility-field` (Home field mask) and a
merge write keeping an omitted leaf (no existing class).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@kodjima33

Copy link
Copy Markdown
Collaborator Author

Closing: superseded by #25782, a smaller change on current main with a kill switch. This branch conflicts in 9 files, and main already writes live-conversation notes on open.

@kodjima33 kodjima33 closed this Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @kodjima33 👋

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:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

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!

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