[Senate] Build real-time resource monitoring dashboard

← All Specs

[Senate] Build real-time resource monitoring dashboard

Quest: Resource Governance Priority: P4 Status: done

Goal

Add a /resources page (or enhance existing) showing real-time VM resource usage, per-analysis resource consumption, cost tracking, and historical trends. This is the control panel for resource governance.

Acceptance Criteria

☑ Real-time CPU, memory, disk, network stats on /resources page
☑ Per-analysis resource breakdown (memory, CPU time, tokens, cost)
☑ Historical charts: daily cost trend, resource usage over time (pre-existing Cost Dashboard with Chart.js)
☑ Alert indicators when resources approach limits
☑ Auto-refresh every 15 seconds

Approach

  • Enhance existing /resources route in api.py
  • Add psutil-based real-time metrics
  • Query resource_usage table for per-analysis breakdown
  • Add simple chart rendering (CSS bar charts or inline SVG)
  • Add alert thresholds matching resource governance limits
  • Dependencies

    _Identify during implementation._

    Dependents

    _Identify during implementation._

    Work Log

    2026-04-21 03:17 PDT — Slot codex:52

    • Reopened after merge gate found the previous task branch could not merge cleanly.
    • Rechecked current origin/main: /resources existed, but Live VM Resources, /api/resources/vm-stats, fetchVmStats(), and per_analysis_section were absent.
    • Reviewed recent api.py changes and preserved the security headers/authentication work that landed after the earlier attempt.
    • Implemented the scoped dashboard work in api.py: live psutil VM metrics endpoint, 15-second polling UI with alert thresholds, per-core CPU bars, and a per-analysis resource table from resource_usage.
    • Hardened the per-analysis query with table_exists(), token resource-type variants, CPU-time variants, optional memory peak columns, event counts, and graceful debug logging.
    • Verified: python3 -m py_compile api.py passed; direct api_resources_vm_stats() returned ok: true with CPU, memory, disk, and network fields; resources_dashboard() HTML contains Live VM Resources, fetchVmStats, /api/resources/vm-stats, Per-Analysis Resource Breakdown, and Peak Memory.

    Tasks using this spec (1)
    [Senate] Build real-time resource monitoring dashboard
    File: 7034fc7b952e_senate_build_real_time_resource_monitor_spec.md
    Modified: 2026-04-25 23:40
    Size: 2.5 KB