Repository navigation
Conversation
|
Verified this fix against the head — it is correct and well-scoped.
Regression risk is indeed near zero: only conversations with Because this gates the trusted sync lane (a security- and privacy-sensitive user-data surface), it needs a maintainer sign-off before merge — leaving for human maintainer review rather than a formal approval. This review was generated by an automated maintainer assistant acting on behalf of the Omi maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @miso466 — reviewed on head a89f0a7. backend/utils/sync/provenance.py — the guard is placed correctly: backend/tests/unit/test_sync_provenance.py — good coverage. The tombstone case asserts Backend unit suite and Backend Hermetic Merge Gate pass on this head. This closes a real gap: without the guard, manifest claims could attach provenance to deleted conversations and elevate sync requests into the trusted lane. Since this gates trusted-lane classification, keeping by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verified on head a89f0a7: the new guard in backend/utils/sync/provenance.py correctly routes through conversations_db.is_soft_deleted (the same bool(conversation.get('deleted')) tombstone convention used across backend/database/conversations.py), and because it sits before the timestamp/window checks, a soft-deleted conversation can no longer obtain capture provenance via the slop window — the new test's mock_window.assert_not_called() pins that ordering nicely. I also confirmed both call sites in backend/routers/sync.py (manifest claim verification and sync_files) consume this function to grant has_server_capture_proof, so the fix genuinely closes the trusted-lane elevation path described in the PR body. The seven cases in backend/tests/unit/test_sync_provenance.py cover the full guard chain (active match, tombstone, missing conversation, device mismatch, missing ids, invalid timestamps, window bounds) and patch the right module attributes. One trivial nit, non-blocking: 'import pytest' in the test file is unused. Backend unit suite and the hermetic merge gate are green. Since this changes the sync trust-lane gate (a security-sensitive surface), maintainer sign-off on the security-review label is requested before merge.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
…venance Reject soft-deleted conversation tombstones in `capture_matches_server_conversation` by checking `conversations_db.is_soft_deleted(conversation)`. Failure-Class: none
a89f0a7 to
0f4cf7e
Compare
|
Hey @miso466 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
…ion_photos (#20949) ### Summary Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763, #20772, #20783, #20800, #20871, #20877, #20891, #20895, #20899, #20901, #20935, #20948. Reject soft-deleted conversation tombstones in `store_conversation_photos` to prevent persisting orphaned photo subcollections and mutating soft-deleted conversation documents. ### Problem `backend/database/conversations.py` provides `store_conversation_photos(uid, conversation_id, photos)` to persist conversation photo records into the `photos` subcollection and update the parent conversation's content flags. While it checked physical existence (`if not getattr(conversation_snapshot, 'exists', False): return False`), it omitted checking `is_soft_deleted(raw)`. Because soft-deleted conversations retain their Firestore documents with `deleted: True`, `conversation_snapshot.exists` evaluates to `True`. Consequently: 1. Photos arriving after a conversation was deleted were written into orphaned `photos` subcollections that Firestore does not cascade-delete. 2. The transactional write mutated the soft-deleted parent document via `transaction.update(conversation_ref, {'has_content': True, 'has_photos': True})`, violating the tombstone immutability invariant. 3. Callers relying on the boolean return to stop pipeline steps (such as `backend/routers/listen/transcripts.py`) received `True` and proceeded with post-commit source mutations on soft-deleted conversations. ### Solution - In `backend/database/conversations.py:store_conversation_photos`: ```python conversation_snapshot = conversation_ref.get(transaction=transaction) raw = conversation_snapshot.to_dict() if getattr(conversation_snapshot, 'exists', False) else None if not raw or is_soft_deleted(raw): return False level = raw.get('data_protection_level', 'standard') ``` - Reject soft-deleted tombstones by returning `False` without writing photo subcollection documents or updating the parent document. - Inlines `client.transaction()` to replace the previous checks without adding any lines (ratchet diff: +0 lines). ### Product invariants affected none ### Regression Risk Zero. Only affects soft-deleted conversations (`deleted: True`). Active live conversations continue to persist photos and update flags identically. ### Verification - Added unit tests in `backend/tests/unit/test_store_conversation_photos_tombstone_guard.py`: - `test_store_conversation_photos_live_conversation`: asserts photos are stored and parent flags updated for active conversations. - `test_store_conversation_photos_missing_conversation`: asserts `False` is returned and nothing is written when parent doc is absent. - `test_store_conversation_photos_rejects_soft_deleted_tombstone`: asserts `False` is returned, no photo docs created, and parent flags left untouched for tombstones. - Verified existing photo contract tests (`test_merge_conversation_photos.py`, `test_conversation_revision_contract.py`) passed cleanly (25 passed). - Verified Black 26.5.1 code formatting (`0 violations`). - Passed `scripts/failure-class validate`. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20949?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> <!-- End of auto-generated description by cubic. -->
…rame request promotion (#20895) ### Summary Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763, #20772, #20783, #20800, #20871, #20877, #20891. Reject soft-deleted conversation tombstones in `attach_frame_request_to_conversation` to prevent tombstone bypass during just-in-time frame evidence promotion. ### Problem `attach_frame_request_to_conversation` validated conversation existence using `conversation_snapshot.exists` inside the promotion transaction, but did not check `is_soft_deleted(conversation_data)`. Even when a conversation was soft-deleted (`deleted: True`), callers of `POST /v1/frame-requests/{request_id}/promote` could: 1. Write permanent photo metadata into the soft-deleted conversation's `photos` subcollection (`photo_ref`). 2. Mutate the tombstone conversation document with `has_content: True, has_photos: True`. 3. Transition the temporary frame request to `attached` state with permanent evidence linked to a deleted conversation. This violated Omi's conversation tombstone invariant and allowed resurrecting evidence references on deleted conversations. ### Solution - Import `is_soft_deleted` from `database.conversations`. - In `attach_frame_request_to_conversation`, check `if not conversation_snapshot.exists or is_soft_deleted(conversation_data): raise KeyError("conversation not found")`. - Reuse `conversation_data` for resolving `data_protection_level` instead of redundant `.to_dict()` calls. - The router layer continues mapping `KeyError` to HTTP 404 `frame_request_not_found`. ### Product invariants affected none ### Regression Risk Zero. Only affects soft-deleted conversations (`deleted: True`). All active conversations continue to attach and promote frame evidence identically. ### Verification - Added unit tests in `backend/tests/unit/test_frame_request_promotion_safety.py`: - `test_attach_frame_request_rejects_soft_deleted_conversation_tombstone`: asserts `KeyError("conversation not found")` on tombstone conversation. - `test_promote_frame_request_maps_tombstone_rejection_to_404`: asserts router-level HTTP 404 response. - Verified all frame request test suites pass hermetically (70 passed). - Formatted via Black 26.5.1 specification. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20895?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
…n_for_capture_check (#20948) ### Summary Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763, #20772, #20783, #20800, #20871, #20877, #20891, #20895, #20899, #20901, #20935. Reject soft-deleted conversation tombstones in `get_conversation_for_capture_check` to prevent decrypting deleted transcripts and exposing them to duplicate capture grouping and shadow LLM evaluation. ### Problem `backend/database/conversations.py` provides `get_conversation_for_capture_check(uid, conversation_id)` to retrieve a decrypted conversation document and its transcript fingerprint for cross-device capture grouping and shadow evaluation. While it checked physical existence (`if not raw:`), it omitted checking `is_soft_deleted(raw)`. Because soft-deleted conversations retain their Firestore documents with `deleted: True`, `snapshot.exists` evaluates to `True`. Consequently: 1. `prepare_conversation_for_read(raw, uid)` decrypted and returned transcripts of conversations that users had explicitly deleted. 2. In `duplicate_capture.py` (`_group_confirmed_captures`), soft-deleted transcripts were compared against active captures via `measure_shared_speech` and `measure_capture_containment`. 3. In `capture_jev_shadow.py` (`_run`), soft-deleted conversation data was passed directly into shadow LLM pipeline evaluations. 4. While downstream `link_duplicate_capture` contains a transactional guard against deleted rows (`if row.get('deleted'): return False`), the preceding read and decryption step leaked deleted content without protection. ### Solution - In `backend/database/conversations.py:get_conversation_for_capture_check`: ```python if not raw or is_soft_deleted(raw): return None, None ``` - Soft-deleted conversation tombstones return `(None, None)` exactly like missing documents. - Protects deleted transcript content from being decrypted or measured in duplicate capture algorithms. - Replaces the existing existence check in-place without adding any lines (ratchet diff: +0 lines). ### Product invariants affected none ### Regression Risk Zero. Only affects soft-deleted conversations (`deleted: True`). Active live conversations continue to be fetched, decrypted, and grouped normally. ### Verification - Added unit tests in `backend/tests/unit/test_capture_check_tombstone_guard.py`: - `test_get_conversation_for_capture_check_active_conversation`: asserts live conversations return decrypted conversation and fingerprint. - `test_get_conversation_for_capture_check_missing_conversation`: asserts missing documents return `(None, None)`. - `test_get_conversation_for_capture_check_rejects_soft_deleted_tombstone`: asserts tombstones return `(None, None)` and are never decrypted. - `test_get_conversation_for_capture_check_empty_doc`: asserts empty documents return `(None, None)`. - Verified all related capture group and policy test suites (`test_capture_groups.py`, `test_capture_jev_shadow.py`, `test_capture_containment_policy.py`) passed cleanly (106 passed). - Verified Black 26.5.1 code formatting (`0 violations`). - Passed `scripts/failure-class validate`. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20948?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> <!-- End of auto-generated description by cubic. -->
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_conversationto 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_conversationwould returnTrueas long as timestamps aligned within the configurable time-matching tolerance window (slop window), allowing:claim_fresh_capture_provenance(POST /v1/sync/capture/manifest) to associate manifest claims with soft-deleted conversation tombstones.POST /v1/sync(sync_files) to granthas_server_capture_proofand elevate sync requests targeting deleted conversations into the trusted sync lane (classify_sync_lane).This fix:
capture_matches_server_conversation(backend/utils/sync/provenance.py), returningFalseimmediately whenconversations_db.is_soft_deleted(conversation)is true.Regression Risk
Zero. Only affects soft-deleted conversations (
deleted: True). All activeconversations continue to match captures identically.
Product invariants affected
none
How it was verified
reproducer_test.py) verified against unpatched code (vulnerability confirmed: tombstone accepted) and patched code (pass: tombstone rejected).backend/tests/unit/test_sync_provenance.py(7 passed in 0.54s).test_sync_two_lane.py,test_sync_file_paths_filename_none.py- 41 passed in 0.95s, zero regressions).scripts/backend-python-format --checkpassed cleanly (Black 26.5.1, 0 violations).scripts/pr-preflightverified all checks pass.Tests
backend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_active_matchesbackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_rejects_soft_deleted_tombstonebackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_missing_conversationbackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_mismatched_devicebackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_missing_idsbackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_invalid_timestampsbackend/tests/unit/test_sync_provenance.py::test_capture_matches_server_conversation_outside_windowFailure class (fixes)
Failure-Class: none