seriesoftubes/scripts/lib
jvanvik 065c922287 Server-run play, part 2: the engine
The engine that runs every network of a server session (server-sim design,
section 4): each network in its own vm realm, realms in a small pool of
worker threads, a promise API for the session host. Nothing uses it yet;
the plain build and the game are unchanged (no file under src/).

- scripts/lib/mp-sim-realm.js: one network in a DONT_CONTEXTIFY realm
  running the plain page's game (never the MP page's client folder), with
  recording DOM stand-ins, no-op timers that count, and the srv... calls:
  load from a checkpoint (route memory seeded, then routed), begin a new
  network, marks and restores, the day as a page runs it, the action
  pipeline with drafts, arming, the sanitize gate and rollback, what-ifs
  that put S, R, the dice and uidN back, pulls with top-level key diffs,
  slim R and flow records on demand, fx captured and bounded, saves, cards.
- scripts/lib/mp-sim-worker.js: realms per session in one worker, days one
  network at a time with other messages between them, loads and unloads
  waiting for a session's day, time limits; a throw goes back to the mark
  in place, a timeout gets a fresh realm (new epoch) carrying the old R, a
  day is retried once and the network broken after a second failure.
- scripts/lib/mp-sim-engine.js: createEngine() with the fake engine's API,
  placement by realm count, every pending call rejected when its worker
  exits, a worker of its own after two exits in an hour; snapWith() joins
  the host's clock, roster and since to a realm's snapshot.
- Contract: a pulled snapshot is the realm's half (the host adds clock,
  roster, since); haptic fx carry milliseconds; the fake engine follows,
  with close() and snapWith(). The button crawl moved to tests/lib.
- Tests: realm vs jsdom byte for byte over 60 scenic big-network days with
  actions; restore; retry after a throw or a timeout; realm order; a timer
  audit and the gate over a sweep of sent buttons (SIM_LONG=1: a year and
  every button); captures, rollbacks, asks, selection reports, ordering,
  bounds, pollution, worker exits; the act tables against the game.

The gate found two keys the game writes in a shape a reload repairs (buyTE's
S.te, mkLeave's S.monkey): game fixes for the integrator, kept visible as a
todo test and a list in the audit.

Rebased onto the 3.3.0 merge (61e31c5): the engine itself needed no change. A
realm still routes in the game's own code (no route worker, no saves), the
route cache that now keeps list orders from day to day leaves a checkpoint and a
retry the same, and the capacity market and moved customers play in a realm as
on a page, under the strict gate. The tests needed three things: an old save's
first days earn the new traffic badges, which the unwatched network's snapshot
keeps; the restore test compares JSON text with sorted keys instead of a
deep-equal of two networks (a diff of gigabytes when they differ); and the crawl
opens the windows that move a customer, with a new test playing the market's and
the path moves' acts, 40 days of sales and a checkpoint against the page.
2026-11-09 19:30:38 +01:00
..
compile-labels.js Tests, CHANGELOG and docs for the peering desk 2026-10-29 21:41:28 +01:00
dict.js Translations keyed by labels instead of English text 2026-10-27 11:05:09 +01:00
fuzz-page.js Server-run play, part 1: game prerequisites and shared contracts 2026-11-07 10:26:06 +01:00
gpu-bench-client.js GPU benchmark: answer only its own page, and print what it sends as plain text 2026-11-05 11:15:05 +01:00
js-literal.js Fix CodeQL code-scanning alerts 2026-11-05 21:24:26 +01:00
mcp-browser.js Agent mode: an AI agent plays in the player's own tab, with the agent's clock or a running one 2026-11-03 16:18:43 -05:00
mcp-game.js feat(noc): tooltips and clickable legends on the dashboard charts 2026-11-04 18:58:45 +01:00
mcp-headless.js Agent mode: an AI agent plays in the player's own tab, with the agent's clock or a running one 2026-11-03 16:18:43 -05:00
mp-sim-acts.js Merge upstream: Lambda Bazaar, traffic badges, moving customers and faster routing (3.3.0) 2026-11-09 19:04:21 +01:00
mp-sim-engine.js Server-run play, part 2: the engine 2026-11-09 19:30:38 +01:00
mp-sim-realm.js Server-run play, part 2: the engine 2026-11-09 19:30:38 +01:00
mp-sim-worker.js Server-run play, part 2: the engine 2026-11-09 19:30:38 +01:00
mp.js Multiplayer for self-hosted copies: sessions, server-side saves, a leaderboard 2026-11-07 00:42:39 +01:00
page.js Server-run play, part 1: game prerequisites and shared contracts 2026-11-07 10:26:06 +01:00
puzzle-solver.js Puzzles: real traffic routed by the game, routers, link sizes and paths 2026-10-29 10:35:28 +01:00
relay-client.js Agent mode: an AI agent plays in the player's own tab, with the agent's clock or a running one 2026-11-03 16:18:43 -05:00
route-fuzz.js Merge upstream: Lambda Bazaar, traffic badges, moving customers and faster routing (3.3.0) 2026-11-09 19:04:21 +01:00
scenario-bot.js Fix CodeQL code-scanning alerts 2026-11-05 21:24:26 +01:00
scenario-ref.js Deals belong to Sales: the intern sticks to the network, the sales desk signs deals for you, orbit ones too 2026-11-06 09:58:01 +01:00
timings-reporter.js Faster tests, split everywhere: one sharded CI for pushes and releases 2026-11-07 07:24:09 +01:00