feat(server): map import CLI, pulled forward to M4 (#79)

Slice a PNG/WebP map into the gate's <x>_<y>.png tree under
<state>/tiles/<scene>/v<art_version>/ and update the one scene row
(w, h, tile_size, art_version); a re-import grows art_version so
clients never serve stale tiles. The state-dir lock keeps a running
server out (it loads the scene at startup), so stop/import/restart.

Decoding is ImageMagick from the root devbox with a disk-backed
pixel cache (-limit memory/map), keeping a 16384 px source
memory-sane; no Nim/npm image dependency and the FIXED stack is
unchanged. The black-box harness covers the tile geometry, scene
row, restart pickup through the gate, re-import bump and every
refused-import case.

Records the M6 -> M4 move in DESIGN 3.3/11.1/13 and DESIGN-history,
and documents the CLI plus the 16384 px/50-token recipe in README.
This commit is contained in:
2026-11-21 15:59:54 +01:00
parent bacf2e1412
commit ad610abd65
12 changed files with 700 additions and 30 deletions
+18
View File
@@ -57,6 +57,13 @@ built against glibc 2.44 while this host (NixOS) runs 2.42, so a 2.44-built `lib
- Slice 9 (#24) pins the full status split of DESIGN §3.3: `404` also for another scene or a stale art
version, `403` also for a missing or unknown session (one response with "unexplored"), and
`Cache-Control: private`. The proving group is §10.3 Tiles (`tools/tiles.test.mjs`).
- Map import (#79) writes the tree this gate parses: `tools/import.test.mjs` runs the real binary's
`fff-vtt import`, checks the exact `<x>_<y>.png` set and per-tile geometry, then starts the real
server and test nginx and proves a player with an explored overlapping cell gets `200` (and an
unexplored tile `403`, another art version `404`). A re-import grows `art_version` and the
restarted server serves the `v<new>` tree. Every refused import (bad/absent image, unsupported or
multi-frame format, scene ≠ 1, `tile_size % cell ≠ 0`, absent state dir or DB, held lock) exits
non-zero and leaves no tile tree. This is §10.3 Tiles evidence.
### 3.4 Threat list
@@ -412,6 +419,17 @@ from the prototype, what was missing, what the M3 build added, and the tools it
answer carries `X-Accel-Redirect: /_tiles/1/v1/<x>_<y>.png`, `Cache-Control: private` and an empty
body. Fixture tiles are 32 px PNGs written by `tools/tilefixture.mjs` under the state dir at test
time; the test asserts the repo tracks no `.png` at all.
- **Map import CLI (#79)**: `tools/import.test.mjs` is the black-box harness for the offline
`fff-vtt import` subcommand (DESIGN 11.1, 3.3). It writes a real fixture PNG at test time, runs
the binary, and asserts the exact gate tree (`tiles/1/v1/<x>_<y>.png`, row-major, 4x3 at 64 px),
each tile's 64x64 geometry, the scene row via `hello.scene` (w, h, tile_size, art_version), and a
player with an explored overlapping cell getting `200` through the real nginx+server stack while
an unexplored tile gets `403` and a stale version `404`. A second import must grow `art_version`
and a restarted server must serve the `v<new>` tree (the persisted explored grid still allows it).
Negative cases each exit non-zero and leave no tile tree: missing/unsupported/multi-frame image,
`--scene` other than 1, `tile_size % cell != 0`, absent state dir, state dir without `state.db`,
and a running server holding the state-dir lock (exit 3). `tools/groups.mjs` registers the first
title as Tiles evidence.
- **Probing test (T8)**: M2, in-process against the move-rules module (DESIGN §5.5): arbitrary far
moves; assertion: facts about walls/doors beyond LOS recoverable from replies <= a bounded amount
(step cap), and uniform nack shape. M3: same test over WS with a hostile client (moved from M2).