docs: add ADRs for the durable design decisions
22 ADRs: server-authoritative sight and single egress, per-recipient views/diffs, uniform nack, opaque ids, 32 px tile unit, wall switches/presets, see-over, thick walls, open-door gap, typed wall columns, proto 2, build order, zoom clamp, accepted status leak, player marker, chunked explored, slow-client policy, session/key split, closing message, character records, global lock, synchronous choice. Each links its tickets and its spec section.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# The server alone decides what each player sees
|
||||
|
||||
Every client is untrusted, including the GM's browser. The server computes per-player vision and
|
||||
explored area, builds a typed per-recipient view, and sends only the diff; client-side fog is
|
||||
cosmetic. All bytes to a player leave through one egress module that accepts a recipient and that
|
||||
recipient's view, and raw world state has no code path into it. We chose this over trusting the
|
||||
client to hide fog or over sending world state and filtering in the browser, because a modified
|
||||
client must learn nothing it is not entitled to.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Trust the client with the full world and draw fog client-side: rejected, one devtools tab defeats
|
||||
it.
|
||||
- Send a filtered frame from each handler: rejected, filtering spreads across the codebase and a new
|
||||
frame is a new leak surface.
|
||||
- Enforce the boundary by discipline in a `sync()` function (the prototype): kept as the fallback,
|
||||
replaced by distinct `PlayerView`/`GmView` types.
|
||||
|
||||
## Consequences
|
||||
The server recomputes vision on every relevant mutation and holds per-player explored state, so it
|
||||
needs the vision budget of current §5.3. A new message type must be built inside the egress or it
|
||||
cannot reach a player. Leak testing is possible because there is one place to audit.
|
||||
|
||||
## Tickets
|
||||
#11 (wire catalogue), #20 (typed views and single egress).
|
||||
|
||||
## Spec
|
||||
Current §2 (trust boundary, single egress rule), §3.1 (what each role receives), §3.4 T1/T2.
|
||||
@@ -0,0 +1,31 @@
|
||||
# Per-recipient typed views and state-based diffs
|
||||
|
||||
Each connection keeps a `known` table of the last view it was sent; the egress builds the current
|
||||
view for that recipient, diffs it against `known`, and sends only what changed. Messages are built
|
||||
from typed structures (`PlayerView`, `GmView`, per-token views), not from a shared JSON tree, and
|
||||
every server frame carries a per-connection counter `n` rather than a global sequence number. We
|
||||
chose this over broadcasting mutations and over a global counter because players must not learn that
|
||||
a hidden mutation happened from a gap in a sequence, and because a full-state push per mutation is
|
||||
too large (a player move's full polygon is ~3 KB).
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Broadcast every mutation and let each client filter: rejected, leaks hidden entities and needs the
|
||||
client to hold world state.
|
||||
- Global `gseq` with per-recipient filtering: rejected, gaps reveal that something hidden changed
|
||||
(the prototype did this).
|
||||
- Full snapshot per mutation: rejected, the vision polygon alone is ~3 KB per move.
|
||||
|
||||
## Consequences
|
||||
The diff base is the frame before `n` is stamped, so stamping must deep-copy; otherwise every frame
|
||||
looks changed (a real bug fixed in slice 8). State messages can be coalesced per key at flush time
|
||||
without desynchronising the client, which is what makes the bounded outbox (ADR-0017) safe. Ordering
|
||||
between an ack and the state messages it caused is not guaranteed.
|
||||
|
||||
## Tickets
|
||||
#11, #20; #28 (borrowed egress context), #31 (one scene read per request).
|
||||
|
||||
## Spec
|
||||
Current §2, §3.1, §4.2, §6.4.
|
||||
@@ -0,0 +1,28 @@
|
||||
# A refused move carries only the old position
|
||||
|
||||
A refused player move — locked, over the step cap, wall collision — returns `ack {ok:false, pos:<old
|
||||
position>}` with no `code` and no reason, and a GM move out of bounds uses the same shape. Every
|
||||
other refusal carries a static code and no position. We chose one opaque shape because a
|
||||
wall-probing client can otherwise binary-search walls and doors beyond its line of sight from the
|
||||
differences between refusals.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Per-cause codes (`blocked`, `out-of-range`, `locked`): rejected, each distinction is an oracle.
|
||||
- Echoing the collision point or the blocking wall: rejected, leaks geometry.
|
||||
- Explicitly refusing the whole intent class with a reason for the GM: the GM already sees all
|
||||
walls, but one shape keeps the code path single.
|
||||
|
||||
## Consequences
|
||||
The client cannot explain a refusal; it snaps back (or waits for release while dragging). The step
|
||||
cap (the token's effective vision radius, or the scene default) bounds what one probe can learn, and
|
||||
the rate limit bounds the number of probes. Tests assert the shape and that two scenes differing
|
||||
only beyond the cap produce identical replies.
|
||||
|
||||
## Tickets
|
||||
#11, #15, Q18; T8/T9 in current §3.4.
|
||||
|
||||
## Spec
|
||||
Current §5.5 (player move, GM move), §6 (uniform move refusal), §6.5 (ack codes).
|
||||
@@ -0,0 +1,27 @@
|
||||
# Tokens get random opaque ids; walls get per-scene counters
|
||||
|
||||
A token id is 12 characters from `[A-Za-z0-9_-]` drawn from the OS CSPRNG (72 bits),
|
||||
collision-checked at create and unique game-wide. A wall id is a per-scene counter (`next_wall_id`)
|
||||
that is monotonic and never reused. We chose different schemes because token ids reach players (as
|
||||
`mine`, `encountered`, `vision`), so a counter would leak how many hidden tokens exist through gaps,
|
||||
while wall ids never reach a player and a counter keeps scene copy/export stable.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Dense counters for tokens: rejected, gaps leak hidden tokens.
|
||||
- Random ids for walls: rejected, ids must stay readable/stable across a scene export and import,
|
||||
and nothing player-facing depends on them.
|
||||
- A game-wide wall counter: rejected, per-scene ids keep a scene self-contained.
|
||||
|
||||
## Consequences
|
||||
Token creation checks collision against the loaded set; no counter column is needed. A token may
|
||||
later change scene and keep its id. Removing a wall never renumbers and never reuses its id, and a
|
||||
restart reloads `next_wall_id` from the scene row.
|
||||
|
||||
## Tickets
|
||||
#3 (ids), #20 (token ids).
|
||||
|
||||
## Spec
|
||||
Current §8 (ids, wall and token paragraphs), §4.4 step 3 (`next_wall_id`).
|
||||
@@ -0,0 +1,30 @@
|
||||
# A 32 px tile is the unit of disclosure, and the edge leak is accepted
|
||||
|
||||
The map is served as 32 px tiles, the tile grid shares the explored cell grid and the world origin,
|
||||
and a tile is allowed as soon as its cell is explored. A vision polygon that grazes a cell therefore
|
||||
discloses the whole cell's art, including pixels LOS did not see, and once revealed a tile is never
|
||||
revoked. We accepted this rather than masking tiles server-side because masking costs image
|
||||
processing in Nim on every request, and smaller tiles multiply requests; the authoring rule is to
|
||||
keep secrets out of map art within ~32 px of reachable areas and to model secrets as GM-only
|
||||
entities.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- 256 px tiles (the prototype): rejected, a 256 px leak is too large.
|
||||
- Server-side masked tiles: rejected for v1, cost and complexity.
|
||||
- Gate on a fraction of explored cells: rejected, still discloses the whole tile and complicates the
|
||||
rule.
|
||||
|
||||
## Consequences
|
||||
A tile may reveal up to one 32 px cell of unseen art; it is documented as accepted (T5), not
|
||||
testable as a leak. Tile URLs are immutable per `art_version`, cached privately, and door state is
|
||||
never in tiles. The M4 gates (headless mobile emulation and one phone run) can force 64 px per scene
|
||||
without a code change.
|
||||
|
||||
## Tickets
|
||||
Q4, #7, #24; H8.
|
||||
|
||||
## Spec
|
||||
Current §3.3, §3.4 T5, §8 (scene tile size).
|
||||
@@ -0,0 +1,32 @@
|
||||
# A wall is a set of switches; kinds are presets and derived labels
|
||||
|
||||
A wall record carries independent switches — `blocks_sight`, `blocks_movement`, `player_marker`, the
|
||||
door settings `door`/`open`/`secret`/`locked` and a sight-only `sight_dir` — and the server reads
|
||||
those. `wall`, `door`, `window` and `one_way` are editor presets and GM-facing labels only; `kind`
|
||||
is derived by shape (`window`, then `one_way`, then `door`, then `wall`, else `custom`) and is never
|
||||
stored or accepted as input. We rejected a fixed kind enum as the record's behaviour and
|
||||
client-interpreted free flags because a named kind and the actual rules would drift, and because the
|
||||
set of useful barrier behaviours (railing, bush, pit edge, fixed window) is one switch set with
|
||||
different labels.
|
||||
|
||||
## Status
|
||||
accepted (supersedes any earlier kind-enum or `terrain` reading; see history §D)
|
||||
|
||||
## Alternatives
|
||||
- A stored `kind` enum with per-kind code: rejected, every combination needs a new kind and the
|
||||
label becomes the authority.
|
||||
- Free-form flags interpreted by the client: rejected, the server must enforce sight and movement.
|
||||
- A `terrain` preset/kind for "blocks movement, not sight": dropped; that switch set is a fixed
|
||||
window.
|
||||
|
||||
## Consequences
|
||||
`secret`/`locked` are flags that never change the label, and a one-way door is labelled `one_way`. A
|
||||
preset expands server-side to switches and never implies thickness, position or height. The editor
|
||||
may show four presets plus checkboxes; two presets cannot drift from what the wall does because the
|
||||
presets are not stored. The switch set is closed in v1, so a new axis is a schema step (ADR-0010).
|
||||
|
||||
## Tickets
|
||||
#42 (switch model), #47 (window and direction), #48 (four presets, marker, label).
|
||||
|
||||
## Spec
|
||||
Current §1 (principle), §5.8, §6.1 (wall payloads), §7.4 (editor), §8.
|
||||
@@ -0,0 +1,33 @@
|
||||
# See-over is a per-target predicate over a strict vision polygon
|
||||
|
||||
A token is visible across a low wall when the line from the viewer's effective eye height to the
|
||||
token's top clears every sight-blocking wall it crosses, strictly (equality is hidden), at every
|
||||
crossed face of a thick wall. The vision polygon stays strict and stops at every sight wall's line,
|
||||
so the floor behind a low wall stays unexplored and black even when a figure standing on it is
|
||||
visible. We chose a per-target predicate rather than a permissive polygon or a per-wall "see-over"
|
||||
switch because it is the only model that answers "who sees this token" with one pass and keeps
|
||||
`visibilityPolygon`, `cellsTouched` and the tile gate height-blind.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- A permissive polygon that reveals a band behind the wall: rejected, it fogs floor nobody can see
|
||||
and complicates the tile gate.
|
||||
- A `see_over` switch on the wall: rejected, what is visible depends on the viewer's eye and the
|
||||
target's height, not on the wall alone.
|
||||
- A distance rule or an "adjacent always visible" exception: rejected, both are rules-engine
|
||||
judgements.
|
||||
|
||||
## Consequences
|
||||
A visible token may stand on an unexplored cell ("floating on black"); players get a binary answer
|
||||
and the whole token, never a clipped body or a cover percentage. The GM gets a who-sees-it view with
|
||||
a visible fraction, computed from data the GM already receives. The independent oracle needs its own
|
||||
height test, and cells in a low wall's hidden band are oracle-*maybe* for explored/tiles. Movement
|
||||
never reads height.
|
||||
|
||||
## Tickets
|
||||
#41 (heights and units), #44 (see-over).
|
||||
|
||||
## Spec
|
||||
Current §5.7, §5.9, §5.10 (crossed faces), §7.4.
|
||||
@@ -0,0 +1,34 @@
|
||||
# A thick wall is one rectangle read by both sight and movement
|
||||
|
||||
Thickness widens the drawn `a -> b` line into a rectangle of length `|ab|` with square ends, placed
|
||||
`center`, `left` or `right` of the line. The same exact rectangle is the sight footprint (four
|
||||
faces, hoisted once per wall edit and viewer-independent) and the movement collider (true
|
||||
circle-vs-rectangle distance, centre inside = overlap). We chose one shared shape over a generous
|
||||
sight shape or a separate collider because a corner that is generous to one reader and tight to the
|
||||
other is a class of bugs and leaks; and we chose the four-face quad over an observer-dependent
|
||||
three-face silhouette because only the quad can be hoisted (measured 3.15x vs 8.4x on the 5k sparse
|
||||
layout).
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Inflate the wall by the token radius for movement: rejected, not the same shape as sight.
|
||||
- Three-face near+caps silhouette: rejected, observer-dependent, cannot be hoisted, 0.699 ms/query
|
||||
vs 0.263 ms hoisted quad.
|
||||
- Polygon/mitre joints: rejected, a small outer notch at overlaps is acceptable and a cave is a
|
||||
chain of straight walls.
|
||||
|
||||
## Consequences
|
||||
`thickness: 0` degrades exactly to the old segment. The body is opaque floor: never in a player
|
||||
polygon, never newly explored, no tile revealed under it. A token whose centre is inside a
|
||||
sight-blocking body sees nothing until the GM moves it out. Wall edits never push (they set
|
||||
`stuck`); only a door close pushes. The rectangle-distance primitive serves the move checks, the
|
||||
status overlap, the door push and resize. Curved walls stay possible by changing the one wall-shape
|
||||
function.
|
||||
|
||||
## Tickets
|
||||
#45 (thickness), #43 (cost measurements), #47 (one-way body), #50 (door leaf and push).
|
||||
|
||||
## Spec
|
||||
Current §5.10, §5.5, §5.9, §8.
|
||||
@@ -0,0 +1,30 @@
|
||||
# An open door is only a gap; the leaf is the wall's own body
|
||||
|
||||
A door stores the same `a`, `b`, `thickness` and `position` as any wall, and that body is its leaf
|
||||
for sight, movement and the close push. Opening removes the body from both readers and leaves only
|
||||
the gap between the wall pieces on either side; closing puts the same body back. Nothing swings,
|
||||
slides or hinges, so a close never sweeps an arc through the room. We rejected a separate leaf
|
||||
rectangle inside a deep opening and any clamp to the neighbouring jambs because that would create a
|
||||
second geometry model, a second set of edge cases and a shape that disagrees with what the GM drew.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- A thin leaf inside a thick opening: rejected, second geometry and a swing/clamp model.
|
||||
- Clamping the leaf to the jamb inner faces: rejected, the drawn door would not be the door.
|
||||
- Keeping an open door's body as an invisible blocker for sight or movement: rejected, an open
|
||||
doorway must be a true gap.
|
||||
|
||||
## Consequences
|
||||
A thick door bulges out of its doorway or leaves a step behind its jambs; that is authoring, not a
|
||||
rule. A deep opening between thick jambs keeps the tunnel/keyhole view. The close push is measured
|
||||
from the body with the 5.5 formula and reduces term-for-term to the old zero-thickness push, which
|
||||
is the regression gate. A fixed window (`door:false`) never closes and so never pushes; a locked or
|
||||
secret door pushes exactly as a plain closed door, preserving the door-equivalence obligation.
|
||||
|
||||
## Tickets
|
||||
#46 (secret and locked doors), #50 (door geometry and push).
|
||||
|
||||
## Spec
|
||||
Current §5.5 (door close push), §5.8 (closed vs open, leaf), §5.10.
|
||||
@@ -0,0 +1,30 @@
|
||||
# The wall record is stored as typed columns with CHECK constraints
|
||||
|
||||
Every interpreted wall field — geometry, the eight switches, `height` and `label` — is its own typed
|
||||
SQLite column with CHECK constraints; `flags` remains a JSON object for GM data the server never
|
||||
reads. We chose columns over one JSON object because SQLite CHECKs can reject an impossible switch
|
||||
set (an open non-door, a one-way window with no sight to block), `loadScene` can read a row straight
|
||||
into a typed `WallRec` with no second parse-and-validate path at startup, and the project's
|
||||
precedent is a column for everything the server reads while `props_*`/`flags` hold what it does not.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- One JSON object per wall: rejected, no CHECKs without triggers, and a parse/validate path at every
|
||||
startup.
|
||||
- A chain of `ALTER TABLE` statements: rejected, `DROP COLUMN` refuses a column named in a CHECK,
|
||||
and the step must drop the legacy `kind` and add the new columns in one shape.
|
||||
- Keeping the legacy `kind` column alongside the switches: rejected, two authorities could drift.
|
||||
|
||||
## Consequences
|
||||
Migration step 8 rebuilds the table and drops `kind`; the mapping is "today's behaviour" for every
|
||||
existing row. `height` and `label` are nullable and written as SQL literals because `db_connector`
|
||||
cannot bind NULL and neither `''` nor `0` is a legal value. A new switch axis is a schema step.
|
||||
§5.8's "one object" is the domain and wire object; the columns are how that object is stored.
|
||||
|
||||
## Tickets
|
||||
#49.
|
||||
|
||||
## Spec
|
||||
Current §4.4 step 8, §5.8 ("Where the switches live"), §6.1 (storage), §8.
|
||||
@@ -0,0 +1,31 @@
|
||||
# The wall-record change bumps `proto` to 2
|
||||
|
||||
`proto` is compiled into both client and server and is required on the `/ws` upgrade. The wall-model
|
||||
build changes `wall.add`/`wall.update` to take typed fields and a `preset` instead of `kind`, adds
|
||||
`height` to the GM frames, and adds the player `marker` message, so it bumps `proto` from 1 to 2.
|
||||
The bump is necessary because the old input shape is dangerous rather than merely old: the server
|
||||
ignores unknown fields, so a `proto` 1 client's `{"kind":"door"}` would silently create a solid
|
||||
wall.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Keep `proto` 1 and accept both shapes: rejected, the ambiguity is silent and safety-relevant.
|
||||
- Reject unknown fields instead of ignoring them: a larger breaking change for every client and not
|
||||
needed once the version is bumped.
|
||||
- Infer the version from the payload shape: rejected, a heuristic on a security-relevant
|
||||
distinction.
|
||||
|
||||
## Consequences
|
||||
A mismatch (older or newer) completes the upgrade, sends `closing {reason:"proto-mismatch",
|
||||
code:4003}` and closes, because a browser cannot read an HTTP status on a WebSocket and the mummy
|
||||
pin cannot send application close codes (ADR-0019). No `hello` and no state follow. The client shows
|
||||
"reload"; content-hashed assets fetch the matching client. Within one `proto`, changes are additive
|
||||
only.
|
||||
|
||||
## Tickets
|
||||
#49.
|
||||
|
||||
## Spec
|
||||
Current §6.2, §6.5 rows 3 and 5.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Thick walls and heights are built after the M4 phone playtest
|
||||
|
||||
The design for thick walls (#45/#50) and for wall/token heights and see-over (#41/#44) is FIXED and
|
||||
is not cut, but the build order changes: the first v1 build ships thin walls with the 5.8 switches,
|
||||
doors, secret/locked windows, one-way and player markers, and the first playable M4 client; thick
|
||||
walls and heights are built after a phone playtest. The #49 schema still lands complete now, with
|
||||
`thickness 0`, `position center` and `height NULL`, so the later build adds behaviour and no
|
||||
migration. We chose this over building everything before the first playable client because the
|
||||
client and phone experience are the larger unknowns, and over cutting the features because the owner
|
||||
wants them in v1.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Build the full wall model before the client: rejected, delays the only end-to-end test that can
|
||||
judge the design.
|
||||
- Cut thick walls and heights from v1: rejected, they stay FIXED design.
|
||||
- Defer the schema too: rejected, that would force a second migration later.
|
||||
|
||||
## Consequences
|
||||
The M4 editor has no thickness or height controls; the columns exist and stay at their defaults.
|
||||
Test gates for thick walls (5.10, 10.3) are written but their build tickets come later. Nothing in
|
||||
the current wire needs to change when the behaviour lands: the fields are already in `proto` 2.
|
||||
|
||||
## Tickets
|
||||
`docs/ANALYSIS-review.md` D1 (owner decision 2026-11-17); #45, #50, #41, #44, #49.
|
||||
|
||||
## Spec
|
||||
Current §1 (v1 scope, build order), §13.
|
||||
@@ -0,0 +1,25 @@
|
||||
# Player zoom-out clamps at 0.5
|
||||
|
||||
The client clamps player zoom-out at 0.5. At that scale a 4096 px scene shows about 1.3k tiles,
|
||||
against about 5k at 0.25; this is the cheapest bound on the number of tile requests a player can
|
||||
trigger by zooming out, and it needs no server work. A per-player, explored-masked overview image
|
||||
would allow a further zoom-out but is a possible later feature, not v1.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- No clamp: rejected, a phone can request thousands of tiles by pinching out.
|
||||
- Server-side tile-count throttling: more moving parts and a worse experience than a simple clamp.
|
||||
- A masked overview image now: deferred, it needs a per-player rendered artifact.
|
||||
|
||||
## Consequences
|
||||
The map cannot be viewed as a whole at 0.5 on very large scenes; the owner accepted that for v1. The
|
||||
bound is a client rule and does not constrain a modified client, whose tile requests are still gated
|
||||
per tile by the server (ADR-0005).
|
||||
|
||||
## Tickets
|
||||
`docs/ANALYSIS-review.md` D3 (owner decision 2026-11-17).
|
||||
|
||||
## Spec
|
||||
Current §7.4, §13 (M4).
|
||||
@@ -0,0 +1,28 @@
|
||||
# A wall-sourced `stuck`/`squeezed` status visible to players is accepted
|
||||
|
||||
A player who sees a token with a `walls`-sourced `stuck` or `squeezed` status learns that some
|
||||
blocking wall touches that token. We accept and document this instead of removing the status or
|
||||
hiding its coexistence: a refused move already reveals the same fact through the uniform nack
|
||||
(ADR-0003), so hiding the status would remove a useful signal without closing the channel.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Send no statuses to players: rejected, the status is the only indication of why their token will
|
||||
not move.
|
||||
- Send a synthetic source-free status only for GM-sourced entries: rejected, the two cases would
|
||||
still be distinguishable by timing and refusal behaviour.
|
||||
- Add a new message to explain refusals: rejected, it reopens the oracle that the uniform nack
|
||||
closes.
|
||||
|
||||
## Consequences
|
||||
The status set is viewer-visible but the `source` field is GM-only (the controller included). Leak
|
||||
note 6 is closed as accepted; no source-free status is added. The effect is documented in §5.5 and
|
||||
the threat list, not tested as a leak.
|
||||
|
||||
## Tickets
|
||||
#4 (status model), #46 (doors), `docs/ANALYSIS-review.md` D4 (owner decision 2026-11-17).
|
||||
|
||||
## Spec
|
||||
Current §3.1, §5.5, §6.1 leak note 6.
|
||||
@@ -0,0 +1,30 @@
|
||||
# A player marker is the one wall fact a player ever receives
|
||||
|
||||
A wall with `player_marker` on that derives `window` sends a player, once any point of its visible
|
||||
extent has entered that player's vision polygon, exactly one anchor point (integer px, the drawn
|
||||
midpoint) and an opaque per-player marker id. It carries no type, kind, open/closed, direction,
|
||||
label, thickness, height, wall id or switch. This is a deliberate, exact exception to "walls never
|
||||
reach a player", because an invisible window is worse for play than a single point of disclosure,
|
||||
and the point cannot be used to infer what the wall does.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Send the window's geometry or kind: rejected, that is wall data and reveals a barrier's shape.
|
||||
- Send nothing: rejected, players would walk into invisible windows.
|
||||
- Send a marker for every marked wall regardless of kind: rejected, turning the switch on for a
|
||||
solid wall would then disclose it; the derived-kind gate makes a solid wall's switch inert.
|
||||
|
||||
## Consequences
|
||||
The marker is per-player memory like explored: persisted in `marker_seen`, restored before the first
|
||||
connection, never retracted by walking away, a door or lost sight, and retracted only when the GM
|
||||
removes the wall, clears the switch, makes it not a window or moves its geometry. The GM never
|
||||
receives `marker` frames. Frames diff by the opaque id, never the wall id, and an anchor is never
|
||||
updated in place. Three fault classes and an oracle pin it.
|
||||
|
||||
## Tickets
|
||||
#48 (marker decision), #49 (wire shape and storage).
|
||||
|
||||
## Spec
|
||||
Current §3.1 (the one exception), §5.8, §6.1 (`marker`), §6.3, §8 (`marker_seen`), §10.3.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Explored area is stored as chunked 64x64 bitmaps
|
||||
|
||||
Each player's explored cells are persisted as 64x64-cell chunks: 512 bytes per chunk, row-major,
|
||||
LSB-first, keyed by `(player, scene, chunk_x, chunk_y)`, both FKs cascading. A mutation writes only
|
||||
the chunks its refresh dirtied, and each dirty chunk is encoded from the whole explored set because
|
||||
a bitmap is a value, not a delta. We chose this over the prototype's one row per cell because a move
|
||||
can add hundreds of cells, and over one blob per player because a small mutation would rewrite the
|
||||
whole grid.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- One row per cell: rejected, one INSERT per new cell and a huge row count.
|
||||
- One blob per player: rejected, every mutation rewrites the full grid.
|
||||
- Delta rows: rejected, the in-memory set is authoritative and a bitmap is cheaper to rewrite than
|
||||
to merge.
|
||||
|
||||
## Consequences
|
||||
A move and its chunks are one `NORMAL` transaction; a GM authoring write adds a second `NORMAL`
|
||||
chunk transaction under the same lock, so the two are not atomic with each other and a crash can
|
||||
lose cells no client was acked about (the next refresh re-adds them). At 4096 px/32 px the whole map
|
||||
is 2x2 chunks; at 16384 px it is 8x8. The exact bit layout is pinned by tests and re-read
|
||||
independently by the Node harness.
|
||||
|
||||
## Tickets
|
||||
#21; H13.
|
||||
|
||||
## Spec
|
||||
Current §4.4 (step 5, write policy), §8 (explored grid).
|
||||
@@ -0,0 +1,30 @@
|
||||
# Slow clients are stopped and resynced, never closed for lag
|
||||
|
||||
Each connection has an app-level bounded outbox (byte and message caps) keyed by an app `connId`,
|
||||
with latest-state-wins coalescing per state key and the diff computed at flush time. WS
|
||||
`Ping(seq)`/`Pong` measures lag; a client over the cap or without a timely Pong stops being fed and
|
||||
is fully resynced when it recovers. Lag never closes a connection; a peer that never recovers is
|
||||
closed by the nginx proxy timeout. We chose this over closing slow clients because at the mummy
|
||||
0.4.8 pin there is no per-socket queue visibility, no forced close, and `close(ws)` queues behind
|
||||
the backlog.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Patch or fork mummy for per-socket depth and forced close: fallback only, not planned.
|
||||
- Close a client when lag exceeds a bound: impossible at the pin, and it loses a phone that was
|
||||
briefly backgrounded.
|
||||
- Drop state messages with no resync: rejected, the client would silently diverge.
|
||||
|
||||
## Consequences
|
||||
Memory per connection is bounded by the caps; a stopped client's state is rebuilt from its `known`
|
||||
table on recovery, so a dropped intermediate state cannot desynchronise it. Ordering between a state
|
||||
message and an ack is flush order, not mutation order (ADR-0002). The connection limits (4 per
|
||||
player, 16 total) are enforced separately.
|
||||
|
||||
## Tickets
|
||||
Q13, #18, #15; research `docs/research/q13-mummy-slow-clients.md`.
|
||||
|
||||
## Spec
|
||||
Current §4.3, §6.3, §6.4.
|
||||
@@ -0,0 +1,30 @@
|
||||
# Session tokens are separate from keys, and keys stay plaintext
|
||||
|
||||
A player key is a 20-symbol secret the GM creates and can re-show; signing in with it issues a
|
||||
separate random 32-byte session token, stored only as its SHA-256 hash, in an `HttpOnly; Secure;
|
||||
SameSite=Strict` cookie. Sessions never expire; one key works on several devices; replacing a key
|
||||
invalidates the old key, revokes all that player's sessions and closes live connections. Keys stay
|
||||
plaintext so the GM can re-show them. We rejected hashing keys at rest and per-person invite links
|
||||
because the GM must be able to re-copy a key, the key space is ~99 bits so hashing buys little
|
||||
against guessing, and one link per player is the simpler sharing model.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Store only a key hash and regenerate on loss: rejected, the GM loses the ability to re-show.
|
||||
- Make the key the session cookie (prototype): rejected, a permanent bearer in logs and history.
|
||||
- Expiring sessions: rejected, a home table re-signs in rarely and expiry only annoys.
|
||||
- Per-person invite links: rejected in favour of player keys.
|
||||
|
||||
## Consequences
|
||||
The key never appears in a URL or a log (redaction is a safety net, not the rule). Removing a player
|
||||
invalidates the key, revokes sessions and hands their characters and tokens to the GM. The GM key is
|
||||
created only by the CLI and rotates only with `--new`, which refuses while the server holds the
|
||||
state-dir lock. The web server terminates TLS and the binary binds 127.0.0.1.
|
||||
|
||||
## Tickets
|
||||
#6 (players and keys), #17 (auth slice), Q10, Q11.
|
||||
|
||||
## Spec
|
||||
Current §3.2, §6.6, §8.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Close reasons ride a final `closing` message at the mummy pin
|
||||
|
||||
Mummy 0.4.8 exposes only `close(ws)`, which sends an empty close frame; a browser reports 1005 and
|
||||
no application close code can be sent. The server is neither forked nor patched. Instead every
|
||||
server-initiated close is two frames: a final `closing {reason, code}` application message carrying
|
||||
the static reason and the numeric code from the connection-outcome table, then the close frame. The
|
||||
client reads the reason from the last message it received.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- Patch/fork mummy to send a close code: fallback only, rejected as the primary path.
|
||||
- Infer the reason from 1005 alone: rejected, a client cannot tell eviction from revocation from a
|
||||
protocol mismatch.
|
||||
- Put the reason in the close frame's reason string: not possible at the pin.
|
||||
|
||||
## Consequences
|
||||
A server-initiated close is always two steps, and `closing` is the last application frame that
|
||||
connection sees. `closing` is a catalogue message, so the server-message count includes it. Tests
|
||||
assert "last message is `closing` with this reason and code, then 1005". Refusals before the upgrade
|
||||
(403/401/400/503) remain plain HTTP statuses. The `n` counter is stamped on `closing` too.
|
||||
|
||||
## Tickets
|
||||
#18; #17 (slice 2 revoke/evict paths).
|
||||
|
||||
## Spec
|
||||
Current §3.2, §6.1 (`closing`), §6.5.
|
||||
@@ -0,0 +1,32 @@
|
||||
# Characters are records separate from tokens
|
||||
|
||||
A character is its own record: identity and base values, exactly one owner (a player or the GM), its
|
||||
own names, `reveal_all`, and three property buckets. A token is what is on the map and holds what is
|
||||
happening to that figure; a plain token (monster, item) belongs to no character. A character's
|
||||
tokens use the character's names, and changing a character's owner never changes a token's
|
||||
controller. We chose this split over putting all data on the token or all data on the character
|
||||
because a character can have several figures across scenes, and because duplicating stats onto every
|
||||
token makes one reveal or rename a fan-out problem.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- All data on the token: rejected, duplicated identity and stats.
|
||||
- All data on the character: rejected, plain tokens (monsters, items) have no character and still
|
||||
need data.
|
||||
- Token controller derived from the character owner: rejected, a figure can be controlled by someone
|
||||
else.
|
||||
|
||||
## Consequences
|
||||
An owner change is explicit (`character.reassign`) and leaves controllers alone. Encounters are
|
||||
per-player snapshots that survive token and character removal and a `gm_only` flip. Linked tokens
|
||||
store empty names and take the character's. The `owner` bucket means character owner plus GM for a
|
||||
character, token controller plus GM for a token. Characters and plain tokens share one id namespace
|
||||
so a reveal row can name either without an ambiguity column.
|
||||
|
||||
## Tickets
|
||||
#14, #23.
|
||||
|
||||
## Spec
|
||||
Current §8 (character, character vs token props, names, encountered), §3.1.
|
||||
@@ -0,0 +1,29 @@
|
||||
# One global lock in v1, with persistence inside it
|
||||
|
||||
Intent handling, vision recomputation, the SQLite commit and the enqueue into per-connection
|
||||
outboxes all happen under one global lock; network sends happen outside it. We keep this in v1
|
||||
because a table of at most ten clients is two orders of magnitude below the measured single-core
|
||||
limit (server total per mutation avg 0.70 ms), and because moving persistence out of the lock would
|
||||
break ack-after-commit and mutation order. The cost is a measured ~20 ms SQLite COMMIT tail that
|
||||
every other mutation queues behind.
|
||||
|
||||
## Status
|
||||
proposed (may be revisited on a measured p99 > 50 ms in production logs)
|
||||
|
||||
## Alternatives
|
||||
- Per-scene or per-player locks: rejected for v1, no measured need and more deadlock surface.
|
||||
- Persist outside the lock: rejected, breaks ack-after-commit and order.
|
||||
- Group commit / world thread: considered, deferred as a post-v1 option with the JsonNode race fix.
|
||||
|
||||
## Consequences
|
||||
The egress borrows the live tables through a context of pointers rather than copying them, because a
|
||||
per-mutation copy of a large explored set costs milliseconds; nothing borrowed may outlive the lock.
|
||||
Every reader takes one scene snapshot under the lock. Hot-path code must not do blocking I/O, large
|
||||
formatting or per-cell work under it; logging and metrics are O(1) updates. A 583 ms outlier was
|
||||
observed once and not reproduced; production SLOW lines must make a recurrence diagnosable.
|
||||
|
||||
## Tickets
|
||||
#13 (slices), #28 (borrowed context), #31 (scene snapshot); `docs/ANALYSIS-review.md` adoption list.
|
||||
|
||||
## Spec
|
||||
Current §4.2, §4.3, §11.3.
|
||||
@@ -0,0 +1,29 @@
|
||||
# `synchronous=NORMAL`, with `FULL` around GM authoring
|
||||
|
||||
SQLite runs with `journal_mode=WAL` and `synchronous=NORMAL`, except that GM authoring transactions
|
||||
(walls, scene changes, token create/update/remove) run with `FULL`. `NORMAL` cut the average commit
|
||||
from 0.60 to 0.17 ms and server total from 1.16 to 0.74 ms with the tail unchanged, and a SIGKILL
|
||||
loses nothing; a power loss can drop the last few commits but never corrupts. Positions and explored
|
||||
cells are cheap to lose (the next refresh re-derives explored), while GM-authored walls and scenes
|
||||
are expensive, so only authoring pays the `FULL` cost.
|
||||
|
||||
## Status
|
||||
accepted
|
||||
|
||||
## Alternatives
|
||||
- `FULL` everywhere: rejected, pays the cost on every move for no benefit the owner values.
|
||||
- `NORMAL` everywhere: rejected, a power loss could silently drop authored content.
|
||||
- Move persistence outside the lock: rejected (ADR-0021).
|
||||
|
||||
## Consequences
|
||||
An ack follows COMMIT, so a client never sees state a crash can undo, except under a `NORMAL` power
|
||||
loss, which is stated rather than hidden. The trade-off is explicit: ack-before-durable on power
|
||||
loss for moves and explored. Wall and scene writes update memory only after COMMIT, so a failed
|
||||
write leaves memory and DB identical. The two-commit pattern for explored under an authoring write
|
||||
is accepted (ADR-0016).
|
||||
|
||||
## Tickets
|
||||
Q12, #16.
|
||||
|
||||
## Spec
|
||||
Current §4.4, §4.2.
|
||||
Reference in New Issue
Block a user