import Link from "next/link"; import AppShell from "@/components/shell/AppShell"; import BarForm from "@/components/bench/BarForm"; import MarkButtons from "@/components/bench/MarkButtons"; import { badgeVariants } from "@/components/ui/badge"; import { BASELINE_MODEL, VERDICTS, VERDICT_MEANINGS, VERDICT_PARTS_RULE, filterBenchRows, passesBar, readBenchRuns, readBenchView, readVerdictsPolicy, type BenchItemRow, } from "@/lib/bench"; import type { MarkedScore, ModelScore } from "yt-dlp-transcript-common/lib/report/draft/bench/index"; import type { GenerationVerdicts } from "yt-dlp-transcript-common/lib/generationSettings"; export const dynamic = "force-dynamic"; // THE VERDICT BENCH (release 28 M7): could a model propose a fact-check // verdict well enough to be worth a review? One run at a time: per model its // agreement with the operator's rulings and its CONTRADICTED and NOT_FOUND // recall beside the always-CORROBORATED baseline, its cost; the confusion // matrix; every item with each model's verdict and reason, disagreements // first. The bar (settings.generation.verdicts) is set here, and each model's // pass or fail read against it — the handoff for the verdict proposals. The // runs are local-only (`archilyzer reports bench-verdicts`); zero client JS // but the bar's form and the marks. // // Release 29 V1: the run's prompt version and items hash; "compare with" over // the runs with the same items (each model's agreement in both, the claims // whose answers changed); a Right / Wrong mark on each disagreement; the // not-CORROBORATED precision and recall beside the bar, marked and not; what // the verdicts mean (the one copy, verdicts.mjs). // // Bench v3: under each claim, what the model saw (its windows and its cited // posts and pages); under each answer, the model's parts and their findings. type Search = { run?: string; model?: string; verdict?: string; compare?: string }; const pct = (v: number | null) => (v === null ? "—" : `${Math.round(v * 1000) / 10}%`); export default async function BenchPage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const runs = await readBenchRuns(); const id = sp.run && runs.some((r) => r.id === sp.run) ? sp.run : runs[0]?.id; const view = id ? await readBenchView(id, sp.compare) : null; const sameItems = view ? runs.filter((r) => r.id !== id && r.itemsHash === view.itemsHash) : []; let policy: GenerationVerdicts | null = null; let policyError: string | null = null; try { policy = await readVerdictsPolicy(); } catch (e) { policyError = (e as Error).message; } const qs = (next: Partial) => { const p = new URLSearchParams(); for (const [k, v] of Object.entries({ ...sp, run: id, ...next })) if (v) p.set(k, String(v)); return `/tools/bench?${p.toString()}`; }; return (
{runs.length === 0 ? (

no bench runs — archilyzer reports bench-verdicts --models …

) : ( <> {!view ? (

run {id} cannot be read

) : ( )} )}
); } function RunView({ view, policy, policyError, sp, qs, sameItems, }: { view: NonNullable>>; policy: GenerationVerdicts | null; policyError: string | null; sp: Search; qs: (n: Partial) => string; sameItems: Awaited>; }) { const { summary: s, score } = view; const bar = policy?.bar ?? null; const rows = filterBenchRows(view.items, { model: sp.model, verdict: sp.verdict }); const models = sp.model ? s.models.filter((m) => m === sp.model) : s.models; return (

{s.status} · {s.items} items · {s.skipped.length} skipped {s.dropped?.length ? ` · ${s.dropped.length} citations dropped` : ""} ·{" "} {s.windowMode === "turn" ? `the speaker's turn within ${s.windowS} s` : `a ${s.windowS} s window`} ·{" "} prompt v{view.promptVersion} ·{" "} items {view.itemsHash} {s.itemsFrom ? ` (from ${s.itemsFrom})` : ""} · ${s.spentUsd.toFixed(4)} of ${s.maxUsd} ·{" "} {new Date(s.createdAt).toISOString().slice(0, 16).replace("T", " ")} UTC {s.stopped?.length ? ` · stopped: ${s.stopped.join("; ")}` : ""}

{[...score.models, score.baseline].map((m) => ( ))}
{policy ? ( ) : (

the bar cannot be read: {policyError}

)}
{score.models.map((m) => ( ))}
model {s.models.map((m) => ( ))} operator {VERDICTS.filter((v) => score.ruled[v] > 0).map((v) => ( ))}
{models.map((m) => ( ))} {rows.map((r) => ( {models.map((m) => { const a = r.answers[m]; return ( ); })} ))}
claim operator {m}
{r.key}
{r.text}
{r.verdict} {!a ? ( not asked ) : a.verdict ? ( <> {a.verdict} {a.parts && } {a.checkable === false &&
not checkable
} {a.reason &&
{a.reason}
} {a.verdict !== r.verdict && } ) : ( {a.failure}: {a.error} )}
what the verdicts mean
{VERDICTS.map((v) => (
{v}
{VERDICT_MEANINGS[v]}
))}

{VERDICT_PARTS_RULE}

{s.dropped && s.dropped.length > 0 && (
dropped {s.dropped.length}
    {s.dropped.map((d) => (
  • {d.key} {d.citation} — {d.reason}
  • ))}
)} {s.skipped.length > 0 && (
skipped {s.skipped.length}
    {s.skipped.map((k) => (
  • {k.key} — {k.reason}
  • ))}
)}
); } const stampOf = (sec: number) => { const t = Math.max(0, Math.floor(sec)); const h = Math.floor(t / 3600); const m = Math.floor((t % 3600) / 60); const ss = String(t % 60).padStart(2, "0"); return h ? `${h}:${String(m).padStart(2, "0")}:${ss}` : `${m}:${ss}`; }; // What the model saw beside the claim (bench v3): the cited posts and pages, // and each transcript window — its span, what ended it, its cues. function Seen({ row }: { row: BenchItemRow }) { return (
what the model saw · {row.windows.length} window{row.windows.length === 1 ? "" : "s"} {row.evidence.length ? ` · ${row.evidence.length} post${row.evidence.length === 1 ? "" : "s"} or page${row.evidence.length === 1 ? "" : "s"}` : ""} {row.evidence.length > 0 && (
    {row.evidence.map((e) => (
  • {[e.kind, e.label ?? e.title ?? e.channel, e.date].filter(Boolean).join(" · ")} “{e.quote}”
  • ))}
)} {row.windows.map((w) => (
{w.label ?? `${w.channel}/${w.id}`} · {stampOf(w.from)}–{stampOf(w.to)} {w.bound ? ` · ended by ${w.bound}` : ""} · {w.cues.length} lines
{w.cues.map((c) => (
[{stampOf(c.start)}] {c.text}
))}
))}
); } // The model's parts and what it found of each (bench v3: the verdict follows from them). function Parts({ parts }: { parts: NonNullable }) { return (
    {parts.map((p, i) => (
  • {p.finding} {p.part}
  • ))}
); } // "Not CORROBORATED" as the positive class — the claims a proposal would put // in front of the operator — plain and with the operator's marks applied. function Precision({ scores, marked }: { scores: ModelScore[]; marked: MarkedScore[] }) { return (
not CORROBORATED · precision / recall {scores.map((m) => { const k = marked.find((x) => x.model === m.model); return ( ); })}
model as ruled marked marks
{m.model} {pct(m.notCorroborated.precision)} / {pct(m.notCorroborated.recall)} {k ? `${pct(k.notCorroborated.precision)} / ${pct(k.notCorroborated.recall)}` : "—"} {k && k.marks.marked ? `${k.marks.right} right · ${k.marks.wrong} wrong` : "none yet"}
); } // Another run over the SAME items (the same hash): each model asked in both, // its agreement there and here, and every claim whose answer changed. function Compare({ view, sameItems, qs, current, }: { view: NonNullable>>; sameItems: Awaited>; qs: (n: Partial) => string; current?: string; }) { if (!sameItems.length) return null; const c = view.compare; return (
{c && (
{c.result.models.map((m) => ( ))}
model {c.with} (v{c.promptVersion}) this run (v{view.promptVersion}) changed
{m.model} {pct(m.a.agreement)} {pct(m.b.agreement)} {m.changed.length} · {m.fixed} now agree · {m.broke} no longer
{c.result.models.some((m) => m.changed.length) && (
    {c.result.models.flatMap((m) => m.changed.map((x) => (
  • {m.model} {x.key}: {x.a ?? "none"} → {x.b ?? "none"} (ruled {x.ruled})
  • )), )}
)}
)}
); } function ModelTile({ m, baseline, pass }: { m: ModelScore; baseline: ModelScore | null; pass: { pass: boolean; misses: string[] } | null }) { const vs = (v: number | null, b: number | null | undefined) => (baseline ? `${pct(v)} (baseline ${pct(b ?? null)})` : pct(v)); return (
{m.model} {pass && ( {pass.pass ? "passes" : "fails"} the bar )}
agreement
{vs(m.agreement, baseline?.agreement)}
with PARTLY ~ CORROBORATED
{vs(m.agreementAdjacent, baseline?.agreementAdjacent)}
CONTRADICTED recall
{vs(m.recall.CONTRADICTED.recall, baseline?.recall.CONTRADICTED.recall)} of {m.recall.CONTRADICTED.ruled}
NOT_FOUND recall
{vs(m.recall.NOT_FOUND.recall, baseline?.recall.NOT_FOUND.recall)} of {m.recall.NOT_FOUND.ruled}
PARTLY recall
{pct(m.recall.PARTLY.recall)} · adjacent {pct(m.recall.PARTLY_ADJACENT.recall)}
{baseline && ( <>
cost
${m.usd.toFixed(4)}
latency
{m.latency.medianMs === null ? "—" : `${(m.latency.medianMs / 1000).toFixed(1)} s median, ${((m.latency.p90Ms ?? 0) / 1000).toFixed(1)} s p90`}
answered
{m.answered} of {m.asked} {m.parseFailures ? ` · ${m.parseFailures} parse failures` : ""} {m.errors ? ` · ${m.errors} errors` : ""}
)}
); } function Matrix({ m }: { m: ModelScore }) { return ( ))} {VERDICTS.map((op, i) => ( {VERDICTS.map((v, j) => ( ))} ))}
{m.model} — rows: operator, columns: model
{VERDICTS.map((v) => ( {v.slice(0, 4)} none
{op} 0 ? "text-[var(--color-good)]" : m.matrix[i]![j]! > 0 ? "text-[var(--color-text)]" : "text-[var(--color-dim)]"}`} > {m.matrix[i]![j]} {m.unanswered[i]}
); } function Chip({ href, on, label }: { href: string; on: boolean; label: string }) { return ( {label} ); }