You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(minesweeper): persist in-progress boards → Home Resume pill (① part-b, from #448) #455
Split from #448 (① part-b). The wrapper-unification epic delivered the shared resume scaffold (GameRootViewModel<Route> fetches latestInProgress() and GameRoot/ResumePill render it) — but Minesweeper still can't show a Home "Resume" pill because MS doesn't persist in-progress boards.
Blocker
SavedGameSummary (PersistenceKit) carries puzzleId / mode / difficulty / elapsedSeconds / … but no seed. MS's board route is .board(difficulty:, seed:, mode:) — without a persisted seed, MS can't reconstruct the in-progress board, so it passes resumeRoute: nil (resume off).
To enable MS resume
Persist MS in-progress board state (incl. seed + reveal/flag state) via the SavedGame store — mirror Sudoku's save flow.
Ensure latestInProgress() returns MS in-progress games (today MS's saved-game flow is a stub).
Provide MS a resumeRoute: { AppRoute.board(difficulty: $0.difficulty, seed: <persisted seed>, mode: $0.mode) } and switch MS Root construction to pass it (scaffold already shared — pill lights up automatically).
Verify: start MS game → background → relaunch → Home shows "Resume", tapping restores the exact board.
Likely needs a seed (and possibly serialized board) field on the saved-game record — check CloudKit schema impact (ck:schema).
Goal: MS Home "Resume" pill at parity with Sudoku. The shared scaffold is already done (#448): GameRootViewModel<Route> fetches latestInProgress(), GameRoot/ResumePill render it — MS just passes resumeRoute: nil today. This issue lights it up.
Hard blocker (user-owned)
cloudkit/minesweeper.ckdb has only MonetizationState — no SavedGame record type. MS resume requires adding one → a CloudKit schema change, and per cloudkit-schema-ops/foundations.md the seed + production deploy is USER-OWNED (mise run ck:schema … against the live token). So this issue cannot fully land without a user step.
Phasing
MinesweeperSession snapshot/restore (MinesweeperCoreKit) — add Codablesnapshot() + restore(from:), mirroring Sudoku's GameSession. Deterministic: persist seed + difficulty + mode + revealed/flagged cell state + elapsed; restore reconstructs the exact board from the seed (DeterminismKit) and replays state. Determinism tests + a frozen restore vector.
MS SavedGame persistence (PersistenceKit) — wire MS SavedGameStore (save / loadOrCreate / latestInProgress / markCompleted) for the MS container; map the snapshot to a SavedGame record. SavedGameSummary likely needs a seed field (today it has none).
CloudKit schema (USER-OWNED) — add SavedGame to cloudkit/minesweeper.ckdb; user seeds + ck:schema deploys to Dev then Production. Gates step 4 going live.
Wire-up (MS UI/composition) — board save-on-background/teardown; MinesweeperAppComposition/Live.swift builds the MS savedGameStore + passes resumeRoute: { AppRoute.board(difficulty: $0.difficulty, seed: <persisted>, mode: $0.mode) }; MinesweeperRoot forwards it. Pill lights up automatically (scaffold shared).
Verify — start MS game → background → relaunch → Home shows "Resume" → tap restores the exact board (same mines, same revealed/flagged state, elapsed continues).
the package depends on SudokuCoreKit (not MinesweeperCoreKit).
So MS cannot reuse the existing store as-is. Options:
(a) Generalize the seam — persist the snapshot as an opaque Codable/Data blob; make PersistenceProtocol's saved-game methods game-agnostic (generic over snapshot type or Data-based). Cleanest + matches the wrapper-unification principle, but a real shared-PersistenceKit refactor with Sudoku call-site ripple. Recommended.
(b) Parallel MS-specific saved-game store — duplicates the pattern (against the de-dup principle).
(c) Couple PersistenceKit to both CoreKits — ugly.
No urgency: step 2 is gated by step 3 (the minesweeper.ckdbSavedGame schema + ck:schema production deploy, user-owned) — MS resume can't go live without it regardless. Recommend designing step 2 (option a) fresh next session rather than firing a shared-persistence refactor blind.
Step 2 halted — SavedGameSummary is Sudoku-typed (architecture decision needed)
Scoping step 2 surfaced a hard contradiction: the resume seam's return type, SavedGameSummary, hardcodes SudokuEngine's enums:
mode: Mode = daily | practice — MS has no mode.
difficulty: Difficulty = easy | medium | hard — MS is beginner | intermediate | expert.
MS cannot return a truthful SavedGameSummary. (The existing MS placeholder already lies: SavedGameSummary(mode: .daily, difficulty: .easy) for a "…-beginner" puzzleId — MinesweeperUITests/ClearCacheFeedbackTests.swift:63.) A real MS store returning this would misreport every MS game.
This is NOT sliceable, because the same Sudoku-typed summary flows through PersistenceProtocol.latestInProgress() AND GameAppKit.GameRootViewModel's resumeRoute: (SavedGameSummary) -> Route (the #448 seam). So #455 collapses to one cross-cutting design decision:
Decision: how to make the saved-game/resume seam game-agnostic
Option 1 — MS-native summary (MinesweeperSavedGameSummary): truthful + zero Sudoku risk, but then GameRootViewModel's resume seam must become generic over the summary type (or each game maps to a shared shape) — i.e. the generalization still has to happen at the seam.
Option 2 — generalize SavedGameSummary (difficulty/mode as raw String or generic): one shared type both games use; touches Sudoku's mapper + call sites (additive/low-risk if done as String, but it IS a shared-type change).
Recommendation: design the seam generalization holistically (SavedGameSummary + PersistenceProtocol resume surface + GameRootViewModel.resumeRoute + Sudoku call sites), determinism-low but breadth-high — best done as a designed pass, not piecemeal.
Still gated by step 3 (user-owned)
Regardless of the seam decision, MS resume can't go live without the user seeding cloudkit/minesweeper.ckdb with a SavedGame record type + ck:schema deploy (the .ckdb is user-seeded; absent from the repo).
Net:#455 step 1 (snapshot/restore) is banked. Steps 2-4 are one architecture decision + a user-owned CloudKit deploy — deferred to a proper design pass.
Resume seam ✅ merged (#460) — the architecture decision is resolved
Approach A shipped (design spec: docs/superpowers/specs/2026-06-10-resume-seam-design.md, CR-reviewed):
New game-agnostic GameAppKit.ResumeCandidate<Route> (title/subtitle/route).
GameRootViewModel now takes an injected fetchResume: (() async throws -> ResumeCandidate<Route>?)? — decoupled from the Sudoku-typed SavedGameSummary/PersistenceProtocol. ResumePill renders the DTO.
Sudoku migrated as reference (its SavedGameSummary/persistence/CloudKit untouched); GameAppKit 6 / SudokuKit 220 / MS 127 all green, no snapshot drift.
MS resume is now just an injection away — no further GameAppKit change needed.
Remaining (downstream)
MS saved-game store — map MinesweeperSessionSnapshot (Codable, step 1 ✅) ↔ CloudKit via the public gateway; expose an MS fetchResume that returns a ResumeCandidate(route: .board(difficulty:seed:mode:)). (Now unblocked — MS owns its own store + mapping; no shared-type fight.)
CloudKit schema (user-owned) — seed cloudkit/minesweeper.ckdb with a SavedGame record type + ck:schema deploy. The .ckdb is user-seeded (absent from repo).
Wire MS fetchResume into MinesweeperAppComposition.
Activity
wei18 commentedon Jun 9, 2026
Implementation plan (grounded)
Goal: MS Home "Resume" pill at parity with Sudoku. The shared scaffold is already done (#448):
GameRootViewModel<Route>fetcheslatestInProgress(),GameRoot/ResumePillrender it — MS just passesresumeRoute: niltoday. This issue lights it up.Hard blocker (user-owned)
cloudkit/minesweeper.ckdbhas onlyMonetizationState— noSavedGamerecord type. MS resume requires adding one → a CloudKit schema change, and percloudkit-schema-ops/foundations.md the seed + production deploy is USER-OWNED (mise run ck:schema …against the live token). So this issue cannot fully land without a user step.Phasing
Codablesnapshot()+restore(from:), mirroring Sudoku'sGameSession. Deterministic: persistseed+ difficulty + mode + revealed/flagged cell state + elapsed; restore reconstructs the exact board from the seed (DeterminismKit) and replays state. Determinism tests + a frozen restore vector.SavedGameStore(save / loadOrCreate /latestInProgress/ markCompleted) for the MS container; map the snapshot to aSavedGamerecord.SavedGameSummarylikely needs aseedfield (today it has none).SavedGametocloudkit/minesweeper.ckdb; user seeds +ck:schemadeploys to Dev then Production. Gates step 4 going live.MinesweeperAppComposition/Live.swiftbuilds the MS savedGameStore + passesresumeRoute: { AppRoute.board(difficulty: $0.difficulty, seed: <persisted>, mode: $0.mode) };MinesweeperRootforwards it. Pill lights up automatically (scaffold shared).Sequencing
MinesweeperAppComposition/Live.swift.test(minesweeper): harden restore tests per CR — continued play + .pl…
feat(minesweeper): codable MinesweeperSessionSnapshot + Session.resto…
wei18 commentedon Jun 9, 2026
Step 1 ✅ merged (#458) — foundation in place
MinesweeperSessionSnapshotis nowCodable+ carriesseed;MinesweeperSession.restore(from:)reconstructs the exact board (CR-verified determinism + continued-play-after-restore + clock-freeze).Step 2 is an architecture fork (needs a design decision before implementation)
Discovered while scoping: PersistenceKit's saved-game layer is Sudoku-specific, not generic —
PersistenceProtocolhardcodesGameSessionSnapshot(loadOrCreate/save/latestInProgress return/take it),SavedGameStore+SavedGameMapperinternal import GameState/SudokuEngine,So MS cannot reuse the existing store as-is. Options:
Codable/Datablob; makePersistenceProtocol's saved-game methods game-agnostic (generic over snapshot type orData-based). Cleanest + matches the wrapper-unification principle, but a real shared-PersistenceKit refactor with Sudoku call-site ripple. Recommended.No urgency: step 2 is gated by step 3 (the
minesweeper.ckdbSavedGameschema +ck:schemaproduction deploy, user-owned) — MS resume can't go live without it regardless. Recommend designing step 2 (option a) fresh next session rather than firing a shared-persistence refactor blind.wei18 commentedon Jun 9, 2026
Step 2 halted —
SavedGameSummaryis Sudoku-typed (architecture decision needed)Scoping step 2 surfaced a hard contradiction: the resume seam's return type,
SavedGameSummary, hardcodes SudokuEngine's enums:mode: Mode=daily | practice— MS has no mode.difficulty: Difficulty=easy | medium | hard— MS isbeginner | intermediate | expert.MS cannot return a truthful
SavedGameSummary. (The existing MS placeholder already lies:SavedGameSummary(mode: .daily, difficulty: .easy)for a"…-beginner"puzzleId —MinesweeperUITests/ClearCacheFeedbackTests.swift:63.) A real MS store returning this would misreport every MS game.This is NOT sliceable, because the same Sudoku-typed summary flows through
PersistenceProtocol.latestInProgress()ANDGameAppKit.GameRootViewModel'sresumeRoute: (SavedGameSummary) -> Route(the #448 seam). So #455 collapses to one cross-cutting design decision:Decision: how to make the saved-game/resume seam game-agnostic
MinesweeperSavedGameSummary): truthful + zero Sudoku risk, but thenGameRootViewModel's resume seam must become generic over the summary type (or each game maps to a shared shape) — i.e. the generalization still has to happen at the seam.SavedGameSummary(difficulty/mode as rawStringor generic): one shared type both games use; touches Sudoku's mapper + call sites (additive/low-risk if done as String, but it IS a shared-type change).Recommendation: design the seam generalization holistically (
SavedGameSummary+PersistenceProtocolresume surface +GameRootViewModel.resumeRoute+ Sudoku call sites), determinism-low but breadth-high — best done as a designed pass, not piecemeal.Still gated by step 3 (user-owned)
Regardless of the seam decision, MS resume can't go live without the user seeding
cloudkit/minesweeper.ckdbwith aSavedGamerecord type +ck:schemadeploy (the.ckdbis user-seeded; absent from the repo).Net: #455 step 1 (snapshot/restore) is banked. Steps 2-4 are one architecture decision + a user-owned CloudKit deploy — deferred to a proper design pass.
feat(shell): game-agnostic resume seam (ResumeCandidate + fetchResume) (
feat(shell): game-agnostic resume seam (ResumeCandidate + fetchResume) (
wei18 commentedon Jun 10, 2026
Resume seam ✅ merged (#460) — the architecture decision is resolved
Approach A shipped (design spec:
docs/superpowers/specs/2026-06-10-resume-seam-design.md, CR-reviewed):GameAppKit.ResumeCandidate<Route>(title/subtitle/route).GameRootViewModelnow takes an injectedfetchResume: (() async throws -> ResumeCandidate<Route>?)?— decoupled from the Sudoku-typedSavedGameSummary/PersistenceProtocol.ResumePillrenders the DTO.SavedGameSummary/persistence/CloudKit untouched); GameAppKit 6 / SudokuKit 220 / MS 127 all green, no snapshot drift.MS resume is now just an injection away — no further GameAppKit change needed.
Remaining (downstream)
MinesweeperSessionSnapshot(Codable, step 1 ✅) ↔ CloudKit via the public gateway; expose an MSfetchResumethat returns aResumeCandidate(route: .board(difficulty:seed:mode:)). (Now unblocked — MS owns its own store + mapping; no shared-type fight.)cloudkit/minesweeper.ckdbwith aSavedGamerecord type +ck:schemadeploy. The.ckdbis user-seeded (absent from repo).fetchResumeinto MinesweeperAppComposition.docs: address CR blockers — purge removed New Game mode from frames, …
chore: re-tag shipped prototypes + remove dead ASC/Telemetry code, sp…
fix(minesweeper): address #463 CR — index contract, schema-version ga…
feat(minesweeper): saved-game store (snapshot↔CloudKit, MS-native sum…
wei18 commentedon Jun 10, 2026
Step 3 —
cloudkit/minesweeper.ckdbschema spec(user-owned,可以動手了)Store 已 merge(#463,CR-verified)。請在 MS container(
iCloud.com.wei18.minesweeper)新增 record type,欄位逐字如下:Record type:
SavedGamedifficultybeginner/intermediate/expertseedmodedaily/practiceelapsedSecondsstatusinProgress/completedlastModifiedAtschemaVersionstateBlobMinesweeperSessionSnapshotIndexes(#463 CR 抓出的必要項 — 漏了會在第一次
latestInProgress()時 production 炸 "field not marked queryable")status→ QUERYABLErecordName→ QUERYABLE(CloudKit query 的習知前置)lastModifiedAt不需 sortable(max-by 在 client 端)流程照
cloudkit/README.md/ck:schemaskill:跑 debug build 寫 Development container(注意:store 目前 inert——沒有寫入路徑,所以直接手寫 .ckdb 或先在 CK Dashboard Dev 環境手建後 export),review diff → commit.ckdb→mise run ck:schemadeploy 至 Production(--i-am-suregate)。recordName 方案(已內建 helper,#463 CR)
daily-<YYYY-MM-DD>-<difficulty>(==MinesweeperDaily.puzzleId)practice-<difficulty>(每難度單一 resumable slot)Step 4 驗收清單(schema deploy 後我接手)
MinesweeperSavedGameStore+ save-on-background/teardown(用 recordName helpers;guardstatus != .idle不存零資訊棋盤)fetchResume注入(summary →ResumeCandidate;route 需帶 recordName/snapshot 到 board VM — 現有.board(difficulty:seed:mode:)只能重建新局,feat(minesweeper): saved-game store (snapshot↔CloudKit, MS-native summary) (#455) #463 CR 💭8)schemaVersionTooNew的 resume candidate 隱藏/清除feat(cloudkit): commit schema source of truth + MS SavedGame; fix ck:…
wei18 commentedon Jun 10, 2026
Step 3 ✅ 完成(2026-06-10)
cloudkit/minesweeper.ckdb+cloudkit/sudoku.ckdb已 commit 為 source of truth(feat(cloudkit): commit schema source of truth + MS SavedGame; fix ck:schema live-run bugs (#455) #464,CR 過)。export --environment production驗證與.ckdbbyte-identical。MonetizationState補上lastShownDate/dismissedDate/lastSeenWallClock(線上 banner-dismiss 持久化默默失敗的 bug);MS Production 首次獲得MonetizationState(fix(minesweeper): run persistence.bootstrap() so AdGate/banner works (#448) #450 banner 修復至此才真正可在 TestFlight 生效)+SavedGame。ck:schema三個首跑 bug 修正(feat(cloudkit): commit schema source of truth + MS SavedGame; fix ck:schema live-run bugs (#455) #464);學習收錄於cloudkit-schema-opsskill §Live-run gotchas。剩餘:Step 4(最後一步 — MS resume 點亮)
照本 thread 的 step-4 驗收清單(save-on-background、
fetchResume注入、stale-daily filter、decode-failure 處置、conflict 策略、Telemetry funnel、真機驗證)。schema 已就緒,無前置阻擋。style(minesweeper): trim Live.swift comments under file_length (#455)
feat(minesweeper): wire saved-game resume — save hooks, .resumeBoard …
wei18 commentedon Jun 11, 2026
Step 4 ✅ merged(#465)— MS Resume pill 點亮
端到端:開局 → 玩 → pause/背景/離開時
persistCurrentState()→ 重啟 →fetchResume→ Home Resume pill → tap →.resumeBoard→ loader 還原同一盤(paused、elapsed 凍結)。CR(APPROVE-WITH-NITS)全數套用:Retry 重織 persistence seam(retry 後存檔不再默默死亡)、過時註解清掃、+2 合約測試(save-failure funnel、
GameModeRaw==GameMode.rawValue)。Lazy gateway 結構性密閉(CKContainer.default()延遲到首次操作,unentitled test runner 實證可建構)。測試:MS 143 · PersistenceKit 58 · SudokuKit 220 · MSCore 87。
收尾(非阻擋)
tf:upload連同 fix(minesweeper): run persistence.bootstrap() so AdGate/banner works (#448) #450 banner 一起驗最划算).board跨 UTC 午夜的 recordName/seed day 不一致(narrow、self-healing;route payload 改動時一併)#455 全部 step(1–4)完成。
wei18 commentedon Jun 11, 2026
Closing per owner decision: all 4 steps merged (#458 snapshot/restore → #463 store → #464 schema, prod verified byte-identical → #465 end-to-end wire, CR'd incl. Retry-seam re-thread). On-device/simulator verification deferred — assumed passing until a regression says otherwise (sim tap tooling gap: idb absent; non-brew install path + XCUITest alternative documented in-thread for when needed).
Carried follow-ups (non-blocking, revisit on regression or next release pass):
docs(#592): re-tag shipped work + fix doc-staleness audit findings (#609