(async function () {
const EV = await (await fetch("evidence/video_evidence.json")).json();
const TAU = EV.tau, LC = EV.long_chain_24, X48 = EV.chain_48_extra, REF = EV.reference_plugin_24, CS = EV.cross_scene_6, CW = EV.cross_window_video;
const CHAIN = LC.rows.concat(X48.rows);
const REFS = {}; REF.rows.forEach(r => REFS[r.segment] = r.score);
const f3 = x => (Math.round(Number(x) * 1000 + 1e-6) / 1000).toFixed(3), f4 = x => Number(x).toFixed(4);
const $ = id => document.getElementById(id);
const css = n => getComputedStyle(document.documentElement).getPropertyValue(n).trim();
const BLUE = "var(--blue)", TEAL = "var(--teal)", GREEN = "var(--green)", REFC = "var(--ref)", GRAY = "#94a3b8";
const s = LC.summary;
const C48 = LC.rows.concat(X48.rows).map(r => r.chosen_score), m48 = C48.reduce((a, b) => a + b, 0) / C48.length;
$("heroStats").innerHTML = [[`${C48.filter(v => v >= TAU).length}/${C48.length}`, "segments above the same-person bar", "g"], [f3(m48), "mean identity over 48 segments", "b"],
[`${f3(X48.summary.quarter_means[0])} → ${f3(X48.summary.quarter_means[3])}`, "first vs last quarter of the chain: no decay", "t"], ["0", "abstentions · plugin route averages 0.552", "b"]]
.map(([n, l, c]) => `
${n}
${l}
`).join("");
// concept diagram
$("diagram").innerHTML = ``;
const H = window.RIcharts.hbar;
H($("cmpChart"), [
{ label: "Fate layer · 6 cross-scene", value: CS.summary.chosen_mean, color: BLUE },
{ label: "Fate layer · 24-seg chain", value: s.mean, color: BLUE },
{ label: "Plugin · 6 cross-scene", value: CS.summary.reference_plugin_mean, color: REFC },
{ label: "Plugin · 24-seg chain", value: REF.summary.mean, color: REFC },
{ label: "Plain short prompt", value: 0.471, color: GRAY },
{ label: "A different person", value: CS.summary.different_person, color: GRAY, muted: true }],
{ max: 0.8, tau: TAU, tauLabel: "τ 0.5", labelW: 210, w: 560 });
H($("quarterChart"), X48.summary.quarter_means.map((v, i) => ({ label: `Segments ${i * 12}–${i * 12 + 11}`, value: v, color: [BLUE, TEAL, GREEN, BLUE][i] })),
{ max: 0.8, tau: TAU, tauLabel: "τ 0.5", labelW: 150, w: 560 });
H($("supplyChart"), [
{ label: "Short fragment", value: 0.471, color: GRAY },
{ label: "Short + negatives", value: 0.419, color: GRAY },
{ label: "Detailed, reworded", value: 0.506, color: REFC },
{ label: "Detailed block", value: 0.589, color: TEAL },
{ label: "Detailed + \"never\" facts", value: 0.610, color: BLUE }],
{ max: 0.8, tau: TAU, tauLabel: "τ 0.5", labelW: 190, w: 560 });
H($("sizeChart"), [
{ label: "Generator A", value: 0.471, color: TEAL },
{ label: "Generator B (several× params)", value: 0.480, color: BLUE }],
{ max: 0.8, tau: TAU, tauLabel: "τ 0.5", labelW: 230, w: 560, rowH: 46 });
H($("videoChart"), [
{ label: "Within one take (short)", value: 0.90, color: GREEN, text: "0.90" },
{ label: "Within one take (longest)", value: 0.96, color: GREEN, text: "0.96+" },
{ label: "Next window · anchor-frame start", value: CW.anchor_frame_selected, color: BLUE },
{ label: "Next window · text only (best)", value: Math.max(...CW.text_only_takes), color: GRAY },
{ label: "Next window · text only (worst)", value: Math.min(...CW.text_only_takes), color: GRAY }],
{ max: 1, tau: TAU, tauLabel: "τ 0.5", labelW: 240, w: 560 });
const EXP = [
["24-segment chain", "12 hostile scenes × 2 seeds, 4 candidates each, same pass bar as the plugin test", `${f3(s.mean)} mean · ${f3(s.min)} min · 24/24`, "Beats the plugin route (0.552) with no reference image fed in"],
["48-segment pressure chain", "24 more segments on new seeds, same character", `${X48.summary.quarter_means.map(f3).join(" / ")}`, "No decay with length"],
["Cross-scene, 6 segments", "3 seeds × 2 scenes, enrolled studio anchor", `${f3(CS.summary.chosen_mean)} · min ${f3(CS.summary.chosen_min)} · 6/6`, "Plugin scored 0.581 on the same set"],
["Supply factorial", "short / detailed × with / without negatives, same scenes", "0.471 → 0.610", "Pinned detailed text is the main lever"],
["Model size", "same short prompt on a model with several× the parameters", "0.471 vs 0.480", "Size buys render quality, not identity"],
["Cross-window video", "second window from text only vs from the anchor frame", `${f3(Math.max(...CW.text_only_takes))} vs ${f3(CW.anchor_frame_selected)}`, "Pixel anchoring is required across windows"],
["Foreign real face", "target a face that isn't in the bible's character", "0.372 · abstained", "The gate refuses instead of passing a lookalike"]];
$("expTable").innerHTML = EXP.map(r => `
${r[0]}
${r[1]}
${r[2]}
${r[3]}
`).join("");
// 48-seg line chart
const W = 960, Hh = 330, L = 48, R = 16, T = 14, B = 36, y0 = 0.3, y1 = 0.8, n = CHAIN.length;
const X = i => L + (W - L - R) * i / (n - 1), Y = v => T + (Hh - T - B) * (1 - (v - y0) / (y1 - y0));
let g = "";
for (let v = 0.3; v <= 0.801; v += 0.1) g += `${v.toFixed(1)}`;
for (let i = 0; i < n; i += 6) g += `${CHAIN[i].segment}`;
g += ``;
const path = pts => pts.map((p, k) => (k ? "L" : "M") + p[0].toFixed(1) + " " + p[1].toFixed(1)).join(" ");
const refPts = CHAIN.map((r, i) => r.segment in REFS ? [X(i), Y(REFS[r.segment])] : null).filter(Boolean);
g += ``;
g += ``;
CHAIN.forEach((r, i) => g += `Segment ${r.segment} · ${r.scene}: ${f4(r.chosen_score)}`);
g += ``;
$("chart").innerHTML = g;
const seg = $("seg"); seg.max = n - 1;
function show(i) {
const r = CHAIN[i], best = Math.max(...r.pool_scores);
const v = r.abstained ? `ABSTAINED · flagged for regeneration` : r.chosen_score >= TAU ? `ACCEPTED` : `BELOW τ`;
let h = `
Segment ${r.segment} of ${n} · scene ${r.scene} · seed ${r.seed}
${f4(r.chosen_score)}
chosen identity score (τ = ${TAU})
Verdict: ${v}
`;
if (r.segment in REFS) h += `
Same segment with the reference-image plugin: ${f4(REFS[r.segment])}