Repository navigation
fix(users): enforce access validation in joan followup question endpoint to prevent tombstone bypass - #19867
Conversation
…int to prevent tombstone bypass
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for this follow-up in the tombstone-guard series — the fix itself is correct and well tested. Verified against main: get_conversation() returns the raw document with no tombstone filter, so before this change a soft-deleted conversation's transcript segments could still reach followup_question_prompt(). The 404 guard matches the pattern already merged in #19762 and #19774.
Both changed files reviewed:
backend/routers/users.py — the single-line guard if not memory or memory.get('deleted', False): in delete_person_endpoint (the handler for DELETE /v1/joan/{memory_id}/followup-question; the function name is legacy). Correct placement: it sits before the is_locked check and before deserialize_conversation, so no soft-deleted data flows further. Consistent with database/conversations.py:is_soft_deleted semantics.
backend/tests/unit/test_users_joan_followup_tombstone_guard.py — good coverage: deleted→404, nonexistent→404, locked→402, active→success (prompt stubbed), memory_id='0' in-progress path, and missing in-progress→400. Backend unit suite passes. Two small items:
-
Formatting check is failing — black (via
scripts/backend-python-format, line 120, skip-string-normalization) wants theENCRYPTION_SECRETsetdefault joined onto one line. Runningscripts/backend-python-format --write backend/tests/unit/test_users_joan_followup_tombstone_guard.pyfixes it, i.e.:os.environ.setdefault('ENCRYPTION_SECRET', 'omi_ZwB2ZNqB2HHpMK6wStk7sTpavJiPTFg7gXUHnc4tFABPU6pZ2c2DKgehtfgi4RZv')
-
Nit:
from unittest.mock import MagicMockis imported but unused — drop it while you're in there.
The dummy ENCRYPTION_SECRET fixture value is fine — it's the same placeholder used across the repo's unit tests.
Requesting changes only for the formatting fix; once CI is green this should be quick to merge.
Automated review on behalf of the maintainers — feedback is AI-generated.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Both concerns from this review are resolved on the current head: the ENCRYPTION_SECRET setdefault is now single-line (Formatting check green) and the unused MagicMock import is removed. Backend unit suite and Backend Hermetic Merge Gate pass.
|
Thanks for the quick turnaround — both items from the prior automated review are verified resolved on the current head:
The fix itself is unchanged and remains correct: in I've dismissed the earlier changes-requested review since its concerns are addressed. Since this tightens a user-data access-control path, leaving the merge call to a human maintainer. Automated review on behalf of the maintainers — feedback is AI-generated. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @miso466 - clean follow-up in the tombstone-guard series. backend/routers/users.py: the one-line change to delete_person_endpoint (DELETE /v1/joan/{memory_id}/followup-question) correctly folds tombstone rejection into the existing existence check, so soft-deleted conversations now 404 before their transcript segments reach followup_question_prompt. This matches the tombstone contract documented on database/conversations.py is_soft_deleted (tombstones must be invisible; content operations must reject them), and I confirmed the guard is still missing on main, so no duplication with merged work. backend/tests/unit/test_users_joan_followup_tombstone_guard.py: good coverage - 404 deleted/nonexistent, 402 locked, 200 active, and both in-progress ('0') paths (200 and the 400 'No memory in progres' case), all fully mocked with no network. The test env values follow the existing unit-test dummy conventions. One non-blocking nit: sibling routers (conversations.py, screen_frames.py) use the shared conversations_db.is_soft_deleted() predicate for this check. The inline memory.get('deleted', False) is behaviorally equivalent here, but using the shared predicate would keep the guard pattern uniform if this series continues. Already approved by a maintainer; no concerns from my side. This review was produced by AI automation on behalf of the maintainer team. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…event tombstone mutation (#19870) Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, and #19867. Line-Count-Exception: backend/routers/sync.py | 2494 -> 2500 | enforce conversation tombstone guard in audio merge jobs ## Problem In `backend/routers/sync.py`, the Cloud Tasks background merge endpoint: - `POST /v2/audio-merge-jobs/run` (`run_audio_merge_job` and `_run_conversation_merge_job`) builds playback MP3 artifacts from audio chunks and updates Firestore conversations with the resulting `conversation_audio` metadata. However, neither the v2 conversation-level merge (`_run_conversation_merge_job`) nor the legacy single-file merge validated `deleted=True` (tombstone) on the conversation: - `_run_conversation_merge_job` fetched `conversations_db.get_conversation(uid, conversation_id)` but only checked `if not conversation or not conversation.get('audio_files'):`. - `run_audio_merge_job` proceeded to load chunks and build MP3s without checking the parent conversation's existence or tombstone status. When a user deletes a conversation, queued Cloud Tasks merge jobs would still execute heavy audio concatenation (FFmpeg/AudioSegment), upload playback MP3 artifacts to GCS, and write `conversation_audio` metadata into the soft-deleted Firestore conversation document. As documented across conversation lifecycle contracts (e.g. `merge_conversations.py:147`), tombstones must not be resurrected or mutated with newly generated artifacts. ## Fix 1. In `_run_conversation_merge_job`: add tombstone validation after conversation lookup: ```python conversation = await run_blocking(db_executor, conversations_db.get_conversation, uid, conversation_id) if not conversation or conversation.get('deleted', False): return JSONResponse(status_code=200, content={'status': 'dropped', 'reason': 'deleted_conversation'}) ``` 2. In `run_audio_merge_job`: verify the conversation before reading chunks, dropping tasks for missing or soft-deleted conversations with `status=dropped` and `reason=deleted_conversation`. Returning 200 with `status=dropped` safely consumes and acks the Cloud Tasks task without triggering unnecessary retries. ## Verification Added unit tests in `backend/tests/unit/test_sync_audio_merge_job_tombstone_guard.py`: - `TestV2ConversationAudioMergeTombstoneGuard`: - `test_v2_merge_drops_soft_deleted_conversation` (dropped, no build/upload/mutation) - `test_v2_merge_drops_nonexistent_conversation` (dropped) - `test_v2_merge_drops_conversation_without_audio_files` (dropped, reason=no_audio_files) - `test_v2_merge_proceeds_for_active_conversation` (done, artifact built and stamped) - `TestV1SingleFileAudioMergeTombstoneGuard`: - `test_v1_merge_drops_soft_deleted_conversation` (dropped, no build) - `test_v1_merge_drops_nonexistent_conversation` (dropped) Ran tests: ```bash backend/.venv/bin/pytest backend/tests/unit/test_sync_audio_merge_job_tombstone_guard.py -v # 12 passed in 2.64s backend/.venv/bin/pytest backend/tests/unit/test_audio_merge_tasks.py -v # 23 passed in 2.64s ``` Product invariants affected: none Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/19870?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. -->
Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
) * fix(backend): restore pyright-clean main after #22207 and #22326 Main's backend unit shards fail the enforced pyright lane: - database/desktop_previews.py (#22207): 16 reportUnnecessaryIsInstance errors. The runtime guards stay; they move into validators that take `object` (_payload, _string, _expected_generation, _datetime), so the checks are meaningful to pyright. Public signatures, error messages and check order are unchanged. - utils/sync/pipeline.py:process_segment (#22326 on top of #22452): "code is too complex to analyze". Behaviour-neutral split: the two identical cap-hold defer blocks become one hold_for_cap closure, and the final-pass / speaker-identification block moves to _assign_segment_speakers with the same exception handling. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): repair unit tests that drifted from main across merges Five unit files fail on current main. Each one passed on its own PR's base and broke when main moved underneath it; none is a product regression. - test_request_context.py (#19738): tested the JIT budget surface that #22209 removed from llm_gateway/gateway/request_context.py. Keep the request-id tests; drop the tests for removed code. - test_users_joan_followup_tombstone_guard.py (#19867): called delete_person_endpoint, but the joan followup route is delete_followup_question_endpoint. - test_developer_from_segments_idempotency.py (#21265): process fakes rejected the trigger=CLIENT_FINALIZE kwarg the router passes since #19788. - test_external_tools_sanitization.py (#19406): the stubbed utils package lacked utils.generated_compute (#21488) and utils.model_text. Stub the default-off gate as disabled and load the stdlib-only model_text for real. - test_batch_upload_storage.py: the database.vector_db stub lacked delete_action_item_vectors_batch, which merge_conversations imports since #15953. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…mbstones Enforce is_soft_deleted check in submit_mobile_feedback to reject feedback targeting soft-deleted conversation tombstones with HTTP 404, and avoid extracting provenance metadata from soft-deleted conversations in recording targets. Follow-up to BasedHardware#19762, BasedHardware#19774, BasedHardware#19796, BasedHardware#19804, BasedHardware#19860, BasedHardware#19864, BasedHardware#19867, BasedHardware#19870, BasedHardware#20763. Failure-Class: none
…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. -->
…mbstones (#20772) ### Summary Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763. Ensures `submit_mobile_feedback` rejects operations targeting soft-deleted conversation tombstones with HTTP 404, and avoids extracting provenance metadata from soft-deleted conversations in recording targets. ### Problem In `backend/routers/mobile_feedback.py`: - For conversation feedback (`summary_helpfulness` or `target_kind == 'conversation'`), `conversations_db.get_conversation` fetches the conversation record, but only checks `if not conversation:`. The tombstone check `conversations_db.is_soft_deleted(conversation)` is missing. - For recording feedback (`binding` path), provenance metadata (such as `model_name`, `prompt_name`, `trace_id`) is extracted from `conversation` even if that conversation was soft-deleted. - For legacy mobile feedback fallback (`payload.target_kind is None`), `conversations_db.is_soft_deleted` is likewise not checked. As a result, client feedback requests targeting soft-deleted conversations succeed and persist records in Firestore, violating the invariant that "a tombstone is invisible to the user" (conversations.py). ### Solution - Add `or conversations_db.is_soft_deleted(conversation)` check in both conversation target branches, raising HTTP 404. - In recording target path, only extract provenance if `not conversations_db.is_soft_deleted(conversation)`. ### Verification - Unit test passed: `pytest backend/tests/unit/test_mobile_feedback.py` (15/15 passed in 0.53s) - Formatting: `scripts/backend-python-format --check` (exit code 0) - Preflight: `scripts/pr-preflight` ## Regression Risk Zero. Only adds rejection paths for soft-deleted tombstone documents; all existing feedback actions for active conversations and recordings continue to work identically. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20772?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. -->
…and task tombstones (#20783) ### Summary Follow-up to #19762, #19774, #19796, #19804, #19860, #19864, #19867, #19870, #20763, #20772. Guards the chat-first block validation endpoint against admitting journal blocks that reference soft-deleted conversation tombstones or soft-deleted tasks. ### Problem In `backend/routers/chat_first.py`: - `_entity_available` validates entity references for `ChatFirstJournalBlockSpec` during `POST /v1/chat-first/blocks/validate`. - For conversation and capture references (`CaptureLinkSpec`, `ConversationLinkSpec`, and `subject.kind == 'capture'`), the check inspected `discarded` and `is_locked`, but omitted `conversations_db.is_soft_deleted`. - For task references (`TaskCardSpec` and `subject.kind == 'task'`), the check inspected `is_locked`, but omitted `task.get('deleted')`. As a result, client validation requests referencing soft-deleted conversation tombstones or soft-deleted tasks returned `accepted: true` instead of `accepted: false, code: 'entity_unavailable'`, violating the invariant that tombstones are invisible and inaccessible to user-facing workflows. ### Solution - Added `not conversations_db.is_soft_deleted(...)` checks to `CaptureLinkSpec`, `ConversationLinkSpec`, and `subject.kind == 'capture'` branches in `_entity_available`. - Added `not task.get('deleted', False)` checks to `TaskCardSpec` and `subject.kind == 'task'` branches in `_entity_available`. - Blocks referencing soft-deleted records now deterministically fail validation with `entity_unavailable`. ### Verification - Unit tests passed: `pytest backend/tests/unit/test_chat_first_tombstone_guard.py` (5/5 passed in 1.60s) - Regression test suite passed: `pytest backend/tests/unit/test_chat_first*.py` (127/127 passed in 2.77s) - Formatting: `scripts/backend-python-format --check` (exit code 0) - Preflight: `scripts/pr-preflight` ## Regression Risk Zero. Only rejects soft-deleted records (`deleted: True`). All active conversations, captures, and tasks continue to validate identically. Failure-Class: none <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/20783?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. -->
Follow-up to #19762, #19774, #19796, #19804, #19860, and #19864.
Problem
In
backend/routers/users.py, the Joan follow-up question endpoint:DELETE /v1/joan/{memory_id}/followup-question(delete_person_endpoint)retrieves the conversation record via
get_conversation(uid, memory_id)and verifies existence (404) andis_locked(402), but fails to validatedeleted=True(tombstone).As documented in
database/conversations.py(is_soft_deleted) and aligned across other routers, tombstones must be invisible to the user and operations on soft-deleted conversations must return 404. Without this check, the transcript segments of soft-deleted conversations could still be passed tofollowup_question_prompt(uid, memory.transcript_segments)to generate follow-up question prompts.Fix
In
delete_person_endpoint, update the existence check to include tombstone validation:Verification
Added unit tests in
backend/tests/unit/test_users_joan_followup_tombstone_guard.py:TestJoanFollowupQuestionTombstoneGuard:test_joan_followup_rejects_deleted_conversation(404)test_joan_followup_rejects_nonexistent_conversation(404)test_joan_followup_rejects_locked_conversation(402)test_joan_followup_allows_active_conversation(200)test_joan_followup_handles_in_progress_conversation_zero(200)test_joan_followup_rejects_missing_in_progress_conversation(400)Ran tests:
backend/.venv/bin/pytest backend/tests/unit/test_users_joan_followup_tombstone_guard.py -v # 6 passed in 2.18sProduct invariants affected: none
Failure-Class: none