synvael/docs/adr/0004-server-authoritative-simulation.md

24 lines
1.7 KiB
Markdown

# 0004. Server-authoritative simulation
- **Status:** Accepted
- **Date:** 2026-06-27
## Context
The game supports single-player and multiplayer through one dedicated `server` crate; single-player runs that same server logic rather than a separate offline path. A networked simulation must decide where authority lives and how much determinism the simulation is held to.
One option is full simulation determinism (lockstep, rollback, or replay-from-inputs), which permits clients to advance the simulation in agreement and exchange only inputs. It is powerful but imposes a heavy, ongoing cost: every float, every hash-map iteration, and all platform-specific math must be made cross-platform reproducible.
## Decision
The simulation is **server-authoritative**. The server computes the truth; clients send inputs and receive state snapshots, predicting locally for responsiveness and reconciling on disagreement. Combat, physics, mob AI, and item drops are computed once, on the server.
**Full simulation determinism (lockstep / rollback / replay-from-inputs) is an explicit non-goal.** Outside of worldgen (see [ADR-0003](0003-seed-deterministic-worldgen.md)), floats, hash-map iteration order, and platform-specific math are all permitted.
## Consequences
- The engine does not pay the cost of cross-platform float reproducibility for the simulation, only worldgen carries that burden.
- Clients require prediction and reconciliation logic to stay responsive against an authoritative server.
- Cheat resistance follows from authority residing on the server.
- Features that would require deterministic replay of the full simulation are out of scope by this decision; reopening them would mean revisiting the determinism cost deliberately avoided here.