///|
/// Render the self-contained AI Trace Clinic.
///
/// The page intentionally has no framework, server, or external asset. Its
/// default evidence mirrors `fixtures/agent-traces`: a selection-sort trace
/// whose stale-index swap first diverges at step 10.
pub fn render_trace_playground() -> String raise TraceError {
  // Preserve the established fallible API while validating the empty clinic
  // shell with the same scene rules used by imported traces.
  ignore(Scene::new(objects=[]))
  (
    #|
    #|
    #|
    #|
    #|FrontierLab AI Trace Clinic
    #|
#|
Semantic Time-Travel Debugger · Schema v1

AI Trace Clinic

Turn an opaque wrong trace into a contract failure, the first divergence, two precise state comparisons, and a portable focused counterexample slice — in one click, fully offline.

#|

Find the first wrong step

Ready: the built-in incorrect example is loaded.
#|

Schema

Not run

Contract

Not run

First divergence

Not run

Focus

Not run
#|

Expected event vs actual event

✓ Expected

Run diagnosis.

✕ Actual

Run diagnosis.

Focused counterexample slice

Run diagnosis.

#|

State evidence

Actual transition into focus

Run diagnosis.

Reference vs actual at focus

Run diagnosis.
#|
#|

Faulty selection sort - stale index

Run diagnosis to jump to the first bad step.

#|
Advanced details #|
Drop a JSON file here or choose one

#|
#|

Semantic breakpoints

#|

Trace contract

#|

First divergence

#|

Quality diagnostics

    Windowed timeline

    At most 101 nearby entries are rendered for large traces.

    #|
    ) }