Repository navigation
fix: prevent deleted conversations from backlog resurrection - #21000
Git-on-my-level merged 17 commits into
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Review findings (grok, round 1): - re-check tombstone before the final from-segments persist so a delete committing during processing still wins the admission race - tombstone sync_merged_from source ids when the survivor delete purges them, or a backlog retry resurrects the merge donor - create guard also matches a tombstone on the raw client session id (ws doc id / client_conversation_id alias), covering cross-device deletes of live conversations Both regressions pinned in test_developer_from_segments_idempotency.
Review chainRound 1 — cursor grok (grok-4.7-high, adversarial, read-only): APPROVE with 3 non-blocking findings, all verified at cited lines and fixed in 788e953:
Both race regressions pinned with new tests ( Review round 2 on the new head will be posted before merge. |
- smart-merge flatten fixture binds conversation_tombstones.db to the fake store and the cascade fake document gains SDK create semantics (set-if-absent, AlreadyExists on replay) so merge-source intent writes resolve in-process instead of reaching real Firestore - merge_validation import isolation stubs the new database module that merge_conversations now imports at module scope
Round-2 review BLOCK: a tombstone write that cannot reach Firestore (unprovisioned project, blocked metadata endpoint) must not abort the donor purge the user asked for. Log and continue; suppression still holds through the survivor tombstone that the create guard re-checks before recreating, and the pre-persist re-check covers in-flight work.
Same hermetic-import treatment as merge_validation: the fixture builds a synthetic database package, so the new module-level import in merge_conversations needs the stub entry to resolve.
Round-3 review BLOCK, both items: - merge-source tombstone fixtures bind conversation_tombstones.db to the fake store (cascade x2, smart-merge audit now also asserts the donor intent record), so no cascade/audit test touches live Firestore and BlockedNetwork leaks are gone - the pre-persist suppress branch checks BOTH identities (derived uuid5 + raw session id), purges the processing row it may have created/completed, and the race test now flips the tombstone only after process_conversation starts so it actually exercises this branch; admission create-if-absent is stubbed for hermeticity
Review chain (complete)
CI: all checks green on head 00feaa7 (Backend shards, Desktop Swift, Dart, Android, Hygiene after body refresh). Reviewer chain: 4 rounds, every blocking finding verified at file:line, fixed, and re-reviewed on the exact new head. |
MergedSquash-merged as 08afc66 on main. All required checks green on head 00feaa7 before merge (Backend unit shards, Desktop Swift, Dart, Android, Hygiene after the body declaration refresh to 2645). Dev auto-deploy (Backend to Development + pusher) in progress on this SHA; bake monitor watching:
|
…rtion RewindEvidenceCardTests asserted the old "unavailable locally" hint. TranscriptionStorageRecoveryTests kept an assertion that the shell was deleted after #21000 removed the delete from its setup; the delete-survives-hydration case is covered by testStaleServerHydrationCannotUndoConfirmedDelete. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ssertion TasksStoreUnsyncedSyncTests hung on CI (327s/324s vs 300s budget, twice) before any test case ran: the owner-transition fixture's finalization touches RewindIndexer.shared, whose init resolved ClientDeviceService.shared.clientDeviceId at actor-init time and could block on a Keychain SecItemCopyMatching IPC. Resolve the device id on first frame write instead; the value is stable for the process lifetime, so frame provenance is unchanged. TranscriptionStorageRecoveryTests asserted hydrated.deleted in a test whose setup delete was removed by the same PR that added the assertion (#21000); no-resurrect coverage lives in testStaleServerHydrationCannotUndoConfirmedDelete and the upsert tombstone early-return, so the stale line failed 3x on CI.
…ead (#21081) * feat(desktop): ship a product guide the Mac chat agent can read Chat had no local source for how this build of Omi works, so questions like enabling Only Meetings could not be answered from the UI the user actually has. Co-authored-by: Cursor <[email protected]> * chore(desktop): cover ProductKnowledgeBase in chat-hermetic e2e flow The desktop-e2e-flow-coverage gate requires every changed desktop Swift source to be claimed by an e2e flow; the KB loader is exercised on the chat-hermetic path where the capability registry is already covered. * test(pi-mono): list get_product_kb in the required-fields table The exhaustive per-tool required-field assertion in pi-mono-extension must name every OMI tool; get_product_kb takes only optional params. * fix(desktop): resolve Rewind device id lazily; drop stale hydration assertion TasksStoreUnsyncedSyncTests hung on CI (327s/324s vs 300s budget, twice) before any test case ran: the owner-transition fixture's finalization touches RewindIndexer.shared, whose init resolved ClientDeviceService.shared.clientDeviceId at actor-init time and could block on a Keychain SecItemCopyMatching IPC. Resolve the device id on first frame write instead; the value is stable for the process lifetime, so frame provenance is unchanged. TranscriptionStorageRecoveryTests asserted hydrated.deleted in a test whose setup delete was removed by the same PR that added the assertion (#21000); no-resurrect coverage lives in testStaleServerHydrationCannotUndoConfirmedDelete and the upsert tombstone early-return, so the stale line failed 3x on CI. --------- Co-authored-by: Cursor <[email protected]>
…tion (#21329) * fix(backend): restore the released 204 delete contract for conversation deletion DELETE /v1/conversations/{conversation_id} shipped to released mobile clients as 204 No Content. The 2026-07-04 response_model backfill (e22938a) turned it into a 200 with a StatusResponse body, and the released app (app/lib/backend/http/api/conversations.dart::deleteConversationServer) gates delete success on exactly 204 — so every conversation delete there reads as a failure: the optimistic tombstone is dropped immediately, the server-cursor rebase and fetch-revision bookkeeping are skipped, and once the server delete cannot complete (e.g. cascade retraction failing closed) the deleted conversation resurfaces on the next refresh. This is the recurrence of Restore status_code=204 with no body (the folders/mcp convention) and pin the contract from both sides in backend/tests/unit/test_conversation_delete_wire_contract.py: the router declaration and the regenerated app-client OpenAPI spec. Verified: offline harness — cascade delete of a conversation with attributed memories returned 503 before this change, 204 with an empty body after. Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3 Co-authored-by: Max Carter <[email protected]> (cherry picked from commit 21002a8) * fix(checks): allow recorded released-status restorations in app-client contract gate The gate treats the merge-base spec as the released-clients truth. That baseline can itself carry a spec-only regression: e22938a (2026-07-04) flipped DELETE /v1/conversations/{conversation_id} from the released 204 No Content to 200 + StatusResponse while every released mobile client still gates delete success on exactly 204 (app/lib/backend/http/api/conversations.dart::deleteConversationServer, #10446 recurrence: desktop delete errors, mobile re-adds on refresh). With the baseline poisoned, the gate blocked restoring the actual released contract, and the July regression shipped precisely because no guard existed to catch it. Add RELEASED_STATUS_RESTORES, patterned on DELIBERATELY_REMOVED_ENDPOINTS: an explicit, evidence-cited (route, method, status) record whose released-client contract predates the baseline regression, so restoring that status is not flagged as a new success status. Entries are narrow — an unrecorded operation cannot borrow the allowance — and both the allow-and-refuse directions are unit-tested. Evidence: app/lib/backend/http/api/conversations.dart:140 in the released app source returns response.statusCode == 204 for this call. Failure-Class: none Amp-Thread-ID: https://ampcode.com/threads/T-01a0b76d-bb38-749d-a0da-1b0837aa8e2e Co-authored-by: Max Carter <[email protected]> (cherry picked from commit 11cc3c5) * chore: regenerate TS/Swift OpenAPI clients for the restored 204 delete contract Regenerated from the updated app-client spec with backend/scripts/generate_ts_openapi_types.py and generate_swift_openapi_types.py rather than cherry-picking 2fb1f42 from #14691, whose generated files predate current main. Only the conversation delete function changes: Swift returns Void, TypeScript returns without parsing a body. No in-tree code calls either generated function. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): expect no body from conversation delete under the 204 contract test_conversation_tombstones.py (#21000) landed after the 200-with-body regression and asserted the handler's {'status': 'Ok'} return. The route is 204 No Content again, the contract the released mobile client gates on (app/lib/backend/http/api/conversations.dart::deleteConversationServer returns statusCode == 204), so the handler returns None. The tests' subject, tombstone ordering against retraction and cleanup, is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): assert conversation delete answers 204 with an empty body over HTTP The wire-contract test pinned the route declaration and the published spec. This adds the HTTP layer: the real route through FastAPI's TestClient, with only storage side effects stubbed, for cascade=false and cascade=true. Against main's route both requests answer 200 (assert 200 == 204), which the released mobile client reads as a failed delete. Co-Authored-By: Claude Opus 5.5 <[email protected]> * chore(backend): keep the 204 delete rationale to one line The full reasoning lives in test_conversation_delete_wire_contract.py; the router stays at its line-count baseline. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Amp <[email protected]> Co-authored-by: Max Carter <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
fix: prevent deleted conversations from backlog resurrection
A user-reported incident (May/June conversations re-appearing Oct 6–8) exposed a resurrection
path: the desktop client keeps un-uploaded sessions in a local outbox, and when a months-old
backlog drains (post-#19613 retry-budget removal), the from-segments create path re-derives the
same deterministic conversation id (
uuid5(namespace, uid + "\0" + client_session_id)), findsthe doc absent (the user had deleted it), and re-creates the conversation — rerunning the full
pipeline including canonical memories. Fleet logs show ≥207 distinct users re-persisting
from-segments conversations since Oct 6; in one day's sample 103/955 persisted uploads were
Design
database/conversation_tombstones.py: content-free deletion intent, stored atusers/{uid}/deleted_conversations/{conversation_id}— identity fields only(conversation_id, deleted_at, bound from-segments client_session_id, created_at);
never transcript, structured, or calendar data.
create()is first-writer-wins so aretried delete preserves the original binding.
DELETE /v1/conversations/{id}and the developer-API conversation delete record thetombstone BEFORE any retraction/cleanup; a later failing step never removes it, so a
delete that partially failed still suppresses future re-creation.
acks retired identities with
{id, status: "deleted", discarded: true}instead ofcreating — no processing, no memories, no vectors.
generation fenced so a stale owner cannot touch a newer owner's row); confirmed user
deletes now also resolve matching local rows — including never-synced rows matched via
the client-side mirror of the backend uuid5 identity (
ConversationDeletionIdentity).delete_user_data) already enumerates and removes the user'ssubcollections including
deleted_conversations; doc comment updated.Failure-Class
Failure-Class: new
New class
FC-ingest-recreates-retired-identityships in this PR (definition JSON +scope hints + canonical prevention artifacts pointing at the tombstone module, its tests,
and the desktop retry tests). Existing classes cover adjacent-but-different mechanisms
(FC-content-derived-identity-retired-by-deletion: reissue a fresh identity on content
rewrite; FC-read-in-flight-across-delete-resurrects-row: client read fencing).
Testing
pytest tests/unit/test_conversation_tombstones.py(tombstone content,owner scoping, ordering vs retraction/cleanup failures, developer-delete parity,
listen-runtime rejection) +
tests/unit/test_developer_from_segments_idempotency.py(tombstoned ack, idempotency hit preserved for live ids) + cascade/reprocess/
client-processing/reminders suites — results in CI; known pre-existing main-side
test-pollution pair documented below.
xcrun swift test --package-path Desktop(outbox ack resolution, deletionidentity matching, pool-generation fencing) — results in CI.
deleted-conversation-backlog.yamlcovers delete → backlog re-post → ack →no resurrection.
Known pre-existing issue (not this PR)
tests/unit/test_developer_from_segments_idempotency.pyperforms import-timesys.modulesstubbing that leaks into files ordered after it in the same pytest worker;combined with
test_delete_conversation_cascade.py/test_reprocess_tombstone_guard.pythis reproduces 15 failures on pristine origin/main (verified on a clean main worktree).
CI's sharded execution order does not hit the pair. Left untouched here to keep this PR
scoped; worth a dedicated isolation fix.
Not in this PR
contract; separate change.
Line-Count-Exception: backend/routers/conversations.py | 2284 -> 2288 | tombstone-first ordering: three-line intent commit plus one import at the delete entrypoint; logic lives in the new dedicated module
Line-Count-Exception: backend/routers/developer.py | 2603 -> 2645 | tombstone ack branch and pre-persist race re-check at the shared from-segments choke point plus intent commit on the developer delete route; no split that small is coherent
UI-Evidence: none -- pure behavior change (outbox ack resolution + tombstone guard); no visible UI element added, removed, or restyled; existing screens and flows render identically
Product invariants affected
.github/workflows/*files are touched by this diff.