[claude] Sovereignty metrics emitter + SQLite store (#954) #1164
Reference in New Issue
Block a user
Delete Branch ":claude/issue-954"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #954
What this does
Implements the sovereignty metrics infrastructure for the Bannerlord sovereignty loop.
New module:
src/timmy/sovereignty/metrics.pySovereigntyMetricsStorebacked by SQLite (data/sovereignty_metrics.db)eventstable:timestamp,event_type,session_id,metadata_jsonsessionstable:session_id,game,start_time,end_timerecord(event_type, metadata)— logs any of the 9 sovereignty event typesget_sovereignty_pct(layer, time_window)→ float (0–100)get_cost_per_hour(time_window)→ float (USD)get_skills_crystallized(session_id)→ intget_snapshot()— real-time dict for dashboard widgetsemit_sovereignty_event()— async helper that records + publishes on event busmetrics.record(...),metrics.get_sovereignty_pct(...), etc.WebSocket emitter:
src/dashboard/routes/sovereignty_ws.py/ws/sovereignty— streams snapshots every 5 s to dashboard widget clientsdashboard/app.py34 new unit tests (all passing, included in
tox -e unit)Covers all analytics functions, session management, edge cases, and
emit_sovereignty_event.