Skip to content

fix(memories): mirror the canonical delete-all into the store the user reads - #10454

Closed
aryanorastar wants to merge 2 commits into
BasedHardware:mainfrom
aryanorastar:fix/10446-delete-all-mirror
Closed

aryanorastar wants to merge 2 commits into
BasedHardware:mainfrom
aryanorastar:fix/10446-delete-all-mirror

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

Follow-up to #10451, which I deliberately scoped out of that PR. DELETE /v3/memories (delete-all) carries 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.

Stacked on #10451 (it reuses that PR's guard); review the last commit only. Refs #10446.

⚠️ This one needs your call before merge

I held this back from #10451 on purpose and I'd rather you decide than assume: mirroring delete-all means a bulk wipe of the legacy collection. That is a much larger blast radius than the single/batch mirror, on a user-data deletion path, during a live migration.

The argument for it: the user explicitly asked to delete everything, and today that request silently doesn't affect what they see. The argument against: if legacy is ever meant to be recoverable during the migration, this removes that option in one call.

If you'd rather leave delete-all asymmetric until read cutover, close this — #10451 stands on its own and fixes the reported symptom.

Fix

  • Mirror the wipe into legacy until read cutover, under the same guard and best-effort contract as the single/batch mirror: no-ops once canonical_read_enabled is true, and a legacy failure never fails a request whose canonical delete already committed.
  • Factored 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.

Tests

backend/tests/unit/test_memories_batch_delete.py:

  • delete-all during dual-write reaches the store the user reads
  • delete-all after read cutover leaves legacy alone
  • the legacy cohort still purges after the factoring (guards the refactor)

Suites: test_memories_batch_delete.py → 23 passed; test_memories_batch.py + test_memory_api_egress_contract.py + test_memories_pagination_clamp.py + test_inv_mem_1_guard.py → 34 passed.

Product invariants affected

  • INV-MEM-1 — no tier added, no new canonical collection, default access policy untouched; this only mirrors an existing delete into the pre-existing legacy collection during the migration window. Guard test green.

Failure-Class: none

Review in cubic

aryanorastar and others added 2 commits July 24, 2026 07:22
… 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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Git-on-my-level Git-on-my-level added security-review Touches auth, provider routing, secrets, or security-sensitive surfaces needs-maintainer-review Needs a human maintainer to sign off before merge labels Jul 24, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful follow-up and for explicitly separating this from #10451.

I reviewed the diff around DELETE /v3/memories and the added regression coverage. The implementation looks technically coherent: canonical delete/delete-all commits first, legacy mirroring only runs before canonical read cutover, and the legacy purge still collects IDs before deleting so vectors are cleaned up. I also ran the touched unit file in a scrubbed local environment:

pytest tests/unit/test_memories_batch_delete.py -q → 23 passed.

I am not approving this automatically because this is intentionally a user-data deletion/migration blast-radius decision: mirroring delete-all means a canonical wipe also bulk-wipes the legacy collection while legacy is still the read surface. That matches the current user-visible semantics of "delete everything", but it removes legacy as a rollback/recovery source for that user's memories during the rollout. Human maintainer review should decide whether that is the desired migration contract before merge.

One merge-readiness note: GitHub still shows Hygiene cancelled and Formatting skipped on this head, so please make sure the required gates are clean before landing.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Folded into #10451 so the single, batch, and delete-all mirrors land as one complete fix for the dual-write delete asymmetry (per the review on #10451, which flagged delete-all as the remaining gap). This branch was stacked on #10451 and added only the delete-all commit, now part of #10451.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @aryanorastar 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-maintainer-review Needs a human maintainer to sign off before merge security-review Touches auth, provider routing, secrets, or security-sensitive surfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants