docs(guide): document ScoreKeeper and PersistWallet#52
Merged
Conversation
GUIDE.md never mentioned ScoreKeeper/PersistWallet (kit.go ~93-99, internal/game/scorekeeper.go), so authors were steered into the manual r.Post + KV-clobber footgun these abstractions exist to eliminate. Add a "Bank scores the easy way: ScoreKeeper" subsection under Scores and leaderboards covering: what it does, when to use it (esp. continuous / never-ending games), an idiomatic example, cadence semantics (OnImprove/OnChange), the live/FlushLeave/FlushAll post points, PersistBest/PersistWallet, and an explicit prefer-this-over-manual-r.Post note. Docs only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
BCook98
marked this pull request as ready for review
June 17, 2026 02:21
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.
Problem
The flagship leaderboard/wallet abstractions
ScoreKeeperandPersistWallet/PersistBest(kit.go~93-99,internal/game/scorekeeper.go)had zero mentions in
GUIDE.md. Game authors were therefore steered intothe manual
r.Post+ KV-clobber footgun these helpers were built to eliminate:forgetting to re-post on disconnect, never posting an abandoned-but-ticking
continuous world, and racing KV writes that clobber durable wallets at merge
time.
Fix
Add a "Bank scores the easy way:
ScoreKeeper" subsection underScores and leaderboards in
GUIDE.mddocumenting:ScoreKeeperdoes and the one-keeper-on-the-room idiom (with example);LifecycleResident) games viaFlushAllfromOnWake;OnImprovevsOnChange, and the always-post-first-sighting rule;Record(alwaysStatusFinished),FlushLeave(DNF, no-op when untracked, lower-is-better caveat),FlushAll(deterministic AccountID order, timer-free / replay-safe);PersistBest(MergeMax) andPersistWallet(MergeSum + MergeMax) for resume KV, with a note that these feed KV only, not the board;r.Post+ KV writes callout.Docs only — no code changes.
Verification
go build ./...— passgo vet ./...— passgo test . -run ScoreKeeper -v— all 6 ScoreKeeper tests passEvery documented claim (cadence behaviour, statuses, no-op, merge rules,
deterministic order, timer-free design) was checked against
internal/game/scorekeeper.goandscorekeeper_test.go. Intra-doc anchorlinks (
#scores-and-leaderboards,#choosing-a-lifecycle,#durable-state-the-per-player-kv) verified against the actual headers.No changeset added: this is docs-only with no module-surface change, so it
should not drive a version bump / release.
For reviewers
Confirm the API descriptions match the source and that the
prefer-ScoreKeeper framing reads right alongside the existing manual
Post/Endguidance.🤖 Generated with Claude Code