feat(draft): server-generated draft pools with per-queue policy - #42
Open
ChronoFinale wants to merge 1 commit into
Open
feat(draft): server-generated draft pools with per-queue policy#42ChronoFinale wants to merge 1 commit into
ChronoFinale wants to merge 1 commit into
Conversation
Server-side deck+stake draft pool service (consumed by the MultiplayerPvP/Speedrun ban-pick flow) plus an admin-tunable weekly cocktail. Opt-in per queue.
- POST /api/matches/:matchId/draft-pool: idempotent, server-generated pool of {deck,stake} tuples per queue policy.
- Generator: Botlatro TupleBans port reworked as Efraimidis-Spirakis weighted sampling (per-deck/per-stake weights as a live knob) with stake-minimum guarantees; bounded retry so a greedy dead-end never surfaces at runtime, and validateDraftPolicies() checks every seed policy at boot.
- Weekly cocktail: admin-set via PUT /admin/weekly-cocktail, persisted (weekly_cocktail table, decks text[]), defaults to in-code SEED when unset and degrades to SEED rather than crashing boot.
- Typed errors (ValidationError/NotFoundError/ForbiddenError) on the shared AppError. Self-describing pool items (cocktail tuple carries its decks+name).
ChronoFinale
marked this pull request as ready for review
July 22, 2026 18:15
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.
Server-generated draft pools + weekly cocktail
Adds a server-side deck+stake draft pool service (consumed by the MultiplayerPvP / Speedrun ban-pick flow) plus an admin-tunable weekly cocktail. Opt-in per queue — a mod that never calls the endpoints keeps its fully client-side draft.
What's here
POST /api/matches/:matchId/draft-pool— idempotent, server-generated pool of{deck, stake}tuples for a match, per-queue policy.generate-draft-pool.ts) — a port of Botlatro's TupleBans reworked as Efraimidis–Spirakis weighted sampling (per-deck/per-stake weights are a live tuning knob) with stake-minimum guarantees. Bounded retry so a greedy dead-end can never surface as a runtime error, andvalidateDraftPolicies()runs every seed policy at boot so a misconfigured policy fails at startup, never per-request.PUT /admin/weekly-cocktail, persisted in aweekly_cocktailtable (decks astext[]), defaults to an in-code SEED when unset, and degrades to SEED rather than crashing boot if the table is missing.ValidationError/NotFoundError/ForbiddenErroron the sharedAppError.decks+name), so one pool fetch covers everything.Tests
tsc --noEmitclean;drizzle-kit generatereports no schema changes.Notes for review
0017migration's snapshot is hand-chained to0003because the repo's drizzle meta is missing0004–0016snapshots (pre-existing, repo-wide) —drizzle-kit generatecan't diff against a missing baseline. Flagging as a separate repo-health item, not introduced here.Related
Client / rendering side: BalatroMultiplayerAPI#16 — the ban-pick draft UI +
fetch_draft_poolseam that consumes these server-generated pools.PvP consumer: feat(draft): server-issued draft pools + weekly cocktail (matchmaking) BalatroMultiplayer#501 — the mod-side that fetches these pools + renders the cocktail.
Related: addresses BalatroMultiplayerAPI#13 (weighted tuple-pool policy per gamemode — the server's per-queue weighted sampling implements it).