Repository navigation
fix(v3): batch projection applies v3 admission to sync rows it creates - #25718
Merged
Merged
Conversation
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]>
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v3-admitted owners keep getting legacy completed sync conversations beside their v3 recordings. These rows have
relevance_decision.triggersync_intake/sync_updateand a sync revision, but norecordingand noterminal_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:
utils/conversations/lifecycle.py:215-244ingest_sync_conversationcallstriggers.mark_new(uid, incoming)beforeassign_sync_conversation. It then callstriggers.changed()when the assigned row is a recording.utils/batch_pipeline/projection.pyassign_parts(~1137-1170 on main) buildsincomingwithbuild_incoming(:287) and callsconversations_db.assign_sync_conversationdirectly. It never callsmark_neworchanged.assign_in_transactionstamps a created rowsync_intake(utils/sync/assignment.py:1008). The row is completed and legacy, so enrichment runs the full legacy notes (sync_update).conversations_v3_enabledworks the same for both paths. Projection just never asks.Prod evidence (read-only; counts only):
ingest_sync_conversationloggedomi_sync_intake60createdand 4,920mergedfleet-wide, on backend-listen and backend-sync. Over the same 6h, projection'sowner_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.sync_intake, 15sync_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 legacysync_intakerows were later absorbed (deleted,sync_merged_into) into a v3 recording by a later marked chunk. The rest remain as duplicates.Fix
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.triggers.committed_sync_assignment, which callstriggers.changed. It runs post-commit and is never fatal (event=batch_projection action=v3_wake outcome=error), so it cannot replay the unit.assign_sync_conversationthat can create rows from new speech does not callmark_new.utils/sync/bridge.pyre-assigns existing rows and is exempt.CONVERSATIONS_V3=offand the stage gate still decide admission.commit_projection,service._commitand reconcile. Another lane owns those.Known limit (same as sync intake today)
mark_newmarks 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
backend/tests/unit/test_batch_projection_v3_admission.py, synthetic data. It covers:recording,terminal_no_derived_effects,v3_pending, emptystructured) and its reconcile is woken;assign_sync_conversationwith new speech, including the(a or b)(...)call form, also callsmark_new.projection.py, 4 of these fail (the three behaviour tests plus the caller contract forprojection.py).test_batch_pipeline_projection.py,test_conversations_v3_contract.py,test_batch_pipeline_owner_chain_projection.py,test_batch_pipeline_projection_donor_dedupe.pyandtest_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