M4: map import CLI (pulled forward from M6) #79
Notifications
Due Date
No due date set.
Blocks
#77 M4: real-phone playtest gate (Note 10, 60 fps)
SirStone/FFF_vtt_frozen
Reference: SirStone/FFF_vtt_frozen#79
Reference in New Issue
Block a user
Part of #63
Goal
Build the DESIGN §11.1 map import CLI now, in M4, not as a throwaway seeder. The M4 gate needs a real map: #77's phone playtest requires a 16384 px tiled scene with 50 tokens, and today neither the scene dimensions nor the art can be set —
scene.setexplicitly refusesw, h, tile_size, cell, art_version(§6.1 "import is M6 CLI"), and the seeded scene is 4096 px, 32 px tiles,art_version1.DESIGN §11.1 specifies it: "offline CLI that slices an image into
tile_sizePNG/WebP tiles into<state>/tiles/<scene>/v<art_version>/and registers/updates the scene". #63's Out of Scope currently lists "map import CLI (M6)"; the owner-delegated decision of 2026-11-21 (orchestrator) pulls it forward into M4 as the designed CLI. Record that decision in #63 and in DESIGN §13 (M6 → M4 plus a note in §11.1) and DESIGN-history §C.Acceptance criteria
tile_size, and writes tiles to<state>/tiles/<scene>/v<art_version>/in the layout §3.3 and §11.1 fix (origin at world origin, filenames exactly as the tile gate parses them).w,h(from the image),tile_size,art_version; it growsart_versionwhen art is re-imported for an existing scene so browsers do not hit stale caches (§3.3), and it refuses combinations the server would reject (tile_size % cell == 0, tile-size fallback 64 allowed).hello.sceneand the new tiles through the tile gate without any code change; no server-side import path is added.art_version, and the tile gate answers 200 for an allowed new tile (black-box, same harness style astools/*.test.mjs).devbox run test,devbox run client-test,devbox run e2egreen on a clean checkout, no test weakened or skipped.Proven at
New offline CLI plus its black-box Node harness alongside
tools/*.test.mjs(fixture image → tile tree + scene row + tile-gate 200); existingtools/tiles.test.mjsandtools/scene.test.mjsstay green.Notes
tools/genmap.mjs: it is the prototype's deterministic hand-authored fixture generator, not an image importer (§11.1 says so explicitly).Implemented and merged as
ad610ab(main).CLI:
fff-vtt import --image=<png|webp> [--scene=1] [--tile-size=<px>] [--state-dir=<path>]slices at the world origin into<state>/tiles/<scene>/v<art_version>/<x>_<y>.pngand updates the scene roww, h, tile_size, art_version. Re-import growsart_version; older v dirs stay (M6 cleanup). It takes the state-dir lock (live server refuses, exit 3), so stop/import/restart;--tile-sizedefaults to the current tile size and must be a multiple of the 32 px cell (64 fallback).Decoding: ImageMagick via the root devbox (
imagemagick), run with-limit memory 256MiB -limit map 512MiBso its pixel cache is disk-backed and a 16384 px source is memory-sane. No Nim/npm image dependency; FIXED stack unchanged; archivedgenmap.mjsnot reused.Proof:
tools/import.test.mjs(Tiles evidence intools/groups.mjs) covers exact tile set/geometry, the scene row viahello.scene, a player with explored cells getting 200 through nginx+server (unexplored 403, stale version 404), the re-import bump + restart pickup, and every refusal (missing/unsupported/corrupt image, scene != 1, bad tile_size, absent state dir/DB, unreadable DB, held lock). README documents the CLI and the 16384 px / 50-token recipe; DESIGN 3.3/6.1/11.1/13 and DESIGN-history record the M6→M4 move.Gates on rebased main (
bacf2e1):devbox run test161 Node + Nim green,devbox run client-test173 green,devbox run e2e27 green on a clean checkout; kernel log clean (oops|bug:|soft lockup|rcu stall|list_del|general protection|segfault= 0 lines).