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:
@@ -870,6 +870,21 @@ radius starts blank (scene default), on create and on edit. No wire default chan
|
||||
follows the existing `'{}'` reading rather than choosing "vision on for a player-controlled token".
|
||||
See current 8.
|
||||
|
||||
Owner also decided 2026-11-21 [FIXED (owner-delegated, 2026-11-21, #79; recorded here in the
|
||||
decision log that continues the old §C)]: **the map import CLI moves from M6 to M4.** It is the
|
||||
designed CLI of 11.1, not a throwaway seeder: `fff-vtt import --image=<png|webp> [--scene=1]
|
||||
[--tile-size=<px>] [--state-dir=<path>]` writes `<state>/tiles/<scene>/v<art_version>/<x>_<y>.png`
|
||||
(origin at the world origin) and updates the one scene row's `w`, `h`, `tile_size` and `art_version`.
|
||||
A re-import for art that already exists grows `art_version`; old versions stay until M6 cleanup. It
|
||||
takes the state-dir lock (a live server refuses it, exit 3) because the server reads the scene at
|
||||
startup, so the operator stops the server, imports and restarts. `--tile-size` defaults to the
|
||||
scene's tile size and must be a positive multiple of the explored cell (64 px fallback). Decoding
|
||||
uses ImageMagick from the root devbox with disk-backed pixel-cache limits, so a 16384 px source is
|
||||
memory-sane; no Nim/npm image dependency is added and the FIXED stack (2) is unchanged. This note
|
||||
supersedes #63's "map import CLI (M6)" Out-of-Scope line for the CLI only; NixOS deployment, the
|
||||
production vhost and tile-version cleanup stay M6. See current 3.3, 6.1, 11.1, 13 and TESTING 3.3 /
|
||||
10.3.
|
||||
|
||||
## D. Superseded statements removed from the current spec
|
||||
|
||||
Each entry quotes the superseded statement (excerpt) and names the surviving rule.
|
||||
|
||||
+27
-10
@@ -306,9 +306,9 @@ Notes:
|
||||
error, not a leak.
|
||||
- Tile URLs include the scene's `art_version` so that re-imported art does not hit stale caches
|
||||
[FIXED, owner decision 2026-11-14, #7]: from M3 on, always `1` in M3. The gate reads
|
||||
`<state>/tiles/<scene>/v<art_version>/` (layout fixed in M3; writing versions and cleanup are M6,
|
||||
11.1). Response `Cache-Control: private` [FIXED, owner decision 2026-11-14, #7], not the
|
||||
prototype's `no-store`.
|
||||
`<state>/tiles/<scene>/v<art_version>/` (layout fixed in M3; writing versions is the import CLI of
|
||||
11.1, pulled forward to M4 by #79; cleanup remains M6). Response `Cache-Control: private` [FIXED,
|
||||
owner decision 2026-11-14, #7], not the prototype's `no-store`.
|
||||
- **URL grammar and status split [FIXED (owner-delegated), 2026-11-15, #24].** Every numeric
|
||||
component is canonical decimal: digits only, no sign, no space, **no leading zero** (`0` alone is
|
||||
the only zero), bounded at 9 digits for `<scene>` and `<art_version>` (`v` + digits) and 5 digits
|
||||
@@ -1393,7 +1393,7 @@ on any G-only intent is implied and not repeated.
|
||||
|
||||
| t | fields | who | ack ok / extra codes | effects and recipients |
|
||||
|---|---|---|---|---|
|
||||
| `scene.set` | `scene`; any of `name, grid_size, vision_radius_default, token_radius_default, extra` (at least one) | G | `{}`; `invalid`, `not-found` | `hello` plus full resync to **every** connection (hello-equivalent reset; no `scene.activate`, Q3). `token_radius_default` change resizes tokens using the default with grow push (5.6): `token` updates per view, `vision`/`explored` as needed. `w, h, tile_size, cell, art_version` are not settable on the wire (import is M6 CLI) |
|
||||
| `scene.set` | `scene`; any of `name, grid_size, vision_radius_default, token_radius_default, extra` (at least one) | G | `{}`; `invalid`, `not-found` | `hello` plus full resync to **every** connection (hello-equivalent reset; no `scene.activate`, Q3). `token_radius_default` change resizes tokens using the default with grow push (5.6): `token` updates per view, `vision`/`explored` as needed. `w, h, tile_size, cell, art_version` are not settable on the wire (import is the offline CLI, 11.1) |
|
||||
| `wall.add` | `scene, a:[x,y], b:[x,y]`; geometry `thickness?` (px, 0..256, default 0), `position?` (`center|left|right`, default `center`), `height?` (metres, `>0`..`<=100`, `null`/absent = full height); then either a preset name (`preset:"wall"|"door"|"window"|"one_way"`) or the raw 5.8 switches (`blocks_sight?, blocks_movement?, sight_dir?, player_marker?, door?, open?, secret?, locked?`); `label?`, `flags?` | G | `{id}`; `invalid`, `not-found` | `wall` to GM; vision recompute for all players (`vision`, `explored`, `token` as their views change); tokens whose circle overlaps get `stuck` source `walls` (5.5): `token` per view; a newly seen marker (5.8) to the players who see it |
|
||||
| `wall.update` | `scene, id`; any of `a, b, thickness, position, height (null = full height)`, a preset name or the raw switches, `label` (`null` clears), `flags` | G | `{}`; `not-found`, `invalid` | as `wall.add` (update = remove + add for the status rules, 5.5; PROPOSED there); a marker whose cause changed is retracted, a moved one is re-earned (5.8) |
|
||||
| `wall.remove` | `scene, id` | G | `{}`; `not-found` | `wall_gone` to GM; recompute; `walls`-sourced entries re-evaluated (Keep/Clear, 5.5) |
|
||||
@@ -1503,7 +1503,7 @@ switches, never `thickness`, `position` or `height` (#50).
|
||||
- `extra`: a JSON object, stored verbatim and never interpreted; the GM sees it in `hello`. It
|
||||
carries the same opaque caps as wall `flags` [FIXED (owner-delegated), 2026-11-20, #35]: 8 KB
|
||||
serialized, 64 keys per object, depth 8; over a cap is `invalid` and applies none of the patch.
|
||||
- `w`, `h`, `tile_size`, `cell` and `art_version` are **not** patch fields (import is the M6 CLI):
|
||||
- `w`, `h`, `tile_size`, `cell` and `art_version` are **not** patch fields (import is the offline CLI, 11.1):
|
||||
they are unknown fields and ignored (6.2), so a patch carrying only one of them has no field at
|
||||
all and is `invalid`.
|
||||
- Persistence: one `FULL` transaction writes the scene row and every token whose effective radius
|
||||
@@ -2263,10 +2263,23 @@ See TESTING §10.4 (Node 26 black-box harnesses, built-ins only, `devbox run tes
|
||||
- No `limit_req` on `/join` (owner, #6: no rate limit on key entry; ~100-bit key space).
|
||||
- Prototype nginx config (`docs/archive/prototypes/server-vision/nginx/nginx.conf`) is the functional reference;
|
||||
its `listen` has no address (binds all) and its temp/log paths are dev-only.
|
||||
- Map import: offline CLI that slices an image into `tile_size` PNG/WebP tiles into
|
||||
`<state>/tiles/<scene>/v<art_version>/` and registers/updates the scene (prototype:
|
||||
`tools/genmap.mjs`, deterministic, hand-authored, not reusable as the importer). Browser upload is
|
||||
post-v1; CLI-only import in v1 (Q5 FIXED).
|
||||
- Map import [FIXED (owner-delegated), 2026-11-21, #79; pulled forward from M6]: offline CLI
|
||||
`fff-vtt import --image=<png|webp> [--scene=1] [--tile-size=<px>] [--state-dir=<path>]` slices
|
||||
one source image into `tile_size` PNG tiles into `<state>/tiles/<scene>/v<art_version>/` and
|
||||
registers/updates the scene row's `w`, `h`, `tile_size` and `art_version`; the tile grid origin is
|
||||
the world origin and names are the gate's `<x>_<y>.png` (3.3). `art_version` grows on a re-import
|
||||
for a scene that already has art, so browsers never serve a stale cached tile; older versions stay
|
||||
on disk (cleanup remains M6). `--tile-size` defaults to the scene's current tile size and must be a
|
||||
positive multiple of the explored cell, so 64 px is the designed fallback. The state-dir lock of
|
||||
3.2/11.1 is taken (a live server refuses the import, exit 3): the server reads the scene at startup
|
||||
(4.1), so the operator stops it, imports and restarts. Invalid input, an unsupported/multi-frame
|
||||
image, a scene other than the one v1 scene, a bad tile size, a missing/unreadable state dir or DB
|
||||
and a held lock all exit non-zero with a message and write nothing. Decoding is ImageMagick from
|
||||
the root devbox (`imagemagick`); it is run with `-limit memory 256MiB -limit map 512MiB` so its
|
||||
pixel cache is disk-backed and a 16384 px source stays memory-sane. No Nim/npm image dependency is
|
||||
added, the FIXED stack (2) is unchanged, and the archived prototype's deterministic
|
||||
`docs/archive/prototypes/server-vision/tools/genmap.mjs` fixture generator is not reused. Browser
|
||||
upload is post-v1; CLI-only import in v1 (Q5 FIXED).
|
||||
|
||||
### 11.2 Backups [PROPOSED]
|
||||
- SQLite: systemd timer running an online backup (`.backup` or `VACUUM INTO`) to a dated file in a
|
||||
@@ -2338,6 +2351,9 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
prediction/rollback, DOM overlay, reconnect backoff, reducer tests; `prototype-*` archived under
|
||||
`docs/archive/prototypes/` (Q24). Thickness and height controls are not in M4 (build order above;
|
||||
5.7, 5.10).
|
||||
- **Map import CLI** [FIXED (owner-delegated), 2026-11-21, #79; moved here from M6]: the designed
|
||||
offline importer of 11.1 is built in M4 because the gate needs a 16384 px tiled scene and
|
||||
`scene.set` cannot set `w`, `h`, `tile_size`, `cell` or `art_version` (6.1).
|
||||
- Accept: headless e2e (fog pixel checks, player traffic audit clean, reconnect restores) - met by
|
||||
`devbox run e2e` including `client/e2e/audit.test.mjs`; the manual run on laptop and Note 10 at
|
||||
60 fps with 50 tokens on a 16384 px tiled map (test target PROPOSED, Q2) with fog active is
|
||||
@@ -2358,7 +2374,8 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
timeout; stats computation outside the lock.
|
||||
- **M6 - NixOS deployment.** `nix/` per Q20 (`lock.json`, `package.nix`, `module.nix` with
|
||||
`services.fffVtt`), client build, nginx vhost, systemd hardening, backups timer and restore drill,
|
||||
map import CLI. Accept: deployed behind HTTPS; direct `/_tiles/` 404; WS upgrade works; phone
|
||||
tile-version cleanup. The map import CLI moved to M4 (#79, 2026-11-21); M6 keeps only its cleanup
|
||||
and deployment fit. Accept: deployed behind HTTPS; direct `/_tiles/` 404; WS upgrade works; phone
|
||||
sign-in works; no secret in the access log; backup and restore drill passes.
|
||||
- **M7 - Real-world pass.** Real-network latency/throughput run, iOS/Safari check if available, one
|
||||
real session with the owner's table, SLOW lines collected. Accept: documented numbers, defects
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user