Skip to content

fix(memories): preserve deletion ownership through refresh and retry - #24980

Merged
aryanorastar merged 8 commits into
mainfrom
codex/24719-delete-boundary-audit
Nov 9, 2026
Merged

aryanorastar merged 8 commits into
mainfrom
codex/24719-delete-boundary-audit

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Deleting a second memory could expose the first again during refresh, and a refused request could restore an old account's private row after sign-out. A draft deleted during upload could also leave its newly created server record behind.

The shared memory delete flow now owns one operation per ID, joins repeated commits, stops Undo at submission, reports refusals, and guards publication by owner and session. Uploading drafts hand off their canonical IDs before deletion. Create/delete authorization is rechecked after authentication waits and before every HTTP retry. Confirmed owner-scoped deletion markers protect cached and pending projections through failed writes and restart; HTTP 404 is treated as already absent.

Refs #24719. This is a separate reproducible mobile memory boundary. #24774 already merged the conversation-cache fix. This PR does not close the umbrella account/desktop/recording-storage trace investigation or claim that either fix is in a store release.

Verification

  • Five new regressions failed on unchanged main before implementation. Two additional paused-authentication regressions failed when transport ownership fences were removed and passed with them restored.
  • Full local Flutter suite passed: 8,542 tests, 10 skipped (bash test.sh --concurrency=4). The 119 focused deletion/provider/cache/edit-sheet/Spotlight tests also passed.
  • iPhone 16 Pro / iOS 26.5: build and all five loopback integration scenarios passed.
  • Simulator uses the real MemoryItem swipe/Undo, HTTP adapter and provider with synthetic records. No production data or recording was touched.
  • Agent-flutter also exercised the shared deletion helper in a synthetic component harness and captured visible refusal feedback. Full analyzer ratchet passed. Targeted analysis reports only the pre-existing avoid_print info in memories_provider.dart.
  • 130 existing backend memory/identity compatibility tests passed; backend request/response schemas are unchanged.
  • Final diff reviewed at a17b424. The previous CI run found eight signed-out fixtures in deletion_consistency_test.dart; they now initialize the same authenticated owner as their rows, without relaxing production guards. Draft until current-commit required CI passes; no merge or release performed.

Implementation and verification checklist: app/docs/memory-deletion-lifecycle.md.

Product invariants affected

  • INV-MEM-1: retains the existing memory tiers, canonical authority and access policy.

Failure class

Failure-Class: FC-continuation-resumed-after-unmount

UI evidence

Synthetic component harness using the production MemoryItem and shared deletion helper; loopback HTTP 409 restores the row and shows failure. The separate simulator integration also exercised actual swipe, Undo, 5xx retries and offline reopen.

Memory delete refusal

@aryanorastar aryanorastar added the ci:full Maintainer-granted: run full CI on this fork PR label Nov 9, 2026
@aryanorastar
aryanorastar marked this pull request as ready for review November 9, 2026 12:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T12:39:09.734403Z a17b424 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@aryanorastar
aryanorastar merged commit cf36c67 into main Nov 9, 2026
50 checks passed
@aryanorastar
aryanorastar deleted the codex/24719-delete-boundary-audit branch November 9, 2026 12:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a17b4246e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +157 to +160
if (deletion != null) {
deletion.serverMemory = serverMemory;
_ledgerProjectionRevision++;
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep an uploaded draft cached when deletion is undone

When a draft's POST succeeds while its deletion is staged, the caller removes it from pendingMemories before this branch returns without saving the canonical row to cachedMemories. If the user then undoes the deletion or the DELETE is refused, the row is restored only in _memories; an offline reopen after restart has neither a pending nor cached copy and hides a memory that still exists on the server. Preserve the canonical row in the offline cache when restoring it.

Useful? React with 👍 / 👎.

final key = _userScopedKey('confirmedMemoryDeletes', ownerUid);
var markerSaved = false;
try {
markerSaved = await saveStringList(key, {...getStringList(key), id}.toList());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Serialize concurrent memory deletion cache updates

When two per-ID deletes finish close together, both can read the same owner-scoped marker and cache lists before either asynchronous write completes. Each then writes a list pruned only for its own ID, so the last write can drop the other deletion marker and reintroduce its row into the cached projection; that row can reappear after restart. Serialize these read-modify-write updates or otherwise merge against the latest stored lists.

Useful? React with 👍 / 👎.

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

Labels

ci:full Maintainer-granted: run full CI on this fork PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant