Skip to content

fix(conversations-v3): multi-batch projection readback ignores the Home commit stamp (owner livelock) - #25734

Merged
Git-on-my-level merged 2 commits into
mainfrom
fix/v3-multibatch-readback-stamp
Nov 19, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
fix/v3-multibatch-readback-stamp

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

After #25714 deployed, fleet parks fell from 85 to 6, but the product owner stayed wedged: still parked on document_too_large, with 17 rows stuck at writing.

Root cause: a multi-batch projection commit treats its own Commit-hook stamp as an external change.

  • home_feed_writer.augment_home_writes (database/home_feed_writer.py:169) adds a fresh random home_source_version to every conversation write at the Commit boundary. When transcript fields change, it also adds home_content_invalidated.
  • After each non-final batch, commit_projection reads its own writes back (database/conversations_v3.py:649-682).
    • Derived rows: the readback compares every encoded field with the stored doc. A row rebuilt from a prior carries the prior's home_source_version (planner.build merges **existing). The hook replaced it, so the check raises source_changed.
    • Recordings: the same stamp is not in the readback's owned set. Every recording therefore looks changed and is marked moved.
  • The result: every pass commits batch 0 and then races. The final batch, which clears pending markers and resets the park, never lands.

Evidence (prod, read-only, owner on prod-operator; field names and counts only):

  • A 7-minute watch of the owner's documents: every ~70 s a pass takes the builder lease and commits one transaction of 151 documents (68 sources and 83 derived rows). It releases the lease about 1 s later, and batch 1 is never written. Nothing else writes those documents in between.
  • An in-process replay of the owner's pass, with every writer stubbed: 95 planned rows in batches of [83, 12], no duplicate ids, and every encoded field survives an SDK round trip.
    • The real commit_projection, run against an in-memory copy of the closure without the Commit hook, commits both batches.
    • The only difference from prod is the hook's stamp.
  • The unit test below emulates the hook and fails on main. Before fix(conversations-v3): stop source claims doubling past the 1 MiB limit; size batches on every write #25714 this owner never reached the readback, because batch 0 failed on document_too_large first.

Fix

  • home_feed_writer.COMMIT_STAMPED_FIELDS names the fields the hook stamps. The readback ignores them for both derived rows and recordings.
  • A test pins that set to what augment_home_writes actually adds.
  • Any other change between batches still conflicts. It now logs v3 projection readback changed kind=<derived_row|recording> batch=<i> fields=[...], with field names only.

Related findings (not changed here)

  • Race-wake enqueue 500s at 22:51–22:53Z (triggers.enqueue → cloud_tasks.enqueue_named_task:458) were Cloud Tasks transport errors: UNAVAILABLE ("Connection reset by peer") and DEADLINE_EXCEEDED. They were not tombstone or ALREADY_EXISTS dedup; that path logs "already enqueued, skipping duplicate" and succeeds. The 500 is the designed fallback: Cloud Tasks retries the task.
  • 18 rows completed/tile_state=failed, reason attempts_exhausted:
    • The notes writer fences its persist on the row's update_time (database/conversations_v3_processing.py:38, summary_source_changed).
    • The livelocked builder rewrote every batch-0 row about every 70 s (and earlier this morning). Each rewrite bumps update_time, plus the hook's stamp, so in-flight notes lost their fence twice and begin_processing failed them (conversations_v3_processing.py:247-249).
    • Fixing the livelock stops the rewrite storm. These rows stay summary_retryable for the client retry.

Test plan

  • New backend/tests/unit/test_conversations_v3_commit_readback.py, with a fake Commit hook that stamps each write (6 tests):
    • a 64-row commit that is asserted to split into at least two batches reaches the final batch, clearing pending and the park;
    • an external change between batches still raises source_changed, and the log names the field but no ids. This is covered for a derived-row field and for the recording fence fields is_locked and data_protection_level;
    • live speech appended between batches is still marked moved;
    • the stamped-field set equals what augment_home_writes adds, for both a transcript write and a metadata-only write.
  • Run against unfixed conversations_v3.py, 5 of the 6 tests fail.
  • Change note: backend/docs/listen_pusher_pipeline/changes/2026-11-19-v3-readback-home-stamp.md.
  • The v3 and home-feed unit suites pass.

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits November 19, 2026 06:37
…h projection reads its writes back

augment_home_writes stamps a fresh home_source_version (and home_content_invalidated) on every
conversation write at Commit. The between-batch readback compared every written field, so the
stamp looked like an external change: each pass committed batch 0 and raced, and the final batch
that clears pending markers and resets the park never landed.

- Name the stamped fields (home_feed_writer.COMMIT_STAMPED_FIELDS) and exclude them from the
  derived-row and recording readback; any other change still conflicts.
- Log the document kind and changed field names when a readback conflicts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rding compare (panel review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit a6824b8 into main Nov 19, 2026
69 of 73 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/v3-multibatch-readback-stamp branch November 19, 2026 00:29
Git-on-my-level added a commit that referenced this pull request Nov 19, 2026
…g the Firestore hook (main red after #25734) (#25739)

## Summary
Main went red after #25734. `database/conversations_v3.py` imported
`COMMIT_STAMPED_FIELDS` from `database/home_feed_writer.py`, which
imports `google.cloud.firestore_v1.types` at load time. That put the
import on the chain routers/conversations → v3 summary →
conversations_v3 → home_feed_writer.

Isolated-router unit tests stub `google.cloud.firestore_v1` as a plain
module, not a package, so they fail with `ModuleNotFoundError: ...
'google.cloud.firestore_v1' is not a package`. The affected files:
- `test_conversations_date_range_validation`
- `test_conversations_merge_duplicate_guard`
- `test_dev_api_lock_bypass`
- `test_lock_bypass_fixes`
- `test_recovery_rule_skip`

PR CI is graph-selected, so #25734 never ran them.

Production is unaffected, because the real package is installed.

## Change
- Move the constant to a new import-free module,
`database/home_feed_fields.py`.
- `home_feed_writer` re-exports it, so existing references keep working.
- `conversations_v3` imports it from the new module.

## Verification
All five files above pass locally, along with
`test_conversations_v3_commit_readback` and
`test_conversations_v3_claim_growth`.

Failure-Class: none
UI-Evidence: none -- backend import-only change

🤖 Generated with [Claude Code](https://claude.com/claude-code)
MichaelC001 pushed a commit to MichaelC001/omi that referenced this pull request Nov 19, 2026
…an import-free module

BasedHardware#25734 made conversations_v3 import home_feed_writer, which loads
google.cloud.firestore_v1.types; isolated-router tests stub firestore_v1 as
a non-package and fail. Production is unaffected.

Failure-Class: FC-partition-depends-on-arrival-order

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 19, 2026
…changes (#25739 follow-up) (#25742)

## Summary
This is the follow-up from the #25739 panel
(review-20261119t010333-6394, findings F1 and F3).

**F1.** A change to `backend/database/conversations_v3.py`,
`conversations_v3_processing.py`, `home_feed_writer.py` or
`home_feed_fields.py` now selects the five isolated-router tests that
#25734 broke without CI noticing:
- `test_conversations_date_range_validation`
- `test_conversations_merge_duplicate_guard`
- `test_dev_api_lock_bypass`
- `test_lock_bypass_fixes`
- `test_recovery_rule_skip`

These tests load `routers.conversations` fresh with
`google.cloud.firestore_v1` stubbed as a non-package. The import graph
never selects them for those modules, which is how main went red. The
mapping is a new `AREA_TESTS` entry in
`scripts/select_backend_unit_tests.py`.

**F3.** `home_feed_writer` no longer re-exports `COMMIT_STAMPED_FIELDS`.
The readback test now imports it from `database.home_feed_fields`, so it
has a single import path.

## Verification
- `select_backend_unit_tests.py --changed-files` with only
`backend/database/conversations_v3.py` now selects all five.
- `test_conversations_v3_commit_readback` passes.

Failure-Class: none
UI-Evidence: none -- backend CI selection and import path only

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


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25742?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/25742?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25742&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. -->
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