# NEXT Honest status, updated at the end of every stage. ## Done - Stage 0 skeleton: db + migrations, clock, scheduler with catch-up, router, auth/tokens, error envelope, openapi generation, static server. - Stage 1 economy (server): lazy resources, buildings, build queue, storage caps, power battery. - Stage 2 world (server): seeded tiles, spawn ring, map viewport query. ## Stage 5 (partial): social, server only Built (migration `003_social.sql`): alliances (found, invite/accept/decline/cancel, leave, kick, roles, leader transfer, disband, pinned notes, member list with POP count and last online), diplomacy between alliances (war, neutral, NAP, confederation; proposals; 24 h / speed pact cancel through the `diploChange` event; revoke), messages (DM, alliance broadcast, inbox/outbox/thread/ alliance feed, read, delete own copy, block list, DB-backed rate limit, text sanitising), rankings (operators, alliances, battles), `alliance` in `/me` and `/map`, lookup helpers in `server/alliances.js` (`operatorRelation`, `atWar`, `confederated`, `pactPartners`). Tests: `test/social-*.test.js` (pure rules, alliances, diplomacy with the fake clock and event queue, messages, rankings), every response in them is checked against its declared schema (`createTestServer({ contract: true })` in `test/helpers.js`). Not done: - Marketplace / Internet exchange and resource transport (waits for the movement system of stage 3). - Shared report folder of the alliance (needs reports from stage 3), confederation effects (reinforce, see incoming) and the pact effect "no attacks inside a NAP/confederation": the military stage must call `alliances.pactPartners` / `confederated`; nothing enforces it yet. - No web client, no WebSocket push (notifications rows are written; stage 6 pushes them). - Message retention/cleanup of old rows, alliance rename/description, mass-mail abuse reporting, sitter accounts. - Rankings are not cached; battle rankings stay empty until the military stage writes `operator_stats`. - Not run: Playwright, load, or any bot balance run; the social numbers in `SOCIAL` (limits, TTLs, role table) are first guesses. ## Stage 3/4: military and expansion (server only) Built (migration `002_military.sql`: `town_units`, `stationed`, `town_research`, `town_power`, `movements`, `reports`, `report_recipients`, `operator_stats`, `incumbent_takes`): 10 unit types and research in `data.js`/`rules.js`; training queue (`trainDone` per batch, sequential per building); research (`researchDone`); movements scan/raid/attack/takeover/reinforce/settle/transport with latency, ETA, recall (90 s), return legs with loot; combat resolved at arrival in the event queue (full attack, raid, firewall vs DDoS rigs, exploit kits on a chosen building, loot with Rack hall cache, losses, reinforcements, research, battle points in `operator_stats`); scans with intel and detection; takeover with loyalty, capital and last-POP protection, footprint gate; founding POPs with wild-slot choice; incumbent sites (static defence growing with world age, one-time Hardware bonus, +10% research speed per site); beginner protection (both directions, re-checked at arrival); power: offline units when the battery is empty, decommission after 24 h (`powerCheck`); incoming warnings with hidden type; reports (shared row, per-user read flag, 14 day cleanup event); transport movement and arrival hook (`movements.hooks.transportArrived`) for the trade stage. Routes: see docs/API.md, all in `docs/openapi.json`. Tests: `test/military-*.test.js` (rules as pure functions, train queue order, raid end to end, event order and determinism, takeover and its protections, offline units and decommission, restart catch-up from a reopened DB file, protection, settle, incumbent, transport, recall, research, reports/cursor/retention, API smoke over HTTP). Fake clock, in-memory DB, port 0; no Playwright. Not done / not claimed: - **Nothing is balanced.** All unit stats, costs, research curves, incumbent defence and the 50-unit-scale combat numbers are first guesses; there was no bot run (`tools/bot.js` does not exist yet). Do not cite any of them as tuned. - Training cannot be cancelled; reports cannot be shared to the alliance yet (the shared report folder needs a table in the social stage); confederates do not see each other's incoming movements (only reinforce is wired); no sitter, no night protection. - A building damaged by exploit kits that has an upgrade in flight jumps to the queued level when that finishes (`buildDone` sets absolute levels). - Units in transit draw no power from anyone; an operator cannot choose a new capital POP (no command); a captured POP keeps its footprint. - Backbone landing sites and the Backbone node (end game) are not part of this stage. ## Client (stages 1-2 web client) Built: `public/` vanilla JS, no build step, strict-CSP friendly (no inline scripts or handlers, no external requests). - Shell (`js/main.js`): session, `App.registerScreen({id, titleKey, navKey, icon, hud, render, onShow, onHide, onLang})`, bottom nav (left rail in landscape and on wide screens), live resource bar ticked with `rules.resourcesAt` from the server clock, hash routing. - Screens (`js/screens/`): login/signup (invite field appears after `signup_closed`), POP (resource fields by type, infrastructure, build queue with countdowns and cancel, power panel, detail sheet with the server's `next` plan, live affordability, rename), map (`js/render.js` canvas: pan, pinch, wheel, keyboard, culling; chunked `GET /map` cache; tile info sheet), alerts (`GET /notifications`), settings (language, device tokens + revoke, logout). - `js/api.js`: bearer token, serverTime offset, retry/backoff (network, 429 + Retry-After, 502-504), `Idempotency-Key` per intent, `ApiError.code`, event emitter with a reserved `push` event (no WebSocket client yet). - `js/i18n.js`: en + nb, all player-facing names; `PWA`: manifest + icons (no service worker, so no offline mode). - Tests: `test/client-i18n.test.js` (key parity, names, error codes, formatting), `test/client-api.test.js` (retry, idempotency, offset). - Looked at with headless Chromium screenshots (phone portrait, phone landscape, desktop) and one scripted signup/build/cancel/map-tap flow on a phone profile. Not run: real devices, Safari/iOS, Playwright suite. Gaps: the unread badge is stored in localStorage (no "mark read" route); `/me` exposes the world seed which the client ignores; no push, no service worker, canvas has no inertia/fling, no light theme. ## Not done - Everything else. See CLAUDE.md "Working in stages".