diff --git a/README.md b/README.md index 052dd94..0e54080 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ in front of the server (the server itself stays on `127.0.0.1`), and prints: - the `https://:8443` URL to open on the phone and the laptop, - the GM key (created on first run; an existing key is printed, never replaced), -- the certificate-trust steps for Android Chrome and for a laptop (Linux/macOS/Firefox). +- the certificate-trust steps for Android Chrome and for a laptop (Linux/macOS/Firefox; on NixOS it + prints the `security.pki.certificateFiles` option instead of the Debian `update-ca-certificates` + steps). To import a map on the same first start, pass `--image` (an offline import runs before the server; a fresh state dir is created and migrated first): @@ -43,6 +45,10 @@ a fresh state dir is created and migrated first): devbox run serve -- --image=run/map16384.png --tile-size=64 ``` +Everything after `--` reaches the script (#84: devbox 0.17.2 needs the `"$@"` suffix in +`devbox.json`); an unknown or unusable flag fails loudly instead of being ignored. To check the +parsed options without building anything: `devbox run serve -- --dry-run`. + Ctrl-C stops nginx and the server and releases the port; the next start works. State (`state.db`, `tiles/`), the GM key and the certificate live under `run/lan` and are **not** wiped, so a session survives a restart and a phone that trusted the certificate does not have to trust it again. @@ -320,6 +326,8 @@ panel); it needs USB debugging, the overlay does not. | command | what it does | |---|---| | `devbox run test` | the server gate: Nim in-process tests (`nimble test`), then the Node black-box harnesses in `tools/*.test.mjs`, then a check that every registered evidence test actually ran and passed | +| `devbox run serve` | the LAN playtest stack: server + client build behind TLS/HTTP2 nginx, persistent state under `run/lan`; `-- --image= [--tile-size=]` imports first, `-- --dry-run` prints the parsed options and exits | +| `devbox run seed` | 49 deterministic NPC tokens over the real WebSocket; `-- --url= --tokens=49 --vision=1` | | `devbox run client-test` | client unit tests (Vitest): the pure reducer, protocol client and envelope; no DOM, no GPU | | `devbox run e2e` | builds `client/dist`, then drives headless Chromium against the real server through the TLS/HTTP2 test nginx | | `devbox run mutation` | mutation suite on a temp copy of `server/`, `tests/`, `tools/`: every seeded mutation must fail at least one test | diff --git a/devbox.json b/devbox.json index 6d0ac60..90fa816 100644 --- a/devbox.json +++ b/devbox.json @@ -33,22 +33,22 @@ "client/run-tests.sh" ], "serve": [ - "tools/serve.sh" + "tools/serve.sh \"$@\"" ], "seed": [ - "node tools/seed.mjs" + "node tools/seed.mjs \"$@\"" ], "mutation": [ - "tools/mutation.sh" + "tools/mutation.sh \"$@\"" ], "bench": [ - "mkdir -p results; nim c -d:release --hints:off -r tools/bench.nim > results/bench.log 2>&1; rc=$?; cat results/bench.log; exit $rc" + "mkdir -p results; nim c -d:release --hints:off -r tools/bench.nim \"$@\" > results/bench.log 2>&1; rc=$?; cat results/bench.log; exit $rc" ], "import-scale": [ - "mkdir -p results; IMPORT_SCALE=1 node --test --test-concurrency=1 --test-reporter=spec tools/importscale.test.mjs > results/import-scale.log 2>&1; rc=$?; cat results/import-scale.log; exit $rc" + "mkdir -p results; IMPORT_SCALE=1 node --test --test-concurrency=1 --test-reporter=spec tools/importscale.test.mjs \"$@\" > results/import-scale.log 2>&1; rc=$?; cat results/import-scale.log; exit $rc" ], "fogbench": [ - "mkdir -p results; nim c -d:release --hints:off -o:run/test/fogbench tools/fogbench.nim > results/m4-fog-bench.log 2>&1 && ./run/test/fogbench >> results/m4-fog-bench.log 2>&1; rc=$?; cat results/m4-fog-bench.log; exit $rc" + "mkdir -p results; nim c -d:release --hints:off -o:run/test/fogbench tools/fogbench.nim > results/m4-fog-bench.log 2>&1 && ./run/test/fogbench \"$@\" >> results/m4-fog-bench.log 2>&1; rc=$?; cat results/m4-fog-bench.log; exit $rc" ] } }, diff --git a/docs/HANDOFF-M4.md b/docs/HANDOFF-M4.md index f03fffd..0eba726 100644 --- a/docs/HANDOFF-M4.md +++ b/docs/HANDOFF-M4.md @@ -30,7 +30,10 @@ what exists, what is proven, what is deliberately still open. - **Playtest tooling (#82, closed with this note):** `?perf=1` in-app fps/frame/JS/token/zoom overlay (off by default), `fff-vtt import` on a fresh/empty state dir, `devbox run serve -- --image=`, `devbox run seed -- --url=...` for the 50 tokens, and the GM token form's X/Y - default to the viewport centre. + default to the viewport centre. #84 fixed the seam that made those `--` arguments invisible: + devbox 0.17.2 scripts must end with `"$@"` in `devbox.json`, `serve` now fails on an unknown or + unusable flag, and `devbox run serve -- --dry-run` prints the parsed options. On NixOS the serve + output prints `security.pki.certificateFiles`, not the Debian `update-ca-certificates` steps. - **M5** - concurrency, bounded outbox/coalescing, lag tracking, SIGTERM, metrics, nginx dead-peer timeout, stats outside the lock. `#34` heartbeat is M5. - **Deferred:** `db_connector` -> thin sqlite3 binding (build item 13); per-token polygon cache and diff --git a/server/markers.nim b/server/markers.nim index 9fdf791..3ca8d3c 100644 --- a/server/markers.nim +++ b/server/markers.nim @@ -26,7 +26,9 @@ ## No DB transaction control here: the caller owns it, exactly like explored.nim. import std/[math, options, strutils, tables] import db_connector/db_sqlite -import faults, geometry, tokens, vision, world +import geometry, tokens, vision, world +when defined(leakfault): + import faults # faultActive() is only referenced inside the leakfault blocks below (#84) proc anchorOf*(w: WallRec): (int, int) = ## The wall's drawn midpoint, rounded once to integer px and fixed for the wall (5.8, 6.1). diff --git a/server/vision.nim b/server/vision.nim index e3bb22c..7db1d36 100644 --- a/server/vision.nim +++ b/server/vision.nim @@ -28,7 +28,9 @@ ## moves; a re-earn gets a fresh id. `markerFresh`/`markerDead` hold the markers minted/retracted by ## the current refresh so the mutation's transaction can persist them (server/markers.nim). import std/[algorithm, math, sets, tables] -import tokens, worldmap, geometry, world, faults +import tokens, worldmap, geometry, world +when defined(leakfault): + import faults # faultActive() is only referenced inside the leakfault block below (#84) type Poly* = object diff --git a/server/worldmap.nim b/server/worldmap.nim index a7ae333..0074462 100644 --- a/server/worldmap.nim +++ b/server/worldmap.nim @@ -15,7 +15,9 @@ ## copies a token record before it applies an outcome, and a Nim seq assignment shares its buffer, so ## in-place edits would reach the authoritative list before the transaction commits (4.2 step 6). import std/options -import geometry, moverules, tokens, world, faults +import geometry, moverules, tokens, world +when defined(leakfault): + import faults # faultActive() is only referenced inside the leakfault blocks below (#84) proc geometryWalls*(sc: SceneRec, forSight = false): seq[Wall] = ## The scene's walls as the vision and move code see them. Each wall carries its stored switches: diff --git a/tools/devboxargs.test.mjs b/tools/devboxargs.test.mjs new file mode 100644 index 0000000..ae35b4e --- /dev/null +++ b/tools/devboxargs.test.mjs @@ -0,0 +1,61 @@ +// #84: the devbox seam. Every other harness calls tools/*.mjs directly, which hides the fact that +// `devbox run