Capsule: deployment & hardening
Use when changing server bind/config, the build pipeline, or the input-hardening surface.
Read first
- docs/design/hardening.md — full hardening section
- docs/design/client-stress-tests.md — bounded report ingestion
and the
RTS_RECORD_STRESS_TESTSpersistence gate
Run / build
cd server && cargo run # serves client + /ws on RTS_ADDR; open the printed URL
cd server && cargo run --release # fast build
cd server && cargo build && cargo clippy
node scripts/check-wiki.mjs # wiki routes, player wiki generator, stats, catalog parity
node scripts/check-crate-boundaries.mjs
No JS build step (plain ES modules + PixiJS from CDN). The client is served from ../client
relative to the server crate, so cargo run from server/ is the whole dev loop. Release Docker
builds pin the repository Rust toolchain and use independent stages for the native rts-server
binary and prediction WASM. Runtime client files are copied after both stages so client-only edits
reuse the Rust layers. The WASM stage runs scripts/build-sim-wasm.sh into a separate output, and
the final image fails if client/vendor/sim-wasm/rts_sim_wasm.js or
rts_sim_wasm_bg.wasm is missing. Beta workflow summaries report each deploy phase and cache hit.
Every push to main triggers beta deployment independently of post-merge CI. Required PR checks
still gate merging; serialized deploys finish the active rollout and coalesce pending pushes.
Invariants
- Clients are untrusted. Validate and bound every wire input:
- ordinary command unit lists deduped + capped (
MAX_UNITS_PER_COMMAND); lab command-limit bypass lists use the larger boundedLAB_MAX_UNITS_PER_COMMAND - WebSocket frames size-limited
- placement coords range/overflow-checked
- ordinary command unit lists deduped + capped (
- No panics on tick or network paths. Stale ids = no-op. Use
checked_*arithmetic on anything derived from client input. Debug builds have overflow checks on (a badBuildcoord can panic incargo runbut silently wrap in--release). Keep placement mathchecked_*. - Keep the room task alive: handle errors, don’t propagate panics out of message handlers.
rts-serveris the only crate that may own Axum/Tokio WebSocket/static-file serving.- Missing static asset URLs must not fall back to the SPA shell. App routes may fall back to
index.html, but/vendor,/src,/assets, and root asset files should return 404 when the requested file is absent. - Deploy drain is bounded. SIGTERM/Ctrl-C starts the 295s app drain inside Fly’s 300s stop
window: natural match drain, forced aborted finalization for eligible live matches, tracked
match-history/replay write wait, then WebSocket/Axum slack. Beta/mainline validation should check
logs for forced-finalization success/failure,
match recorded outcome=aborted replay=true, and any write-wait timeout before treating an interrupted deploy as healthy. /wikiis server-rendered and read-only./wiki/is the player wiki, generated once per process byserver/crates/wiki(rts-wiki) from the compiledrts-rulesdefinitions, faction catalogs and the sim research table; numbers are never copied into its data. The player presentation filters archived/playtest-hidden content viaserver/crates/wiki/src/visibility.rsbefore pages, tables and search are built (seedocs/design/balance.md). Its only file inputs aredocs/wiki/(Markdown notes,icons.json,history.json, all fixed names) and the client’srules_mirror.jsfor labels/tooltips. Developer docs live at/wiki/dev/and may serve only allowlisted Markdown fromdocs/contextanddocs/design; the old/wiki/docs|context|design/...links redirect there./wiki/statsmust be generated fromrts-rulesdefinitions and faction catalogs, not scraped from client config or rendered docs. The release image copiesdocs/wikialongsidedocs/contextanddocs/design.docs/wiki/history.json(changelog with PR attribution) andicons.json(unit art drawn by the client) are refreshed outside CI by the local wiki tool (update-wiki.cmd -ExportTo <checkout>); a build newer than the last export still shows current numbers everywhere.
Cross-capsule triggers
- Touching the wire surface → protocol.md.
- Touching sim correctness → server-sim.md.