Content expanders — R-1 authored_paper embeds + R-3 dashboard metadata noise

← All Specs

Content expanders — R-1 authored_paper embeds + R-3 dashboard metadata noise

Task ID: audit-content-expanders-2026-05-14 Layer: Atlas (artifact_detail content rendering) Date: 2026-05-14 v1 carve-out: user-authorized; v1 still serves scidex.ai

R-1 — Authored-paper artifact view shows literal {{artifact:ID}} markers

The /paper/<id> route at api.py:30603 calls _resolve_authored_paper_embeds(db, content) to replace {{artifact:ID[:view]}} markers with rendered artifact cards. The /artifact/authored_paper-* branch at api.py:36304 (in artifact_detail) does not — so the same content shows the raw
markers when viewed via the artifact route. The 2026-05-13 audit
found 9 unique unrendered markers on authored_paper-seaad-microglia-review-001.

Fix: call _resolve_authored_paper_embeds(db, str(_ap_content))
inside the authored_paper branch of artifact_detail before passing
to _render_collapsible_description / simple_md_to_html. Wrap in
try/except so a broken embed can't sink the whole page render
(matches the conservative pattern around the markdown converter
selection that follows).

R-3 — Dashboard metadata table leaks {{data:main}} placeholder

The generic metadata table at api.py:34941+ iterates every metadata.items() and renders them as key/value rows. For dashboard and dashboard_snapshot artifacts the template_html
field is literally the raw {{data:main}} placeholder (the
dashboard engine substitutes it at render time and stores the result
in rendered_html). Without filtering, the metadata table dumps the
placeholder verbatim and end users see {{data:main}} as if the
page were broken.

Inspecting dashboard-evidence-density-map:

rendered_html length  : 17916 chars, no markers
template_html length  : 13 chars, "{{data:main}}"

The dashboard preview block at api.py:35119 already prefers rendered_html, so the preview itself is correct. Only the metadata
table leaks the raw placeholder.

Fix: extend the skip_keys set inside the metadata loop to exclude
dashboard-internal state keys (template_html, rendered_html, view_spec_json, last_render_data, last_render_errors) when atype in ("dashboard", "dashboard_snapshot"). The dashboard
preview block already shows the substituted output; the raw engine
state belongs in the underlying dashboards table, not in the
artifact view.

Verification

  • python3 -c "import ast; ast.parse(open('api.py').read())" → OK
  • Re-run /tmp/audit-2026-05-13/reverify.py. Both R-1 and R-3 should
flip to PASS; no previously-PASS check should regress.
  • Spot-check /artifact/authored_paper-seaad-microglia-review-001
shows rendered embed cards in place of {{artifact:…}} markers.
  • Spot-check /artifact/dashboard-evidence-density-map no longer
shows {{data:main}} anywhere on the page.

Risk

Low.

  • R-1: invokes an existing helper (_resolve_authored_paper_embeds)
that's already exercised by /paper/<id>. Wrapped in try/except so
a single broken marker can't break the page render — falls back to
the original unresolved content.
  • R-3: pure-skip change to the metadata table. The skipped keys are
internal engine state; their content remains in PG artifacts.metadata
for engineers and the dashboard engine to read. The Quick Stats
sidebar and dashboard preview block (which DO need these fields)
read directly from metadata, not from this table.

File: audit-content-expanders-2026-05-14_spec.md
Modified: 2026-05-18 04:17
Size: 3.4 KB