Game Design/World & Simulation
Turn Processing Submodules
Last updated 2026-08-21
Source files
Historical index. For the current registry, ordering, lock recovery, phase counts, and telemetry contract, use The Turn Processor (as shipped).
The live turn is driven by processTurn() in and entered through authenticated GET /api/cron/turn. It runs adapters from ; each adapter calls individually named phases through the runtime wrapper in .
Stable invariants#
- Adapter order is load-bearing. Move a phase only after identifying every read-after-write dependency.
- Election resolution is strictly ordered: primary resolution, vote accumulation, spend reset, timer advancement, snapshots, general resolution, and office handoff cannot be freely parallelized.
- Fiscal-year processing uses each country's configured boundary, which is turn 40 for the current country configs.
- A phase failure is isolated and recorded. An error outside a phase can abort the turn.
- The processing lock, heartbeat, timeout, crash recovery, and final
turnLogare part of the correctness contract. - The cron route is
GET, protected byAuthorization: Bearer <CRON_SECRET>.
Where code lives#
| Concern | Location |
|---|---|
| Orchestrator | |
| Adapter registry | |
| Phase runtime and telemetry | |
| Large state-effects adapter | |
| Domain implementations | src/lib/turn/ and the owning domain modules |
| Per-country election phase list | |
| HTTP entry |
Counts and exact membership change frequently. Do not copy a numbered phase list from an older design document into new code or operational runbooks; inspect the registry or the as-shipped page instead.