Skip to content

feat(shell): game-agnostic resume seam (ResumeCandidate + fetchResume) (#455) - #460

Merged
wei18 merged 2 commits into
mainfrom
feat/455-resume-seam
Jun 10, 2026
Merged

wei18 merged 2 commits into
mainfrom
feat/455-resume-seam

Conversation

@wei18

@wei18 wei18 commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Approach A — game-agnostic resume seam (#455)

Draws the game-agnostic boundary at the GameAppKit resume seam, not at PersistenceKit. The Home Resume pill only needs a label + a destination, which is genuinely game-agnostic; persisted state stays per-game. Sudoku's SavedGameSummary / PersistenceProtocol / store / CloudKit are untouched (zero shipping risk).

Changes

  • New ResumeCandidate<Route: Hashable & Sendable> DTO (title / subtitle / route).
  • GameRootViewModel: drops the SavedGameSummary-typed resumeCandidate + resumeRoute + the direct persistence.latestInProgress() call; adds an injected throwing fetchResume closure (nil => resume disabled). resumeCandidate is now the DTO; bootstrap() funnels fetchResume failures via errorReporter (source: GameRootViewModel.bootstrap.resume). persistence stays (still used by bootstrap()).
  • ResumePill: API -> (title:subtitle:onTap:); rendering byte-identical.
  • Sudoku Live/Preview: map SavedGameSummary -> ResumeCandidate; the %d:%02d elapsed helper moved to a single shared AppComposition.elapsed home (used by both).
  • GameRoot's Route constraint gains & Sendable (necessary propagation from the VM).

Behavior

Notes

  • This PR also carries the approved design spec docs/superpowers/specs/2026-06-10-resume-seam-design.md.

Tests

  • GameAppKit: 6 pass (rewritten for fetchResume).
  • SudokuKit: 220 pass, unchanged, no snapshot diffs.
  • MinesweeperKit: 127 pass, unchanged.

Refs #455.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 10, 2026 12:24
Brainstormed design for the resume seam: a game-agnostic ResumeCandidate<Route> DTO at the GameAppKit seam + an injected fetchResume closure on GameRootViewModel, decoupling it from the Sudoku-typed SavedGameSummary/PersistenceProtocol. Sudoku migrates as reference; MS store/CloudKit/wiring are downstream.

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

Approach A: draw the game-agnostic boundary at the GameAppKit resume seam,
not at PersistenceKit. The Home Resume pill only needs a label + a destination,
which is genuinely game-agnostic.

- New ResumeCandidate<Route: Hashable & Sendable> DTO (title/subtitle/route).
- GameRootViewModel: drop SavedGameSummary-typed resumeCandidate + resumeRoute
  + the direct persistence.latestInProgress() call; add injected throwing
  fetchResume closure (nil => resume disabled). resumeCandidate is now the DTO;
  bootstrap funnels fetchResume failures via errorReporter. persistence stays
  (still used by bootstrap).
- ResumePill: API -> (title:subtitle:onTap:); rendering byte-identical.
- Sudoku Live/Preview map SavedGameSummary -> ResumeCandidate; the %d:%02d
  elapsed helper moved to a single shared AppComposition.elapsed home.
- Sudoku behavior unchanged: same pill, same nav, no snapshot PNG re-records.
- Minesweeper stays fetchResume:nil (resume lands when its store does, downstream
  #455). No GameAppKit change needed for MS — the seam is N-game ready.
- Carries the approved design spec (2026-06-10-resume-seam-design.md).

Tests: GameAppKit 6, SudokuKit 220, MinesweeperKit 127 — all pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit d18efcb into main Jun 10, 2026
4 checks passed
@wei18
wei18 deleted the feat/455-resume-seam branch June 10, 2026 04:36
wei18 added a commit that referenced this pull request Jun 10, 2026
…mary) (#455) (#463)

* feat(minesweeper): saved-game store (snapshot↔CloudKit, MS-native summary) (#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]>

* fix(minesweeper): address #463 CR — index contract, schema-version gate, 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]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
wei18 added a commit that referenced this pull request Jun 11, 2026
…loader, fetchResume (#455 step 4) (#465)

* feat(minesweeper): wire saved-game resume — save hooks, .resumeBoard loader, fetchResume (#455 step 4)

Lights the MS Home resume pill end-to-end:

- PersistenceKit: public PrivateCKGatewayFactory (LivePrivateCKGateway stays internal). LAZY by contract — defers CKContainer.default() to first op; the app-shape tests construct .live() in a runner with no CloudKit entitlement, where eager resolution raises an uncatchable ObjC CKException (found by the test run, fixed via a deferring proxy actor — mirrors LivePersistence's own per-op gateway).
- Store: stale-daily filter in latestInProgress (daily-<day> recordName vs today UTC; Sudoku #228 class) + .gameSaved/.gameSaveFailed telemetry funnel (mirrors Sudoku's store)
- VM: optional store/recordName seam + persistCurrentState() — save points: pause, terminal reveal (upsert → wireStatus completed clears the pill), scenePhase .background + onDisappear (BoardView). Idle boards never save; failures funnel, never interrupt gameplay
- AppRoute.resumeBoard(recordName:mode:) + MinesweeperBoardLoaderView (mirrors Sudoku's BoardLoaderView): loadInProgress → MinesweeperSession.restore → board mounts paused (elapsed frozen); missing/newer-schema/corrupt records land in an honest failed state + Retry
- recordName fixed at board creation (daily == MinesweeperDaily.puzzleId for today; practice singleton slot) via a UI-layer GameMode helper
- Composition: savedGameStore over the factory; fetchResume (Live+Resume.swift — Live.swift is at the file_length budget) maps summary → ResumeCandidate; route factory threads store into boards + mounts the loader

Tests: MS 141 (was 136; +4 persist-hooks +1 stale-daily), PersistenceKit 58, SudokuKit 220, MSCore 87 — green; no snapshot PNG changes.

Follow-up: 'Couldn't load saved game.' needs the next L10n pass (Retry already in the MS catalog); resume-pill title strings keep the pre-#460 literal-interpolation behavior.

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

* style(minesweeper): trim Live.swift comments under file_length (#455)

The step-4 wiring (+store build, +2 args) tipped Live.swift to 404; strict CI treats the 400-line file_length warning as an error. Condensed 4 comment blocks — no factual loss; Live+Resume.swift already carries the resume rationale.

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

* fix(minesweeper): address #465 CR — re-thread Retry persistence seam, doc sweeps, contract tests

Code Reviewer (APPROVE-WITH-NITS):
- Retry rebuilt the VM without errorReporter/store/recordName → save hooks silently died post-Retry (same class as the #330 soundPlayer omission). Seams now internal-readable on the VM and re-threaded in onRetry — a retried board keeps saving to its original slot.
- doc sweeps: RootViewModel header (resume is ON via Live+Resume.swift), store header (constructed + conflict policy decided + schema deployed), VM scope line, filter >= wording
- +2 tests: save-failure funnels (FakePrivateCKGateway.alwaysOnSave + FakeErrorReporter; gameplay state intact) and the GameModeRaw == GameMode.rawValue string contract

Deferred (CR nit, narrow + self-healing): daily .board recordName derives 'today' at view-build while the seed was baked at hub render — a hub left open across UTC midnight can file yesterday's board under today's slot. Airtight fix = carry the day in the route; noted for a future route-payload change.

MinesweeperKit 143 (was 141).

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

* style(minesweeper): rename vm → viewModel in persist-hooks tests (identifier_name)

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

---------

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.

1 participant