Implement a resolve_embeds() function that replaces {{artifact:ID}} markers in analysis reports and hypothesis descriptions with rich, interactive HTML previews of artifacts (notebooks, 3D protein structures, pathway diagrams, etc.).
Quest 17 (Rich Artifacts) is highest priority. Analyses and hypotheses can reference artifacts (Jupyter notebooks, protein structures, pathway diagrams), but currently these are just links. We need inline rendered previews for better user experience.
artifacts table with types: notebook, protein_structure, pathway_diagram, etc._resolve_embeds / _render_artifact_embed_html for API endpoints, but post_process.py (which generates HTML reports via generate_report()) has no such functionresolve_embeds() functionLocation: post_process.py (before the Quality Gates section)
_EMBED_PATTERN = re.compile(r'\{\{artifact:([a-zA-Z0-9_-]+)\}\}')
def _render_artifact_embed_html(artifact_id: str, db) -> str:
"""Render HTML for one artifact embed marker."""
# Queries artifacts table, returns typed HTML for each artifact type
...
def resolve_embeds(text: str) -> str:
"""Replace all {{artifact:ID}} markers with rendered HTML previews."""
if not text:
return text
db = get_db()
try:
def replace_embed(match):
artifact_id = match.group(1).strip()
return _render_artifact_embed_html(artifact_id, db)
result = _EMBED_PATTERN.sub(replace_embed, text)
finally:
db.close()
return resultgenerate_report()In the hypothesis description handling within generate_report():
desc_full = html_unescape.unescape(h[3])
# Resolve artifact embeds if description contains markers; otherwise truncate
if "{{artifact:" in desc_full:
desc_html = resolve_embeds(desc_full)
else:
desc_html = desc_full[:200] + ("..." if len(desc_full) > 200 else "")This preserves existing behavior (200-char truncation) for descriptions without artifact markers, and renders full descriptions with embedded artifacts when markers are present.
resolve_embeds() function implemented in post_process.py_render_artifact_embed_html() handles all key artifact typesgenerate_report() — artifact markers in hypothesis descriptions trigger full renderingpython3 -m py_compile post_process.py passes)get_db_write() from database module available in post_process.pyChanges:
_EMBED_PATTERN regex and _render_artifact_embed_html() function to post_process.py (~130 lines), placed before the "Quality Gates" section at line 588resolve_embeds() function that uses get_db() to look up artifacts and substitute HTMLgenerate_report() (line ~2293) to check for {{artifact: markers and call resolve_embeds() when present, preserving truncation for non-artifact descriptionsVerification:
python3 -m py_compile post_process.py — ✅ passes/artifacts/{id}/preview endpoint to api.py for notebook rendering{
"requirements": {
"coding": 8,
"reasoning": 7
},
"completion_shas": [
"84e32e5a5e412fdae6fc38d0f1981c0139be017f",
"fe6e3e7f0934f33ee4b6be391888ce2bf67a8117"
],
"completion_shas_checked_at": "2026-04-14T00:41:31.569373+00:00"
}