Commit Graph
93 Commits
Author SHA1 Message Date
SirStone d38b871dfa server: token records and the entity migration step (#20)
Migration step 4 ("tokens") creates the entity table: the token id, scene, kind,
both names, position, nullable radius/owner/vision_radius, gm_only and flags. A
NULL owner is GM-controlled, so player.remove hands that player's tokens to the GM
through the FK; radius, props and character_id stay out until slices 7-8.

server/tokens.nim holds the record, the 6.1 field rules (12 CSPRNG characters from
a 64-symbol alphabet, trimmed names, kind, positive vision_radius), the write-through
persistence (FULL for GM authoring, NORMAL for a move) and the loader. db_connector
quotes every argument, so the three nullable columns are emitted as numeric literals
while text still goes through ? arguments.
2026-11-15 09:35:05 +01:00
SirStone 8b595156f0 results: slice 4 test and mutation logs (#19) 2026-11-15 08:49:44 +01:00
SirStone 864cf26e98 design: record the walls and doors decisions (#19)
v0.16. 4.4 gets migration step 3 (scene + wall DDL and the seeded v1 scene);
6.1 gets the wall payload rules the catalogue left open (scene id, a/b
validation, open never true on a wall, flags as an object, wall.update's
patch set, fields before lookup, ids from next_wall_id, synchronous=FULL);
6.1/6.3 note what slice 4 actually sends (`walls` on GM connect); 8 points
next_wall_id at the scene row; 14 records the whole slice as FIXED
(owner-delegated).
2026-11-15 08:49:42 +01:00
SirStone 6c3e8c6e18 tools: mutations t-z2 for the wall state (#19)
t: removal renumbers next_wall_id | u: the counter is not loaded from the DB |
v: the counter is never written | w: a wall may stay open | x: zero-length
walls accepted | y: endpoints unchecked against the world bounds | z:
door.set on a plain wall accepted | z2: persisted open state loaded inverted.
Control passes; every mutation fails its expected tests.
2026-11-15 08:49:24 +01:00
SirStone d72fc6ed20 tools: wall harness, and the walls frame in the existing groups (#19)
tools/walls.test.mjs: GM snapshot, CRUD acks and effects, ids monotonic and
never reused, the 6.1 validation table, door toggling, "players get no wall
data" (no walls/wall/wall_gone type and no wall coordinate in any player
frame) and a restart that leaves walls, door state and the id counter
identical. protocol.test.mjs/smoke.test.mjs follow the new frame and schema:
hello = 1, walls = 2, the first ack = 3; user_version 3 with the seeded scene.
2026-11-15 08:49:24 +01:00
SirStone a8f508ef2e server: wall and door intents, GM wall snapshot and fan-out (#19)
wall.add, wall.update, wall.remove and door.set leave the unknown-type rollout
list: field shapes and ranges per 6.1 (and the payload rules recorded FIXED in
4.4/6.1), lookup failures not-found, non-GM refused by the existing GM-only
gate. wall.add acks {id} from the scene's next_wall_id; wall.update patches
a/b/kind/flags only (open belongs to door.set); door.set is invalid on a plain
wall. Effects go to every GM connection only: wall / wall_gone, plus one walls
snapshot right after hello (the wall part of the 6.3 resync). Players receive
no wall data in any message (3.1, T2).

protocol.nim gains the wallObject/wallsFrame/wallFrame/wallGoneFrame builders
(no n: the sender stamps it per recipient) and the five wall intents in the
implemented set.
2026-11-15 08:49:20 +01:00
SirStone bf9ab3edfd server: scene and wall state, slice-4 migration (#19)
Migration step 3 ("world") creates scene and wall and seeds the single v1 scene
(id 1, 4096x4096, tile = cell 32, vision 400, token radius 20, art_version 1,
next_wall_id 1). server/world.nim holds the in-memory scene with SQLite as
write-through persistence: per-scene wall ids from next_wall_id (monotonic,
never reused, #3), 6.1 validation (a != b, in bounds, a wall is never open),
flags as an opaque JSON object, and one transaction with synchronous=FULL
around every GM authoring write (Q12); memory follows COMMIT, so a failed
write leaves both sides unchanged.

Tests: tests/tworld.nim (ids, reload, doors, validation, pragma, failed write),
tests/tdb.nim (version 3, history, a slice-2 DB migrating to slice 3).
2026-11-15 08:49:16 +01:00
SirStone 2a1e2dd71c results: slice 3 test and mutation logs (#18) 2026-11-15 08:33:16 +01:00
SirStone db22b33567 design: record the closing message and the protocol-shell decisions (#18)
Owner decision (#18), option A: mummy 0.4.8 cannot send an application close code
(close(ws) -> an empty close frame -> the browser sees 1005), and mummy is not forked
for it. Every server-initiated close now sends one closing {reason, code} message and
then the close frame; the client reads the reason from that last message. Amends 3.2
(the OPEN note is FIXED) and 6.5, and adds the message to the 6.1 catalogue (server
messages 14 -> 15) with the reason/code table.

Also recorded FIXED: proto is a required query parameter (400 when absent, 4003 on a
mismatch, no hello); the server Ping interval (20 s, plus one right after hello, lag
enforcement stays M5); the n rule (server frames only, no number for Ping/Pong); the
explicit 64 KB maxMessageLen; and the slice-3 rollout note that catalogue intents
whose slice has not landed answer unknown-type. 10.3 lists the protocol test group.
2026-11-15 08:33:16 +01:00
SirStone 951f37c3fb tools: mutations p-s for the protocol module and the n counter (#18) 2026-11-15 08:33:12 +01:00
SirStone 5e43ffa545 tools: raw WS client and the protocol test group (#18)
lib.mjs gains a node:net WebSocket client (frames, opcodes, masked sends, a close
handshake that mirrors a browser) so the harness can send what the global WebSocket
cannot: oversize, binary, unmasked, bad-opcode and garbage frames, and read Ping/Pong
and the empty close frame. wsUrl/rawUpgrade now carry the required proto query.

withserver.mjs gains the GM-server helpers (gm-key, withGmServer, signIn, openAs) that
auth.test.mjs used to keep privately, so both harnesses share one copy.

protocol.test.mjs is the protocol group of DESIGN 13 M3: hello/n, catalogue types,
proto, unknown type and ignored fields, exactly one ack per reqId, unnamed player,
malformed + binary frames, the flood close, the intent bucket, the 64 KB boundary,
unmasked/bad opcode, server Ping and Pong, the connection cap, and closing-then-1005.
auth.test.mjs now also asserts the closing reason on eviction and revocation.
2026-11-15 08:33:12 +01:00
SirStone 88dd27e2cc server: hello, one ack per intent, proto check, rate limit, flood, ping (#18)
The protocol shell over the socket, in DESIGN 6.5 order: spend a token, parse, then
unknown type / unnamed player / role / fields / lookup / semantics. Every readable
intent gets exactly one ack with a 6.5 code; an unreadable frame gets one error.

- hello {proto, role, me} as the first frame (n = 1); the scene block lands in slice 5
- /ws?proto=N is required: 400 when absent or not an integer, 101 + closing 4003 on
  a mismatch (no hello, no state)
- intent bucket 30/s burst 100 and the 10-in-10-s malformed flood (closing 1008);
  a rate-limited intent applies nothing and the connection stays open
- mummy maxMessageLen stated explicitly (64 KB) and mummy's own log lines routed
  through the event log instead of stdout
- server Ping(seq) right after hello and every 20 s (lag enforcement stays M5);
  inbound Pings are answered with a Pong, which mummy does not do itself
- close reasons: every server-initiated close sends closing {reason, code} then the
  close frame, and slice 2's eviction/revocation paths do the same (FIXED, #18)
2026-11-15 08:33:07 +01:00
SirStone 7e2d5b8dc0 server: per-connection wire state and closing frames in the conn registry (#18)
Conn now carries what DESIGN 6/6.4/6.5 need per connection, all under the one
registry lock: the outgoing n counter (starts at 1, server frames only), the intent
token bucket, the malformed-flood window, the player's named flag and the last Pong.
None of it is shared, so the n counter is not a global side channel (H25).

activate/revokePlayer now hand back the doomed Conn values instead of raw sockets:
the caller still has the frame count, so the final closing frame carries the right n
before the close. Tests cover per-connection counters, the bucket and the flood
window in isolation, and that a snapshot survives the lock.
2026-11-15 08:33:07 +01:00
SirStone eb48034eba server: wire protocol module - envelope, frames, rate limit, flood window (#18)
Pure, mummy-free module for the protocol shell: the envelope rules of DESIGN 6.5
step 2 (UTF-8 text, JSON object, string t, integer reqId in 0..2^31-1), the frame
builders of 6.1 including closal/closing, the per-connection intent token bucket
(30/s, burst 100) and the malformed-flood window (10 in any 10 s), plus the FIXED
constants: proto 1, 64 KB inbound, close codes 4001/4002/4003/1008 and their reason
strings. The 29-intent catalogue and the GM-only set live here so 'unknown type'
and role checks have one definition.

Found while testing: std/json parseJson("") returns nil instead of raising, and
node{"t"} is nil for a missing key, so both are guarded (a bare {} would have
crashed the handler).
2026-11-15 08:33:01 +01:00
SirStone 527e216c37 design: mark sign-in path and ws origin check fixed (#17) 2026-11-14 22:13:25 +01:00
SirStone 8ff66530d8 results: slice 2 test and mutation logs (#17) 2026-11-14 22:13:09 +01:00
SirStone f85665b53e design: record slice 2 decisions (#17) 2026-11-14 22:13:09 +01:00
SirStone 9d43aef9ed server: /join, session cookies, ws auth and gm-key CLI (#17) 2026-11-14 22:13:09 +01:00
SirStone e612db5826 server: auth schema, keys, sessions, connection registry (#17) 2026-11-14 22:13:04 +01:00
SirStone c89c8eab42 results: slice 1 test and mutation logs (#16) 2026-11-14 21:41:33 +01:00
SirStone 86e7ad397d design: record slice 1 decisions (#16) 2026-11-14 21:40:48 +01:00
SirStone a3c1ac36ef devbox: nodejs 26, sqlite, test runs Nim then Node (#16) 2026-11-14 21:40:44 +01:00
SirStone 65b8f0a148 tools: Node 26 harness base, smoke and ws-header checks (#16) 2026-11-14 21:40:44 +01:00
SirStone f376efdc39 server: config, migrations, redacted logging, /healthz entrypoint (#16) 2026-11-14 21:40:39 +01:00
SirStoneandClaude Haiku 5.5 143cb534dc design: retag gm-key service user as owner-delegated (#13)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 20:58:58 +01:00
SirStoneandClaude Sonnet 5.5 4465e7e89d design: M3 slices and gm-key service user (#13)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 20:56:32 +01:00
SirStoneandClaude Haiku 5.5 7667e28f5e design: owner review of message list flags (#11)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 20:49:11 +01:00
SirStoneandClaude Sonnet 5.5 277cb5f896 design: fix M3 message list (#11)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 20:42:16 +01:00
SirStoneandClaude Haiku 5.5 2801fbcca5 design: fix M3 limits (#15)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 20:12:15 +01:00
SirStoneandClaude Haiku 5.5 356a70f2b5 design: fix M3 done criteria (#12)
M3 done = devbox run test green on a clean checkout with nine named
groups (leak+fault, tiles, probing, protocol, auth, characters and
names, restart, persistence, logs). Concurrency moves to M5, bind check
to M6. Protocol limits pending on the "M3 limits" card.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 19:47:06 +01:00
SirStoneandClaude Haiku 5.5 acc69c9fb6 design: fix test tools (#9)
Node 26 black-box harnesses under tools/ (no Nim rewrite, no npm deps);
in-process tests stay Nim; devbox run test runs Nim then Node.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 19:35:54 +01:00
SirStoneandClaude Haiku 5.5 8c03224f2a design: fix map tiles in M3 (#7)
Tile gate, test nginx and generated 32 px fixtures in M3 scope.
Versioned private tile URLs (art_version, Cache-Control private).
404 for malformed paths, 403 for unexplored tiles.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-14 18:41:34 +01:00
SirStoneandClaude Haiku 5.5 0772f26400 design: fix players and player keys (#6)
One shared site link; each player signs in with a personal player key
generated by the GM. GM signs in the same way with a GM key from
`fff-vtt gm-key` (replaces gm-link, #5). GM can replace a key live
(old key invalid, sessions and connections revoked). Removing a player
passes characters and tokens to the GM. No rate limit on key entry
(owner decision: ~100-bit key space).

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 19:27:22 +01:00
SirStoneandClaude Haiku 5.5 d9e135f6bd design: fix characters and player data (#14)
Characters are own records separate from tokens; tokens may link to one.
Character owner: exactly one (player or GM). Token controller is independent
and never changes with the character owner. Identity lives on the character,
per-figure state on the token. Descriptive/actual names revealed per player
or to all. Per-player encountered list, GM-removed only. Server-side SQLite only.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 19:11:16 +01:00
SirStoneandClaude Haiku 5.5 ae2f7c48dc design: fix first GM login bootstrap (#5)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 18:04:11 +01:00
SirStoneandClaude Haiku 5.5 90576381df design: fix token size and stuck/squeezed statuses (#4)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 17:51:02 +01:00
SirStoneandClaude Haiku 5.5 48b77888c6 design: fix wall and token ids (#3)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 17:13:25 +01:00
SirStoneandClaude Haiku 5.5 91cea1a364 research: mummy 0.4.8 and db_connector API facts (#10)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 16:54:03 +01:00
SirStoneandClaude Haiku 5.5 8f65680176 research: M3 test harness WebSocket options (#8)
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-10 16:52:29 +01:00
SirStoneandClaude Haiku 5.5 c9d94e40b2 docs: handoff for M3 session
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-08 19:22:51 +01:00
SirStoneandClaude Sonnet 5.5 809f219f42 results: regenerate mutation log (parallel run)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 19:19:58 +01:00
SirStoneandClaude Sonnet 5.5 8d3b77add4 mutation: parallel jobs in temp copies, per-mutation test files, FFF_MUTATION reduced iterations, trap cleanup, sleep inhibit
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 19:19:58 +01:00
SirStoneandClaude Sonnet 5.5 dcb8efa422 results: regenerate test, mutation (a-o), bench logs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 19:03:26 +01:00
SirStoneandClaude Sonnet 5.5 65c6b53c2a docs: DESIGN door push rule (5.5, 5.4, 6.1, H2, M2 accept, Q14)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:56:22 +01:00
SirStoneandClaude Sonnet 5.5 a29bb0bb46 moverules: door close pushes overlapped tokens aside (valid-side check, blocked only if no side valid); Push list; tests; mutations m-o
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:56:06 +01:00
SirStoneandClaude Sonnet 5.5 153ff6cd18 docs: DESIGN blocked policy (set/keep/clear), 5k bench target, test-count baseline, GM OOB nack, wall id stability (M3)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:53:12 +01:00
SirStoneandClaude Sonnet 5.5 0e67331b6c results: regenerate test, mutation (a-l), bench logs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:53:12 +01:00
SirStoneandClaude Sonnet 5.5 388e901541 moverules: blocked policy set/keep/clear (GM moves and placements set/clear, KEEP while any wall overlaps); tests; mutations k, l
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:47:39 +01:00
SirStoneandClaude Sonnet 5.5 0e0b1a6052 mutation: run all test files, add mutations e-j (scanline fill, escape crossing, GM bypass, capsule, step cap, blocked trigger); header limitations updated
Control passes; a-d still caught (1,2,2,1,1 expected tests), new e-j each caught. Logs regenerated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 18:33:12 +01:00
SirStoneandClaude Sonnet 5.5 e0705a8533 bench: harness with synthetic 5k-wall scenes (devbox run bench), scenegen + tests
Targets met without a spatial grid: polygon+cells 0.048 ms (<= 0.451) on the prototype scene, polygon 0.083 ms
(< 1 ms) on 5k sparse. 5k dense stress layout reported (1.28 ms). Logs: results/bench.log, nimble-test.log.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 12:15:31 +01:00