Skip to content

Fence Python post-effects episode writes against deletion - #26190

Merged
Git-on-my-level merged 5 commits into
mainfrom
agent/multica-worker-2-codex-sol/e0662157f531
Nov 24, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
agent/multica-worker-2-codex-sol/e0662157f531

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T03:28:32.309479Z b007431 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1273 to +1277
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +15 to +19
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit d5d0b95 into main Nov 24, 2026
66 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/multica-worker-2-codex-sol/e0662157f531 branch November 24, 2026 07:31
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 24, 2026
…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)
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