Experiment-extras follow-ups: debate history, what-it-tests, related hypotheses, redirect-hop polish

← All Specs

Experiment-extras follow-ups: debate history, what-it-tests, related hypotheses, redirect-hop polish

Task ID: experiment-extras-followups-2026-05-18 Layer: Atlas (artifact_detail) Date: 2026-05-18 Status: open — follow-up to experiment-artifact-extras-2026-05-13 Priority: medium (enhancements; no broken behavior) v1 carve-out: user-authorized; v1 still serves scidex.ai

Context

PR #1413 ported the high-value sections of the deleted experiment_detail
handler into _render_experiment_extras_html (api.py:31062). Three
capabilities from the old handler were deliberately deferred (low value
or no data today), plus one cleanup item. Capture here so they are not
lost. Each is small and independently shippable; gate every section on
its own data so empty experiments render nothing (consistent with the
existing helper).

Items

1. Related Hypotheses block (~38 LOC) — recommended first

The old handler resolved linked hypotheses two ways and rendered them
with expand/collapse: (a) from experiments.hypothesis_ids (JSON array),
(b) fallback SELECT … FROM hypotheses WHERE target_gene = %s LIMIT 5.
The current artifact experiment branch lists hypothesis ids inline but
not as a scored, titled, collapsible panel with composite scores. Add a
"Related Hypotheses" section to _render_experiment_extras_html (cards
linking /artifact/<hyp_id>, show title + composite_score, "Show N
more" toggle past 5). Tables/cols: hypotheses(id, title,
composite_score, disease)
, experiments.hypothesis_ids, target_gene.

2. Debate History widget (~40 LOC) — gate on rows

The old handler queried experiment_debates JOIN debate_sessions and
rendered linked session cards (/debates/<session_id>,
question + date). experiment_debates currently has 0 rows, so this
renders nothing today — but the join is cheap and the section
self-hides when empty, so it is safe to add now and will light up when
debates are wired to experiments. Cols: experiment_debates(role,
score_before, score_after, debate_session_id)
, debate_sessions(id, question, num_rounds, debate_type, created_at).

3. "What This Experiment Tests" callout (~3 LOC) — lowest value

A one-paragraph templated narrative the old handler showed above the
fold ("{type} experiment designed to {validate|challenge|discover}…
targeting {target_gene} in {model_system}. Primary outcome: …"). Pure
string assembly from experiments.experiment_type / target_gene /
model_system / primary_outcome
— no extra query. Optional; include only
if it reads well next to the metadata grid rather than duplicating it.

4. Redirect-hop polish (~14 call sites + 2 routes) — optional cleanup

Functional but every singular /experiment/<id> link costs one 301 hop
into /artifact/<id>:

  • api_routes/pantheon_routes.py:416 and :422
"experiment": "/experiment/{cid}" and
"experiments": "/experiment/{cid}" → point at /artifact/{cid}.
  • ~14 singular /experiment/<id> link generators in api.py (e.g.
_canonicalize_local_url api.py:30058, the artifact-type→URL lambdas
~api.py:95761 / :96185, etc.). Repointing to /artifact/<id> removes
the hop. Low priority — purely a latency/cleanliness win, behavior is
already correct via the alias.

Verification

  • Each new section appears only when its data exists; absent data → no
empty stub (matches _render_experiment_extras_html conventions).
  • No spillover to non-experiment artifact types.
  • Targeted suite still green (route order, artifact page kinds, etc.).
  • Repointed links resolve directly to /artifact/<id> with no 301.

File: experiment-extras-followups-2026-05-18_spec.md
Modified: 2026-05-18 19:31
Size: 3.6 KB