feat: implement WebSocket synchronization and HTTP recovery

This commit is contained in:
2026-08-28 23:33:14 +03:00
parent 95b3450317
commit 03b283f892
8 changed files with 524 additions and 13 deletions
+13 -2
View File
@@ -650,7 +650,7 @@ If all criteria pass, set this milestone to `DONE`, append its execution record,
## Milestone 012 — Implement WebSocket synchronization and HTTP recovery
**Status:** `READY`
**Status:** `DONE`
**Depends on:** Milestone 011
### Objective
@@ -678,11 +678,22 @@ Deliver immediate personalized updates while preserving the proven HTTP polling
If all criteria pass, set this milestone to `DONE`, append its execution record, and change Milestone 013 from `BLOCKED` to `READY`.
### Execution record
- Date: 2026-08-28
- Board model and revision: ESP32-C6FH4 QFN32, revision v0.2.
- Toolchain and library versions: PlatformIO Core 6.1.19; `espressif32` 7.0.1; ESP-IDF 6.0.1; `esp_littlefs` 1.20.4.
- Result: PASS, pending on-device endurance confirmation.
- Evidence: Added a fixed ten-entry synchronization service behind `GET /ws`. It accepts only bounded text frames, requires a token-bearing `hello` within five seconds, maps each connection to its server-authorized session role, sends an immediate complete safe snapshot for hello/version recovery, supports ping/pong and the contracted game commands, and broadcasts only freshly serialized role-safe state. HTTP state changes enqueue the same broadcast. Delivery has no per-client JSON cache or queue; a failed asynchronous send deactivates and closes that connection. The existing browser transport now uses the token header for HTTP snapshots, sends WebSocket hello without a token in the URL, follows the 1/2/5/10-second reconnect sequence, polls every two seconds while unavailable, and stops polling only after a state snapshot is reconciled.
- Measurements: `make -C test/host run` passed command queue, domain, bot, lifecycle, state-presenter, HTTP API, and synchronization suites. Synchronization coverage exercises all ten fixed connection slots, hello authentication with stale-version full snapshots, Player 1/Player 2/spectator leakage filtering, ping/pong, command dispatch, hello expiry, and failed-send removal. `node --check data/app.js` and `pio run -e esp32-c6-devkitm-1 -t buildfs` passed. `pio run -e esp32-c6-devkitm-1` passed with 39,348 / 327,680 B RAM (12.0%) and 1,014,500 / 2,097,152 B flash (48.4%), within the Milestone 005 limits.
- Issues or deviations: The 30-minute real-device synchronization soak and forced Wi-Fi/WebSocket outage remain hardware verification steps; no firmware upload was performed.
- Next action: Milestone 013 is ready. Do not start it unless explicitly requested.
---
## Milestone 013 — Build the Russian responsive web interface
**Status:** `BLOCKED`
**Status:** `READY`
**Depends on:** Milestone 012
### Objective