Wall wire format, schema and migration #49

Closed
opened 2026-11-15 15:48:54 +01:00 by SirStone · 4 comments
Owner

Part of #38

Question

What fields, units and defaults go on the wire and in the database, how are existing zero-width walls upgraded, and what changes in wall.add/wall.update/door.set?

Already fixed by 5.8 (#42) and 5.7 (#41) — do not re-decide

  • The record's behaviour is the switch set: blocks_sight, blocks_movement, sight_dir (both|left|right), door, open, secret, locked: typed, validated fields with server-side defaults, not entries in flags.
  • kind is not stored and not accepted as input; it is a derived read-only label on the wall/walls frames (wall, door, secret_door, locked_door, terrain, one_way, else custom).
  • wall.add/wall.update accept either a preset name or raw switches, never both; wall.update is absolute, not additive; door.set is unchanged.
  • Invariants to enforce: open/secret/locked require door; a secret door is closed and two-way; a non-door stores all three false.
  • Heights stay GM-only props (height, eye_height), not wall fields (5.7).

Question (narrowed)

Columns on wall, or one validated restrictions object: which and why? Exact field names and defaults on the wire. How do existing rows migrate (kind=wall|door, open, empty flags -> the switch set, with door:true meaning the door preset)? What does the M6 UVTT importer default to, given the format expresses only sight lines plus closed (#40)? Does wall.update's preset go through the same expand-and-validate path as raw switches?

Input from #44 (DESIGN 5.9, decided)

  • Nothing new on the player wire: the who-sees-it numbers are GM-only and derived from walls + tokens + gm props the GM already receives. Decide whether the GM's numbers are computed server-side or in the client (M4) if any GM frame is needed.
  • Heights stay gm props (5.7); see-over adds no wall field, so this card's field list is unchanged.

Input from #47 (DESIGN 5.8, 5.10, decided)

  • The preset list grows window: preset:"window" expands to blocks_sight:false, blocks_movement:true, door:true, open:false, secret:false, locked:false (an opening see-through door). The fixed window is not a preset and needs no name: it stores blocks_sight:false, blocks_movement:true, door:false and derives kind:"terrain".
  • The derived kind list is now wall, door, secret_door, locked_door, terrain, one_way, window, else custom.
  • New validation: a sight_dir other than "both" requires blocks_sight:true (invalid otherwise), in addition to the secret-door two-way rule.
  • sight_dir wording is fixed: left is the (-dy, dx) normal of a -> b and names the blind side; left and right both derive one_way.
  • No new field or column: windows and one-way walls ride the existing switch fields, so the migration gains nothing and the wall payload shape is unchanged.

Input from #48 (DESIGN 5.8, 3.1, 10.3, decided 2026-11-16)

  • Preset set is four names: preset:"wall"|"door"|"window"|"one_way". secret_door and locked_door are removed as wire preset names; secret/locked are raw door switches (editor checkboxes). The window preset expands to blocks_sight:false, blocks_movement:true, door:true, open:false, sight_dir:"both", player_marker:true; the fixed window is the same switches with door:false and has no preset name of its own.
  • Derived kind is by shape, not exact preset match: window (blocks_sight:false + blocks_movement:true, door either), else one_way (blocks_sight:true, sight_dir != "both"), else door (blocks_sight + blocks_movement + door), else wall (blocks_sight + blocks_movement, no door, sight_dir:"both"), else custom. secret/locked never change the label. A secret door still requires open:false, sight_dir:"both" and both block switches on (a secret window would show itself); a locked window is allowed.
  • New wall field player_marker (bool, default false; the window preset sets true) and new optional GM-only label (1..64 code points, the 6.5 text rule, absent/null clears). Both are typed wall fields, never in flags, and wall.update patches them absolutely.
  • New player-bound message named marker (dotless server noun): it carries a player's marker — an anchor point and the player's opaque per-player marker id, nothing else (no kind, open/closed, direction, label, thickness, height, wall id or switch). Full set on connect/resync, diff afterwards, plus the removal spelling. This card decides the fields, the removal form, and the storage (persisted per player like explored; a marker_seen(player, wall) row is the suggested shape). Retract on GM wall remove, player_marker off, wall no longer a window, or geometry change; a moved wall re-earns its marker only when re-seen. A new wall's marker is sent once any point of its visible extent enters a player's polygon (5.8).
  • Wall migration: existing rows get player_marker:false and no label; they behave exactly as today and send no marker. No other migration change: windows and one-way still ride the switch fields.
  • Oracles: label and player_marker join tools/leakcheck.nim's BannedAlways key scan (WALLDATA); the marker gets the MARKER_EARLY/MARKER_EXTRA/MARKER_OFF fault classes and the independence rules of DESIGN 10.3.
Part of #38 ## Question What fields, units and defaults go on the wire and in the database, how are existing zero-width walls upgraded, and what changes in wall.add/wall.update/door.set? ## Already fixed by 5.8 (#42) and 5.7 (#41) — do not re-decide - The record's behaviour is the switch set: `blocks_sight`, `blocks_movement`, `sight_dir` (`both|left|right`), `door`, `open`, `secret`, `locked`: typed, validated fields with server-side defaults, not entries in `flags`. - `kind` is **not** stored and not accepted as input; it is a derived read-only label on the `wall`/`walls` frames (`wall`, `door`, `secret_door`, `locked_door`, `terrain`, `one_way`, else `custom`). - `wall.add`/`wall.update` accept either a `preset` name or raw switches, never both; `wall.update` is absolute, not additive; `door.set` is unchanged. - Invariants to enforce: `open`/`secret`/`locked` require `door`; a secret door is closed and two-way; a non-door stores all three false. - Heights stay GM-only props (`height`, `eye_height`), not wall fields (5.7). ## Question (narrowed) Columns on `wall`, or one validated restrictions object: which and why? Exact field names and defaults on the wire. How do existing rows migrate (`kind=wall|door`, `open`, empty `flags` -> the switch set, with `door:true` meaning the door preset)? What does the M6 UVTT importer default to, given the format expresses only sight lines plus `closed` (#40)? Does `wall.update`'s `preset` go through the same expand-and-validate path as raw switches? ## Input from #44 (DESIGN 5.9, decided) - Nothing new on the player wire: the who-sees-it numbers are GM-only and derived from walls + tokens + `gm` props the GM already receives. Decide whether the GM's numbers are computed server-side or in the client (M4) if any GM frame is needed. - Heights stay `gm` props (5.7); see-over adds no wall field, so this card's field list is unchanged. ## Input from #47 (DESIGN 5.8, 5.10, decided) - The preset list grows `window`: `preset:"window"` expands to `blocks_sight:false`, `blocks_movement:true`, `door:true`, `open:false`, `secret:false`, `locked:false` (an opening see-through door). The fixed window is not a preset and needs no name: it stores `blocks_sight:false`, `blocks_movement:true`, `door:false` and derives `kind:"terrain"`. - The derived `kind` list is now `wall`, `door`, `secret_door`, `locked_door`, `terrain`, `one_way`, `window`, else `custom`. - New validation: a `sight_dir` other than `"both"` requires `blocks_sight:true` (`invalid` otherwise), in addition to the secret-door two-way rule. - `sight_dir` wording is fixed: `left` is the `(-dy, dx)` normal of `a -> b` and names the blind side; `left` and `right` both derive `one_way`. - No new field or column: windows and one-way walls ride the existing switch fields, so the migration gains nothing and the wall payload shape is unchanged. ## Input from #48 (DESIGN 5.8, 3.1, 10.3, decided 2026-11-16) - **Preset set is four names:** `preset:"wall"|"door"|"window"|"one_way"`. `secret_door` and `locked_door` are **removed** as wire preset names; `secret`/`locked` are raw door switches (editor checkboxes). The `window` preset expands to `blocks_sight:false, blocks_movement:true, door:true, open:false, sight_dir:"both", player_marker:true`; the fixed window is the same switches with `door:false` and has no preset name of its own. - **Derived `kind` is by shape, not exact preset match:** `window` (`blocks_sight:false` + `blocks_movement:true`, door either), else `one_way` (`blocks_sight:true`, `sight_dir != "both"`), else `door` (`blocks_sight` + `blocks_movement` + `door`), else `wall` (`blocks_sight` + `blocks_movement`, no door, `sight_dir:"both"`), else `custom`. `secret`/`locked` never change the label. A secret door still requires `open:false`, `sight_dir:"both"` and **both** block switches on (a secret window would show itself); a locked window is allowed. - **New wall field `player_marker`** (bool, default `false`; the `window` preset sets `true`) and new optional GM-only `label` (1..64 code points, the 6.5 text rule, absent/`null` clears). Both are typed wall fields, never in `flags`, and `wall.update` patches them absolutely. - **New player-bound message named `marker`** (dotless server noun): it carries a player's marker — **an anchor point and the player's opaque per-player marker id, nothing else** (no kind, open/closed, direction, label, thickness, height, wall id or switch). Full set on connect/resync, diff afterwards, plus the removal spelling. This card decides the fields, the removal form, and the storage (persisted per player like explored; a `marker_seen(player, wall)` row is the suggested shape). Retract on GM wall remove, `player_marker` off, wall no longer a window, or geometry change; a moved wall re-earns its marker only when re-seen. A new wall's marker is sent once any point of its visible extent enters a player's polygon (5.8). - **Wall migration:** existing rows get `player_marker:false` and no `label`; they behave exactly as today and send no marker. No other migration change: windows and one-way still ride the switch fields. - **Oracles:** `label` and `player_marker` join `tools/leakcheck.nim`'s `BannedAlways` key scan (`WALLDATA`); the marker gets the `MARKER_EARLY`/`MARKER_EXTRA`/`MARKER_OFF` fault classes and the independence rules of DESIGN 10.3.
SirStone added the wayfinder:grilling label 2026-11-15 15:48:54 +01:00
SirStone added a new dependency 2026-11-15 15:48:59 +01:00
SirStone added a new dependency 2026-11-15 15:48:59 +01:00
SirStone added a new dependency 2026-11-15 15:48:59 +01:00
SirStone added a new dependency 2026-11-15 15:48:59 +01:00
SirStone added a new dependency 2026-11-15 15:48:59 +01:00
SirStone added a new dependency 2026-11-15 16:13:20 +01:00
Author
Owner

Open from #41: what height do existing tokens/characters get at migration (height is required)?

Open from #41: what height do existing tokens/characters get at migration (height is required)?
Author
Owner

Input from #43 (prototype, pictures + findings) — suggestion passed on, this card owns the decision.

  • Precompute the filtered sight-segment list once per wall edit (rebuild on wall.* / door.set), then run the fan over that list. Filtering per query instead costs +0.15 ms per polygon at 5k walls — 2.8× the sparse baseline, ≈ 0.9 ms for a 6-token party, i.e. the whole per-move budget.
  • The only decision that must stay per observer is one-way: a cheap per-wall test on the pre-built list, or two pre-built lists (one per direction).
  • Thickness can also be hoisted with it: store each blocking wall as a 4-face quad in the list (viewer-independent), not a 3-face silhouette. Measured 0.26 ms sparse / 12.7 ms dense on the hoisted quad vs 0.94 / 13.2 per query; #45's owner-accepted cost assumes the hoisted form.
  • The filter itself is exactly 5.8 and nothing else: blocks_sight on, open door off, one-way only for the blocked side; terrain (blocks_sight:false) costs literally zero geometry (identical polygon and explored set).
**Input from #43** (prototype, [pictures + findings](https://git.fossellini.top/SirStone/FFF_vtt/src/branch/prototype/wall-sight/prototype-wall-sight/index.html)) — suggestion passed on, this card owns the decision. - **Precompute the filtered sight-segment list once per wall edit** (rebuild on `wall.*` / `door.set`), then run the fan over that list. Filtering per query instead costs +0.15 ms per polygon at 5k walls — 2.8× the sparse baseline, ≈ 0.9 ms for a 6-token party, i.e. the whole per-move budget. - The only decision that must stay per observer is one-way: a cheap per-wall test on the pre-built list, or two pre-built lists (one per direction). - Thickness can also be hoisted with it: store each blocking wall as a 4-face quad in the list (viewer-independent), not a 3-face silhouette. Measured 0.26 ms sparse / 12.7 ms dense on the hoisted quad vs 0.94 / 13.2 per query; #45's owner-accepted cost assumes the hoisted form. - The filter itself is exactly 5.8 and nothing else: `blocks_sight` on, open door off, one-way only for the blocked side; `terrain` (`blocks_sight:false`) costs literally zero geometry (identical polygon and explored set).
Author
Owner

Input from #50 (DESIGN 5.4, 5.5, 5.8, 5.10, decided 2026-11-17; commit 2a160fb)

  • No new wire field for doors. A door's leaf is its own body: the same a, b, thickness and position as any wall (5.10). A door stores no leaf geometry of its own, and opening/closing changes only open. So this card's field list, payload shape, columns-vs-one-object choice and validation are untouched by doors.
  • Presets set switches only, never geometry. preset:"door" / "window" expand to the switch set as already fixed (#47/#48); thickness and position come from the GM/editor (last-used thickness, 5.10) and must not be implied or reset by a preset. A wall.add may combine a preset with explicit thickness/position.
  • Migration: every existing wall — doors included — gets thickness: 0, position: "center" (#45). That is also what makes an existing door's close push byte-for-byte identical to today's, so there is no door-specific migration and no door-specific default.
  • Thick scenes must be expressible over the wire for the #46 equivalence group's thick pairs (10.3, #50): the same wall.add/wall.update payload carries the thick body, and a GM door.set on it changes only open.
  • Open doors carry no geometry difference: the body simply does not block, so nothing on the wire distinguishes "open" beyond open itself; the push (#50) adds no intent and no field — it is the existing server-originated token position change.

Push geometry, the zero-thickness regression gate and the four new mutations are in DESIGN 5.5 and 10.3, not this card's.

## Input from #50 (DESIGN 5.4, 5.5, 5.8, 5.10, decided 2026-11-17; commit `2a160fb`) - **No new wire field for doors.** A door's leaf is its own body: the same `a`, `b`, `thickness` and `position` as any wall (5.10). A door stores no leaf geometry of its own, and opening/closing changes only `open`. So this card's field list, payload shape, columns-vs-one-object choice and validation are untouched by doors. - **Presets set switches only, never geometry.** `preset:"door"` / `"window"` expand to the switch set as already fixed (#47/#48); `thickness` and `position` come from the GM/editor (last-used thickness, 5.10) and must not be implied or reset by a preset. A `wall.add` may combine a preset with explicit `thickness`/`position`. - **Migration:** every existing wall — doors included — gets `thickness: 0, position: "center"` (#45). That is also what makes an existing door's close push byte-for-byte identical to today's, so there is no door-specific migration and no door-specific default. - **Thick scenes must be expressible over the wire** for the #46 equivalence group's thick pairs (10.3, #50): the same `wall.add`/`wall.update` payload carries the thick body, and a GM `door.set` on it changes only `open`. - **Open doors carry no geometry difference:** the body simply does not block, so nothing on the wire distinguishes "open" beyond `open` itself; the push (#50) adds no intent and no field — it is the existing server-originated token position change. Push geometry, the zero-thickness regression gate and the four new mutations are in DESIGN 5.5 and 10.3, not this card's.
SirStone self-assigned this 2026-11-17 22:19:40 +01:00
Author
Owner

Resolved — DESIGN v0.29, commit 287859d (not pushed)

Owner-fixed (2026-11-17):

  • Wall height is a proper typed wall field: metres, optional, > 0 and <= 100, absent/null = full height; GM-only, carried on the GM wall/walls frames, never on a player frame (BannedAlways). Resolves the 5.7/5.8/6.1/8 contradiction consistently: 5.7's "no dedicated column and no wire field" is narrowed with a dated tag to tokens and characters (they have props; a wall has none), 5.8's "no behaviour in flags" holds, and 6.1's frames gain height.
  • Migration: every existing token and character gets height: 1.8 m in props_gm, filled in code only when absent; eye_height is not written, so #41's 93 % rule is unchanged. #41's deferred question is closed.
  • Existing walls map to today exactly: thickness 0, position center, blocks_sight/blocks_movement 1, sight_dir both, player_marker 0, label/height NULL, secret/locked 0; kind='door' -> door=1 with the same open, kind='wall' -> door=0. No real data exists pre-M4, so correctness = fixture/history hygiene + byte-identical behaviour gates (5.8 player frames, #50 zero-thickness push).

Delegated picks (FIXED, owner-delegated):

  1. Typed columns with CHECK constraints, not one JSON object. Precedent (scene, entity keep interpreted data in columns; flags/props_* are for data the server never reads), CHECKs can reject an impossible switch set (open on a non-door, one-way window), and loadScene stays a typed row read with no second parse/validate path. 5.8's "one object" is the domain/wire object; the columns are its storage.
  2. Migration step 8, forward-only in code. The Migration entry gains a data hook (inside the step's transaction) for the height backfill; the legacy kind column is dropped by a table rebuild, since kind becomes an output-only derived label. Rebuild over ALTER TABLE ... DROP COLUMN because the step must drop kind and add nine NOT NULL CHECKed columns atomically, and SQLite refuses to drop a column named in a CHECK.
  3. flags stays, for non-behaviour data only; no switch or geometry lives there.
  4. Wire: wall.add/wall.update take thickness, position, height, label plus preset XOR raw switches. A preset replaces the whole switch set and never implies geometry; raw switches on update patch only what is present; height:null/label:null clear; wall.update remains absolute; door.set is unchanged; add, update and the M6 importer share one expand-and-validate path.
  5. proto goes to 2 with a 6.2 changelog line: an old client's {"kind":"door"} would otherwise be ignored and silently create a solid wall.
  6. GM frames (walls/wall): id, a, b, thickness, position, height, kind, blocks_sight, blocks_movement, sight_dir, player_marker, door, open, secret, locked, label, flags; height and label are always present (null when unset); kind is derived only.
  7. marker: {full:bool, set:[{id, pos}], del:[id]}, the encountered spelling. pos is the drawn midpoint in integer px (rounded once); id is an opaque per-player 12-character string from the token alphabet (no counter column, no reuse question, never the wall id); the full set goes after explored in the 6.3 player order; the GM receives no marker frames (a player's markers are their own memory, like explored); emission requires player_marker:true and the wall deriving window; storage is marker_seen with cascade on the player and on the wall (composite FK), while the other retractions are a deliberate delete in the update path.
  8. label/height NULL: both are written as SQL literals (NULL when absent) by one helper, because db_connector cannot bind NULL and neither '' nor 0 is a legal value (so no sentinel, unlike encountered.actual_name).
  9. UVTT importer (M6): thickness 0, center, both blocks on, sight_dir both, player_marker false, no label/height; a portal is door:true, open = not closed. Recorded in DESIGN 6.1/8; no ticket.
  10. Leakcheck: BannedAlways gains every wall field name (thickness, position, height, blocks_sight, blocks_movement, sight_dir, player_marker, door, open, secret, locked, label); marker joins the allowed server types; the marker oracle's shape is fixed. The MARKER_* classes stay as recorded in #48.
  11. Fixture churn (build tickets): tests/tdb.nim LatestVersion 7 -> 8 and the step count; tools/persistence.test.mjs schema_version assertion plus a new schema-7 fixture; the listed server modules and test/fixture files in DESIGN 10.3.

Docs: DESIGN.md v0.29 (§3.1, §4.4 step 8, 5.7, 5.8, 5.9, 5.10, 6.1, 6.2, 6.3, 8, 10.3, dated §14 entry), GLOSSARY.md (Height, Wall, Player marker, new Marker id). Commit 287859d.

## Resolved — DESIGN v0.29, commit `287859d` (not pushed) **Owner-fixed (2026-11-17):** - **Wall `height` is a proper typed wall field:** metres, optional, `> 0` and `<= 100`, absent/`null` = full height; GM-only, carried on the GM `wall`/`walls` frames, never on a player frame (`BannedAlways`). Resolves the 5.7/5.8/6.1/8 contradiction consistently: 5.7's "no dedicated column and no wire field" is narrowed with a dated tag to tokens and characters (they have `props`; a wall has none), 5.8's "no behaviour in `flags`" holds, and 6.1's frames gain `height`. - **Migration:** every existing token and character gets `height: 1.8 m` in `props_gm`, filled in code only when absent; `eye_height` is not written, so #41's 93 % rule is unchanged. #41's deferred question is closed. - **Existing walls map to today exactly:** `thickness 0`, `position center`, `blocks_sight`/`blocks_movement` 1, `sight_dir both`, `player_marker` 0, `label`/`height` NULL, `secret`/`locked` 0; `kind='door'` -> `door=1` with the same `open`, `kind='wall'` -> `door=0`. No real data exists pre-M4, so correctness = fixture/history hygiene + byte-identical behaviour gates (5.8 player frames, #50 zero-thickness push). **Delegated picks (FIXED, owner-delegated):** 1. **Typed columns with CHECK constraints, not one JSON object.** Precedent (`scene`, `entity` keep interpreted data in columns; `flags`/`props_*` are for data the server never reads), CHECKs can reject an impossible switch set (open on a non-door, one-way window), and `loadScene` stays a typed row read with no second parse/validate path. 5.8's "one object" is the domain/wire object; the columns are its storage. 2. **Migration step 8, forward-only in code.** The `Migration` entry gains a `data` hook (inside the step's transaction) for the height backfill; the legacy `kind` column is **dropped** by a table rebuild, since `kind` becomes an output-only derived label. Rebuild over `ALTER TABLE ... DROP COLUMN` because the step must drop `kind` and add nine NOT NULL CHECKed columns atomically, and SQLite refuses to drop a column named in a CHECK. 3. **`flags` stays**, for non-behaviour data only; no switch or geometry lives there. 4. **Wire:** `wall.add`/`wall.update` take `thickness`, `position`, `height`, `label` plus `preset` XOR raw switches. A preset replaces the whole switch set and never implies geometry; raw switches on update patch only what is present; `height:null`/`label:null` clear; `wall.update` remains absolute; `door.set` is unchanged; add, update and the M6 importer share one expand-and-validate path. 5. **`proto` goes to 2** with a 6.2 changelog line: an old client's `{"kind":"door"}` would otherwise be ignored and silently create a solid wall. 6. **GM frames** (`walls`/`wall`): `id, a, b, thickness, position, height, kind, blocks_sight, blocks_movement, sight_dir, player_marker, door, open, secret, locked, label, flags`; `height` and `label` are always present (`null` when unset); `kind` is derived only. 7. **`marker`**: `{full:bool, set:[{id, pos}], del:[id]}`, the `encountered` spelling. `pos` is the drawn midpoint in integer px (rounded once); `id` is an opaque per-player 12-character string from the token alphabet (no counter column, no reuse question, never the wall id); the full set goes after `explored` in the 6.3 player order; **the GM receives no marker frames** (a player's markers are their own memory, like explored); emission requires `player_marker:true` **and** the wall deriving `window`; storage is `marker_seen` with cascade on the player and on the wall (composite FK), while the other retractions are a deliberate delete in the update path. 8. **`label`/`height` NULL:** both are written as SQL literals (`NULL` when absent) by one helper, because db_connector cannot bind NULL and neither `''` nor `0` is a legal value (so no sentinel, unlike `encountered.actual_name`). 9. **UVTT importer (M6):** thickness 0, center, both blocks on, `sight_dir both`, `player_marker` false, no label/height; a portal is `door:true, open = not closed`. Recorded in DESIGN 6.1/8; no ticket. 10. **Leakcheck:** `BannedAlways` gains every wall field name (`thickness`, `position`, `height`, `blocks_sight`, `blocks_movement`, `sight_dir`, `player_marker`, `door`, `open`, `secret`, `locked`, `label`); `marker` joins the allowed server types; the marker oracle's shape is fixed. The `MARKER_*` classes stay as recorded in #48. 11. **Fixture churn (build tickets):** `tests/tdb.nim` LatestVersion 7 -> 8 and the step count; `tools/persistence.test.mjs` schema_version assertion plus a new schema-7 fixture; the listed server modules and test/fixture files in DESIGN 10.3. **Docs:** DESIGN.md v0.29 (§3.1, §4.4 step 8, 5.7, 5.8, 5.9, 5.10, 6.1, 6.2, 6.3, 8, 10.3, dated §14 entry), GLOSSARY.md (`Height`, `Wall`, `Player marker`, new `Marker id`). Commit `287859d`.
Sign in to join this conversation.