Skip to content

fix(sync): prevent tombstone privacy stalls in owner projection - #23783

Merged
Git-on-my-level merged 5 commits into
mainfrom
lane/projfence
Oct 27, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
lane/projfence

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Problem and behavior

A DELETE that returned 409 account_gate_busy could leave a deletion tombstone on a still-live conversation. A late batch upload could select that row as canonical, repeatedly fail privacy validation, and block every later capture in the owner's projection chain.

Assignment now excludes transactional deletion tombstones and re-plans once when validation discovers deleted ancestry. If donors still refuse, the complete input speech is projected into a new deterministic conversation without inherited donor ancestry. A no-text, zero-speech terminal privacy receipt requires transactional tombstone proof on the input's own source/target or guarded redirect chain. Unrelated deletion never authorizes dropping live input. Account, protection, generation, ledger ownership, predecessor, and other source fences remain authoritative. A source deleted before its projection policy was pinned can settle without pinning a policy or assigning text.

Cascade DELETE takes the existing account gate before recording intent. The retraction-skip check stays after intent under that gate, so an earlier canonical commit cannot make a pre-gate emptiness hint stale. Nested retraction reuses the gate; a busy gate leaves no tombstone or cleanup and keeps the existing retryable 409. Successful DELETE remains 204.

Discovered live-overlap candidates and redirect survivors obey the same tombstone exclusion, including nonbatch assignment. Prior multipart outputs are fenced separately from original inputs: deleting an earlier output retires its receipt and followups while preserving assigned speech accounting and allowing later parts to project. A deleted output cannot authorize terminal deletion of another part's input.

Validation

  • Targeted backend unit shards via backend/test.sh and BACKEND_UNIT_TEST_FILE_LIST (file isolation, four workers): 376 passed across 15 files.
  • Hermetic sync harness: bash backend/testing/e2e/run.sh -q -k sync (11 passed).
  • Real loopback Firestore emulator: 31 passed, covering historical tombstone/live-row owner sweep, busy DELETE plus late upload, terminal privacy settlement and later independent captures, source deletion during projection, multipart output deletion, account/protection/generation/ledger/predecessor/redirect refusal, and superseded replay boundaries.
  • All tests/builds run through omi-heavy under nice -n 19. Additional planner size-rollover and privacy/policy contract checks and repository preflight are recorded before push.

One Luna review is required. Lead owns merge and the backend deployment train. Production recovery is a separate post-deploy aggregate check; no production writes or deployment are performed by this lane.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

Line-Count-Exception: backend/routers/conversations.py | 2414 -> 2446 | Keep gate acquisition and the existing deletion response/cleanup sequence together for this bounded privacy race repair; broader router extraction is outside the incident fix.

The ordered batch's deterministic privacy refusal was an unbounded poison head. The reusable prevention is bounded re-planning plus a transactional, reasoned terminal receipt, covered by backend/tests/integration/test_batch_projection_delete_race_firestore.py and the shared strict Firestore assignment tests.

…ection

Exclude tombstoned live rows and re-plan deleted ancestry once before writes.
Persist no-text privacy dispositions to release the owner chain, retaining
binding, ledger, predecessor and all non-deletion privacy fences. Acquire the
account gate before conversation deletion intent and preserve retryable 409.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
Require a source or guarded redirect tombstone in the receipt transaction
before terminal privacy settlement. If two donor plans refuse, preserve all
input speech in a new deterministic conversation without donor ancestry.
Keep the retraction-skip decision after intent under the cascade gate.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
Declare the existing dictionary schema at its read boundary so the local
privacy-only hint does not widen normalized_binding's dictionary argument.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T06:29:46.856745Z 34adbcd 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.

…etion

Exclude tombstoned live overlap candidates and redirect survivors in all sync
assignment routes. Separate previous output deletion from original input
privacy proof, retire deleted output receipts without erasing speech usage,
and keep later multipart input eligible for assignment.

Add live overlap and Firestore race regressions and align isolated delete
fixtures with account gate acquisition.

Failure-Class: FC-batch-fault-domain-head-of-line-poison
Keep input and output refusal semantics separate while charging every distinct
conversation document and refused tombstone to the same transaction attempt.
Repeated checks do not consume another slot, and caught output deletions cannot
relax the 256-document ceiling. Narrow validated completed results to mappings.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

@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: 34adbcd277

ℹ️ 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 +520 to +524
old = {
**old,
'new_memories': new,
'updated_memories': updated,
'deleted_output_segments': deleted_output_count,

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 Persist the reconciled completion result before returning it

When an output is deleted after ledger completion but before a projection retry finishes publication, this branch removes its ID only from the returned dictionary. The ledger's result and the jobs' client_result remain unchanged because the early return bypasses their updates below. Consequently, publication receives the reconciled result while ProjectionStore.status() and content-ledger replays continue returning the deleted destination indefinitely. Persist the reconciled result to the durable completion records without changing historical usage accounting.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 9fa9f3d into main Oct 27, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/projfence branch October 27, 2026 06:38
Git-on-my-level added a commit that referenced this pull request Oct 27, 2026
## Problem and behavior

A language-guarded window longer than the fixed 60-second independent
recovery limit could remain prepared when strict CPU VAD found no spans.
Every recovery wake downloaded and inspected the same audio again, with
no possible paid start or durable refusal.

Recovery now transactionally records an independent_duration_limit
refusal and retains the unit as failed_held before any paid start. It
keeps encrypted audio, worker VAD evidence, and the maximum held speech
census. Successful siblings can finish as partial while this audio
remains retained for a separate recovery plan. The existing paid-redrive
tool requires a started intent and cannot adopt this no-spend refusal;
the 60-second independent limit still applies. This change stops the
loop without transcribing longer units. No speech result is fabricated
and no provider call is added. Temporary settings, lower runtime caps,
and allowance refusals retain their existing retry behavior.

The transaction requires the current prepared token, original ledger and
privacy generation, no existing result, and no live worker lease. It
uses the validated WAV duration, checks the same immutable audio URI,
and rechecks the inspector's 0.1-second stored-duration tolerance. A
concurrent paid start, stale token, changed privacy state, other audio,
or other owner cannot be retired through this path.

## Validation

- backend/test.sh with BACKEND_UNIT_TEST_FILE_LIST covering language
recovery, quarantine recovery, and speech redrive: 268 passed
(104+134+30), including stored59.96s/decoded60.04s and
stored60s/decoded60.04s boundaries.
- Hermetic sync harness: 11 passed, 129 deselected.
- Strict transaction regressions cover retained zero/positive worker
census, one download across repeated deliveries, no provider calls,
partial sibling completion, and
stale/running/leased/receipted/privacy-blocked refusal.
- Tests run serially through omi-heavy under nice -n 19. Mandatory
repository push gates and remote CI are recorded separately.

Follow-up to #23783 under lead ruling 08863e; this PR requires review
and green CI before handoff. Lead owns merge and deployment. No
production write, flag flip, provider spend, or deployment is performed
by this lane.

Failure-Class: FC-batch-fault-domain-head-of-line-poison

The regression in backend/tests/unit/test_batch_language_recovery.py
ensures an impossible prepared recovery reaches reasoned held custody
after one inspection, preserving audio and all positive speech evidence.
kodjima33 added a commit that referenced this pull request Nov 11, 2026
…wn deletion gate (#24988)

## Problem (P0, privacy)

`DELETE /v1/conversations/{id}?cascade=true` answers `409
account_gate_busy` for everyone. Prod (Cloud Run `backend`), 2026-11-09
09:00 to 11:35 UTC: **371 of 374** such DELETEs returned 409, **0
returned 204** (the other 3: 2×504, 1×401), across 31 client IPs and 186
distinct conversations. Memory deletes look the same: `DELETE
/v3/memories*` since 06:00 UTC, **1487 of 1491** returned 409.

The route turns the gate exceptions into a 409 without logging, so these
requests leave no traceback. The evidence below comes from Firestore and
the code path:

- `legal_hold_deletion_gates` (one doc per uid, read-only query):
`explicit_memory_deletion` gates ending in `failed` (acquired, then the
body raised) go from **0 on 2026-10-26** to **49 on 10-27** and
80–170/day since. Today: 80 failed vs 12 completed. Only 7 gates are
`running`, so stale gates across accounts are not the cause.
- 272 of the 371 conversation 409s return in under 0.2 s. These are
retries hitting a gate held by the same account. About 99 run longer:
those acquired the gate and failed inside the body.

## Root cause: the request blocks on its own gate

1. `delete_conversation` takes `destructive_operation_gate(uid,
kind='explicit_memory_deletion')` for the whole cascade body. Introduced
by **#23783** (David Zhang, commits fe4499a + 1bba122, merged
**2026-10-27 06:38 UTC**). The analyst found the last normal success at
2026-10-27 16:57 UTC.
2. Inside the body, `delete_conversation_and_frame_evidence` →
`delete_conversation_with_sync_sources` →
`conversations_db.delete_conversation` starts with
`speaker_auto_enroll.retract_conversation` (#23625, 2026-10-26), which
runs `external_write_fence(uid, transaction=...)`.
`delete_transcript_chunk_vectors` is fenced the same way without a
transaction (#22835, 2026-10-20).
3. `external_write_fence` reads `legal_hold_deletion_gates/{uid}`, sees
the request's **own** running gate, and raises
`DestructiveOperationInProgress: external data write blocked by
destructive operation`. The `_EXTERNAL_TRANSACTION` reuse only covers
writes nested inside another transactional fence, not writes under a
gate the request owns.

Effect: the tombstone is written and memories and action items are
retracted, but the conversation doc, its vectors and its audio stay. The
client retries and gets 409 every time. One Windows client retried 144
times.

## Fix

`external_write_fence` now lets a write through only when the running
gate is the one **this context** acquired: `_ACTIVE_GATE == (uid,
gate.kind, gate.token)` and `gate.uid == uid`. Unchanged:
- other requests (they have no `_ACTIVE_GATE`), other accounts, and a
holder displaced by a stale takeover (its token no longer matches) are
still blocked;
- account deletion (`account_deletions/{uid}`) still blocks, including
the gate owner;
- a pass through the owner's own gate sees a running gate, so `reusable`
stays false and the result is never cached for other writers;
- canonical intake (`assert_no_destructive_operation_transaction`) stays
strict even inside the owner's context.
`test_ws_j_delete_privacy::test_delete_all_final_rescan_tombstones_concurrent_write`
still proves an inline intake write is refused.

## Tests

- New:
`test_legal_holds.py::test_gate_owner_nested_writes_are_not_blocked_by_their_own_gate[False|True]`,
`…exemption_never_reaches_other_requests_or_accounts`,
`…exemption_ends_after_peer_takeover_and_never_skips_account_deletion`.
- New, route level with the real gate on a fake Firestore:
`test_conversation_delete_wire_contract.py::test_cascade_delete_nested_fenced_writes_do_not_hit_their_own_gate`.
Before the fix it fails with `409 != 204`. The existing wire tests
replaced the gate with `nullcontext()`, which is why they never caught
this.
- Without the fix, the 3 new reproduction tests fail. With it, all 83
unit test files that reference the gate or fences pass (3128 tests).

## Not proven

- Which nested call blocks **memory** deletes (`MemoryService.delete` /
`delete_batch` under `_legal_hold_gated_deletion`). The fix covers any
nested `external_write_fence` in that path. If a memory-path self-block
goes through `assert_no_destructive_operation_transaction` instead, this
PR does not fix it. Check memory DELETE 409 rates after deploy.
- Conversations left half-deleted between 2026-10-27 and the deploy
(tombstoned but still stored) need a cleanup pass. Not in this PR.

## Scope after review
This fixes cascade **conversation** deletes only. Memory deletes
(`routers/memories.py`) never reach a nested `external_write_fence`;
their 409s are tracked separately (likely #24886, which made stale
memory-vector cleanup on read paths take the exclusive account gate).
About 272 of the 371 conversation 409s sampled today fail before the
delete body runs (gate acquisition), which this PR does not change;
check the 204 rate after deploy.

Added after review:
`test_gate_owner_pass_is_never_cached_for_other_writers` (privacy_ttl60
on): the owner passes its own fence, a writer in a fresh context still
raises and re-reads live authority every time. It fails if the owner
pass is made reusable (`legal_holds.py:534`).

## Product invariants affected

none

Failure-Class: FC-destructive-gate-keyed-on-proxy-for-intent

UI-Evidence: none

🤖 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/24988?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/24988?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24988&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. -->
dwaddle pushed a commit to dwaddle/omi that referenced this pull request Nov 11, 2026
…r own deletion gate

Cascade conversation deletes acquire the account's explicit_memory_deletion
gate (BasedHardware#23783) and then run nested provider writes that each open
external_write_fence for the same uid (speaker auto-enroll retraction inside
conversations_db.delete_conversation, transcript-chunk vector delete). The
fence read the request's own running gate and raised
DestructiveOperationInProgress, so every cascade delete answered 409
account_gate_busy and left the conversation in place.

external_write_fence now lets through only the context that acquired the
running gate (same uid, kind and token). Other requests, other accounts, a
displaced holder after takeover, and account deletion still block, and
canonical intake (assert_no_destructive_operation_transaction) stays strict.

Failure-Class: FC-destructive-gate-keyed-on-proxy-for-intent

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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