Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for tracking this down — the symmetric dual-delete direction makes sense for the single and batch delete paths during the write-before-read rollout window.
I found one blocker before this can land: DELETE /v3/memories (delete-all) still only calls MemoryService.delete_all(uid) in the canonical-write branch and returns without clearing legacy. During MEMORY_MODE=write, GET /v3/memories still reads legacy, so a user who chooses “delete all memories” would see the same class of resurrection this PR fixes for single/batch deletes. Please mirror delete-all into the legacy store while canonical_read_enabled(...) is false as well, and add a regression test for that route.
Validation I ran locally with stripped env/secrets: pytest -q backend/tests/unit/test_memories_batch_delete.py using the existing backend venv from another checkout; the current touched test file passes (20 passed), but it does not cover the delete-all route.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
226a983 to
a5bf83f
Compare
|
Done — folded the delete-all mirror in (it was split into #10454, now closed), so this PR closes the whole asymmetry: single, batch, and delete-all all mirror into legacy during the write window via Flagged the bulk-wipe blast radius of the delete-all mirror in the body for your call, since it's larger than single/batch. (Also fixed a stale static count in |
kodjima33
left a comment
There was a problem hiding this comment.
fix(memories) mirror canonical deletes — approve only (security-review, CHANGES_REQUESTED)
… reads
DELETE /v3/memories/{id} and /v3/memories/batch branch on canonical_write_decision,
which enables canonical at MEMORY_MODE in {write, read}. GET /v3/memories branches on
canonical_read_enabled, which enables canonical only at MEMORY_MODE=read.
So during the dual-write stage (MEMORY_MODE=write) a delete tombstones the canonical
record while the user's list keeps reading legacy, where the row is untouched. The
client drops it optimistically and the next refresh re-reads legacy, so the memory
reappears seconds later (BasedHardware#10446).
Deleting is symmetric with dual-write: mirror the canonical delete into legacy until
read cutover. The mirror is best-effort — canonical is authoritative and already
committed, so a legacy cleanup failure must not fail a request the user saw succeed —
and it no-ops after cutover, where both sides are canonical.
_force_canonical now pins MEMORY_MODE=read explicitly rather than inheriting the
ambient rollout config, so the existing batch-vs-single authorization-parity cases
keep asserting exactly what they always did.
Refs BasedHardware#10446.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…r reads Follow-up to the single/batch delete mirror: DELETE /v3/memories has the same read/write asymmetry. At MEMORY_MODE=write the canonical wipe is invisible, because GET /v3/memories still reads legacy — so "delete everything" leaves the user's entire list intact on the next refresh (BasedHardware#10446). Mirror the wipe into legacy until read cutover, under the same guard and best-effort contract as the single/batch mirror. Also factors the legacy branch's collect-then-purge into _purge_legacy_memories so both paths share one definition instead of duplicating the pagination and vector cleanup. Refs BasedHardware#10446. Co-Authored-By: Claude Opus 4.8 <[email protected]>
a5bf83f to
f75e7f2
Compare
Resolved on f75e7f2: delete-all now mirrors into legacy before read cutover and regression tests cover the route.
|
Thanks for the update — the previous delete-all blocker looks resolved on the current head. What I verified:
I removed by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Rebased onto current main. Green (0 failing), MERGEABLE. Single + batch + delete-all mirror are all folded in with tests. Ready for re-review. |
…onfigured (#15097) * fix(backend): fail privacy deletion open when the vector store is unconfigured #10451 (5fa372e) made Pinecone-unavailable failure handling fail closed: HistoricalMemoryAdapter.cleanup(required=True) raised 503 when vector_db.index is None, and delete_canonical_memory_vectors returned False → RuntimeError → 503 on cascade retraction. Production never provisions Pinecone on most releases (backend/deploy/runtime_env.yaml attaches the key only to llm-gateway releases; desktop_backend_prod.yml explicitly strips it), so every DELETE /v3/memories/{id} and every cascade DELETE /v1/conversations/{id}?cascade=true deterministically 503'd — the desktop app surfaces the error verbatim, and mobile reads the non-200 as a failed delete, drops the tombstone, and the item resurfaces on refresh (#10446 recurrence). Deletion of the user's data is the privacy-preserving direction: when no derived vector store is configured, there is nothing to purge, so cleanup completes successfully; a configured store that errors still fails closed. Tests cover the unconfigured-index deletion path, required historical cleanup completing without a vector authority, and cascade deletion of a conversation with attributed memories completing without a vector store. Verified: offline harness — memory delete returned 503 before this change and 200 afterwards. 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 c55e69a) * chore: register failure class FC-privacy-delete-fails-on-unprovisioned-derived-store Registers the definition for the privacy-delete failure class cited by the two fixes in this branch. Failure-Class: none Amp-Thread-ID: https://ampcode.com/threads/T-01a0b590-2123-744a-9e4a-16706295c2d3 Co-authored-by: Max Carter <[email protected]> (cherry picked from commit 12e47ac) * chore: point the failure class at the guards this PR carries The definition listed test_conversation_delete_wire_contract.py, which pins the 204 delete contract for the released mobile client and ships with that fix, not with this one. Name the two guards that are here instead: the unconfigured-index canonical vector delete and required historical cleanup without a vector authority, plus the module each one guards. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Amp <[email protected]> Co-authored-by: Max Carter <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]>
What
Deleted memories come back a few seconds later. Root-caused to a read/write decision asymmetry in the V3 memory rollout — not a client cache issue.
Refs #10446 (server-side half; see the note on symptom 1 below).
Root cause
The delete and list routes are gated on different rollout modes:
DELETE /v3/memories/{id},/v3/memories/batch,/v3/memories(all)canonical_write_decisionmode ∈ {write, read}GET /v3/memoriescanonical_read_enabledmode == readonlySo during the dual-write stage (
MEMORY_MODE=write) — which every rollout passes through before read cutover, and #10394 has this one mid-flight — a delete tombstones the canonical record while the user's list keeps reading legacy, where the row is untouched. The client drops it optimistically, the next refresh re-reads legacy, and the memory reappears. That matches the reported ~10–15s timing.Fix
Mirror the canonical delete into legacy until read cutover — deleting is symmetric with dual-write — across all three delete paths (single, batch, and delete-all). The mirror:
canonical_read_enabledtrue ⇒ both sides canonical), so this is confined to the migration window;Single/batch mirror the specific
memory_ids; delete-all purges the legacy collection for the uid (_mirror_delete_all_into_legacy→_purge_legacy_memories), matching what the canonical delete-all already did to the canonical store.This changes deletion behavior during a live migration, so it deserves the rollout owner's eye rather than mine. I picked symmetric dual-delete (a delete applies to both stores while both are live). The alternative is routing deletes at the store the user reads. I'm happy to switch if you prefer the other semantic.
Note the delete-all mirror is a bulk wipe of the legacy collection for that uid — larger blast radius than single/batch, but it only mirrors what the canonical delete-all already committed, is confined to the write window, and no-ops after cutover. Called out so the rollout owner can weigh it explicitly.
Related:
_force_canonicalin the batch-delete tests previously left the read stage implicit, inheriting whatever the ambient rollout config produced. It now pinsMEMORY_MODE=readexplicitly, so those batch-vs-single authorization-parity cases keep asserting exactly what they always did — the contract is unchanged, only the stage is now stated.Tests
backend/tests/unit/test_memories_batch_delete.py(23 passed, Python 3.11.venv):test_delete_during_dual_write_also_clears_the_store_the_user_reads— the single/batch regression. Fails on old code (Expected 'mock' to have been called once. Called 0 times.), passes with the fix.test_delete_after_read_cutover_leaves_legacy_alone— the mirror must not fire post-cutover.Not exercised live: I can't see prod's
MEMORY_MODEor the reporter's account from here. If prod is atwrite, this is deterministic for every affected account rather than a flake — worth confirming when you triage.Changes since first review
Folded in the delete-all mirror (previously split into #10454, now closed) so this PR closes the whole asymmetry in one place, per the review — single, batch, and delete-all all mirror during the write window.
Product invariants affected
Failure-Class: none
No registered class covers "a mutation must land in the store the caller reads while a dual-write migration is in flight". Single instance, fixed at the route boundary that owns the decision.