Repository navigation
feat(minesweeper): achievement system — 11 achievements, evaluator, GC reporting - #734
Merged
Merged
Conversation
Adds Minesweeper's first Game Center achievement system per the owner-approved set in #700 (Starter x2, Volume x3, Difficulty x2, Skill x2, Streak x2 = 11 achievements, 650 pts total). MS-native by owner decision (same precedent as #699): evaluation + reporting sit beside submitDailyTimeIfWon() on the win path, NOT wired through the shared TelemetryEvent / makeCompletionSinks pipeline (MS cannot construct the Sudoku-typed TelemetryEvent). MinesweeperUI: - MinesweeperAchievementID: 11 short ids under the com.wei18.minesweeper.achievement. prefix, mirroring Sudoku's key shapes (daily.complete_one, wins.complete_10/50/200, daily.streak_7/30, ...). - MinesweeperWinFact + MinesweeperAchievementEvaluator: pure, synchronous evaluation (progressive percentComplete for the volume tier; GameKit dedupes re-reported 100% achievements). - MinesweeperDailyStreakMath: UTC consecutive-day counting from the day-stamped completedPuzzleIds already recorded by MinesweeperPersonalRecordStore (streak + full-spectrum facts). - MinesweeperWinCountStore: device-local UserDefaults tally backing the volume achievements (both modes combined). - MinesweeperGameViewModel: flagsPlacedThisGame latches on the flag INCREASE edge (place-then-remove still disqualifies No Flags Needed); evaluateAchievementsIfWon() fires ONLY on the live reveal() win transition — deliberately not on refresh(), which would inflate the non-idempotent win tally when re-opening a won board. Reporting is best-effort: errors funnel to errorReporter, never interrupt the win moment. ASCRegisterKit (registration material; apply run stays user-owned): - Config.achievements(for: GCApp) app-split mirroring leaderboards(for:); Sudoku's list byte-identical, pinned by tests. - Reconciler/main: achievement actions now flow for --app minesweeper (previous leaderboard-only filter removed); localization lookup goes through AchievementConfig's app-scoped locKeyPrefix keys. - gc-strings.xcstrings.patch: 33 MS achievement keys (gc.minesweeper.achievement.*, title/description/unearnedDescription) fully translated in all 7 locales (en source, zh-Hant primary, ja/zh-Hans/es/th/ko via the ai-translated-localization flow). Achievement strings live only in the ASCRegister registration material, not in the app catalogs (mirrors Sudoku: no gc.achievement keys in Localizable.xcstrings), so the scan:l10n gate is unaffected. Tests: 31 new (evaluator positive/negative per achievement incl. progressive boundaries and the 179s/181s lightning edge; streak math; win-count round-trip; ViewModel reporting incl. error-swallow and no-inflation-on-refresh). MinesweeperKit 218/218 --no-parallel, ASCRegisterKit 160/160, swiftlint --strict clean. Refs #700 (ASC registration run pending; close after ASCRegister apply) Co-Authored-By: Claude Fable 5 <[email protected]>
Code review on the achievement system found that two achievement facts
lived as ViewModel-instance state while the rules need whole-game-scope
facts, plus a tally/GC coupling nit. Three fixes:
MAJOR 1 — resumed won board re-inflated the win tally:
- MinesweeperSavedGameStore.loadInProgress now filters terminal records
("completed" / "failed") to nil, mirroring latestInProgress()'s status
filter — a terminal save is not resumable (honest-failure philosophy;
a missing status field stays tolerant/resumable).
- ViewModel defense in depth: reveal() only evaluates achievements when
the pre-reveal status was not already .won, so a no-op reveal on a
restored won board (which re-publishes the .won snapshot) can never
re-run the non-idempotent tally increment.
MAJOR 2 — "No Flags Needed" mis-awarded after resume:
- The flag-history fact moves from a ViewModel-instance latch
(flagsPlacedThisGame, lost on rebuild) into the session + snapshot:
MinesweeperSession latches everFlagged on the flag-placement edge and
MinesweeperSessionSnapshot persists it inside the existing stateBlob
JSON (opaque blob — no CloudKit schema change). Back-compat: pre-#700
blobs lack the key and decode false via decodeIfPresent; applySnapshot
additionally ORs in flagCount > 0 so a legacy save with flags on the
board stays disqualified (a legacy placed-then-removed flag is
unrecoverable — accepted, saves are TestFlight-internal, same
precedent as the wireStatus migration note).
MINOR — local tally no longer gated on Game Center presence:
- winCountStore.incrementAndGet() moved before the guard let gameCenter
in evaluateAchievementsIfWon(): the tally is a device fact and must
advance for offline/signed-out wins.
New guard tests (8):
- MinesweeperSavedGameStoreTerminalFilterTests.
loadInProgressReturnsNilForTerminalRecords (MAJOR 1, store)
- MinesweeperAchievementReportingTests.
restoredWonSessionDoesNotRecountOrRereport (MAJOR 1, ViewModel)
- MinesweeperAchievementReportingTests.
flagBeforeResumeStillDisqualifiesNoFlags (MAJOR 2, full blob
round-trip + fresh ViewModel)
- MinesweeperAchievementReportingTests.
winWithoutGameCenterStillCountsLocally (MINOR)
- MinesweeperSessionEverFlaggedTests: placeThenRemoveKeepsEverFlagged /
everFlaggedSurvivesRestore / legacyBlobDecodesEverFlaggedFalse /
restoreLegacySaveWithFlagsOnBoardSetsEverFlagged (MAJOR 2, core)
Verified: MinesweeperKit 222/222 --no-parallel, MinesweeperCoreKit
91/91, swiftlint --strict clean on all changed files.
Refs #700
Co-Authored-By: Claude Fable 5 <[email protected]>
wei18
enabled auto-merge (squash)
July 8, 2026 10:20
This was referenced Jul 8, 2026
wei18
added a commit
that referenced
this pull request
Jul 8, 2026
Consolidates 17+ merged PRs (#701-#734): B1-B4 mirror/product decisions, TF upload four-PR automation chain, GC/board-loader hardening, and the MS achievement system, plus the open queue and two operational incidents. 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.
Refs #700 (stays open for the user-owned ASCRegister apply; code side complete).
What (2 commits, net ~+1760/−58: new Achievements subsystem + ASCRegister app-split + review fixes)
MinesweeperAchievementEvaluatorover aMinesweeperWinFact, mounted ONLY onreveal()'s live.playing→.wontransition; UTCMinesweeperDailyStreakMath; UserDefaultsMinesweeperWinCountStore(per-game key prefix); best-effort GC reporting through errorReporter, local tally independent of GC presence.achievements(for: GCApp), MS registration material (gc.minesweeper.achievement.*, 33 keys × 7 locales), and an en-route fix of a latent Reconciler namespace bug that would have looked up wrong keys for any non-Sudoku app (Sudoku resolution provably unchanged; pinned by new ConfigConsistencyTests).loadInProgressnow filters terminal records + a VM-levelpreviousStatus != .wonsecond line — resuming an already-won save can no longer re-inflate the win tally;everFlaggedis now a persisted session/snapshot fact (backward-compatibledecodeIfPresent, legacy saves OR-fallback onflagCount > 0) — backgrounding/resuming can no longer falsely grant "No Flags Needed". Local tally increments before the GC guard.Verification
cloudkit/*.ckdbzero diff (the new snapshot field lives inside the opaque stateBlob).Review
Dual review: haiku machine-verified the 11 IDs / 231 translation entries / scope discipline; sonnet's deep pass found 2 MAJORs (VM-instance latches vs game-scoped facts) + 1 MINOR — all fixed and delta re-verified ACCEPT by the original finder.
After merge (user-owned)
Register the achievements in ASC: extract the JSON from
Packages/ASCRegisterKit/Sources/ASCRegister/Strings/gc-strings.xcstrings.patch(strip the comment header), thenASCRegister plan→applywith--app minesweeperand the MS ASC app id (creds in secrets/.env). Exact one-liner in the issue thread.🤖 Generated with Claude Code