Skip to content

fix(v3): batch projection applies v3 admission to sync rows it creates - #25718

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/v3-batch-projection-admission
Nov 18, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/v3-batch-projection-admission

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

v3-admitted owners keep getting legacy completed sync conversations beside their v3 recordings. These rows have relevance_decision.trigger sync_intake/sync_update and a sync revision, but no recording and no terminal_no_derived_effects. They show as duplicate Home cards and get full legacy notes, memories and action items, so we pay for the LLM work twice. A read-only audit (prod at 9c88e7f, last 6h) counted about 2,925 such rows across 235 of the 410 owners with v3 recordings. About 89% overlap a v3 recording of the same owner, and 1,662 were kept and enriched.

Root cause

Two writers create sync rows, and only one applies v3 admission:

  • Sync intake marks the row. utils/conversations/lifecycle.py:215-244 ingest_sync_conversation calls triggers.mark_new(uid, incoming) before assign_sync_conversation. It then calls triggers.changed() when the assigned row is a recording.
  • Batch projection does not. utils/batch_pipeline/projection.py assign_parts (~1137-1170 on main) builds incoming with build_incoming (:287) and calls conversations_db.assign_sync_conversation directly. It never calls mark_new or changed.
    • assign_in_transaction stamps a created row sync_intake (utils/sync/assignment.py:1008). The row is completed and legacy, so enrichment runs the full legacy notes (sync_update).
  • Admission itself is fine. Config is correct on every service, and conversations_v3_enabled works the same for both paths. Projection just never asks.

Prod evidence (read-only; counts only):

  • Logs (ro-prod, 6h): ingest_sync_conversation logged omi_sync_intake 60 created and 4,920 merged fleet-wide, on backend-listen and backend-sync. Over the same 6h, projection's owner_drain (Cloud Run backend-integration) advanced at least 27,214 units; the read was capped at 20k log lines. Intake creates cannot account for about 2,925 new legacy rows.
  • One admitted owner (Firestore, flag fields only, since 06:00Z): 49 completed legacy sync rows (34 sync_intake, 15 sync_update) sit among 107 v3 recordings. 32 of the 49 are named by that owner's batch projection receipts (job read capped at 20k). 29 of the legacy sync_intake rows were later absorbed (deleted, sync_merged_into) into a v3 recording by a later marked chunk. The rest remain as duplicates.

Fix

  • Projection calls triggers.mark_new(owner, incoming) right before assignment. That is the same boundary and the same admission as sync intake, and owners who are not admitted are unchanged.
  • After a committed assignment whose row is a recording, projection calls triggers.committed_sync_assignment, which calls triggers.changed. It runs post-commit and is never fatal (event=batch_projection action=v3_wake outcome=error), so it cannot replay the unit.
  • A static contract test fails if any caller of assign_sync_conversation that can create rows from new speech does not call mark_new. utils/sync/bridge.py re-assigns existing rows and is exempt.
  • No flag. CONVERSATIONS_V3=off and the stage gate still decide admission.
  • Not touched: v3 commit_projection, service._commit and reconcile. Another lane owns those.

Known limit (same as sync intake today)

mark_new marks only the incoming chunk. When a marked chunk joins an existing legacy canonical row, the canonical keeps its legacy shape: assignment builds the result from the canonical (utils/sync/assignment.py:697). Sync intake behaves the same way. With this fix, such canonicals are limited to rows created before it shipped and to chains that were already running when the owner was admitted. Promoting or splitting a processed legacy canonical is a separate design change and is covered by the cleanup proposal.

Existing rows

This change does not touch rows already created. Some heal on their own: a later marked chunk that overlaps a legacy row absorbs it into a v3 recording. On the sampled owner that happened to 29 of 34 legacy sync_intake rows; 16 legacy rows remain, 9 of them not discarded (duplicate cards with legacy notes). The cleanup is a separate step run by an operator; it is proposed in the lane record, and this PR does not run it.

Test plan

  • New backend/tests/unit/test_batch_projection_v3_admission.py, synthetic data. It covers:
    • an admitted owner's projected row is marked (recording, terminal_no_derived_effects, v3_pending, empty structured) and its reconcile is woken;
    • an owner who is not admitted stays legacy;
    • an append into a stored recording wakes reconcile;
    • a wake failure after commit still finishes the unit;
    • every function that calls assign_sync_conversation with new speech, including the (a or b)(...) call form, also calls mark_new.
  • Against the unfixed projection.py, 4 of these fail (the three behaviour tests plus the caller contract for projection.py).
  • Existing suites pass: test_batch_pipeline_projection.py, test_conversations_v3_contract.py, test_batch_pipeline_owner_chain_projection.py, test_batch_pipeline_projection_donor_dedupe.py and test_batch_pipeline_empty_disposition.py.

Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1866 -> 1871 | v3 admission must run at the projection assignment call; the wake helper lives in utils/conversations/v3/triggers.py

Failure-Class: new

🤖 Generated with Claude Code

Git-on-my-level and others added 3 commits November 19, 2026 01:50
Batch projection called assign_sync_conversation directly and never ran
triggers.mark_new, so every row it created for a v3-admitted owner was a
legacy completed conversation beside the owner's v3 recordings (duplicate
Home cards, double legacy notes). Mark at the assignment boundary like
sync intake, and wake the v3 reconcile post-commit when the assigned row
is a recording. A static contract test requires every new-speech caller
of assign_sync_conversation to apply mark_new.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l form

Panel review-20261118t195255-b800 F2.

Failure-Class: new

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bridge by function (panel)

Failure-Class: FC-admission-marker-skipped-by-sibling-writer

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 9f116b3 into main Nov 18, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/v3-batch-projection-admission branch November 18, 2026 22:09
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