Spaces:
Sleeping

TheYuchen commited on
Commit
f10a7ab
·
1 Parent(s): 2e43c22

IA inversion 2/4: board cards expand in place (marker card-expand)

Browse files

The Evidence board becomes a working surface, not a menu. A chevron
(or the strip area) expands one card at a time — spanning two grid
columns only when the grid actually measures two (a span-2 in a
1-column auto-fill grid would mint a phantom implicit column) — into
an inline scale-2 summary:

* run-dots timeline: the newest 12 archived runs of the configuration,
chronological, on the SHARED evidence-mass encoding (dot area ~
sqrt(shots), ring = pinned seed, hollow red slash = errored, ink
outline = newest). The encoding is lifted from RunHistory into
lib/evidenceMass.ts so lineage and board size dots identically.
* the pooled Wilson interval as a labeled line (same pool the
collapsed band draws), or an honest "pooling needs >=2 runs with
counts" note.
* quick actions: replay latest (pins the run's seed, auto-runs),
+3 replicates (clears any stale pin, replicateCount=3, auto-runs),
open in editor, A/B. Replay/replicates stay ON the board: the
covered canvas consumes the same pendingRestore/pendingAutoRun
bridge scenario boots ride, the theater overlays the board while a
sampled step streams, and the archive bump repaints the card.

Board-side IA pieces land here too: header renamed to Evidence board
(+ New configuration button -> requestNewConfig + editor), Open sets
editorContext so the editor opens as the card's definition view, hint
and empty state speak board-first, and the history panel's compare
nudge names the board.

frontend/src/components/MultiverseBoard.tsx CHANGED
@@ -1,9 +1,16 @@
1
- // Multiverse board — the archive promoted from a side panel to a
2
- // workspace. The analyst's real object of study is not one pipeline
3
  // but the SET of configurations they have tried; this view makes that
4
  // set first-class: one card per configuration (config_hash group),
5
  // laid out as small multiples so outcome distributions are comparable
6
- // at a glance (multiverse-analysis framing).
 
 
 
 
 
 
 
7
  //
8
  // Encoding decisions, one channel per field:
9
  // * card HUE (chip + border tint + dots) = config_hash, same
@@ -33,13 +40,25 @@
33
  // line compares pooled means when both sides have pools.
34
 
35
  import { useEffect, useMemo, useRef, useState } from "react";
36
- import { GitCompare, HelpCircle, RotateCcw, Workflow, X } from "lucide-react";
 
 
 
 
 
 
 
 
 
 
 
37
  import { useApp } from "../lib/store";
38
  import { listRuns, type RunRecord } from "../lib/runStore";
39
  import type { SharePayload, ShareNode } from "../lib/share";
40
  import { resolveNodeSpec, type NodeSpec } from "../lib/nodeCatalog";
41
  import type { PluginManifest } from "../lib/api";
42
  import { hashHue, hueCss } from "../lib/hues";
 
43
  import {
44
  POOLED_SMALL_N_SHOTS,
45
  poolEvidence,
@@ -356,6 +375,169 @@ function OutcomeStrip({
356
  );
357
  }
358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  // --- misc -------------------------------------------------------------------
360
 
361
  function relTime(ts: number): string {
@@ -380,10 +562,25 @@ export function MultiverseBoard() {
380
  const plugins = useApp((s) => s.plugins);
381
  const requestRestore = useApp((s) => s.requestRestore);
382
  const setWorkspaceMode = useApp((s) => s.setWorkspaceMode);
 
 
 
 
383
  const compareIds = useApp((s) => s.compareIds);
384
  const toggleCompare = useApp((s) => s.toggleCompare);
385
 
386
  const boardRef = useRef<HTMLDivElement>(null);
 
 
 
 
 
 
 
 
 
 
 
387
  const [runs, setRuns] = useState<RunRecord[] | null>(null);
388
  const [hintDismissed, setHintDismissed] = useState<boolean>(() => {
389
  try {
@@ -415,6 +612,18 @@ export function MultiverseBoard() {
415
  const groups = useMemo(() => buildGroups(runs ?? []), [runs]);
416
  const baseline = useMemo(() => pickBaseline(groups), [groups]);
417
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  const demoBannerVisible = runs != null && runs.some((r) => r.demo);
419
  const hintVisible =
420
  groups.length > 0 && (hintForced || (!hintDismissed && !demoBannerVisible));
@@ -429,14 +638,58 @@ export function MultiverseBoard() {
429
  sourceRunId: src.run_id,
430
  precisionTarget: src.precision_target ?? null,
431
  });
 
 
 
 
 
 
 
 
 
432
  setWorkspaceMode("compose");
433
  };
434
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
435
  return (
436
  <div
437
  ref={boardRef}
438
  className="multiverse-board flex-1 flex flex-col min-h-0 bg-canvas"
439
- aria-label="Multiverse board: all configurations as small multiples"
440
  >
441
  {/* Header mirrors the FlowCanvas toolbar height so flipping modes
442
  doesn't jump the layout. The toggle is duplicated here because
@@ -444,7 +697,7 @@ export function MultiverseBoard() {
444
  <div className="h-12 shrink-0 border-b border-edge px-3 sm:px-4 flex items-center gap-3">
445
  <WorkspaceToggle />
446
  <div className="text-xs text-mute truncate">
447
- <span className="text-ink font-medium">Multiverse</span>
448
  <TipIcon
449
  className="ml-1"
450
  hint={`${gloss("configuration")} Card key: squares = pipeline stages · dot above = settings differ from baseline · strip dots = one per replicate (0-100%) · filled band = pooled 95% interval.`}
@@ -457,12 +710,27 @@ export function MultiverseBoard() {
457
  </>
458
  )}
459
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  {!hintVisible && (
461
  <button
462
  type="button"
463
  className="shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
464
  title="Show the board orientation hint (what a card is and what Open / A/B do)"
465
- aria-label="Show multiverse orientation hint"
466
  onClick={() => {
467
  // Explicit reopen beats the one-strip rule AND any
468
  // persisted dismissal.
@@ -508,18 +776,19 @@ export function MultiverseBoard() {
508
  className="multiverse-hint flex items-center gap-2 border-b border-edge/60 bg-surfaceAlt/40 px-3 py-1.5 text-[11px] text-mute"
509
  role="note"
510
  data-marker="multiverse-hint"
511
- aria-label="Multiverse orientation hint"
512
  >
513
  <span className="min-w-0">
514
  Each card is one configuration — its pipeline, its outcome
515
- distribution, Δ vs the baseline card. Open rebuilds it; A/B
516
- sends two cards to Between configurations.
 
517
  </span>
518
  <button
519
  type="button"
520
  className="ml-auto shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
521
  title="Dismiss (remembered on this device — the ? in the header brings it back)"
522
- aria-label="Dismiss multiverse orientation hint"
523
  onClick={() => {
524
  setHintForced(false);
525
  setHintDismissed(true);
@@ -545,23 +814,27 @@ export function MultiverseBoard() {
545
  No configurations archived yet
546
  </div>
547
  <p className="text-sm text-mute leading-relaxed mb-4">
548
- The Multiverse view treats every configuration you try as
549
- evidence: one card per configuration, with its pipeline
550
- schematic and the distribution of outcomes across
551
- replicates. Switch to Compose, run a pipeline (try the ×5
552
- replicate runner), then flip back here to compare.
553
  </p>
554
  <button
555
  type="button"
556
  className="btn"
557
- onClick={() => setWorkspaceMode("compose")}
 
 
 
558
  >
559
- <Workflow className="w-3.5 h-3.5" /> Go to Compose
560
  </button>
561
  </div>
562
  </div>
563
  ) : (
564
  <div
 
565
  className="grid gap-3 p-3"
566
  style={{
567
  gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))",
@@ -597,11 +870,19 @@ export function MultiverseBoard() {
597
  : null;
598
  const abSelected =
599
  g.latestOk != null && compareIds.includes(g.latestOk.run_id);
 
600
  return (
601
  <div
602
  key={g.hash}
603
  className="rounded-lg border bg-surface p-3 flex flex-col gap-2 min-w-0"
604
- style={{ borderColor: hueCss(g.hue, 0.35) }}
 
 
 
 
 
 
 
605
  >
606
  {/* header: circuit + config identity */}
607
  <div className="flex items-center gap-1.5 min-w-0">
@@ -621,14 +902,40 @@ export function MultiverseBoard() {
621
  >
622
  {g.circuitTag}
623
  </span>
624
- {isBaseline && (
625
- <span
626
- className="chip !border-accent/50 !text-accent shrink-0 ml-auto"
627
- title="Most-tried configuration — other cards report Δmean against this one."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  >
629
- baseline
630
- </span>
631
- )}
 
 
 
 
632
  </div>
633
 
634
  {/* pipeline schematic */}
@@ -638,7 +945,18 @@ export function MultiverseBoard() {
638
  plugins={plugins}
639
  />
640
 
641
- {/* outcome distribution */}
 
 
 
 
 
 
 
 
 
 
 
642
  {g.values.length >= 2 ? (
643
  <>
644
  <OutcomeStrip values={g.values} hue={g.hue} pooled={g.pooled} />
@@ -698,6 +1016,7 @@ export function MultiverseBoard() {
698
  no metric recorded
699
  </div>
700
  )}
 
701
 
702
  {/* meta */}
703
  <div className="flex items-center gap-2 text-[10px] text-mute">
@@ -716,39 +1035,134 @@ export function MultiverseBoard() {
716
  )}
717
  </div>
718
 
719
- {/* actions */}
720
- <div className="flex items-center gap-1.5 mt-auto pt-1">
721
- <button
722
- type="button"
723
- className="btn disabled:opacity-40 disabled:cursor-not-allowed"
724
- disabled={g.latestOk == null}
725
- onClick={() => openConfig(g)}
726
- title={
727
- g.latestOk
728
- ? "Rebuild this configuration on the canvas (switches to Compose)"
729
- : "No successful run to restore"
730
- }
731
- >
732
- <RotateCcw className="w-3 h-3" /> Open
733
- </button>
734
- <button
735
- type="button"
736
- className={`btn disabled:opacity-40 disabled:cursor-not-allowed ${
737
- abSelected ? "!border-accent/60 !text-accent" : ""
738
- }`}
739
- disabled={g.latestOk == null}
740
- onClick={() =>
741
- g.latestOk && toggleCompare(g.latestOk.run_id)
742
- }
743
- title={
744
- g.latestOk
745
- ? "Select this configuration's latest run for side-by-side comparison (pick two)"
746
- : "No successful run to compare"
747
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  >
749
- <GitCompare className="w-3 h-3" /> A/B
750
- </button>
751
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
752
  </div>
753
  );
754
  })}
 
1
+ // Evidence board (internal id: "multiverse") — HOME since the IA
2
+ // inversion. The analyst's real object of study is not one pipeline
3
  // but the SET of configurations they have tried; this view makes that
4
  // set first-class: one card per configuration (config_hash group),
5
  // laid out as small multiples so outcome distributions are comparable
6
+ // at a glance (multiverse-analysis framing). Since the IA-inversion
7
+ // wave the board is the DEFAULT workspace (store default + persisted
8
+ // preference), and a card expands IN PLACE into a scale-2 summary
9
+ // (marker: card-expand) — recent-run dots, pooled interval, quick
10
+ // actions — so working the evidence never requires leaving home. The
11
+ // Pipeline editor is the subordinate definition view of one
12
+ // configuration, entered from a card's "Open in editor" or the
13
+ // header's "New configuration" (marker: config-context).
14
  //
15
  // Encoding decisions, one channel per field:
16
  // * card HUE (chip + border tint + dots) = config_hash, same
 
40
  // line compares pooled means when both sides have pools.
41
 
42
  import { useEffect, useMemo, useRef, useState } from "react";
43
+ import {
44
+ ChevronDown,
45
+ ChevronUp,
46
+ GitCompare,
47
+ HelpCircle,
48
+ Play,
49
+ Plus,
50
+ Repeat,
51
+ RotateCcw,
52
+ Workflow,
53
+ X,
54
+ } from "lucide-react";
55
  import { useApp } from "../lib/store";
56
  import { listRuns, type RunRecord } from "../lib/runStore";
57
  import type { SharePayload, ShareNode } from "../lib/share";
58
  import { resolveNodeSpec, type NodeSpec } from "../lib/nodeCatalog";
59
  import type { PluginManifest } from "../lib/api";
60
  import { hashHue, hueCss } from "../lib/hues";
61
+ import { evidenceRadius } from "../lib/evidenceMass";
62
  import {
63
  POOLED_SMALL_N_SHOTS,
64
  poolEvidence,
 
375
  );
376
  }
377
 
378
+ // --- expanded card: in-place scale-2 summary (marker: card-expand) ----------
379
+
380
+ /** Newest runs of one configuration as a compact chronological dot
381
+ * timeline — the lineage's row-dot encoding, miniaturized and shared
382
+ * via lib/evidenceMass.ts so "dot area = shots of evidence" stays ONE
383
+ * encoding across panels: ring = pinned seed (deterministic replay),
384
+ * hollow + red slash = errored run, ink outline = newest. y is flat
385
+ * (time only): the outcome axis already lives in the card's 0-1
386
+ * strip, and duplicating it here would imply two value axes. */
387
+ const MAX_DOTS = 12;
388
+
389
+ function RunDotsStrip({ runs, hue }: { runs: RunRecord[]; hue: number }) {
390
+ const shown = runs.slice(-MAX_DOTS);
391
+ const earlier = runs.length - shown.length;
392
+ const H = 24;
393
+ const STEP = 19;
394
+ const PADX = 10;
395
+ const w = PADX * 2 + Math.max(0, shown.length - 1) * STEP;
396
+ return (
397
+ <div className="flex items-center gap-1.5 min-w-0">
398
+ {earlier > 0 && (
399
+ <span className="text-[10px] text-mute shrink-0">+{earlier} earlier</span>
400
+ )}
401
+ <svg
402
+ width={w}
403
+ height={H}
404
+ role="img"
405
+ aria-label={`${shown.length} most recent runs, oldest to newest; dot area is shots of evidence, a ring marks a pinned (replayed) seed`}
406
+ className="shrink-0"
407
+ >
408
+ {shown.length > 1 && (
409
+ <line
410
+ x1={PADX}
411
+ x2={PADX + (shown.length - 1) * STEP}
412
+ y1={H / 2}
413
+ y2={H / 2}
414
+ stroke="rgb(var(--color-edge))"
415
+ strokeWidth={1}
416
+ />
417
+ )}
418
+ {shown.map((r, i) => {
419
+ const ev = runEvidence(r.response);
420
+ const rad = evidenceRadius(ev?.shots ?? 0);
421
+ const cx = PADX + i * STEP;
422
+ const pinned = r.seed_mode === "pinned";
423
+ const newest = i === shown.length - 1;
424
+ const label = r.ok
425
+ ? r.headline_value != null
426
+ ? `${(Math.min(1, Math.max(0, r.headline_value)) * 100).toFixed(1)}%`
427
+ : "no metric"
428
+ : "errored";
429
+ const title = `${label} · ${ev ? `${ev.shots} shots` : "no sampled evidence"}${
430
+ r.root_seed != null
431
+ ? ` · ${pinned ? "replayed seed" : "seed"} ${r.root_seed}`
432
+ : ""
433
+ } · ${relTime(r.created_at)}`;
434
+ return (
435
+ <g key={r.run_id}>
436
+ {r.ok ? (
437
+ <circle
438
+ cx={cx}
439
+ cy={H / 2}
440
+ r={rad}
441
+ fill={hueCss(hue, newest ? 0.95 : 0.55)}
442
+ stroke={newest ? "rgb(var(--color-ink))" : "none"}
443
+ strokeWidth={newest ? 1 : 0}
444
+ >
445
+ <title>{title}</title>
446
+ </circle>
447
+ ) : (
448
+ <g>
449
+ <circle
450
+ cx={cx}
451
+ cy={H / 2}
452
+ r={rad}
453
+ fill="none"
454
+ stroke={hueCss(hue, 0.55)}
455
+ strokeWidth={1.2}
456
+ >
457
+ <title>{title}</title>
458
+ </circle>
459
+ <line
460
+ x1={cx - rad}
461
+ y1={H / 2 + rad}
462
+ x2={cx + rad}
463
+ y2={H / 2 - rad}
464
+ stroke="rgb(var(--color-danger))"
465
+ strokeWidth={1.2}
466
+ />
467
+ </g>
468
+ )}
469
+ {pinned && (
470
+ <circle
471
+ cx={cx}
472
+ cy={H / 2}
473
+ r={rad + 2}
474
+ fill="none"
475
+ stroke={hueCss(hue, 0.8)}
476
+ strokeWidth={1}
477
+ >
478
+ <title>pinned seed — deterministic replay</title>
479
+ </circle>
480
+ )}
481
+ </g>
482
+ );
483
+ })}
484
+ </svg>
485
+ </div>
486
+ );
487
+ }
488
+
489
+ /** The pooled 95% interval as its own labeled line — the same Wilson
490
+ * pool the collapsed card draws as a band under the dots, promoted to
491
+ * a readable statement when the card is expanded. */
492
+ function PooledLine({ pooled, hue }: { pooled: PooledEvidence; hue: number }) {
493
+ const H = 18;
494
+ const X0 = 8;
495
+ return (
496
+ <div className="flex items-center gap-2 min-w-0">
497
+ <svg
498
+ viewBox={`0 0 220 ${H}`}
499
+ className="w-full max-w-[220px]"
500
+ height={H}
501
+ preserveAspectRatio="xMidYMid meet"
502
+ role="img"
503
+ aria-label={`Pooled 95% interval ${(pooled.ci95[0] * 100).toFixed(1)} to ${(pooled.ci95[1] * 100).toFixed(1)} percent over ${pooled.shots} shots`}
504
+ >
505
+ <line x1={X0} x2={212} y1={H / 2} y2={H / 2} stroke="rgb(var(--color-edge))" strokeWidth={1} />
506
+ {(() => {
507
+ const px = (v: number) => X0 + v * (212 - X0);
508
+ return (
509
+ <>
510
+ <rect
511
+ x={px(pooled.ci95[0])}
512
+ y={H / 2 - 3}
513
+ width={Math.max(2, px(pooled.ci95[1]) - px(pooled.ci95[0]))}
514
+ height={6}
515
+ rx={3}
516
+ fill={hueCss(hue, 0.35)}
517
+ stroke={hueCss(hue, 0.7)}
518
+ strokeWidth={0.75}
519
+ >
520
+ <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>
521
+ </rect>
522
+ <line
523
+ x1={px(pooled.point)}
524
+ x2={px(pooled.point)}
525
+ y1={H / 2 - 6}
526
+ y2={H / 2 + 6}
527
+ stroke={hueCss(hue, 0.95)}
528
+ strokeWidth={1.5}
529
+ />
530
+ </>
531
+ );
532
+ })()}
533
+ </svg>
534
+ <span className="text-[10px] text-mute tabular-nums whitespace-nowrap shrink-0">
535
+ {(pooled.ci95[0] * 100).toFixed(1)}–{(pooled.ci95[1] * 100).toFixed(1)}%
536
+ </span>
537
+ </div>
538
+ );
539
+ }
540
+
541
  // --- misc -------------------------------------------------------------------
542
 
543
  function relTime(ts: number): string {
 
562
  const plugins = useApp((s) => s.plugins);
563
  const requestRestore = useApp((s) => s.requestRestore);
564
  const setWorkspaceMode = useApp((s) => s.setWorkspaceMode);
565
+ const setEditorContext = useApp((s) => s.setEditorContext);
566
+ const requestNewConfig = useApp((s) => s.requestNewConfig);
567
+ const setReplicateCount = useApp((s) => s.setReplicateCount);
568
+ const setPinnedSeed = useApp((s) => s.setPinnedSeed);
569
  const compareIds = useApp((s) => s.compareIds);
570
  const toggleCompare = useApp((s) => s.toggleCompare);
571
 
572
  const boardRef = useRef<HTMLDivElement>(null);
573
+ // In-place card expansion (marker: card-expand): at most ONE card at
574
+ // a time — the expansion is a focused reading of one configuration,
575
+ // not a second grid density. Keyed by config hash so it survives
576
+ // archive refreshes (run counts change, identity doesn't).
577
+ const [expandedHash, setExpandedHash] = useState<string | null>(null);
578
+ // Whether the grid is wide enough for an expanded card to span two
579
+ // columns. Guarded because `grid-column: span 2` in a ONE-column
580
+ // auto-fill grid would mint a phantom implicit column and shrink
581
+ // every card; measured on the grid element itself.
582
+ const gridRef = useRef<HTMLDivElement>(null);
583
+ const [canSpan, setCanSpan] = useState(false);
584
  const [runs, setRuns] = useState<RunRecord[] | null>(null);
585
  const [hintDismissed, setHintDismissed] = useState<boolean>(() => {
586
  try {
 
612
  const groups = useMemo(() => buildGroups(runs ?? []), [runs]);
613
  const baseline = useMemo(() => pickBaseline(groups), [groups]);
614
 
615
+ const hasCards = groups.length > 0;
616
+ useEffect(() => {
617
+ const el = gridRef.current;
618
+ if (!el) return;
619
+ // Two 240px columns + the 12px gap must fit the grid content box.
620
+ const update = () => setCanSpan(el.clientWidth >= 240 * 2 + 12);
621
+ update();
622
+ const ro = new ResizeObserver(update);
623
+ ro.observe(el);
624
+ return () => ro.disconnect();
625
+ }, [hasCards]);
626
+
627
  const demoBannerVisible = runs != null && runs.some((r) => r.demo);
628
  const hintVisible =
629
  groups.length > 0 && (hintForced || (!hintDismissed && !demoBannerVisible));
 
638
  sourceRunId: src.run_id,
639
  precisionTarget: src.precision_target ?? null,
640
  });
641
+ // The editor opens as this configuration's DEFINITION VIEW: the
642
+ // context bar (marker: config-context) names the identity being
643
+ // edited and live-rehashes it as params change.
644
+ setEditorContext({
645
+ source: "card",
646
+ hash: g.hash,
647
+ circuitTag: g.circuitTag,
648
+ runCount: g.runs.length,
649
+ });
650
  setWorkspaceMode("compose");
651
  };
652
 
653
+ // Quick actions of an expanded card (marker: card-expand). Both stay
654
+ // ON the board: the canvas underneath rebuilds and auto-runs (the
655
+ // same pendingRestore/pendingAutoRun bridge scenario boots ride),
656
+ // the theater overlays the board while the sampled step streams,
657
+ // and the archive bump repaints this card. Disabled for runs on
658
+ // uploaded circuits — auto-run needs a reloadable sample.
659
+ const replayLatest = (g: ConfigGroup) => {
660
+ const src = g.latestOk;
661
+ if (!src || src.sample_key == null || src.root_seed == null) return;
662
+ requestRestore({
663
+ graph: src.graph,
664
+ sampleKey: src.sample_key,
665
+ pinSeed: src.root_seed,
666
+ sourceRunId: src.run_id,
667
+ precisionTarget: src.precision_target ?? null,
668
+ autoRunAfter: true,
669
+ });
670
+ };
671
+ const runThreeReplicates = (g: ConfigGroup) => {
672
+ const src = g.latestOk;
673
+ if (!src || src.sample_key == null) return;
674
+ // Fresh draws: clear any stale pinned seed (a pin forces ×1 and
675
+ // identical numbers) and ask for 3 replicates.
676
+ setPinnedSeed(null);
677
+ setReplicateCount(3);
678
+ requestRestore({
679
+ graph: src.graph,
680
+ sampleKey: src.sample_key,
681
+ pinSeed: null,
682
+ sourceRunId: src.run_id,
683
+ precisionTarget: src.precision_target ?? null,
684
+ autoRunAfter: true,
685
+ });
686
+ };
687
+
688
  return (
689
  <div
690
  ref={boardRef}
691
  className="multiverse-board flex-1 flex flex-col min-h-0 bg-canvas"
692
+ aria-label="Evidence board: all configurations as small multiples"
693
  >
694
  {/* Header mirrors the FlowCanvas toolbar height so flipping modes
695
  doesn't jump the layout. The toggle is duplicated here because
 
697
  <div className="h-12 shrink-0 border-b border-edge px-3 sm:px-4 flex items-center gap-3">
698
  <WorkspaceToggle />
699
  <div className="text-xs text-mute truncate">
700
+ <span className="text-ink font-medium">Evidence board</span>
701
  <TipIcon
702
  className="ml-1"
703
  hint={`${gloss("configuration")} Card key: squares = pipeline stages · dot above = settings differ from baseline · strip dots = one per replicate (0-100%) · filled band = pooled 95% interval.`}
 
710
  </>
711
  )}
712
  </div>
713
+ {/* IA inversion: composing starts FROM home. The button clears
714
+ the canvas (newConfigRequest bridge) and frames the editor
715
+ as "New configuration — not yet run" (config-context). */}
716
+ <button
717
+ type="button"
718
+ className="btn shrink-0"
719
+ title="Define a new configuration in the Pipeline editor (opens a blank canvas)"
720
+ onClick={() => {
721
+ requestNewConfig();
722
+ setWorkspaceMode("compose");
723
+ }}
724
+ >
725
+ <Plus className="w-3 h-3" />
726
+ <span className="hidden sm:inline">New configuration</span>
727
+ </button>
728
  {!hintVisible && (
729
  <button
730
  type="button"
731
  className="shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
732
  title="Show the board orientation hint (what a card is and what Open / A/B do)"
733
+ aria-label="Show board orientation hint"
734
  onClick={() => {
735
  // Explicit reopen beats the one-strip rule AND any
736
  // persisted dismissal.
 
776
  className="multiverse-hint flex items-center gap-2 border-b border-edge/60 bg-surfaceAlt/40 px-3 py-1.5 text-[11px] text-mute"
777
  role="note"
778
  data-marker="multiverse-hint"
779
+ aria-label="Board orientation hint"
780
  >
781
  <span className="min-w-0">
782
  Each card is one configuration — its pipeline, its outcome
783
+ distribution, Δ vs the baseline card. Expand (⌄) for recent
784
+ runs and quick actions; Open rebuilds it in the Pipeline
785
+ editor; A/B sends two cards to Between configurations.
786
  </span>
787
  <button
788
  type="button"
789
  className="ml-auto shrink-0 p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
790
  title="Dismiss (remembered on this device — the ? in the header brings it back)"
791
+ aria-label="Dismiss board orientation hint"
792
  onClick={() => {
793
  setHintForced(false);
794
  setHintDismissed(true);
 
814
  No configurations archived yet
815
  </div>
816
  <p className="text-sm text-mute leading-relaxed mb-4">
817
+ The Evidence board is home: every configuration you try
818
+ becomes a card, with its pipeline schematic and the
819
+ distribution of outcomes across replicates. Open the
820
+ Pipeline editor, define and run a configuration (try the
821
+ ×5 replicate runner), then come back here to compare.
822
  </p>
823
  <button
824
  type="button"
825
  className="btn"
826
+ onClick={() => {
827
+ requestNewConfig();
828
+ setWorkspaceMode("compose");
829
+ }}
830
  >
831
+ <Workflow className="w-3.5 h-3.5" /> Define a configuration
832
  </button>
833
  </div>
834
  </div>
835
  ) : (
836
  <div
837
+ ref={gridRef}
838
  className="grid gap-3 p-3"
839
  style={{
840
  gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))",
 
870
  : null;
871
  const abSelected =
872
  g.latestOk != null && compareIds.includes(g.latestOk.run_id);
873
+ const expanded = expandedHash === g.hash;
874
  return (
875
  <div
876
  key={g.hash}
877
  className="rounded-lg border bg-surface p-3 flex flex-col gap-2 min-w-0"
878
+ style={{
879
+ borderColor: hueCss(g.hue, expanded ? 0.6 : 0.35),
880
+ // span 2 only when the grid really has two columns:
881
+ // in a 1-column grid, span 2 would mint a phantom
882
+ // implicit column and shrink every card (canSpan is
883
+ // measured on the grid element).
884
+ ...(expanded && canSpan ? { gridColumn: "span 2" } : {}),
885
+ }}
886
  >
887
  {/* header: circuit + config identity */}
888
  <div className="flex items-center gap-1.5 min-w-0">
 
902
  >
903
  {g.circuitTag}
904
  </span>
905
+ <span className="ml-auto flex items-center gap-1 shrink-0">
906
+ {isBaseline && (
907
+ <span
908
+ className="chip !border-accent/50 !text-accent shrink-0"
909
+ title="Most-tried configuration — other cards report Δmean against this one."
910
+ >
911
+ baseline
912
+ </span>
913
+ )}
914
+ <button
915
+ type="button"
916
+ className="p-0.5 rounded text-mute hover:text-ink hover:bg-surfaceAlt"
917
+ aria-expanded={expanded}
918
+ aria-label={
919
+ expanded
920
+ ? "Collapse configuration card"
921
+ : "Expand configuration card: recent runs, pooled interval, quick actions"
922
+ }
923
+ title={
924
+ expanded
925
+ ? "Collapse"
926
+ : "Expand in place: recent runs, pooled interval, quick actions"
927
+ }
928
+ onClick={() =>
929
+ setExpandedHash(expanded ? null : g.hash)
930
+ }
931
  >
932
+ {expanded ? (
933
+ <ChevronUp className="w-3.5 h-3.5" />
934
+ ) : (
935
+ <ChevronDown className="w-3.5 h-3.5" />
936
+ )}
937
+ </button>
938
+ </span>
939
  </div>
940
 
941
  {/* pipeline schematic */}
 
945
  plugins={plugins}
946
  />
947
 
948
+ {/* outcome distribution — the strip area doubles as
949
+ the expand affordance (chevron is the accessible
950
+ path; this is the big pointer target). */}
951
+ <div
952
+ className="cursor-pointer"
953
+ title={
954
+ expanded
955
+ ? "Collapse"
956
+ : "Expand in place: recent runs, pooled interval, quick actions"
957
+ }
958
+ onClick={() => setExpandedHash(expanded ? null : g.hash)}
959
+ >
960
  {g.values.length >= 2 ? (
961
  <>
962
  <OutcomeStrip values={g.values} hue={g.hue} pooled={g.pooled} />
 
1016
  no metric recorded
1017
  </div>
1018
  )}
1019
+ </div>
1020
 
1021
  {/* meta */}
1022
  <div className="flex items-center gap-2 text-[10px] text-mute">
 
1035
  )}
1036
  </div>
1037
 
1038
+ {/* actions. Collapsed: the two originals. Expanded
1039
+ (marker: card-expand): the in-place scale-2
1040
+ summary + quick actions — replay/replicates stay
1041
+ ON the board (the canvas underneath runs, the
1042
+ theater overlays, the card repaints), so the
1043
+ board is a working surface, not a menu. */}
1044
+ {!expanded ? (
1045
+ <div className="flex items-center gap-1.5 mt-auto pt-1">
1046
+ <button
1047
+ type="button"
1048
+ className="btn disabled:opacity-40 disabled:cursor-not-allowed"
1049
+ disabled={g.latestOk == null}
1050
+ onClick={() => openConfig(g)}
1051
+ title={
1052
+ g.latestOk
1053
+ ? "Open this configuration in the Pipeline editor (its definition view)"
1054
+ : "No successful run to restore"
1055
+ }
1056
+ >
1057
+ <RotateCcw className="w-3 h-3" /> Open
1058
+ </button>
1059
+ <button
1060
+ type="button"
1061
+ className={`btn disabled:opacity-40 disabled:cursor-not-allowed ${
1062
+ abSelected ? "!border-accent/60 !text-accent" : ""
1063
+ }`}
1064
+ disabled={g.latestOk == null}
1065
+ onClick={() =>
1066
+ g.latestOk && toggleCompare(g.latestOk.run_id)
1067
+ }
1068
+ title={
1069
+ g.latestOk
1070
+ ? "Select this configuration's latest run for side-by-side comparison (pick two)"
1071
+ : "No successful run to compare"
1072
+ }
1073
+ >
1074
+ <GitCompare className="w-3 h-3" /> A/B
1075
+ </button>
1076
+ </div>
1077
+ ) : (
1078
+ <div
1079
+ data-marker="card-expand"
1080
+ className="mt-auto border-t border-edge/60 pt-2 flex flex-col gap-2"
1081
  >
1082
+ <div className="text-[10px] uppercase tracking-wider text-mute/70 select-none">
1083
+ recent runs — oldest → newest
1084
+ </div>
1085
+ <RunDotsStrip runs={g.runs} hue={g.hue} />
1086
+ {g.pooled ? (
1087
+ <PooledLine pooled={g.pooled} hue={g.hue} />
1088
+ ) : (
1089
+ <div className="text-[10px] text-mute">
1090
+ no pooled interval yet — pooling needs ≥2 runs
1091
+ with measurement counts; +3 replicates buys them
1092
+ </div>
1093
+ )}
1094
+ <div className="flex flex-wrap items-center gap-1.5">
1095
+ <button
1096
+ type="button"
1097
+ className="btn disabled:opacity-40 disabled:cursor-not-allowed"
1098
+ disabled={
1099
+ g.latestOk == null ||
1100
+ g.latestOk.sample_key == null ||
1101
+ g.latestOk.root_seed == null
1102
+ }
1103
+ onClick={() => replayLatest(g)}
1104
+ title={
1105
+ g.latestOk == null
1106
+ ? "No successful run to replay"
1107
+ : g.latestOk.sample_key == null
1108
+ ? "This run used an uploaded circuit — open it in the editor and re-upload to replay"
1109
+ : g.latestOk.root_seed == null
1110
+ ? "No recorded seed on the latest run"
1111
+ : `Replay the latest run bit-exactly (pins seed ${g.latestOk.root_seed}, runs without leaving the board)`
1112
+ }
1113
+ >
1114
+ <Play className="w-3 h-3" /> Replay latest
1115
+ </button>
1116
+ <button
1117
+ type="button"
1118
+ className="btn disabled:opacity-40 disabled:cursor-not-allowed"
1119
+ disabled={
1120
+ g.latestOk == null || g.latestOk.sample_key == null
1121
+ }
1122
+ onClick={() => runThreeReplicates(g)}
1123
+ title={
1124
+ g.latestOk == null
1125
+ ? "No successful run to replicate"
1126
+ : g.latestOk.sample_key == null
1127
+ ? "This run used an uploaded circuit — open it in the editor and re-upload to replicate"
1128
+ : "Buy more evidence: 3 fresh-seed replicates of this configuration, run from the board"
1129
+ }
1130
+ >
1131
+ <Repeat className="w-3 h-3" /> +3 replicates
1132
+ </button>
1133
+ <button
1134
+ type="button"
1135
+ className="btn disabled:opacity-40 disabled:cursor-not-allowed"
1136
+ disabled={g.latestOk == null}
1137
+ onClick={() => openConfig(g)}
1138
+ title={
1139
+ g.latestOk
1140
+ ? "Open this configuration in the Pipeline editor (its definition view)"
1141
+ : "No successful run to restore"
1142
+ }
1143
+ >
1144
+ <RotateCcw className="w-3 h-3" /> Open in editor
1145
+ </button>
1146
+ <button
1147
+ type="button"
1148
+ className={`btn disabled:opacity-40 disabled:cursor-not-allowed ${
1149
+ abSelected ? "!border-accent/60 !text-accent" : ""
1150
+ }`}
1151
+ disabled={g.latestOk == null}
1152
+ onClick={() =>
1153
+ g.latestOk && toggleCompare(g.latestOk.run_id)
1154
+ }
1155
+ title={
1156
+ g.latestOk
1157
+ ? "Select this configuration's latest run for side-by-side comparison (pick two)"
1158
+ : "No successful run to compare"
1159
+ }
1160
+ >
1161
+ <GitCompare className="w-3 h-3" /> A/B
1162
+ </button>
1163
+ </div>
1164
+ </div>
1165
+ )}
1166
  </div>
1167
  );
1168
  })}
frontend/src/components/RunHistory.tsx CHANGED
@@ -60,6 +60,7 @@ import { Download, GitCompareArrows, History, KeyRound, Play, RotateCcw, Trash2,
60
  import { useApp } from "../lib/store";
61
  import { deleteRun, exportArchive, importArchive, listRuns, type RunRecord } from "../lib/runStore";
62
  import { hashHue, hueCss } from "../lib/hues";
 
63
  import { runEvidence, wilson95 } from "../lib/stats";
64
  import { DemoArchiveBanner } from "./DemoArchiveBanner";
65
 
@@ -72,21 +73,11 @@ const STRIP_H = 20; // height of a group distribution-strip row
72
  const LANE_X0 = 13; // x of lane 0 inside the gutter
73
  const LANE_DX = 11; // horizontal distance between lanes
74
  const N_LANES = 4; // lanes cycle mod 4 — enough separation for edges to read
75
- const R_MIN = 3; // node radius floor (runs with no sampled evidence)
76
- const R_MAX = 7; // node radius cap
77
- const SHOTS_REF = 2048; // shots that earn R_MAX = the app's default full budget
78
  const RING_PAD = 2.5; // pinned-seed ring sits this far outside the dot
79
  const FUNNEL_MAX_PX = 10; // widest half-width of a group certainty funnel
80
-
81
- /** Wave J evidence mass: dot AREA ∝ √shots ⇒ radius ∝ shots^(1/4),
82
- * against a FIXED 2048-shot reference (not view-normalized) so the
83
- * same run keeps the same weight across sessions and figures — the
84
- * same stability argument as the hash→hue mapping. 512 shots ≈ 5px,
85
- * 2048 ≈ 7px; an early stop at 512 of 2048 is plainly lighter. */
86
- function evidenceRadius(shots: number): number {
87
- if (!(shots > 0)) return R_MIN;
88
- return Math.max(R_MIN, Math.min(R_MAX, R_MAX * Math.pow(shots / SHOTS_REF, 0.25)));
89
- }
90
  const STRIP_W = 92; // width of the 0-1 distribution mini strip
91
 
92
  function timeLabel(ts: number): string {
@@ -678,7 +669,7 @@ export function RunHistory({ embedded = false }: { embedded?: boolean } = {}) {
678
  first checkbox beyond a "1" on a tab the user may never
679
  look at — the interaction just seemed to do nothing. One
680
  transient chip closes the loop and names the alternative
681
- entry point (Multiverse A/B). Disappears at 0 or 2. */}
682
  {compareIds.length === 1 && (
683
  <div
684
  role="status"
@@ -687,7 +678,7 @@ export function RunHistory({ embedded = false }: { embedded?: boolean } = {}) {
687
  <GitCompareArrows className="w-3 h-3 shrink-0" />
688
  <span>
689
  1 of 2 picked — tick one more run for Between
690
- configurations, or A/B a card in Multiverse.
691
  </span>
692
  </div>
693
  )}
 
60
  import { useApp } from "../lib/store";
61
  import { deleteRun, exportArchive, importArchive, listRuns, type RunRecord } from "../lib/runStore";
62
  import { hashHue, hueCss } from "../lib/hues";
63
+ import { R_MIN, evidenceRadius } from "../lib/evidenceMass";
64
  import { runEvidence, wilson95 } from "../lib/stats";
65
  import { DemoArchiveBanner } from "./DemoArchiveBanner";
66
 
 
73
  const LANE_X0 = 13; // x of lane 0 inside the gutter
74
  const LANE_DX = 11; // horizontal distance between lanes
75
  const N_LANES = 4; // lanes cycle mod 4 — enough separation for edges to read
 
 
 
76
  const RING_PAD = 2.5; // pinned-seed ring sits this far outside the dot
77
  const FUNNEL_MAX_PX = 10; // widest half-width of a group certainty funnel
78
+ // Evidence-mass sizing (R_MIN/R_MAX/evidenceRadius) moved to
79
+ // lib/evidenceMass.ts in the IA-inversion wave: the Evidence board's
80
+ // expanded card strip shares the identical dot-area encoding.
 
 
 
 
 
 
 
81
  const STRIP_W = 92; // width of the 0-1 distribution mini strip
82
 
83
  function timeLabel(ts: number): string {
 
669
  first checkbox beyond a "1" on a tab the user may never
670
  look at — the interaction just seemed to do nothing. One
671
  transient chip closes the loop and names the alternative
672
+ entry point (Evidence-board A/B). Disappears at 0 or 2. */}
673
  {compareIds.length === 1 && (
674
  <div
675
  role="status"
 
678
  <GitCompareArrows className="w-3 h-3 shrink-0" />
679
  <span>
680
  1 of 2 picked — tick one more run for Between
681
+ configurations, or A/B a card on the Evidence board.
682
  </span>
683
  </div>
684
  )}
frontend/src/lib/evidenceMass.ts ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Evidence-mass encoding (Wave J), lifted into a shared module by the
2
+ // IA-inversion wave: the lineage (RunHistory) and the Evidence-board
3
+ // card's expanded run-dots strip must size dots IDENTICALLY, or "dot
4
+ // area = shots of evidence" stops being one encoding.
5
+ //
6
+ // dot AREA ∝ √shots ⇒ radius ∝ shots^(1/4), against a FIXED 2048-shot
7
+ // reference (not view-normalized) so the same run keeps the same
8
+ // weight across sessions, panels and figures — the same stability
9
+ // argument as the hash→hue mapping. 512 shots ≈ 5px, 2048 ≈ 7px; an
10
+ // early stop at 512 of 2048 reads plainly lighter. Area (not radius)
11
+ // because dots read as quantities; √shots (not shots) so a 4096-shot
12
+ // run cannot visually swallow eight 512s.
13
+
14
+ export const R_MIN = 3; // radius floor (runs with no sampled evidence)
15
+ export const R_MAX = 7; // radius cap
16
+ export const SHOTS_REF = 2048; // shots that earn R_MAX = the default full budget
17
+
18
+ export function evidenceRadius(shots: number): number {
19
+ if (!(shots > 0)) return R_MIN;
20
+ return Math.max(
21
+ R_MIN,
22
+ Math.min(R_MAX, R_MAX * Math.pow(shots / SHOTS_REF, 0.25)),
23
+ );
24
+ }