Repository navigation
Conversation
…-progress retrieval `retrieve_in_progress_conversation` is the primary intake for `POST /v1/conversations` (process_in_progress_conversation) and the listen session connection pipeline. While the fallback query `get_in_progress_conversation` filters out soft-deleted conversations (`not is_soft_deleted(conversation)`), the fast-path Redis pointer branch (`get_in_progress_conversation_id` -> `get_conversation`) only verified that `status == 'in_progress'`. If a conversation was soft-deleted while recording or shortly after, the tombstone remained referenced by Redis and was returned unfiltered. This allowed `POST /v1/conversations` to finalize and resurrect a deleted conversation, generating summaries, memories, and notifications for user-deleted data. This commit: 1. Rejects soft-deleted tombstones in `retrieve_in_progress_conversation` when resolved via the Redis pointer, resetting `existing = None` so it can fall back to clean storage or return None. 2. Adds defense-in-depth in `POST /v1/conversations` to ensure any tombstone reaching the router is rejected with HTTP 404. 3. Adds regression tests covering tombstone rejection and fallback behavior. Failure-Class: none
|
Verified a real gap and a clean fix. Reviewed file by file against the PR head:
One trivial nit, non-blocking: Nice bug report and write-up — the reproducer-verified description made this easy to confirm. Leaving for human maintainer merge sign-off (user-data deletion behavior warrants a maintainer decision even though the code matches the established tombstone contract). AI-generated maintainer feedback posted 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 |
|
Verified the gap and the fix against the head:
Nice catch, and thanks for the reproducer-driven verification writeup. One non-blocking thought for a follow-up: after rejecting a tombstone the stale Redis pointer isn't cleared, so each subsequent call pays a This tightens deletion enforcement on the conversation intake path (a user-data integrity surface), so leaving for human maintainer sign-off before merge. Feedback sent by an AI reviewer acting for the Omi maintainers. Human review may follow. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Verified the fix on head — the tombstone bypass was real and this closes it cleanly.
Backend unit suite and Backend Hermetic Merge Gate are green on head. This is a well-scoped privacy fix with solid tests — thanks @miso466. Since this touches deletion semantics for user data (which conversations may be finalized), it needs a human maintainer sign-off before merge. Leaving for human maintainer review. This review was AI-generated on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
Approved eeb6f59a22f9b54af578a8a9c592b3af653aebbf. retrieve_in_progress_conversation in backend/utils/conversations/process_conversation.py on main keeps a deleted in-progress row. This head drops it and Hygiene succeeded.
…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
Reject soft-deleted conversation tombstones in
retrieve_in_progress_conversationwhen resolved via the fast-path Redis pointer, and add defense-in-depth inPOST /v1/conversations.retrieve_in_progress_conversationis the primary intake forPOST /v1/conversations(process_in_progress_conversation) and the listen session connection pipeline.While the fallback query
get_in_progress_conversationproperly filters out soft-deleted conversations (not is_soft_deleted(conversation)), the fast-path Redis pointer branch (get_in_progress_conversation_id->get_conversation) only verified thatstatus == 'in_progress'. If a conversation was soft-deleted while recording or shortly after, the tombstone remained referenced by Redis and was returned unfiltered. This allowedPOST /v1/conversationsto finalize and resurrect a deleted conversation, generating summaries, memories, and notifications for user-deleted data.This fix:
retrieve_in_progress_conversation(backend/utils/conversations/process_conversation.py), rejects soft-deleted tombstones (conversations_db.is_soft_deleted(existing)) when resolving via the Redis pointer, resettingexisting = Noneso it can fall back to clean storage or return None.process_in_progress_conversation(backend/routers/conversations.py), adds defense-in-depth to ensure any tombstone reaching the router is rejected with HTTP 404 ("Conversation in progress not found").Product invariants affected
How it was verified
reproducer_test.py) verified against unpatched code (vulnerability confirmed) and patched code (pass).backend/tests/unit/test_conversations_in_progress_tombstone_guard.py(2 passed in 2.68s).backend/tests/unit/test_listen_session_survives_redis_maxmemory.py(31 passed in 2.43s).backend/tests/unit/test_conversations_processing_rollback.py(12 passed in 2.96s).scripts/backend-python-format --checkpassed cleanly (Black 26.5.1).scripts/pr-preflightverified all checks pass.Tests
backend/tests/unit/test_conversations_in_progress_tombstone_guard.py::test_retrieve_in_progress_conversation_ignores_soft_deleted_redis_cached_conversationbackend/tests/unit/test_conversations_in_progress_tombstone_guard.py::test_process_in_progress_conversation_rejects_soft_deleted_tombstonebackend/tests/unit/test_listen_session_survives_redis_maxmemory.py::test_retrieve_in_progress_conversation_ignores_soft_deleted_from_redisbackend/tests/unit/test_listen_session_survives_redis_maxmemory.py::test_retrieve_in_progress_conversation_falls_back_when_redis_target_is_soft_deletedFailure class (fixes)
Failure-Class: none