[kimi-task] [refactor] Extract presence state serializer from workshop heartbeat #668

Closed
opened 2026-03-21 03:12:02 +00:00 by kimi · 1 comment
Collaborator

Epic: Matrix Unification

Task

The WorkshopHeartbeat in src/dashboard/routes/world.py writes presence.json with Timmy's state.
Extract the serialization logic into a standalone function serialize_presence() in
src/infrastructure/presence.py so it can be reused by the WebSocket gateway.

Files

  • src/infrastructure/presence.py — NEW: serialize_presence() function
  • src/dashboard/routes/world.py — import and call serialize_presence() instead of inline dict building
  • tests/unit/test_presence.py — NEW: test serialization round-trip

Acceptance Criteria

  • serialize_presence() returns dict matching ADR-023 schema (liveness, mood, energy, confidence, etc.)
  • world.py still works identically (no behavior change)
  • tox -e unit passes
  • tox -e lint passes

Context

ADR-023 presence state contract fields: version, liveness (ISO timestamp), current_focus (str),
mood (focused/exploring/uncertain/excited/tired/idle), active_threads (list), recent_events (list),
concerns (list), energy (0-1), confidence (0-1), familiar (Pip snapshot).

## Epic: Matrix Unification ## Task The WorkshopHeartbeat in `src/dashboard/routes/world.py` writes presence.json with Timmy's state. Extract the serialization logic into a standalone function `serialize_presence()` in `src/infrastructure/presence.py` so it can be reused by the WebSocket gateway. ## Files - src/infrastructure/presence.py — NEW: serialize_presence() function - src/dashboard/routes/world.py — import and call serialize_presence() instead of inline dict building - tests/unit/test_presence.py — NEW: test serialization round-trip ## Acceptance Criteria - [ ] serialize_presence() returns dict matching ADR-023 schema (liveness, mood, energy, confidence, etc.) - [ ] world.py still works identically (no behavior change) - [ ] tox -e unit passes - [ ] tox -e lint passes ## Context ADR-023 presence state contract fields: version, liveness (ISO timestamp), current_focus (str), mood (focused/exploring/uncertain/excited/tired/idle), active_threads (list), recent_events (list), concerns (list), energy (0-1), confidence (0-1), familiar (Pip snapshot).
kimi self-assigned this 2026-03-21 03:12:02 +00:00
Author
Collaborator

PR created. Extracted _build_world_state() into serialize_presence() in src/infrastructure/presence.py. world.py now delegates to it — no behavior change. Added 5 unit tests covering round-trip, defaults, partial input, and edge cases. All tests and lint pass.

PR created. Extracted `_build_world_state()` into `serialize_presence()` in `src/infrastructure/presence.py`. `world.py` now delegates to it — no behavior change. Added 5 unit tests covering round-trip, defaults, partial input, and edge cases. All tests and lint pass.
kimi closed this issue 2026-03-21 13:41:43 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#668