[Exchange] Hypothesis detail page enrichment

← All Specs

[Exchange] Hypothesis detail page enrichment

Goal

Enhance hypothesis detail pages at /hypothesis/{id} to display comprehensive context including linked papers with citations, price history charts showing scoring evolution, related hypotheses by target gene, and knowledge graph neighborhood. Currently these pages lack critical data that would help users understand hypothesis quality, provenance, and relationships.

Acceptance Criteria

☑ Linked papers section shows PubMed citations with PMIDs (already present)
☑ Price history chart displays composite score evolution over time
☑ Related hypotheses section lists hypotheses targeting the same gene
☑ Knowledge graph neighborhood shows connected entities (already present)
☑ All sections gracefully handle missing/empty data
☑ Page loads in <2 seconds
☑ Python syntax verified

Approach

  • Read current /hypothesis/{id} route handler in api.py
  • Check database schema for related tables: papers, price_history, knowledge_edges
  • Query and join relevant data for each section:
  • - Papers: JOIN with evidence_for/evidence_against PMIDs
    - Price history: SELECT from price_history WHERE hypothesis_id = ?
    - Related hypotheses: SELECT WHERE target_gene = ?
    - KG neighborhood: SELECT from knowledge_edges WHERE source/target references hypothesis
  • Generate HTML sections for each enrichment
  • Update the hypothesis detail route with enhanced data
  • Test page rendering and performance
  • Already Resolved — 2026-04-26 03:40:00Z

    Verified on live system at http://localhost:8000/hypothesis/h-019ad538 and h-044ee057:

    • Linked papers with citations: Cited Papers section shows 49-84 papers per hypothesis with full metadata (title, journal, year, PMID links) — "&#x1f4da; Cited Papers (84)" heading, paper cards with PubMed links
    • Price history chart: Market tab contains SVG price history chart with 232+ events, dual-line display (market price + composite score), color-coded event dots for evidence/debate/score_update events
    • Related hypotheses by target gene: Related Hypotheses section lists other hypotheses targeting same gene (e.g., TREM2, CLOCK) with score, disease, status
    • KG neighborhood: KG Entities section shows 26-36 entity chips by type (gene/protein/disease/pathway), Knowledge Subgraph (110+ edges), hyperlinked entity chips linking to wiki/entity pages
    • ✅ All sections gracefully handle empty data (fallback messages present)

    All acceptance criteria met by prior task work. Task re-opened (no task_runs row) but no additional implementation needed.

    Work Log

    2026-04-01 23:15 PT — Slot 2

    Investigation:

    • Read current hypothesis detail route in api.py (lines 742-992)
    • Found that papers with PMIDs and KG edges were already present
    • Identified missing features: price history chart and related hypotheses
    • Checked database schema for available data:
    - market_transactions table: has price history (new_price, created_at, action, reason)
    - hypotheses table: has target_gene for finding related hypotheses
    - 8 market transactions across 7 hypotheses
    - 118 total hypotheses
    - Multiple target genes with 2+ hypotheses (APOE: 5, AQP4: 3, TARDBP: 3, etc.)

    Implementation:

    • Added queries in hypothesis detail route (api.py):
    - Price history: SELECT from market_transactions WHERE hypothesis_id = ? ORDER BY created_at
    - Related hypotheses: SELECT from hypotheses WHERE target_gene = ? AND id != ? LIMIT 5
    • Generated price history chart HTML:
    - SVG line chart (500x150) with time series visualization
    - Shows composite score evolution over time
    - Includes grid lines, axis labels, data points with connecting line
    - Gracefully handles empty data with placeholder message
    • Generated related hypotheses section HTML:
    - Card layout showing title, score, disease, status
    - Color-coded scores (blue: ≥0.7, green: ≥0.5, yellow: <0.5)
    - Links to related hypothesis detail pages
    - Shows "No related hypotheses" message if none found
    • Inserted both sections into page template:
    - Price history after dimension scores radar chart
    - Related hypotheses after knowledge subgraph section

    Verification:

    • Verified Python syntax: python3 -c "import py_compile; py_compile.compile('api.py', doraise=True)" → OK
    • Committed changes with descriptive message
    • Pushed to branch: orchestra/task/b74e6fdc-c4d6-48f2-ad9b-96d8430072dc
    Result: Complete. Hypothesis detail pages now show:
  • ✅ Price history chart with composite score time series
  • ✅ Related hypotheses by target gene (top 5 by score)
  • ✅ Existing features preserved: papers with PMIDs, dimension radar, KG edges
  • Changes will be live after supervisor merges branch and restarts API service.

    File: f3840c8c-a813-429b-8340-c2f5440dc08e_spec.md
    Modified: 2026-04-25 23:40
    Size: 4.8 KB