Repository navigation
fix(backend): drop a merge source's task search vectors when the merge removes them - #15953
Conversation
|
Bounty proposal for this fix: #15954 ($25 proposed). |
aryanorastar
left a comment
There was a problem hiding this comment.
Reviewed 47ab3f5.
Merge-source task vectors are still skipped on main. This head stops skipping them on delete. Not merging. This is a delete-data change.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Verified - this closes the last delete path that leaked task vectors, consistent with #15317 (merged) and the companion #15950.
What I checked:
backend/utils/conversations/merge_conversations.py-_delete_conversation_and_related_datanow feeds the task rows it read before the Firestore delete intodelete_action_item_vectors_batch, inside the sameelsebranch as the reminder cancels and wrapped in its own try/except, so a Pinecone failure logs but cannot abort the remaining cleanup (photos, audio, conversation vector, doc) or fail the merge after the rows are gone. The delete is scoped to{uid}-ai-{id}vector IDs built from that source's own rows, so the surviving merged conversation's tasks and anyone else's data can't be touched, and re-deleting an already-absent vector is a Pinecone no-op.backend/tests/unit/test_merge_source_delete_cancels_task_reminders.py- the new assertions cover the cases that matter: every removed task's vector drops in one batched call, an undated task with no reminder still drops its vector, and a source with no tasks makes no call. The pre-existing reminder-cancel assertions are retained.backend/tests/unit/test_merge_validation.py- one-line addition of the new collaborator to the module-scopeddatabase.vector_dbstub, the right seam for the module-level import.
CI on this head (Backend Hermetic Merge Gate, Backend unit suite, Sync Cloud Tasks Stack Gauntlet, Hermetic Backend E2E) is green, and this head already carries a maintainer approval - no further action needed from my side. Thanks @kduailabs for the tight, well-explained fix.
🤖 Automated review 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 need human response.
|
Follow-up verification on 47ab3f5 — the change still checks out, with two accuracy notes and one follow-up opportunity. Per-file:
Two accuracy notes (non-blocking):
Minor edges observed, all bounded by the Firestore re-check above: soft-deleted ( No concerns on the merge path itself; @aryanorastar's approval on this head stands. The cascade-delete vector gap in note 2 is the one piece worth a maintainer's eye — a small hygiene follow-up, not urgent. Feedback generated by the repo's automated review assistant 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 |
47ab3f5 to
06a9095
Compare
|
Rebased onto current |
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]>
Summary
Merging conversations deletes every source conversation and its tasks (
_delete_conversation_and_related_data) but leaves the removed tasks' Pinecone vectors behind.Impact
find_similar_action_itemsfeeds the conversation-extraction prompt with the user's open tasks so the LLM can suppress duplicates. A merged-away task's orphaned vector still matches, so a real new task extracted later looks like a duplicate and is silently never created. The vectors accumulate in the action-items namespace with no other cleanup path.Same class as the just-merged #15317 (swipe-delete) and the companion #15950 (cascade delete). Every other delete path already drops the vector; the merge cleanup was the remaining one.
Fix
The cleanup already reads the source's stored tasks before deleting them (for the reminder cancels from #15177). The same read now drives
delete_action_item_vectors_batch, guarded so a source without tasks makes no call and logged so a vector failure cannot abort the rest of the cleanup (matching the reminder-cancel step above it).Tests
backend/tests/unit/test_merge_source_delete_cancels_task_reminders.py: a merged-away source drops the vectors of every removed task; a source without tasks makes no call; a task without a due date still has its vector dropped (it had no reminder but does have a vector). The two reminder assertions still hold.backend/tests/unit/test_merge_validation.py: the module-scopeddatabase.vector_dbstub now carries the new collaborator (one line).Verification
Against
origin/mainmerge_conversations.pythe two new vector assertions fail.Product invariants affected
none
Failure-Class: none