fix: forward -- args through devbox scripts, fail serve loudly (#84)

devbox 0.17.2 runs .devbox/gen/scripts/<name>.sh with the args as positional
parameters but does not append "$@", so tools/serve.sh (and seed, bench,
mutation, import-scale, fogbench) saw an empty argv and a documented
`serve -- --image=...` silently served the default 4096 scene. End every
argument-taking script body with "$@".

serve: --dry-run parses and prints the options without building; unknown
options, non-numeric ports/tile sizes and --tile-size without --image fail
loudly; a no-image start prints the current map read from state.db; NixOS
gets security.pki.certificateFiles instead of the Debian trust steps.

Guard the faults import in worldmap/vision/markers with
`when defined(leakfault)` (it is only used inside those blocks), removing
the three UnusedImport warnings; leakfault builds still compile.

tools/devboxargs.test.mjs goes through `devbox run <script> -- <args>` for
serve (dry-run, unknown flag, tile-size without image) and seed (--help,
unknown flag), the seam the direct-tool tests missed.
This commit is contained in:
2026-11-21 21:35:39 +01:00
parent c8b5289a3d
commit 30b35592c7
9 changed files with 190 additions and 15 deletions
+9 -1
View File
@@ -34,7 +34,9 @@ in front of the server (the server itself stays on `127.0.0.1`), and prints:
- the `https://<lan-ip>: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=<file> [--tile-size=<px>]` imports first, `-- --dry-run` prints the parsed options and exits |
| `devbox run seed` | 49 deterministic NPC tokens over the real WebSocket; `-- --url=<origin> --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 |