feat(m4): cap map images at Full HD and shrink on import (#85)
The owner fixed the map cap at 1920 px on the long side and 1080 px on the short side (either orientation). fff-vtt import now shrinks a larger source with ImageMagick Lanczos before tiling (alpha kept, proportions preserved, no upscaling), prints `scaled WxH -> WxH`, and records the shrunk w/h; a source at or below the cap is untouched, so the pixel-identity tests still hold. A scene row already above the cap is not rewritten: the server logs `map_above_cap` at startup and serve prints the re-import advice. Docs: ADR-0023, DESIGN 3.3/5.3/8/11.1/13/14, TESTING 5.3/13, README, HANDOFF-M4, client README. The M4 phone gate and the fogbench measurement now use the Full HD maximum; the 16384 px / 262144-cell bench and test rows stay as labelled server stress references. import-scale now proves a 16384² input is shrunk to 1080x1080 (289 tiles at 64 px) quickly and bounded. Part of #63, #85. #77 is blocked by this issue.
This commit is contained in:
+40
-16
@@ -304,6 +304,12 @@ Notes:
|
||||
- A second consequence: map art itself may depict walls/doors. Art is "what players see once there",
|
||||
walls data is "what physics/vision uses". Authoring must keep them consistent; mismatch is GM
|
||||
error, not a leak.
|
||||
- **Map size is capped at Full HD [FIXED (owner decision), 2026-11-21, #85].** An imported map image
|
||||
is at most 1920 px on the long side and 1080 px on the short side, either orientation. The importer
|
||||
shrinks a larger source before tiling (Lanczos, alpha kept, proportions preserved) and the scene
|
||||
`w,h` become the shrunk size; smaller images are imported as-is. The largest scene is therefore
|
||||
60x34 explored cells at cell 32, which bounds the tile tree, the fog texture and the explored
|
||||
bitmaps (ADR-0023, §8, §11.1, §13).
|
||||
- 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 is the import CLI of
|
||||
@@ -525,8 +531,9 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
|
||||
- Prototype stores one row per explored cell (`exp(role, c)`, one INSERT per new cell,
|
||||
`HANDOFF.md`); the real build stores **chunked bitmaps** [FIXED (owner-delegated, 2026-11-15,
|
||||
#21)]: a chunk is 64x64 cells = 512 B, upserted per mutation and only when the mutation dirtied
|
||||
it. Sizes: 4096 px map / 32 px cell = 16 384 cells = 2 KB (2x2 chunks); 16384 px map = 262 144
|
||||
cells = 32 KB (8x8 chunks). The measured write cost and the pinning tests: TESTING §4.4.
|
||||
it. Sizes: the seeded 4096 px map / 32 px cell = 16 384 cells = 2 KB (2x2 chunks); the largest
|
||||
scene, Full HD / 32 px cell = 60x34 = 2040 cells (one chunk, 512 B) [FIXED (owner decision),
|
||||
2026-11-21, #85]. The measured write cost and the pinning tests: TESTING §4.4.
|
||||
- Entity move = one UPSERT of x,y (prototype: `INSERT OR REPLACE INTO tok`).
|
||||
- Migrations: `PRAGMA user_version` + forward-only migration list; startup refuses to run on a newer
|
||||
DB [PROPOSED]. Detail [FIXED (owner-delegated, 2026-11-14, #16)]: `schema_migration(version
|
||||
@@ -570,8 +577,8 @@ explored_chunk(player_id, scene_id, cx, cy, bits BLOB, PRIMARY KEY(player_id, sc
|
||||
row-major inside the chunk, least-significant bit first (cell `(cx, cy)` is bit `(cy mod 64) * 64
|
||||
+ (cx mod 64)`, byte `bit div 8`, mask `1 shl (bit mod 8)`). Cells outside the scene stay 0, so a
|
||||
map whose cell count is not a multiple of 64 needs no special case; the v1 scene is 128x128 cells
|
||||
= 2x2 chunks, a 16384 px map 8x8. Both FKs cascade, so `player.remove` and a scene delete take the
|
||||
explored rows with them. The layout is pinned by tests (TESTING §4.4), so a refactor cannot
|
||||
= 2x2 chunks, the largest Full HD scene is one chunk (#85). Both FKs cascade, so `player.remove`
|
||||
and a scene delete take the explored rows with them. The layout is pinned by tests (TESTING §4.4), so a refactor cannot
|
||||
silently swap axes or bit order.
|
||||
- Step 6 (`token details`) [FIXED (owner-delegated, 2026-11-15, #22)]: adds `entity.props_public`,
|
||||
`props_owner`, `props_gm` (`TEXT NOT NULL DEFAULT '{}'`: one JSON object per visibility bucket)
|
||||
@@ -744,6 +751,10 @@ Targets and accepted decisions. The measured table and the bench scenes are in T
|
||||
fan, never in per-viewer geometry.
|
||||
- **Load/perf regression gate:** the bench and concurrency numbers are compared with committed
|
||||
baselines; fail on > 2x regression [PROPOSED]. Numbers and method: TESTING §5.3.
|
||||
- **Map size bound [FIXED (owner decision), 2026-11-21, #85]:** the product maximum is Full HD
|
||||
(1920x1080), so the largest explored set is 2040 cells at cell 32. The 16384 px and 262144-cell
|
||||
bench rows are kept only as labelled server stress references, never as the product target
|
||||
(ADR-0023).
|
||||
|
||||
### 5.4 Known limitations (carry forward)
|
||||
- Token exactly on a wall cannot move off it: `moveBlocked` counts any touch as a hit, so every move
|
||||
@@ -2026,7 +2037,9 @@ exposure later leaks at most about the wall count (accepted). Rejected: dense id
|
||||
broadcast (in-flight intents hit the wrong wall); game-wide wall counter (per-scene ids keep scene
|
||||
copy/export stable).
|
||||
|
||||
- **Scene** (exactly one in v1, Q3): `id, name, w, h` (px), `tile_size` (32 default =
|
||||
- **Scene** (exactly one in v1, Q3): `id, name, w, h` (px; at most 1920 on the long side and 1080 on
|
||||
the short side [FIXED (owner decision), 2026-11-21, #85]: the importer shrinks larger images, and
|
||||
`scene.set` cannot write `w`/`h` at all, 6.1), `tile_size` (32 default =
|
||||
`explored_cell` [FIXED, Q4]; 64 is the per-scene fallback), `explored_cell` (32 default;
|
||||
`tile_size % cell == 0` required, prototype assumes it silently), `grid_size`,
|
||||
`vision_radius_default`, `token_radius_default` (px, > 0, no upper cap [FIXED, #4]),
|
||||
@@ -2270,13 +2283,20 @@ See TESTING §10.4 (Node 26 black-box harnesses, built-ins only, `devbox run tes
|
||||
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
|
||||
positive multiple of the explored cell (64 px is a common larger choice; with the Full HD cap 32 px
|
||||
is only 2040 tiles). 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
|
||||
and a held lock all exit non-zero with a message and write nothing. **Map images are capped at
|
||||
Full HD [FIXED (owner decision), 2026-11-21, #85]:** a source larger than 1920 px on the long side
|
||||
or 1080 px on the short side is shrunk with ImageMagick's Lanczos filter (alpha kept, proportions
|
||||
preserved) before tiling, the shrink is printed (`scaled 4000x3000 -> 1440x1080`), and the scene
|
||||
row gets the shrunk size; a smaller source is imported as-is and is never upscaled (ADR-0023). An
|
||||
existing DB scene above the cap is not rewritten: the server logs a `map_above_cap` warning at
|
||||
startup and `serve` prints the re-import advice. 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
|
||||
pixel cache is disk-backed and a huge 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).
|
||||
@@ -2353,18 +2373,19 @@ columns with today's defaults) lands complete now, so the later build needs no m
|
||||
`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).
|
||||
offline importer of 11.1 is built in M4 because the gate needs a tiled scene and `scene.set`
|
||||
cannot set `w`, `h`, `tile_size`, `cell` or `art_version` (6.1). Images are capped at Full HD
|
||||
and larger ones are shrunk on import [FIXED (owner decision), 2026-11-21, #85].
|
||||
- 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
|
||||
#77, the one `ready-for-human` step, and M4 accept is met only when it passes.
|
||||
60 fps (the 60 fps target is PROPOSED) with 50 tokens on a Full HD map (max scene, 1920x1080)
|
||||
with fog active is #77, the one `ready-for-human` step, and M4 accept is met only when it passes.
|
||||
- Tile-size gates [FIXED, Q4]: (a) automated headless-Chromium test (mobile emulation, real server
|
||||
path): viewport fills in < 1 s at zoom 1 - met in `client/e2e/map.test.mjs`; (b) one manual run
|
||||
on the owner's 5-year-old Android phone - #77. If either fails: `tile_size` 64 px (per-scene
|
||||
config, no code change). Harness detail and the prototype-run caveat: TESTING §13.
|
||||
- Build evidence (#76): `results/m4-fog-bench.md` (50 tokens / 16384 px: server move path
|
||||
0.119 ms; headless SwiftShader cadence recorded, explicitly not a phone number),
|
||||
- Build evidence (#76): `results/m4-fog-bench.md` (50 tokens / Full HD max scene: server move path
|
||||
recorded; headless SwiftShader cadence recorded, explicitly not a phone number),
|
||||
`results/bench.log`, `results/mutation.log`, `results/nimble-test.log`, and the
|
||||
`devbox run test | client-test | e2e` logs (regenerated, not committed).
|
||||
- **M5 - Robustness and observability.** SIGTERM handler, bounded metrics and SLOW lines, per-client
|
||||
@@ -2400,8 +2421,10 @@ owner may overturn. The full Q1-Q24 decision log is in [`docs/DESIGN-history.md`
|
||||
|
||||
### Open questions
|
||||
|
||||
- **Q2, map size and wall count.** The owner does not know yet; a 16384 px map and 5k walls are
|
||||
PROPOSED test targets (5.3, 13). Revisit with real maps.
|
||||
- **Q2, map size and wall count.** Map size is settled: images are capped at Full HD (1920x1080)
|
||||
[FIXED (owner decision), 2026-11-21, #85; ADR-0023], so the largest scene is 60x34 cells at cell
|
||||
32. The wall count is still unknown; 5k walls remains a PROPOSED server stress target (5.3, 13),
|
||||
not the product scene. Revisit with real maps.
|
||||
- **Q8, table conveniences after v1.** Order decided at M7.
|
||||
- **Q19, where FFF runs.** Hidden state is settled (no state beyond the three buckets and
|
||||
`gm_only`); engine language, runtime and location are not. Options in 9.
|
||||
@@ -2451,3 +2474,4 @@ the section here that it constrains.
|
||||
| [0020](adr/0020-characters-separate-from-tokens.md) | Characters are records separate from tokens | 8 | #14, #23 |
|
||||
| [0021](adr/0021-one-global-lock-v1.md) | One global lock in v1; persistence stays inside it | 4.2, 4.3 | #13 |
|
||||
| [0022](adr/0022-synchronous-normal-full-authoring.md) | `synchronous=NORMAL`, `FULL` around GM authoring | 4.4 | Q12 |
|
||||
| [0023](adr/0023-full-hd-map-cap.md) | Map images are capped at Full HD; the import shrinks larger ones | 3.3, 5.3, 8, 11.1, 13 | #85, #63, #77 |
|
||||
|
||||
Reference in New Issue
Block a user