Skip to content

Supersedes #20891: fix(sync): reject soft-deleted conversation tombstones in capture provenance - #23080

Open
omiagent[bot] wants to merge 1 commit into
mainfrom
community/revive-20891
Open

omiagent[bot] wants to merge 1 commit into
mainfrom
community/revive-20891

Conversation

@omiagent

@omiagent omiagent Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What this does, in plain terms

When a conversation is deleted in Omi, the server keeps a hidden "tombstone" record so deleted data stays deleted. This fix closes a gap where that hidden tombstone could still pass capture provenance verification — a capture file could be proven as belonging to a conversation the user already deleted, as long as timestamps lined up within the matching window. Concretely, a deleted conversation could get fresh capture files attached to it and its sync requests elevated into the trusted sync lane. After this change, soft-deleted conversations never match capture provenance; active conversations behave exactly as before.

Credits

Carried forward from #20891 by @miso466 — cherry-picked with the original authorship intact (git author preserved). The entire diff is the author's; this superseding PR exists only because the fork branch cannot be updated directly.

Supersedes #20891.

What changed and why

Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763, #20772, #20783, #20800, #20871, #20877.

Reject soft-deleted conversation tombstones in capture_matches_server_conversation to prevent tombstone bypass in capture provenance verification.

In capture_matches_server_conversation (backend/utils/sync/provenance.py), validation for whether a parent conversation is soft-deleted was missing when verifying capture file provenance for server-created conversations.

Even when a conversation was soft-deleted (deleted: True), capture_matches_server_conversation would return True as long as timestamps aligned within the configurable time-matching tolerance window (slop window), allowing:

  1. claim_fresh_capture_provenance (POST /v1/sync/capture/manifest) to associate manifest claims with soft-deleted conversation tombstones.
  2. POST /v1/sync (sync_files) to grant has_server_capture_proof and elevate sync requests targeting deleted conversations into the trusted sync lane (classify_sync_lane).

This fix:

  1. Rejects soft-deleted tombstones in capture_matches_server_conversation (backend/utils/sync/provenance.py), returning False immediately when conversations_db.is_soft_deleted(conversation) is true.
  2. Adds unit tests covering active matching, soft-deleted tombstone rejection, missing conversations, device mismatch, invalid timestamps, and window bounds.

Regression Risk

Zero. Only affects soft-deleted conversations (deleted: True). All active conversations continue to match captures identically.

Product invariants affected

none

How it was verified

Tests

  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_active_matches
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_rejects_soft_deleted_tombstone
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_missing_conversation
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_mismatched_device
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_missing_ids
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_invalid_timestamps
  • backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_outside_window

Failure class (fixes)

Failure-Class: none

View guided diff Turn on auto-fix

…venance

Reject soft-deleted conversation tombstones in
`capture_matches_server_conversation` by checking
`conversations_db.is_soft_deleted(conversation)`.

Failure-Class: none
@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution backend Backend Task (python) labels Oct 21, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

The production change here is correct and nicely scoped — a genuine tombstone-bypass fix with the right shape; leaving formal approval to a human maintainer because it touches trust-lane elevation.

Verified on the current head:

  • backend/utils/sync/provenance.py:25-30 — the new guard inserts conversations_db.is_soft_deleted(conversation) into the existing early-reject chain ahead of the device-id and timestamp checks, so soft-deleted tombstones now return False before the 30-minute slop window is even consulted. Strictly fail-closed: no previously-rejected input becomes accepted.
  • database/conversations.py:813 — is_soft_deleted is the established shared tombstone predicate (bool(conversation.get('deleted'))); legacy documents without the field return False, so old conversations are not falsely rejected.
  • utils/sync/fsr_metadata.py:38 — 'deleted' is in PROVENANCE_FIELDS, so the predicate works on both read_metadata paths (full read and field-masked snapshot).
  • routers/sync.py:255 and routers/sync.py:1060 — the two callers behave exactly as the PR describes: POST /v1/sync/capture/manifest claims against a tombstone now get the 403, and POST /v1/sync no longer grants has_server_capture_proof for deleted conversations.
  • backend/tests/unit/test_sync_provenance.py — good coverage: active-match baseline, tombstone rejection (asserts capture_times_within_window is never reached), missing conversation, mismatched device, missing ids, invalid timestamps, outside window. All 7 pass locally on this head; CI is green including the Hermetic Merge Gate.

Security: this closes a path where deleted-conversation tombstones could still acquire fresh capture provenance and elevate sync requests into the trusted lane — blast radius if wrong is limited to sync admission, and the direction of change is reject-more.

USER IMPACT: conversations a user deleted can no longer get new capture files attached or re-enter trusted sync; active conversations behave exactly as before.

Nothing blocking from my side. Given it changes trust-lane elevation logic, final merge sign-off belongs to a maintainer — it is ready for that.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants