Repository navigation
Fence Python post-effects episode writes against deletion - #26190
Conversation
Co-authored-by: multica-agent <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: af4ca2c0c2
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| c = replace(c, finalizing_conversation_id=conversation_id) | ||
| outcome = _on_finalized(uid, conversation_id, row, trigger, absorbed_from, c) | ||
| if outcome == 'skipped_deleted': | ||
| return outcome | ||
| outcome = composer.after_finalized(uid, conversation_id, outcome, c, row=row if not absorbed_from else None) |
There was a problem hiding this comment.
Add the required conversation-lifecycle change note
This changes conversation-finalization ordering and deletion fencing, but the commit contains no pipeline change note. backend/AGENTS.md explicitly requires a note under backend/docs/listen_pusher_pipeline/changes/ for conversation-lifecycle changes. Repository searches for SCA-4083 and the new fence names found no corresponding documentation. Add the required note describing the changed behavior, rollout state, and verification evidence so these lifecycle guarantees remain discoverable outside the commit message.
AGENTS.md reference: backend/AGENTS.md:L164-L164
Useful? React with 👍 / 👎.
| for ref in (account_deletion_document(uid, firestore_client=client), tombstone): | ||
| snapshot = ref.get(transaction=transaction) | ||
| record_document_read(site, FirestoreReadOutcome.HIT if snapshot.exists else FirestoreReadOutcome.MISS) | ||
| if snapshot.exists: | ||
| raise EpisodeFinalizationDeleted |
There was a problem hiding this comment.
Honor restored account states in the deletion fence
For users who restore an account during the deletion grace period, _restore_user_deletion_txn in database/account_deletion_grace.py retains the marker and sets wipe_status='cancelled'. The shared policy in database/account_deletion_policy.py explicitly permits both cancelled and billing_failed, but this existence-only check rejects them indefinitely. Consequently, these active users' guarded episode updates and finalized attach memos are silently skipped. Apply account_deletion_marker_blocks_access to the account snapshot while retaining the existence check for conversation tombstones, and cover the allowed statuses in the regression tests.
Useful? React with 👍 / 👎.
Co-authored-by: multica-agent <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Co-authored-by: multica-agent <[email protected]>
…are#26190) ## Summary SCA-4083 fences Python post-effects episode writes inside their Firestore transactions. Transcript-tail commits, episode closes, episode updates including discarded-row reconciliation, recorded sync attachment after a memo miss, sync rejoin, and finalized attach memos recheck the account deletion marker and the source conversation tombstone before writing. The shared account policy permits `cancelled` and `billing_failed` markers. Any conversation tombstone still blocks the write, and retries recheck current authority. The [pipeline change note](backend/docs/listen_pusher_pipeline/changes/2026-11-24-episode-finalization-deletion-fence.md) records the behavior, verification and rollout. ## Verification - The scoped repair passed all 181 existing focused tests plus four new race cases, for 185 passes. The new cases insert each deletion marker before the recorded attach and reopen transactions and assert that stored state is unchanged. - On the prior revision, 1,357 episode unit tests and 61 Firestore emulator tests passed. The Home read fixture import error and discarded-anchor emulator mismatch were also present on the base. - The prior Hygiene failure is the overdue `OMI_INDEXED_LIST_READS_ENABLED` retirement, reproduced on `origin/main`. ## Release readback R19 full custody and deletion review is required before merge and rollout. On the serving revision, sum the increase in `omi_firestore_document_reads_by_site_total` across outcomes for `site=~"episode_finalization_(update|memo|moment|close)_fence"` during a controlled replay and divide by the number of finalizations in each case. Each guarded transaction attempt adds up to two reads. An update and memo that each run once add four reads, and a memo retry after transcript preload adds another pair. Tail, close, recorded attachment and reopen contribute their own reads when exercised. Recorded attachment and reopen use the episode update metric label. Record the serving revision and replay window in SCA-4083 before using the results as the Python R7 baseline. Rollback by reverting this PR. Line-Count-Exception: backend/utils/episodes/service.py | 2318 -> 2345 | Carry the finalizing conversation through existing episode writer calls and return the deletion outcome before subsequent finalization effects. (cherry picked from commit d5d0b95)
Summary
SCA-4083 fences Python post-effects episode writes inside their Firestore transactions. Transcript-tail commits, episode closes, episode updates including discarded-row reconciliation, recorded sync attachment after a memo miss, sync rejoin, and finalized attach memos recheck the account deletion marker and the source conversation tombstone before writing. The shared account policy permits
cancelledandbilling_failedmarkers. Any conversation tombstone still blocks the write, and retries recheck current authority.The pipeline change note records the behavior, verification and rollout.
Verification
OMI_INDEXED_LIST_READS_ENABLEDretirement, reproduced onorigin/main.Release readback
R19 full custody and deletion review is required before merge and rollout. On the serving revision, sum the increase in
omi_firestore_document_reads_by_site_totalacross outcomes forsite=~"episode_finalization_(update|memo|moment|close)_fence"during a controlled replay and divide by the number of finalizations in each case. Each guarded transaction attempt adds up to two reads. An update and memo that each run once add four reads, and a memo retry after transcript preload adds another pair. Tail, close, recorded attachment and reopen contribute their own reads when exercised. Recorded attachment and reopen use the episode update metric label. Record the serving revision and replay window in SCA-4083 before using the results as the Python R7 baseline.Rollback by reverting this PR.
Line-Count-Exception: backend/utils/episodes/service.py | 2318 -> 2345 | Carry the finalizing conversation through existing episode writer calls and return the deletion outcome before subsequent finalization effects.