[kimi] Add system_status message producer (#681) #743

Merged
kimi merged 1 commits from kimi/issue-681 into main 2026-03-21 15:13:01 +00:00
Collaborator

Fixes #681

Summary

Implements produce_system_status() in src/infrastructure/presence.py that generates system_status messages for the Matrix frontend.

Changes

  • Added produce_system_status() function that returns a dict with:
    • type: "system_status"
    • data: Object containing system health metrics
      • agents_online: Count of agents with status != offline
      • visitors: Count from WebSocket clients (_ws_clients)
      • uptime_seconds: Time since APP_START_TIME
      • thinking_active: Bool from thinking engine state and settings
      • memory_count: Total memories from get_memory_stats()
    • ts: Unix timestamp

Design Decisions

  • Used graceful degradation pattern (try/except blocks) for all data collection
  • Function never crashes even when dependencies fail
  • All numeric values are non-negative integers
  • thinking_active checks both settings.thinking_enabled and engine existence

Tests

Added comprehensive test class TestProduceSystemStatus in tests/unit/test_presence.py covering:

  • Message structure validation
  • Data field types verification
  • Non-negativity constraints for all numeric fields
  • Graceful degradation on errors
  • Timestamp format validation

Verification

  • tox -e format (auto-formatted)
  • tox -e unit (2574 passed)
  • tox -e lint (clean)
  • tox -e pre-push (full CI suite)
Fixes #681 ## Summary Implements `produce_system_status()` in `src/infrastructure/presence.py` that generates system_status messages for the Matrix frontend. ## Changes - Added `produce_system_status()` function that returns a dict with: - `type`: "system_status" - `data`: Object containing system health metrics - `agents_online`: Count of agents with status != offline - `visitors`: Count from WebSocket clients (_ws_clients) - `uptime_seconds`: Time since APP_START_TIME - `thinking_active`: Bool from thinking engine state and settings - `memory_count`: Total memories from get_memory_stats() - `ts`: Unix timestamp ## Design Decisions - Used graceful degradation pattern (try/except blocks) for all data collection - Function never crashes even when dependencies fail - All numeric values are non-negative integers - thinking_active checks both settings.thinking_enabled and engine existence ## Tests Added comprehensive test class `TestProduceSystemStatus` in `tests/unit/test_presence.py` covering: - Message structure validation - Data field types verification - Non-negativity constraints for all numeric fields - Graceful degradation on errors - Timestamp format validation ## Verification - ✅ tox -e format (auto-formatted) - ✅ tox -e unit (2574 passed) - ✅ tox -e lint (clean) - ✅ tox -e pre-push (full CI suite)
kimi added 1 commit 2026-03-21 15:12:02 +00:00
feat: Add produce_system_status() for Matrix system health messages
Some checks failed
Tests / lint (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
6739ec0da8
Implements produce_system_status() in src/infrastructure/presence.py that
generates system_status messages for the Matrix frontend.

Features:
- agents_online: Count of agents with status != offline
- visitors: Count from WebSocket clients (_ws_clients)
- uptime_seconds: Time since APP_START_TIME
- thinking_active: Bool from thinking engine state and settings
- memory_count: Total memories from get_memory_stats()

All data collection uses graceful degradation (try/except blocks)
to ensure the function never crashes even when dependencies fail.

Includes comprehensive tests in tests/unit/test_presence.py covering:
- Message structure validation
- Data field types and non-negativity
- Graceful degradation on errors
- Timestamp format

Fixes #681
kimi merged commit f7404f67ec into main 2026-03-21 15:13:01 +00:00
kimi deleted branch kimi/issue-681 2026-03-21 15:13:02 +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#743