2. Wire protocol (JSON and binary snapshots over WebSocket)
Client-to-server messages and reliable server-to-client messages are JSON objects with a t field
(the discriminator/tag). Live snapshot messages are MessagePack compact binary snapshot frames over
the same WebSocket. Field names are short but readable. Coordinates are world pixels (floats)
unless a field name ends in Tile. The canonical Rust definitions live in
server/crates/protocol/src/lib.rs; the server-shell server/src/protocol.rs is an adapter for
typed entity-kind conversion and legacy imports. Protocol constants, compact code tables, and the
structured contract dump are factored into server/crates/protocol/src/contract_metadata.rs; the
compact snapshot serializer is factored into server/crates/protocol/src/compact_snapshot.rs; both
are re-exported through lib.rs. The browser mirror lives in client/src/protocol.js (builders +
decode entry points), with constants in client/src/protocol_constants.js, frame transport
internals in client/src/protocol_frame.js, and compact snapshot decoding in
client/src/protocol_snapshot.js. Rust and JS MUST agree on every tag, field name, and compact
transport shape.
This is a pre-alpha, latest-version-only protocol. It may change incompatibly with older clients, servers, and replay artifacts; keep the current Rust and JS mirrors synchronized instead of carrying compatibility shims for old builds by default.
rts-protocol may depend on rts-contract but must not depend on rts-sim, rts-rules,
rts-ai, or rts-server. Domain kind conversion that needs EntityKind belongs in an adapter
layer such as server/src/protocol.rs or server/crates/sim/src/protocol.rs, not in the wire DTO
crate.
Client build compatibility is checked using buildId on reliable welcome/pong messages and
no-store HTTP /version checks. The document’s rts-client-build stamp identifies the loaded
client; a later HTTP response must not relabel it. Mismatch recovery and the persistent warning
are described in client-ui.md.
Lobby messages carry countdownActive: bool so membership broadcasts during countdown do not
permit a version-triggered reload. A false value also authoritatively signals countdown cancellation.
2.0 Boundary authority and guardrails
server/crates/protocol/src/lib.rs owns the wire DTO vocabulary, with protocol constants, message
tags, compact code tables, compact slot schemas, COMPACT_SNAPSHOT_VERSION,
PREDICTION_PROTOCOL_VERSION, and the unknown compact-code sentinel (255) housed in
server/crates/protocol/src/contract_metadata.rs and re-exported from lib.rs. MessagePack
frame-writing internals live in
server/crates/protocol/src/messagepack_frame.rs; compact snapshot semantic serialization lives in
server/crates/protocol/src/compact_snapshot.rs; both stay behind the public frame and serializer
helpers re-exported by lib.rs. server/crates/contract/src/lib.rs owns shared semantic DTOs that
the protocol crate re-exports, including start/snapshot contract records and DEFAULT_FACTION_ID.
rts-rules::EntityKind::stable_id() owns entity domain identity strings, while
rts-rules::faction::{AbilityKind, UpgradeKind} own typed gameplay identities and their stable
strings. Because crate direction forbids rts-protocol from depending on rts-rules, protocol
ability/upgrade constants and compact code tables remain an intentional wire mirror. Focused
rules/sim adapter tests require stable-id agreement and a non-unknown compact code for every typed
kind; browser parity separately checks that wire mirror against JavaScript.
client/src/protocol.js is the browser mirror and stable public import surface for protocol
vocabulary, compact decode tables, message builders, and decode helpers. Internal browser constants
and compact-code maps live in client/src/protocol_constants.js, while callers should continue
importing through client/src/protocol.js. Binary frame parsing lives in
client/src/protocol_frame.js; compact snapshot decoding lives in
client/src/protocol_snapshot.js. Future internal browser splits may live under
client/src/protocol_*.js or client/src/protocol/**. Protocol changes must update Rust DTOs or
dumps, the JS mirror, this design file, and focused parity coverage in the same commit. Compact slot
order is append-only unless the compact snapshot version is intentionally bumped and the Rust
serializer, JS decoder, parity fixture, and docs change together.
Run node tests/protocol_parity.mjs after any protocol vocabulary, compact code, compact slot,
start/snapshot/replay DTO, prediction metadata, default faction id, or lobby color palette change.
That check compares the structured Rust protocol contract dump to the JS mirror, rejects duplicate
or sentinel compact codes, decodes representative compact fixtures, and also checks
PLAYER_PALETTE against server/src/lobby/mod.rs. The palette is not a wire-protocol constant,
but the server assigns lobby/start colors and the client keeps a fallback/render mirror, so the
cross-surface guard intentionally lives with the protocol parity smoke test until a structured
lobby/config dump replaces the source scrape.
pointTanks { units, x, y, queued? } is a tank-only command; queued defaults to false. The server validates the unit
list and computes one heading from the eligible tanks’ centroid to the world point. It clears
active/queued orders for immediate issue, or appends a bounded queued heading when queued is true.
Hulls use normal turn speed; following orders wait for alignment. A click at the centroid is a no-op.
It has no research requirement, cost, or cooldown.
2.1 Client → Server (ClientMessage)
t | Fields | Meaning |
|---|---|---|
join | name: string, room?: string, spectator?: bool, replayOk?: bool | Join (or create) a room as an active lobby player or, when spectator is true, as an observer. room defaults to "main". Normal live matches accept spectator: true after match start and attach the connection as a gameplay-read-only live spectator with shared live pause controls; active late joins and countdown joins are rejected. Lobby role switches are observer-only and must happen before match start. Persisted match-history replay rooms start as kind: "replay" staging lobbies; joins there are accepted as spectators only and do not require replayOk. Active replay playback remains listed in the lobby browser with kind: "replay"; its explicit Join replay action sends replayOk: true and attaches the viewer at the room’s current shared tick. Other attempts to enter replay playback without replayOk receive joinReplayPrompt and may retry after confirmation. If the same WebSocket is already in a different room and the new room accepts the join, the connection transfers to the new room and leaves the previous room. |
setPreferredColor | color: string | null | Save the sender’s palette preference in a normal lobby. Only the eight PLAYER_PALETTE hex strings or null are accepted. Spectators may save a preference but do not reserve colors. Active humans with the same preference compete by a server-generated random priority fixed for their connection; retransmitting or changing the preference cannot reroll it. Reserve preferred winners first, then assign remaining humans the first free palette colors in join order, with AIs using the remaining palette order. Lobby and match start share the resolved colors. Countdown, in-game, and post-match replay requests save the preference for the next lobby without recoloring the starting match, running match, or replay. The client also persists preferences locally and resends them after joining. |
setName | name: string | Update the sender’s display name while still in the lobby. The server trims and bounds the value with the same rules as join, broadcasts the updated roster, and ignores the request during countdown or after match start. |
ready | ready: bool | Toggle ready state in the lobby. |
matchLoadReady | countdownId: u32 | Confirm that this client’s renderer and required assets finished warming for the exact active multiplayer countdown. Stale ids, spectators, and requests outside countdown are ignored. |
start | — | Host asks to start the match (only honored from the room host). In a persisted replay staging lobby, host start begins replay playback immediately when at least one spectator is present and deploy drain is not blocking new sessions; ready/team/map/AI checks do not apply. |
setTeamPreset | preset: string | Deprecated compatibility command. The server ignores it; lobby teams are host-managed slots. |
setTeam | id: u32, teamId: u32 | Host assigns an active human or AI lobby seat to team 1..=4 (lobby phase only, host-only). Unknown ids, spectators, team id 0, and team ids outside the supported range are ignored. |
setFaction | factionId: string | Active human players select their own playable lobby faction (lobby phase only). Unknown ids, fixture ids, spectators, countdown, and in-game requests are ignored. The normal client only exposes this during the beta UI rollout. |
addAi | teamId?: u32, aiProfileId?: string | Host adds a computer opponent to the room (lobby phase only, host-only). When teamId is provided it must be in 1..=4; otherwise the server assigns the first empty team slot. Player lobbies support ai_2_3, jeffs_ai_v1_1 (Jeff’s AI), rush_ai, pressure_ai, eco_ai, and jeffs_cult (Jeffs Cult, which always plays Cultivators); omitted, unknown, or internal-only IDs default to jeffs_ai_v1_1. Observer-only internal sessions may also request ai_2_1, jeffs_ai (Jeff’s AI V1.0), and ai_turtle. |
setAiProfile | id: u32, aiProfileId: string | Host selects a supported profile for an existing AI lobby seat (lobby phase only, host-only). Player lobbies support ai_2_3, jeffs_ai_v1_1 (Jeff’s AI), rush_ai, pressure_ai, eco_ai, and jeffs_cult (Jeffs Cult, which always plays Cultivators); unknown AI ids and unsupported or internal-only profile ids are ignored. Observer-only internal sessions may also select ai_2_1, jeffs_ai, and ai_turtle. Any internal profile is replaced with jeffs_ai_v1_1 if a human takes an active seat and again at match start. |
removeAi | id: u32 | Host removes a previously-added AI opponent by id (lobby phase only, host-only). |
setSpectator | spectator: bool, id?: u32 | Switch between active player and spectator role while still in the lobby. When id is omitted, the sender switches their own role. The host may include another connected human player’s id to move that lobby player into or out of spectators; non-host targeted requests, AI ids, and unknown ids are ignored. Ignored after the match starts; switching to active player is ignored if the active seats are full. |
chatSend | channel: "all" or "team", text: string | Send room chat. The server collapses whitespace, drops empty text, caps it at 200 Unicode scalar values, and admits at most five messages per sender in a rolling ten-second window. Lobby and branch-staging chat is always all-chat and ephemeral. Live match all-chat reaches every connected player and spectator; team chat reaches only active human connections on the sender’s authoritative team. Spectators are forced to all-chat. Replay viewers cannot send chat. |
command | clientSeq: u32, cmd: Command | Issue a gameplay command (see below). Ignored unless in-game. clientSeq is a browser-local, per-match, per-connection sequence id for prediction/reconciliation and diagnostics-only command receipts. |
giveUp | — | Give up the active match. The server eliminates that player and sends their score screen. |
pauseGame | — | Pause a live match. Honored only from live recipients with matchControls.pause while the room is unpaused and that active seat or spectator connection has successful pause starts remaining. |
unpauseGame | — | Resume a paused live match. Honored from any live recipient with matchControls.pause while the room is paused. |
returnToLobby | — | Leave replay playback for this connection only. Other viewers stay in the replay; the room resets to a clean lobby only after the last viewer leaves. Ignored outside replay playback. |
ping | ts: number | Latency probe; server replies with pong. |
netReport | report: ClientNetReport | Periodic client-observed network/render health aggregate. Server logs notable reports for diagnostics only; it never affects simulation state. |
activity | — | Throttled notice that the connected browser received human pointer, keyboard, wheel, or foregrounding input. It extends the server’s player-inactivity deadline but does not mutate room state. Automatic heartbeat and diagnostics traffic never sends this message. |
requestGroundDecals | requestId: u32, afterRevision: u32 | Request reliable durable ground marks learned after this recipient-scoped cursor. requestId is nonzero and echoed by the response so clients can reject replies from an earlier seek or vision perspective. Accepted only during an active live/replay simulation and rate-limited to one response per connection per 500 ms. |
setRoomTimeSpeed | speed: f32 | Set the room-controlled time speed where the current room-time capability profile allows speed control. 0 pauses replay playback, speed-only live-game rooms, dev scenario watch rooms, and lab rooms; other accepted speeds are clamped. Ignored in fixed-realtime rooms. |
stepRoomTime | — | Advance room-controlled time by one authoritative simulation tick where the current room clock capability allows stepping. Currently accepted only in paused dev scenario watch rooms and paused lab rooms. |
seekRoomTime | ticksBack: u32 | Rewind room-controlled time by N simulation ticks where the current room clock capability allows relative seek; pass a large value (e.g. 2^31-1) to reset to tick 0. Currently accepted in replay and lab rooms. |
seekRoomTimeTo | tick: u32 | Seek room-controlled time to an absolute simulation tick where the current room clock capability allows absolute seek. Replay rooms clamp to duration, rate-limit accepted seeks, restore the nearest recorded replay keyframe at or before the target tick, and incrementally fast-forward in bounded room-owned slices. They sample full fog-scoped snapshots plus roomTimeState while progressing instead of rebuilding the client or sending every simulated tick. Lab rooms use room-local keyframes and recorded accepted lab operations/issue-as commands, then re-send lab start, roomTimeState, labState, and a fresh snapshot. Replay keyframes are recorded every 1,000 ticks while authoritative replay time advances; Lab keyframes retain their separate 2,000-tick interval. |
setVisionSelection | selection: VisionSelectionRequest | Select replay fog/vision for this viewer only. Ignored outside replay rooms. The server validates the request and applies it to that viewer’s subsequent snapshot projection. |
lab | requestId: u32, op: LabClientOp | Privileged lab request envelope. requestId must be nonzero. Ignored before join; rejected outside lab rooms and from non-operator roles with labResult. Accepted setup mutations and issue-as commands are room-local; setVision changes only the requesting operator’s projection. Accepted lab requests append to the lab operation log with the requesting connection id. |
requestBranchFromTick | — | Request creation of a new practice branch room from this replay room’s current authoritative server tick. Ignored before join; rejected outside replay playback. The server rejects replays with AI seats in the first implementation and returns error. On success, the source replay room broadcasts branchFromTickCreated to all current viewers. |
claimBranchSeat | playerId: u32 | Claim one original replay player seat in a replay branch staging room. Ignored outside branch staging. Rejected with error if the seat is unknown, already claimed, or this occupant already claimed another seat. |
releaseBranchSeat | playerId: u32 | Release one original replay player seat currently claimed by this occupant in branch staging. Ignored outside branch staging or when the occupant does not own that claim. |
startBranch | — | Host asks to launch the staged replay branch. Ignored outside branch staging and from non-hosts. The server requires at least one claimed original seat. Unclaimed players remain in the restored simulation with no command issuer; their units retain automatic combat behavior but receive no player commands. Live promotion is handled by the branch promotion phase. |
selectMap | map: string | Host selects the lobby map by its stable map name. Ignored outside the lobby, from non-hosts, during match countdown, in dev-watch rooms, or in replay staging lobbies. The server broadcasts the selected value as lobby map and the available catalog as maps[]. |
Live player command messages MUST include clientSeq; unsequenced live commands are
protocol-invalid and are not executed. The browser resets allocation to 1 on every start
payload and increments monotonically for every gameplay command sent through the live transport.
0 is reserved/invalid. The sequence range does not wrap within a match; exhausting u32 ends
client command allocation for that match rather than reusing earlier ids. clientSeq belongs to
the transport envelope only and is intentionally absent from replay/simulation command DTOs.
Command (the cmd object) — c is the command discriminator:
c | Fields | Meaning |
|---|---|---|
move | units: u32[], x: f32, y: f32, queued?: bool | Move selected units to a world point. Infantry ignore enemies until they arrive or receive another order; tanks and scout cars keep driving and fire at in-range enemies without chasing. When queued is true, store future movement intent instead of replacing the active order. |
formationMove | units: u32[], points: {x:f32,y:f32}[], attackMove?: bool, queued?: bool | Move selected units into a freehand formation along a world-space polyline. attackMove gives every resolved unit goal attack-move semantics; absent/false preserves ordinary move behavior. The submitted stroke must contain 2–128 finite points; the server clamps points to map bounds and collapses near-duplicate neighbors. Long strokes distribute one rank across the full arc length, while short strokes create parallel ranks. Legal final goals remain authoritative and may shift from the stroke for body standability, uniqueness, terrain, reachability, or known-trench preference. Queued formation moves store one resolved move or attack-move point intent per accepted unit, not the polyline. |
attackMove | units: u32[], x: f32, y: f32, queued?: bool | Move toward a world point while engaging enemies that enter current weapon range. The unit may pause to fire, then resumes the player-issued destination; enemy sightings never replace that path with pursuit movement. Mortar Teams move without acquiring or firing and require explicit mortarFire commands. Artillery treats the order as permission to spend its normal shell cost: it stops for currently team-visible enemy units in its 10-to-35-tile range band, or buildings only when no unit is eligible, sets up, and repeats minimum-radius fire while targets remain. Candidate aim points rank exposed unarmored targets (including support weapons and light cars) first, combat infantry second, and armored units last, then use a lightweight sum of enemy purchase value inside the dispersion circle within that tier; deployed guns prefer targets already inside their current firing field before redeploying. Automatic artillery fire retains ordinary friendly fire, does not coordinate overkill between guns, and resumes the original route after a one-second no-target grace. When queued is true, store future attack-move intent instead of replacing the active order. |
clearObstacleArea | units: u32[], target: u32, queued?: bool | Contextual A-click order for a completed neutral Tank Trap that is either currently team-visible or present in the issuing player’s authoritative remembered-building intel. The client submits only the known trap id; the server resolves the objective center from current or remembered state and rejects never-observed ids. Units attack-move to a standable inspection point near that center, engage ordinary enemies encountered under normal attack-move rules, and dynamically give every currently actionable completed neutral Tank Trap inside the four-tile objective radius priority over ordinary targets. Hidden traps are not targeted until current vision makes them actionable. When queued is true, store the resolved center and objective as one future intent. There is no standalone clear-area hotkey or arbitrary ground form of this command. |
attack | units: u32[], target: u32, tankTrapCluster?: bool, queued?: bool | Direct-target attack. Ordinary combat units keep this target locked, pursue it until reaching their current weapon range band, then stop and fire; Mortar Teams ignore the firing behavior and require explicit mortarFire commands. The order does not switch to a different target while its commanded target remains legal and visible. Explicit attack commands may target an enemy entity, a neutral completed Tank Trap, or an entity owned by the issuing player, allowing deliberate self-attacks on stuck friendly units/buildings. Allied teammates’ entities are not valid self-attack targets, and ordinary automatic attack-move/idle acquisition remains enemy-only. The legacy tankTrapCluster form remains parseable for replay compatibility: when true and target is a visible completed neutral Tank Trap, it captures that trap plus the visible completed traps within four tiles as one atomic direct-attack list. Current clients use clearObstacleArea for contextual Tank Trap A-clicks. When queued is true, store the direct or legacy cluster attack as one future intent instead of replacing the active order. |
repair | units: u32[], target: u32, queued?: bool | Engineers/Serfs repair an owned completed damaged building or a damaged Tank, Scout Car, Rocket Truck, Mortar Team, or AT Gun. All selected eligible workers participate; Shift queues normally. Authoritative target markers use repair (compact stage code 36). |
deconstruct | units: u32[], target: u32, queued?: bool | Send one selected worker to deconstruct a visible completed Tank Trap. Completed Tank Traps are neutral obstacles regardless of who built them. Deconstruction uses half of the Tank Trap build time (75 ticks / 2.5 seconds with current balance), cannot be sped up by multiple workers on the same trap, and refunds the Tank Trap cost to the deconstructing player’s economy. When queued is true, store one future deconstruct intent using the same selected-worker allocation policy as build orders. |
setupAntiTankGuns | units: u32[], x: f32, y: f32, queued?: bool | Manually emplace owned Anti-Tank Guns and Artillery toward the submitted world point. When queued is true, append a future setup intent for owned completed setup-capable support weapons only; the stored facing point is evaluated from the unit’s position when the stage promotes. Immediate setup clears movement/target state and begins after alignment. Mortar Teams and other selected units are ignored. |
tearDownAntiTankGuns | units: u32[] | Pack up owned Anti-Tank Guns and Artillery that are setting_up or deployed, or cancel their staged setup facing while packed. Mortar Teams and other selected units are ignored. |
charge | units: u32[] | Legacy Rifleman Charge activation. Preserved for old clients/replays as a parseable no-op; manual commands do not activate the Novice passive. |
artilleryFire | units: u32[], x: f32, y: f32, radiusTiles: f32, queued?: bool | Unified Artillery Fire command. x/y is the selected center and radiusTiles is the click-click or press-drag-release radius. The server clamps it to 6–15 tiles normally or 3–15 after Artillery Fire Control. Each gun preserves the clicked center: a gun already inside its 10-to-35-tile range band sets up or redeploys in place, while an out-of-range gun packs up, paths to a legal firing position, sets up facing the center, and then begins its terminal repeating fire order. Every shell lands at a uniformly area-sampled point inside the selected circle; there is no additional accuracy error or repeated-shot tightening. |
useAbility | `ability: “charge” | “smoke” |
vectorField | units: u32[], x: f32, y: f32, directionX: f32, directionY: f32 | Magic Adept/Master directed field placement. The first click fixes the center and the second click or drag-release supplies a nonzero direction, normalized server-side. Placement is immediate, preserves active and queued orders, and starts a 30-second Adept or 20-second Master cooldown. The server derives the 4-by-4 or 5-by-5-tile cast-time size from the selected caster. The effect moves all ground units by 3 world pixels per tick and is independent of Ekat’s Magic Anchor. |
recastAbility | ability: "ekatTeleport", units: u32[], targetObjectId?: u32, queued?: bool | Explicit second activation for an existing per-caster ability state. The server does not infer recast from missing x/y; it validates ownership, live caster eligibility, matching active return marker state, the no-instant-return availability tick, and destination standability, then returns Ekat to the marker and consumes it. |
setAutocast | ability: string, units: u32[], enabled: bool | Legacy parseable command. No current ability supports autocast, so all requests are ignored. |
gather | units: u32[], node: u32, queued?: bool | Send faction gather-capable units to a live steel node. Kriegsia Engineers are no longer gather-capable; Ekat Golems retain direct Steel gathering. A legal gatherer may travel to a patch and wait for mining-anchor coverage. Oil nodes remain non-direct-mineable. When queued is true, store future gather intent instead of replacing the active order. |
build | units: u32[], building: string, tileX: u32, tileY: u32, queued?: bool | Selected workers construct a building at a tile. The server allocates one compatible worker per build click, first walks that worker to a nearby point outside the requested footprint, then starts construction once it is in range. building ∈ worker-buildable building kinds. Steel Mines and Pump Jacks are excluded because Resource Depots create them through train. When queued is true, store future build intent instead of replacing the active order. |
train | building: u32, unit: string | Queue one manual production item. Most items are units; a Resource Depot also accepts steel_mine and pump_jack. A paid front extractor item immediately creates an under-construction scaffold on the nearest deterministic live, unoccupied matching resource patch within that producer’s mining range. Its public buildProgress equals the depot item’s prodProgress, and completing the queue item completes that same scaffold. An extractor waits unpaid at zero progress while no eligible patch exists. Other legal manual requests may wait for Steel, Oil, or supply. Later FIFO items do not prepay. |
adjustProductionRepeat | buildings: u32[], unit: string, delta: -1|1 | Atomically adjust a production item across selected compatible producers. +1 enables it on one producer that does not already repeat it, preferring the producer with the fewest standing repeat items; -1 removes it from one producer that repeats it, preferring the producer with the most standing repeat items so another automatic order survives when possible. Stable opposite entity-id tie-breaks make repeated additions followed by removals reversible. When a producer’s ordinary queue is empty, it silently retries the ordered list’s current eligible entry. Entries missing a completed building or upgrade prerequisite stay enabled but are skipped until unlocked; resource, supply, pause, and reserve failures wait without skipping the selected eligible entry. A repeated Steel Mine or Pump Jack creates no queue item and spends nothing while every matching patch in that producer’s range is occupied; destroying an extractor makes the repeat eligible again. Each successful automatic enqueue advances to the next enabled item. Any production cancel clears the affected producer’s whole repeat list. |
setAutoBuildSettings | paused: bool, reserveSteel: u32, reserveOil: u32 | Replace the issuing player’s authoritative Auto-Build policy. New players start unpaused with both resource floors at 0. The server clamps each reserve to 0–9,950. While paused, standing repeat orders do not enqueue new units. Otherwise, for each resource an automatic item actually spends, the resulting stockpile must stay at or above that resource’s floor. A zero-cost resource does not gate the item, so Worker Auto-Build can run below the Oil floor without spending Oil. For human players, automatic admission also preserves the combined unpaid cost of ready manual production/research fronts and valid construction purchases whose worker has arrived; the effective floor is the greater of that pending budget and the configured floor per resource. Travelling workers and future queue entries do not contribute. Already-paid production keeps progressing, and manual purchases may spend normally. |
research | building: u32, upgrade: string | Queue a permanent player upgrade at a tech building, including a valid Training Centre or Engineering Complex that is still under construction. Research queued during construction remains unpaid and at zero progress until the building completes. A legal manual request may also wait unpaid at zero progress until its cost is available. A prerequisite must either be complete or already appear earlier in the same building’s authoritative FIFO research queue. Current Kriegsia upgrade ids: methamphetamines, panzerfausts, and entrenchment at the Training Centre; artillery_unlock (Artillery), ballistic_tables (Artillery Fire Control), tank_unlock, tank_plus (Tank Plus), smoke_plus, scout_plane_unlock (Scout Plane), and rockets (Rockets) at the Engineering Complex (engineering_complex). panzerfausts unlocks Panzerfaust training at the Barracks without changing Riflemen. Anti-Tank Guns need no research and are trainable from a completed Gun Works after having owned a completed Engineering Complex. TEMPORARY HACK (TODO: remove when tech requirements are revisited): anti_tank_gun_unlock is automatically granted as a permanent ownership-history marker in existing upgrades rows, survives loss of the complex, and remains non-researchable. artillery_unlock independently unlocks Artillery training; ballistic_tables requires artillery_unlock and reduces the Artillery Fire minimum radius from 6 tiles to 3; tank_unlock unlocks Tank training. smoke_plus increases Scout Car Smoke radius to 4 tiles and doubles its duration. scout_plane_unlock unlocks the Resource Depot and Command Car Scout Plane ability. rockets costs 75 steel and 125 oil, takes 25 seconds, and unlocks Rocket Truck production at Gun Works. |
cancel | building: u32, construction?: bool | With construction: true, cancel an owned unfinished building for a full construction-cost refund; an extractor scaffold instead cancels and refunds its owning Resource Depot item. Otherwise cancel the latest item in a completed building’s production queue; cancelling its active extractor item also removes the linked scaffold. The explicit construction scope prevents a delayed scaffold action from cancelling production after the building completes. Attached builders return to ordinary order handling when a construction site is canceled. |
stop | units: u32[] | Clear orders and return selected units to ordinary idle behavior. |
holdPosition | units: u32[], queued?: bool | Stand ground. Without queued, clear active and queued unit orders immediately. With queued: true, append a terminal hold-position intent so units complete earlier queued stages before standing ground. Held units still fire at enemies already in weapon range and can still be pushed by collision resolution. |
setRally | building: u32, x: f32, y: f32, `kind?: “move” | “attackMove”, queued?: bool, points?: {x:f32,y:f32}[]` |
Servers MUST ignore commands referencing commanded units/buildings the player does not own, unknown
ids, illegal placements, or unaffordable immediate actions (fail silently or emit a notice event).
Manual build, train, and research commands are the explicit affordability exceptions documented
above: they retain bounded authoritative intent and wait before spending or progressing. Attack
target ids are separately validated by explicit attack-target rules.
For appendable unit commands, omitted queued is equivalent to false. Unit order queues are
capped at 32 future intents per unit. Queued intents are lightweight future intent only; active Order
remains the per-tick execution state. Non-queued unit orders replace the active order and clear
future unit intents; stop and non-queued holdPosition clear both active and queued unit orders.
Queued holdPosition is terminal, so later queued unit orders are not appended after it.
Production building rally plans are capped at four total stages. A non-queued rally replaces the
whole plan; a queued rally appends if space remains and establishes the first stage when the plan is
empty.
Prediction acknowledgement has two milestones. Socket/room receipt means the server parsed a
sequenced command and the room task accepted or rejected the envelope; the server may send a tiny
commandReceipt containing only clientSeq, serverTick, accepted, and optional stable reason.
This is diagnostics-only and is not the reconciliation acknowledgement. Sim consumption means the
authoritative tick stream drained the queued command into the simulation; snapshots expose only this
milestone. Sim consumption does not mean the command succeeded: ownership, affordability,
visibility, placement, and other authoritative validation can still make the command a no-op.
ClientNetReport is an untrusted, rate-limited diagnostic aggregate emitted by the browser while
in a match:
{
schemaVersion: u8, // currently 1
matchRunId: string, // live match correlation id from start payload; empty when absent
elapsedMs: u32, // client-side aggregation window duration
matchTick: u32, // latest snapshot tick observed by this client
rttMs: u16, // latest app-level ping round-trip sample
rttMaxMs: u16, // max round-trip sample in this report window
badRttSamples: u32, // samples at/above the client's latency warning threshold
snapshotJitterMs: u16, // current max receive jitter over the client's short jitter window
snapshotGapMaxMs: u16, // largest observed interval between received snapshots
jitterSamples: u32, // jitter incidents in this report window
snapshots: u32, // snapshots received in this report window
snapshotLateFrameCount: u32, // frames where the latest snapshot was late by jitter threshold
predictedSnapshotLateFrameCount: u32, // late-snapshot frames with owned predicted overlay present
predictedSnapshotLateFramePctX100: u16, // predicted/late coverage percentage multiplied by 100
predictionActiveLateFrameCount: u32, // late-snapshot frames where local prediction was predicting/resyncing
snapshotBytesTotal: u32, // total received snapshot application payload bytes
snapshotBytesMax: u32, // largest received snapshot application payload bytes
snapshotBytesAvg: u32, // average received snapshot application payload bytes
snapshotMessageCount: u32, // snapshot frames observed by the transport report window
snapshotByteSource: string, // currently "messagepack-application-payload"; not compressed wire bytes
snapshotCodec: string, // currently "messagepack-compact"
snapshotCodecVersion: u16, // currently 1
snapshotFrameKind: string, // currently "binary"
snapshotBytesP95: u32, // bucketed p95 received snapshot application payload bytes
snapshotSegmentBudgetBytes: u32, // payload-byte single-segment budget used by this client
snapshotOverSegmentBudgetCount: u32, // snapshot frames above snapshotSegmentBudgetBytes
snapshotOverSegmentBudgetPctX100: u16, // over-budget percentage multiplied by 100
snapshotParseMaxMs: u16, // max browser frame parse cost for snapshot frames
snapshotParseP95Ms: u16, // bucketed p95 frame parse cost for snapshot frames
snapshotDecodeMaxMs: u16, // max compact protocol decode cost
snapshotDecodeP95Ms: u16, // bucketed p95 compact protocol decode cost
websocketExtensions: string, // bounded browser WebSocket.extensions after open
websocketCompression: string, // normalized "permessage-deflate" or "none"
snapshotApplyMaxMs: u16, // max GameState.applySnapshot cost
snapshotApplyP95Ms: u16, // bucketed p95 GameState.applySnapshot cost
predictionApplyMaxMs: u16, // max authoritative prediction reconciliation/overlay cost
predictionApplyP95Ms: u16, // bucketed p95 authoritative prediction reconciliation/overlay cost
snapshotTickGapMax: u32, // largest authoritative tick delta between received snapshots
staleSnapshotCount: u32, // snapshots older than the latest accepted snapshot tick
duplicateSnapshotCount: u32, // snapshots with the same tick as the latest accepted snapshot
skippedSnapshotCount: u32, // snapshots whose tick jumped by more than one
snapshotBurstCount: u32, // frames where more than one snapshot arrived before the next rAF
snapshotBurstMax: u32, // max snapshots received before one rAF boundary
frameGapMaxMs: u16, // largest requestAnimationFrame gap in this report window
clientBuildId: string, // page-initialization /version observation (__RTS_BUILD__), bounded to 64 characters
performanceSummary: object | null, // optional 60-second aggregate described below
fpsEstimate: u16, // coarse average client frame rate for this report window
frameWorkMaxMs: u16, // largest measured JS frame work duration
frameWorkP95Ms: u16, // bucketed p95 measured JS frame work duration
frameRafDispatchMaxMs: u16, // max RAF callback dispatch delay before JS frame work
frameRafDispatchP95Ms: u16,
frameUnattributedMaxMs: u16, // max frame work not covered by top-level match.* phases
frameUnattributedP95Ms: u16,
slowFrameCount: u32, // frames whose gap or work crossed the slow-frame threshold
frameWorkBudgetMissCount: u32, // frames whose complete JS work exceeded 1000/60 ms
presentBudgetMissCount: u32, // actual presents whose synchronous work exceeded 1000/60 ms
worstFramePhase: string, // bounded profiler label most often worst in this report window
worstFramePhaseMs: u16, // max duration for worstFramePhase
rendererMaxMs: u16, // largest measured match.renderer duration
rendererP95Ms: u16, // bucketed p95 match.renderer duration
rendererUpdateMaxMs: u16, // max backend scene translation/update duration
rendererUpdateP95Ms: u16, // bucketed p95 backend scene translation/update duration
rendererPresentMaxMs: u16, // max Pixi worker present duration
rendererPresentP95Ms: u16, // bucketed p95 Pixi worker present duration
topRendererPhase: string, // allowlisted top renderer.* phase label for this report window
topRendererPhaseMs: u16,
topRenderDiagnosticGroup: string, // allowlisted grouped render/minimap/HUD diagnostic counter
topRenderDiagnosticGroupCount: u32,
clientFramePhases: [{ label: string, count: u32, maxMs: u16, p95Ms: u16 }], // top 5 allowlisted frame phases
rendererFramePhases: [{ label: string, count: u32, maxMs: u16, p95Ms: u16 }], // top 5 allowlisted renderer.* phases
renderDiagnosticCounters: [{ label: string, samples: u32, frames: u32, total: u32, maxFrame: u32 }], // top 5 grouped counters
renderWorkerMode: string, // active worker presentation route
renderWorkerSubmitted: u32, // cumulative host frame submissions
renderWorkerPresented: u32, // cumulative acknowledged presentations
renderWorkerFailureCount: u32, // new terminal worker failures since the prior report
renderWorkerContextLostCount: u32, // new WebGL context-loss failures since the prior report
renderWorkerInFlight: bool,
renderWorkerInFlightFrameId: u32,
renderWorkerInFlightAgeMs: u32, // age of the unacknowledged in-flight frame
renderWorkerPending: bool,
renderWorkerPendingFrameId: u32,
renderWorkerLastPresentedFrameId: u32,
renderWorkerLastPresentedAgeMs: u32,
renderWorkerLastMessageAgeMs: u32,
renderWorkerErrorCode: string, // bounded stable worker/host failure category
renderWorkerErrorMessage: string, // bounded terminal failure detail
renderWorkerErrorStack: string, // bounded worker/host stack with control characters flattened
renderWorkerErrorSource: string, // bounded worker error-event source when available
renderWorkerErrorLine: u32,
renderWorkerErrorColumn: u32,
renderWorkerBackend: string,
renderWorkerPixiVersion: string,
renderWorkerGlVendor: string,
renderWorkerGlRenderer: string,
renderWorkerGlVersion: string,
renderWorkerUserAgent: string,
entityCount: u32, // latest client-visible entity count context
selectedCount: u16, // latest local selection size context
visibleTileCount: u32, // latest visible-tile count context
viewportWidth: u16, // latest CSS viewport width context
viewportHeight: u16, // latest CSS viewport height context
devicePixelRatioX100: u16, // latest devicePixelRatio multiplied by 100
commandBurstBucketMs: u16, // short command-density bucket width, currently 250 ms
commandBurstMax: u16, // max commands issued in any commandBurstBucketMs window
commandBurstFrameGapMaxMs: u16, // max frame gap while a command burst was active
commandBurstWorstFramePhase: string, // bounded worst frame phase while a command burst was active
commandBurstWorstFramePhaseMs: u16,
hidden: bool, // document.hidden when the report was sent
focused: bool, // document.hasFocus() when available
desktopRuntimePresent: bool, // true when the desktop shell runtime flag exists
nativeCursorBridgePresent: bool, // true when the native cursor JS bridge exists
nativeCursorSupported: bool, // native cursor bridge support result
nativeCursorActive: bool, // native cursor capture active state from bridge diagnostics
nativeCursorLastReason: string, // bounded native cursor diagnostic reason
nativeCursorLastError: string, // bounded native cursor diagnostic error
tauriInternalsPresent: bool, // true when Tauri IPC internals are visible
tauriGlobalPresent: bool, // true when the global Tauri API object is visible
tauriGlobals: string, // bounded comma-separated Tauri global key summary
wsBufferedBytes: u32, // browser WebSocket bufferedAmount
serverTickMs: u16, // latest server tick work duration seen in snapshot netStatus
serverLagMs: u16, // latest scheduler lag seen in snapshot netStatus
slowTickCount: u32, // latest server slow-tick count seen by this client
headOfLineCount: u32, // latest per-client pending-snapshot replacement count seen
predictionMode: string, // disabled, tracking, predicting, or resyncing
pendingCommandCount: u16,
acknowledgedCommandLatencyMs: u16, // latest local issue -> sim-ack latency
commandsIssued: u32, // commands allocated in this report window
commandSocketSendAccepted: u32, // WebSocket.send accepted by the browser
commandServerReceived: u32, // accepted commandReceipt count
commandSimAcknowledged: u32, // commands covered by snapshot sim-consumption ack
commandRejected: u32, // rejected commandReceipt count
commandIssueToSocketSendAcceptedLatestMs: u16,
commandIssueToSocketSendAcceptedMaxMs: u16,
commandIssueToSocketSendAcceptedP95Ms: u16,
commandIssueToServerReceiptLatestMs: u16,
commandIssueToServerReceiptMaxMs: u16,
commandIssueToServerReceiptP95Ms: u16,
commandServerReceiptToSimAckLatestMs: u16,
commandServerReceiptToSimAckMaxMs: u16,
commandServerReceiptToSimAckP95Ms: u16,
commandIssueToSimAckLatestMs: u16,
commandIssueToSimAckMaxMs: u16,
commandIssueToSimAckP95Ms: u16,
commandAckSnapshotReceivedToAppliedLatestMs: u16,
commandAckSnapshotReceivedToAppliedMaxMs: u16,
commandAckSnapshotReceivedToAppliedP95Ms: u16,
oldestPendingCommandAgeMs: u16,
maxPendingCommandCount: u16,
commandFamilyMove: u32, // command family counts for stable low-cardinality grouping
commandFamilyAttackMove: u32,
commandFamilyBuild: u32,
commandFamilyTrain: u32,
commandFamilyOther: u32,
commandLifecycleExemplars: [{
clientSeq: u32, // bounded top-N diagnostic exemplar, no command payload
family: "move"|"attackMove"|"build"|"train"|"other",
issuedElapsedMs: u32, // report-window-relative client issue time
stage: string, // stable lifecycle stage label
stageMs: u16
}],
correctionDistancePx: u16, // largest correction observed by the client
correctionCount: u32,
predictionDisableCount: u32,
predictionDisableUserCount: u32,
predictionDisableReplayCount: u32, // replay-viewer or replay-budget reset reasons
predictionDisableSpectatorCount: u32,
predictionDisableCompatibilityCount: u32,
predictionDisableWasmCount: u32,
predictionDisableOtherCount: u32,
wasmTickMs: u16, // latest measured WASM prediction/replay work duration
wasmMemoryBytes: u32, // current WASM memory buffer size, when available
predictionReplayTicks: u16, // latest local replay/advance ticks processed in one measured step
predictionReplayMaxMs: u16, // max WASM pending-command replay duration in report window
predictionReplayMaxTicks: u16, // max pending-command replay ticks in report window
predictionReplayBudgetExceededCount: u32
}
The snapshot payload, codec, parse, decode, apply, prediction-apply, cadence, command milestone,
command lifecycle, and desktop cursor runtime fields are report-window aggregates or bounded
summaries only; raw snapshot
payloads, raw timestamp arrays, entity ids, unit ids, target ids, positions, replay data, command
payloads, and raw cursor input events are not uploaded. HUD jit and snapshotJitterMs mean
snapshot arrival jitter, not JavaScript compiler/JIT time. The canonical single-segment payload
budget is 1280 bytes. It is intentionally below a common 1460-byte Ethernet TCP MSS because the measured
snapshot bytes are only WebSocket application payload bytes and exclude WebSocket framing plus TLS,
TCP, and IP overhead. Command milestone timing splits local issue to WebSocket send acceptance,
issue/send to receipt, receipt to sim acknowledgement, issue to sim acknowledgement, and ack snapshot
receipt to browser apply. commandLifecycleExemplars preserves at most five report-window
exemplars by clientSeq, stable command family, stage, and duration; it never includes units,
targets, positions, raw command payloads, or raw timestamp arrays. The
frame-work and renderer fields come from the browser’s bounded frame-profiler report window; the
local debug surface may keep richer cumulative phase tables, but those raw arrays and detailed
recent frames are not uploaded. Durations are integer milliseconds after bounded rounding for the
wire. rendererUpdate* and rendererPresent* are stable scalars even when their nested phase rows
fall outside a capped top-five list. They are nested inside match.renderer and must not be added
to frameWork*. The two budget-miss counts use strict > 1000/60 ms; they reset after each report
upload, while the local profiler remains cumulative until explicitly reset. The existing 33 ms
slowFrameCount meaning is unchanged. commandsIssued is the report-window total and catches sustained
rapid input that may not reach the fixed 250 ms commandBurstMax threshold. Command burst fields
only count commands accepted by the browser WebSocket send path after local command-budget checks. Prediction
disable reason fields are stable buckets; detailed WASM loader errors stay local. The server logs
this message only when the aggregate contains
notable lag, jitter, browser frame stalls, 60 FPS work-budget misses, local JS frame work,
large-payload pressure, packet-budget pressure, snapshot parse/decode/apply cost,
snapshot cadence/burst issues, renderer update/present cost, WebSocket
backlog, server tick/scheduler pressure, sustained or bursty command density, command milestone delay/rejection, or prediction
correction/fallback signals, alongside the connection’s player_id, room name, and reported
match_run_id. The same structured row also includes server-observed counters for the report
window, prefixed server*, such as command receipt counts, command frame deserialize time,
deserialize-to-room-enqueue time, room-event queue delay, room handling/receipt queue time,
receipt-send age, accepted-to-sim-ack time, bounded server command lifecycle exemplars, reliable
messages drained while a snapshot was pending, snapshot send age, and latest-only snapshot slot
stored/replaced/closed counts.
One reliable message before a snapshot with no send age or slot replacement is normal ordering, not
outbound pressure.
Those server-only log fields are not client protocol fields. Values are advisory because clients are untrusted; use them to diagnose
transport/browser/prediction/render behavior, not as gameplay authority.
The optional netReport.performanceSummary is emitted after at least 60 seconds on the existing
10-second report transport. The server writes a compact client_performance_summary event even
when the exceptional diagnostics are healthy. Match end/teardown also attempts a final partial summary after at least one second and one
recorded frame; delivery remains best effort if the socket closes. Summary
windows reset only after an accepted send. elapsedMs is wall-clock window duration;
clientBuildId records the server build observed by the page at initialization, not a
content hash proving the version of every loaded asset. frameCount and frameTotalMs describe main-thread rAF gaps, not GPU/display FPS.
frameGapMaxMs, bucketed frameGapP95Ms/frameGapP99Ms, and framesOver33Ms,
framesOver50Ms, framesOver100Ms quantify stutters. Quantiles use upper buckets
8/16/17/24/33/50/100/250/1000/65535 ms; gaps above the final bucket saturate quantiles.
workerPresentedCount is the acknowledged worker presentation delta; divide by elapsedMs
for throughput only when workerCountersValid is true. Counter resets invalidate that window.
These acknowledgements mean render submission completed, not GPU completion or monitor scanout.
visibleThroughout, focusedThroughout, and visibilityChangeCount flag mixed foreground and
background windows, including hide/show between reports; exclude mixed windows when comparing.
workerRollingUpdate, workerRollingPresent, workerRollingQueueAge, and
workerRollingDisplayAge each contain {samples: u32, maxMs: u16, p95Ms: u16} over the
worker host’s last 2048 acknowledged frames, not the minute window. Present timing measures
CPU command submission. Summaries do not reset host diagnostics or introduce GPU synchronization.
All other counters/durations are u32 except quantiles (u16) and validity flags (bool).
2.2 Server → Client (ServerMessage)
t | Fields |
|---|---|
welcome | playerId: u32 — assigned on connect; buildId: string — running server build for the client version handshake. |
lobby | room: string, kind: LobbyKind, hostId: u32, players: LobbyPlayer[], canStart: bool, countdownActive: bool, teamPreset: string, map: string, maps: AvailableMap[] |
matchCountdown | countdownId: u32, durationMs: u32, words: string[] — reliable pre-match countdown sent to every lobby participant after the host starts and before start. Active human clients begin warming their renderer when they become ready, then acknowledge this exact nonzero countdown generation with matchLoadReady once warmup completes. During this interval the server keeps the room in lobby setup, disables canStart, freezes lobby edits, and rejects new joins. At expiry it sends start only if every active human acknowledged; otherwise it returns the room to editable lobby state and broadcasts <name> failed to load the game. Spectators and AI do not block launch. |
start | Game start payload (see 2.3). |
snapshot | Per-player snapshot (see 2.4). |
replayResourceHistory | replace: bool, samples: [{ tick: u32, steel: i64, oil: i64, aliveSteel: i64, aliveOil: i64, lostSteel: i64, lostOil: i64, unitSteel: i64, unitOil: i64, players: [{ id: u32, lifetimeSteel: i64, lifetimeOil: i64, steel: i64, oil: i64, aliveSteel: i64, aliveOil: i64, lostSteel: i64, lostOil: i64, unitSteel: i64, unitOil: i64 }] }] — reliable replay-only collection, alive-resource, destroyed-value, and current-army-value comparison timeline for two to four players. The players series contains absolute individual values, including lifetime mined totals; collection is the trailing five-second income (the client divides by five for a per-second average) (zero until a window baseline exists). A full replacement is sent on join and after seek; one sample is appended per replay second (steel/oil: trailing 5-second collection advantage; aliveSteel/aliveOil: lifetime mined minus destroyed value, lostSteel/lostOil: cumulative destroyed unit and building value; unitSteel/unitOil: summed current unit value; top-level metric fields are first player minus second in ascending player-id order) during ordinary playback. Samples span from replay start through the current tick and are not subject to the latest-only observer-analysis lane. |
groundDecals | requestId: u32, revision: u32, decals: GroundDecalView[], tankTrails: TankTrailView[] — reliable fog/observer-scoped delta response. requestId echoes the request so stale pre-seek or pre-view-change responses cannot enter the current cache. A trail row carries an immutable chunk id and sparse [xQuarterPx, yQuarterPx, headingI16] poses; these wire units remain stable even though historical poses are deliberately coarsened before projection. The server discloses a historical chunk when its indexed swept bounds first intersect current team vision. As an explicit best-effort-cosmetic exception to positional fog secrecy, the client may therefore hold nearby hidden tread geometry from that bounded chunk; no live entity or command state is included. It reconstructs and permanently rasterizes the approximate swept left/right tread footprint only inside individual currently visible map tiles. Ordinary decal rows carry id, decalClass, sourceKind, x, y, owner, seed, and optional facing, weaponFacing, or radiusTiles. |
roomTimeState | Room-controlled time state (see 2.6). |
roomTimeSeekStarted | controllerId: u32, fromTick: u32, targetTick: u32 — reliable broadcast to every replay viewer immediately before an accepted shared replay seek resets timeline-derived presentation and begins incremental fast-forward. Rejected and rate-limited seeks do not emit it. |
livePauseState | Live match pause state (see 2.6). |
observerAnalysis | Observer analysis state (see 2.7). |
joinReplayPrompt | room: string — the requested room is currently replay playback; clients should confirm before retrying join with replayOk: true. |
branchFromTickCreated | branchRoom: string, sourceTick: u32, seats: ReplayBranchSeat[] — a separate practice branch room has been created from the source replay’s current authoritative tick. |
branchStaging | room: string, sourceTick: u32, hostId: u32, seats: BranchStagingSeat[], occupants: BranchStagingOccupant[], canStart: bool — reliable current state for a replay branch staging room. Sent after joins, leaves, claims, and releases. |
chat | scope: "lobby" or "game", channel: "all" or "team", tick?: u32, senderId: u32, senderName: string, text: string — reliable server-authored chat delivery. Lobby deliveries omit tick; live and replay deliveries carry the authoritative presentation tick. Clients render all fields as text, never HTML. |
roomNotice | msg: string — reliable, ephemeral room activity shown through the normal brief toast. Active replay joins notify existing viewers; departures notify remaining viewers. Delivered even while paused, seeking, or ended; never recorded or replayed on seek. |
shutdownWarning | deadlineUnixMs: u64, secondsRemaining: u64 — deploy/termination drain has started; active matches may continue until the deadline, but new match starts are disabled. |
observationReady | matchRunId: string — a watched all-AI match has resolved; this id retrieves its saved replay and joins its structured server logs. |
gameOver | `winnerId: u32 |
pong | ts: number (echo of the ping ts), buildId: string (running server build). |
commandReceipt | clientSeq: u32, serverTick: u32, accepted: bool, reason?: string — reliable diagnostics-only room receipt. Does not reconcile prediction. |
error | msg: string |
Game-generated critical alerts reuse chat with senderId: 0, senderName: "Game", and
channel: "all". Lost auto-production prerequisite warnings are delivered only
to the owning active seat, never teammates or spectators, as Rebuild Engineering Complex!
(or the other missing prerequisites’ display names), with a 30-second simulation-time cooldown
per seat. A prerequisite qualifies only if the seat previously had a completed building of that
kind in the live session and active auto-production is currently blocked by its absence. Multiple
blocked units produce one reminder listing each qualifying prerequisite once. Persistent blocked
conditions may remind after the cooldown. Supply-cap warnings are disabled.
The client displays these alerts as bare text without channel or sender prefixes, with a subtle
size pulse (disabled for reduced-motion preferences). These private economy warnings are excluded
from replay chat and contain no positional information.
LobbyPlayer: { id: u32, teamId: u32, factionId: string, name: string, ready: bool, color: string, isAi: bool, aiProfileId?: string, isSpectator: bool }. isAi is
true for computer opponents (always shown ready; the client renders an “AI” tag, a host-only
profile selector, and a host-only remove control instead of a ready toggle). aiProfileId is
present only for computer opponents and identifies the canonical live AI profile selected for that
seat. isSpectator is true for human observers; they do not consume active map starts,
block readiness, or count toward win/loss.
AvailableMap: { name: string, description: string, minPlayers: u32, maxPlayers: u32 }.
name is the stable value sent back in selectMap; description is display text for the lobby
selector; minPlayers is one and maxPlayers is derived from the authored startLocations count
for that map. Lobby map is the current selected map name and is distinct from replay start
metadata mapName.
LobbyKind: "normal" for ordinary public lobbies/live rooms and "replay" for replay staging
or active replay playback, including the automatic replay entered after a normal match ends.
Replay staging lobbies carry only spectator LobbyPlayer rows, report canStart when the host may
begin playback, send the replay artifact map name as map, and send an empty maps[] because map
selection is disabled. The HTTP GET /api/lobbies row uses the same kind values and includes
only safe room metadata: room, kind, host name, map, creation time, active-slot counts, spectator
count, phase, and join state. Active replay rows use phase: "inGame" and
joinState: "inGame", report zero active slots, and count every connected replay viewer as a
spectator.
GET /api/lab-scenarios returns a bounded catalog of bundled lab checkpoint setup metadata:
[{ id, title, description, map, playerCount, filename }]. id is the stable safe token used
in direct lab room URLs as scenario=<id>, map and playerCount mirror the listed setup
payload, and filename is the safe bundled JSON filename under
server/assets/lab-scenarios/. The listing deliberately omits the full setup JSON; lab starts
load it server-side from the manifest source of truth.
teamId is nonzero for active match players and AI seats. New active players and default-added AI
opponents are assigned to the next empty team after the currently occupied teams when possible,
falling back to the first empty team in 1..=4; the host may move active human or AI seats between
those team slots. The normal lobby UI shows occupied teams plus one “New team” drop target while
fewer than four teams are occupied, plus a bottom spectator drop target for host-managed observer
moves. Spectator lobby rows carry teamId: 0 because they are not match players. In normal
lobbies, canStart is false until there is at least one active seat, every active human is ready,
every active seat has a team in 1..=4, and the active seat count is at or below the selected
map’s maxPlayers cap and the server’s hard four-player cap. Selecting a lower-capacity map
removes overflow AI seats first, then moves overflow humans to spectators. In replay staging
lobbies, canStart is true when a host spectator is present and the server is not blocking new
sessions for deploy drain.
PlayerScore: { id: u32, teamId: u32, name: string, color: string, apm: u32, unitScore: u32, structureScore: u32, unitsKilled: u32, unitsLost: u32, buildingsKilled: u32, buildingsLost: u32 }. scores is a
frozen server snapshot taken when that recipient gets gameOver; it is not live-updated while a
3-4 player match continues. Unit/structure score is the configured steel+oil value of every
unit/building entity created for that player, including starting entities. apm counts one action
per authoritative gameplay command regardless of the number of units in that command, excludes the
first 60 seconds, and averages the remaining actions over the remaining simulated match time.
unitsLost and buildingsLost count only entities that died in the simulation. Surviving entities
removed as administrative cleanup after give-up or disconnect do not increment either loss total.
winnerTeamId is the winning team’s id when a winner exists, otherwise null. winnerId remains
for FFA compatibility. During singleton-team FFA, winnerTeamId matches winnerId; during team
wins, winnerId is the first living player on the winning team in stable start/lobby order.
MatchConclusion is { defeatedPlayerIds: u32[], reason: "gaveUp" | "eliminated" | "lostAllBuildings" | "lostPrimaryBase" } and records the decisive authoritative cause when one is
known. eliminated is the accurate common description when an AI in an ordinary mixed match may
have lost either all units or all survival buildings; all-AI observation matches instead identify
their starting-primary-base objective explicitly. The score screen uses the frozen score rows to
name the defeated players and explain the result below its headline. Draws and abnormal server
termination omit it.
ReplayBranchSeat: { playerId: u32, teamId: u32, factionId: string, name: string, color: string, claimable: bool }. Seats are
listed in original replay player order. claimable is false only for unsupported original seats;
the first implementation rejects AI-seat replays before creating a branch, so successful branch
creation currently reports all seats as claimable.
BranchStagingSeat: { playerId: u32, teamId: u32, factionId: string, name: string, color: string, claimantId?: u32, claimantName?: string }. Seats are listed in original replay player order. A missing claimant
means that original seat is still available to claim.
BranchStagingOccupant: { id: u32, name: string }. Occupants are all human viewers currently in
the branch staging room, whether they have claimed an original seat or are remaining spectators.
canStart becomes true for the host once at least one original seat is claimed and launch is not
otherwise blocked by countdown or deploy drain.
2.3 start payload
Sent when a live match begins and when replay playback is rebuilt, including after replay seeks. Carries static match metadata and recipient-scoped capabilities for that start.
{
t: "start",
playerId: u32, // your id (repeat of welcome for convenience)
spectator: bool, // true when this connection is observing only
predictionBuildId?: string, // live active players only; server/client bundle id
predictionVersion?: u32, // live active players only; currently 1
matchRunId?: string, // live match correlation id for log joins
capabilities?: { // explicit recipient-scoped shared room affordances
roomTime?: {
available?: bool,
setSpeed?: bool,
pause?: bool,
step?: bool,
seekRelative?: bool,
seekAbsolute?: bool,
timeline?: bool
},
matchControls?: { pause?: bool },
visibility?: { visionSelection?: bool },
commands?: { gameplay?: bool },
actions?: { branchFromTick?: bool }
},
diagnostics?: { // explicit recipient-scoped diagnostic affordances
movementPaths?: "ownerOnly"|"all",
observerAnalysis?: bool
},
replay?: { // present for production replay playback
artifactSchemaVersion: u32,
serverBuildSha: string,
mapName: string,
mapSchemaVersion: u32,
mapContentHash: string,
seed: u32,
durationTicks: u32
},
lab?: { // present for lab room starts
room: string, // safe public lab id, not the hidden internal room prefix
operatorId: u32,
role: "operator"|"readOnly",
vision: { mode: "all" } | { mode: "team", teamId: u32 }, // legacy setup/default metadata; runtime selection uses setVisionSelection
godModePlayers?: u32[],
initialCamera?: { centerX: u32, centerY: u32 }, // optional world-pixel camera center from the selected setup
dirty: bool,
operationCount: u32
},
observerView?: { mode: "all" } | { mode: "player", playerId: u32 } | { mode: "players", playerIds: u32[] },
// authoritative per-connection privileged observer selection; omitted for active players
tick: u32, // starting tick (0 for normal starts; restored checkpoint tick for checkpoint replays)
map: {
width: u32, height: u32, // in tiles
tileSize: u32, // world px per tile
// terrain: row-major array length width*height. Codes: 0 grass, 1 rock,
// 2 water, 3 bare road, 4 horizontal-marked road, 5 vertical-marked road,
// 6 NW-SE diagonal-marked road, 7 NE-SW diagonal-marked road,
// 8-10 gravel A/B/C, 11-13 dirt A/B/C, 14-16 mud A/B/C,
// 17 frosted ground. Grass, all roads, gravel, dirt, mud, and frosted
// ground are passable; rock/water are impassable.
terrain: number[],
// Server-authored height levels, row-major and shape-matched to terrain.
// Omitted on flat maps (implicit zero). Local elevation direction affects movement speed. Ordinary
// unit/sight-granting building sight gains one
// tile per two absolute elevation levels, capped at four; zero-sight buildings stay visionless,
// and elevation does not block sight or alter combat LOS.
elevation?: number[],
// Required when elevation varies and optional on flat maps. Azimuth is compass degrees in map space
// (0=north/-Y, 90=east); elevation is degrees above the horizon; warmth is 0-100.
sun?: { azimuthDegrees: u16, elevationDegrees: u8, warmth: u8 },
// All neutral resource nodes (static, never move). Sent so the client can
// render them on the minimap before fog-of-war reveals them.
resources: [ { id: u32, kind: "steel"|"oil", x: f32, y: f32 } ],
// Static authored map objects, canonicalized by ascending nonzero id. Tree records have
// authoritative tiny trunk collision and wildflowers are inert. Entity-backed authored
// objects such as unit.tank_trap are omitted so their positions arrive only through
// fog-filtered entity snapshots. Coordinates are integer world pixels. color is allowed only
// on wildflowers.
doodads: [ { id: u32, typeId: string, x: u32, y: u32, color?: "#rrggbb" } ],
concealmentTiles: [ { x: u32, y: u32 } ],
noVehicleTiles: [ { x: u32, y: u32 } ],
noBuildingTiles: [ { x: u32, y: u32 } ],
noEntrenchmentTiles: [ { x: u32, y: u32 } ],
damageReductionTiles: [ { x: u32, y: u32 } ],
unwalkableTiles: [ { x: u32, y: u32 } ],
slowMovementTiles: [ { x: u32, y: u32 } ]
},
players: [ { id, teamId, factionId, name, color, isAi, startTileX, startTileY } ], // active match players only
}
unwalkableTiles is an independent sparse tile annotation (omission means empty) carried by
authored maps, match-start map data, Lab drafts, handoffs, and checkpoint map containers.
It preserves rendered terrain while rejecting ground movement, ability landings, unit spawns,
and intersecting building footprints. It does not block teleport travel over a tile, sight, or shots.
Units/buildings arrive via snapshots (so they obey fog), including the player’s own starting
loadout from the validated faction catalog. Normal live starts may skip countdown when there are
one or zero active human seats, including one-human-vs-AI and AI-only rooms, but they still use
ordinary starting resources and ordinary faction loadouts. Dev scenario start payloads may
advertise diagnostics.movementPaths: "all" because those rooms
intentionally use full-world diagnostic projection. players[].isAi identifies computer-controlled
seats in live matches and remains preserved in replay start payloads so client diagnostics can
require an actual AI participant. Replay viewers and live spectators receive
diagnostics.observerAnalysis: true only
when room projection policy will send observer-analysis payloads to that recipient.
capabilities is the neutral control/affordance contract. Live active players receive
commands.gameplay: true and matchControls.pause: true; live spectators receive
matchControls.pause: true without commands.gameplay. Replay viewers, dev-watch viewers, and
lab viewers do not receive match controls. AI-only live matches are the live route that maps to the
speed-only room-time capability profile: connected spectators receive room-time speed/pause
controls, but no step, relative seek, absolute seek, or timeline capability.
Replay branch live rooms also advertise matchControls.pause to both claimed-seat and observer
recipients; gameplay commands remain claimed-seat only through the branch-live seat alias path.
Every privileged observer (live spectator, replay, dev-watch, and Lab) advertises
visibility.visionSelection: true. Replay playback additionally advertises room-time
speed/pause/relative seek/absolute seek/timeline controls. Replay branch creation is advertised separately with
actions.branchFromTick: true only when the current replay can accept a branch request. Dev scenario
watch rooms advertise speed/pause/step room-time controls without seek. Lab rooms advertise
speed/pause/step/relative seek/absolute seek/timeline controls and generic vision selection, but
not branch-from-tick controls. Clients must not infer these shared affordances
from replay, lab, URL-local dev-watch state, or legacy debug flags.
The browser’s shared room-time controls render lab seek and keyframe metadata from these
capabilities and roomTimeState; observer perspective is per connection and remains separate from
Lab command authority.
Spectator start payloads keep the spectator connection’s playerId, set spectator: true, and
list only active match players in players. Late live spectator joins receive the same live start
payload shape stamped from the current Game::start_payload() tick, with prediction metadata
omitted and live spectator capabilities/diagnostics applied for that recipient.
Lab room start payloads set lab metadata and currently also set spectator: true with prediction
metadata omitted. Labs use a hidden internal room id, a default two-team real Game template, and
server-owned projection. initialCamera, when present, is a setup-authored world-pixel center
point that the browser uses for the first Lab view instead of centering on the operator’s home
base. role names the room-owned operator/read-only viewer classification.
Direct lab URL joiners currently receive operator; readOnly remains available for future
explicit viewer modes. operatorId identifies the original lab joiner for compatibility metadata,
not the sole authority for privileged lab operations. Lab room-time controls are shared room state:
any operator can pause, resume at a clamped positive speed, step exactly one authoritative tick
while paused, seek relatively, or seek to an absolute retained lab timeline tick. Accepted lab seeks
restore the nearest retained lab keyframe at or before the target, replay accepted lab operations
and issue-as commands through normal server validation, re-send lab start metadata, broadcast
roomTimeState/labState, and send fresh snapshots. If a new lab operation or issue-as command is
accepted after a past seek, future lab timeline entries and keyframes after the current tick are
truncated; there is no branch, redo, or undo protocol in this slice.
For compatibility with hand-built fixtures and older replay artifacts, missing teamId values at
simulation/replay/test-helper boundaries default to singleton FFA: the player’s own nonzero id.
Current live server payloads always emit explicit nonzero teamId values for active players.
The canonical default faction id is kriegsia; ekat remains an internally supported playable
catalog id but is hidden from the normal lobby selector. cultivators is a playable economy-first
catalog, selectable alongside Kriegsia in normal human lobbies on every deployment. Start payloads emit factionId
for every active start player, lobby seat and replay branch seat, and replay artifacts store
faction_id for every player. Missing faction requests default to kriegsia in normal lobby,
AI, self-play and dev contexts. Explicit kriegsia, ekat and cultivators requests follow
playable lifecycle policy; the phase2_empty_fixture test fixture and unknown ids remain restricted. Cultivators uses the
cultivators.standard loadout; Nexus is a faction-specific presentation name for
resource_depot, and Serf is the presentation name for worker, while Portal uses the dedicated portal entity kind (compact kind code 28).
Sword Disciples use warrior (compact kind code 29), Bow Novices use bow_novice (41); both evolve. Evolved Adepts use
wind_adept (35), war_adept (36), and magic_adept (37). Their generic
base/War/Wind attack events carry warrior_sword (compact weapon-kind code 12). The retained arrow identity is disciple_arrow (13), and Magic orbs use disciple_orb (14), through the same fog-filtered attack event and immediate authoritative damage timing.
Protocol vocabulary is not lifecycle admission: adding a string constant, compact code, or payload
field does not make a faction playable. Fixture-only, reserved/future, and historical-only ids must
not become valid setFaction, AI-seat, replay-branch, or post-match replay ids without updating
docs/design/faction-architecture-inventory.md, the lifecycle validator, and protocol parity in
the same change.
Prediction start compatibility metadata is present for live active players. Spectator,
replay-viewer, Lab, and dev-watch recipients omit it. Clients MUST keep
prediction disabled unless predictionVersion matches their supported prediction protocol version
and, when both sides know a build id, predictionBuildId matches the client bundle id. Mismatches
fall back to authoritative snapshots/tracking instead of running local visual reconciliation.
Replay start payloads include replay metadata so the client can display or cache a
self-describing playback session. The server validates replay artifacts before playback: artifact
schema version, map name, map schema version, and map content hash must match the running
server/map asset or the replay is rejected with a clear error. Schema 3 artifacts additionally
validate the embedded startState.checkpointPayload map binding, including the materialized map
hash, before constructing the replay Game. A server build-SHA mismatch is warning-compatible:
replay metadata keeps the original serverBuildSha, and the server logs or surfaces a warning
while attempting playback. Saved self-play artifacts use the same ReplayArtifactV1 contract as
post-match and match-history replays; pre-unified dev-only artifact payloads are rejected instead
of falling back to a separate loader.
Replay artifact schema version 3 stores a launch-time startState containing map binding fields
and a tick-zero GameCheckpointV1 text payload, plus ordered players[] with each original
team_id and required faction_id, plus playerLoadouts[] with one { playerId, factionId, loadoutId, startingSteel, startingOil } record per player. Replay reconstruction restores the
start Game from the checkpoint payload and then applies the authoritative commandLog[] on the
recorded ticks. Its bounded ordered chatLog[] stores {tick, senderId, senderName, channel, text}
for accepted in-game chat and public Game announcements; replay playback reliably emits each entry when the shared cursor
reaches that tick. Seeking clears the client’s transient chat presentation and positions the chat
cursor after the target tick, so already-passed messages do not flood the screen and appear again
only after rewinding before them and resuming. Both all-chat and formerly private team-chat are part
of the completed replay’s historical record and are visible to replay spectators. The compatibility
winnerId, optional winnerTeamId, durationTicks, and
finalScores[] with each row’s teamId remain part of the artifact. Artifact schema 2 and older
payloads are rejected with the unsupported-schema error; new captures always include explicit
nonzero player and score team ids, required player faction ids, required player loadout records,
startState, and winnerTeamId when there is a winning team.
Persisted match-history replay launch creates a replay staging lobby rather than starting playback
on the first join. The first spectator becomes host, additional viewers may gather from the lobby
browser, and the host’s start transitions the shared room into the same replay playback runtime
used after post-match replay. Replay staging ignores ready toggles, active-seat role changes, team
or faction edits, AI changes, and map selection. After playback starts, the room remains in the
lobby browser as an active replay. New viewers join the existing shared cursor and receive its
current start metadata, room-time state, snapshot, and observer analysis immediately, including
when playback is already at its final tick.
When replay playback first reaches its final tick, including through a seek, the server sends the
artifact’s frozen gameOver result to every viewer with the neutral spectator verdict draw.
Late viewers joining an already-ended replay receive that result with the current replay state.
When a real multi-player match ends, the server sends the normal gameOver score payload, clears
pending latest-only live snapshots for connected humans, and then sends a replay start payload
at tick 0 plus roomTimeState. Post-match replay defaults every viewer to all active players’
combined authoritative vision and starts at 2.0x speed. returnToLobby detaches only the
requesting replay viewer; the shared replay session remains alive for everyone else. The room drops
the replay simulation after the last viewer leaves; for normal public rooms, that empty room then
asks the lobby registry to dispose the public name rather than holding it for reconnect. Dedicated
replay rooms created for match-history or dev replay viewing follow the same per-viewer detach rule
after playback has started; they keep the shared replay session alive until the room empties.
Playable replay branches use this same post-match replay transition after give-up or ordinary match
resolution while retaining their private replay-branch room identity.
Automatic post-match replay rooms remain listed and joinable as replay rooms for that entire
shared-viewing lifetime.
2.4 snapshot payload (per-player, fog-filtered)
Snapshot remains the semantic shape used by server game code and by client modules after
transport decode:
{
t: "snapshot",
tick: u32,
groundDecalRevision: u32, // recipient-scoped durable-ground-mark discovery cursor
groundDecalDelta?: { // repeated complete tail (afterRevision, revision]
afterRevision: u32,
decals: GroundDecalView[] // at most 64 fog/observer-entitled rows
},
worldCombatPosition?: [f32, f32], // coarse global combat area; omitted when inactive
steel: u32, oil: u32, // your resources
supplyUsed: u32, supplyCap: u32,
autoBuild?: {paused: bool, reserveSteel: u32, reserveOil: u32}, // projected player's authoritative policy
entities: Entity[], // your non-resource entities (always) + entities visible to living-team current/firing/death vision
resourceReset?: bool, // replace resource projection before applying rows; compact rr
resourceDeltas?: ResourceDelta[], // authoritative knowledge changes; omitted when empty
smokes?: SmokeCloud[], // active smoke clouds visible to this recipient; omitted when empty
abilityObjects?: AbilityObject[], // active ability world objects visible to this recipient; omitted when empty
trenches?: Trench[], // neutral trench terrain visible to this recipient; omitted when empty
visibleTiles?: u8[], // row-major current server visibility; 1 = visible, 0 = fogged
exploredTiles?: u8[], // row-major server-owned exploration history for this perspective
rememberedBuildings?: RememberedBuilding[], // stale enemy building intel for projected players
rememberedAntiTankGuns?: {id, owner, x, y, facing, observedTick}[], // stale deployed enemy AT-gun arcs for projected players
events: Event[], // transient things to surface (see 2.5)
upgrades?: string[], // completed permanent upgrades for this recipient
playerFactions?: {id, factionId}[], // public seat identities, independent of vision selection
playerResources?: {id, steel, oil, supplyUsed, supplyCap, apm, upgrades?}[], // projected players; observer modes only; upgrades are that real owner's completed research
netStatus: { // per-recipient server-side health for the current match
serverLagMs: u16, // how late this room started the tick vs its scheduled time
tickMs: u16, // elapsed room-tick work so far when this snapshot was built
slowTick: bool, // true when the room was at/over its tick budget this tick
slowTickCount: u32, // number of slow-tick incidents so far this match
headOfLine: bool, // true when an older unsent snapshot was still pending for this client
headOfLineCount: u32, // number of pending-snapshot replacements so far this match
predictionVersion?: u32, // live active players only; currently 1
lastSimConsumedClientSeq?: u32, // highest contiguous local clientSeq consumed by the sim
lastSimConsumedClientTick?: u32 | null // authoritative tick that consumed that sequence
}
}
Steel, Oil, and Supply are fixed protocol fields for this faction plan. Normal snapshots,
observer playerResources, compact "s", compact "pr", start-map resources, score values, and
observer analysis remain on the current Steel/Oil/Supply schema; faction-specific or arbitrary
resource vectors are deferred to a separate generic-resource migration. Selected observer snapshots
include playerResources rows only for the explicitly selected real player ids; omniscient views
expose all active player rows. Each row carries that owner’s completed research so multi-player
observer views do not depend on the single-recipient top-level upgrades field.
Durable death, mortar-impact, and artillery-impact decals live in an authoritative append-only
store with compact typed rows and a derived spatial discovery index. A mark becomes known to a
player only when its point or blast footprint is physically visible in that player’s current team
fog; firing ownership and transient event delivery do not by themselves reveal an impact hidden
in fog. groundDecalRevision is the latest discovery revision for the projected player union (or
the global cursor for omniscient views). Ordinary snapshots also repeat a bounded
groundDecalDelta covering every entitled row in (afterRevision, groundDecalRevision], where the
rolling cursor spans at most 64 global creation/discovery revisions. The server builds that tail
from its revision log in bounded time and applies the same active-player, selected-player-union, or
omniscient projection used by the snapshot; the fast path never sends a mark that perspective has
not discovered. Stable decal ids make repeated/overlapping tails idempotent. A client advances its
complete cache cursor only when it already covers afterRevision; it may display entitled rows
from a gapped tail immediately while requesting the missing range.
requestGroundDecals remains the reliable repair path for late joins, reconnects, seeks,
perspective changes, missed revisions beyond the rolling tail, and renderer/cache recovery. Its
response contains only marks first discovered after afterRevision, or marks created after that
cursor for omniscient views. Full requests from zero rebuild the selected perspective. The client
cache is an optimization: checkpointed server rows, the revision log, and discovery revisions are
the authority.
For normal active-player snapshots, entity visibility and visibleTiles are projected from the
server-authoritative union of current fog grids contributed by living teammates on the recipient’s
team. A defeated/disconnected teammate stops contributing live sight; if that player’s team still
has a living member, their own connection continues to receive the surviving team’s current
visibility. exploredTiles is the cumulative server-owned history of those team-visible tiles; it
is checkpointed and replayed, and clients replace their local exploration grid on every snapshot
instead of accumulating whichever observer perspectives they happened to render. Allied
Smoke suppresses normal sight, but two living units whose positions are both inside smoke gain
mutual actionable visibility when their body-edge gap is at most one tile. This close-quarters
exception exposes the opposing unit and its occupied tile without granting a normal sight radius.
Allied
non-resource entities visible through team current fog expose full read-only
inspection details: hp/state/facing/setup state, production or research kind/progress/queue length,
legacy Scout Plane queue presence, construction progress, gatherer latched node, active Breakthrough
status, per-unit enemy unit and building kill totals, and safe combat tracers. unitsKilled is present on units
only, starts at zero, increments when that unit deals the final hostile damage to another unit or a building,
and does not count friendly fire or resource nodes. The selection panel labels this total “Kills”;
the existing unitsKilled field carries the combined total. Player score rows still track
unitsKilled and buildingsKilled separately.
Tank commanderFacing is the independent roof MG world angle. It is included only for a visible,
non-vision-only Tank when its secondary target is visible to the recipient (or absent); owners and
omniscient observers receive it directly. It never carries a secondary target id.
When the secondary target is absent, its aim follows the cannon and also requires the cannon’s
target-direction visibility gate.
Combat targetId and weaponFacing for allied units are sent whenever an attack-capable entity has
a visible acquired target, including autonomous acquisition while its explicit order state remains
idle. They are omitted when the target is not visible in the recipient’s team-current actionable
fog, so allied units attacking hidden enemies do not reveal hidden target ids or target directions.
setupFacing remains owner/allied setup detail except for an actionable visible deployed enemy
Anti-Tank Gun: that gun projects its fixed emplacement direction because the same direction is
already disclosed by its live threat cone. Clients must orient that cone only from setupFacing,
never from the dynamically tracking body or weaponFacing values.
steel, oil, supply, autoBuild, upgrades, rallies, order plans,
construction activity hints, ability controls/autocast toggles, debug paths, and command authority
remain exact-owner-only in normal active-player and selected-player/team observer projections.
A Tank Trap scaffold belongs to its builder only while construction is in progress. Entity-backed
neutral buildings authored into the selected map begin in every player’s rememberedBuildings
and have their exact footprint set in exploredTiles, so their map-defined position is legible
below fog from match start without granting current vision. Player-built Tank Traps do not receive
this authored-map knowledge. Completion
changes it to owner 0, making it a neutral field obstacle. It grants no owner-private projection:
outside current team vision no player receives its live entity, HP changes, attack alert, or death
event. Any recipient with current vision receives its exact visible HP and ordinary visible impact
feedback. Neutral Tank Traps remain explicit attack/deconstruct targets and vehicle breach targets,
but a shot against one never creates a victim-owner firing reveal or under-attack alert.
worldCombatPosition is the narrow global exception to fog-filtered combat detail. The server sets
the same coarse world point for every active player, spectator, replay, Lab, and dev recipient.
It changes only on 15-tick boundaries after hostile weapon fire/impact activity and remains present
through the last boundary no more than 60 ticks after the most recent activity. The point is the
centroid of distinct combat areas observed during the latest activity tick, snapped to a 32-tile
grid. It intentionally reveals approximate battle direction, but no player, team, entity, weapon,
count, composition, exact position, or live cadence. Clients use it only to pan one generic
constant-gain background combat bed; positional combat events and entities remain fog-filtered.
Full-world diagnostic projections are the explicit exception: they may project those per-entity
planning and setup details through each entity’s real owner so lab/dev inspection overlays are
complete for every player.
Anti-Tank Guns that fire from fog create actionable temporary live fog for the recipients that see
the attack event, except when the resolved shot victim is a Tank Trap. The revealed gun is
projected as a normal non-visionOnly snapshot entity and
can validate direct attack commands or combat target acquisition until the firing reveal expires.
Its reveal-only actionable tile is deliberately omitted from visibleTiles and does not enter
exploredTiles; clients infer the explicit above-fog shotReveal presentation when a projected
enemy unit occupies a presentation-dark tile. This keeps the unit fully legible without clearing
the terrain tile beneath it. An authoritative deployed AT gun presented above fog still draws its
live threat cone from setupFacing. When the reveal expires without ordinary sight, the server
projects its last observed arc in rememberedAntiTankGuns and the client draws the stale
question-mark memory cone instead. Event-only shot ghosts do not provide authoritative live arcs.
The expiration is calculated from the firing tick plus that gun’s firing-cycle cooldown plus
0.5 seconds (TICK_HZ / 2), not from a hardcoded wall-clock duration. The half-second counterfire
reaction applies only while a firing-reveal-stamped tile is the target’s necessary source of
actionable sight;
ordinary live vision takes precedence and bypasses that reaction gate without changing weapon
reload timing. Explicit attacks and autonomous acquisition use team-current ordinary sight for
both legality and reaction bypass. Repeated shots extend one stable reveal
episode, so move orders or transient target switches cannot restart the same episode’s reaction
deadline. Tile-level provenance covers colocated entities and remains tied to the stamped tile when
the firing entity moves before the next fog rebuild.
A unit close-detected within two tiles between hostile body edges is team-shared for one second
after separation and projected normally. A firing-only unit concealed by concealmentTiles is
projected with visionOnly and rendered as the white alpha edge of its current production rig/frame
rather than full-color unit art. Its ordinary damaged-unit HP bar remains visible above fog. Firing
reveal provenance distinguishes concealment from terrain visibility: if the recipient already sees
the ground, visibleTiles remains clear instead of drawing a dark square over the concealment tile.
Artillery Fire creates the same kind of actionable temporary live fog for every enemy player,
subject to normal smoke suppression, when the shell is launched. The reveal exposes the firing gun
as a normal snapshot entity without exposing the target point, its terrain tile, surrounding
terrain, or pre-impact target marker.
Each Rocket Truck barrage launch grants the same 6.5-second actionable firing reveal to every
enemy player and extends the same continuous reveal episode during the four-second unload. A
firing-revealed Rocket Truck appears in world view and on the minimap above presentation fog using
its ordinary unit icon; the reveal does not expose its target point or surrounding terrain.
Lingering death sight is ordinary temporary team sight for five seconds. It makes current
non-owned units/buildings visible as normal entities, contributes to visibleTiles, refreshes
remembered buildings, and can drive command validation and combat auto-acquisition while active.
Ability world
objects are projected separately in abilityObjects: normal players
receive only objects whose world position is visible in their current team fog, while full-world
dev snapshots include every object and spectator/replay snapshots use the existing union vision.
Enemy objects never carry owner-only state, and sourceCasterId is omitted unless the caster is
safe for the recipient or the recipient is an owner/spectator/full-world viewer.
MessagePack compact binary snapshot frames are the live WebSocket snapshot path. Each binary frame
starts with the ASCII magic RTSM, a one-byte snapshot codec version (1), then a MessagePack map
containing the same compact snapshot object shape shown below. The active snapshot codec is
messagepack-compact, codec version 1, compact snapshot version 79. The client also accepts compact
snapshot versions 51 through 62: version 52 only appends a kind code, version 53 appends the
optional unitsKilled entity slot, version 54 appends an optional rocket style bit to mortar
launch/impact event records, and version 55 adds the artilleryIncoming event code, so the older
record layouts remain safe to decode. Version 56 appends optional entity slot 43,
rocketRackCount (0–16). This public physical rack state is included only on already-visible
Rocket Trucks; it reveals neither a private reload timer nor a hidden unit. Sixteen PNG rounds
remain attached while moving, disappear individually in the server launch order, and return when
the existing reload cooldown reaches zero. mortarLaunch.fromX/fromY for rockets are the exact
rotated rack slot centres, not the truck centre. Launch visibility remains owner/team-only.
The client retains the visible shooter owner/facing with each launch for detached team-tinted
projectiles, without inventing or exposing hidden targets.
client/src/net.js calls
parseServerFrame; the binary frame parser in client/src/protocol_frame.js returns the raw
compact snapshot object, then decodeCompactSnapshot expands it back into the semantic object above
before dispatching S.SNAPSHOT.
The rollout is direct and latest-version-only. Reliable non-snapshot messages (welcome, start,
lobby, pong, errors, room/lab/replay control messages, and game over) remain JSON text. The
server does not negotiate stale-client capability and does not maintain a compact JSON fallback mode
for live snapshots; rollback is a normal Git revert of the MessagePack snapshot change. Compact JSON
serialization remains available in local tooling and tests as a historical size baseline, and the
browser can still decode object-shaped JSON snapshots for narrow dev/test use, but that is not the
normal live path.
The live compression diagnostics are report-only. snapshotBytes* fields are browser-delivered
MessagePack application payload measurements after any transport extension would have been decoded
by the browser; they are not compressed wire bytes. snapshotCodec, snapshotCodecVersion, and
snapshotFrameKind identify the active snapshot path for the report window. websocketExtensions
mirrors the bounded browser WebSocket.extensions string, and websocketCompression is a
normalized label that is permessage-deflate only when that extension appears. With the current
Axum 0.8 / Tungstenite 0.29 server stack, direct permessage-deflate negotiation is not available,
so the expected live label is none until a future phase changes the WebSocket implementation or
adds an explicit application compression envelope.
{
"t": "snapshot",
"v": 79,
"gr": groundDecalRevision, // omitted when zero
"gd": [afterRevision, [ // omitted when this tick has no discovered/created revision
[id, decalClass, sourceKindCode, x, y, owner, seed, facing, weaponFacing, radiusTiles]
], [
[trailId, [[xQuarterPx, yQuarterPx, headingI16], ...]]
]],
"s": [tick, steel, oil, supplyUsed, supplyCap],
"ab": [paused, reserveSteel, reserveOil], // omitted when no real player is projected
"e": [
[
id, owner, kind, x, y, hp, maxHp, state,
facing?, weaponFacing?, prodKind?, prodProgress?, prodQueue?,
buildProgress?, latchedNode?, targetId?, setupState?, remaining?, rally?, reservedMovementOil?,
setupFacing?, orderPlan?, chargeCooldownLeft?, abilities?, breakthroughTicks?,
visionOnly?, debugPath?, rallyPlan?, prodUpgrade?, buildActive?, deconstructProgress?,
weaponRangeTiles?, occupiedTrenchId?, scoutPlane?, prodScoutPlaneQueued?,
panzerfaustLoaded?, prodRepeatKinds?, prodWaiting?, breakthroughAuraTicks?, extractorActive?,
prodUpgradeQueue?, panzerfaustWindupProgress?, unitsKilled?, rocketRackCount?, commanderFacing?, insight?, dao?, daoReady?, daoAdvanceTicks?, chosenDao?, tournamentEntrants?, daoTrainingQueue?, daoMaster?, escapeTreasure?, itemRadianceTier?, chargeActive?
]
],
"r": [[id, remaining]], // omitted when empty
"sm": [[id, x, y, radiusTiles, expiresIn]], // omitted when empty
"ao": [[id, owner, ability, kind, x, y, expiresIn?, sourceCasterId?, ownerState?, vector?, fieldSize?]], // abilityObjects; omitted when empty
"tr": [[id, x, y, radiusTiles]], // trenches; omitted when empty
"fg": [firstValue, runLen, ...], // RLE visibleTiles; omitted when empty/no-fog
"eg": [firstValue, runLen, ...], // RLE exploredTiles; omitted when empty/no-fog
"wc": [1024, 2048], // worldCombatPosition; omitted when inactive
"mb": [[id, owner, kind, x, y, [[tileX, tileY], ...], observedTick]], // rememberedBuildings; omitted when empty
"ma": [[id, owner, x, y, facing, observedTick]], // rememberedAntiTankGuns; omitted when empty
"ev": [EventRecord], // omitted when empty
"pf": [[id, factionId]], // public seat identities; omitted when empty
"pr": [[id, steel, oil, supplyUsed, supplyCap, apm, [upgradeCode...]]], // projected observer playerResources; omitted when empty
"n": [serverLagMs, tickMs, flags, slowTickCount, headOfLineCount,
predictionVersion?, lastSimConsumedClientSeq?, lastSimConsumedClientTick?]
}
Compact numeric codes:
| Vocabulary | Codes |
|---|---|
kind | 1 worker, 2 rifleman, 3 machine_gunner, 4 anti_tank_gun, 5 tank, 6 resource_depot, 7 depot, 8 barracks, 9 training_centre, 10 factory, 11 steel, 12 oil, 13 steelworks, 14 scout_car, 15 mortar_team, 16 artillery, 17 engineering_complex, 18 command_car, 19 ekat, 20 zamok, 21 tank_trap, 30 barbed_wire, 22 golem, 23 pump_jack, 24 panzerfaust, 25 scout_plane, 26 steel_mine, 27 rocket_launcher, 28 portal, 29 warrior, 31 three_dao_pavilion, 32 tournament_grounds, 33 proven_grounds, 34 shop, 35 wind_adept, 36 war_adept, 37 magic_adept, 38 healing_seal, 39 shop_delivery, 40 technique_library, 41 bow_novice |
state | 1 idle, 2 move, 3 attack, 4 gather, 5 build, 6 train, 7 construct, 8 dead |
setupState | 1 packed, 2 setting_up, 3 deployed, 4 tearing_down |
orderStage | 1 move, 2 attackMove, 3 attack, 4 gather, 5 build, 6 smoke, 7 setupAntiTankGuns, 8 charge, 9 mortarFire, 10 pointFire, 11 breakthrough, 12 ekatTeleport, 13 ekatLineShot, 14 ekatMagicAnchor, 15 deconstruct, 16 ekatConsumeGolem, 17 blanketFire, 18 dismissScoutPlane, 19 scoutPlane, 20 holdPosition, 21 barrage, 22 evolveWind, 23 evolveWar, 24 evolveMagic, 25 discipleShield, 26 throwSword, 27 regen, 28 escapeTreasure, 29 windDash, 30 healingSeal, 31 haste, 32 doubleDamage, 33 armorTreasure, 34 vitalityTreasure, 35 vectorField, 36 repair, 37 doubleXp, 38 breakthroughTreasure |
ability | 1 charge, 2 smoke, 3 mortarFire, 4 pointFire, 5 breakthrough, 6 ekatTeleport, 7 ekatLineShot, 8 ekatMagicAnchor, 9 ekatConsumeGolem, 10 blanketFire, 11 dismissScoutPlane, 12 scoutPlane, 13 barrage, 14 evolveWind, 15 evolveWar, 16 evolveMagic, 17 discipleShield, 18 throwSword, 19 regen, 20 escapeTreasure, 21 windDash, 22 healingSeal, 23 haste, 24 doubleDamage, 25 armorTreasure, 26 vitalityTreasure, 27 vectorField, 28 doubleXp, 29 breakthroughTreasure |
abilityObject.kind | 1 returnMarker, 2 magicAnchor, 3 lineProjectile, 4 shield, 5 vectorField |
upgrade | 1 methamphetamines, 2 anti_tank_gun_unlock, 3 tank_unlock, 4 artillery_unlock, 7 ballistic_tables, 8 entrenchment, 9 smoke_plus, 10 panzerfausts, 11 scout_plane_unlock, 12 rockets, 13 tank_plus, 14 dao_wind, 15 dao_of_magic, 16 dao_of_heaviness, 18 technique_charge, 19 technique_blink, 20 technique_shield, 21 technique_throw_sword |
weaponKind | 1 worker_tools, 2 golem_fists, 3 rifleman_rifle, 4 machine_gunner_mg, 5 scout_car_mg, 6 anti_tank_gun, 7 panzerfaust_loaded_shot, 8 mortar_team_mortar, 9 artillery_gun, 10 tank_cannon, 11 tank_coax, 12 warrior_sword, 13 disciple_arrow, 14 disciple_orb |
notice.severity | 1 info, 2 warn, 3 alert |
EventRecord | [1, from, to] attack, [1, from, to, reveal?, toPos?] legacy attack with optional shooter reveal and target position, [1, from, to, revealOrNull, toPosOrNull, weaponKind] attack with compact weapon hint, [2, id, x, y, kind] death, [3, id, kind] build, [4, msg] notice, [4, msg, severity] position-free notice with severity, [4, msg, severity, x, y] positioned notice, [5, [fromX, fromY], [toX, toY], delayTicks] smoke launch, [6, x, y, radiusTiles] mortar impact/marker, [6, x, y, radiusTiles, from?, reveal?] mortar impact with optional shooter reveal, [7, from, [x, y], radiusTiles, delayTicks] artillery target marker, [8, x, y, radiusTiles] artillery impact, [9, from, [fromX, fromY], [toX, toY], radiusTiles, delayTicks] mortar launch, [11, owner, x, y, facing] global artillery firing minimap marker, [12, from, [fromX, fromY], [toX, toY], delayTicks] Panzerfaust launch, [13, x, y] Panzerfaust impact, [15, to] missed direct shot (14 removed with conversion) |
2.4.1 Boundary inventory
This inventory records the current source-of-truth map after the protocol mirror split. It does not
change the wire shape or compact snapshot version. Public lab catalog, import, export, and authoring
validation errors use checkpoint setup terminology; legacy LabScenario wire and type names remain
compatibility internals.
| Value/path | Rust owner | JS mirror path | Category | Current checker | Proposed future checker | Client-only exclusion reason | Compact version impact |
|---|---|---|---|---|---|---|---|
ClientMessage, ServerMessage, Command, HTTP lobby browser/create endpoints, HTTP lab setup catalog endpoint, HTTP map handoff endpoints, lobby/replay/branch message tags and fields | server/crates/protocol/src/client_message.rs, server/crates/protocol/src/server_message.rs, and server/crates/protocol/src/lib.rs; lobby/lab catalog/map-handoff HTTP route handlers in server/src/main.rs and server/src/map_handoffs.rs; lab catalog source of truth in server/src/lab_scenarios.rs; room-task summaries in server/src/lobby/** | client/src/protocol.js C, S, CMD, msg.*, decodeServerMessage; client/src/lab_catalog.js consumes the HTTP lab catalog; client/src/map_editor_handoff.js consumes the map handoff API; future internal client/src/protocol_*.js or client/src/protocol/** files must re-export through client/src/protocol.js | wire/HTTP DTO | tests/protocol_parity.mjs compares the structured Rust protocol contract dump to JS tags/builders/decoder and asserts stable JS public exports; serde compile/tests plus rts-protocol public-surface integration coverage guard Rust export names; focused server tests cover lobby summary, create-lobby behavior, lab catalog loading, and map handoff binding | Remaining source-text checks for DTO/lobby assertions outside the current dump scope | Lab catalog rows and map handoff records are HTTP metadata, not mirrored through protocol.js; their app-owned clients validate response shapes | No compact bump unless a compact snapshot slot/code changes; normal JSON message changes still require Rust, JS, and docs together |
| Semantic start/snapshot/replay/analysis DTOs | server/crates/contract/src/lib.rs, re-exported by server/crates/protocol/src/lib.rs | client/src/protocol.js decoder output consumed by client modules | wire DTO | tests/protocol_parity.mjs fixture decodes selected compact fields; Rust serde tests cover local serialization | Structured contract/schema dump for semantic DTO fields plus compact round-trip fixtures | None; JS is a protocol mirror | Compact bump only when the live compact representation changes |
terrain codes | server/crates/protocol/src/contract_metadata.rs terrain, re-exported by lib.rs; adapter test checks rules terrain constants | client/src/protocol_constants.js TERRAIN and PASSABLE, re-exported by client/src/protocol.js | wire DTO / compact transport code | tests/protocol_parity.mjs extracts Rust terrain codes | Structured protocol constants dump | None | No compact snapshot bump today; terrain is in the start.map.terrain payload, not the compact snapshot frame |
kinds strings, KIND, UNIT_KINDS, BUILDING_KINDS, RESOURCE_KINDS | server/crates/protocol/src/contract_metadata.rs kinds, re-exported by lib.rs; domain identity is rts-rules::EntityKind::stable_id() | client/src/protocol_constants.js KIND, UNIT_KINDS, BUILDING_KINDS, RESOURCE_KINDS, re-exported by client/src/protocol.js | wire DTO plus domain adapter grouping | tests/protocol_parity.mjs checks kind code mapping; adapter tests round-trip every EntityKind; catalog parity checks many kind references | Structured protocol constants dump plus catalog export that classifies unit/building/resource groups | None | Bump only if compact kind codes or compact slots change; append-only codes otherwise |
server/src/protocol.rs and server/crates/sim/src/protocol.rs kind conversion | Rules/sim-aware adapter modules | No direct JS mirror beyond the protocol kind strings | domain adapter mapping | Rust adapter tests in both modules | One shared rules-aware adapter path with a single round-trip test | Not client data | No compact impact unless output kind strings/codes change |
states, SETUP, NOTICE_SEVERITY, VISION_SELECTION, WEAPON_KIND, and event discriminators | server/crates/protocol/src/contract_metadata.rs string vocabulary; compact event serialization lives in server/crates/protocol/src/compact_snapshot.rs | client/src/protocol_constants.js constants, re-exported by client/src/protocol.js; compact decoder lives in client/src/protocol_snapshot.js behind decodeServerMessage | wire DTO / compact transport code | tests/protocol_parity.mjs checks state, setup, notice severity, weapon kind, and event compact codes; selected decoder fixtures | Structured protocol constants and compact event-shape dump | None | Bump when compact event/entity slots change |
COMPACT_SNAPSHOT_VERSION, PREDICTION_PROTOCOL_VERSION, compact top-level keys, optional entity slots, limits, and net status slots | server/crates/protocol/src/contract_metadata.rs owns versions and slot metadata; server/crates/protocol/src/compact_snapshot.rs compact serializer; server/crates/protocol/src/messagepack_frame.rs frame writer | client/src/protocol_constants.js COMPACT_SNAPSHOT_VERSION and MAX_COMPACT_* limits; client/src/protocol_snapshot.js compact decoder; client/src/protocol_frame.js binary frame parser | compact transport code | tests/protocol_parity.mjs source-text version checks and fixture decode | Structured compact schema dump including slot names, order, caps, and version | None | Direct owner of compact version; slot/order changes require bump unless strictly optional trailing additions preserve decoder compatibility by explicit decision |
| Compact code tables for kind, state, setup, order stage, ability, ability object kind, upgrade, weapon kind, notice severity, and event records | server/crates/protocol/src/contract_metadata.rs code tables and code functions; compact event serializer lives in server/crates/protocol/src/compact_snapshot.rs | client/src/protocol_constants.js *_CODE and reverse-code maps, re-exported through client/src/protocol.js where public; compact record decoder lives in client/src/protocol_snapshot.js | compact transport code | tests/protocol_parity.mjs extracts Rust functions/events and rejects duplicate or 255 real codes | Structured protocol constants dump generated from Rust instead of source scraping | None | 255 remains unknown/sentinel; real codes must not use it. New codes should append without reusing old values; incompatible reorder/removal requires compact version bump |
| Ability and upgrade ids in command/research/snapshot payloads | Typed identities and stable ids in server/crates/rules/src/faction.rs; intentional wire constants/codes mirror in server/crates/protocol/src/contract_metadata.rs | client/src/protocol_constants.js ABILITY, UPGRADE, ABILITY_CODE, UPGRADE_CODE, re-exported by client/src/protocol.js; command-card descriptors in client/src/config.js | domain identity plus wire DTO, compact transport code, faction catalog fact | Rust adapter tests check every rules-owned id against protocol vocabulary and compact-code coverage; tests/protocol_parity.mjs checks protocol ids/codes; scripts/check-faction-catalog-parity.mjs checks catalog-exposed ability codes and descriptors | Structured protocol dump plus complete faction catalog dump | None where mirrored from Rust; catalog descriptors are not UI-only when exported by Rust | Code/order changes can require compact bump; descriptor-only changes do not |
DEFAULT_FACTION_ID | server/crates/contract/src/lib.rs, re-exported by protocol | client/src/protocol.js | wire DTO / faction catalog fact | tests/protocol_parity.mjs; scripts/check-faction-catalog-parity.mjs checks default catalog id | Structured contract/catalog dump | None | No compact impact |
PLAYER_PALETTE lobby colors | server/src/lobby/mod.rs assigns authoritative lobby/start colors | client/src/config.js fallback palette | server-owned presentation data mirrored by client | tests/protocol_parity.mjs source-scrapes the Rust palette | Structured lobby/config dump | Not client-only because server sends assigned colors; JS is fallback/render mirror | No compact impact |
Compact entity records are positional arrays. Optional fields keep the semantic order above and
trailing missing optional fields are omitted; interior missing optional fields are encoded as
null. The rally slot is itself a two-element [x, y] array (or null).
The orderPlan slot is an owner-private array capped at 33 entries (one active stage plus 32 queued orders): exact-owner in normal and
selected observer projections, and per-entity-owner in full-world diagnostic projections. It contains
the current active stage first, followed by queued unit stages in execution order. Artillery Fire
stages carry the server-stored clicked center; the
selected radius is server-owned order state but is not projected in this compact stage. Clients may temporarily merge local pending
move/setup/fire stages for preview continuity while waiting for command acknowledgement, but the
snapshot orderPlan is the only authoritative queued-plan contract and stale local previews must
reconcile to it. Each compact stage is [kind, x, y], where kind uses the orderStage compact
code table above. Build stages append a fourth buildingKind kind code, forming
[kind, x, y, buildingKind]; other stages retain three fields.
Tank Point stores a heading rather than a destination and is omitted from these positional markers.
Stages carry safe world points only, never target ids; hidden attack target stages may be omitted
rather than leaking enemy positions through fog. Production building rally points are exposed
separately through rally and rallyPlan and are not part of orderPlan. rallyPlan is appended
after debugPath in compact snapshots to preserve older optional slot positions; it follows the
same owner-private projection policy, is capped at four stages, and uses the same [kind, x, y]
compact stage encoding for point rallies with move and attackMove stages; line rallies
append a null building-kind slot and a bounded array of vertex pairs.
The abilities slot is owner-only and capped at 16 entries. Each compact ability cooldown is
[ability, cooldownLeft, remainingUses?, autocastEnabled?, activeObjectId?, availableTick?, lockoutUntilTick?, expiresIn?, chargeRechargeLeft?],
where ability uses the ability compact code table above. Novices project charge with
their authoritative passive cooldown (zero when ready) and autocastEnabled: true. The disabled
Charge tile cannot be cast or toggled; manual charge commands remain no-ops.
The server projects ability affordances only when the owning player’s faction catalog exposes that
ability for the entity’s global kind and the registry marks it for command-card exposure. Artillery
projects one pointFire-backed Fire affordance for selected owning clients; the blanketFire
catalog row remains as the hidden order implementation for the unified command.
Scout Car smoke remains visible but disabled until the owner has a completed Engineering Complex. The
server checks that building requirement when a Smoke command is issued and again when a queued
Smoke order promotes, so losing the Engineering Complex relocks the ability.
remainingUses is present for charged or finite-use abilities; a value of 0 means the ability
cannot currently be used by that caster. Scout Car Smoke projects its current 0-to-2 charge count;
its authoritative sequential recharge restores one missing charge every 15 seconds.
chargeRechargeLeft is owner-private and present while a charged ability is regenerating. It is
the authoritative ticks remaining for the next charge and drives the command card’s existing clock
animation independently of activation cooldown readiness.
autocastEnabled reports automatic activation state, including the always-automatic Novice Charge
indicator and the toggleable Escape Treasure item.
activeObjectId, availableTick, and expiresIn are owner-only per-caster affordance fields for
two-stage or persistent ability state such as Ekat’s return marker, Magic Anchor, and the active
Breakthrough aura duration on the casting Command Car. lockoutUntilTick is available for
owner-only ability lockouts; Magic Anchor does not currently use a destruction lockout because the
anchor is not attackable.
breakthroughTicks is present only while the affected visible unit has active Breakthrough speed
status; it is not caster identity. breakthroughAuraTicks is present only on a visible casting
Command Car while its authoritative aura remains active, so renderers can keep the bright radius
visible without selection or owner-private ability affordances. Owner snapshots also expose the
Command Car’s breakthrough
ability cooldown and, while the caster’s aura is active, its caster-only expiresIn through
abilities.
weaponRangeTiles is present for owner/allied Tank views and carries the current authoritative
default-weapon range, including the stationary range ramp. Enemy views omit it; static unit catalog
range remains the fallback for render-only range overlays.
occupiedTrenchId is present while a visible eligible infantry unit is actively stopped in a
trench. It names the neutral trench terrain id already projected through trenches; it is omitted
while the unit is digging in, slotting is unavailable, merely near a trench, or moving out.
panzerfaustLoaded is present for visible Panzerfaust units. It is true until launch and false
for the rest of that unit’s lifetime after launch, so the client swaps from loaded launcher art to
normal Rifleman art. It is omitted for Riflemen and all other entities.
panzerfaustWindupProgress is present only while a visible Panzerfaust is in its cancellable loaded
shot wind-up. It is an authoritative normalized 0..1 value using that owner’s actual 15-tick
wind-up, or 12 ticks with Methamphetamines, so renderers can select wind-up frames without receiving
private upgrade state. unitsKilled is the optional trailing compact entity slot added in compact
snapshot version 53. Versions 51 and 52 omit that slot and decode the field as absent. Compact
version 54 additionally permits a trailing rocket: true style bit on mortar launch and impact
records; rocket impacts retain null attacker/reveal placeholders so the style bit always occupies
its unambiguous trailing slot. The decoder also accepts the brief placeholder-free version-54
shape. The bit changes presentation only, while damage and fog remain authoritative.
scoutPlane is owner/full-world diagnostic private state for scout_plane entities. It carries
the current orbit center and source Command Car id; enemy projections that can see the plane omit
this state. Scout Plane
entities are not selectable or commandable by normal clients, and runtime movement is driven by the
server-side Command Car ability lifecycle.
visionOnly is a special projection flag for non-owned render-only intel rather than normal
visibility. Concealment firing reveals use it to select outline-only above-fog presentation. Current
lingering death sight is ordinary temporary team sight and does not set it. Clients must not select
visionOnly entities.
In n.flags, bit 0 = slowTick and bit 1 = headOfLine.
The optional compact n prediction fields are present only for live active player snapshots.
Spectators, replay viewers, and dev full-world viewers omit prediction acknowledgement metadata.
debugPath is present only when the room’s projection policy enables movement-path diagnostics for
that recipient and only while the unit has remaining movement waypoints. Dev scenario rooms may
enable full projected movement paths. It carries { waypoints, goal, lastRepathTick, stuckTicks, staticBlockedTicks, totalWaypoints }, where waypoints are remaining {x, y} world-pixel path
points in traversal order and waypoints[0] is the current movement target. The compact slot
encodes this as
[waypoints, goal, lastRepathTick, stuckTicks, staticBlockedTicks, totalWaypoints], with points
encoded as [x, y]; waypoints is capped at 128 entries for transport.
AbilityObject: { id, owner, ability, kind, x, y, expiresIn?, sourceCasterId?, ownerState? }.
The compact ao slot uses ability ids from the existing ability code table and
abilityObject.kind codes from the table above. ownerState is owner/spectator/full-world data (except Shield HP, maximum HP, duration and radius, which are public whenever the field is visible)
encoded as [earliestReturnTick?, hp?, radius?, destroyedLockoutTicks?, distanceTraveled?, ticksOut?, maxHp?, durationTicks?].
Magic Anchor currently fills only radius; the hp and destroyed-lockout slots are retained as
optional compact slots for compatibility.
Normal enemy snapshots receive only the public object fields needed to render a marker at a visible
position.
Trench: { id, x, y, radiusTiles }. Trenches are neutral persistent battlefield terrain, not
buildable entities, and do not carry an owner field. The id is stable for the trench lifetime,
x/y are the world-pixel center, and radiusTiles is the footprint/render radius used by later
slotting and rendering code. Normal active-player snapshots include trenches whose footprint is in
that recipient’s current living-team fog, plus trench terrain the recipient has already discovered.
Spectator, replay, and lab selected-perspective snapshots use the selected real players’ current
fog and discovered terrain memory; full-world dev snapshots include every trench. Remembered
trench terrain is terrain-only: it exposes no creator, owner, occupant, or current hidden unit
state. Clients treat each snapshot’s trenches field as the complete current trench-terrain set
for that recipient; a missing or empty field clears prior client trench terrain. Rendering uses the
snapshot data below fog, so reconnects, replay seeks, and fog-memory refreshes restore trench ground
from the server instead of from local visual history.
RememberedBuilding: { id, owner, kind, x, y, footprint, observedTick }. These records are
recipient-only last-seen enemy building memory, refreshed from team-current actionable observations
and sent only when the building is not currently projected as a live visible entity. They are stale
intel for normal building rendering below the fog overlay and coordinate targeting context; clients
must not make them selectable live entities or issue entity-targeted commands against them.
footprint is an array of [tileX, tileY] cells from the last visible state. The record
intentionally omits hidden live HP, current build progress, and destruction state. Artillery Fire
remains a world-coordinate ability; remembered buildings help the player know where to aim but do
not become target ids. Its selected radius and server-authoritative clicked center do not make
remembered buildings target ids.
Union views build remembered buildings from the selected real
players’ memory stores. When the building’s owner is selected, its knowledge of destruction
suppresses other selected players’ stale memories even if the footprint is currently hidden.
Tank Traps are excluded from this inference because their scaffold ownership expires on completion;
their memories still require observed-empty knowledge to clear.
Selecting only opponents preserves their independent last-seen intel. If more than one selected player has stale memory for the same building id,
the server sends one record: the newest observedTick wins, with selected-player order as the
deterministic tie-breaker. The server also retains per-player, checkpointed clear ticks when a
remembered footprint is observed empty while another player’s stale positive memory remains. A
selected player’s clear at or after the newest positive observation suppresses that building from
the union even after current vision leaves, preventing older selected-player memory from
resurrecting destroyed buildings. Clears with no remaining positive memory are discarded. Clear
ticks remain internal; the wire continues to carry only positive RememberedBuilding rows. This
keeps one-player replay vision isolated to that player’s memory without adding a memory-source wire
field.
ResourceDelta: { id: u32, remaining: u32 }. Static positions/kinds come from
start.map.resources; last-observed amounts and explicit zero/depletion records are owned by the
simulation, per player, and included in checkpoints and replay keyframes. Resource memory retains
static kinds and positions after depletion so mid-match start payloads still describe every remembered
patch, including patches absent from the current world. Public initial amounts
are seeded once at match start. Each tick updates only resources on that player’s living-team
visible tiles, including visible absence after depletion. Hidden mining never updates that player’s
knowledge. A selected-player union takes the newest observation per resource; ties prefer the lower
remaining amount. Omniscient projection reads current quantities without changing player memories.
Internal snapshots contain the complete selected resource projection with resourceReset: true.
The connection writer sends a complete replacement baseline on first delivery, match start, replay
seek, and perspective change (resourceReset: true, compact rr: true), then diffs each complete
projection against the last snapshot taken for delivery. Ordinary snapshots omit unchanged resource
rows and the reset flag. Latest-only pending snapshots remain complete, so coalescing cannot lose a
resource change or a replacement baseline before socket encoding. Once encoded, resource rows
are incremental: a client-side buffer cannot treat the entire snapshot as latest-only. It must
retain the last replacement marker and fold subsequent resource rows by id alongside the latest
complete entity/fog view. A newer replacement discards all prior pending rows, including explicit
zeros from another time or perspective. Buffering must begin before asynchronous startup work;
loading must not discard the first baseline. Replacement epochs are connection-local transport state,
not simulation knowledge. The reset flag, resource rows, fog, and building views share one snapshot.
Clients clear their resource display on replacement and apply the supplied rows; they never infer
resource depletion from missing deltas, death effects, visibility, or the initial map. Seeking and
changing observer selection cannot carry knowledge from another time or perspective.
SmokeCloud: { id: u32, x: f32, y: f32, radiusTiles: f32, expiresIn: u16 }. Smoke clouds are
neutral world effects, not entities. radiusTiles and expiresIn reflect the cast-time smoke
rules, including completed smoke_plus research. Normal player snapshots include only clouds that
have at least one currently visible tile after smoke-suppressed team fog is recomputed, plus any
cloud currently containing one of that player’s allied non-resource entities; spectator/dev full-world
snapshots may include all active clouds. Smoke-covered enemy units/buildings, target ids, death
events, and positioned notices remain fog-gated and are withheld when smoke hides the position.
Entity (lean; omit fields that don’t apply):
{
id: u32,
owner: u32, // 0 = neutral (resources/completed Tank Traps), else player id
kind: string, // EntityKind: "worker","golem","rifleman","panzerfaust","machine_gunner","anti_tank_gun","mortar_team","artillery","rocket_launcher","scout_car","scout_plane","tank","command_car","ekat","resource_depot","portal","three_dao_pavilion","zamok","depot","barracks","training_centre","engineering_complex","factory","steelworks","tank_trap","steel_mine","pump_jack"
x: f32, y: f32, // world px (center)
hp: u32, maxHp: u32,
state: string, // "idle","move","attack","gather","build","train","construct","dead"
facing?: f32, // radians, for unit body/hull orientation (optional)
weaponFacing?: f32, // radians, for independent weapon/barrel orientation (optional)
insight?: u32, // public Disciple 0..60 before evolution, 0..200 after, compact slot 45
dao?: "wind"|"war"|"magic", // evolved Disciple, compact slot 46
daoReady?: bool, // public maximum-insight readiness, slot 47
daoAdvanceTicks?: u16, // public realm burst, 1..15 ticks, slot 48
chosenDao?: "wind"|"war"|"magic", // team-private pending evolution, slot 49
commanderFacing?: f32, // Tank roof MG world angle; compact entity slot 44
// production buildings:
prodKind?: string, // unit currently being produced
prodUpgrade?: string, // upgrade currently being researched
prodUpgradeQueue?: string[], // owner/allied; ordered authoritative research queue
prodProgress?: f32, // 0..1
prodQueue?: u32, // queued count (including the in-progress one)
prodRepeatKinds?: string[], // owner/allied; ordered standing unit list for an empty queue
prodScoutPlaneQueued?: bool, // owner/allied; true if any queued item is a Scout Plane
// buildings under construction:
buildProgress?: f32, // 0..1; when present and <1, render as scaffolding
buildActive?: bool, // owner-only; true when server advanced this scaffold this tick
extractorActive?: bool, // visible completed Pump Jack is currently extracting
// Tank Trap deconstruction:
deconstructProgress?: f32, // 1..0 remaining dismantle progress; render reverse progress bar
// gatherers:
latchedNode?: u32, // node id the Worker/Golem is currently harvesting (attached mining)
// combat feedback:
targetId?: u32, // current attack target, for drawing tracers
weaponRangeTiles?: f32, // owner/allied Tanks only; current authoritative weapon range
occupiedTrenchId?: u32, // visible eligible infantry only while actively stopped in a trench
rocketRackCount?: u8, // 0–16 physical rounds; visible Rocket Trucks only
panzerfaustLoaded?: bool, // Panzerfaust units only; false after disposable launch
panzerfaustWindupProgress?: f32,// Panzerfaust wind-up only; authoritative normalized 0..1 timing
scoutPlane?: { // owner/full-world diagnostics only; enemies omit this private state
orbitCenter?: [f32, f32],
sourceCommandCar?: u32
},
setupState?: string, // machine_gunner/anti_tank_gun/artillery only:
// "packed","setting_up","deployed","tearing_down"
// unit-producing buildings:
rally?: [f32, f32], // first rally point (world px); owner-private except full-world diagnostics
rallyPlan?: [ // building rally stages; owner-private except full-world diagnostics
{ kind: "move"|"attackMove", x: f32, y: f32 }
],
// compact slot 19 remains null after retirement of movement-oil telemetry
setupFacing?: f32, // anti_tank_gun/artillery only: owner/allied deployed arc center; compact slot 20
orderPlan?: [ // current + queued order stages; owner-private except full-world diagnostics
{ kind: "move"|"attackMove"|"holdPosition"|"attack"|"gather"|"build"|"repair"|"deconstruct"|"smoke"|"mortarFire"|"pointFire"|"blanketFire"|"breakthrough"|"scoutPlane"|"dismissScoutPlane"|"ekatTeleport"|"ekatLineShot"|"ekatMagicAnchor"|"ekatConsumeGolem"|"barrage"|"setupAntiTankGuns", x: f32, y: f32, buildingKind?: string }
],
chargeCooldownLeft?: u16, // legacy; no longer projected by current server
abilities?: [ // owner-only ability affordance/cooldown data
{ ability: "smoke"|"mortarFire"|"pointFire"|"blanketFire"|"breakthrough"|"scoutPlane"|"dismissScoutPlane"|"ekatTeleport"|"ekatLineShot"|"ekatMagicAnchor"|"ekatConsumeGolem"|"barrage",
cooldownLeft: u16, remainingUses?: u16, autocastEnabled?: bool,
activeObjectId?: u32, availableTick?: u32, lockoutUntilTick?: u32, expiresIn?: u16 }
],
breakthroughTicks?: u16, // active Breakthrough speed status; visible only with the entity
breakthroughAuraTicks?: u16, // casting Command Car only; active aura duration, visible with caster
visionOnly?: bool, // legacy/special render-only intel; current death vision does not set this
debugPath?: { // diagnostic policy only; remaining movement path; owner-only unless policy says full projected diagnostics
waypoints: { x: f32, y: f32 }[],
goal?: { x: f32, y: f32 },
lastRepathTick: u32,
stuckTicks: u16,
staticBlockedTicks: u16,
totalWaypoints: u16
},
}
2.5 Event (transient, one snapshot only)
{ e: "attack", from: u32, to: u32,
reveal?: { owner: u32, kind: string, x: f32, y: f32, facing?: f32, weaponFacing?: f32, setupState?: string },
toPos?: [f32, f32],
weaponKind?: "worker_tools"|"golem_fists"|"warrior_sword"|"disciple_arrow"|"disciple_orb"|"rifleman_rifle"|"machine_gunner_mg"|"scout_car_mg"|"anti_tank_gun"|"panzerfaust_loaded_shot"|"mortar_team_mortar"|"artillery_gun"|"tank_cannon"|"tank_coax" } // feedback hint; unknown/missing hints fall back to attacker kind
{ e: "miss", to: u32 } // direct shot missed the target; no position
{ e: "death", id: u32, x: f32, y: f32, kind } // for death poofs
{ e: "build", id: u32, kind: string } // building completed
{ e: "smokeLaunch", fromX: f32, fromY: f32, toX: f32, toY: f32, delayTicks: u32 }
{ e: "mortarLaunch", from: u32, fromX: f32, fromY: f32, toX: f32, toY: f32, radiusTiles: f32, delayTicks: u32, rocket?: bool }
{ e: "mortarWarning", x: f32, y: f32, radiusTiles: f32, delayTicks: u32 }
{ e: "mortarImpact", from?: u32, x: f32, y: f32, radiusTiles: f32,
reveal?: { owner: u32, kind: string, x: f32, y: f32, facing?: f32, weaponFacing?: f32, setupState?: string }, rocket?: bool }
{ e: "artilleryTarget", from: u32, x: f32, y: f32, radiusTiles: f32, delayTicks: u32 }
{ e: "artilleryIncoming", x: f32, y: f32, delayTicks: u32 }
{ e: "artilleryFiring", owner: u32, x: f32, y: f32, facing: f32 }
{ e: "artilleryImpact", x: f32, y: f32, radiusTiles: f32 }
{ e: "panzerfaustLaunch", from: u32, fromX: f32, fromY: f32, toX: f32, toY: f32, delayTicks: u32 }
{ e: "panzerfaustImpact", x: f32, y: f32 }
{ e: "notice", msg: string, severity?: "info"|"warn"|"alert", x?: f32, y?: f32 }
Notices default to severity: "info" with no position. alert:-prefixed notice ids are
gameplay alerts: active-player clients play alert audio and ping the minimap at (x, y) when
present, or pulse the minimap border when absent. Replay viewers and live spectators keep the visual
alert feedback but suppress notice alert audio. alert:under_attack is emitted at the damaged enemy
unit’s position to the victim owner only; same-team recipients may still see the attack event through
shared vision, but they do not receive teammate under-attack alerts. Same-team friendly-fire damage
does not emit under-attack alerts. notice:artillery_steel_shortage identifies artillery-ammo
shortages so clients can render the ordinary “Not enough steel” feedback while throttling only that
automatic retry source; ordinary Not enough steel notices remain unthrottled. Unit attack events
are sent to the attacker’s team and to enemy
recipients whose team can currently see the shooter or target point. Shots resolved against Tank
Traps carry no shooter reveal and grant no actionable firing reveal to observers of the impact. A
missed direct shot
additionally emits a miss event to the same recipient set, carrying only the receiving entity id;
clients anchor the tiny text feedback to the already projected entity and ignore the event if the
target is absent. Attack events include reveal so a shooter
that fires from fog can be rendered briefly as a semi-transparent, non-interactive silhouette above
the fog overlay; Anti-Tank Gun reveals additionally become the actionable snapshot visibility
described in §2.4. toPos lets tracers draw even when the hit target is no longer in the snapshot.
weaponKind is a closed, fog-safe feedback hint for attack events that would already be projected;
current default direct-fire attacks emit their default weapon id, Tanks emit tank_cannon, and
artillery self-reveal attacks emit artillery_gun. Clients must tolerate missing or unknown
weapon ids by falling back to the legacy attacker-kind feedback path. Direct shots damage only
the resolved victim and draw no tracer continuation past it. Compact event code 10 is retired.
Full-world dev-watch projections attach a deterministic
deduplicated union of the per-player event buckets so transient effects match the exposed world
state. Normal active-player views keep player-only event delivery. Live spectators and selected
player/team replay or lab views union only the real-player buckets selected by the view. Live
spectator event unions filter per-player, position-free, non-alert notices such as command
rejections or economy toasts; room-owned recipient notices, including late-spectator joins, are
appended separately after projection.
When a normal live match accepts a mid-match spectator attach, the server queues a position-free
info notice for every already-connected active player and spectator: <name> has joined the match as a spectator. The joining spectator is excluded. The name comes from the server-sanitized join name
with control-only/empty results displayed as Commander; the message is a normal notice event
without an alert: prefix. Delivery is one-shot on each recipient’s next live snapshot. If the match
is live-paused, snapshot fanout is skipped and the notice remains queued until the next emitted live
snapshot after unpause.
Death events are sent to the dead entity’s team and to enemy recipients whose team can currently see
the death position; smoke-covered hidden death positions are withheld. Build completion events are
sent to the completed building’s team and to enemy recipients whose team currently sees the site.
Smoke launch events are team-visible local feedback for the scout-car canister animation; enemies
do not receive hidden smoke launch data. The authoritative smoke cloud appears later in smokes
after the reported launch delay. Mortar launch events are always sent to the firing team, with
shooter id, shell origin, impact point, radius, and delay so clients can draw launch dust, recoil,
the projectile, and the warning marker until detonation. Mortar launch events are withheld from
all enemy recipients. Instead, enemies with team-current visibility at the landing point receive
mortarWarning { x, y, radiusTiles, delayTicks } at launch. This draws the same pre-impact circle
without a shooter id, origin, trajectory, launch dust, or recoil. Hidden landing points receive no
warning. Rocket barrages do not emit this warning. Compact event code 16 encodes this as
[16, x, y, radiusTiles, delayTicks]. Mortar impact events are sent to the firing team and to enemy recipients
with team-current visibility at the impact point, plus enemy players whose entities were damaged by
the shell. An enemy damaged victim
owner receives from + reveal so the attacking mortar can be shown briefly above fog after
indirect fire lands. Allied or owned entities can still take mortar splash damage, but that damage
is unattributed and does not reveal the firing mortar as hostile. Enemy players do not receive
hidden mortar launch data or hidden mortar impact markers unless their entities were hit or their
team sees the relevant point.
Artillery target events are sent to the firing team so enemies never receive the firing-side
pre-impact marker or shooter id, even if they have vision of the gun. Fire reports the final
deterministic shell target after the uniform selected-area sample, not the raw clicked center. The
from id lets allied clients recoil the specific gun and draw launch
dust. Enemy players whose team currently sees the final target point instead receive an
artilleryIncoming event containing only that point and the remaining delay. It exists solely to
schedule the spatial incoming-whistle-and-impact cue; it does not create a target marker, identify
the gun, reveal terrain, or update exploration. Every player receives a visual-only
artilleryFiring event with the firing owner, shooter
position, and facing so the minimap can show a small global artillery firing marker; it does not
carry the shooter entity id, target point, terrain, or exploration. Separately, the server grants
every enemy player actionable temporary live fog on the firing gun, subject to normal smoke
suppression, so it is projected as a normal world entity and can be targeted during the firing
reveal window.
Enemy players also receive a visual-only attack event with a shooter reveal when their team
currently sees the firing gun, so the gun can be shown briefly without revealing terrain,
exploration, or the target point. Artillery impact events are sent to the firing team and to enemy
recipients whose team currently sees the impact point; they do not reveal terrain, update
exploration, or carry entity visibility. Artillery impact damage follows the same support-fire
friendly-fire attribution rule as mortar splash: owned and allied entities in the radius can take
damage, but same-team damage does not produce hostile reveal, under-attack, or score attribution.
Panzerfaust launch events are emitted by the one-shot anti-tank runtime. They carry the firing
unit id, launch point, intended visual endpoint, and travel delay, but never carry the target entity id.
Launch events are sent to the firing team and to enemy recipients whose
team-current fog can see the shooter or launch point; the endpoint must be withheld unless it is
visible to that recipient or otherwise already safe through the recipient’s projection. Panzerfaust
impact events carry only the impact point and are sent to the firing team and to enemy recipients
whose team-current fog can see that point; they do not imply damage, target identity, terrain
reveal, or exploration. The firing entity remains a Panzerfaust throughout; panzerfaustLoaded flips
to false at launch while the detached projectile resolves through the launch/impact events.
Events are best-effort visual flavor; the client must not depend on receiving them.
2.5.1 Projection contract summary
Projection modes select a view and an event policy separately from command authority. Normal
active-player views use the recipient’s living-team current fog for entity
visibility but keep resources, upgrades, ability affordances, command authority, order plans, and
rally plans exact-owner-only. Lab operator command surfaces are the exception on the client side:
they are still spectator-shaped projections, but issueCommandAs names the selected real player as
the authoritative command issuer and rejects mixed-owner selections.
Live spectator, replay, dev-watch, and Lab views pass one shared ObserverView through one
projection seam: Omniscient or a non-empty set of real player ids. Omniscient means the complete
world, all-owner private detail, all visible and explored tiles, and the full event union; it is
not an all-player fog union. Selected ids drive effective team fog, visibleTiles,
exploredTiles, entities,
remembered-building memory, private detail for explicitly selected owners, playerResources, and
event unions. No observer view creates a command issuer. Lab issueCommandAs remains the only
cross-player command path and is independently authorized.
artilleryFiring remains an intentionally global visual event for minimap firing
markers, while artillery’s actionable world reveal is modeled separately as temporary live fog on
enemy player grids without granting target-point or surrounding-terrain visibility.
worldCombatPosition is the second explicit global exception. Every projection receives the
identical 32-tile-quantized combat-area point. It intentionally conveys broad direction while
withholding exact location, owner, team, entity id, weapon kind, count, composition, and live
cadence. It may pan generic constant-gain audio only and never changes fog, exploration, targeting,
or entity projection.
When adding a projection-affecting field or event, use docs/projection-audit-checklist.md and update this section’s mode/event policy if the new data does not fit an existing row.
Local replay AI rule diagnostics (prototype)
This local review surface does not change WebSocket messages or snapshots. Self-play ai-matchup --save-replay writes an optional ai-diagnostics.json beside replay.json: schema version 1,
replayArtifact, seed, finalTick, profile-owned profiles[] (playerId, profileId, sections and
rule-tree nodes), and changed-state timeline[]. Each sample carries its actual AI invocation
tick, playerId, activeNodes, phase, expansionPaused, and formation counts/readiness. Rules
are recorded directly by the controller’s decision branches; traces/chat are never parsed.
Only Eco currently exposes this section. The timeline is capped at 100,000 changes and 16 MiB.
GET /dev/replay-ai-diagnostics?replay=<safe-artifact-name> exists only when
RTS_REPLAY_AI_DIAGNOSTICS=1; it reads completed saved replay files, checks their seed and final
tick against sidecar metadata, and never consults a live room. Names are ASCII alphanumeric,
underscore or hyphen, at most 128 bytes. This opt-in local artifact endpoint exposes full
recorded AI decisions, like the existing full replay artifact; do not enable it on a live service.
The client requires observer-analysis capability plus replayArtifact and rtsAiDiagnostics=1.
It chooses the latest recorded decision at or before the authoritative snapshot tick; seeks
before the first decision clear all highlights. Pause and playback speed never advance this
cursor independently. Demo fixtures remain separately gated by rtsAiDiagnosticsPreview=1 and
are visibly labeled Preview / Sample data. Real playback is labeled Recorded.
2.6 Room time state and vision selection
roomTimeState is a full, coalescing latest-only server message that carries the shared
room-controlled time cursor/state. Replay rooms send it for playback cursor changes; dev scenario watch rooms and lab
rooms also send it after pause/resume and one-tick step controls so clients can confirm the
authoritative room-time speed and tick. Clients keep a pending room-time command across stale
authoritative frames and clear or recover its timeout notice when a later state confirms the
command. Lab rooms also send it after timeline baseline resets and new timeline keyframes, accepted
seeks, and future-history truncation:
{
t: "roomTimeState",
currentTick: u32,
durationTicks: u32,
keyframeTicks: u32[],
speed: f32,
paused: bool,
ended: bool,
controllerId?: u32,
seek?: {
id: u32,
controllerId: u32,
fromTick: u32,
targetTick: u32
}
}
When seek is present, currentTick is the authoritative incremental reconstruction cursor and
the latest sampled snapshot represents that tick. The seek completes when a later state omits
seek at the clamped target. The seek id is monotonic within the replay session so clients can
distinguish replacement work from stale progress. speed and paused remain the selected replay
playback state. Internal reconstruction continues to the requested target even when playback is
paused; after completion the unchanged paused state prevents ordinary playback from advancing.
keyframeTicks lists the replay or lab keyframes the server has recorded so far. Replay and lab
clients may display them as seek marks, but a seek target is not limited to these ticks; the server
restores the nearest recorded keyframe at or before the requested tick and fast-forwards from there.
For schema 3 replay artifacts that begin from a checkpoint, the restored checkpoint tick is the
minimum playback tick; earlier seek targets are clamped to that tick.
Lab rooms expose recorded baseline and periodic keyframe ticks through the same field, with
durationTicks set to the current maximum retained lab tick. Lab history is bounded by retained
room-local keyframes and recorded entries; seek requests outside retained history are rejected with
error instead of rebuilding from discarded state.
Before an accepted replay seek resets to its reconstruction keyframe, the room broadcasts
roomTimeSeekStarted with the authoritative current and clamped target ticks. Every replay viewer,
including the controller, clears timeline-derived client presentation in place and presents the
direction and tick distance as seconds. The room then emits an immediate authoritative state and
full snapshot, advances as fast as bounded CPU slices allow, and publishes sampled state/snapshots
at a reduced wall-clock cadence. Ordinary room events run between slices, so pause/resume, vision,
leave, and later admitted seek commands remain responsive. Intermediate transient events are not
replayed to viewers; each sample is a complete authoritative world state. Recorded 1,000-tick
keyframes appear through the growing keyframeTicks list.
livePauseState is a reliable server message that carries the authoritative live-match pause
state. Normal live and branch-live match recipients receive it after start and after accepted or
rejected pause/unpause transitions. Pause-capable active players and live spectators receive their
own remaining-count value plus pause/unpause authority:
{
t: "livePauseState",
paused: bool,
pausedBy?: u32,
pausesRemaining?: u8,
pauseLimit: u8,
canPause?: bool,
canUnpause?: bool,
resumeCountdown?: {
durationMs: u32,
setupDurationMs: u32,
remainingMs: u32,
words: string[]
}
}
Each active seat and live spectator connection has three successful pause starts per match. The
server decrements the count only when a request changes the room from unpaused to paused; any
pause-capable live recipient can request a resume. An accepted resume starts a server-owned
three-second Drei! Zwei! Eins! countdown and leaves paused: true until its deadline. During the
countdown canUnpause is false, and resumeCountdown carries the full duration, recipient-time
remaining duration, the setup duration (setupDurationMs: 0 for ordinary live unpause), and final countdown display words
so late live spectators enter at the current phase rather than restarting it. The server broadcasts a final paused: false state when simulation resumes.
Initial replay-branch launch instead starts a 13-second sequence after start and a frozen,
fog-filtered snapshot: ten seconds of hotkey-group setup (setupDurationMs: 10000) followed by
the three-second countdown. This automatic setup does not consume a pause charge; later unpauses
in that branch use the ordinary three-second countdown.
While live
pause is active the room task skips the live simulation tick branch, so AI thinking, command-ack
consumption, Game::tick, live snapshot fanout, and defeat checks do not advance, while reliable
control-plane messages such as ping/pong, net reports, Give up, disconnect handling, and unpause
still run. Room-owned recipient notices queued during pause, such as late-spectator join notices,
are delivered on the next emitted live snapshot after unpause rather than through a separate
reliable message.
VisionSelectionRequest selects fog/vision per viewer:
{ mode: "all" }
{ mode: "player", playerId: u32 }
{ mode: "players", playerIds: u32[] }
{ mode: "omniscient" }
The server rejects unknown player ids, empty subsets, duplicate subset ids, active-player requests,
and requests outside a privileged observer surface. Selection is per connection. mode: "all"
uses the union of every active player’s effective team fog, while mode: "omniscient" exposes the
complete world and every owner’s private details. The all-player union is the default for live
spectators, replay, dev-watch, and Lab; omniscient remains available as an explicit selection. A
selected single/multi-player view uses the real selected owners and their effective team fog.
Owner-only details remain limited to explicitly selected owners, even when team fog reveals an
ally.
LabClientOp is tagged by op:
{ op: "exportMap" }
{ op: "spawnEntities", spawns: [{ owner: u32, kind: string, x: f32, y: f32, completed?: bool, daoMaster?: bool }] }
{ op: "applyUpdates", updates: [
{ operation: "move", entityId: u32, x: f32, y: f32 } |
{ operation: "reassign", entityId: u32, owner: u32 } |
{ operation: "resources", playerId: u32, steel: u32, oil: u32 } |
{ operation: "research", playerId: u32, upgrade: string, completed?: bool } |
{ operation: "godMode", playerId: u32, enabled?: bool }
] }
{ op: "deleteEntities", entityIds: u32[] }
// Existing singular browser/UI operations remain accepted for compatibility.
{ op: "spawnEntity", owner: u32, kind: string, x: f32, y: f32, completed?: bool, daoMaster?: bool }
{ op: "deleteEntity", entityId: u32 }
{ op: "moveEntity", entityId: u32, x: f32, y: f32 }
{ op: "setEntityOwner", entityId: u32, owner: u32 }
{ op: "setPlayerResources", playerId: u32, steel: u32, oil: u32 }
{ op: "setPlayerGodMode", playerId: u32, enabled: bool }
{ op: "setCompletedResearch", playerId: u32, upgrade: string, completed: bool }
{ op: "setVision", vision: LabVisionMode }
{ op: "issueCommandAs", playerId: u32, cmd: Command, ignoreCommandLimits?: bool }
{ op: "exportScenario", name?: string }
{ op: "importScenario", scenario: LabScenarioPayload }
{ op: "validateScenario", metadata: LabScenarioAuthoringMetadata }
LabVisionMode remains compatibility metadata for authored Lab scenarios and the legacy
setVision Lab operation. At runtime, all maps to the shared all-player union view and team
maps to a shared selected-player view containing the current real players on that team. Unknown
team selections are rejected. New UI selection uses setVisionSelection, just like live
spectators, replay, and dev-watch. Each connection’s shared observer view drives the snapshot body,
events, remembered-building memory, playerResources, and completed research. labState.vision
and start.lab.vision retain the compatibility metadata; they are not command authority and must
not be used to infer which player the operator can command.
Plural mutation arrays contain 1–400 items and commit atomically. Success returns
outcome.items: [{index, outcome}] in input order, with each nested outcome retaining the
corresponding singular shape. Rejection returns failedIndex; placement rejection also returns
details: {attempted:{x,y}, blockers:[...], suggestions:[...]}. Blocker records use kind values
entity, feature, terrain, or boundary; features distinguish building and resource and
carry the blocking entity id/kind. Suggestions contain no more than eight deterministic points and
building points are authoritative snapped centers.
issueCommandAs queues a normal gameplay command as the selected player only when all selected
units belong to that player; mixed-owner selections are rejected instead of partitioned. When
ignoreCommandLimits is true, the lab command bypasses the normal command-supply budget and uses
the larger bounded lab command window instead of the ordinary live-player unit-id window. A
successful labResult carries
outcome: {accepted:true, admission:"enqueued", playerId, queuedAtTick} as an authoritative enqueue
receipt. queuedAtTick is the simulation tick at admission; the receipt does not claim that command
planning produced an effect or that the command has already completed.
setPlayerGodMode is lab-only room state: enabled players’ units and buildings ignore incoming
damage, while resources keep normal damage behavior. The current enabled player ids are mirrored in
start.lab.godModePlayers and labState.godModePlayers.
exportMap returns outcome.map: LabMapDraft from the authoritative Lab map and deliberately
excludes entities, orders, player resources, fog, room time, operation history, and replay state.
It is the only Lab-to-Map-Editor transition payload.
Map mutation is not a LabClientOp; exportMap is read-only. The dedicated editor uses a bounded HTTP handoff contract:
POST /api/map-handoffs
{
destination: "lab" | "editor",
authoredMap: AuthoredMapV10,
materializedMap: {
name: string,
width: u32,
height: u32,
terrain: u8[],
elevation: u8[],
sun?: { azimuthDegrees: u16, elevationDegrees: u8, warmth: u8 },
starts: LabMapTile[],
baseSites: { x: u32, y: u32, steelPatches: u32, oilPatches: u32 }[],
doodads: { id: u32, typeId: string, x: u32, y: u32, color?: string }[],
concealmentTiles: LabMapTile[],
noVehicleTiles: LabMapTile[],
noBuildingTiles: LabMapTile[],
noEntrenchmentTiles: LabMapTile[],
damageReductionTiles: LabMapTile[],
unwalkableTiles: LabMapTile[],
slowMovementTiles: LabMapTile[]
}
}
-> { handoffId: 32-lowercase-hex, expiresInMs: 120000 }
POST /api/map-handoffs/{handoffId}
-> { destination: "lab", room: privateLabRoom }
| { destination: "editor", authoredMap: AuthoredMapV10 }
AuthoredMapV10 declares independent width and height tile dimensions, whose product must
exactly match the row-major terrain body. Its optional elevation digit rows must have the same
shape. Varying elevation requires a sun record (azimuthDegrees 0–359,
elevationDegrees 1–89, warmth 0–100); flat maps may also include one to opt into authored
atmosphere and directional unit shadows. sun is presentation-only; local elevation direction affects
authoritative movement speed as defined in balance.md. The schema also has flat startLocations, baseSites, and required
doodads, forestSpans, concealmentTiles, noVehicleTiles, noBuildingTiles,
noEntrenchmentTiles, damageReductionTiles, and slowMovementTiles arrays. A forest span is the compact encoding of the first-class composite
Forest tile: [y, xStart, xEnd] with inclusive bounds. Spans may not overlap and each Forest tile
materializes into the concealment, no-vehicle, no-building, and damage-reduction gameplay layers. Slow movement remains independently authored. Explicit overlay records remain bounded,
unique, in-bounds tile-coordinate pairs and can independently supplement forest-derived layers.
Schema v10 is the only accepted authored-map schema. Older documents are rejected rather than
migrated, and every shipped map declares forestSpans even when it is empty.
Each dimension is bounded to 256 tiles. Start locations determine the
supported player count. Each start optionally carries teamGroup (integer 1–4).
Either every start has a group or none do. On grouped maps, all members of a team must occupy
one group, and different teams must occupy different groups. Group numbers are map-local affinities,
not lobby team ids. Unused starts/groups are allowed, so groups [1,2,1,2] support 2v2, 1v2,
and 1v1, but reject 1v3 and three- or four-team FFA. Incompatible rosters fail map loading and the
lobby reports the error to the host without starting the match. Assignment remains deterministic
for a given map, roster, and seed. Maps without groups retain the existing FFA shuffle and
team-distance heuristic. This optional v10 extension affects authored-map JSON only; start/snapshot
wire payloads carry the already-assigned positions and need no new fields. The editor preserves
groups through import/export, move, resize, and undo/redo, and exposes them per start. Lab materialized
maps hold explicit positions rather than lobby assignment policy; returning a materialized Lab map
to the editor does not reconstruct authored groups.
Every base site is a permanent resource location, including unoccupied
start locations. Each base site carries authoritative steelPatches (0–36) and oilPatches (0–9)
counts. Doodads use unique nonzero u32 ids and integer world-pixel positions, are canonicalized
by ascending id, and are capped at 4,096 entries. The server allowlist is tree.oak, tree.pine,
tree.spruce, tree.alder, wildflower.single, wildflower.cluster, and unit.tank_trap. Every tree id has the
same Tree semantic class and authoritative 4.5-world-pixel circular trunk; species affects
presentation only. Tree color
is forbidden. Wildflower color is optional and, when present, must be canonical lowercase
#rrggbb. Tree trunks are hard geometry for vehicles. Infantry pathing assigns tree tiles a finite
avoidance cost and local movement steers around nearby trunks when space exists, but trunks do not
invalidate infantry paths or landings; infantry pass through when avoidance cannot resolve a dense
cluster. Wildflowers have no collision or pathing effect.
Tank Trap records must be tile-centred and become completed owner-0 Tank Trap entities during game
setup; from that point they use ordinary entity fog, combat, deconstruction, and vehicle-pathing
rules. Static trees and wildflowers have no fog, vision, cover, or combat behavior themselves;
schema-v9 forest spans jointly supply concealment, vehicle exclusion, building exclusion, 25% incoming-damage reduction,
and 25% movement-speed reduction; independent explicit overlays can supply any subset outside a
forest. The damage and movement effects are selected from the tile
beneath the entity centre.
Lab handoff creation strictly rejects unknown fields and validates the complete authored-map schema,
catalog, count, ids, colors, and world bounds before binding terrain, locations, resource counts,
and doodads to materializedMap. Editor-directed handoffs are bounded authored-draft transport and
do not require or retain the duplicate materialized body. Records are capped at 64; Lab records
expire after two minutes, editor records after 24 hours, and both are removed on first consume.
Unknown, expired, or already-used ids return HTTP 410.
The map body never appears in a URL. Consumption uses POST so browser or intermediary prefetching
cannot burn the one-use record. Consuming a Lab-directed record creates a private Lab from the
validated materialized map before the browser joins; an unjoined room has a short empty-room lease
and its reserved name cannot recreate a fallback room after disposal. Its only initial start is tick
zero on the edited map. Editor-directed records return only the map; simulation entities, orders, resources, fog,
timeline state, and replay history are not part of the contract.
LabScenarioPayload accepts only the current checkpoint-backed setup container. Setup exports,
validation previews, imports, and bundled catalog assets use LabCheckpointScenarioV1:
{
schemaVersion: 1,
kind: "labCheckpointScenario",
name: string,
seed: u32,
map: {
name: string,
schemaVersion: u32,
contentHash: string,
materializedHash: string,
data: {
width: u32,
height: u32,
terrain: u8[],
starts: [{ x: u32, y: u32 }],
baseSites: [{ x: u32, y: u32, steelPatches: u32, oilPatches: u32 }],
doodads: [{ id: u32, typeId: string, x: u32, y: u32, color?: string }],
concealmentTiles: [{ x: u32, y: u32 }],
noVehicleTiles: [{ x: u32, y: u32 }],
noBuildingTiles: [{ x: u32, y: u32 }],
noEntrenchmentTiles: [{ x: u32, y: u32 }],
damageReductionTiles: [{ x: u32, y: u32 }],
unwalkableTiles: [{ x: u32, y: u32 }],
slowMovementTiles: [{ x: u32, y: u32 }]
}
},
metadata: {
exportedTick: u32,
lab: {
vision: LabVisionMode,
godModePlayers?: u32[],
initialCamera?: { centerX: u32, centerY: u32 }
},
sourceEntityIdMap?: [{ oldId: u32, newId: u32 }]
},
checkpointPayload: string // GameCheckpointV1 JSON text
}
The map body is a setup-container sibling of the checkpoint payload, not part of
GameCheckpointV1. Import validates the setup map data and materialized hash, the embedded
checkpoint mapBinding, player/team/resource/research/entity/count bounds, lab metadata,
checkpoint byte limits, metadata.lab.godModePlayers, optional metadata.lab.initialCamera
inside the restored map’s world bounds, and a one-to-one sourceEntityIdMap whose newId values
reference restored entities before replacing the live lab game. sourceEntityIdMap is returned as
outcome.entityIdMap on checkpoint import so imports and fresh exports preserve existing id-remap
callers. Legacy labScenario JSON is rejected by the checkpoint-only payload parser before it can
mutate a lab room.
Setup export returns { scenario: LabCheckpointScenarioV1 } in labResult.outcome using the requesting
operator’s current lab vision in metadata.lab.vision and the current room god-mode player ids in
metadata.lab.godModePlayers. Checkpoint-backed import applies setup vision to the requester and
future join default without overwriting already connected collaborators, restores god mode from the
embedded checkpoint payload, and returns the container sourceEntityIdMap.
validateScenario exports the current authoritative lab Game as a checkpoint-backed setup,
applies authoring metadata, pretty formats the setup JSON, checks duplicate catalog
ids/filenames, id-matched filenames, manifest limits, setup entity count, and setup JSON byte
limits, validates map metadata and checkpoint map binding, and restores through the same lab Game
API without mutating the room or writing server state.
LabScenarioAuthoringMetadata is:
{
slug: string, // future catalog id and filename stem, max 48 catalog-safe bytes
name: string, // exported setup name, max 80 bytes
title: string, // catalog title, max 96 bytes
description: string // catalog description, max 320 bytes
}
LabReplayArtifactV1 is the portable lab-session artifact contract owned by rts-protocol
because it is a shareable JSON file shape and reuses the public Command DTO for issued commands.
It is not sim-private LabOp, not LabSession.operationLog, and not the room-local
LabTimeline keyframe list. The first schema is latest-version-only:
{
schema: "rts.labReplay",
schemaVersion: 1,
kind: "labReplay",
serverBuildSha: string,
authoring: {
name: string, // max 120 bytes
author?: string, // max 80 bytes
createdAtUnixMs?: u64,
description?: string, // max 2000 bytes
tags?: string[] // max 16, each max 32 safe ASCII bytes
},
initialSetup: LabCheckpointScenarioV1,
timeline: {
initialTick: u32, // must match initialSetup.metadata.exportedTick
durationTicks: u32, // final replayable tick
keyframeIntervalTicks: 2000
},
operations: [{
sequence: u64, // contiguous from 0
tick: u32, // nondecreasing and within timeline bounds
requestId: u32, // nonzero original lab request id
operatorId: u32, // nonzero room connection id, not necessarily a game player
op: LabReplayOperation
}]
}
Whole artifacts are capped at 8 MiB. The operation stream is capped at 50,000 entries, each
non-setup operation payload is capped at 64 KiB, and embedded GameCheckpointV1 text payloads in
the initial setup are capped at 4 MiB. A lab replay may be saved/opened by Interact’s bounded
local artifact path; it is not carried through the current WebSocket lab request envelope because
long lab sessions can exceed that control frame budget. The daemon-started private server enables
a loopback-only handoff only when RTS_INTERACT_LAB_ARTIFACT_CAPABILITY contains the driver’s
random 256-bit capability. Requests echo that capability and address artifacts by expiring opaque
transfer id. Production startup leaves the seam unavailable. Export/import still execute on the
single-owner room task, so accepted ticks, operation order, truncation, and rebuild validation never
move into the browser or daemon.
LabReplayOperation deliberately promotes only replayable lab state changes:
{ op: "spawnEntities", spawns: [{ owner: u32, kind: string, x: f32, y: f32, completed?: bool, daoMaster?: bool }] }
{ op: "applyUpdates", updates: [LabUpdateSpec] }
{ op: "deleteEntities", entityIds: u32[] }
// Reader-only compatibility for artifacts written before plural operations:
{ op: "spawnEntity", owner: u32, kind: string, x: f32, y: f32, completed?: bool, daoMaster?: bool }
{ op: "deleteEntity", entityId: u32 }
{ op: "moveEntity", entityId: u32, x: f32, y: f32 }
{ op: "setEntityOwner", entityId: u32, owner: u32 }
{ op: "setPlayerResources", playerId: u32, steel: u32, oil: u32 }
{ op: "setPlayerGodMode", playerId: u32, enabled: bool }
{ op: "setCompletedResearch", playerId: u32, upgrade: string, completed: bool }
{ op: "issueCommandAs", playerId: u32, cmd: Command, ignoreCommandLimits?: bool }
New Interact writes use the plural replay vocabulary even for one-item requests. Existing
schema-version-1 artifacts containing singular spawn/delete/move/owner/player operations remain
readable.
setVision is excluded because it is per-operator projection metadata; reopening a lab replay
starts from initialSetup.metadata.lab.vision and connected viewers may choose their own current
lab vision afterward. exportScenario and validateScenario are checkpoint
setup UI/control requests and never enter the durable stream. Checkpoint setup import uses rebase semantics: the
artifact replaces initialSetup with the imported LabCheckpointScenarioV1 and clears prior
operations instead of storing an import operation. That keeps later entity references unambiguous:
after a rebase, operation entity ids refer to the rebased setup’s current ids, and
initialSetup.metadata.sourceEntityIdMap remains the only setup-import id-remap record. Seeking
into the past and then accepting a new lab mutation truncates future operation entries just like
the room-local timeline does.
Lab replay import validates schema/kind/version, artifact bytes, authoring metadata, checkpoint
map binding, player/team ids, lab metadata, entity ids and allocator facts, operation count,
operation payload sizes, non-finite coordinates, stale entity references, bad player ids, command
unit caps (256 normally, 4096 when ignoreCommandLimits is true), timeline order, and rejects
excluded session/setup/import operations before mutating a live lab game.
Accepted setup validation returns { summary, preview } in labResult.outcome; preview includes
manifestEntry, manifestPath, scenarioPath, and deterministic scenarioJson. The preview is
returned to the requesting operator only; no lab request writes setup files or repository state.
facing serializes unit body orientation, and weaponFacing serializes stable combat
weapon/turret orientation for entities with combat state. setUp serializes only stable deployed
support-weapon state for machine gunners, anti-tank guns, mortar teams, and artillery; omitted
setUp defaults to false on import. setupFacing is the authoritative deployed support-weapon
direction in radians. setupTarget is a legacy finite world point fallback used to reconstruct
that direction for older exported scenarios; new exports include setupFacing and may also include
setupTarget for compatibility. A setup entity must include setupFacing or legacy
setupTarget; both setup direction fields are rejected when setUp is false. order and
queuedOrders persist stable active and future command intents, including artillery point and
blanket fire orders for preview scenarios. Setup/teardown transition timers, path progress,
gather/build execution progress, production/research queues, rally plans, attack cooldowns,
ability cooldowns/uses/lockouts, projectile runtime state, transient snapshot fields, fog
recipient projections, events, command logs, interpolation state, and lab operation result metadata
are intentionally omitted because lab setup fixtures are not mid-match savegames.
Reliable lab server messages:
t | Fields | Meaning |
|---|---|---|
labState | room, operatorId, role, vision, godModePlayers, dirty, operationCount | Recipient-scoped lab control metadata plus room-scoped active god-mode player ids. World state still travels through snapshot. |
labResult | requestId, ok, op, error?, outcome? | Targeted reply for every lab request accepted by the room task. Rejected requests include error; accepted setup mutations may include typed outcome metadata such as entityId. |
Lab protocol deliberately omits seek controls, broad lab simulation flags such as globally disabled
damage, user-writable public setup storage, fine-grained multi-operator permissions, visual
iteration hot reload, and /dev/scenario migration. Bundled prebuilt setups are selected before
join through the HTTP lab setup catalog and direct lab URL scenario=<id> tokens, not through a
normal-lobby command or a lab client op. Pause, speed, step, and room-local timeline metadata use
the neutral room-time messages instead of overloading LabClientOp.
2.7 Observer analysis state
observerAnalysis is the wire tag for latest-only observer analysis overlay/tab data that cannot
be derived safely from the browser’s current projected snapshot. The server delivers it on a
separate latest-only outbound lane behind snapshots; stale unsent observer-analysis payloads may be
replaced by newer payloads and must never block world-state snapshot delivery. In replay playback it
is sent to replay viewers after replay start/roomTimeState, after accepted seeks, after vision
selection changes, and during replay playback ticks. Live matches produce the same payload every
server tick, at the normal snapshot cadence, only when at least one spectator connection is present.
The server computes the live payload once per tick and sends it only to connections whose room
player state is spectator: true; active-player connections, including claimed branch-live seats,
must not receive this message.
{
t: "observerAnalysis",
tick: u32,
players: [
{
id: u32,
units: [{ kind: string, count: u32, steelValue: u32, oilValue: u32 }],
production: [
{
buildingId: u32,
buildingKind: string,
itemKind: string,
itemType: "building" | "unit" | "upgrade",
progress: f32,
queueDepth: u32
}
],
upgrades?: string[], // completed permanent research; omitted when empty
unitsLost: [{ kind: string, count: u32, steelValue: u32, oilValue: u32 }],
buildingsLost?: [{ kind: string, count: u32, steelValue: u32, oilValue: u32 }],
resourcesLost: { steel: u32, oil: u32 },
resources: {
lifetime: { steel: u32, oil: u32 },
last5s: { steel: u32, oil: u32 },
lastMinute: { steel: u32, oil: u32 }
},
}
]
}
players lists every active observed player. units is the current living unit inventory by kind.
production has one building row for each owned unfinished building, including extractor
scaffolds, and one unit or upgrade row for each owned building with a non-empty queue. A building
under construction can therefore have both a construction row and a queued research row. progress
is the construction or front item’s completion fraction; queueDepth is zero for construction and
the total item count for a queue.
upgrades lists that player’s completed permanent research using protocol upgrade ids.
steelValue and oilValue are aggregate row values (count * configured cost), not per-unit
costs. unitsLost is the authoritative unit-death count by kind. buildingsLost is the
authoritative building-death count by kind and is omitted when empty; zero-cost resource extractors
still appear with zero aggregate value. Pump Jack losses always have zero steel/oil value, including
manually built Pump Jacks, because loss history does not track construction origin.
resourcesLost uses the same loss valuation (excluding Pump Jack costs) for units and
buildings that died; it does not include current spending, cancelled production, refunds,
harvesting, or stockpile deltas.
resources is authoritative mined income: lifetime counts all worker/golem harvest and Pump Jack
payouts for that player, last5s counts payouts in the most recent five simulated seconds, and
lastMinute counts payouts in the most recent sixty simulated seconds. Starting resources, lab
resource edits, refunds, deconstruction refunds, spending, and current stockpile deltas are
excluded.
Observer analysis contains resource, loss, production and army statistics only. AI decision
announcements use ordinary chat with scope: "game", channel: "all", authoritative seat
identity and simulation tick; their rows are retained in replay chatLog alongside human chat.
Live and offline writers share the 10,000-entry replay chat limit. The retired aiDiagnostics
and mapAnalysis fields are not emitted. Observer analysis follows each viewer’s selection,
retaining only selected player rows; it is not an active-player information surface.
Replay playback recomputes the payload from the current authoritative replay Game state after
normal playback ticks and at sampled progress points while an incremental seek advances from its
restored keyframe to the target tick. Analysis state is not serialized separately in
ReplayKeyframe.
Machine-gun prototype ray feedback (compact version 57)
attack gains optional shotOrigin: [x, y]. When present, toPos is the fixed
first-impact/range endpoint, not a live target center. Compact attacks append
shotOrigin at slot 6: [1, from, to, revealOrNull, toPosOrNull, weaponKindOrNull, shotOrigin].
to: 0 denotes a miss or an endpoint without a disclosed victim. Each MG cycle
emits up to three ray events per viewer. The server resolves damage immediately and
the client animates short moving streaks along these fixed rays. Ordinary attacks
omit the field. Version 56 remains decodable.
Prototype ray projection requires current team visibility in every tile intersected by the ray and omits impacts on victims hidden by fog, concealment, or smoke, including bodies whose edges cross into visible space. Rays crossing hidden space are also omitted rather than exposing hidden impact positions. Bursts that only hit traps or miss do not grant a shooter reveal; their rays are withheld from enemies when the shooter is concealed. Smoke-hidden shooters are also withheld. This can hide some firing feedback at fog edges; it never changes authoritative damage.
Barbed Wire uses kind barbed_wire (compact kind code 30) in existing build commands,
entity snapshots and remembered buildings. HP is remaining crossings (2 then 1), not weapon
durability. No new event or command fields; Rust kind adapters use the shared rules parser.
Three Dao Pavilion prototype vocabulary
Cultivators can construct three_dao_pavilion (compact kind code 31) and research
dao_wind, dao_of_magic, and dao_of_heaviness (upgrade codes 14–16).
The existing build/research commands, research queues, completed-upgrade lists, and
owner-only projection rules apply. These upgrades unlock the corresponding Adept production at Portals and paid
training at Proving Grounds. Combat-earned evolution needs no research. Rust protocol and sim adapters and the client protocol facade
continue to re-export their authoritative vocabulary.
The Wind rename uses dao_wind, wind_adept, evolveWind, windDash, and
wind Dao values throughout commands, snapshots, Lab setup, and checkpoints. Compact
snapshot version 69 keeps the existing numeric codes and slots.
Disciple insight and Dao specializations
See Dao evolution playtest. Entity-owned insight and authoritative unit kind persist
through checkpoints. Evolution changes Novice warrior (29) to wind_adept (35),
war_adept (36), or magic_adept (37), preserving the entity id and orders.
Permanent Dao identity is derived from kind; the engine stores no separate mutable dao. Disciple snapshots append public insight (compact slot 45), public
dao (slot 46: wind/war/magic), daoReady (47), and optional
daoAdvanceTicks (48, 1–15). Ordinary fog filtering applies to all public fields. Evolution buttons set replaceable, entity-owned chosenDao intent (team-private compact slot 49), independent of orders. Codes 14–16 and order stages 22–24 retain their positions.
Evolution automatically occurs once 60 insight is ready, without research or a Pavilion.
Evolution clears all insight and raises the cap to 200. Evolved Disciples continue earning
insight from actual hostile HP damage; reaching 200 automatically advances a living Adept
to its matching Master, resets insight, and fully heals to the new maximum HP.
daoMaster (public boolean, compact slot 52) persists with the entity; Masters cannot advance again. Research ids are
dao_wind, dao_of_heaviness (War), dao_of_magic (Magic).
Dao presentation and support Shield follow Disciple insight and Dao evolution.
Shield uses ability discipleShield (code 17, order stage 25), world-point target,
ability-object kind shield (code 4). It expires after 10 seconds for Adepts or 15 seconds for Masters, projected through expiresIn; ownerState.hp carries
the remaining pool (150 HP for Adepts, 300 HP for Masters); ownerState.maxHp and ownerState.durationTicks carry the cast-time maxima for the bars to every viewer who can see the field, including enemies and allies. The client renders this pool as a cyan HP bar above the public gray lifetime bar, updating it as full incoming hit damage drains shield HP. The radius
is 2.1 tiles for every viewer. Field visibility is gated at its center, independently
of its caster; sourceCasterId is omitted when that caster is hidden.
War Adept and War Master Throw Sword uses ability throwSword (compact code 18, order stage 26),
world-point targeting and the existing lineProjectile ability-object kind/payload.
It is fog-filtered by the existing object projection; clients select its spinning sword
sprite by ability id without requiring visibility of the caster. Entity ability availability
is restricted to Dao of War; daoMaster selects a 20-second rather than 40-second cooldown on cast. Checkpoints retain the shared projectile leg and per-leg hit sets.
Tournament Grounds
tournament_grounds appends entity-kind compact code 32. Optional team-private
tournamentEntrants (0–4) appends entity slot 50 in compact version 62. Ordinary
prodKind, prodProgress, prodQueue and rally fields represent the five-second batch
and pending winners. Visible opponents see progress but no entrant count.
A normal unqueued move to the exact owned completed building center means enter for
base Disciples only; the client resolves right-clicks to that center. Entry intent is
entity-owned, cancels on replacement/stop/hold, and records through existing replay commands.
See Tournament Grounds.
Portal first-stage rallies to the exact owned completed Grounds center automatically issue entry movement to newly trained base Disciples. Busy grounds retain waiting entry intents.
Portal Adept production
A completed Cultivator Portal trains Novices and, after matching Pavilion research, Wind, War and Magic Adepts. Each Adept costs 150 steel, 45 oil, three supply and takes 300 ticks (ten seconds), without a Novice input. Use normal train/repeat commands, queue payment/refunds, legal spawn exits and rally behavior. An unresearched Dao cannot be trained. Combat-earned evolution and Tournament Grounds are unchanged.
Proving Grounds
Cultivator Engineers construct proven_grounds after a completed Portal: 100 steel, zero oil,
200-tick construction, 3×3 tiles, 120 HP, armored, one-tile sight, no weapon or supply.
Select the building to queue a mix of researched Dao training plans (maximum 64). Right-click
base Disciples inside or rally a Portal there. Each admission consumes one base Disciple and
100 oil, reserving three supply for its Adept replacement. One full-health chosen
Dao specialist emerges after 300 ticks (10 seconds), using legal exits and the full rally plan.
Blocked exits retry; destruction loses the trainee and oil. Unpaid plans can be canceled; active
training cannot. Combat-earned 60-insight evolution requires no research.
See Proving Grounds brief and rules for details and deferred audio/AI work.
proven_grounds uses kind code 33. Compact v63 appends entity slot 51
daoTrainingQueue?: string[], a team-private bounded FIFO of Dao upgrade ids, including the
active trainee as its front entry. Omitted for enemy/vision-only views. prodKind/prodProgress
remain public when visible; queue contents never appear in building memory.
The existing research {building, upgrade} command enqueues a paid-training plan when targeting
an owned completed Proving Grounds; it researches normally at other structures. Only completed
Dao research owned by a Cultivator player is accepted; stale, wrong-owner, non-Dao and full-queue
requests are no-ops. cancel removes the latest unpaid plan, preserving active training.
Move-to-center and Portal rally use the existing tournament admission convention for both grounds.
Entity production state checkpoints the training plans and the active paid production item.
Lab unit spawning accepts an optional dao (wind, war, or magic) on
spawnEntity and each spawnEntities entry. Only the Novice (warrior) kind accepts
it; other kinds are rejected before mutation. The authoritative spawn uses normal
Dao evolution to initialize specialization stats, with its entrance animation already
complete. Omission spawns a base unit. Lab timeline and replay operations retain this
field, and setup checkpoints retain the resulting entity specialization.
Set daoMaster: true on a Wind, War, or Magic Adept kind to spawn it at Master rank.
The server uses standard promotion to initialize full Master health and abilities, then
validates placement with the Master body. Other kinds reject Master rank. Omission or
false keeps the base rank. Timeline and replay operations preserve Master spawns.
Spawn entries also accept factionId from the faction catalog. A successful spawn sets
the target player’s faction; the kind must belong to that catalog. Invalid placement
or invalid faction/kind combinations leave the player unchanged. Faction is a seat-level
identity, so changing it affects all that player’s entities. Snapshots carry public playerFactions rows ({id, factionId}, compact pf: [[id, factionId], ...])
independently of private resource projection. The client refreshes player identity from these
authoritative rows, including unselected seats after Lab rewind and replay seek.
Cultivator Shop
shop is a building kind with compact code 34. Existing Build/Cancel commands, entity views,
construction progress, fog memory and checkpoint/replay paths carry the building normally.
It has no production, research or weapon. Its targeted goods extend ability targeting below. See
Shop for the rules.
Shop item targeting
Compact vocabulary version 75 replaces healingPotion with regen at the same codes.
Regen projects a permanent private abilities entry (remainingUses:1) after arrival.
Generic useAbility accepts optional targetId for friendlyUnit abilities. regen
and escapeTreasure are Shop abilities with compact ability codes 19/20 and order stage codes
27/28. Unit targeting is authoritative: a visible living friendly unit at any distance is required;
buildings are rejected. Purchases are immediate and do not enqueue a movement order.
For the R Buy menu, useAbility omits targetId and includes the source Shop id plus the
selected fighter ids in units. This uses existing bounded/deduplicated command admission.
One item is purchased per command. The server considers only living visible owned Novices,
Adepts and Masters with a free slot and without that item equipped or in flight. Priority is
rank, Insight, carried-plus-reserved count (descending), then entity id (ascending). Source
ownership/completion, resources and Escape cooldown are checked normally. Missing/dead sources
spend nothing. The menu does not require new message fields or expose recipient identities.
Compact vocabulary version 72 adds shop_delivery (kind code 39), a transient 10-HP
combat body with ordinary entity HP, targeting, and visibility. Its id is server-linked to
the delivery projectile; no recipient id is exposed. It is not a controllable unit, building,
or resource. It has no collision, sight, supply, or weapon. Delivery removal also removes the body.
Deliveries travel at 7.5 tiles/second with no timeout and use existing fog-filtered abilityObjects with kind: "lineProjectile" and the item
ability id; owners/allies also receive their own deliveries outside current vision.
EntityView.escapeTreasure is team-private: only the unit’s owner/allies receive
its protection status. Enemy player snapshots and enemy-selected observer views omit it even when
the unit is visible. Selected observer unions include it when an owner or ally is selected, and
omniscient/full-world observers retain it. The flag is true while the unit carries protection; false is omitted in JSON and compact entity slot 53 (54-element record) defaults
to false. This field reveals no supplying-Shop id or position. Existing ownership/visibility
rules gate projectile source ids; no hidden target id is projected. Snapshot replacement clears
consumed effects normally, including replay seeks and observer perspective changes.
Carried Escape Treasure activation
useAbility with ability: "escapeTreasure", no targetId, and owned living treasure
carriers alone in units manually consumes their item and returns them to the supplying Shop,
preserving current HP. With targetId, it retains the Shop purchase behavior. Neither form
is queueable. setAutocast for escapeTreasure toggles lethal-damage rescue on owned carriers.
Private carrier abilities includes escapeTreasure, remainingUses: 1, and
autocastEnabled while the item exists; team-private escapeTreasure remains the badge flag.
Wind Dash has its own windDash ability (21) and order stage (29). Compact snapshot vocabulary is version 69. It creates no return object. Owner-visible remainingUses and chargeRechargeLeft carry one Adept charge or up to two Master charges; no new snapshot fields.
Healing Seal
healingSeal (ability code 22, order stage 30) remains reserved but has no carriers and
is hidden from command cards. Shops no longer sell it; even a direct command spends nothing.
Authored/checkpointed fields retain the entity projection below.
healing_seal is selectable building-kind code 38, a non-blocking, non-attackable field.
Its existing entity hp / maxHp pair represents healing remaining / total capacity
(400), rather than combat health. Damage and repair cannot modify it. No entity slots
are added; the compact vocabulary version is 69. The field is checkpointed with ordinary
entities; its healing pulse uses authoritative tick multiples of 10. Ordinary ownership
and positional fog filtering apply, including observer views. It provides no vision and
is excluded from enemy building memory. Depletion removes the entity without a death event.
Categorized carried Shop items
Abilities haste (compact23, order-stage31), doubleDamage (24,32), and armorTreasure (25,33) use the existing useAbility command with a Shop and friendly targetId for purchase. All carried attack/defense items are permanent passives applied on delivery, not activatable carrier abilities. Private entity abilities entries expose remainingUses:1 while equipped, with zero cooldown and no expiry. Absent items omit the entry. Escape remains movement, Haste/Double Damage attack, and Armor/Vitality defense. Shop escapeTreasure.cooldownLeft projects the purchasing owner’s shared cooldown across all their Shops. Item identities stay private; public visual strength is specified below.
Vitality Treasure uses ability vitalityTreasure (compact ability 26, order-stage 34), with the same private permanent carried-passive abilities entry as Armor Treasure. Existing public hp/maxHp fields include its bonus from delivery onward. No new snapshot fields.
Public Cultivator item radiance
Compact v70 appends optional entity slot 54, itemRadianceTier: u8 (0–6),
as a complete per-snapshot visual value for already-visible Cultivator fighters.
All recipients (owners, allies, visible enemies, selected-player/spectator unions and full-world
observers) receive the same tier. Zero is explicitly projected to clear consumed or expired items.
Each distinct carried item contributes one tier, saturated at six.
The tier discloses visual strength, never inventory identities or timers.
Existing private abilities and team-private escapeTreasure retain their privacy policies.
Fog-hidden carriers are omitted as usual; vision-only entities omit this field. The client
uses this public field exclusively for the golden rim, bloom and rays, including allies’ defense
and attack items. No glow renders on the minimap or through unexplored/hidden terrain.
Vector Field
vectorField { units: u32[], x: f32, y: f32, directionX: f32, directionY: f32 } immediately places the new Magic Dao ability. Center and direction must be finite; a nonzero direction is normalized server-side. Unit ids use normal command admission. Owner, carrier, faction, range, resource, readiness and cooldown validation remain authoritative. Its ability id is vectorField (ability code 27, order-stage code 35), distinct from ekatMagicAnchor. Its world-object kind is vectorField (kind code 5), distinct from magicAnchor. Compact v74 ao records append public vector: [f32,f32] and fieldSize: 4|5 slots; the entire object uses the existing authoritative fog gate. Ekat’s Anchor command, shape and projection remain unchanged.
Charge speed streaks
Compact v76 appends optional entity slot 55, chargeActive: bool (56-element record).
It is a complete public visual flag on an already-visible actionable Novice, War Adept or
War Master, true only while the authoritative Charge movement timer is active. False is omitted
in JSON/trailing compact records and defaults to inactive. It exposes no cooldown, target,
position beyond the carrier, or private ability state. Vision-only entities omit the flag;
hidden entities remain absent. Selected-team observers and full-world diagnostics use their
ordinary entity projection policy. Losing Charge or visibility immediately removes the streaks;
no world-space trail persists into fog. The flag crosses the detached presentation frame to Pixi.
2X XP uses doubleXp (compact ability 28, order-stage 37) with existing Shop purchase and private permanent passive inventory entries (remainingUses: 1). It contributes to public item radiance without revealing its identity to enemies. No new snapshot fields.
Cosmic Energy and Breakthrough item
Compact v77 adds Snapshot.cosmicEnergy: u32, encoded as compact top-level ce.
It follows the selected private-resource perspective, returning zero when none is selected.
Observer PlayerResourceSnapshot.cosmicEnergy follows existing resource projection permissions;
compact pr rows append it at slot 7 after upgrades. Missing values decode to zero.
Cosmic Energy reveals no source unit, event position, or hidden enemy information.
breakthroughTreasure uses ability code 29 and order stage 38, separate from the existing
Wehrmacht breakthrough ability. It uses ordinary Shop delivery, private permanent carried
ability entries (remainingUses:1), reservations, and public item-radiance counts. No new entity
fields are projected. The client protocol facade exports this vocabulary from protocol_constants.js;
server/src/protocol.rs re-exports the authoritative protocol contract unchanged.
Technique Library vocabulary
technique_library uses compact kind code 40. technique_charge, technique_blink,
technique_shield, and technique_throw_sword use upgrade codes 18–21 respectively.
Compact snapshot version 78 adds these identities. Existing build/research commands, queues,
cancellation, completed-upgrade lists and owner-only research visibility apply. No new fields
or events are introduced. See Technique Library.
Bow Novice identity
bow_novice uses compact entity kind code 41. warrior (29) is displayed as Sword
Disciple. Both base kinds share the existing insight/chosenDao/evolution snapshot fields
and evolution commands; Bow Novice attacks emit existing disciple_arrow (weapon code 13)
events, with the same visibility gates and immediate damage as other direct-fire weapons.
No new message, event, or snapshot field is introduced.
Compact snapshot version 79 extends an owner-only rallyPlan marker with optional line points:
[kindCode, x, y, buildingKindCodeOrNull, [[x,y], ...]]. Point-only markers keep their
three/four-slot encoding. Expanded JSON markers use points: [{x,y}, ...]. Selected-building
privacy gates also protect line vertices.