{% if not q %}
This question no longer exists.
{% else %}
{{ qkey }} {{ LABELS[q.state] }} {% if q.asked_at %}asked {{ q.asked_at[:16]|replace('T', ' ') }}{% endif %}
{% if done %}{% endif %} {% if error %}{% endif %} {% if conflict %}{% endif %}
{% if q.state == 'new' %} {% if context %}
Earlier in the conversation: {% for c in context|reverse %}{{ c.question }}{% if not loop.last %} → {% endif %}{% endfor %}
{% endif %} {% else %}

{{ q.question }}

{% endif %} {% set editable = actions|select('in', ['promote_test', 'promote_example', 'write_golden', 'fix_golden'])|list %} {% set sql_now = q.golden_sql or (q.genie_sql if editable else none) %} {% set failed = last and last.assessment != 'good' and last.actual_sql %} {# The truth check is the NUMBER (decision #30): result rows first, loaded on open; SQL folded below. Failed tests show both answers side by side. hx-target="this" is not optional: htmx inherits the form's hx-target="#panel", and the rows would replace the whole panel (odense, 2026-09-20). #}
{% if sql_now %}
running…
{% else %}
No SQL yet.
{% endif %}
{% if failed %}
{% if reasons %}
    {% for x in reasons %}
  • {{ REASON.get(x, x) }}
  • {% endfor %}
{% endif %}
running…
{% endif %}
{% if editable %}
SQL {% if q.state == 'new' %}— Genie's draft; fix it to what the user should have seen{% elif q.state == 'candidate' %}— write it here first{% else %}— edit only if the number above is wrong{% endif %}
first 20 rows
{% elif q.golden_sql %}
SQL
{{ q.golden_sql }}
{% endif %} {% if last and last.actual_sql %}
Genie's SQL
{{ last.actual_sql }}
{% elif last %}

Genie gave no SQL on {{ last.started_at[:16]|replace('T', ' ') }} · {{ {'good':'correct','bad':'wrong'}.get(last.assessment, 'needs review') }}

{% endif %} {% set tags = [q.difficulty, q.measure, q.measure_variant, q.time_period, q.filters]|select|list %} {% if tags or q.expected_answer or q.note %}
From the test set {% if tags %}

{% for t in tags %}{{ t }}{% endfor %}

{% endif %} {% if q.expected_answer %}

Expected: {{ q.expected_answer }}

{% endif %} {% if q.note %}

{{ q.note }}

{% endif %}
{% endif %} {% if actions %}
{% for a in actions if a not in DISMISS %}{% endfor %} {% for a in actions if a in DISMISS %}{% endfor %}
{% endif %}
{% if events %}
History
    {% for e in events %}
  1. {{ e.at[:16]|replace('T', ' ') }} {{ e.who }} · {{ e.action }}{% if e.from_state %} {{ LABELS.get(e.from_state, e.from_state) }} →{% endif %} {{ LABELS.get(e.to_state, e.to_state) }}{% if e.note %} — {{ e.note }}{% endif %}
  2. {% endfor %}
{% endif %}
{% endif %}