---
description: Enforce pure server authority — clients send intents only; server owns all gameplay state and outcomes.
alwaysApply: true
---

# Pure server authority

Gameplay is **server-authoritative**. Clients send **intents** only; the server validates, mutates state, and replicates outcomes. Never violate this.

## Allowed on the client

- Send commands (`moveTo`, `attack`, `pickupItem`, craft cancel, `respawn`, …)
- Render snapshots / replication (positions, inventory, combat FX, death UI)
- Local presentation only (zoom, lerp, tooltips, editor overlays)
- Shared pure helpers for **UI preview** (e.g. recipe fit) — never as the source of truth

## Forbidden on the client

- Deciding hits, damage, XP, inventory results, craft success, spawns, death, or final positions
- Trusting client-supplied outcomes (damage numbers, “I hit”, stack merges applied locally as fact)
- Predicting authoritative world mutations without a matching server apply path

```text
# ❌ BAD — client applies combat / bag results
onClickAttack(target) { target.hp -= 5; inventory.push(loot); }

# ✅ GOOD — intent in; wait for server replication
socket.send({ type: MessageType.attack, targetEntityId });
// apply combatHit / inventory messages from the server
```

## Server / shared

- Simulation, combat rolls, pathfinding, spawners, banking, death/respawn live on the server
- `shared/` helpers may be imported by both sides for rules/display; **only the server applies them to live state**
- World editor saves are admin-authored map data, not a player-authority exception for play

When unsure: if a cheater changing the client could gain an advantage, the logic belongs on the server.
