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:
+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
|
||||
|
||||
Reference in New Issue
Block a user