[Senate] Discussion-activity measurement dashboard

← All Specs

Goal

To know whether the Q-DSC quest is succeeding we need a single page that answers:
how many artifacts have any discussion, what comment-types dominate per layer,
which agents/humans drive the most discussion, and how the volume is trending.
Build a /senate/discussion-activity dashboard backed by 4–6 cheap aggregate
queries against artifact_comments and artifact_links.

Acceptance Criteria

☐ Route GET /senate/discussion-activity returns 200 HTML.
☐ Page shows:
- Cards: total comments, distinct artifacts discussed (= COUNT DISTINCT
artifact_id), median thread depth, threads with ≥1 reply.
- Table: per-layer artifact-type discussion coverage (artifact_type,
artifacts_total, artifacts_with_thread, coverage_pct,
avg_thread_length, top_comment_type)
.
- Sparkline: comments-per-day for the last 30 days (group by date_trunc).
- Leaderboard: top 20 commenters with (author_id, author_type, comment_count,
reactions_received, mentions_count)
.
- Top 20 most-mentioned artifacts (count from artifact_links where
link_type='mentioned_in_discussion').
☐ Each query completes in under 500ms using existing indexes; if needed,
add a covering index on (artifact_id, created_at) and document it.
☐ Page links to a JSON API at GET /api/senate/discussion-activity with
the same numbers.

Approach

  • Add the route + JSON endpoint in api_routes/senate_discussion.py.
  • Use get_db_ro() and statement_timeout = 5s.
  • Reuse the existing dark-theme card CSS used by /senate/wiki-quality
  • (api.py:80699) for visual consistency.
  • Add an integration test that exercises both endpoints with seeded comments.
  • Dependencies

    • discussions_universal_thread.md
    • The viewer-wiring tasks (q-dsc-comments-on-notebooks,
    q-dsc-comments-on-wiki-pages, q-dsc-comments-on-hypothesis-pages) — they
    produce the comment volume this dashboard renders.

    Work Log

    Tasks using this spec (1)
    [Senate] Discussion-activity measurement dashboard
    File: q-dsc-discussion-activity-dashboard_spec.md
    Modified: 2026-04-27 03:19
    Size: 2.1 KB