feat: credits_buyback host function (wire revision 8)#71
Merged
Conversation
Casino-kind games can now offer a broke player a mid-session rebuy without leaving the game. `Credits.Buyback(p) (int64, error)` returns the new balance (symmetric to Balance); the host owns the gate (broke-only floor + a per-day rebuy limit) and makes the credited amount wagerable in the current seat. A refusal (solvent, or the daily limit reached) is CreditsErrInsufficient with the balance unchanged. Additive minor: existing games are unaffected; the meta payload is unchanged (only a new host function the guest may import). Wire Revision 7 -> 8. - wire: FnCreditsBuyback, Revision 8 + ledger entry; rust WIRE_REVISION 8; scalar + hardcoded rust meta goldens regenerated for the revision byte. - guest SDK: Credits.Buyback (Go internal/game api/host/room + dev runner; rust host extern/wrapper/test-host). - host: sdk.CreditsService.Buyback + gameabi credits_buyback dispatch (routes through creditsCall, inheriting the casino-kind guard / roster bounds / timeout); memsvc + kittest doubles + fakeCredits stub. - ABI.md §3: credits_buyback row + buyback semantics; revision-8 note. - memsvc test: solvent-refused / mid-hand-not-broke / broke-tops-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W7oJQSTva5xgbAZomdV5Jj
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.
What
Adds a
credits_buybackhost function so casino-kind games can offer a broke player a mid-session rebuy without leaving the game. Guest surface:The host owns the policy — it applies the rebuy only when the player is broke (balance below a platform floor, open stake excluded) and under a per-day rebuy limit, credits the platform's buyback amount to the account and makes it wagerable in the current seat. A refusal (solvent, or the daily limit reached) is
CreditsErrInsufficient(-1) with the balance unchanged.Why
Casino games (blackjack, pokies, scratchies, roulette) need an in-game rebuy when a player busts. The existing credits ABI (
balance/wager/settle) has no path to trigger the platform's broke-relief buyback from inside a game — this adds it.Shape
Additive minor (wire Revision 7 → 8, ABI major stays 2). The meta payload is unchanged — this is only a new host function the guest may import, so existing games are unaffected.
wire:FnCreditsBuyback,Revision = 8+ ledger entry; rustWIRE_REVISION = 8; scalar golden + the hardcoded rust meta goldens regenerated for the revision byte.Credits.Buyback(Gointernal/gameapi/host/room + dev runner; rust host extern + wrapper + test-host).sdk.CreditsService.Buyback+gameabicredits_buybackdispatch routed throughcreditsCall(inherits the casino-kind guard, roster bounds, and store timeout);memsvc+kittestdoubles +fakeCreditsstub.ABI.md§3:credits_buybackrow + buyback semantics + revision-8 note.kitminor.Tests
go build/vet/test ./...green;cargo test --libgreen (57 tests).memsvcTestCreditsBuyback: solvent → refused (balance unchanged), mid-hand (stake open) → not broke, broke → tops up to the amount and returns the new balance.Downstream: shellcade pins v2.16.0 and implements
CasinoWallet.Buyback(ledger buyback + reservation top-up + daily-limit-100 + rebuy-count tracking); the 4 casino games pin v2.16.0 and wire in-game rebuy.🤖 Generated with Claude Code