File size: 26,256 Bytes
fd11263 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | """Small, dependency-free HTML view for completed evaluation artifacts."""
from __future__ import annotations
import html
import json
import math
from typing import Any
from collections.abc import Mapping
from urllib.parse import urlsplit
from ..models import deep_thaw
from .models import ReportData
def _bar(value: Any, maximum: float, *, unavailable: bool = False) -> str:
if unavailable or value is None:
return '<span class="unavailable">unavailable</span>'
try:
number = float(value)
except (TypeError, ValueError):
return '<span class="unavailable">unavailable</span>'
if not math.isfinite(number) or number < 0:
return ""
width = 0 if maximum <= 0 or number == 0 else max(2, min(100, number / maximum * 100))
return f'<span class="bar" aria-hidden="true"><i style="width:{width:.2f}%"></i></span>'
def _numeric_value(value: Any) -> float | None:
"""Return a safe chart scalar without knowing evaluator or metric names.
Scalar measurements are directly chartable. For structured values, a
conventional numeric ``total`` is used when present; arbitrary mappings
remain structured unless they contain exactly one numeric leaf. This
keeps the renderer generic while avoiding a misleading choice between
unrelated fields such as p50/p95/count.
"""
if isinstance(value, Mapping):
total = value.get("total")
if isinstance(total, (int, float)) and not isinstance(total, bool):
value = total
else:
numeric = [item for item in value.values()
if isinstance(item, (int, float)) and not isinstance(item, bool)]
value = numeric[0] if len(numeric) == 1 else None
if isinstance(value, bool) or not isinstance(value, (int, float)):
return None
try:
number = float(value)
except OverflowError:
return None
return number if math.isfinite(number) else None
def _chart_maxima(rows: list[Mapping[str, Any]]) -> dict[str, float]:
"""Return independent chart scales for each declared measurement unit.
Units are part of the generic measurement contract, so values in seconds,
tokens, or a future evaluator-defined unit must not distort one another's
bars. No evaluator or metric identifier is inspected here.
"""
maxima: dict[str, float] = {}
for row in rows:
number = _numeric_value(row.get("value"))
if number is None:
continue
unit = str(row.get("unit") or "")
maxima[unit] = max(maxima.get(unit, 0.0), number)
return maxima
def _display_value(value: Any) -> str:
if isinstance(value, (Mapping, list, tuple)):
return json.dumps(deep_thaw(value), ensure_ascii=False, sort_keys=True)
if value is None:
return "unavailable"
return str(value)
def _json_text(value: Any) -> str:
try:
return json.dumps(deep_thaw(value), ensure_ascii=False, sort_keys=True, indent=2, default=str)
except (TypeError, ValueError):
return str(value)
def _rounded_value(value: Any) -> Any:
"""Display precision only; persisted scores and chart scales stay exact."""
if isinstance(value, Mapping):
return {key: _rounded_value(item) for key, item in value.items()}
if isinstance(value, (list, tuple)):
return [_rounded_value(item) for item in value]
if isinstance(value, float) and math.isfinite(value):
return round(value, 1)
return value
def _measurement_value_html(value: Any, unit: Any, maximum: float) -> str:
numeric = _numeric_value(value)
structured = isinstance(value, (Mapping, list, tuple))
primary = f"{numeric:,.1f}" if numeric is not None else ("" if structured else _display_value(value))
rounded = _rounded_value(value)
parts = [
'<div class="measurement-value">',
f'<div class="value-head"><strong>{html.escape(primary)}</strong>'
f'<span class="unit">{html.escape(str(unit or ""))}</span></div>',
_bar(numeric, maximum) if numeric is not None and numeric >= 0 else "",
]
if structured:
parts.append(f'<div class="value-breakdown"><code>{html.escape(_display_value(rounded))}</code></div>')
if _display_value(rounded) != _display_value(value):
parts.append(f'<details class="exact-value"><summary>Exact value</summary><pre>{html.escape(_json_text(value))}</pre></details>')
parts.append('</div>')
return "".join(parts)
def _identity_html(fields: list[tuple[str, Any]]) -> str:
return '<dl class="identity-grid">' + "".join(
f'<div><dt>{html.escape(label)}</dt><dd>{html.escape(str(value or "—"))}</dd></div>'
for label, value in fields
) + '</dl>'
def _status_class(status: Any) -> str:
normalized = str(status or "unavailable").lower().replace("_", "-")
if normalized == "exact":
return "status-exact"
if normalized in {"partial", "batched", "ambiguous"}:
return "status-warning"
if normalized in {
"missing-explicit-event", "testpoint-not-reached", "trace-missing", "unavailable",
"token-attributes-missing", "previous-boundary-ambiguous",
"previous-boundary-unavailable", "previous-boundary-timestamp-unavailable",
"completion-timestamp-unavailable", "root-start-timestamp-unavailable",
"invalid-interval-order",
}:
return "status-unavailable"
return "status-warning"
def _measurement_rows(result: Any) -> list[dict[str, Any]]:
rows: list[dict[str, Any]] = []
for score in result.scores:
if score.result_kind != "measurement":
continue
metadata = score.metadata or {}
rows.append({
"case_id": score.case_id,
"evaluator_id": score.evaluator_id,
"stage": score.testpoint_id,
"metric": score.metric,
"unit": score.unit,
"value": score.value,
"label": score.label,
"status": score.status,
"metadata": metadata,
"attribution_status": metadata.get("attribution_status"),
"explanation": score.explanation,
"evidence_refs": score.evidence_refs,
})
return rows
def _assessment_rows(result: Any) -> list[dict[str, Any]]:
return [{
"case_id": score.case_id,
"evaluator_id": score.evaluator_id,
"testpoint_id": score.testpoint_id,
"label": score.label,
"score": score.score,
"status": score.status,
"explanation": score.explanation,
"evidence_refs": score.evidence_refs,
"metadata": score.metadata,
} for score in result.scores if score.result_kind == "assessment"]
def _diagnostic_rows(result: Any) -> list[dict[str, Any]]:
rows: list[dict[str, Any]] = []
for score in result.scores:
if score.result_kind != "diagnostic":
continue
metadata = score.metadata or {}
value = score.value
selection = metadata.get("selection") if isinstance(metadata.get("selection"), Mapping) else {}
rows.append({
"case_id": score.case_id,
"evaluator_id": score.evaluator_id,
"testpoint_id": score.testpoint_id,
"label": score.label,
"summary": score.explanation,
"duration_seconds": selection.get("duration_seconds"),
"rank": selection.get("rank"),
"selected": selection.get("selected", False),
"evidence_completeness": metadata.get("evidence_completeness"),
"bottlenecks": value.get("bottlenecks", []) if isinstance(value, Mapping) else [],
"value": value,
"metadata": metadata,
"explanation": score.explanation,
"status": score.status,
"evidence_refs": score.evidence_refs,
})
return rows
def _evidence_links(refs: list[str]) -> str:
if not isinstance(refs, (list, tuple)) or not refs:
return '<span class="muted">none</span>'
return ", ".join(
f"<code>{html.escape(str(ref))}</code>"
for ref in refs
)
def _diagnostic_html(rows: list[dict[str, Any]]) -> str:
if not rows:
return "<p>No diagnostics recorded.</p>"
rendered: list[str] = []
for row in sorted(rows, key=lambda item: (
str(item["case_id"]), str(item["evaluator_id"]), str(item["testpoint_id"]),
)):
findings: list[str] = []
bottlenecks = row["bottlenecks"] if isinstance(row["bottlenecks"], (list, tuple)) else []
for finding in bottlenecks:
if not isinstance(finding, Mapping):
continue
findings.append(
'<li class="finding">'
f'<strong>{html.escape(str(finding.get("category", "finding")))}</strong> '
f'<span class="confidence">confidence={html.escape(str(finding.get("confidence", "unknown")))}</span>'
f'<p>{html.escape(str(finding.get("finding", "")))}</p>'
f'<p><strong>Impact:</strong> {html.escape(str(finding.get("impact", "")))}</p>'
f'<p><strong>Recommendation:</strong> {html.escape(str(finding.get("recommendation", "")))}</p>'
f'<p><strong>Evidence:</strong> {_evidence_links(finding.get("evidence_refs") or [])}</p>'
'</li>'
)
findings_html = f'<ul>{"".join(findings)}</ul>' if findings else ""
duration = row["duration_seconds"]
selection = []
if duration is not None:
selection.append(f'duration={html.escape(_display_value(_rounded_value(duration)))}s')
if row["rank"] is not None:
selection.append(f'rank={html.escape(str(row["rank"]))}')
if row["evidence_completeness"] is not None:
selection.append(f'evidence={html.escape(str(row["evidence_completeness"]))}')
rendered.append("".join((
'<article class="diagnostic">',
f'<h3>{html.escape(str(row["case_id"]))} · {html.escape(str(row["evaluator_id"]))}</h3>',
f'<p><span class="pill">{html.escape(str(row["label"]))}</span> '
f'status={html.escape(str(row["status"]))} · TestPoint={html.escape(str(row["testpoint_id"] or "—"))}</p>',
f'<p>{" · ".join(selection)}</p>' if selection else "",
f'<p>{html.escape(str(row["summary"]))}</p>',
f'<details><summary>Structured value</summary><pre>{html.escape(_json_text(row["value"]))}</pre></details>',
_metadata_html(row["metadata"]), findings_html,
f'<p><strong>All references:</strong> {_evidence_links(list(row["evidence_refs"]))}</p>',
'</article>',
)))
return "\n".join(rendered)
def _assessment_html(rows: list[dict[str, Any]]) -> str:
if not rows:
return '<p class="empty">No assessment results recorded.</p>'
body = []
for row in rows:
score = "—" if row["score"] is None else f"{float(row['score']):.1f}"
body.append(
"<tr>"
f"<td><code>{html.escape(str(row['case_id']))}</code></td>"
f"<td><code>{html.escape(str(row['evaluator_id']))}</code></td>"
f"<td>{html.escape(str(row['testpoint_id'] or '—'))}</td>"
f"<td><span class=\"result-label label-{html.escape(str(row['label']))}\">{html.escape(str(row['label']))}</span></td>"
f"<td>{html.escape(score)}</td><td>{html.escape(str(row['status']))}</td>"
f"<td>{html.escape(str(row['explanation']))}{_metadata_html(row['metadata'])}"
f"<p>Evidence: {_evidence_links(row['evidence_refs'])}</p></td>"
"</tr>"
)
return ('<div class="table-wrap" tabindex="0" role="region" aria-label="Assessment results"><table class="assessments-table">'
'<colgroup><col class="col-case"><col class="col-evaluator"><col class="col-testpoint">'
'<col class="col-label"><col class="col-score"><col class="col-status"><col></colgroup>'
'<thead><tr><th>Case</th><th>Evaluator</th><th>TestPoint</th><th>Label</th><th>Score</th><th>Status</th><th>Explanation</th></tr></thead><tbody>'
+ "".join(body) + "</tbody></table></div>")
def _metadata_html(metadata: Any) -> str:
return f'<details><summary>Metadata</summary><pre>{html.escape(_json_text(metadata))}</pre></details>'
def _backend_link(url: str | None) -> str:
"""An optional UI entrance, never an inferred evidence deep link."""
if not isinstance(url, str) or any(char.isspace() or ord(char) < 32 for char in url):
return ""
try:
parsed = urlsplit(url)
if (parsed.scheme not in {"http", "https"} or not parsed.hostname
or parsed.username is not None or parsed.password is not None):
return ""
parsed.port # Reject malformed ports as well as malformed host brackets.
except ValueError:
return ""
return f'<a class="backend-button" href="{html.escape(url, quote=True)}">Open backend UI <span aria-hidden="true">↗</span></a>'
def _publication_html(backend: Mapping[str, Any]) -> str:
metadata = backend.get("metadata") or {}
warnings = metadata.get("warnings") or []
publications = metadata.get("publications") or {}
if not warnings and not publications:
return ""
rows = "".join(
f'<li><strong>{html.escape(str(warning.get("operation", "publication")))}</strong> '
f'<span class="pill">{html.escape(str(warning.get("code", "warning")))}</span>'
f'<p>{html.escape(str(warning.get("message", "")))}</p></li>'
for warning in warnings if isinstance(warning, Mapping)
)
cards = []
for operation, stats in publications.items():
fields = stats.items() if isinstance(stats, Mapping) else [("Value", stats)]
values = ''.join(
f'<div><dt>{html.escape(str(key).replace("_", " "))}</dt>'
f'<dd>{html.escape(_display_value(value))}</dd></div>'
for key, value in fields
)
cards.append('<article class="publication-card">'
f'<h3>{html.escape(str(operation).replace("_", " "))}</h3>'
f'<dl class="publication-stats">{values}</dl></article>')
return ('<section class="publication-section"><div class="section-head"><h2>Backend publication</h2>'
'<span class="subtle">Optional result publishing · separate from evaluation scores</span></div>'
f'<div class="publication-grid">{"".join(cards)}</div>'
+ (f'<ul class="publication-warnings">{rows}</ul>' if rows else '<p class="publication-ok">No publication warnings</p>')
+ f'<details><summary>Raw publication data</summary><pre>{html.escape(_json_text(publications))}</pre></details></section>')
def _safe_task_link(value: str) -> bool:
if not isinstance(value, str) or not value or any(ord(c) < 33 for c in value) or "\\" in value:
return False
try:
parsed = urlsplit(value)
return (not parsed.scheme and not parsed.netloc and not value.startswith("/")
and not parsed.query and not parsed.fragment)
except ValueError:
return False
def render_evaluation_document(result: ReportData, *, backend_ui_url: str | None = None,
task_links: Mapping[str, str] | None = None) -> str:
"""Shared HTML view for a persisted native experiment or a local audit report."""
if not isinstance(result, ReportData):
raise TypeError("renderer requires ReportData")
measurements = _measurement_rows(result)
assessments = _assessment_rows(result)
diagnostics = _diagnostic_rows(result)
run_metadata = [getattr(run, "metadata", {}) or {} for run in result.runs]
adapter = next((item.get("adapter") for item in run_metadata if item.get("adapter")), None)
model = next((item.get("model") for item in run_metadata if item.get("model")), None)
chart_maxima = _chart_maxima(measurements)
rows_html: list[str] = []
for row in measurements:
metric = row["metric"]
value = row["value"]
status_class = _status_class(row["attribution_status"]) if row["attribution_status"] else "muted"
rows_html.append(
"<tr>"
f"<td>{html.escape(str(row['case_id']))}</td>"
f"<td>{html.escape(str(row['evaluator_id']))}</td>"
f"<td>{html.escape(str(row['stage'] or '—'))}</td>"
f"<td>{html.escape(str(metric))}</td>"
f"<td>{_measurement_value_html(value, row['unit'], chart_maxima.get(str(row['unit'] or ''), 0.0))}</td>"
f"<td>{html.escape(str(row['status']))}</td>"
f"<td class=\"{status_class}\">{html.escape(str(row['attribution_status'] or '—'))}</td>"
f"<td>{html.escape(str(row['explanation']))}{_metadata_html(row['metadata'])}"
f"<p>Evidence: {_evidence_links(row['evidence_refs'])}</p></td>"
"</tr>"
)
rows = "\n".join(rows_html) or '<tr><td colspan="8">No measurements recorded.</td></tr>'
artifact_links: list[str] = []
for run in result.runs:
link = (task_links or {}).get(run.run_id, "")
target = (f'<a href="{html.escape(link, quote=True)}">task-artifact.json</a>'
if _safe_task_link(link) else html.escape(run.run_id))
artifact_links.append(
f'<li>{html.escape(run.case_id)}: {target} '
f'({html.escape(run.status)})</li>'
)
artifact_list = "\n".join(artifact_links) or "<li>No task artifacts.</li>"
diagnostic_view = _diagnostic_html(diagnostics)
summary = result.summary()
title = html.escape(str(result.experiment_id))
backend = summary.get("backend", {})
backend_link = _backend_link(backend_ui_url)
identity = _identity_html([
("Skill", summary.get('inputs', {}).get('skill', {}).get('skill_id')),
("Dataset", summary.get('inputs', {}).get('dataset', {}).get('dataset_id')),
("Adapter", adapter), ("Agent model", model),
("Backend", backend.get("name", "unknown")),
])
document = f"""<!doctype html>
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Evaluation report {title}</title>
<style>
:root{{color-scheme:light;--ink:#172033;--muted:#64748b;--line:#e2e8f0;--panel:#fff;--wash:#f8fafc;--blue:#2563eb;--green:#15803d;--amber:#b45309;--red:#b91c1c}}
*{{box-sizing:border-box}} body{{font:14px/1.5 system-ui,sans-serif;margin:0;background:#f1f5f9;color:var(--ink)}}
main{{max-width:1800px;margin:auto;padding:2.5rem 2rem;overflow-wrap:anywhere}} h1{{font-size:2rem;margin:.1rem 0 .35rem;letter-spacing:-.035em}} h2{{margin:2rem 0 .75rem;font-size:1.2rem}}
.eyebrow{{color:var(--blue);font-weight:700;text-transform:uppercase;letter-spacing:.08em;font-size:.75rem}} .subtle,.muted{{color:var(--muted)}}
.hero,.card,.diagnostic{{background:var(--panel);border:1px solid var(--line);border-radius:14px;box-shadow:0 4px 18px #0f172a0b}}
.hero{{padding:1.5rem 1.75rem;margin-bottom:1.25rem}} .summary{{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:.8rem;margin:1.25rem 0}}
.hero-top{{display:flex;align-items:center;justify-content:space-between;gap:1rem}} .backend-button{{display:inline-flex;gap:.75rem;align-items:center;padding:.6rem .9rem;border:1px solid var(--line);border-radius:8px;color:var(--blue);text-decoration:none;font-weight:600;white-space:nowrap}}
.experiment-id{{display:flex;flex-wrap:wrap;gap:.5rem 1rem;align-items:baseline;margin:1rem 0;color:var(--muted)}} .experiment-id code{{color:var(--ink);font-size:.9rem}}
.identity-grid{{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));margin:1.25rem 0 0;border-top:1px solid var(--line);gap:1.25rem;padding-top:1.25rem}} dl dt{{color:var(--muted);font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em}} dl dd{{margin:.4rem 0 0;font-weight:600}}
.snapshot-note{{display:flex;align-items:baseline;gap:1rem;flex-wrap:wrap;margin:1.25rem 0 0;padding:.75rem 1rem;border-radius:8px;background:var(--wash);color:var(--muted);font-size:.8rem}} .snapshot-note strong{{color:var(--ink)}}
.card{{padding:1rem 1.1rem}} .card strong{{display:block;font-size:1.5rem;margin-top:.2rem}} .section-head{{display:flex;justify-content:space-between;align-items:end;gap:1rem}}
.table-wrap{{overflow:auto;background:var(--panel);border:1px solid var(--line);border-radius:12px}} table{{border-collapse:collapse;width:100%;table-layout:fixed}} .assessments-table{{min-width:1240px}} .measurements-table{{min-width:1560px}}
.col-case{{width:140px}} .col-evaluator{{width:245px}} .col-testpoint{{width:110px}} .col-label{{width:90px}} .col-score{{width:75px}} .col-status{{width:110px}} .col-metric{{width:155px}} .col-value{{width:265px}} .col-attribution{{width:150px}}
.assessments-table td:nth-child(5){{white-space:nowrap}}
th,td{{border-bottom:1px solid var(--line);padding:.7rem .8rem;text-align:left;vertical-align:top}} th{{background:var(--wash);font-size:.78rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}} tr:last-child td{{border-bottom:0}}
tbody tr:hover{{background:#f8faff}} code{{font-size:.88em}} .bar{{display:block;width:100%;max-width:220px;height:6px;background:#dbeafe;border-radius:9px;margin:.6rem 0}} .bar i{{display:block;height:100%;background:var(--blue);border-radius:9px}}
.value-head{{display:flex;align-items:baseline;gap:.45rem;flex-wrap:wrap;font-variant-numeric:tabular-nums}} .value-head strong{{font-size:1.05rem}} .unit{{font-size:.8rem;color:var(--muted)}} .value-breakdown{{display:block;margin-top:.6rem;color:var(--muted);line-height:1.6}} .exact-value{{font-size:.8rem;color:var(--muted)}}
.publication-card{{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:1rem 1.25rem}} .publication-card h3{{font-size:.95rem;text-transform:capitalize;margin:0 0 1rem}} .publication-grid{{display:grid;gap:.75rem}} .publication-stats{{display:grid;grid-template-columns:repeat(auto-fit,minmax(115px,1fr));gap:.9rem;margin:0}} .publication-stats dd{{font-size:1.35rem;font-variant-numeric:tabular-nums}} .publication-ok{{color:var(--green);font-size:.85rem}} .publication-warnings{{list-style:none;padding:1rem 1.25rem;background:#fffbeb;border:1px solid #fde68a;border-radius:10px;color:var(--amber)}} .publication-warnings p{{margin:.35rem 0}}
.unavailable,.status-unavailable{{color:var(--red);font-weight:650}} .status-exact{{color:var(--green);font-weight:650}} .status-warning{{color:var(--amber);font-weight:650}}
.result-label,.pill{{display:inline-block;padding:.16rem .5rem;border-radius:999px;font-weight:650;background:#e2e8f0}} .label-pass,.label-diagnosed{{background:#dcfce7;color:#166534}} .label-fail,.label-error{{background:#fee2e2;color:#991b1b}} .label-partial,.label-incomplete{{background:#fef3c7;color:#92400e}}
.diagnostic{{padding:1.15rem 1.35rem;margin:1rem 0;border-left:5px solid var(--blue)}} .diagnostic h3{{margin:.1rem 0 .4rem}} .diagnostic p{{margin:.4rem 0}} .finding{{margin:.75rem 0}}
.confidence{{color:var(--muted);margin-left:.5rem}} pre{{white-space:pre-wrap;background:var(--wash);padding:.8rem;border-radius:8px;max-height:260px;overflow:auto}} details{{margin-top:.7rem}}
summary{{cursor:pointer;color:var(--muted);font-size:.85rem}} summary:hover{{color:var(--blue)}} a:focus-visible,summary:focus-visible,.table-wrap:focus-visible{{outline:2px solid var(--blue);outline-offset:3px}}
.empty{{padding:1rem;background:var(--panel);border:1px dashed var(--line);border-radius:10px;color:var(--muted)}}
@media(max-width:700px){{main{{padding:1rem}} .hero{{padding:1.1rem}} .hero-top,.section-head{{align-items:start;flex-direction:column}} .identity-grid{{grid-template-columns:1fr 1fr}} .section-head .subtle{{margin-bottom:.75rem}}}}
</style></head><body>
<main><section class="hero"><div class="hero-top"><div><div class="eyebrow">Skill Evaluation</div><h1>Evaluation report</h1></div>{backend_link}</div>
<div class="experiment-id"><span>Experiment</span><code>{title}</code></div>
{identity}
<aside class="snapshot-note"><strong>Static audit snapshot</strong><span>Not synchronized with subsequent backend changes. Evidence references are text; inspect them via the backend UI when available.</span></aside></section>
<div class="summary">
<div class="card">assessment evaluations: <strong>{summary['evaluation']['assessment_count']}</strong></div>
<div class="card">measurements: <strong>{summary['evaluation']['measurement_count']}</strong></div>
<div class="card">diagnostics: <strong>{summary['evaluation']['diagnostic_count']}</strong></div>
<div class="card">pass rate: <strong>{summary['evaluation']['pass_rate']:.1%}</strong></div>
</div>
{_publication_html(backend)}
<div class="section-head"><h2>Assessments</h2><span class="subtle">Quality gates and evaluator explanations</span></div>
{_assessment_html(assessments)}
<div class="section-head"><h2>Measurements</h2><span class="subtle">Structured values; unavailable is never zero</span></div>
<p><strong>Attribution status:</strong> <span class="status-exact">exact</span> ·
<span class="status-warning">partial / batched / ambiguous</span> ·
<span class="status-unavailable">missing_explicit_event / testpoint_not_reached / boundary-unavailable / token_attributes_missing / unavailable</span></p>
<div class="table-wrap" tabindex="0" role="region" aria-label="Measurement results"><table class="measurements-table">
<colgroup><col class="col-case"><col class="col-evaluator"><col class="col-testpoint"><col class="col-metric"><col class="col-value"><col class="col-status"><col class="col-attribution"><col></colgroup>
<thead><tr><th>Case</th><th>Evaluator</th><th>TestPoint</th><th>Metric</th><th>Value</th><th>Status</th><th>Attribution</th><th>Explanation</th></tr></thead>
<tbody>{rows}</tbody></table>
</div>
<h2>Diagnostics</h2>
<p>Diagnostic results do not affect pass rate. Selection, evidence completeness, and structured findings are shown when supplied by the evaluator.</p>
{diagnostic_view}
<h2>Task artifacts</h2><ul>{artifact_list}</ul>
</main></body></html>
"""
return document
|