Evidence pooling honesty: scenario tagging, replay dedupe everywhere, timesTrusted
Browse files- Scenario auto-runs archive tagged (RunRecord.scenario, threaded
scenario key through pendingRestore -> pendingAutoRun ->
runPipeline -> buildRunRecord; preserved across archive import).
Scripted figure states are excluded from the theater's
prior-evidence pool and from the F7 overlay picker, so repeated F0
boots can no longer pollute the archive into a fake replicate group
or distort the evidence the figures claim to show (documented in
scenarios.ts).
- dedupeDraws ("exact replays counted once") now applies to EVERY
undisclosed pooling surface: theater archive band, fidelity-card
replicate strip, multiverse pooled band + pooled line, and the
lineage certainty funnel (seen-seed skip, same rule). Labels and
tooltips updated to say so; stats.ts's known-looseness note replaced
by the uniform truth.
- timesTrusted: a displayed run with no run_id is trusted only WHILE
streaming — a restored / cache-served run must not inherit the
previous run's seed chip, config hash, or wall-times.
- frontend/src/components/EvidenceTheater.tsx +31 -15
- frontend/src/components/FlowCanvas.tsx +17 -7
- frontend/src/components/MultiverseBoard.tsx +16 -6
- frontend/src/components/RunHistory.tsx +12 -3
- frontend/src/components/results/cards.tsx +17 -6
- frontend/src/lib/runStore.ts +10 -0
- frontend/src/lib/scenarios.ts +11 -1
- frontend/src/lib/stats.ts +6 -5
- frontend/src/lib/store.ts +10 -2
|
@@ -93,7 +93,8 @@ import { getRun, listRunsByConfig, type RunRecord } from "../lib/runStore";
|
|
| 93 |
import {
|
| 94 |
poolEvidence,
|
| 95 |
runEvidence,
|
| 96 |
-
|
|
|
|
| 97 |
type PooledEvidence,
|
| 98 |
} from "../lib/stats";
|
| 99 |
import { hashHue, hueCss } from "../lib/hues";
|
|
@@ -523,7 +524,7 @@ function Panel({
|
|
| 523 |
<tspan x={W - M.r + 10} dy={12}>
|
| 524 |
over {fmtShots(pool.shots)} shots from {poolRuns} run{poolRuns === 1 ? "" : "s"}
|
| 525 |
</tspan>
|
| 526 |
-
<title>Evidence this exact configuration already accumulated in your run archive (pooled Wilson interval over all archived shots — valid because replicates of one configuration share the same underlying probability). The streaming run adds to this.</title>
|
| 527 |
</text>
|
| 528 |
</g>
|
| 529 |
)}
|
|
@@ -1019,11 +1020,14 @@ export function EvidenceTheater() {
|
|
| 1019 |
const [autoOpenPref, setAutoOpenPref] = useState(theaterAutoOpenEnabled());
|
| 1020 |
|
| 1021 |
// Do the displayed run and the retained traces describe the same
|
| 1022 |
-
// run? While streaming the partial RunResponse has no run_id yet
|
| 1023 |
-
//
|
| 1024 |
-
//
|
|
|
|
|
|
|
| 1025 |
const timesTrusted =
|
| 1026 |
-
theaterRun != null &&
|
|
|
|
| 1027 |
|
| 1028 |
const series = useMemo(() => {
|
| 1029 |
const out: Series[] = [];
|
|
@@ -1134,15 +1138,27 @@ export function EvidenceTheater() {
|
|
| 1134 |
listRunsByConfig(ch)
|
| 1135 |
.then((rs) => {
|
| 1136 |
if (cancelled) return;
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
| 1140 |
-
|
| 1141 |
-
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1146 |
const p = evs.length > 0 ? poolEvidence(evs) : null;
|
| 1147 |
setPool(p ? { p, n: evs.length } : null);
|
| 1148 |
})
|
|
|
|
| 93 |
import {
|
| 94 |
poolEvidence,
|
| 95 |
runEvidence,
|
| 96 |
+
dedupeDraws,
|
| 97 |
+
type DatedEvidence,
|
| 98 |
type PooledEvidence,
|
| 99 |
} from "../lib/stats";
|
| 100 |
import { hashHue, hueCss } from "../lib/hues";
|
|
|
|
| 524 |
<tspan x={W - M.r + 10} dy={12}>
|
| 525 |
over {fmtShots(pool.shots)} shots from {poolRuns} run{poolRuns === 1 ? "" : "s"}
|
| 526 |
</tspan>
|
| 527 |
+
<title>Evidence this exact configuration already accumulated in your run archive (pooled Wilson interval over all archived shots — valid because replicates of one configuration share the same underlying probability). Exact replays are counted once; scenario-boot runs are excluded. The streaming run adds to this.</title>
|
| 528 |
</text>
|
| 529 |
</g>
|
| 530 |
)}
|
|
|
|
| 1020 |
const [autoOpenPref, setAutoOpenPref] = useState(theaterAutoOpenEnabled());
|
| 1021 |
|
| 1022 |
// Do the displayed run and the retained traces describe the same
|
| 1023 |
+
// run? While streaming the partial RunResponse has no run_id yet —
|
| 1024 |
+
// that is the ONLY case an id-less run is trustworthy; once finished
|
| 1025 |
+
// it must match the run_meta the stream announced. A restored or
|
| 1026 |
+
// cache-served run without an id must NOT inherit the previous run's
|
| 1027 |
+
// seed / config chips / wall-times.
|
| 1028 |
const timesTrusted =
|
| 1029 |
+
theaterRun != null &&
|
| 1030 |
+
(run?.run_id == null ? running : run.run_id === theaterRun.runId);
|
| 1031 |
|
| 1032 |
const series = useMemo(() => {
|
| 1033 |
const out: Series[] = [];
|
|
|
|
| 1138 |
listRunsByConfig(ch)
|
| 1139 |
.then((rs) => {
|
| 1140 |
if (cancelled) return;
|
| 1141 |
+
// Honest pool: scenario-boot records are scripted figure
|
| 1142 |
+
// states, not prior evidence, and exact replays are counted
|
| 1143 |
+
// once (dedupeDraws — the same rule the difference funnel
|
| 1144 |
+
// applies).
|
| 1145 |
+
const evs = dedupeDraws(
|
| 1146 |
+
rs
|
| 1147 |
+
.filter(
|
| 1148 |
+
(r) =>
|
| 1149 |
+
r.ok &&
|
| 1150 |
+
r.scenario == null &&
|
| 1151 |
+
r.created_at < (theaterRun?.startedAt ?? 0) &&
|
| 1152 |
+
r.run_id !== theaterRun?.runId,
|
| 1153 |
+
)
|
| 1154 |
+
.map((r): DatedEvidence | null => {
|
| 1155 |
+
const ev = runEvidence(r.response);
|
| 1156 |
+
return ev
|
| 1157 |
+
? { ...ev, created_at: r.created_at, root_seed: r.root_seed }
|
| 1158 |
+
: null;
|
| 1159 |
+
})
|
| 1160 |
+
.filter((e): e is DatedEvidence => e != null),
|
| 1161 |
+
);
|
| 1162 |
const p = evs.length > 0 ? poolEvidence(evs) : null;
|
| 1163 |
setPool(p ? { p, n: evs.length } : null);
|
| 1164 |
})
|
|
@@ -983,6 +983,7 @@ export function FlowCanvas() {
|
|
| 983 |
precisionTarget: restoredTarget,
|
| 984 |
autoRunAfter,
|
| 985 |
replicateOnce,
|
|
|
|
| 986 |
} = pendingRestore;
|
| 987 |
useApp.getState().clearRestore();
|
| 988 |
|
|
@@ -1058,10 +1059,10 @@ export function FlowCanvas() {
|
|
| 1058 |
// Scenario boot: the graph is on the canvas and the right
|
| 1059 |
// circuit is loaded — NOW it is safe to request the auto
|
| 1060 |
// run (see the pendingAutoRun consumer below).
|
| 1061 |
-
useApp.getState().requestAutoRun(
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
);
|
| 1065 |
return;
|
| 1066 |
}
|
| 1067 |
setNotice({
|
|
@@ -1087,7 +1088,10 @@ export function FlowCanvas() {
|
|
| 1087 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 1088 |
}, [pendingRestore]);
|
| 1089 |
|
| 1090 |
-
const runPipeline = async (opts?: {
|
|
|
|
|
|
|
|
|
|
| 1091 |
if (!circuit) {
|
| 1092 |
// Open the left pane so the user can see where to pick a circuit.
|
| 1093 |
useApp.getState().bumpHintExpandLeftPane();
|
|
@@ -1193,6 +1197,9 @@ export function FlowCanvas() {
|
|
| 1193 |
useLiveIbm,
|
| 1194 |
forkedFrom: useApp.getState().restoredFrom,
|
| 1195 |
precisionTarget: useApp.getState().precisionTarget,
|
|
|
|
|
|
|
|
|
|
| 1196 |
});
|
| 1197 |
await saveRun(record);
|
| 1198 |
// forked_from is a one-shot claim: only the FIRST run archived
|
|
@@ -1276,9 +1283,12 @@ export function FlowCanvas() {
|
|
| 1276 |
)
|
| 1277 |
return;
|
| 1278 |
autoRunFiredRef.current = true;
|
| 1279 |
-
const { replicateOnce } = pendingAutoRun;
|
| 1280 |
useApp.getState().clearAutoRun();
|
| 1281 |
-
void runPipeline(
|
|
|
|
|
|
|
|
|
|
| 1282 |
// eslint-disable-next-line react-hooks/exhaustive-deps -- runPipeline is stable-enough (reads live state via closures/store)
|
| 1283 |
}, [pendingAutoRun, circuit, sampleKey, nodes, running]);
|
| 1284 |
|
|
|
|
| 983 |
precisionTarget: restoredTarget,
|
| 984 |
autoRunAfter,
|
| 985 |
replicateOnce,
|
| 986 |
+
scenario,
|
| 987 |
} = pendingRestore;
|
| 988 |
useApp.getState().clearRestore();
|
| 989 |
|
|
|
|
| 1059 |
// Scenario boot: the graph is on the canvas and the right
|
| 1060 |
// circuit is loaded — NOW it is safe to request the auto
|
| 1061 |
// run (see the pendingAutoRun consumer below).
|
| 1062 |
+
useApp.getState().requestAutoRun(sk, {
|
| 1063 |
+
...(replicateOnce != null ? { replicateOnce } : {}),
|
| 1064 |
+
...(scenario != null ? { scenario } : {}),
|
| 1065 |
+
});
|
| 1066 |
return;
|
| 1067 |
}
|
| 1068 |
setNotice({
|
|
|
|
| 1088 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 1089 |
}, [pendingRestore]);
|
| 1090 |
|
| 1091 |
+
const runPipeline = async (opts?: {
|
| 1092 |
+
replicateOnce?: number;
|
| 1093 |
+
scenario?: string;
|
| 1094 |
+
}) => {
|
| 1095 |
if (!circuit) {
|
| 1096 |
// Open the left pane so the user can see where to pick a circuit.
|
| 1097 |
useApp.getState().bumpHintExpandLeftPane();
|
|
|
|
| 1197 |
useLiveIbm,
|
| 1198 |
forkedFrom: useApp.getState().restoredFrom,
|
| 1199 |
precisionTarget: useApp.getState().precisionTarget,
|
| 1200 |
+
// Scenario boots archive tagged: a scripted figure state
|
| 1201 |
+
// must never pool with (or be picked as) user evidence.
|
| 1202 |
+
scenario: opts?.scenario ?? null,
|
| 1203 |
});
|
| 1204 |
await saveRun(record);
|
| 1205 |
// forked_from is a one-shot claim: only the FIRST run archived
|
|
|
|
| 1283 |
)
|
| 1284 |
return;
|
| 1285 |
autoRunFiredRef.current = true;
|
| 1286 |
+
const { replicateOnce, scenario } = pendingAutoRun;
|
| 1287 |
useApp.getState().clearAutoRun();
|
| 1288 |
+
void runPipeline({
|
| 1289 |
+
...(replicateOnce != null ? { replicateOnce } : {}),
|
| 1290 |
+
...(scenario != null ? { scenario } : {}),
|
| 1291 |
+
});
|
| 1292 |
// eslint-disable-next-line react-hooks/exhaustive-deps -- runPipeline is stable-enough (reads live state via closures/store)
|
| 1293 |
}, [pendingAutoRun, circuit, sampleKey, nodes, running]);
|
| 1294 |
|
|
@@ -68,7 +68,8 @@ import {
|
|
| 68 |
POOLED_SMALL_N_SHOTS,
|
| 69 |
poolEvidence,
|
| 70 |
runEvidence,
|
| 71 |
-
|
|
|
|
| 72 |
type PooledEvidence,
|
| 73 |
} from "../lib/stats";
|
| 74 |
import { WorkspaceToggle } from "./WorkspaceToggle";
|
|
@@ -126,9 +127,18 @@ function buildGroups(runs: RunRecord[]): ConfigGroup[] {
|
|
| 126 |
const values = oks
|
| 127 |
.filter((r) => r.headline_value != null)
|
| 128 |
.map((r) => Math.min(1, Math.max(0, r.headline_value as number)));
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
groups.push({
|
| 133 |
hash,
|
| 134 |
hue: hashHue(hash),
|
|
@@ -380,7 +390,7 @@ function OutcomeStrip({
|
|
| 380 |
stroke={hueCss(hue, 0.6)}
|
| 381 |
strokeWidth={0.75}
|
| 382 |
>
|
| 383 |
-
<title>{`pooled 95% interval: ${(pooled.ci95[0] * 100).toFixed(1)}–${(pooled.ci95[1] * 100).toFixed(1)}% (${pooled.successes}/${pooled.shots} pooled counts over ${pooled.nRuns} runs)`}</title>
|
| 384 |
</rect>
|
| 385 |
)}
|
| 386 |
<line x1={X0} x2={X1} y1={H / 2} y2={H / 2} stroke="rgb(var(--color-edge))" strokeWidth={1} />
|
|
@@ -558,7 +568,7 @@ function PooledLine({ pooled, hue }: { pooled: PooledEvidence; hue: number }) {
|
|
| 558 |
stroke={hueCss(hue, 0.7)}
|
| 559 |
strokeWidth={0.75}
|
| 560 |
>
|
| 561 |
-
<title>{`pooled 95% interval: ${(pooled.ci95[0] * 100).toFixed(1)}–${(pooled.ci95[1] * 100).toFixed(1)}% (${pooled.successes}/${pooled.shots} counts over ${pooled.nRuns} runs)`}</title>
|
| 562 |
</rect>
|
| 563 |
<line
|
| 564 |
x1={px(pooled.point)}
|
|
|
|
| 68 |
POOLED_SMALL_N_SHOTS,
|
| 69 |
poolEvidence,
|
| 70 |
runEvidence,
|
| 71 |
+
dedupeDraws,
|
| 72 |
+
type DatedEvidence,
|
| 73 |
type PooledEvidence,
|
| 74 |
} from "../lib/stats";
|
| 75 |
import { WorkspaceToggle } from "./WorkspaceToggle";
|
|
|
|
| 127 |
const values = oks
|
| 128 |
.filter((r) => r.headline_value != null)
|
| 129 |
.map((r) => Math.min(1, Math.max(0, r.headline_value as number)));
|
| 130 |
+
// Exact replays counted once (dedupeDraws): pooling a pinned
|
| 131 |
+
// replay twice would narrow the band with no new evidence.
|
| 132 |
+
const evs = dedupeDraws(
|
| 133 |
+
oks
|
| 134 |
+
.map((r): DatedEvidence | null => {
|
| 135 |
+
const ev = runEvidence(r.response);
|
| 136 |
+
return ev
|
| 137 |
+
? { ...ev, created_at: r.created_at, root_seed: r.root_seed }
|
| 138 |
+
: null;
|
| 139 |
+
})
|
| 140 |
+
.filter((e): e is DatedEvidence => e != null),
|
| 141 |
+
);
|
| 142 |
groups.push({
|
| 143 |
hash,
|
| 144 |
hue: hashHue(hash),
|
|
|
|
| 390 |
stroke={hueCss(hue, 0.6)}
|
| 391 |
strokeWidth={0.75}
|
| 392 |
>
|
| 393 |
+
<title>{`pooled 95% interval: ${(pooled.ci95[0] * 100).toFixed(1)}–${(pooled.ci95[1] * 100).toFixed(1)}% (${pooled.successes}/${pooled.shots} pooled counts over ${pooled.nRuns} runs; exact replays counted once)`}</title>
|
| 394 |
</rect>
|
| 395 |
)}
|
| 396 |
<line x1={X0} x2={X1} y1={H / 2} y2={H / 2} stroke="rgb(var(--color-edge))" strokeWidth={1} />
|
|
|
|
| 568 |
stroke={hueCss(hue, 0.7)}
|
| 569 |
strokeWidth={0.75}
|
| 570 |
>
|
| 571 |
+
<title>{`pooled 95% interval: ${(pooled.ci95[0] * 100).toFixed(1)}–${(pooled.ci95[1] * 100).toFixed(1)}% (${pooled.successes}/${pooled.shots} counts over ${pooled.nRuns} runs; exact replays counted once)`}</title>
|
| 572 |
</rect>
|
| 573 |
<line
|
| 574 |
x1={px(pooled.point)}
|
|
@@ -248,9 +248,18 @@ function computeLayout(records: RunRecord[]): Layout {
|
|
| 248 |
let cSucc = 0;
|
| 249 |
let cShots = 0;
|
| 250 |
let cRuns = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
for (let i = sec.length - 1; i >= 0; i--) {
|
| 252 |
-
const
|
|
|
|
| 253 |
if (!ev) continue; // non-binomial runs neither widen nor narrow the pool
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
cSucc += ev.successes;
|
| 255 |
cShots += ev.shots;
|
| 256 |
cRuns += 1;
|
|
@@ -517,7 +526,7 @@ function LineageLegend() {
|
|
| 517 |
</KeyItem>
|
| 518 |
<KeyItem
|
| 519 |
label="band = replicates"
|
| 520 |
-
hint="A translucent band + spine groups a contiguous block of replicate runs of one configuration (what the xN runner produces). The two thin lines flaring around a band are its certainty funnel: the pooled 95% CI half-width narrowing as replicates accumulate -- scaled per group, so compare funnel widths within a band, not across bands."
|
| 521 |
>
|
| 522 |
<rect x={1} y={2.5} width={22} height={9} rx={4.5} fill={ACC} fillOpacity={0.15} />
|
| 523 |
<line x1={5} y1={7} x2={19} y2={7} stroke={ACC} strokeOpacity={0.4} strokeWidth={1.5} />
|
|
@@ -942,7 +951,7 @@ export function RunHistory({ embedded = false }: { embedded?: boolean } = {}) {
|
|
| 942 |
style={{ pointerEvents: "auto" }}
|
| 943 |
>
|
| 944 |
<title>
|
| 945 |
-
{`pooled ±${(newest.hw * 100).toFixed(1)}pp after ${newest.nRuns} runs / ${newest.shots} shots
|
| 946 |
cumulative Wilson CI half-width of this configuration's pooled counts, widest (oldest) row scaled to ${FUNNEL_MAX_PX}px — the funnel narrowing upward is certainty accumulating across replicate runs (same motif as the fidelity card's funnel, where shot batches accumulate inside one run)`}
|
| 947 |
</title>
|
| 948 |
</polygon>
|
|
|
|
| 248 |
let cSucc = 0;
|
| 249 |
let cShots = 0;
|
| 250 |
let cRuns = 0;
|
| 251 |
+
// Exact replays counted once (same rule as stats.dedupeDraws):
|
| 252 |
+
// a pinned replay repeats its ancestor's draw bit-exactly, so
|
| 253 |
+
// pooling it again would narrow the funnel with no new evidence.
|
| 254 |
+
const seenSeeds = new Set<number>();
|
| 255 |
for (let i = sec.length - 1; i >= 0; i--) {
|
| 256 |
+
const rec = sec[i];
|
| 257 |
+
const ev = evidence.get(rec.run_id);
|
| 258 |
if (!ev) continue; // non-binomial runs neither widen nor narrow the pool
|
| 259 |
+
if (rec.root_seed != null) {
|
| 260 |
+
if (seenSeeds.has(rec.root_seed)) continue;
|
| 261 |
+
seenSeeds.add(rec.root_seed);
|
| 262 |
+
}
|
| 263 |
cSucc += ev.successes;
|
| 264 |
cShots += ev.shots;
|
| 265 |
cRuns += 1;
|
|
|
|
| 526 |
</KeyItem>
|
| 527 |
<KeyItem
|
| 528 |
label="band = replicates"
|
| 529 |
+
hint="A translucent band + spine groups a contiguous block of replicate runs of one configuration (what the xN runner produces). The two thin lines flaring around a band are its certainty funnel: the pooled 95% CI half-width narrowing as replicates accumulate (exact replays counted once) -- scaled per group, so compare funnel widths within a band, not across bands."
|
| 530 |
>
|
| 531 |
<rect x={1} y={2.5} width={22} height={9} rx={4.5} fill={ACC} fillOpacity={0.15} />
|
| 532 |
<line x1={5} y1={7} x2={19} y2={7} stroke={ACC} strokeOpacity={0.4} strokeWidth={1.5} />
|
|
|
|
| 951 |
style={{ pointerEvents: "auto" }}
|
| 952 |
>
|
| 953 |
<title>
|
| 954 |
+
{`pooled ±${(newest.hw * 100).toFixed(1)}pp after ${newest.nRuns} runs / ${newest.shots} shots (exact replays counted once)
|
| 955 |
cumulative Wilson CI half-width of this configuration's pooled counts, widest (oldest) row scaled to ${FUNNEL_MAX_PX}px — the funnel narrowing upward is certainty accumulating across replicate runs (same motif as the fidelity card's funnel, where shot batches accumulate inside one run)`}
|
| 956 |
</title>
|
| 957 |
</polygon>
|
|
@@ -14,7 +14,8 @@ import { GLOSSARY } from "../../lib/glossary";
|
|
| 14 |
import {
|
| 15 |
poolEvidence,
|
| 16 |
runEvidence,
|
| 17 |
-
|
|
|
|
| 18 |
type PooledEvidence,
|
| 19 |
} from "../../lib/stats";
|
| 20 |
import {
|
|
@@ -599,10 +600,20 @@ function ReplicateStrip({ currentPoint }: { currentPoint: number }) {
|
|
| 599 |
// valid within one configuration (same underlying p; see
|
| 600 |
// lib/stats.ts) — so the across-runs answer carries a real
|
| 601 |
// interval, not just a scatter of points.
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 606 |
setPooled(evs.length >= 2 ? poolEvidence(evs) : null);
|
| 607 |
})
|
| 608 |
.catch(() => {});
|
|
@@ -635,7 +646,7 @@ function ReplicateStrip({ currentPoint }: { currentPoint: number }) {
|
|
| 635 |
{pooled && (
|
| 636 |
<div
|
| 637 |
className="text-[10px] text-mute tabular-nums"
|
| 638 |
-
title={`All ${pooled.nRuns} archived replicates' measurement counts pooled (${pooled.successes}/${pooled.shots}), one Wilson interval over the pooled counts — same math as the Evidence-board card's pooled band.`}
|
| 639 |
>
|
| 640 |
pooled μ {(pooled.point * 100).toFixed(1)}% ±
|
| 641 |
{(pooled.halfWidth * 100).toFixed(1)}pp over {pooled.shots} shots (
|
|
|
|
| 14 |
import {
|
| 15 |
poolEvidence,
|
| 16 |
runEvidence,
|
| 17 |
+
dedupeDraws,
|
| 18 |
+
type DatedEvidence,
|
| 19 |
type PooledEvidence,
|
| 20 |
} from "../../lib/stats";
|
| 21 |
import {
|
|
|
|
| 600 |
// valid within one configuration (same underlying p; see
|
| 601 |
// lib/stats.ts) — so the across-runs answer carries a real
|
| 602 |
// interval, not just a scatter of points.
|
| 603 |
+
// Exact replays counted once (dedupeDraws): a pinned replay
|
| 604 |
+
// repeats its ancestor's draw bit-exactly, so pooling it again
|
| 605 |
+
// would narrow the interval with no new evidence.
|
| 606 |
+
const evs = dedupeDraws(
|
| 607 |
+
rs
|
| 608 |
+
.filter((r) => r.ok)
|
| 609 |
+
.map((r): DatedEvidence | null => {
|
| 610 |
+
const ev = runEvidence(r.response);
|
| 611 |
+
return ev
|
| 612 |
+
? { ...ev, created_at: r.created_at, root_seed: r.root_seed }
|
| 613 |
+
: null;
|
| 614 |
+
})
|
| 615 |
+
.filter((e): e is DatedEvidence => e != null),
|
| 616 |
+
);
|
| 617 |
setPooled(evs.length >= 2 ? poolEvidence(evs) : null);
|
| 618 |
})
|
| 619 |
.catch(() => {});
|
|
|
|
| 646 |
{pooled && (
|
| 647 |
<div
|
| 648 |
className="text-[10px] text-mute tabular-nums"
|
| 649 |
+
title={`All ${pooled.nRuns} archived replicates' measurement counts pooled (${pooled.successes}/${pooled.shots}), one Wilson interval over the pooled counts — same math as the Evidence-board card's pooled band. Exact replays (same pinned seed) are counted once.`}
|
| 650 |
>
|
| 651 |
pooled μ {(pooled.point * 100).toFixed(1)}% ±
|
| 652 |
{(pooled.halfWidth * 100).toFixed(1)}pp over {pooled.shots} shots (
|
|
@@ -46,6 +46,12 @@ export interface RunRecord {
|
|
| 46 |
* archive (real seeded runs recorded against the live backend).
|
| 47 |
* Lets the UI label them honestly and clear them in one click. */
|
| 48 |
demo?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
/** Optional-stopping target the run was executed with (absolute
|
| 50 |
* fidelity units), or null/absent. Part of provenance: replay
|
| 51 |
* must re-send it or an early-stopped run is not reproducible. */
|
|
@@ -265,6 +271,8 @@ export function buildRunRecord(args: {
|
|
| 265 |
forkedFrom: string | null;
|
| 266 |
/** Optional-stopping target the request was sent with. */
|
| 267 |
precisionTarget?: number | null;
|
|
|
|
|
|
|
| 268 |
}): RunRecord {
|
| 269 |
const { response } = args;
|
| 270 |
const headline = extractHeadline(response.steps);
|
|
@@ -297,6 +305,7 @@ export function buildRunRecord(args: {
|
|
| 297 |
args.useLiveIbm,
|
| 298 |
),
|
| 299 |
forked_from: args.forkedFrom,
|
|
|
|
| 300 |
precision_target: args.precisionTarget ?? null,
|
| 301 |
stopped_early: stoppedEarly,
|
| 302 |
ok: response.ok,
|
|
@@ -437,6 +446,7 @@ export async function importArchive(file: File): Promise<ImportReport> {
|
|
| 437 |
typeof entry.precision_target === "number"
|
| 438 |
? entry.precision_target
|
| 439 |
: null,
|
|
|
|
| 440 |
});
|
| 441 |
// Preserved verbatim: the original archive timestamp (the lineage
|
| 442 |
// layout orders by it) and the demo honesty flag.
|
|
|
|
| 46 |
* archive (real seeded runs recorded against the live backend).
|
| 47 |
* Lets the UI label them honestly and clear them in one click. */
|
| 48 |
demo?: boolean;
|
| 49 |
+
/** Scenario key ("F0".."F8") when this run was executed by a
|
| 50 |
+
* scenario boot's auto-run — a scripted figure state, not user
|
| 51 |
+
* evidence. Scenario-tagged records are excluded from the theater's
|
| 52 |
+
* prior-evidence pool and the F7 overlay picker (lib/scenarios.ts
|
| 53 |
+
* documents the pollution this prevents). */
|
| 54 |
+
scenario?: string | null;
|
| 55 |
/** Optional-stopping target the run was executed with (absolute
|
| 56 |
* fidelity units), or null/absent. Part of provenance: replay
|
| 57 |
* must re-send it or an early-stopped run is not reproducible. */
|
|
|
|
| 271 |
forkedFrom: string | null;
|
| 272 |
/** Optional-stopping target the request was sent with. */
|
| 273 |
precisionTarget?: number | null;
|
| 274 |
+
/** Scenario key when this run is a scenario boot's auto-run. */
|
| 275 |
+
scenario?: string | null;
|
| 276 |
}): RunRecord {
|
| 277 |
const { response } = args;
|
| 278 |
const headline = extractHeadline(response.steps);
|
|
|
|
| 305 |
args.useLiveIbm,
|
| 306 |
),
|
| 307 |
forked_from: args.forkedFrom,
|
| 308 |
+
scenario: args.scenario ?? null,
|
| 309 |
precision_target: args.precisionTarget ?? null,
|
| 310 |
stopped_early: stoppedEarly,
|
| 311 |
ok: response.ok,
|
|
|
|
| 446 |
typeof entry.precision_target === "number"
|
| 447 |
? entry.precision_target
|
| 448 |
: null,
|
| 449 |
+
scenario: typeof entry.scenario === "string" ? entry.scenario : null,
|
| 450 |
});
|
| 451 |
// Preserved verbatim: the original archive timestamp (the lineage
|
| 452 |
// layout orders by it) and the demo honesty flag.
|
|
@@ -419,7 +419,9 @@ async function pickOverlayPairRunIds(): Promise<string[]> {
|
|
| 419 |
};
|
| 420 |
const byHash = new Map<string, Array<{ r: (typeof runs)[number]; req: number }>>();
|
| 421 |
for (const r of runs) {
|
| 422 |
-
|
|
|
|
|
|
|
| 423 |
const req = tracedBudget(r);
|
| 424 |
if (req === 0) continue;
|
| 425 |
const arr = byHash.get(r.config_hash) ?? [];
|
|
@@ -467,6 +469,14 @@ export async function activateScenario(rawKey: string): Promise<boolean> {
|
|
| 467 |
sourceRunId: null, // scenario boot is not a fork of an archived run
|
| 468 |
precisionTarget: sc.precisionTarget ?? null,
|
| 469 |
autoRunAfter: sc.autoRun === true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 470 |
});
|
| 471 |
}
|
| 472 |
|
|
|
|
| 419 |
};
|
| 420 |
const byHash = new Map<string, Array<{ r: (typeof runs)[number]; req: number }>>();
|
| 421 |
for (const r of runs) {
|
| 422 |
+
// Scenario-boot records are scripted figure states, not evidence —
|
| 423 |
+
// never let an accumulated F0 group hijack the F7 pair.
|
| 424 |
+
if (!r.ok || r.scenario != null) continue;
|
| 425 |
const req = tracedBudget(r);
|
| 426 |
if (req === 0) continue;
|
| 427 |
const arr = byHash.get(r.config_hash) ?? [];
|
|
|
|
| 469 |
sourceRunId: null, // scenario boot is not a fork of an archived run
|
| 470 |
precisionTarget: sc.precisionTarget ?? null,
|
| 471 |
autoRunAfter: sc.autoRun === true,
|
| 472 |
+
// Archive pollution guard: every scenario auto-run archives a
|
| 473 |
+
// RunRecord like any run (each F0 boot adds one bell-state
|
| 474 |
+
// record). Tagging it RunRecord.scenario keeps scripted figure
|
| 475 |
+
// states out of the theater's prior-evidence pool and out of
|
| 476 |
+
// pickOverlayPairRunIds below — otherwise repeated F0 boots
|
| 477 |
+
// would accumulate into a fake "replicate" group and distort
|
| 478 |
+
// (or hijack) the evidence the figures claim to show.
|
| 479 |
+
...(sc.autoRun === true ? { scenario: sc.key } : {}),
|
| 480 |
});
|
| 481 |
}
|
| 482 |
|
|
@@ -192,11 +192,12 @@ export interface DatedEvidence extends Evidence {
|
|
| 192 |
* bundled demo archive contains exactly this case: bell-512 run
|
| 193 |
* 7e401b5270b9 replays f0cb7403bbae, seed 815033775, 247/512 twice).
|
| 194 |
* Runs with unknown seeds are never deduped — there is no proof they
|
| 195 |
-
* repeat a draw.
|
| 196 |
-
*
|
| 197 |
-
*
|
| 198 |
-
*
|
| 199 |
-
*
|
|
|
|
| 200 |
export function dedupeDraws<T extends DatedEvidence>(runs: T[]): T[] {
|
| 201 |
const sorted = [...runs].sort((a, b) => a.created_at - b.created_at);
|
| 202 |
const seen = new Set<number>();
|
|
|
|
| 192 |
* bundled demo archive contains exactly this case: bell-512 run
|
| 193 |
* 7e401b5270b9 replays f0cb7403bbae, seed 815033775, 247/512 twice).
|
| 194 |
* Runs with unknown seeds are never deduped — there is no proof they
|
| 195 |
+
* repeat a draw. Since the 2026-07-10 audit wave, EVERY pooling
|
| 196 |
+
* surface applies this rule — difference funnel, theater archive
|
| 197 |
+
* band, multiverse pooled band/line, fidelity-card replicate strip,
|
| 198 |
+
* lineage certainty funnel — and their labels say "exact replays
|
| 199 |
+
* counted once" (uniform truth documented in
|
| 200 |
+
* docs/EVIDENCE_WORKBENCH.md). */
|
| 201 |
export function dedupeDraws<T extends DatedEvidence>(runs: T[]): T[] {
|
| 202 |
const sorted = [...runs].sort((a, b) => a.created_at - b.created_at);
|
| 203 |
const seen = new Set<number>();
|
|
@@ -233,6 +233,10 @@ interface AppState {
|
|
| 233 |
* quick action "+3 replicates"). Consumed by that single run
|
| 234 |
* only — never written into the global toolbar replicateCount. */
|
| 235 |
replicateOnce?: number;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
} | null;
|
| 237 |
requestRestore: (r: NonNullable<AppState["pendingRestore"]>) => void;
|
| 238 |
clearRestore: () => void;
|
|
@@ -338,10 +342,14 @@ interface AppState {
|
|
| 338 |
* boot-time default circuit is still loaded (restore's sample load is
|
| 339 |
* async and races the default bell_state auto-load).
|
| 340 |
*/
|
| 341 |
-
pendingAutoRun: {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
requestAutoRun: (
|
| 343 |
sampleKey: string | null,
|
| 344 |
-
opts?: { replicateOnce?: number },
|
| 345 |
) => void;
|
| 346 |
clearAutoRun: () => void;
|
| 347 |
|
|
|
|
| 233 |
* quick action "+3 replicates"). Consumed by that single run
|
| 234 |
* only — never written into the global toolbar replicateCount. */
|
| 235 |
replicateOnce?: number;
|
| 236 |
+
/** Scenario key when this restore is a scenario boot: threads into
|
| 237 |
+
* the auto-run's archived RunRecord (RunRecord.scenario) so
|
| 238 |
+
* scripted figure-state runs never masquerade as user evidence. */
|
| 239 |
+
scenario?: string;
|
| 240 |
} | null;
|
| 241 |
requestRestore: (r: NonNullable<AppState["pendingRestore"]>) => void;
|
| 242 |
clearRestore: () => void;
|
|
|
|
| 342 |
* boot-time default circuit is still loaded (restore's sample load is
|
| 343 |
* async and races the default bell_state auto-load).
|
| 344 |
*/
|
| 345 |
+
pendingAutoRun: {
|
| 346 |
+
sampleKey: string | null;
|
| 347 |
+
replicateOnce?: number;
|
| 348 |
+
scenario?: string;
|
| 349 |
+
} | null;
|
| 350 |
requestAutoRun: (
|
| 351 |
sampleKey: string | null,
|
| 352 |
+
opts?: { replicateOnce?: number; scenario?: string },
|
| 353 |
) => void;
|
| 354 |
clearAutoRun: () => void;
|
| 355 |
|