Skip to content

fix(persistence): make LivePrivateCKGateway.delete idempotent - #925

Merged
wei18 merged 1 commit into
mainfrom
fix/757w6-ckgateway-delete-idempotent
Jul 21, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/757w6-ckgateway-delete-idempotent

Conversation

@wei18

@wei18 wei18 commented Jul 21, 2026

Copy link
Copy Markdown
Owner

What

LivePrivateCKGateway.delete(recordName:) now tolerates deleting an already-absent record (catch CKError.unknownItem → return) and routes other errors through Self.translate — matching its fetch/save siblings.

Why

#757 wave-6. delete was the only gateway op that threw raw .unknownItem; a cross-device discard-of-already-deleted race surfaced it up through SavedGameStore.deleteAbandoned.

Verification

  • PersistenceKit 81 tests + swiftlint --strict clean. +2 tests (delete-absent no-throw + op recorded; delete-existing still removes).
  • Dual CR: APPROVE ×2 — .unknownItem catch matches fetch verbatim, catch-all matches save; both callers want delete-absent-as-success.

Part of #757

🤖 Generated with Claude Code

#757 wave-6. delete(recordName:) threw raw CKError.unknownItem on an
already-absent record — unlike its siblings (fetch returns nil, query returns
[], save routes through translate). So a cross-device discard-of-already-
deleted race surfaced a raw error up through SavedGameStore.deleteAbandoned.

Now: catch .unknownItem → return (idempotent no-op, mirroring fetch's
unknownItem branch); route every other error through Self.translate(_:
recordName:) (mirroring save), unifying the gateway's error-translation
contract. +2 tests: delete-absent doesn't throw (op still recorded, not short-
circuited); delete-existing still removes (idempotency isn't a no-op). The
non-unknownItem-still-surfaces path is covered by the existing translate tests
the catch-all now calls.

Verified: PersistenceKit 81 tests + swiftlint --strict clean. Dual CR: APPROVE
x2 (pattern matches fetch/save verbatim; both callers want delete-absent-as-
success). Live-path .unknownItem branch shares the documented "needs a real
CKDatabase" unit-test ceiling as every other live-CK branch in this file.

Part of #757

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 21, 2026 06:14
@wei18
wei18 merged commit c6c0b97 into main Jul 21, 2026
5 checks passed
@wei18
wei18 deleted the fix/757w6-ckgateway-delete-idempotent branch July 21, 2026 06:15
@wei18 wei18 mentioned this pull request Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant