Skip to content

feat(minesweeper): record practice personal bests via seed-derived puzzle id - #779

Merged
wei18 merged 1 commit into
mainfrom
worktree-impl-705
Jul 11, 2026
Merged

wei18 merged 1 commit into
mainfrom
worktree-impl-705

Conversation

@wei18

@wei18 wei18 commented Jul 11, 2026

Copy link
Copy Markdown
Owner

What

Widens the #699 MS personal-record write path from daily-only to daily + practice (owner decision 2026-07-06), filling the 3 unused practice slots. The practice dedup puzzleId derives from the board's existing generation seed — practice-{crockfordBase32(seed)}-{difficulty}, mirroring Sudoku's PuzzleIdentity.practice(salt:) — because the practice SavedGame recordName stays a deliberate singleton.

Key design point: the seed is already minted once per new practice game (UInt64.random at both production callsites) and already round-trips save→resume verbatim (it reproduces the mine layout), so this needs zero new snapshot fields, no schema-version bump, and no legacy-decode fallback — a resumed practice win dedups as the same game for free.

  • submitDailyTimeIfWon() → submitWinIfWon(): latch arms on any win; GC submission stays strictly daily-only (fix(minesweeper): gate GC leaderboard submit to daily mode (mirror Sudoku) #329, permanent); personal-record puzzleId branches by mode
  • New MinesweeperPracticeIdentity + byte-identical private Crockford encoder copy (Sudoku's is internal); 7 shared test vectors pin the two implementations against drift
  • .replayDailyBoard route comment now explicitly documents why personalRecordStore stays nil there (CR finding)

Verification

  • MinesweeperKit full suite: 240 tests / 40 suites pass (was 218/36) — run independently by Leader and both reviewers
  • MinesweeperCoreKit 91 tests pass; SudokuKit builds clean (zero Sudoku source touched)
  • swiftlint --strict 0 violations; no .ckdb / schema changes (verified)
  • Dual code review APPROVE — the fact-check pass hunted seed-reuse counterexamples (DEBUG fixed-seed boards, daily-replay route, id keyspace collisions, CK optimistic-concurrency) and found none; new tests spot-verified to assert what they claim

Closes #705

🤖 Generated with Claude Code

…zzle id

The #699 personal-record store shipped with 6 mode/difficulty slots but a
mode == .daily write gate, leaving the 3 practice slots unused — a
deliberate launch scope (owner decision 2026-07-06) because the practice
SavedGame recordName is a singleton (practice-{difficulty}) and would
collapse every practice win into one dedup entry.

The per-game unique id now derives from the board's existing generation
seed instead of a new persisted field: every new-practice callsite
already mints UInt64.random once per game, and the seed round-trips
through MinesweeperSessionSnapshot / MinesweeperSession.restore verbatim
(it reproduces the mine layout), so a resumed practice win dedups as the
same game with zero new snapshot fields, no schema-version bump, and no
legacy-decode fallback. Id format mirrors Sudoku's
PuzzleIdentity.practice(salt:): practice-{crockfordBase32(seed)}-{difficulty},
via a new MinesweeperPracticeIdentity + a byte-identical private copy of
the Crockford encoder (SudokuPersistence's is internal; shared test
vectors pin the two implementations against drift).

submitDailyTimeIfWon() is renamed submitWinIfWon(): the didSubmitWin
latch now arms on any win (practice previously early-returned before
latching), Game Center submission stays strictly daily-only (#329,
permanent), and the personal-record puzzleId branches by mode (daily:
board recordName as before; practice: the seed-derived id).

Tests: practice wins record with the expected id format; two distinct
practice games count separately; resume keeps the id (dedup as one
game); GC never fires for practice; daily path unchanged; Crockford
vector pins (0, 1, 31, 32, 42, 12345, UInt64.max) shared with Sudoku.

Verification: MinesweeperKit full suite 240 tests / 40 suites pass
(was 218/36); MinesweeperCoreKit 91 tests pass; SudokuKit builds clean
(no Sudoku source touched); swiftlint --strict 0 violations on all
changed files.

Closes #705

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 11, 2026 11:51
@wei18
wei18 merged commit 99ef09b into main Jul 11, 2026
4 checks passed
@wei18
wei18 deleted the worktree-impl-705 branch July 11, 2026 11:52
wei18 added a commit that referenced this pull request Jul 11, 2026
…722) (#782)

Timeline log for the five-issue wave: cross-app coordinate a11y l10n
(#755/PR #776), Sudoku state-suffix l10n (#771/PR #777), the #716 premise
refutation + pencil-notes snapshot regression lock (PR #778), MS practice
personal bests via seed-derived ids (#705/PR #779), and Sudoku digit-first
input (#722/PR #781). Records the three pre-push review catches, the
seed-reuse design decision, and process notes (haiku numeric spot-checks,
reviewer send-report instruction, filtered-batch verification).

Co-authored-by: Claude Fable 5 <[email protected]>
wei18 added a commit that referenced this pull request Jul 14, 2026
…ntry) (#820)

Implements docs/v2/stats-screen-proposal.md as amended by the owner's
2026-07-14 adjudication comments on the issue (which are binding and
supersede the older body/proposal text where they conflict):

- Entry point: Home ONLY — a secondary-weight HomeSecondaryEntryLink row
  below the four mode cards (new optional secondaryLink slot on the shared
  HomeScreen scaffold; GameConfig.statsRoute drives it). The Settings
  disclosure row is DROPPED from scope per adjudication 4 — SettingsScreen
  is untouched.
- Layout: Daily and Practice as two stacked sections (adjudication 1, no
  segmented control).
- NO streak number anywhere (adjudication 2 — #774 adds it later).
- NO MS win-rate tile (adjudication 3 — no loss counter exists).
- Per-app screens (SudokuUI StatsView/StatsViewModel + MinesweeperUI
  MinesweeperStatsView/MinesweeperStatsViewModel; proposal §7 scope note —
  no shared cross-app Stats component), reading ONLY existing
  PersonalRecord fields: completedCount, bestTimeSeconds (nilable),
  totalTimeSeconds → average computed as total/count. Zero schema changes.
- MS Daily AND Practice sections ship with real data (#705 closed via
  #779 — practice PBs write for both).

Screen behavior:
- Pushed route per app (AppRoute.stats + LiveRouteFactory mapping; MS's
  destination split into LiveRouteFactory+Stats.swift for the 400-line
  file_length ceiling). Compact: 1-column tiles; iPad/Mac regular:
  3-column reflow + the boards' 960pt clamp-and-center; .accessibility3+:
  grid AND per-tile stat columns stack vertically (LeaderboardView's
  policy), no truncation.
- VoiceOver: each tile is one combined element with an explicit localized
  label ("Easy, 14 completed, best time 3 minutes 12 seconds, ...").
- Fetch: renders empty tiles instantly, fills as async CK reads land;
  offline / iCloud-signed-out degrades to zeroes via errorReporter funnel
  (daily-hub graceful-degrade posture). No monetization surface.
- Telemetry: new TelemetryEvent.statsViewed fired once per screen mount.
- L10n: 8 new keys in both catalogs (7 locales), +3 MS-only (Completed /
  Daily / Practice were missing from the MS catalog); l10n fixture
  regenerated; scan:l10n passes.

Deviation (documented): the proposal's conditional status.success accent
on a "just-set personal best" tile is omitted — PersonalRecord carries no
"best changed at last update" signal, so the screen cannot know
"just-set" (the dispatch's stated fallback).

Tests: VM unit tests both apps (average computation, nil-best / zero-count
tiles, fetch-failure degrade, one-shot telemetry, nil-store MS path);
strict-image snapshot baselines for the new screen (iPhone light, AX3,
iPad, Mac × both apps) recorded once and eyeballed; Home baselines
re-recorded for the new entry (both apps) and eyeballed. SudokuKit
verified in filtered batches (full-suite segfault is the known local
issue, reproduced on unmodified main); MinesweeperKit --no-parallel
276/276; GameAppKit 35/35; GameShellKit 28/28; TelemetryKit 32/32.
swiftlint --strict clean on changed files.

CR round-1 fix: per-case route-factory sentinel tests added for `.stats`
(statsRouteReturnsStatsView in SudokuKit RouteFactoryTests;
factoryReturnsViewForStatsRoute in MS LiveRouteFactoryTests). Rebased over
#744 (53c3daa): kept both sides in MS LiveRouteFactory/Live (their
share/review/invite-friends params + this branch's stats route); removed
an orphaned doc-comment line #744 left at the file tail and compressed the
`.stats` case to hold the 400-line file_length ceiling.

Closes #773

Co-authored-by: Claude Fable 5 <[email protected]>
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.

feat(minesweeper): record practice personal bests (needs per-game unique practice id)

1 participant