@crowandraven/evalkeeper 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/drafts.d.ts +49 -0
  2. package/dist/drafts.js +105 -0
  3. package/dist/drafts.js.map +1 -0
  4. package/dist/glossary.d.ts +6 -2
  5. package/dist/glossary.js +6 -2
  6. package/dist/glossary.js.map +1 -1
  7. package/dist/health.d.ts +35 -2
  8. package/dist/health.js +29 -5
  9. package/dist/health.js.map +1 -1
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +2 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/next/actions.js +128 -15
  14. package/dist/next/actions.js.map +1 -1
  15. package/dist/next/wiring.d.ts +6 -0
  16. package/dist/order.d.ts +18 -0
  17. package/dist/order.js +53 -0
  18. package/dist/order.js.map +1 -0
  19. package/dist/prisma/index.d.ts +1 -0
  20. package/dist/prisma/index.js +3 -0
  21. package/dist/prisma/index.js.map +1 -1
  22. package/dist/react/HubSections.d.ts +7 -0
  23. package/dist/react/HubSections.js +22 -8
  24. package/dist/react/HubSections.js.map +1 -1
  25. package/dist/react/ModelMenu.d.ts +18 -4
  26. package/dist/react/ModelMenu.js +12 -7
  27. package/dist/react/ModelMenu.js.map +1 -1
  28. package/dist/react/RateView.js +1 -0
  29. package/dist/react/RateView.js.map +1 -1
  30. package/dist/react/SuiteSections.d.ts +31 -0
  31. package/dist/react/SuiteSections.js +148 -32
  32. package/dist/react/SuiteSections.js.map +1 -1
  33. package/dist/react/app.d.ts +18 -0
  34. package/dist/react/app.js.map +1 -1
  35. package/dist/react/pieces.d.ts +10 -1
  36. package/dist/react/pieces.js +50 -0
  37. package/dist/react/pieces.js.map +1 -1
  38. package/dist/settings.d.ts +14 -0
  39. package/dist/settings.js +24 -2
  40. package/dist/settings.js.map +1 -1
  41. package/dist/testing.d.ts +1 -1
  42. package/dist/testing.js +32 -0
  43. package/dist/testing.js.map +1 -1
  44. package/dist/types.d.ts +33 -0
  45. package/dist/types.js +11 -0
  46. package/dist/types.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schema/evalkeeper.prisma +3 -0
  49. package/src/drafts.ts +123 -0
  50. package/src/glossary.ts +10 -2
  51. package/src/health.ts +53 -6
  52. package/src/index.ts +2 -0
  53. package/src/next/actions.ts +162 -16
  54. package/src/next/wiring.ts +6 -0
  55. package/src/order.ts +64 -0
  56. package/src/prisma/index.ts +5 -0
  57. package/src/react/HubSections.tsx +31 -7
  58. package/src/react/ModelMenu.tsx +33 -7
  59. package/src/react/RateView.tsx +1 -0
  60. package/src/react/SuiteSections.tsx +640 -170
  61. package/src/react/app.ts +15 -0
  62. package/src/react/pieces.tsx +62 -1
  63. package/src/settings.ts +37 -2
  64. package/src/testing.ts +35 -1
  65. package/src/types.ts +37 -0
  66. package/templates/lib/evalkeeper/actions.ts +20 -0
@@ -2,7 +2,16 @@ import {
2
2
  FAVOR_TEXT,
3
3
  answerKeyHealth,
4
4
  attacksFrom,
5
+ barStatus,
5
6
  checkBar,
7
+ draftAnswers,
8
+ draftsToTarget,
9
+ newStarters,
10
+ orderRows,
11
+ pctBeside,
12
+ priorityGain,
13
+ priorityOf,
14
+ type SuitePriority,
6
15
  isInjectionSuite,
7
16
  meanCalibrationError,
8
17
  money,
@@ -25,13 +34,20 @@ import {
25
34
  IconSubmit,
26
35
  InfoTip,
27
36
  Score,
37
+ Select,
28
38
  Spinner,
29
39
  Submit,
40
+ TextInput,
30
41
  Tip,
31
42
  } from "./pieces.js";
32
43
  import { pct, LINK } from "./format.js";
33
- import { RotateCw } from "lucide-react";
34
- import { evalsPath, type EvalAppConfig, attacksResisted } from "./app.js";
44
+ import { ChevronDown, RotateCw, ShieldAlert, Sparkles } from "lucide-react";
45
+ import {
46
+ evalsPath,
47
+ type EvalAppConfig,
48
+ type FormAction,
49
+ attacksResisted,
50
+ } from "./app.js";
35
51
  import { SettingsHistory } from "./SettingsHistory.js";
36
52
 
37
53
  /**
@@ -61,14 +77,17 @@ export async function loadSuitePage(app: EvalAppConfig, key: string) {
61
77
  ]),
62
78
  ),
63
79
  app.runner.casesInInstructions(key),
64
- app.store.listCases(key),
80
+ // Retired ones too: starters already added once aren't offered again.
81
+ app.store.listCases(key, { includeRetired: true }),
65
82
  ]);
66
83
  const { suite, rows } = b;
67
84
  const attacks = attacksFrom(attackBoards);
68
85
  // An injection suite's models are chosen on its base suite's page.
69
86
  const choosesHere = !isInjectionSuite(suite);
87
+ // The suite's priority, or the one an admin chose in its settings.
88
+ const priority = priorityOf(suite, liveSettings.settings);
70
89
  const s = choosesHere
71
- ? suggest(rows, suite.checks, suite.priority, app.models, { attacks })
90
+ ? suggest(rows, suite.checks, priority, app.models, { attacks })
72
91
  : null;
73
92
  const testing =
74
93
  rows.some((r) => r.testing) ||
@@ -114,6 +133,8 @@ export async function loadSuitePage(app: EvalAppConfig, key: string) {
114
133
  showAttacks,
115
134
  live,
116
135
  health,
136
+ cases,
137
+ priority,
117
138
  };
118
139
  }
119
140
 
@@ -125,6 +146,16 @@ export type SuitePageData = NonNullable<
125
146
  /** A share as a whole percent, or a dash when there's nothing to show. */
126
147
  const asPct = (x: number | null) => (x === null ? "—" : pct(x));
127
148
 
149
+ /** The choices when changing it: accuracy is always held. */
150
+ const CHOICES = {
151
+ quality: "Accuracy alone",
152
+ speed: "Speed",
153
+ cost: "Cost",
154
+ } as const;
155
+
156
+ /** The suite's priority, as the page names it. */
157
+ const FAVORS = { cost: "cost", speed: "speed", quality: "accuracy" } as const;
158
+
128
159
  const VS: Record<string, string> = {
129
160
  BETTER: "More accurate",
130
161
  SAME: "About as accurate",
@@ -134,7 +165,7 @@ const VS: Record<string, string> = {
134
165
 
135
166
  /** The suite's name, what it tests, and its priority. */
136
167
  export function SuiteHeader({ data }: { data: SuitePageData }) {
137
- const { app, suite } = data;
168
+ const { app, suite, priority } = data;
138
169
  return (
139
170
  <>
140
171
  <div className="space-y-2">
@@ -142,7 +173,7 @@ export function SuiteHeader({ data }: { data: SuitePageData }) {
142
173
  <h1 className="text-2xl font-semibold">{suite.label}</h1>
143
174
  <p className="readable text-muted">{suite.description}</p>
144
175
  <p className="readable text-sm text-muted">
145
- Priority: {FAVOR_TEXT[suite.priority.favor]}.
176
+ Priority: {FAVOR_TEXT[priority.favor]}.
146
177
  <InfoTip term="priority" />
147
178
  </p>
148
179
  </div>
@@ -265,12 +296,33 @@ export function ModelTable({ data }: { data: SuitePageData }) {
265
296
  estimates,
266
297
  showAttacks,
267
298
  live,
299
+ s,
300
+ priority,
268
301
  } = data;
302
+ const suggestedLive = s && !s.keepLive ? s.live.key : null;
303
+ const suggestedFallback =
304
+ s?.fallback && !s.fallback.fallback ? s.fallback.key : null;
305
+ const ordered = orderRows(rows, suite.checks, priority, {
306
+ live: suggestedLive,
307
+ });
269
308
  return (
270
309
  <>
271
310
  <section className="space-y-3">
272
311
  <div className="flex items-center justify-between gap-4">
273
- <h2 className="text-lg font-semibold">Models</h2>
312
+ <div className="flex flex-wrap items-center gap-2">
313
+ <h2 className="text-lg font-semibold">Models</h2>
314
+ <Tip term="favors" side="bottom" id="favors">
315
+ <Chip tone="neutral">Favors {FAVORS[priority.favor]}</Chip>
316
+ </Tip>
317
+ {choosesHere && app.actions.setPriority && (
318
+ <PriorityControl
319
+ action={app.actions.setPriority}
320
+ suite={key}
321
+ favor={priority.favor}
322
+ own={suite.priority.favor}
323
+ />
324
+ )}
325
+ </div>
274
326
  <div className="flex items-center gap-4">
275
327
  <form action={app.actions.testAll}>
276
328
  <input type="hidden" name="suite" value={key} />
@@ -285,7 +337,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
285
337
  <th className="p-3 font-normal">Model</th>
286
338
  <th className="p-3 font-normal">
287
339
  <Tip term="score" side="bottom">
288
- Score
340
+ Accuracy
289
341
  </Tip>
290
342
  </th>
291
343
  <th className="p-3 font-normal">
@@ -302,7 +354,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
302
354
  )}
303
355
  <th className="p-3 font-normal">
304
356
  <Tip term="time" side="bottom" align="end">
305
- Time
357
+ Speed
306
358
  </Tip>
307
359
  </th>
308
360
  {suite.decisions && (
@@ -333,7 +385,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
333
385
  </tr>
334
386
  </thead>
335
387
  <tbody>
336
- {rows.map((r) => (
388
+ {ordered.map((r) => (
337
389
  <tr key={r.key} className="border-b border-line last:border-0">
338
390
  <td className="p-3">
339
391
  <div className="flex flex-wrap items-center gap-2">
@@ -356,6 +408,20 @@ export function ModelTable({ data }: { data: SuitePageData }) {
356
408
  <Chip tone="fallback">Fallback</Chip>
357
409
  </Tip>
358
410
  )}
411
+ {(r.key === suggestedLive ||
412
+ r.key === suggestedFallback) && (
413
+ <Tip
414
+ term="suggestion"
415
+ side="bottom"
416
+ id={`suggested-${r.key}`}
417
+ >
418
+ <Chip tone="suggested">
419
+ {r.key === suggestedLive
420
+ ? "Suggested"
421
+ : "Suggested fallback"}
422
+ </Chip>
423
+ </Tip>
424
+ )}
359
425
  {retiresLabel(app.models, r.model) && (
360
426
  <Tip
361
427
  term="retiring"
@@ -405,9 +471,18 @@ export function ModelTable({ data }: { data: SuitePageData }) {
405
471
  <Spinner />
406
472
  </span>
407
473
  ) : r.test ? (
408
- <Link href={evalsPath(app, key, "runs", r.test.runId)}>
409
- <Score right={r.test.right} total={r.test.total} />
410
- </Link>
474
+ <div className="flex flex-col gap-0.5">
475
+ <Link href={evalsPath(app, key, "runs", r.test.runId)}>
476
+ <Score right={r.test.right} total={r.test.total} />
477
+ </Link>
478
+ {!r.test.stale && r.test.failedAnswers > 0 && (
479
+ <span className="text-xs text-muted">
480
+ {r.test.failedAnswers}{" "}
481
+ {r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
482
+ failed: test again
483
+ </span>
484
+ )}
485
+ </div>
411
486
  ) : (
412
487
  <span className="text-muted">
413
488
  {r.failed ?? "Not tested"}
@@ -460,6 +535,9 @@ export function ModelTable({ data }: { data: SuitePageData }) {
460
535
  className={LINK}
461
536
  >
462
537
  {VS[r.vsLive]}
538
+ {(r.vsLive === "SAME" || r.vsLive === "BETTER") &&
539
+ priorityGain(r, live, priority) &&
540
+ `, ${priorityGain(r, live, priority)}`}
463
541
  </Link>
464
542
  ) : r.vsLive ? (
465
543
  VS[r.vsLive]
@@ -468,59 +546,28 @@ export function ModelTable({ data }: { data: SuitePageData }) {
468
546
  )}
469
547
  </td>
470
548
  <td className="p-3">
471
- <div className="flex flex-col items-end gap-0.5">
472
- <div className="flex justify-end gap-2">
473
- <form action={app.actions.testModel}>
474
- <input type="hidden" name="suite" value={key} />
475
- <input type="hidden" name="model" value={r.model} />
476
- <Tip
477
- control
478
- id={`test-${r.key}`}
479
- text={
480
- r.test
481
- ? "Test this model again on every case in use."
482
- : "Test this model on every case in use."
483
- }
484
- side="bottom"
485
- align="end"
486
- >
487
- <IconSubmit
488
- label="Test"
489
- icon={
490
- <RotateCw aria-hidden className="h-4 w-4" />
491
- }
492
- />
493
- </Tip>
494
- </form>
495
- {choosesHere && (
496
- <ModelMenu
497
- suite={key}
498
- model={r.model}
499
- label={r.label}
500
- makeLive={
501
- !r.live && r.canMakeLive
502
- ? app.actions.makeLive
503
- : null
504
- }
505
- makeFallback={
506
- r.canMakeFallback
507
- ? app.actions.makeFallback
508
- : null
509
- }
510
- />
511
- )}
512
- </div>
513
- <EstimateNote
514
- id={r.key}
515
- estimate={estimates.get(r.key)}
549
+ <div className="flex justify-end">
550
+ <ModelMenu
551
+ suite={key}
552
+ model={r.model}
553
+ label={r.label}
554
+ test={{
555
+ action: app.actions.testModel,
556
+ text: r.test ? "Test again" : "Test",
557
+ note: estimateText(estimates.get(r.key)),
558
+ }}
559
+ makeLive={
560
+ choosesHere && !r.live && r.canMakeLive
561
+ ? app.actions.makeLive
562
+ : null
563
+ }
564
+ makeFallback={
565
+ choosesHere && r.canMakeFallback
566
+ ? app.actions.makeFallback
567
+ : null
568
+ }
569
+ effort={r.variant ? r.effort : undefined}
516
570
  />
517
- {r.test && !r.test.stale && r.test.failedAnswers > 0 && (
518
- <span className="text-right text-xs text-muted">
519
- {r.test.failedAnswers}{" "}
520
- {r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
521
- failed on its last test
522
- </span>
523
- )}
524
571
  </div>
525
572
  </td>
526
573
  </tr>
@@ -533,6 +580,156 @@ export function ModelTable({ data }: { data: SuitePageData }) {
533
580
  );
534
581
  }
535
582
 
583
+ /**
584
+ * Testing a model at a reasoning setting other than the feature's: less
585
+ * reasoning is faster and cheaper, more can be more accurate. Each setting
586
+ * gets its own row in the model table. Shows only when a model the feature
587
+ * may use lists its settings in your catalog.
588
+ */
589
+ export function TestSettingSection({ data }: { data: SuitePageData }) {
590
+ const { app, key, operation, choosesHere } = data;
591
+ const tunable = app.runner.modelsFor(operation).flatMap((m) => {
592
+ const efforts = app.models[m]?.efforts;
593
+ return efforts?.length
594
+ ? [{ model: m, label: app.models[m]?.label ?? m, efforts }]
595
+ : [];
596
+ });
597
+ if (!choosesHere || !tunable.length) return null;
598
+ return (
599
+ <form
600
+ action={app.actions.testModel}
601
+ className="flex flex-wrap items-end gap-2"
602
+ >
603
+ <input type="hidden" name="suite" value={key} />
604
+ <div>
605
+ <label htmlFor="test-setting" className="block text-sm font-medium">
606
+ Test a reasoning setting
607
+ <InfoTip term="reasoningSetting" id="test-setting" />
608
+ </label>
609
+ <Select
610
+ id="test-setting"
611
+ name="setting"
612
+ className="mt-1 rounded-md border border-line bg-card px-3 py-2 text-sm"
613
+ >
614
+ {tunable.map((t) => (
615
+ <optgroup key={t.model} label={t.label}>
616
+ {t.efforts.map((e) => (
617
+ <option key={e} value={JSON.stringify([t.model, e])}>
618
+ {t.label} · {e} reasoning
619
+ </option>
620
+ ))}
621
+ </optgroup>
622
+ ))}
623
+ </Select>
624
+ </div>
625
+ <Submit variant="quiet">Test this setting</Submit>
626
+ </form>
627
+ );
628
+ }
629
+
630
+ const BAR_TONE = {
631
+ meets:
632
+ "bg-emerald-100 text-emerald-900 dark:bg-emerald-500/15 dark:text-emerald-200",
633
+ close: "bg-amber-100 text-amber-900 dark:bg-amber-500/15 dark:text-amber-200",
634
+ below: "bg-red-100 text-red-900 dark:bg-red-500/15 dark:text-red-200",
635
+ } as const;
636
+
637
+ /**
638
+ * Where the mistakes are: how often each check passed, for every model
639
+ * with a current test, beside each check's bar. Serious checks first. The
640
+ * checks section shows the live model alone; this shows which model fails
641
+ * which check.
642
+ */
643
+ export function CheckBreakdownSection({ data }: { data: SuitePageData }) {
644
+ const { suite, rows } = data;
645
+ const tested = rows.filter((r) => r.test && !r.test.stale);
646
+ if (!tested.length) return null;
647
+ const checks = [...suite.checks].sort(
648
+ (a, b) => Number(a.severity === "minor") - Number(b.severity === "minor"),
649
+ );
650
+ return (
651
+ <section aria-labelledby="check-breakdown" className="space-y-3">
652
+ <h2 id="check-breakdown" className="text-lg font-semibold">
653
+ Where the mistakes are
654
+ <InfoTip term="checkBreakdown" />
655
+ </h2>
656
+ <Card className="space-y-3">
657
+ <p className="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs">
658
+ {(
659
+ [
660
+ ["meets", "Meets the bar"],
661
+ ["close", "Within 10 points"],
662
+ ["below", "Further below"],
663
+ ] as const
664
+ ).map(([k, text]) => (
665
+ <span key={k} className="flex items-center gap-1.5">
666
+ <span className={`inline-block h-3 w-3 rounded ${BAR_TONE[k]}`} />
667
+ {text}
668
+ </span>
669
+ ))}
670
+ </p>
671
+ <div className="overflow-x-auto">
672
+ <table className="w-full text-left text-sm">
673
+ <thead className="text-xs text-muted">
674
+ <tr>
675
+ <th className="py-2 pr-4 font-normal">Check</th>
676
+ <th className="py-2 pr-4 font-normal">Bar</th>
677
+ {tested.map((r) => (
678
+ <th key={r.key} className="py-2 pr-3 font-normal">
679
+ {r.label}
680
+ </th>
681
+ ))}
682
+ </tr>
683
+ </thead>
684
+ <tbody>
685
+ {checks.map((c) => (
686
+ <tr key={c.key}>
687
+ <td className="py-1.5 pr-4">
688
+ <span className="mr-2">{c.label}</span>
689
+ <Chip
690
+ tone={c.severity === "serious" ? "serious" : "neutral"}
691
+ >
692
+ {c.severity}
693
+ </Chip>
694
+ </td>
695
+ <td className="py-1.5 pr-4 tabular-nums text-muted">
696
+ {pct(checkBar(c))}
697
+ </td>
698
+ {tested.map((r) => {
699
+ const x = r.test?.byCheck[c.key];
700
+ const rate = x?.n ? x.passed / x.n : null;
701
+ return (
702
+ <td key={r.key} className="py-1 pr-2">
703
+ {rate === null ? (
704
+ <span className="text-muted">–</span>
705
+ ) : (
706
+ <span
707
+ className={`inline-block rounded px-2 py-0.5 tabular-nums ${BAR_TONE[barStatus(rate, checkBar(c))]}`}
708
+ >
709
+ {pctBeside(rate, checkBar(c))}
710
+ </span>
711
+ )}
712
+ </td>
713
+ );
714
+ })}
715
+ </tr>
716
+ ))}
717
+ <tr>
718
+ <td className="py-1.5 pr-4">Answers with no mistakes at all</td>
719
+ <td />
720
+ {tested.map((r) => (
721
+ <td key={r.key} className="py-1.5 pr-3 tabular-nums">
722
+ {r.test?.answersRight} of {r.test?.answers}
723
+ </td>
724
+ ))}
725
+ </tr>
726
+ </tbody>
727
+ </table>
728
+ </div>
729
+ </Card>
730
+ </section>
731
+ );
732
+ }
536
733
  /** The feature's settings history, with rollback; not on an injection suite. */
537
734
  export function Versions({ data }: { data: SuitePageData }) {
538
735
  const { app, key, history, liveSettings, choosesHere } = data;
@@ -563,7 +760,11 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
563
760
  <InfoTip term="checks" />
564
761
  </h2>
565
762
  <div className="grid gap-3 md:grid-cols-2">
566
- {suite.checks.map((c) => {
763
+ {/* Serious first; each group keeps the suite's own order. */}
764
+ {[
765
+ ...suite.checks.filter((c) => c.severity === "serious"),
766
+ ...suite.checks.filter((c) => c.severity !== "serious"),
767
+ ].map((c) => {
567
768
  const rate = live?.test?.byCheck[c.key];
568
769
  return (
569
770
  <Card key={c.key} className="space-y-1">
@@ -589,7 +790,7 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
589
790
  : "text-warn"
590
791
  }
591
792
  >
592
- {pct(rate.passed / rate.n)}
793
+ {pctBeside(rate.passed / rate.n, checkBar(c))}
593
794
  </span>{" "}
594
795
  ({rate.passed}/{rate.n}) ·{" "}
595
796
  </>
@@ -607,6 +808,147 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
607
808
  );
608
809
  }
609
810
 
811
+ /**
812
+ * Ways to fill the answer key, beside adding a case by hand: how to judge
813
+ * an answer, testing with draft answers before review, an injection
814
+ * suite's attack cases, starter cases not added yet, and more drafts from
815
+ * the suite's `draftMore`. Each shows only when it applies and your app
816
+ * passes its action.
817
+ */
818
+ export function AnswerKeyToolsSection({ data }: { data: SuitePageData }) {
819
+ const { app, key, suite, cases } = data;
820
+ const { actions } = app;
821
+ const inUse = cases.filter((c) => c.status !== "RETIRED");
822
+ const drafts = draftAnswers(cases);
823
+ const fresh = newStarters(suite.starter, cases);
824
+ const guide =
825
+ suite.answerGuide ??
826
+ (suite.labelHelp ? { points: [{ text: suite.labelHelp }] } : null);
827
+ const injection = isInjectionSuite(suite) ? suite : null;
828
+ const parts = [
829
+ guide && (
830
+ <details
831
+ key="guide"
832
+ className="group rounded-lg border border-line bg-card"
833
+ >
834
+ <summary className="flex cursor-pointer list-none items-center justify-between gap-3 p-4 text-sm font-medium">
835
+ How to judge an answer
836
+ <ChevronDown
837
+ aria-hidden
838
+ className="h-4 w-4 transition-transform group-open:rotate-180"
839
+ />
840
+ </summary>
841
+ <div className="readable space-y-2 px-4 pb-4 text-sm">
842
+ {guide.lead && <p className="font-medium">{guide.lead}</p>}
843
+ {(() => {
844
+ const items = guide.points.map((p, n) => (
845
+ <li key={n}>
846
+ {p.term && <strong>{p.term} </strong>}
847
+ {p.text}
848
+ </li>
849
+ ));
850
+ return guide.ordered ? (
851
+ <ol className="list-decimal space-y-1 pl-5">{items}</ol>
852
+ ) : (
853
+ <ul className="list-disc space-y-1 pl-5">{items}</ul>
854
+ );
855
+ })()}
856
+ {guide.note && <p className="text-muted">{guide.note}</p>}
857
+ </div>
858
+ </details>
859
+ ),
860
+ actions.useDraftsProvisionally && drafts.length > 0 && (
861
+ <Card key="provisional" className="space-y-3">
862
+ <p className="readable text-sm">
863
+ To test before you&apos;ve reviewed them, put the {drafts.length}{" "}
864
+ draft {drafts.length === 1 ? "answer" : "answers"} to use as
865
+ provisional. Scores then say they rest on unreviewed answers until you
866
+ confirm each.
867
+ <InfoTip term="provisional" />
868
+ </p>
869
+ <form action={actions.useDraftsProvisionally}>
870
+ <input type="hidden" name="suite" value={key} />
871
+ <Submit variant="quiet">Test with drafts, as provisional</Submit>
872
+ </form>
873
+ </Card>
874
+ ),
875
+ actions.makeAttackCases && injection && (
876
+ <Card key="attacks" className="space-y-3">
877
+ <p className="readable text-sm">
878
+ Each attack case is a confirmed {injection.base.label} case with an
879
+ attack planted where untrusted text goes, and keeps that case&apos;s
880
+ answer: an attack shouldn&apos;t change it. Run this again after you
881
+ confirm, change, or retire {injection.base.label} answers.
882
+ </p>
883
+ <form action={actions.makeAttackCases}>
884
+ <input type="hidden" name="suite" value={key} />
885
+ <Submit variant={inUse.length ? "quiet" : "primary"}>
886
+ <ShieldAlert aria-hidden className="mr-1.5 inline h-4 w-4" />
887
+ {inUse.length ? "Update attack cases" : "Make attack cases"}
888
+ </Submit>
889
+ </form>
890
+ </Card>
891
+ ),
892
+ actions.addStarters && fresh.length > 0 && (
893
+ <Card key="starters" className="space-y-3">
894
+ <p className="readable text-sm">
895
+ {inUse.length
896
+ ? `${fresh.length} more starter ${fresh.length === 1 ? "case is" : "cases are"} ready.`
897
+ : `No cases yet. Start with the suite's ${fresh.length} starter ${fresh.length === 1 ? "case" : "cases"}.`}{" "}
898
+ Each needs your review and counts only once you confirm it, unless the
899
+ suite&apos;s author already reviewed it.
900
+ </p>
901
+ <form action={actions.addStarters}>
902
+ <input type="hidden" name="suite" value={key} />
903
+ <Submit variant={inUse.length ? "quiet" : "primary"}>
904
+ <Sparkles aria-hidden className="mr-1.5 inline h-4 w-4" />
905
+ Add {fresh.length} starter {fresh.length === 1 ? "case" : "cases"}
906
+ </Submit>
907
+ </form>
908
+ </Card>
909
+ ),
910
+ actions.draftMore && suite.draftMore && inUse.length > 0 && (
911
+ <details
912
+ key="draft"
913
+ className="group rounded-lg border border-line bg-card"
914
+ >
915
+ <summary className="flex cursor-pointer list-none items-center justify-between gap-3 p-4 text-sm font-medium">
916
+ <span className="flex items-center gap-1.5">
917
+ <Sparkles aria-hidden className="h-4 w-4" />
918
+ Draft {draftsToTarget(inUse.length)} more cases
919
+ </span>
920
+ <ChevronDown
921
+ aria-hidden
922
+ className="h-4 w-4 transition-transform group-open:rotate-180"
923
+ />
924
+ </summary>
925
+ <form action={actions.draftMore} className="space-y-3 px-4 pb-4">
926
+ <input type="hidden" name="suite" value={key} />
927
+ <div>
928
+ <label htmlFor="draft-focus" className="block text-sm font-medium">
929
+ Anything to focus on? (optional)
930
+ </label>
931
+ <TextInput
932
+ id="draft-focus"
933
+ name="focus"
934
+ maxLength={500}
935
+ placeholder="e.g. longer, messier notes; more than one owner"
936
+ className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2 text-sm"
937
+ />
938
+ <p className="readable mt-1 text-xs text-muted">
939
+ A model looks at the cases you have and covers what&apos;s
940
+ missing. Drafts need your review and count only once you confirm
941
+ them.
942
+ </p>
943
+ </div>
944
+ <Submit>Draft cases</Submit>
945
+ </form>
946
+ </details>
947
+ ),
948
+ ].filter(Boolean);
949
+ if (!parts.length) return null;
950
+ return <div className="space-y-3">{parts}</div>;
951
+ }
610
952
  /** The answer key: the cases in use and their answers, with ways to add and rate them. */
611
953
  export function AnswerKeySection({ data }: { data: SuitePageData }) {
612
954
  const { app, key, b, suite, rows, attackBoards } = data;
@@ -626,6 +968,7 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
626
968
  tools={
627
969
  <>
628
970
  {suite.caseKind === "imported" &&
971
+ suite.rateBlind !== false &&
629
972
  (suite.labelFromForm || app.answerEditors[key]) && (
630
973
  <Tip control term="rateBlind" side="bottom" align="end">
631
974
  <Link
@@ -676,6 +1019,26 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
676
1019
  answers change.
677
1020
  </p>
678
1021
  }
1022
+ tools={
1023
+ <>
1024
+ <a
1025
+ href="https://seanhudson.github.io/evalkeeper/guides/suites/#more-attacks"
1026
+ className={LINK}
1027
+ >
1028
+ Add an attack
1029
+ </a>
1030
+ {app.actions.makeAttackCases && (
1031
+ <form action={app.actions.makeAttackCases}>
1032
+ <input
1033
+ type="hidden"
1034
+ name="suite"
1035
+ value={a.suite.key}
1036
+ />
1037
+ <Submit variant="quiet">Update attack cases</Submit>
1038
+ </form>
1039
+ )}
1040
+ </>
1041
+ }
679
1042
  />
680
1043
  ),
681
1044
  })),
@@ -687,32 +1050,83 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
687
1050
  }
688
1051
 
689
1052
  /** "Free: all 16 reused" or "~$0.03, 4 of 16 reused", under a model's buttons. */
690
- function EstimateNote({
691
- id,
692
- estimate,
1053
+ /**
1054
+ * Changing what a feature's suggestion favors: accuracy, speed, or cost.
1055
+ * It's saved as a new settings version, with an optional reason, so it
1056
+ * shows under Versions and can be rolled back.
1057
+ */
1058
+ function PriorityControl({
1059
+ action,
1060
+ suite,
1061
+ favor,
1062
+ own,
693
1063
  }: {
694
- id: string;
695
- estimate:
696
- { answers: number; reused: number; costUsd: number | null } | undefined;
1064
+ action: FormAction;
1065
+ suite: string;
1066
+ favor: SuitePriority["favor"];
1067
+ /** The suite's own priority, from its code. */
1068
+ own: SuitePriority["favor"];
697
1069
  }) {
698
- if (!estimate || estimate.answers === 0) return null;
699
- const { answers, reused, costUsd } = estimate;
700
- const text =
701
- reused === answers
702
- ? `Free: all ${answers} reused`
703
- : `${costUsd === null ? "Cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
704
1070
  return (
705
- <Tip
706
- text="What testing this model costs now. Answers an identical request gave in the last 7 days are reused for free."
707
- id={`estimate-${id}`}
708
- side="bottom"
709
- align="end"
710
- >
711
- <span className="whitespace-nowrap text-xs text-muted">{text}</span>
712
- </Tip>
1071
+ <details className="group relative text-sm font-normal">
1072
+ <summary className="cursor-pointer list-none text-accent hover:underline">
1073
+ Change
1074
+ </summary>
1075
+ <form
1076
+ action={action}
1077
+ className="absolute left-0 z-20 mt-2 w-72 space-y-3 rounded-md border border-line bg-card p-4 shadow-lg"
1078
+ >
1079
+ <input type="hidden" name="suite" value={suite} />
1080
+ <div>
1081
+ <label htmlFor="favor" className="block font-medium">
1082
+ Once accuracy holds, favor
1083
+ </label>
1084
+ <Select
1085
+ id="favor"
1086
+ name="favor"
1087
+ defaultValue={favor}
1088
+ className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
1089
+ >
1090
+ {(["quality", "speed", "cost"] as const).map((f) => (
1091
+ <option key={f} value={f}>
1092
+ {CHOICES[f]}
1093
+ {f === own ? " (the suite's own)" : ""}
1094
+ </option>
1095
+ ))}
1096
+ </Select>
1097
+ </div>
1098
+ <div>
1099
+ <label htmlFor="favor-reason" className="block font-medium">
1100
+ Why? <span className="font-normal text-muted">(optional)</span>
1101
+ </label>
1102
+ <TextInput
1103
+ id="favor-reason"
1104
+ name="reason"
1105
+ maxLength={300}
1106
+ className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2"
1107
+ />
1108
+ </div>
1109
+ <Submit>Save as a new version</Submit>
1110
+ </form>
1111
+ </details>
713
1112
  );
714
1113
  }
715
1114
 
1115
+ /**
1116
+ * What testing a model costs now, as the menu says it: "free, all 34
1117
+ * reused", "~$0.10, 15 of 34 reused". Null before any cases.
1118
+ */
1119
+ function estimateText(
1120
+ estimate:
1121
+ { answers: number; reused: number; costUsd: number | null } | undefined,
1122
+ ): string | null {
1123
+ if (!estimate || estimate.answers === 0) return null;
1124
+ const { answers, reused, costUsd } = estimate;
1125
+ return reused === answers
1126
+ ? `free, all ${answers} reused`
1127
+ : `${costUsd === null ? "cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
1128
+ }
1129
+
716
1130
  /**
717
1131
  * A model's serious mistakes on one injection suite, linked to that test,
718
1132
  * or a dash until the model's Test runs the attacks along with its cases.
@@ -751,12 +1165,23 @@ function UnderAttack({
751
1165
  title={attackLabel}
752
1166
  className="tabular-nums"
753
1167
  >
754
- {resisted ? pct(resisted.resisted / resisted.of) : "—"}
755
- {row.test.stale
756
- ? " · out of date"
757
- : row.test.failedAnswers
758
- ? " · answers failed"
759
- : ""}
1168
+ {row.test.stale ? (
1169
+ `${resisted ? pct(resisted.resisted / resisted.of) : "—"} · out of date`
1170
+ ) : row.test.failedAnswers && !resisted ? (
1171
+ <Tip
1172
+ term="attackFailures"
1173
+ side="bottom"
1174
+ id={`attack-failed-${row.key}`}
1175
+ >
1176
+ <span className="text-warn">
1177
+ {row.test.failedAnswers} failed: test again
1178
+ </span>
1179
+ </Tip>
1180
+ ) : resisted ? (
1181
+ pct(resisted.resisted / resisted.of)
1182
+ ) : (
1183
+ "—"
1184
+ )}
760
1185
  </Link>
761
1186
  );
762
1187
  // Not tested yet: the model's Test runs the attacks with its cases.
@@ -791,102 +1216,144 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
791
1216
  const { retireEasy, retireStaleDrafts } = app.actions;
792
1217
  const cases = (n: number) => `${n} ${n === 1 ? "case" : "cases"}`;
793
1218
  const drafts = (n: number) => `${n} ${n === 1 ? "draft" : "drafts"}`;
1219
+ const { draftMore } = app.actions;
1220
+ const check = h.split.length > 0 || h.duplicates.length > 0;
1221
+ const retire = h.easyToRetire.length > 0 || h.staleDrafts.length > 0;
794
1222
  return (
795
1223
  <section className="space-y-3" aria-labelledby="answer-key-health">
796
1224
  <h2 id="answer-key-health" className="text-lg font-semibold">
797
1225
  Answer key health
798
1226
  <InfoTip term="answerKeyHealth" />
799
1227
  </h2>
800
- <Card className="space-y-5 text-sm">
801
- {h.easyToRetire.length > 0 && (
802
- <div className="readable space-y-2">
803
- <p>
804
- <span className="font-medium">Easy cases</span>
805
- <InfoTip term="easyCases" />: every current model gets{" "}
806
- {cases(h.easy.length)} fully right, so they no longer tell models
807
- apart. Retire {h.easyToRetire.length} and keep{" "}
808
- {h.easy.length - h.easyToRetire.length} as a floor
809
- <InfoTip term="easyFloor" />, so a test still catches a model that
810
- breaks the basics. Recent tests are rescored for free.
811
- </p>
812
- {retireEasy && (
813
- <form action={retireEasy}>
814
- <input type="hidden" name="suite" value={key} />
815
- <Submit variant="quiet">
816
- Retire {h.easyToRetire.length} easy{" "}
817
- {h.easyToRetire.length === 1 ? "case" : "cases"}
818
- </Submit>
819
- </form>
1228
+ {/* What to do, in order: fix doubtful answers, fill thin spots, prune. */}
1229
+ <Card className="space-y-6 text-sm">
1230
+ {check && (
1231
+ <div className="readable space-y-3">
1232
+ <h3 className="font-medium">Check these answers</h3>
1233
+ {h.split.length > 0 && (
1234
+ <div className="space-y-1">
1235
+ <p>
1236
+ Models split about evenly on {cases(h.split.length)}. That
1237
+ usually means the answer key is wrong or the case has no clear
1238
+ answer. Open each one: fix the answer, or retire the case if
1239
+ there&apos;s no right one.
1240
+ <InfoTip term="splitCases" />
1241
+ </p>
1242
+ <ul className="list-disc space-y-0.5 pl-5">
1243
+ {h.split.map((c) => (
1244
+ <li key={c.id}>{caseLink(c)}</li>
1245
+ ))}
1246
+ </ul>
1247
+ </div>
820
1248
  )}
821
- </div>
822
- )}
823
- {h.split.length > 0 && (
824
- <div className="readable space-y-1">
825
- <p>
826
- <span className="font-medium">Split cases</span>
827
- <InfoTip term="splitCases" />: models divide about evenly on{" "}
828
- {cases(h.split.length)}. The answer may be unclear, so check it
829
- first.
830
- </p>
831
- <ul className="list-disc space-y-0.5 pl-5">
832
- {h.split.map((c) => (
833
- <li key={c.id}>{caseLink(c)}</li>
834
- ))}
835
- </ul>
836
- </div>
837
- )}
838
- {h.duplicates.length > 0 && (
839
- <div className="readable space-y-1">
840
- <p>
841
- <span className="font-medium">Near-duplicates</span>
842
- <InfoTip term="nearDuplicates" />: these pairs share nearly all
843
- their words. Keep the clearer one.
844
- </p>
845
- <ul className="list-disc space-y-0.5 pl-5">
846
- {h.duplicates.map(([a, b]) => (
847
- <li key={`${a.id}-${b.id}`}>
848
- {caseLink(a)} and {caseLink(b)}
849
- </li>
850
- ))}
851
- </ul>
852
- </div>
853
- )}
854
- {h.staleDrafts.length > 0 && (
855
- <div className="readable space-y-2">
856
- <p>
857
- <span className="font-medium">Old drafts</span>
858
- <InfoTip term="oldDrafts" />: {drafts(h.staleDrafts.length)}{" "}
859
- nobody reviewed in 30 days. The weekly check retires them on its
860
- own.
861
- </p>
862
- {retireStaleDrafts && (
863
- <form action={retireStaleDrafts}>
864
- <input type="hidden" name="suite" value={key} />
865
- <Submit variant="quiet">
866
- Retire {h.staleDrafts.length} old{" "}
867
- {h.staleDrafts.length === 1 ? "draft" : "drafts"} now
868
- </Submit>
869
- </form>
1249
+ {h.duplicates.length > 0 && (
1250
+ <div className="space-y-1">
1251
+ <p>
1252
+ These pairs share nearly all their words, so each counts
1253
+ twice. Keep the clearer one and retire the other.
1254
+ <InfoTip term="nearDuplicates" />
1255
+ </p>
1256
+ <ul className="list-disc space-y-0.5 pl-5">
1257
+ {h.duplicates.map(([a, b]) => (
1258
+ <li key={`${a.id}-${b.id}`}>
1259
+ {caseLink(a)} and {caseLink(b)}
1260
+ </li>
1261
+ ))}
1262
+ </ul>
1263
+ </div>
870
1264
  )}
871
1265
  </div>
872
1266
  )}
873
1267
  {thin.length > 0 && (
874
1268
  <div className="space-y-2">
1269
+ <h3 className="font-medium">Add cases here</h3>
875
1270
  <p className="readable">
876
- <span className="font-medium">Coverage</span>
877
- <InfoTip term="tagCoverage" />: {thin.length}{" "}
878
- {thin.length === 1 ? "tag has" : "tags have"} a single case. A new
879
- case there tells you the most.
1271
+ {thin.length} {thin.length === 1 ? "topic has" : "topics have"}{" "}
1272
+ only one case, so the score on each rests on a single example: one
1273
+ mistake swings it, and a fix can&apos;t be confirmed. Add a case
1274
+ or two to each.
1275
+ <InfoTip term="tagCoverage" />
880
1276
  </p>
881
1277
  <ul className="flex flex-wrap gap-1.5">
882
- {h.tags.map(([t, n]) => (
1278
+ {thin.map((t) => (
883
1279
  <li key={t}>
884
- <Chip tone={n === 1 ? "warn" : "neutral"}>
885
- {t} · {n}
886
- </Chip>
1280
+ <Chip tone="warn">{t}</Chip>
887
1281
  </li>
888
1282
  ))}
889
1283
  </ul>
1284
+ {draftMore && suite.draftMore && (
1285
+ <form action={draftMore}>
1286
+ <input type="hidden" name="suite" value={key} />
1287
+ <input
1288
+ type="hidden"
1289
+ name="focus"
1290
+ value={`Cases on these topics: ${thin.join(", ")}`.slice(
1291
+ 0,
1292
+ 500,
1293
+ )}
1294
+ />
1295
+ <Submit variant="quiet">Draft cases for these topics</Submit>
1296
+ </form>
1297
+ )}
1298
+ <details className="group">
1299
+ <summary className="cursor-pointer text-muted">
1300
+ Show all topics
1301
+ </summary>
1302
+ <ul className="mt-2 flex flex-wrap gap-1.5">
1303
+ {h.tags.map(([t, n]) => (
1304
+ <li key={t}>
1305
+ <Chip tone={n === 1 ? "warn" : "neutral"}>
1306
+ {t} · {n}
1307
+ </Chip>
1308
+ </li>
1309
+ ))}
1310
+ </ul>
1311
+ </details>
1312
+ </div>
1313
+ )}
1314
+ {retire && (
1315
+ <div className="readable space-y-3">
1316
+ <h3 className="font-medium">Retire these</h3>
1317
+ {h.easyToRetire.length > 0 && (
1318
+ <div className="space-y-2">
1319
+ <p>
1320
+ Every current model gets {cases(h.easy.length)} fully right,
1321
+ so they no longer tell models apart. Retire{" "}
1322
+ {h.easyToRetire.length} and keep{" "}
1323
+ {h.easy.length - h.easyToRetire.length} as a floor, so a test
1324
+ still catches a model that breaks the basics. Recent tests are
1325
+ rescored for free.
1326
+ <InfoTip term="easyCases" />
1327
+ </p>
1328
+ {retireEasy && (
1329
+ <form action={retireEasy}>
1330
+ <input type="hidden" name="suite" value={key} />
1331
+ <Submit variant="quiet">
1332
+ Retire {h.easyToRetire.length} easy{" "}
1333
+ {h.easyToRetire.length === 1 ? "case" : "cases"}
1334
+ </Submit>
1335
+ </form>
1336
+ )}
1337
+ </div>
1338
+ )}
1339
+ {h.staleDrafts.length > 0 && (
1340
+ <div className="space-y-2">
1341
+ <p>
1342
+ {drafts(h.staleDrafts.length)} nobody reviewed in 30 days. The
1343
+ weekly check retires them on its own.
1344
+ <InfoTip term="oldDrafts" />
1345
+ </p>
1346
+ {retireStaleDrafts && (
1347
+ <form action={retireStaleDrafts}>
1348
+ <input type="hidden" name="suite" value={key} />
1349
+ <Submit variant="quiet">
1350
+ Retire {h.staleDrafts.length} old{" "}
1351
+ {h.staleDrafts.length === 1 ? "draft" : "drafts"} now
1352
+ </Submit>
1353
+ </form>
1354
+ )}
1355
+ </div>
1356
+ )}
890
1357
  </div>
891
1358
  )}
892
1359
  </Card>
@@ -916,9 +1383,12 @@ export async function SuitePage({
916
1383
  <SuggestionCard data={data} />
917
1384
  <CasesInInstructions data={data} />
918
1385
  <ModelTable data={data} />
1386
+ <TestSettingSection data={data} />
1387
+ <CheckBreakdownSection data={data} />
919
1388
  <Versions data={data} />
920
1389
  <ChecksSection data={data} />
921
1390
  <AnswerKeyHealthSection data={data} />
1391
+ <AnswerKeyToolsSection data={data} />
922
1392
  <AnswerKeySection data={data} />
923
1393
  </div>
924
1394
  );