feat(issue-10): broadcast hub state changes over WebSocket #12

Merged
rznz merged 2 commits from feat/10-websocket-state-broadcast into main 2026-10-27 09:25:33 +03:00
Collaborator

Issue

Closes #10

Summary

Hardware events and session reset now broadcast authoritative state to connected WebSocket clients without polling. A lifespan-managed FIFO worker serializes mutations and advances a process-local revision; independent bounded outboxes isolate slow or disconnected subscribers. Existing puzzle rules, REST endpoints and JSON ping/pong behavior remain intact.

Acceptance Criteria

  • Two clients receive an initial snapshot matching HTTP status; ping/pong remains available.
  • Events and reset broadcast state_changed with the same data shape as status.
  • state_revision increases across session reset.
  • Mutations are serialized; slow/disconnected clients do not block the worker or healthy subscribers.
  • Tests, architecture/protocol documentation and AI prompt log are updated.

Verification

  • Device/hub Python suites: 16 passed (9 regressions added).
  • Covered two subscribers, disconnect/reconnect, reset/revision order, GPIO-thread intake, detached snapshots, send timeout and queue overflow.
  • Live local Uvicorn with two real WebSocket clients: power transition, disconnect, ping/pong, reset and reconnect passed.
  • Source/tests compile and git diff --check passed.
  • Existing Starlette/httpx deprecation warning remains; no dependency migration is included.

Documentation and architecture

  • Updated README.md and ARCHITECTURE.md.
  • Documented single-process in-memory state, per-connection revision baseline, GPIO intake and bounded client delivery.
  • Task memory: .agents/work/tasks/10-websocket-state-broadcast/.

AI assistance

Prompt log: docs/prompts/10-websocket-state-broadcast.md.

Review

Review requested from echo1.

Integration correction

Commit e569268 shields WebSocket child cleanup from surrounding ASGI cancellation and adds a deterministic regression that fails before the fix. Full Python suites passed 16/16 in five consecutive runs; fresh live Uvicorn/socket smoke passed. AnyIO is now declared directly; dependency package versions are unchanged. New evidence is recorded in follow-up task #11 because prior completed task memory is frozen.

## Issue Closes #10 ## Summary Hardware events and session reset now broadcast authoritative state to connected WebSocket clients without polling. A lifespan-managed FIFO worker serializes mutations and advances a process-local revision; independent bounded outboxes isolate slow or disconnected subscribers. Existing puzzle rules, REST endpoints and JSON ping/pong behavior remain intact. ## Acceptance Criteria - [x] Two clients receive an initial snapshot matching HTTP status; ping/pong remains available. - [x] Events and reset broadcast state_changed with the same data shape as status. - [x] state_revision increases across session reset. - [x] Mutations are serialized; slow/disconnected clients do not block the worker or healthy subscribers. - [x] Tests, architecture/protocol documentation and AI prompt log are updated. ## Verification - Device/hub Python suites: 16 passed (9 regressions added). - Covered two subscribers, disconnect/reconnect, reset/revision order, GPIO-thread intake, detached snapshots, send timeout and queue overflow. - Live local Uvicorn with two real WebSocket clients: power transition, disconnect, ping/pong, reset and reconnect passed. - Source/tests compile and git diff --check passed. - Existing Starlette/httpx deprecation warning remains; no dependency migration is included. ## Documentation and architecture - Updated README.md and ARCHITECTURE.md. - Documented single-process in-memory state, per-connection revision baseline, GPIO intake and bounded client delivery. - Task memory: .agents/work/tasks/10-websocket-state-broadcast/. ## AI assistance Prompt log: docs/prompts/10-websocket-state-broadcast.md. ## Review Review requested from echo1. ## Integration correction Commit e569268 shields WebSocket child cleanup from surrounding ASGI cancellation and adds a deterministic regression that fails before the fix. Full Python suites passed 16/16 in five consecutive runs; fresh live Uvicorn/socket smoke passed. AnyIO is now declared directly; dependency package versions are unchanged. New evidence is recorded in follow-up task #11 because prior completed task memory is frozen.
dudll requested review from echo1 2026-10-26 15:22:48 +03:00
rznz merged commit 6b54922527 into main 2026-10-27 09:25:33 +03:00
rznz deleted branch feat/10-websocket-state-broadcast 2026-10-27 09:25:33 +03:00
Sign in to join this conversation.
No description provided.