{# One card per JobVersion. Header: version index + date range + execution count + cost. Body: unified diff against the previous version (or "Initial version" copy for v1). Footer: chips for resolved / newly-introduced rules. Anchor target: id="version-{{ version.version_id }}". The chart's click-handler navigates to /jobs/{first_job_id}?from=cohort which hits the per-execution view; the per-execution view then links back to /jobs/{table}#execution-{job_id} which scrolls to a matching anchor lower in this card. #}
v{{ version.version_index }} {{ version.first_seen.strftime("%Y-%m-%d %H:%M") }} {% if version.first_seen != version.last_seen %} → {{ version.last_seen.strftime("%Y-%m-%d %H:%M") }} {% endif %} UTC {{ version.executions | length }} execution{% if version.executions | length != 1 %}s{% endif %} · {{ version.total_cost | format_usd }}
{# Per-version chips for "Resolved" and "New in this version". Layer 3 fills these sets; before that they're empty and the row collapses cleanly. #} {% if version.resolved_rules or version.newly_introduced_rules %}
{% for rule_type in version.resolved_rules | sort %} {{ rule_type | replace('_', ' ') }} resolved {% endfor %} {% for rule_type in version.newly_introduced_rules | sort %} {{ rule_type | replace('_', ' ') }} new in this version {% endfor %}
{% endif %} {# Diff body — same tabbed Diff / Original SQL idiom as the opportunity-detail improvement card. Reuses the auditSetTab toggler from /opportunities/{id} (we vendor a tiny inline bootstrap below that re-uses the same global window function when present). #} {% if version.diff_against_previous %}
{% set diff_lines = version.diff_against_previous %} {% set file_path = "v" ~ (version.version_index - 1) ~ " → v" ~ version.version_index %} {% include "components/code_diff.html" %}
{% else %} {# v1 — no previous version to diff against. Show the query body directly so users can see what the initial version looked like before any subsequent change. #}

Initial version in this scan window — no previous version to diff against.

{% for line in (version.query_text or '').split('\n') %}{{ loop.index }}{{ line }}
{% endfor %}
{% endif %} {# Per-execution anchors so /jobs/{job_id}?from=cohort can scroll back to the right execution. Hidden visually — anchor only. #}