Skip to content

feat(shell): add BoardPreview value type + extend resume mappers to stop dropping payload - #1047

Merged
wei18 merged 1 commit into
mainfrom
session/surly-owl-gc26
Aug 31, 2026
Merged

wei18 merged 1 commit into
mainfrom
session/surly-owl-gc26

Conversation

@wei18

@wei18 wei18 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

What

Adds the game-agnostic BoardPreview { columns, rows, cells: [CellMark] } value type to GameShellKit (zero-dependency, per design.md §3.6 ⚠️ 型別約束 / §12 error #11) and extends the resume pipeline so the CloudKit payload both apps already fetch stops being dropped by the mappers:

  • GameAppKit.ResumeCandidate<Route> gains boardPreview: BoardPreview? (references the shell type — dependency direction keeps the shell clean).
  • Sudoku: SavedGameSummary surfaces boardState; pure SudokuBoardPreviewMapper maps it + the puzzle's givenMask (deterministic local regen via puzzleProvider.puzzle(for:), no new CloudKit fetch) into .given/.filled/.empty marks; wired in Live.swift fetchResume.
  • Minesweeper: MinesweeperSavedGameSummary surfaces stateBlob; pure MinesweeperBoardPreviewMapper decodes the session snapshot into .empty/.filled/.marked; wired in Live.swift fetchResume.
  • Degrade contract: any missing/malformed/truncated payload → boardPreview == nil, text-only resume pill; resume itself is never blocked (failable BoardPreview.init? + tolerant decode + try? around the puzzle lookup).
  • Data availability only — no rendering; thumbnails are feat(ui): Today / Practice / Progress tab screens #1021's job.

Verification

  • swift test green: GameShellKit 54, GameAppKit 85, PersistenceKit 81, SudokuKit 438 (full), MinesweeperKit 371 (full) — incl. new malformed-payload → nil degrade tests in all four packages.
  • rg "import Persistence" Packages/GameShellKit/Sources → zero hits (D2 mechanical proof; no new dependency edge in GameShellKit's Package.swift).
  • swiftlint lint --strict clean on all touched files.
  • Dual code review (2 independent reviewers): APPROVE / APPROVE, zero substantive findings; Sudoku puzzle(for:) traced to the local seed-based regen (PuzzleStore.swift:86), failure branch degrades preview only, never the candidate.
  • Doc sync: docs/superpowers/specs/2026-06-10-resume-seam-design.md struct block updated; impl-notes at meetings/2026-08-31_1017-board-preview.impl-notes.md.

Closes #1017
Part of #1014

🤖 Generated with Claude Code

…top dropping payload

Add a zero-dependency BoardPreview { columns, rows, cells: [CellMark] }
value type to GameShellKit (per design.md §3.6 ⚠️ 型別約束 — NOT GameAppKit,
see §12 error #11) and give GameAppKit's ResumeCandidate<Route> an optional
boardPreview field referencing it, so the CloudKit payload both apps already
fetch (Sudoku boardState, Minesweeper stateBlob) stops being discarded by the
resume mappers.

- GameShellKit: BoardPreview + game-agnostic CellMark (empty/given/filled/
  marked); failable init degrades malformed shapes to nil, never traps.
- PersistenceKit: SavedGameSummary surfaces boardState (tolerant decode).
- SudokuKit: pure SudokuBoardPreviewMapper (boardState + givenMask from the
  deterministic local puzzle regen — no new CK fetch); wired in Live.swift
  fetchResume; any failure degrades to a text-only pill.
- MinesweeperKit: MinesweeperSavedGameSummary surfaces stateBlob; pure
  MinesweeperBoardPreviewMapper decodes the session snapshot; wired in
  Live.swift fetchResume with the same degrade contract.
- Tests in all four packages incl. malformed/truncated-payload → nil paths;
  doc sync in docs/superpowers/specs/2026-06-10-resume-seam-design.md.

Data availability only — rendering is #1021's job.

Closes #1017
Part of #1014

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

wei18 commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

T6 ACCEPT — PR #1047 (issue #1017), fresh-context acceptance in a throwaway detached worktree at head c28bdd0.

Sanity check: Packages/GameShellKit/Sources/GameShellUI/BoardPreview.swift exists on head, absent on main. Confirmed.

A. BoardPreview zero-dependency in GameShellKit — ✅. BoardPreview.swift has zero import statements at all. rg "import Persistence" Packages/GameShellKit/Sources → 0 hits. GameShellKit/Package.swift dependencies: [] unchanged.

B. End-to-end payload wiring — ✅. Traced both apps:

  • Sudoku: SavedGameStore.Field.boardState (CK) → SavedGameMapper.swift (+9 lines, tolerant .string cast, nil on wrong type) → SavedGameSummary.boardState: String? → Live.swift fetchResume calls puzzleProvider.puzzle(for: summary.puzzleId) (wrapped try?) → SudokuBoardPreviewMapper.make(boardState:givenMask:) → ResumeCandidate.boardPreview.
  • MS: Field.stateBlob → MinesweeperSavedGameStore.swift (+9 lines, tolerant .data cast) → MinesweeperSavedGameSummary.stateBlob: Data? → Live.swift fetchResume → MinesweeperBoardPreviewMapper.make(stateBlob:) (JSON-decodes MinesweeperSessionSnapshot, wrapped try? decode) → ResumeCandidate.boardPreview.
  • Deviation verified: PuzzleStore.swift:86 func puzzle(for puzzleId:) parses the puzzleId, derives a seed deterministically (dailySeed/practiceSeed), and calls the local runGenerator — zero CloudKit/CKContainer references anywhere in the file. A failed/absent puzzle lookup yields givenMask: [], which SudokuBoardPreviewMapper's length guard (givenMask.count == columns*rows) turns into nil — degrades the preview only, resume candidate itself is still returned. Matches the PR's claimed deviation exactly.

C. CellMark = .empty/.given/.filled/.marked — ✅ (BoardPreview.swift). MS mapper (MinesweeperBoardPreviewMapper.swift) imports only Foundation, GameShellUI, MinesweeperEngine, MinesweeperGameState — no Sudoku-typed dependency; maps .hidden→.empty / .revealed→.filled / .flagged→.marked independently of the Sudoku mapper. Mirror principle intact.

D. Test suites (throwaway worktree, swift test):

  • GameShellKit: 54/54 ✅ (matches PR claim)
  • GameAppKit: 85/85 ✅ (matches PR claim)
  • PersistenceKit: 81/81 ✅ (matches PR claim)
  • MinesweeperKit (full): 371/371 ✅ (matches PR claim)
  • SudokuKit: full-target run hits the documented pre-existing local segfault (signal 11, swiftpm-testing-helper) regardless of --parallel --num-workers 1 — consistent with prior sessions' known local-only NSWindow-related crash, NOT caused by this PR (diff touches zero files under SudokuUITests/ or SudokuUI/, confirmed via git diff main...HEAD --stat returning empty for those paths). Ran via targeted --filter batches instead:
    • SudokuAppCompositionTests (contains the new SudokuBoardPreviewMapperTests, 7 cases): 65/65 ✅
    • SudokuPersistenceTests: 24/24 ✅
    • SudokuUITests in 4 batches: 172+121+24+2 = 319 tests, 317 passed. 2 failures in BoardLeaveOrPauseStateTests.swift:123,126 ("live startOrResume() lands in the reachable Ready window") — a timing-window assertion (elapsedSeconds → 3 instead of 0) that reproduces only under full parallel load; reran in isolation → clean pass (7/7). File is untouched by this PR's diff. Treated as a pre-existing environment flake, not a new regression.
    • Batched SudokuKit total = 408 vs PR's claimed "438 (full)" — a ~30-test gap I could not fully reconcile against the segfaulting full run (likely parameterized-test fan-out counted differently across batch splits, or a couple of non-@Suite helper files). Not treated as blocking: every suite that actually contains PR-touched code (SudokuAppCompositionTests) is 100% green with an exact count match, and the shortfall lives entirely in files this diff does not touch.
    • No NEW failures introduced by this PR in any package.

E. Diff scope — ✅. git diff main...HEAD --stat: 16 files, +618/-9, exactly matching the PR body's claim. All files are within GameShellKit/GameAppKit/MinesweeperKit/PersistenceKit/SudokuKit sources+tests, docs/superpowers/specs/2026-06-10-resume-seam-design.md (resume-seam design doc, correctly updated), and meetings/2026-08-31_1017-board-preview.impl-notes.md. No surprises.

F. swiftlint --strict on all 14 changed .swift files: 0 violations, 0 serious. No colorSchemeContrast or other banned-pattern hits.

G. PR body: Closes #1017 ✅, Part of #1014 ✅, 🤖 footer present ✅. Issue #1017 (part of #1014, OPEN epic) verified via gh issue view; #1021 (referenced as "thumbnails are #1021's job") verified OPEN and on-topic. One cosmetic note: the body's "design.md §12 error #11" will GitHub-autolink to (unrelated, already-merged) PR #11 — this is prose referring to a design-doc section number (mirrors the issue body's own wording), not a fabricated issue claim; not a blocker.

Forbidden-clause checks from #1017: BoardPreview correctly NOT placed in GameAppKit (confirmed in A); no new CloudKit fetch added (confirmed in B — both mappers only consume already-fetched fields, puzzleProvider.puzzle(for:) is local regen).

Verdict: T6 ACCEPT.

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(shell): add BoardPreview value type + extend resume/daily mappers to stop dropping payload

1 participant