M4: LAN playtest run script (devbox run serve) #80

Closed
opened 2026-11-21 15:09:46 +01:00 by SirStone · 1 comment
Owner

Part of #63

Goal

One devbox run command that puts the real table on the LAN, so a phone can join without hand-assembling nim + nginx + a certificate. Today devbox.json has only test, e2e, client-test, mutation and bench; README documents the manual path (build the server, write an nginx config, generate a cert). tools/nginx.mjs and tools/tlsdev.mjs are test-only: loopback ports, three-day loopback-SAN certificate, per-run temp state dir — unusable for a phone on the LAN.

Target: devbox run serve (name may change) that the owner can start on the laptop and hand a URL to the phone.

Acceptance criteria

  • One devbox run <script> builds client dist and the server binary, then starts the server and a TLS+HTTP/2 nginx in front of it with the §11.1 vhost shape (/ static dist with SPA fallback, /join, /ws, /tiles/, internal /_tiles/).
  • Binds on the LAN: bind address and/or hostname configurable (default: all interfaces or the detected LAN IP), and the certificate is self-signed with the LAN IP in its SAN (not just localhost/127.0.0.1).
  • Prints, on startup: the https URL to open, how to trust the self-signed certificate on Android and on a laptop (the concrete steps, per platform), and the GM key (creating one if none exists yet, without clobbering an existing key).
  • Ctrl-C stops the server and nginx (no orphan processes, ports released); a second start works.
  • A smoke test proves the composition: the script gets an h2 + valid-TLS answer on / and /join, and a WS upgrade on /ws succeeds, on the LAN address (not loopback only). One devbox run test addition or its own script, but it must run in the gate.
  • README's usage section replaces the manual nim+nginx+cert path with this command (manual path kept only as a fallback note).
  • Standing gate: devbox run test, devbox run client-test, devbox run e2e green on a clean checkout, no test weakened or skipped.

Proven at

The new devbox script + a black-box smoke harness (h2/TLS/WS on the LAN address); README updated.

Notes

  • Size: S–M (about one agent session). Lane: infra.
  • This is not the M6 NixOS deployment (systemd unit, hardening, backups); no nix module here.
  • tools/tlsdev.mjs is the reference for cert generation but its SANs and 3-day lifetime are test-only; either parameterise it or keep a separate dev variant, without turning it into a test-only dependency inversion.
  • Blocks #77: the phone needs this to reach the laptop over TLS/h2 at all.
Part of #63 ## Goal One `devbox run` command that puts the real table on the LAN, so a phone can join without hand-assembling nim + nginx + a certificate. Today `devbox.json` has only `test`, `e2e`, `client-test`, `mutation` and `bench`; README documents the manual path (build the server, write an nginx config, generate a cert). `tools/nginx.mjs` and `tools/tlsdev.mjs` are test-only: loopback ports, three-day loopback-SAN certificate, per-run temp state dir — unusable for a phone on the LAN. Target: `devbox run serve` (name may change) that the owner can start on the laptop and hand a URL to the phone. ## Acceptance criteria - [ ] One `devbox run <script>` builds client `dist` and the server binary, then starts the server and a TLS+HTTP/2 nginx in front of it with the §11.1 vhost shape (`/` static dist with SPA fallback, `/join`, `/ws`, `/tiles/`, internal `/_tiles/`). - [ ] Binds on the LAN: bind address and/or hostname configurable (default: all interfaces or the detected LAN IP), and the certificate is self-signed with the LAN IP in its SAN (not just `localhost`/`127.0.0.1`). - [ ] Prints, on startup: the https URL to open, how to trust the self-signed certificate on Android and on a laptop (the concrete steps, per platform), and the GM key (creating one if none exists yet, without clobbering an existing key). - [ ] Ctrl-C stops the server and nginx (no orphan processes, ports released); a second start works. - [ ] A smoke test proves the composition: the script gets an h2 + valid-TLS answer on `/` and `/join`, and a WS upgrade on `/ws` succeeds, on the LAN address (not loopback only). One `devbox run test` addition or its own script, but it must run in the gate. - [ ] README's usage section replaces the manual nim+nginx+cert path with this command (manual path kept only as a fallback note). - [ ] Standing gate: `devbox run test`, `devbox run client-test`, `devbox run e2e` green on a clean checkout, no test weakened or skipped. ## Proven at The new devbox script + a black-box smoke harness (h2/TLS/WS on the LAN address); README updated. ## Notes - Size: S–M (about one agent session). Lane: infra. - This is **not** the M6 NixOS deployment (systemd unit, hardening, backups); no nix module here. - `tools/tlsdev.mjs` is the reference for cert generation but its SANs and 3-day lifetime are test-only; either parameterise it or keep a separate dev variant, without turning it into a test-only dependency inversion. - Blocks #77: the phone needs this to reach the laptop over TLS/h2 at all.
SirStone added the ready-for-agentenhancement labels 2026-11-21 15:09:46 +01:00
SirStone added a new dependency 2026-11-21 15:09:52 +01:00
Author
Owner

Implemented in 3567058 (rebased on top of #78/#79).

devbox run serve builds the client dist and run/fff-vtt, then starts the DESIGN 11.1 vhost (nginx TLS+h2) on the detected LAN IPv4 (FFF_VTT_LAN_HOST override, 0.0.0.0 allowed) in front of the loopback server. State, GM key and certificate persist under run/lan (FFF_VTT_STATE_DIR, FFF_VTT_LAN_PORT=8443): restart reuses the same DB/key/cert; a changed LAN address regenerates the cert and reprints the trust steps. Startup prints URL, GM key and Android Chrome / Linux / macOS / Firefox trust steps; SIGINT stops nginx then the server and releases the port.

Shared helpers: tools/tlsdev.mjs now takes SAN/lifetime/subject (test defaults unchanged, .cert-opts stamp triggers regeneration when the address changes); tools/nginx.mjs takes bind host/server name/cert dir; tools/withserver.mjs accepts a prebuilt binary. New: tools/lanserve.mjs (stack), tools/serve.mjs (CLI/printing/shutdown), tools/serve.sh (build+exec), tools/serve.test.mjs (in devbox run test).

Smoke proof on the LAN address (not loopback): verified TLS + ALPN h2 on /healthz and /, POST /join with the GM key (303 + fff_session), /ws upgrade (hello+walls), nginx holds <lan-ip>:8443 while the server listens only on 127.0.0.1; stop releases the port; restart yields the same GM key and byte-identical certificate. / uses the same stub dist as vhost.test.mjs (the real Vite build is covered by client-test/e2e); manual devbox run serve was also smoke-tested against the real dist.

Gates on the rebased tree: devbox run test 162 passed, devbox run client-test 173 passed, devbox run e2e 27 passed. README now leads with devbox run serve and keeps the manual nim+nginx+cert path as a fallback.

Implemented in `3567058` (rebased on top of #78/#79). `devbox run serve` builds the client dist and `run/fff-vtt`, then starts the DESIGN 11.1 vhost (nginx TLS+h2) on the detected LAN IPv4 (`FFF_VTT_LAN_HOST` override, `0.0.0.0` allowed) in front of the loopback server. State, GM key and certificate persist under `run/lan` (`FFF_VTT_STATE_DIR`, `FFF_VTT_LAN_PORT=8443`): restart reuses the same DB/key/cert; a changed LAN address regenerates the cert and reprints the trust steps. Startup prints URL, GM key and Android Chrome / Linux / macOS / Firefox trust steps; SIGINT stops nginx then the server and releases the port. Shared helpers: `tools/tlsdev.mjs` now takes SAN/lifetime/subject (test defaults unchanged, `.cert-opts` stamp triggers regeneration when the address changes); `tools/nginx.mjs` takes bind host/server name/cert dir; `tools/withserver.mjs` accepts a prebuilt binary. New: `tools/lanserve.mjs` (stack), `tools/serve.mjs` (CLI/printing/shutdown), `tools/serve.sh` (build+exec), `tools/serve.test.mjs` (in `devbox run test`). Smoke proof on the LAN address (not loopback): verified TLS + ALPN h2 on `/healthz` and `/`, POST `/join` with the GM key (303 + `fff_session`), `/ws` upgrade (hello+walls), nginx holds `<lan-ip>:8443` while the server listens only on `127.0.0.1`; stop releases the port; restart yields the same GM key and byte-identical certificate. `/` uses the same stub dist as `vhost.test.mjs` (the real Vite build is covered by client-test/e2e); manual `devbox run serve` was also smoke-tested against the real dist. Gates on the rebased tree: `devbox run test` 162 passed, `devbox run client-test` 173 passed, `devbox run e2e` 27 passed. README now leads with `devbox run serve` and keeps the manual nim+nginx+cert path as a fallback.
Sign in to join this conversation.