[Atlas/UI] Embeddable Top-10 open questions widget per field, with field-router landing open

← Open Questions as Ranked Artifacts
JSON+HTML widget endpoint and [[openq:top10:]] wiki macro for embedding the per-field leaderboard with 5-min cache.
Spec File

Goal

Surface the per-field Elo leaderboards everywhere they are useful: as an
embeddable JSON+HTML widget that wiki pages, dashboards, and the per-field /science/<field> landing pages can fetch by field tag. Today the data is
queryable via field_leaderboard() in scidex/agora/open_question_tournament.py:600 but there is no public widget
endpoint or reusable HTML component that other surfaces can embed without
rewriting query+render logic.

Acceptance Criteria

☐ New endpoint GET /api/widget/open_questions/top?field=<slug>&limit=10
returns {field, generated_at, items:[{id, question_text,
importance_elo, rd, sub_field, source_kind, age_days, n_matches}]}
,
uses field_leaderboard() under the hood, applies the
status IN ('open','active') filter from the decay task.
☐ New endpoint GET /widget/open_questions/top.html?field=<slug>&limit=10
returns standalone embeddable HTML (≤6KB, no external JS/CSS, inline
styles). Designed to be <iframe>-able from wiki pages and from a
mermaid-fence-style code block (see Q-LIVE
q-live-embed-dashboard-in-wiki).
☐ Wiki extension: [[openq:top10:neurodegeneration]] macro in wiki
content_md is rendered server-side to the widget HTML during
wiki_quality_pipeline.py post-process. Macro syntax is documented
under docs/atlas/openq_widget.md (≤2 pages).
☐ Cache layer: widget JSON cached in Redis (or in-process LRU if Redis
unavailable) for 5 minutes, Cache-Control: public, max-age=300.
☐ Per-field landing page (api.py:56167 field-router) gains a
"Top 10 open questions" panel rendered via the new widget.
☐ Pytest: endpoint returns expected shape; HTML widget validates as
well-formed XHTML; cache is hit on the second call within 5 min;
wiki macro rewriter handles 0 results gracefully.
☐ Smoke: wiki page Alzheimer's disease shows the widget after the
pipeline runs, with at least 1 question.

Approach

  • Read the per-field landing page route around api.py:56167-56270 to
  • slot the widget panel in.
  • Read wiki_quality_pipeline.py and bulk_mermaid.py to learn the
  • content_md post-processing hook (avoid the 2026-04-21 fence-stripping
    regression — see memory project_scidex_mermaid_fence_incident).
  • HTML widget uses inline <style scoped> and a single <table>; no
  • client JS so it's safe to embed via iframe + mermaid fence.

    Dependencies

    • 47ee9103-ccc0 — Elo tournament populates importance_elo
    • q-openq-decay-and-retire-answered — supplies the status filter
    • q-live-embed-dashboard-in-wiki (sibling) — shares the wiki macro
    rendering plumbing

    Work Log

    Sibling Tasks in Quest (Open Questions as Ranked Artifacts) ↗