Restore rich hypothesis rendering on /artifact/<id>

← All Specs

Problem

/artifact/h-var-… (and every other hypothesis artifact URL) regressed in
two stages:

  • UUID migration Phase 4 (commit 11bbe3c4b) registered a 301 alias
  • /hypothesis/{id}/artifact/{id} ahead of the rich
    hypothesis_detail() route at api.py:45534. FastAPI matches first‑declared,
    so the radar SVG / 11‑dimension breakdown / markdown description / debate
    history / related‑hypothesis panel rendered there became unreachable.
  • The elif atype == "hypothesis": branch inside artifact_detail()
  • (api.py:32336) only renders a 500‑char raw‑text excerpt, four sub‑score
    bars, and a 🧪 View Full Hypothesis → link that is now circular (it
    redirects right back to the page the user is already on).
  • The Provenance / Versions / Links tabs introduced by the artifact‑detail
  • refactor have no hypothesis‑aware data source, so for hypotheses they show
    "No provenance edges", "No version history", "No linked artifacts".

    PR #1354 fixed lookup for non‑prefixed IDs but did not restore any rich
    content.

    Approach (Option B from conversation)

    Inline hypothesis‑specific rich content directly into artifact_detail and
    populate the existing tabs from hypothesis tables. Keep /artifact/<id> as
    the single canonical URL.

    Helpers added (api.py near _wrap_artifact_detail_tabs)

    • _hyp_radar_svg(h) — 11‑dim weighted radar SVG (lifted from
    hypothesis_detail).
    • _hyp_dimension_breakdown(h) — full 11‑dimension score grid with weights.
    • _hyp_predictions_panel(db, hyp_id) — falsifiable predictions list.
    • _hyp_debate_history_html(db, hyp_id, analysis_id) — debate sessions
    feeding the Provenance tab.
    • _hyp_versions_panel(db, hyp_id) — parent / siblings / children chain via
    hypotheses.parent_hypothesis_id, feeding the Versions tab.
    • _hyp_related_panel(db, h, hyp_id) — same target_gene / disease
    hypotheses, feeding the Links tab.

    All helpers are self‑contained, return strings, and tolerate missing
    columns / empty results.

    Hypothesis branch (api.py:32336)

    • Replaced 500‑char [:500] truncation with _render_collapsible_description
    (markdown headings, bold, lists, code blocks, mermaid renderable).
    • Replaced 4 sub‑score bars with the radar SVG + full 11‑dim breakdown.
    • Removed the dead "View Full Hypothesis →" self‑link.
    • Added target / disease badge row.
    • Captures three augmentation strings (_hyp_extra_provenance,
    _hyp_extra_versions, _hyp_extra_links) initialised to "" at the top
    of artifact_detail and merged into the corresponding tab variables right
    before tab assembly.

    Acceptance

    • /artifact/h-var-6612521a02 renders radar SVG, 11‑dimension breakdown,
    full markdown‑rendered description (no [:500] truncation), debate
    history, related hypotheses (where applicable).
    • Versions tab shows parent / sibling / child chain when
    parent_hypothesis_id exists; empty placeholder otherwise.
    • No regression for paper / analysis / notebook / figure / wiki_page
    artifact pages (smoke‑tested via TestClient).
    • The dead /hypothesis/{id}/artifact/{id} redirect remains
    in place — the URL is now the single canonical home.

    Out of scope

    • Removing the /hypothesis/{id} alias route or the now‑unreachable
    hypothesis_detail() function. Those can be retired in a follow‑up
    once we confirm nothing external still links to them and no other code
    paths depend on the function.
    • Description‑level cleanup of inline --- ## separators (the underlying
    data quality issue affects a small fraction of debate‑synthesised
    descriptions; orthogonal to this regression).

    File: restore-hypothesis-rich-rendering-spec.md
    Modified: 2026-05-18 04:17
    Size: 3.8 KB