Repository navigation
feat(minesweeper): add MS-specific personal-record store, wired at daily win - #706
Merged
Merged
Conversation
…ily win Minesweeper had no personal-best record at all. Per owner decision on #699, this adds an MS-specific `MinesweeperPersonalRecordStore` (mirroring PersistenceKit's `PersonalRecordStore` shape: `.ifUnchanged` optimistic retry, `recordingCompletion` dedup-by-puzzleId, min-best merge) rather than generalizing the shared `TelemetryEvent`/`PersonalRecordSink`/ `makeCompletionSinks` pipeline to Minesweeper's types — the same precedent already set by `MinesweeperSavedGameStore` and the direct `gameCenter.submitScore` call for GC best-times. Generalizing the shared pipeline is left to #479. - `MinesweeperPersonalRecord` / `MinesweeperPersonalRecordStore` (new, MinesweeperPersistence): CRUD over the shared `PrivateCKGateway` seam, reusing `PrivateCKConstants.personalRecordRecordType` ("PersonalRecord") — safe because MS and Sudoku each own a separate CKContainer (same precedent as `SavedGame`). - `cloudkit/minesweeper.ckdb`: adds the `PersonalRecord` record type (fields mirror `cloudkit/sudoku.ckdb`). Additive only. - Wired at the same daily-only trigger as the Game Center submit, right beside it in `MinesweeperGameViewModel.submitDailyTimeIfWon()` (moved to MinesweeperGameViewModel+SubmitOnWin.swift to keep the main file under the 400-line lint ceiling). Threaded optional end-to-end: `Live.swift` -> `LiveRouteFactory` -> `MinesweeperBoardView` / `MinesweeperBoardLoaderView` -> `MinesweeperGameViewModel`. A failed write funnels through `errorReporter`, never interrupts gameplay. - Tests mirror PersistenceKit's `PersonalRecordTests` / `PersonalRecordMergeTests` / `PersonalRecordRaceTests` patterns with MS types, plus a VM-level submit-on-win suite (dedup, daily-only gate, swallowed-write-error, nil-store no-op). No shared code (PersistenceKit / GameAppKit / TelemetryKit) touched. Development CloudKit schema push + eventual Production "Deploy Schema Changes to Production" console click are follow-ups, not done here. closes #699 Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #699 — B2 from the 2026-07-05 uiux audit; mechanism (MS-native store, NOT the shared TelemetryEvent/makeCompletionSinks pipeline) owner-approved 2026-07-05, per the two prior per-game precedents. Pipeline generalization stays with #479.
What (+953/−68, MinesweeperKit + cloudkit/minesweeper.ckdb only — no shared code touched)
MinesweeperPersonalRecord+MinesweeperPersonalRecordStore(new, MinesweeperPersistence): CRUD over the injectedPrivateCKGatewayseam (lazy CK — no eagerCKContainer), mirroring PersistenceKit'sPersonalRecordStore:.ifUnchangedoptimistic concurrency with bounded 3-attempt retry (PersonalRecord best-time can clobber under multi-device race after #544 last-write-wins #552 lesson preserved), dedup-by-puzzleId, min-best merge. Record-type namePersonalRecordreuse is safe — each app owns its own CKContainer (same precedent asSavedGame).cloudkit/minesweeper.ckdb: adds thePersonalRecordrecord type, field-for-field identical to sudoku.ckdb's. Additive only.submitDailyTimeIfWon()(extracted to+SubmitOnWin.swiftto stay under the 400-line lint ceiling). Store threaded optional end-to-end likesavedGameStore. Failed writes funnel througherrorReporter, never interrupt the win.guard let gameCenter→if let gameCenter: deliberate — personal records must not depend on GC's presence; the 9 existing GC submit tests pin the old behavior (all green).Verification
swiftlint --strict: 0 violations · pre-commit hooks greenConflictOnceGateway/AlwaysConflictGatewaydecorators (sawConflictasserted)Review
Highest-risk tier: sonnet + opus dual review (data-writing CloudKit path), plus Leader spot-audit of container separation + lazy CK. Sonnet: no findings beyond a PR-note. Opus: 1 MAJOR (the practice-scope divergence — resolved by owner decision: ship daily-only, #705 follow-up; misleading comment reworded) + 2 MINOR (race-test name implied a guarantee it doesn't test — renamed; redundant
: Sendableon actor — kept, faithful mirror of Sudoku).Post-merge (NOT in this PR)
ck:schema, needs secrets/.env on the main checkout).PersonalRecordrecords that will fail silently behind the error funnel until prod has the record type.🤖 Generated with Claude Code