7. Server actions: commands
-
[E] The command map
ACTIONS(src/server/game/dispatch.ts) stays. Every check of an action is a pure function insrc/corethat returns an error code; server and browser turn it into the German message (asyard.ts,lab.tsalready do). -
[V] Built with #53 (second pull request): an action may answer data besides its message,
{ msg, data }(Answer,answerOfinsrc/server/game/actions.ts);POST /api/actionaddsdatato the reply only then, and the client’sact()hands it toanswerbefore it applies the state, only for the newest action of its type: the data of a scan that a newer scan overtook is dropped, its state still applies (CodeRabbit review of #217). First user: the scan of the Auspex-Phalanx, whose checkscanErroris a pure function ofsrc/core/phalanx.tsand whose reachscanReachthe Sternenkarte asks too. -
[E] Audited with #214 on 2026-11-15: Checks of the server actions lists the 33 actions of
ACTIONSwith where their checks live, what the browser repeats and whether the messages match. 7 follow this section, 13 are split betweensrc/coreand the server, 13 check inline only; 17 findings where browser and server disagree. [V] The follow-up pull requests, one per group (economy, fleet, rewards, admin, player, guild), are planned there. -
[E] Economy group built (#214, 2026-11-16):
buildErrors,researchErrors,orderErrorsandisProducerinsrc/core/economy-checks.tsreturn every code that applies; the server refuses with the message of the first, the lists of the browser show the note of the first in their order. Build and research check in one order on both sides, and an order of 0 gets the browser’s text on the server too (O18 (c): F8, F9, F10). -
[E] The other groups built (#214, 2026-11-21): admin, guild, player, rewards and fleet; every action of the audit follows this section,
sendbut for the joining of an attack union (#225). F12 and F15 unified (owner), F18 built: the list of requirements asksbuildErrorsandresearchErrors(Checks of the server actions). -
[V] Built with #283 (a refactor without a visible change, in the style of #111): the settings of a round are a registry,
ROUND_SETTINGSinsrc/core/round.ts, instead of hand wiring inRoundRules,roundRules(),startRoundRules(),UNIVERSE_SPECS, the dialog „Neue Runde“, the client’sdoResetand the reset action. Each entry gives its stored key, its name, its German label, its range or choices, its default and its refusal (else the shared range wordingrangeErrorof the universe settings); the pure checksroundRefusedandroundValuesare in the core, the server words the refusal.RoundRulesis derived from the entries’ types. A feature defines its entries in its own file and exports them asroundSettings; the list of all of them is generated like the feature index (src/core/round-settings.gen.ts,scripts/gen-features.ts, #310), sosrc/core/round.tsnames no feature and a new feature edits no shared place and no test of another feature; itsordernumber, the next free ten above the highest, puts it last in the fixed order of the dialog and the refusals (owner, 2026-11-17; a test refuses a number used twice);live: truealso puts it into the universe settings (X1). The rules are in Admin.
A repeated action runs once (#450)
Section titled “A repeated action runs once (#450)”-
[E] The server ensures by itself that a repeated action runs only once, in its own issue on
main, with #408 (v3) building on it (owner, 2026-11-27, 292a). The locks in the browser (#425, #428) stay. -
[V] The key:
createApi(src/client/logic/transport.ts) makes one key per call with a body,crypto.randomUUID(), and sends it in the headerIdempotency-Key, the same on its own resend after a busy database. A header, not a body field, because actions have a body fieldkeyof their own (pct,tearDownMissiles). -
[V] The check:
onceofsrc/server/http/action-keys.ts, keyed by the player, the route and the key (the same key on two routes runs on both), after the session and before the handler, wrapsPOST /api/action(game, guild and admin actions) and the admin writes (/api/admin/{invite, revoke, announce, moderate, moon, bot-check, totp-reset}). Sign-in, registration, passkeys, passwords, push, reports and deleting the account are not wrapped; they ignore the key the browser sends with them. -
[V] Kept in memory per player for 60 s from the end of the run, at most 240 keys per player (twice the 120 actions of a minute, room for the admin writes; the oldest finished key goes first, a run in progress is never dropped). Every request with a key first drops the keys past their time and the players left without one, of every player; a restart forgets them. An answer is kept without its
state, which a repeat builds anew. Kept are only final outcomes: an answer below 500 or a refusal of the game. The refusal of the limit of actions („Zu viele Aktionen …“) is a refusal of the game too, so a repeat of its key gets it again (by design). A busy database (503ACTION_DB_BUSY), a server error, a missing session and every other failure are forgotten, so a resend runs again. -
[V] A repeat gets the outcome of the first run, an answer with a
statewith the state of now (freshState); it runs no handler, writes no audit entry, records no activity and is not counted against the limit of actions. A repeat of a run still in progress (the invitation awaits its mail) waits for it. -
[V] A request without a key, or with an invalid one (not 1 to 64 letters, digits or dashes), runs as before, the transition until the key is required (#408). No new German text: a repeat shows the answer of the first.
-
[E] Changed for #542, not built yet (owner, 2026-11-30): every feature gets one folder
src/features/<feature>/with its rules and checks, its action inputs and state shape, its Lexicanum page, its server part (*.server.ts) and its client part (*.client.ts), and its tests;src/corekeeps only what two or more features share. This replaces, once #542 is built, the place of the checks insrc/core(pattern 7), the ban of client code in a feature folder (pattern 11) and the separate places of pattern 13 and 14. Names are readable (#543), and each rule exists once and is checked by the server (#544).