{% extends "base.html" %} {% block title_suffix %} — {{ session.session_id[:12] }}{% endblock %} {% block content %} {# ── Session header ──────────────────────────────────────────────── #}

{{ session.session_id }}

{{ session.task_type }} · {{ session.scored_at[:19] | replace("T", " ") }} UTC · {{ session.source_path }}

{# ── Takeaway ────────────────────────────────────────────────────── #} {% if attribution_takeaway %}
{{ attribution_takeaway }}
{% endif %} {# ── Attribution ─────────────────────────────────────────────────── #} {% set bcolors = {"B1": "#f59e0b", "B2": "#f97316", "B3": "#3b82f6", "B4": "#8b5cf6", "B5": "#94a3b8", "B6": "#0ea5e9"} %}
Attribution — where did the cost go?
{% if attribution and attribution_rows %} {# ---- Dual stacked bar SVG ---- #} {# Two parallel horizontal bars: top = Cost%, bottom = Tokens%. Same bucket order (cost-ranked). The visual difference between the two bars IS the insight (e.g. 95% tok vs 49% cost for B3). #} {% set bar_w = 660 %} {% set bar_h = 34 %} {% set label_w = 58 %} {% set gap = 10 %} {% set svg_h = bar_h * 2 + gap + 18 %} {% set svg_w = label_w + bar_w + 4 %}
Cost Tokens 0% 100% {# ---- Cost bar (top) ---- #} {% set ns = namespace(cx=label_w | float) %} {% for row in attribution_rows %} {% set seg_w = (row.cost_pct / 100.0 * bar_w) | round(2) %} {% if seg_w > 0.5 %} {{ row.bucket }} {{ row.label }}: {{ row.cost_pct }}% cost / {{ row.tok_pct }}% tokens {% if seg_w >= 32 %} {{ row.cost_pct }}% {% endif %} {% set ns.cx = ns.cx + seg_w %} {% endif %} {% endfor %} {# ---- Token bar (bottom) — same bucket order, sized by tok_pct ---- #} {% set ns = namespace(cx=label_w | float) %} {% for row in attribution_rows %} {% set seg_w = (row.tok_pct / 100.0 * bar_w) | round(2) %} {% if seg_w > 0.5 %} {{ row.bucket }} {{ row.label }}: {{ row.tok_pct }}% tokens / {{ row.cost_pct }}% cost {% if seg_w >= 32 %} {{ row.tok_pct }}% {% endif %} {% set ns.cx = ns.cx + seg_w %} {% endif %} {% endfor %}
{# ---- Companion table: both cost% and tok% per bucket ---- #} {% for row in attribution_rows %} {% endfor %}
Bucket Cost% ▼ Tok% Cost ($)
{{ row.bucket }} {{ row.label }} {{ row.cost_pct }}% {{ row.tok_pct }}% ${{ "%.4f" | format(row.usd) }}
TOTAL (billed) 100% 100% ${{ "%.4f" | format(attribution.total_usd) }}
{# Honesty element 3: billed-basis label + real_tokens != verdict note #}

Basis: {{ "{:,}".format(attribution.total_billed_tokens) }} total billed tokens (includes cached re-reads). real_tokens (verdict basis): {{ "{:,}".format(attribution.real_tokens) }} — cached re-reads are excluded from the verdict axis but included in this chart; do not compare attribution cost% directly to the real_tokens verdict.

{{ attribution.domain_of_validity }}
{% else %} {# Attribution source file not accessible #}
UNAVAILABLE

Source file not accessible — attribution requires the original JSONL log. Ensure source_path is reachable, or re-run tes score <path>.

{% endif %}
{# ── Token Economy ───────────────────────────────────────────────── #}
Token Economy
{# Honesty element 5: "relative to YOUR OWN baseline" + element 6: baseline source #} {% if session.baseline_available %} {% endif %}
Real Tokens {{ "{:,}".format(session.real_tokens) }}
Band Verdict {% if session.band_verdict == "above_p75" %} above_p75 {% elif session.band_verdict == "below_p25" %} below_p25 {% elif session.band_verdict == "within_band" %} within_band {% else %} {{ session.band_verdict }} {% endif %}
Baseline {% set bs = session.get("baseline_source", "b2_corpus") %} {% if bs == "self" %} self vs your own lean waste-free runs {% if session.p25 is not none and session.p75 is not none %} ({{ "{:,}".format(session.p25) }}–{{ "{:,}".format(session.p75) }} token band) {% endif %} {% elif bs == "building" %} building self-baseline not yet active {% elif bs == "corpus" %} corpus infra-heavy fallback — your own baseline pending {% else %} b2 B2 reference corpus (infra-heavy single-developer; self-baseline not yet scored) {% endif %}
Band p25 {{ "{:,}".format(session.p25) if session.p25 is not none else "—" }}  ·  median {{ "{:,}".format(session.median) if session.median is not none else "—" }}  ·  p75 {{ "{:,}".format(session.p75) if session.p75 is not none else "—" }}
Scope {{ session.scope_status }}
Interpretation {{ session.interpretation }}
{# Honesty element 1: DOV caveat — visible, not buried #}
{{ session.token_domain_of_validity }}
{# ── Trajectory Quality ──────────────────────────────────────────── #}
Trajectory Quality
{% if traj_state == TrajectoryRenderState.UNAVAILABLE %} {# Honesty element 4: UNAVAILABLE = calm invitation, not an error #}

UNAVAILABLE

Token and waste axes ran. Trajectory scoring is optional — enable with one of:

{# Honesty element 8: API-judge data-egress warning (ADDED — was absent from old template) #}

API judge note: sends session data — including 300-char snippets that may contain your code — to your configured provider. Explicit consent required at the CLI before any data is sent.

{% elif traj_state == TrajectoryRenderState.STALE %}

{{ session.judge_verdict }} {% if session.judge_score is not none %} score {{ "%.2f" | format(session.judge_score) }} {% endif %}

{% if session.judge_reasoning %}

{{ session.judge_reasoning }}

{% endif %}

Verdict from an earlier version of this session (session grew after judging). Re-run tes score <path> to update.

{% else %} {# CURRENT #}

{{ session.judge_verdict }} {% if session.judge_score is not none %} score {{ "%.2f" | format(session.judge_score) }} {% endif %}

{% if session.judge_reasoning %}

{{ session.judge_reasoning }}

{% endif %} {% endif %} {# Honesty element 1: trajectory DOV — visible #}
{{ session.trajectory_domain_of_validity }}
{# ── Deterministic Waste ─────────────────────────────────────────── #}
Deterministic Waste
{% if session.waste_event_count == 0 %}

No waste detected.

{% else %} {# Compute total waste cost for collapsed-state signal (honesty element 7) #} {% set wns = namespace(total=0.0) %} {% for ev in session.waste_events %} {% set wc = ev.get("wasted_cost_usd") %} {% if wc is not none and wc > 0 %}{% set wns.total = wns.total + wc %}{% endif %} {% endfor %} {# Honesty element 7: collapsed state SHOWS count + cost; one click reveals evidence #}
{{ session.waste_event_count }} waste event{{ 's' if session.waste_event_count != 1 else '' }} {% if wns.total > 0.0001 %}  — ${{ "%.2f" | format(wns.total) }} {% endif %}  · show proof turns {% for event in session.waste_events %} {% endfor %}
Detector Proof Turns Wasted Cost Evidence
{{ event.get("detector", "—") }} {% set turns = event.get("turns", []) %} {% if turns %}{{ turns | join(", ") }}{% else %}—{% endif %} {% set wc = event.get("wasted_cost_usd") %} {% if wc is not none and wc > 0 %} ~${{ "%.3f" | format(wc) }} {% else %} {% endif %} {% set evidence = event.get("evidence", {}) %} {% if evidence %}
{{ evidence | tojson(indent=2) }}
{% else %}—{% endif %}
{% endif %} {# Honesty element 1: waste DOV — always visible #}
{{ session.waste_domain_of_validity }}
{# ── Cost Annotation ─────────────────────────────────────────────── #} {% if session.get("session_cost_usd") is not none %}
Cost Annotation
Session Cost ${{ "%.2f" | format(session.session_cost_usd) }} {% if session.get("cost_approximate") %} [~] approximate {% endif %}
vs Your Baseline {% if cost_vs_baseline_pct is not none %} {% if cost_vs_baseline_pct >= 0 %} +{{ cost_vs_baseline_pct }}% above your typical efficient run (~${{ "%.2f" | format(baseline_cost_median) }}) {% else %} {{ cost_vs_baseline_pct }}% below your typical efficient run (~${{ "%.2f" | format(baseline_cost_median) }}) {% endif %} {% else %} no baseline yet {% endif %}
Price Basis {{ price_provenance }}

Cost is not a score. It annotates the token axis at API-equivalent rates. Flat-plan users: marginal cost differs; token consumption is the honest metric.

{% if session.get("cost_domain_of_validity") %}
Cost domain of validity
{{ session.cost_domain_of_validity }}
{% endif %}
{% endif %} {% endblock %}