Files
Wizard/wizard_server
marvinandClaude Opus 5.5 763c5678f1 Don't trip the AI circuit breaker on load shedding
With many simultaneous games, AI turns start in bursts and exceed the
in-flight cap. That was counted as an AI failure, so after 5 bursts the
breaker paused the AI for 30 s and every AI seat played random moves.

- Only real failures (timeouts, lost connection, malformed/illegal
  answers, unexpected errors) count towards the breaker; the in-flight
  cap and "overloaded"/"expired" answers from the AI service do not
- AI_MAX_INFLIGHT default 32 -> 64 (>= MAX_ACTIVE_GAMES, matches the AI
  service's AI_MAX_QUEUE)
- Test that load shedding keeps the breaker closed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 13:04:21 +02:00
..
2026-09-27 09:52:00 +02:00
2026-09-27 09:52:00 +02:00
2026-09-27 09:52:00 +02:00
2026-09-27 09:52:00 +02:00
2026-09-27 09:52:00 +02:00

wizard_server

FastAPI game server. It manages sessions, lobbies and games, and talks to the AI service.

  • game_logic/ — the standalone rules engine (pip install ./game_logic, see its README).
  • app/main.py — routes: GET /health, WS /ws (browsers), WS /internal/ai (AI service, refused when the request came through the reverse proxy)
  • app/protocol.py — client message schema
  • app/service.py — dispatches client messages, reconnects sessions, cleanup
  • app/lobby.py — lobbies, seats, host actions, running games and AI turns
  • app/ai_bridge.py — request/response protocol with the AI service, random-move fallback
  • app/sessions.py — sessions (token based, survive reloads) and ordered websocket sending

Configuration (environment): AI_SHARED_SECRET, AI_DECISION_TIMEOUT (5s), AI_MOVE_DELAY (0.8s), TRICK_PAUSE (1.8s), SESSION_TTL (1800s), MAX_LOBBIES (1000), ALLOWED_ORIGINS, LOG_LEVEL.

pip install -r requirements-dev.txt
uvicorn app.main:app --reload
pytest