summaryrefslogtreecommitdiff
path: root/PLAN.md
diff options
context:
space:
mode:
Diffstat (limited to 'PLAN.md')
-rw-r--r--PLAN.md19
1 files changed, 10 insertions, 9 deletions
diff --git a/PLAN.md b/PLAN.md
index 6ff7294..c9b768c 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -1,7 +1,7 @@
# X-Haven Web — Implementation Plan
**Status:** APPROVED — implementation in progress (Phase 0 started 2026-11-08).
-**Last updated:** 2026-11-08
+**Last updated:** 2026-11-12
Progress is tracked in this file: mark steps `- [x]` as they are completed and record
milestones in §6. The reference app (`FrosthavenAssistant/`) is read-only; all new code
@@ -208,19 +208,19 @@ Port of the complete engine — all of it, so later phases are UI-only:
**Milestone M1** — engine runs headless; ported test suite green.
-### Phase 2 — Networking, sessions, secrets
+### Phase 2 — Networking, sessions, secrets ✅ (2026-11-12)
-- [ ] WS server: `hello`/`welcome` handshake, protocol version check, `ping`/`pong`,
+- [x] WS server: `hello`/`welcome` handshake, protocol version check, `ping`/`pong`,
connection lifecycle (dead-connection cleanup)
-- [ ] Sessions + roles: cookie session ids, spectator default, player on claim
-- [ ] Character ownership: assignment on add, `claim`, re-claim after owner disconnects,
+- [x] Sessions + roles: cookie session ids, spectator default, player on claim
+- [x] Character ownership: assignment on add, `claim`, re-claim after owner disconnects,
`seats` broadcasts
-- [ ] Per-connection state serialization with the visibility layer (initiative rule) —
+- [x] Per-connection state serialization with the visibility layer (initiative rule) —
**the server never sends a secret to a non-owner**
-- [ ] Command execution path: player-role check → args validation → execute → per-connection
+- [x] Command execution path: player-role check → args validation → execute → per-connection
`update` broadcast; `error` responses for rejects; undo/redo on request
-- [ ] Persistence: save on every action, restore on startup
-- [ ] Tests (fake WS clients): two players + one spectator — secret initiative never reaches
+- [x] Persistence: save on every action, restore on startup
+- [x] Tests (fake WS clients): two players + one spectator — secret initiative never reaches
non-owners; reveal on draw; reconnect resync; rejected duplicate draw; claim/lose
seat; snapshot restored across a server restart
@@ -321,6 +321,7 @@ changes, room sections, spectator view. *First end-to-end moment.*
| 2026-11-08 | Plan approved. |
| 2026-11-08 | **Phase 0 complete** — server package (shelf + WS, hello/welcome handshake, smoke tests 5/5), web app (Svelte 5 + TS, protocol client, svelte-check clean, build OK), assets copied (73 MB), AGPL license, README, .gitignore, CI script passing end-to-end. |
| 2026-11-12 | **Phase 1 complete / M1 reached** — full engine ported to `server/lib/core/` (models, state + 18 part files, 7 methods classes, game_methods, 79 command files, enums, card_stack, stat_calculator, action_handler, disk-based game_data, l10n, minimal line_builder per conventions §8b). Command registry: 82 entries (wire name ↔ constructor + arg validation; enum/object args resolved against live state). Ported test suite: 81 test files, **562 tests green** (command tests 1:1 with the reference; resource/action-handler/stat-calculator/modifier-deck tests; registry smoke tests). New headless integration test drives a full round (setup → characters + standee → initiative gate → draw → every figure's turn incl. undo/redo → next round → round 2 → round 3). `dart analyze` warning-free. Porting conventions in `server/PORTING.md`. Notable porting fix found by tests: removable-card physical sync had to stay gated to the ten initial counters (reference listener semantics). |
+| 2026-11-12 | **Phase 2 complete / M2 reached** — networking, sessions, and server-gated secrets over WebSocket, no UI. New `server/lib/net/`: `protocol.dart` (JSON wire protocol, v1: `hello`/`welcome`/`update`/`seats`/`error`/`pong` + `claim`/`cmd`/`undo`/`redo`/`ping`), `sessions.dart` (32-hex session ids; role derived from seat ownership; `resolve()` adopts a well-formed cookie id so a browser keeps its seat across restarts), `seat_store.dart` (seat table in `saves/seats.json`, next to the state snapshot), `visibility.dart` (per-connection state serialization; the initiative rule masks every non-owned character's initiative to `null` until the round is drawn — **the server never sends a secret to a non-owner**), `game_server.dart` (the command execution path: role check → game-rule guard → registry build → execute → per-connection `update` broadcast; seat assign/claim/release + `seats` broadcasts; heartbeat sweep), `ws_upgrade.dart` (custom upgrade handler so the server can read the `x-haven-session` cookie — `shelf_web_socket` hides the `Request`), `app.dart` (shelf composition). `bin/main.dart` wires it together. Notable decisions: a server-side `_guard` replaces the reference app's 300 ms draw-button lockout (sequential execution makes a duplicate draw deterministically lose, the loser gets a clear `error`); the session that adds a character owns it and becomes a player; spectators may only `claim`/`addCharacter`; the command index resets to −1 on restart (the snapshot carries state, not undo history); dead-connection sweep defaults 20 s / 90 s. **Persistence bug found & fixed by the kill −9 test:** both file stores did fire-and-forget async `writeAsString`, so a write could land after the reboot's read — made `FileSaveStore.write`/`FileSeatStore.write` synchronous (`writeAsStringSync`) so "written through on every change" is actually on disk when `write` returns. Tests: **34 new network tests** (sessions 9, visibility 5, app 9, multiplayer 9, persistence 2) using a real WS stack on an ephemeral port — secret initiative never reaches non-owners, reveal on draw, reconnect resync, rejected duplicate draw, claim/lose/re-claim seat, undo/redo broadcast to every screen, dead-connection cleanup with seat release, snapshot + seat file restored across a restart. Full suite **591 tests green**; `dart analyze` warning-free; web typecheck/tests/build unaffected (Phase 2 is server-only). |
## 7. Risks and open items