Battles and votes
Clients vote with the comparisonId the API returned
Clients vote with the comparisonId the API returned
dualchat generates the comparisonId and stores the comparison under it. Any ID the client made up before the call is ignored. The arena stores resp.comparisonId on the turn and votes with it.One vote per user per comparison
One vote per user per comparison
ModelStatsService.RecordVoteByChoiceAsync relies on a unique constraint on model_votes (comparison_id, user_id). Keep it in every environment.A vote reveals the comparison
A vote reveals the comparison
comparisons.is_revealed = true and stamps model_votes.revealed_at. v_comparisons_masked relies on is_revealed.left is model1, right is model2
left is model1, right is model2
left maps to model1_id and right to model2_id, matching agent1 and agent2 in the response. tie and both-bad store a null winner.Models
model_name is the identity used everywhere
model_name is the identity used everywhere
ComparisonLogger refer to models by model_name. When ComparisonLogger meets a name it doesn’t know, it creates an active ai_models row for it. Use exact provider model IDs, and fix stray rows from the admin panel.Only active models with a supported provider play
Only active models with a supported provider play
ModelSelector loads status = active rows and drops providers other than groq, google and cloudflare. v_leaderboard also filters to active models, so deactivating a model hides it from the leaderboard without deleting its history.Random battles need two auto-selectable models
Random battles need two auto-selectable models
selectionMode: random fails with an error.The leaderboard needs a model_leaderboard row
The leaderboard needs a model_leaderboard row
v_leaderboard joins model_leaderboard. A model without a row there plays but never appears on the leaderboard. Seed a row when you add models.Users and access
public.users.role is the only source of roles
public.users.role is the only source of roles
RoleClaimsTransformation reads it on every authenticated request; AdminOnly requires admin. Don’t add roles to tokens or to client config.Sync never downgrades a role
Sync never downgrades a role
UserSyncService upserts public.users before writes tied to a user and keeps the existing role. New rows get user.Admin PUT writes every field
Admin PUT writes every field
PUT handlers serialize the whole DTO, so a missing field is stored as null. Clients send full records; the PATCH routes change one field.Runtime
One container instance
One container instance
default container. Running more instances needs that state moved to shared storage first.Message positions follow the current maximum
Message positions follow the current maximum
ThreadMessagesService reads the highest existing position in a thread and writes the next one, so deleting the last message lets its number be reused. Messages are returned in position order.Wire formats
Wire formats
nulls omitted; admin routes are snake_case (they mirror the database). Timestamps are UTC ISO 8601. GET /api/arena/model-stats returns both camelCase and snake_case names on purpose; don’t remove either without checking the arena, the admin panel and the bot.