Skip to content

Casino game kind, credits host functions, CtxFeatCredits (wire revision 7)#69

Merged
BCook98 merged 2 commits into
mainfrom
add-credits-abi
Jul 3, 2026
Merged

Casino game kind, credits host functions, CtxFeatCredits (wire revision 7)#69
BCook98 merged 2 commits into
mainfrom
add-credits-abi

Conversation

@BCook98

@BCook98 BCook98 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What

The wagering surface for casino games, as one additive minor (wire revision 6 → 7):

  • GameMeta.Kind (game | casino) + MaxPayoutMultiplier — a new presence-guarded trailing meta section. Absent ⇒ game, so every existing artifact keeps its meaning; a casino game must declare a payout ceiling ≥ 1 that covers its largest configurable outcome (wire.ValidateGameKind, enforced at SDK encode time and refused at host load).
  • Three host functionscredits_balance, credits_wager, credits_settle: a host-owned account-wide wallet. Wagers escrow atomically (a refused wager means the bet did not happen); settlement is gross (loss 0 · push = stake · win = stake + winnings) and clamped to stake × the declared multiplier; feature rounds (free spins, double-up ladders) ride the triggering stake and settle once. Typed refusals: insufficient, economy-disabled (degrade, never trap), denied, unavailable. Game-kind callers are rejected host-side before any service call.
  • CtxFeatCredits (bit 2) — declaration-only bit marking an artifact that wagers.
  • Go SDK: Services.Credits (+ kit.ErrInsufficientCredits etc.), kittest wallet double (Credits/CreditsStakes/CreditsDisabled), native dev-runner and memsvc backends (so go run ., check, and play all work today).
  • Rust SDK: Meta::kind / max_payout_multiplier, Room::credits_*, CreditsError, CTX_FEAT_CREDITS — wire revision bumped in lockstep, cross-language scalar goldens regenerated, hardcoded meta hexes updated.
  • Docs: ABI.md §3 (host functions + status codes) and §4.2 (game-kind section), GUIDE.md casino authoring section.

Testing

  • go test ./... green (incl. new wire.ValidateGameKind/round-trip/truncation vectors, gameabi kind-gating + status-code mapping tests, regenerated scalars.txt)
  • cargo test green in rust/ and crossverify/ (revision crosscheck passes; byte-identity goldens updated from the Go reference encoder)
  • End-relative truncation offsets across all older-form decode tests grown by the new 5-byte section

Notes for review

  • The multiplier ceiling is a per-hand clamp; the platform applies its own ceiling and economic caps on top — this repo only carries the contract.
  • CtxFeatCredits is intentionally declaration-only: graceful degradation against hosts lacking the imports is impossible (instantiation fails before detection), so hosts at this revision always export the functions and signal economy state via the disabled status code.

🤖 Generated with Claude Code

BCook98 and others added 2 commits July 2, 2026 23:11
…revision 7)

Adds the platform-credits wagering surface for casino games:

- GameMeta.Kind (game | casino) + MaxPayoutMultiplier as a new
  presence-guarded trailing meta section — absent reads as game, so every
  existing artifact keeps its meaning
- credits_balance / credits_wager / credits_settle host functions:
  host-owned account-wide wallet, atomic escrow wagers, gross
  (stake-inclusive) settlement clamped to stake x the declared multiplier,
  typed refusals incl. economy-disabled (degrade, never trap); game-kind
  callers rejected host-side before any service call
- CtxFeatCredits declaration bit; wire revision 6 -> 7 with ledger entry
- Go SDK Services.Credits + kittest wallet double + native dev-runner and
  memsvc backends; Rust SDK mirrors (Meta fields, Room methods,
  CreditsError, CTX_FEAT_CREDITS) with regenerated cross-language goldens
- ABI.md section 3/4.2 + GUIDE.md casino authoring section

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review finding: the Settle double claimed production escrow semantics but
omitted the MaxPayoutMultiplier clamp memsvc and the real host apply. Set
Room.CreditsMaxPayoutMultiplier to your Meta declaration and unit tests
exercise the same ceiling check/production enforce; 0 keeps the old
unclamped behavior.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BCook98
BCook98 marked this pull request as ready for review July 3, 2026 01:33
@BCook98
BCook98 merged commit 384476e into main Jul 3, 2026
6 checks passed
@BCook98
BCook98 deleted the add-credits-abi branch July 3, 2026 01:33
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