Skip to content

Current architecture ​

Latest review, 2026-10-30: CHANGES REQUIRED. Schedule claims now precede dispatch and entry points use Govern; run-row and descriptor failures block dispatch. Reproduced gaps remain in function ACLs, risk lookup, expired claims across slots, and partially persisted terminal events. Drain/shutdown normal paths exist, but accepted-task and overall deadline guarantees remain incomplete. See the latest review. High-risk production writes are not approved.

Croupier is a game operations control plane for one company with multiple games and environments. The implementation combines a modular Server, outbound Agents with distinct roles, and game SDKs, plus a separate analytics pipeline. This overview follows source wiring reviewed on 2026-10-30; design goals are not implied runtime guarantees.

System diagram ​

Arrows identify the labeled flow or connection initiator. Agents dial the Server and SDKs dial the sidecar; established sessions carry requests and results in both directions. Dashed edges are optional connections, including cluster coordination. L7/L4 proxies are deployment options; a single instance may be reached directly.

Croupier current architecture: console, Server, four Agent roles, SDKs, shared state and separate analytics pipeline
Source review: 2026-10-30 · Open the full SVG

Processes and responsibilities ​

ComponentCurrent responsibilityBoundary
Web consoleReact/Umi/Ant Design, resources, Page Studio and operator actionsHTTP API/SSE; no direct Agent sessions
ServerGin API, identity, scope, policy, approvals, audit, contracts, pages, registry/dispatch and OpsOne modular deployment unit
sidecar-agentSDK provider sessions, game function dispatch, tasks and managed process/plugin wiringBuilt as croupier-agent; some wiring remains in internal/app/agent
capture-agentDatabase change capture, checkpoints, filtering and rulesSeparate from SDK function routing
synthetics-agentRole-specific probes, results and probe pluginsRole-specific application lifecycle
devops-agentRegistration, allowlist sync, Broker/Hub session foundationsConsole-to-Agent relay is incomplete; RDP/VNC unavailable
ingest / analytics-workerEvent publishing, consumption and ClickHouse aggregationBuilt-in worker consumes Redis Streams; Kafka publishing alone is not an end-to-end pipeline

Execution and publication ​

  1. HTTP authentication and scope middleware resolve and authorize gameId + env.
  2. Console execution checks the selected PageSpec snapshot and binding. Function calls converge in internal/platform/functioninvoke.
  3. Disabled/assignment gates, policy, approval and input-contract checks run before dispatch as applicable.
  4. Dispatch selects a scoped Agent, using its local session or forwarding to the Server instance that owns that session.
  5. The sidecar invokes the game SDK over its provider session. task_runs/task_events persist asynchronous progress for queries and SSE.
  6. Audit is recorded according to the relevant path and policy. Execution logs are a separate mechanism, not an audit transaction guarantee.

Publication follows registration/OpenAPI → FunctionContract → resource semantics → proposal/draft → validation and publication → Console binding execution. The Console uses published snapshots; Page Studio also has a controlled draft execution path. Database-backed page idempotency does not make all external side effects exactly-once.

State and availability ​

StateCurrent locationImplication
Live Agent/SDK connectionsOwning process memoryAccess through owner forwarding, not shared net.Conn
RegistryLocal registry and database agent_sessions snapshotsDiscovery snapshots do not replace live sessions
Membership and owner leasesShared relational database or configured RedisOne-hop forwarding and epoch fencing
Business data, pages, tasks and page idempotencyRelational database; some game models support dbctx routingVerify scope behavior for each model
Task routingLocal cache/file with task_runs lookup fallbackCross-instance cancellation has a database fallback
Function approvalsApprovalsStore backed by SQLStoreApproval state survives restarts and is shared across instances
AuditSQLAuditStore and AuditServiceHash-chain validation; no signer wired by default
AnalyticsRedis Streams → worker → ClickHouseSeparate from the control database

HA routing exists, but not every business module has shared state. Some cluster initialization failures fall back to standalone; healthz does not fully represent cluster readiness.

Transport and trust ​

  • Server HTTP: 18780 by default; HTTPS commonly terminates at the reverse proxy.
  • Agents dial Server control on 19090. SDKs dial the sidecar provider on 19091. Ports are configurable.
  • Custom TCP sessions use length-prefixed framing and protobuf platform messages; function payloads are typically UTF-8 JSON.
  • core/transport/tcp owns MuxConn. Roles explicitly compose registration, reconnect and configuration packages.
  • Agent-to-Server TLS is supported but disabled in repository development templates: Server cert/key are empty and Agent insecure=true. Configure certificates explicitly for production.
  • Server interconnect supports mTLS via cluster.interconnectTls (peer-certificate identity: dual EKU server role, Agent certs rejected; unhandshaked forward rejected). When the cluster is enabled but the certificate surface is unset and TLS verification is skipped, startup fails closed unless cluster.allowPlaintextInterconnect: true explicitly confirms a trusted isolated network.

Scope and databases ​

The authorization scope is gameId + env. Targets, Agents and nodes describe execution placement. Each Agent instance declares one scope.

Single-database mode still validates scope. multiGame separates metadata from selected game models through dbctx. Binding validation and physical database-name calculation currently follow separate paths: verify mappings before changing prefixes or migrating legacy database names. A logical environment does not automatically imply dedicated hardware, a cluster or a database.

Source map ​

ConcernRepository paths
Bootstrapcmd/server/root.go, cmd/server/cluster.go, internal/svc/service_context.go
API and scopeinternal/handler/routes.go, internal/svc/game_middleware.go
Executioninternal/platform/functioninvoke, internal/platform/dispatch
Registry and clusteringinternal/platform/registry, internal/cluster
Pagesinternal/dashboard, internal/api/page, internal/api/console
Governanceinternal/platform/approvals, internal/audit
Storageinternal/db/router, internal/db/dbctx
Agentsagents, core, internal/app/agent, cmd/*-agent
Analyticscmd/ingest, cmd/analytics-worker, internal/analytics
Simulated integratorsdks/go/cmd/demo-game (design: ../design/demo-game)

Reading path ​

Runtime evidence and lifecycles ​

Process inventory, connection matrix, lifecycle SVGs, deployment failures and official-reference checks. Diagrams show current wiring; approval persistence is wired (SQLStore with CAS, 9066d7c10); interconnect mTLS, Provider draining and reliable task replay remain follow-up work.