Task ID: q06-b3-18A23BD8 Layer: Senate Priority: 85 Type: one-time
Build a comprehensive health dashboard that measures how well SciDEX's world model (knowledge graph + wiki + hypotheses + papers) represents scientific reality. The dashboard provides quantitative metrics across four dimensions: coverage (what fraction of known entities/relationships do we capture?), consistency (do hypotheses contradict each other?), freshness (when was each entity last updated?), and depth (edges per entity, citations per hypothesis).
This enables the Senate layer to monitor world model quality, identify gaps, and prioritize improvements. The dashboard should be accessible at /senate or /atlas.
/senate route handler in api.pyPostgreSQL:
knowledge_edges for entity relationship countshypotheses for scoring and evidence dataanalyses for last update timestampspapers for citation coveragesenate.py with functions:def compute_coverage_metrics(conn):
"""Coverage: entities, relationships, papers."""
def compute_consistency_metrics(conn):
"""Consistency: contradictions, conflicts."""
def compute_freshness_metrics(conn):
"""Freshness: last updates, stale entities."""
def compute_depth_metrics(conn):
"""Depth: edges per entity, citations per hypothesis."""
def get_world_model_health():
"""Aggregate all metrics into dashboard data."""/senate handler to api.py:
senate.get_world_model_health()/senate route returns 200 and renders properlycompute_coverage_metrics() — Entity counts, KG edges, papers, wiki coveragecompute_consistency_metrics() — Detect contradicting hypotheses by target genecompute_freshness_metrics() — Track last update times, identify stale entitiescompute_depth_metrics() — Edges per entity, citations per hypothesis, debate depthget_world_model_health() — Aggregate all metrics with overall health score
origin/main (7a48a2eef) and current task branch state./senate exists, but there is no world-model-health module or dashboard covering coverage/consistency/freshness/depth across KG + wiki + hypotheses + papers.api.py, scidex/senate/metrics.py, and related planning docs to keep the fix aligned with existing patterns.scidex.senate.world_model_health metrics module, expose a /senate/world-model-health dashboard, and link it from /senate with targeted tests.scidex/senate/world_model_health.py to compute coverage, consistency, freshness, and depth metrics directly from PostgreSQL tables (knowledge_edges, wiki_pages, hypotheses, papers, debate_sessions, optional tool_invocations)./senate/world-model-health in api.py and a summary card/link on the main /senate dashboard.tests/test_world_model_health.py for contradiction detection and the new route.python3 -m py_compile scidex/senate/world_model_health.py api.py tests/test_world_model_health.py, pytest -q tests/test_world_model_health.py, direct wmh.get_world_model_health() against the live DB, and an in-process GET returning HTTP 200 for /senate/world-model-health.scidex.senate.world_model_health.get_world_model_health() so repeated /senate and /senate/world-model-health hits reuse the same aggregated payload instead of re-running the full metric suite each time.origin/main after the prior task branch was found to be carrying a stale api.py diff that removed portfolio endpoints.api.py from current main and re-applied only the intended changes: /senate summary card, /senate/world-model-health dashboard route, and Senate landing-page link.python3 -m py_compile api.py scidex/senate/world_model_health.py tests/test_world_model_health.py, pytest -q tests/test_world_model_health.py, live get_world_model_health(force_refresh=True), and in-process GET 200 for /senate/world-model-health.