Skip to content

feat(minesweeper): saved-game store (snapshot↔CloudKit, MS-native summary) (#455) - #463

Merged
wei18 merged 2 commits into
mainfrom
feat/455-ms-savedgame-store
Jun 10, 2026
Merged

wei18 merged 2 commits into
mainfrom
feat/455-ms-savedgame-store

Conversation

@wei18

@wei18 wei18 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

What

New MinesweeperPersistence target: MinesweeperSavedGameStore maps the Codable MinesweeperSessionSnapshot (#458) ↔ a CloudKit SavedGame record via the shared public PrivateCKGateway, returning the MS-native MinesweeperSavedGameSummary.

Why MS-native: the shared SavedGameSummary is Sudoku-typed (daily/practice, easy/medium/hard) — MS difficulties are unrepresentable in it (#455 thread). The #460 resume seam (ResumeCandidate<Route> + fetchResume) makes a shared summary unnecessary: MS maps its own summary at the seam.

Wire schema — this is the cloudkit/minesweeper.ckdb contract (step 3, user-owned)

Record type SavedGame (per-app CKContainer → no Sudoku collision):

field CK type notes
difficulty String beginner/intermediate/expert
seed Int(64) UInt64 bit-pattern (Int64(bitPattern:) out / UInt64(bitPattern:) back)
mode String daily/practice qualifier
elapsedSeconds Int(64)
status String inProgress/completed
lastModifiedAt Date/Time
schemaVersion Int(64) 1
stateBlob Bytes JSON-encoded snapshot

Inert by design

Nothing constructs the store yet. Step 4 (composition fetchResume wire + Telemetry save-funnel mirroring Sudoku's store) lands after the user-owned ck:schema deploy.

Tests (FakePrivateCKGateway — zero live CloudKit)

  • summary fields incl. UInt64.max-1 seed bit-pattern round-trip
  • snapshot load round-trip + step-1 deterministic board restore
  • latest-by-lastModifiedAt; markCompleted excludes + 404 throw; wireStatus mapping

MinesweeperKit 133 (was 127, +6) · MSCore 87 unchanged · xctestplan gains MinesweeperPersistenceTests. Note: PersistenceTesting transitively drags SudokuCoreKit into the test graph (same as MinesweeperUITests — harmless).

Leader-built (session harness denies all subagent writes; two dispatched Developers' verified design used as spec). Refs #455.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 10, 2026 15:55
…mary) (#455)

New MinesweeperPersistence target (+ tests): MinesweeperSavedGameStore maps the Codable MinesweeperSessionSnapshot (#458) to a CloudKit SavedGame record via the shared public PrivateCKGateway, returning the MS-native MinesweeperSavedGameSummary — the shared SavedGameSummary is Sudoku-typed (daily/practice, easy/medium/hard) and cannot represent MS, per the #455 thread; the #460 resume seam makes a shared summary unnecessary.

Wire schema (= the future cloudkit/minesweeper.ckdb contract): difficulty String, seed Int(64) as UInt64 bit-pattern, mode String, elapsedSeconds Int(64), status String(inProgress/completed), lastModifiedAt Date/Time, schemaVersion Int(64)=1, stateBlob Bytes (JSON snapshot). Record type SavedGame — per-app CKContainer, no Sudoku collision.

INERT: nothing constructs the store yet. Step 4 (composition fetchResume wire + Telemetry save-funnel) lands after the user-owned ck:schema deploy.

Tests (FakePrivateCKGateway): summary fields incl. UInt64.max-1 seed bit-pattern round-trip; snapshot load round-trip + step-1 board restore; latest-by-lastModified; markCompleted excludes + 404 throw; wireStatus mapping. MinesweeperKit 133 (was 127, +6), MSCore 87 unchanged.

Co-Authored-By: Claude Fable 5 <[email protected]>
…te, recordName scheme (#455)

Code Reviewer (APPROVE-WITH-NITS):
- store header now documents the .ckdb index contract (status QUERYABLE + recordName QUERYABLE; lastModifiedAt needs none — max is client-side) and the deliberate MVP conflict trim (bare save throws .syncConflict; step 4 decides LWW vs surface)
- loadInProgress no longer try?-swallows: newer schemaVersion throws .schemaVersionTooNew, corrupt blob propagates — distinguishable from absent, so step 4 can clear a stuck resume candidate
- centralized recordName schemes (daily == MinesweeperDaily.puzzleId; practice-<difficulty> singleton) — prevents the Sudoku freehand-recordName orphan scar from recurring
- test renamed to wireStatusMapsTerminalStatesToCompleted (no unused lets); +3 tests: recordName stability, schema-version throw, corrupt-blob throw

MinesweeperKit 136 (was 133).

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 merged commit 2e79b13 into main Jun 10, 2026
4 checks passed
@wei18
wei18 deleted the feat/455-ms-savedgame-store branch June 10, 2026 08:09
wei18 added a commit that referenced this pull request Jun 10, 2026
…schema live-run bugs (#455) (#464)

* feat(cloudkit): commit schema source of truth + MS SavedGame; fix ck:schema live-run bugs (#455)

First real-token run of ck:schema (#337 tooling was never live-tested). Three task bugs fixed:
- save-token: cktool takes the token as positional arg only (stdin piping fails non-interactively)
- validate-schema: --environment is required
- production deploy: import-schema is development-only and cktool has NO promote subcommand -> the task now prints the Console-only steps (Deploy Schema Changes to Production...) and exits; promotion stays naturally user-owned

Schema source of truth committed (validated + deployed to both Development containers, round-trip export verified):
- cloudkit/minesweeper.ckdb (NEW): MonetizationState (all 5 app-writable fields) + SavedGame per #463 (8 fields; minimal indexes — status QUERYABLE only)
- cloudkit/sudoku.ckdb (NEW, exported): + 3 MonetizationState fields the code writes but Production lacked (lastShownDate/dismissedDate/lastSeenWallClock) — banner-dismiss persistence was silently failing in prod (JIT schema never runs in Production)

cloudkit/README.md workflow updated (hand-author path + Console-only promote); cloudkit-schema-ops SKILL gains a Live-run gotchas section (6 findings).

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs(cloudkit): address #464 CR — sweep stale --i-am-sure prod instructions, fix index-contract comment

CR (APPROVE-WITH-NITS) findings applied:
- 5 docs still instructed the dead 'deploy --env production --i-am-sure' (foundations §7.7.2 table+guard prose, both app-store review checklists, skills index ×3) → rewritten to the Console-only promote; MS checklist marked done (prod == .ckdb verified 2026-06-10)
- #MISE description no longer advertises the removed gate; --i-am-sure kept as documented legacy no-op so old commands degrade to instructions
- usage() sed range made robust (2,/^set /p + grep) — was printing code lines into --help
- MinesweeperSavedGameStore index-contract comment no longer claims recordName QUERYABLE (contradicted the .ckdb; Sudoku+MS Production now both run statusEquals without it)

Both Production containers verified byte-identical to cloudkit/*.ckdb after the user's Console promote.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
wei18 added a commit that referenced this pull request Jun 11, 2026
…o CLAUDE.md (#466) (#467)

* chore: #466 hygiene — wire AchievementID SSOT, README 16 packages, spec as-built, zh-Hant naming

- AchievementEvaluator now consumes the AchievementID enum (the SSOT it documented but never honored — 8 raw literals replaced); GameCenterIdentifiers header re-scoped honestly (GameCenterClient = structural; ASCRegister = deliberate runtime-reconciled copy, CLI must not depend on the cores)
- README.md + README.zh-Hant.md architecture trees 14 → 16 (add DeterminismKit, GameAppKit)
- resume-seam spec: MS section re-tagged as-built (#463/#465 landed same day; .resumeBoard supersedes the .board prediction)
- skills index zh: file-count 6→'5 files + meetings/' (en fixed in #461; zh missed) + renamed README.zh-TW.md → README.zh-Hant.md to match repo-root convention

Tests: GameCenterKit suite pending in CI; SudokuCoreKit 131, ASCRegisterKit 153 green locally.

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs: add repo-root CLAUDE.md — distilled agent operating guide

Operating knowledge distilled from the spec-first build sessions: the mirror principle (apps differ only in gameplay + resources, down to source), architecture layering in one map (zero-dep shell vs GameAppKit composition layer), the Leader/Developer/CR workflow contract (incl. subagent write-probe + model selection), build/verify discipline (absolute --package-path, stale-SourceKit rule, snapshot/determinism stops, unentitled-runner CloudKit laziness), user-owned hard gates (tf:upload, Console-only CK prod promote, secrets), and the conventions that bite (--no-gpg-sign, lowercase PR subject, strict-lint ceilings, .task arm64, worktree bleed). Pointer-first: deeper truth stays in skills / foundations / memory.

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot mentioned this pull request Jun 13, 2026
wei18 added a commit that referenced this pull request Jun 16, 2026
#515) (#532)

* fix(daily-hub): two-phase render in MinesweeperDailyHubViewModel (#530)

Bootstrap now sets `state = .loaded(mergeCards(trio, [], []))` immediately
after the synchronous `provider.dailyTrio(date:)`, then fills completion
and failure overlays async in `fillCompletionAndFailureOverlay` (Phase 2).
A CloudKit hang (iCloud signed out) can no longer block the hub's initial
render — same gate class and fix shape as the shipped Sudoku fix (#526).

Added `guard case .loaded = state else { return }` defensive check at
Phase-2 entry and exit (Sonnet's #526 nit, now applied to MS too).

New test file `MinesweeperDailyHubViewModelOfflineTests.swift` adds three
tests mirroring `DailyHubViewModelOfflineTests`:
- `bootstrapReachesLoadedEvenWhenCompletedIdsFetchHangsForever`
- `bootstrapReachesLoadedWhenCompletedIdsFetchThrowsImmediately`
- `bootstrapMarksCompletedCardsWhenPersistenceReturnsIds` (happy-path guard)

Package.swift: added SudokuCoreKit as explicit dep of MinesweeperUITests
so offline-hub fakes can implement PersistenceProtocol (which uses
Mode/GameSessionSnapshot from SudokuCoreKit) under InternalImportsByDefault.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(persistence): map iCloud-signed-out to nil in MinesweeperSavedGameStore (#515)

`loadInProgress(recordName:)` and `latestInProgress()` now catch errors
classified as `.iCloudSignedOut` (CKError.notAuthenticated code 9, and
`PersistenceError.iCloudNotSignedIn`) and return `nil` instead of throwing.
This degrades the Home resume pill / resume flow gracefully when iCloud is
signed out, rather than dead-ending with a thrown error.

Schema and decode errors are NOT caught — `PersistenceError.schemaVersionTooNew`
and JSON decode failures still propagate, preserving the #463 contract that
lets callers hide or delete a broken candidate.

New tests in `MinesweeperSavedGameStoreTests.swift`:
- `loadInProgressReturnsNilOnICloudSignedOutError` — fetch throws CKError 9 -> nil
- `latestInProgressReturnsNilOnICloudSignedOutError` — query throws CKError 9 -> nil
- `loadInProgressStillThrowsOnSchemaVersionTooNew` — regression guard for #463
- `loadInProgressStillThrowsOnDecodeError` — regression guard for #463

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot mentioned this pull request Jun 23, 2026
wei18 added a commit that referenced this pull request Jun 24, 2026
)

Upkeep #592 staleness sweep (Leader-verified against code):
- SDD-004 RFC: status RFC_FINAL->IMPL_APPROVED (M1-M4 built, M5 parked #501); mark M3/M4 DONE; resolve bundle-id checklist contradiction
- MS flow prototype: re-tag resume pill SHIPPED (#455 via #463/#465); best-time row corrected to OMITTED-BY-DESIGN (not 'not yet built' - MS stores no completed-game elapsed)
- README + README.zh-Hant: add Game2048CoreKit/Game2048Kit to package tree
- docs/README: add superpowers/specs to doc map
- GameViewModel: stale 626->648 line count in file_length rationale

Screenshots (#236) + .task footgun (#607) routed separately; README 3rd-game prose disclosure left to user.

Co-authored-by: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot mentioned this pull request Jul 10, 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