[kimi] refactor: extract WebSocket message types into shared protocol module (#667) #696

Merged
kimi merged 1 commits from kimi/issue-667 into main 2026-03-21 13:37:29 +00:00
Collaborator

Fixes #667

Summary

  • Added src/infrastructure/protocol.py with a MessageType StrEnum covering all 9 Matrix PROTOCOL.md types: agent_state, visitor_state, bark, thought, system_status, connection_ack, error, task_update, memory_flash
  • Each message type is a typed dataclass with to_json() and from_json() methods
  • WSMessage.from_json() dispatches to the correct subclass via a registry, falling back to the base class for unknown types
  • Added comprehensive unit tests (tests/unit/test_protocol.py) covering round-trip serialisation, dispatch, enum completeness, and error handling

Test plan

  • tox -e format passes
  • tox -e unit passes (2402 tests)
  • tox -e lint passes
  • tox -e pre-push passes (full CI mirror)
Fixes #667 ## Summary - Added `src/infrastructure/protocol.py` with a `MessageType` StrEnum covering all 9 Matrix PROTOCOL.md types: `agent_state`, `visitor_state`, `bark`, `thought`, `system_status`, `connection_ack`, `error`, `task_update`, `memory_flash` - Each message type is a typed dataclass with `to_json()` and `from_json()` methods - `WSMessage.from_json()` dispatches to the correct subclass via a registry, falling back to the base class for unknown types - Added comprehensive unit tests (`tests/unit/test_protocol.py`) covering round-trip serialisation, dispatch, enum completeness, and error handling ## Test plan - [x] `tox -e format` passes - [x] `tox -e unit` passes (2402 tests) - [x] `tox -e lint` passes - [x] `tox -e pre-push` passes (full CI mirror)
kimi added 1 commit 2026-03-21 13:37:15 +00:00
refactor: extract WebSocket message types into shared protocol module
Some checks failed
Tests / lint (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
5ad703e35f
Adds `src/infrastructure/protocol.py` with a `MessageType` StrEnum
covering all 9 Matrix PROTOCOL.md message types (agent_state,
visitor_state, bark, thought, system_status, connection_ack, error,
task_update, memory_flash) and typed dataclasses with `to_json()` /
`from_json()` serialisation.

Includes comprehensive unit tests for round-trip serialisation and
`WSMessage.from_json()` dispatch to the correct subclass.

Fixes #667

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kimi merged commit e92e151dc3 into main 2026-03-21 13:37:29 +00:00
kimi deleted branch kimi/issue-667 2026-03-21 13:37:29 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#696