Repository navigation
refactor(gamecenter): drop SudokuEngine.Difficulty from the shared protocol - #953
Merged
Merged
Conversation
…otocol (#947) `GameCenterClient.submitScore(puzzleId:elapsedSeconds:difficulty:leaderboardKind:)` forced every conformer (Minesweeper, any future game) through Sudoku's `Difficulty` enum via `public import SudokuEngine`, even though both conformers (`LiveGameCenterClient`, `FakeGameCenterClient`) already discarded the parameter — the caller (`GameCenterSink`) resolves `Difficulty -> LeaderboardKind` before crossing the protocol boundary. Drop the dead parameter and the `public import SudokuEngine` it required; `LeaderboardIDs` / `GameCenterIdentifiers` (the actual id strings) are untouched, so no leaderboard ID changes. Co-Authored-By: Claude Fable 5 <[email protected]>
CR round 1 on PR #953: both DEBUG near-win noop `GameCenterClient` conformers still declared the removed `difficulty:` parameter, so they no longer satisfied the protocol. macOS `swift build` / `swift test` cannot catch this — both actors live inside `#if os(iOS)`, so the host-platform build never compiles them. Reproduced and verified with `xcodebuild -scheme SudokuUI -destination 'generic/platform=iOS Simulator'`: BUILD FAILED with "does not conform to protocol 'GameCenterClient'" on both types before this change, BUILD SUCCEEDED after. Co-Authored-By: Claude <[email protected]>
CR round 1 on PR #953: the protocol-level leak is gone, but `AchievementEvaluator` in the same package still carries `public import SudokuEngine` with `evaluateForCompletion(…difficulty:…)`, so GameCenterKit still re-exports the type at module level. That is a packaging problem (the evaluator is effectively Sudoku-specific and also coupled to the Sudoku-typed Persistence surface), not a conformer constraint — filed as #955. Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #947
What
GameCenterClient.submitScore(puzzleId:elapsedSeconds:difficulty:leaderboardKind:)required aSudokuEngine.Difficultyargument and the protocol file didpublic import SudokuEngine, forcing every conformer — Minesweeper's, any future game's — through Sudoku's enum and re-exporting SudokuEngine visibility downstream (SE-0409).Survey found the
difficultyparameter was already dead at the protocol boundary:GameCenterSink.submitScoreIfEligibleresolvesDifficulty -> LeaderboardKinditself before callingclient.submitScore(...), and both conformers (LiveGameCenterClient,FakeGameCenterClient) discarded the parameter entirely (_ = (puzzleId, difficulty)inLiveGameCenterClient, dropped from the recorded operation inFakeGameCenterClient). So the smallest fix is simply removing the unused parameter — no pre-resolved-ID orLeaderboardSlottype was needed.How
difficulty: Difficultyfrom theGameCenterClient.submitScore(puzzleId:elapsedSeconds:difficulty:leaderboardKind:)requirement.public import SudokuEnginefromGameCenterClient.swift,LiveGameCenterClient.swift, andFakeGameCenterClient.swift(now fully unused there).GameCenterSink.swiftand every conformer/fake:LiveGameCenterClient,FakeGameCenterClient,UITestSignedOutGameCenterClient(GameAppKit), plus test fakes inGameRootViewModelLeaveTests,GameRootViewModelTests,TerminalPersistJoinTests, and the assertions inLiveGameCenterClientSubmitTests.LeaderboardIDs.swift/SudokuEngine/GameCenterIdentifiers.swift(the actual id-string source of truth) are untouched — out of scope, and touching them would risk the production leaderboard IDs.AchievementEvaluator.swift's separatepublic import SudokuEngineis untouched — it's a different public type, not theGameCenterClientprotocol the issue names, and redesigning it is out of scope (issue explicitly warns against redesigning the whole GC surface).Leaderboard-ID equivalence (production safety)
No code that computes leaderboard ID strings changed. Evidence — every
(difficulty, kind) -> idpair, asserted by tests unmodified in their assertions (only the now-removeddifficulty:argument was dropped from call sites) and green on this branch:.easy.dailyEasycom.wei18.sudoku.leaderboard.easy.daily.v1SubmitScoreTests.leaderboardIDSuffixedV1,LiveGameCenterClientSubmitTests.elapsedSecondsConvertsToCentiseconds,SudokuLeaderboardRoutingTests.dailyEasyMapsToEasyLeaderboard.medium.dailyMediumcom.wei18.sudoku.leaderboard.medium.daily.v1SubmitScoreTests.leaderboardIDSuffixedV1,LiveGameCenterClientSubmitTests.zeroElapsedSecondsConvertsToZero,SudokuLeaderboardRoutingTests.dailyMediumMapsToMediumLeaderboard.hard.dailyHardcom.wei18.sudoku.leaderboard.hard.daily.v1SubmitScoreTests.leaderboardIDSuffixedV1,LiveGameCenterClientSubmitTests.twoHourCapMatchesDesignRange,SudokuLeaderboardRoutingTests.dailyHardMapsToHardLeaderboardMinesweeper's
MinesweeperLeaderboardID(easy/medium/hardsegments,.v1suffix,com.wei18.minesweeper.leaderboard.*) is untouched — it never went through thedifficulty-typed overload; MS always called the rawsubmitScore(leaderboardId:elapsedSeconds:)path.All three suites above ran green on this branch (post-refactor); since
LeaderboardIDs.swift/GameCenterIdentifiers.swifthave zero diff, the same assertions hold byte-identically againstmain.Verification
Deviations from the issue's proposed direction
The issue proposed a pre-resolved leaderboard-ID
Stringor aLeaderboardSlot/LeaderboardTargettype. That wasn't needed: thedifficultyparameter was provably dead at the protocol boundary (both real conformers discarded it, and the caller already resolves the mapping before callingsubmitScore), so removing it was the smallest fix that satisfies the issue's goal (noSudokuEngineleak, no live ID change) without adding a new type.🤖 Generated with Claude Code