@crowandraven/evalkeeper 0.12.0 → 0.14.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 (125) hide show
  1. package/dist/drafts.d.ts +2 -0
  2. package/dist/drafts.js +3 -1
  3. package/dist/drafts.js.map +1 -1
  4. package/dist/failures.d.ts +16 -0
  5. package/dist/failures.js +40 -0
  6. package/dist/failures.js.map +1 -0
  7. package/dist/glossary.d.ts +4 -2
  8. package/dist/glossary.js +4 -2
  9. package/dist/glossary.js.map +1 -1
  10. package/dist/health.d.ts +35 -2
  11. package/dist/health.js +31 -6
  12. package/dist/health.js.map +1 -1
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +2 -0
  15. package/dist/index.js.map +1 -1
  16. package/dist/legs.d.ts +4 -1
  17. package/dist/legs.js +6 -2
  18. package/dist/legs.js.map +1 -1
  19. package/dist/next/actions.js +79 -15
  20. package/dist/next/actions.js.map +1 -1
  21. package/dist/next/route.js +2 -1
  22. package/dist/next/route.js.map +1 -1
  23. package/dist/next/weekly.d.ts +7 -2
  24. package/dist/next/weekly.js +5 -3
  25. package/dist/next/weekly.js.map +1 -1
  26. package/dist/next/wiring.d.ts +6 -0
  27. package/dist/order.d.ts +18 -0
  28. package/dist/order.js +53 -0
  29. package/dist/order.js.map +1 -0
  30. package/dist/prisma/index.d.ts +1 -0
  31. package/dist/prisma/index.js +3 -0
  32. package/dist/prisma/index.js.map +1 -1
  33. package/dist/prune.d.ts +4 -1
  34. package/dist/prune.js +11 -2
  35. package/dist/prune.js.map +1 -1
  36. package/dist/react/AddCase.d.ts +12 -2
  37. package/dist/react/AddCase.js +70 -8
  38. package/dist/react/AddCase.js.map +1 -1
  39. package/dist/react/AnswerKey.js +11 -5
  40. package/dist/react/AnswerKey.js.map +1 -1
  41. package/dist/react/CaseMenu.d.ts +6 -1
  42. package/dist/react/CaseMenu.js +5 -2
  43. package/dist/react/CaseMenu.js.map +1 -1
  44. package/dist/react/CompareView.js +4 -4
  45. package/dist/react/CompareView.js.map +1 -1
  46. package/dist/react/FeedbackView.js +3 -3
  47. package/dist/react/FeedbackView.js.map +1 -1
  48. package/dist/react/HubSections.js +11 -10
  49. package/dist/react/HubSections.js.map +1 -1
  50. package/dist/react/ModelMenu.d.ts +13 -4
  51. package/dist/react/ModelMenu.js +12 -7
  52. package/dist/react/ModelMenu.js.map +1 -1
  53. package/dist/react/PriorityPicker.d.ts +21 -0
  54. package/dist/react/PriorityPicker.js +47 -0
  55. package/dist/react/PriorityPicker.js.map +1 -0
  56. package/dist/react/RateView.js +1 -0
  57. package/dist/react/RateView.js.map +1 -1
  58. package/dist/react/RunView.js +21 -5
  59. package/dist/react/RunView.js.map +1 -1
  60. package/dist/react/SettingsHistory.js +3 -3
  61. package/dist/react/SettingsHistory.js.map +1 -1
  62. package/dist/react/SuiteSections.d.ts +6 -0
  63. package/dist/react/SuiteSections.js +100 -39
  64. package/dist/react/SuiteSections.js.map +1 -1
  65. package/dist/react/WeeklyCheck.js +4 -8
  66. package/dist/react/WeeklyCheck.js.map +1 -1
  67. package/dist/react/app.d.ts +4 -0
  68. package/dist/react/app.js.map +1 -1
  69. package/dist/react/format.d.ts +2 -2
  70. package/dist/react/format.js +4 -2
  71. package/dist/react/format.js.map +1 -1
  72. package/dist/react/pieces.d.ts +21 -1
  73. package/dist/react/pieces.js +67 -2
  74. package/dist/react/pieces.js.map +1 -1
  75. package/dist/runner.d.ts +7 -2
  76. package/dist/runner.js +5 -2
  77. package/dist/runner.js.map +1 -1
  78. package/dist/settings.d.ts +14 -0
  79. package/dist/settings.js +24 -2
  80. package/dist/settings.js.map +1 -1
  81. package/dist/suggest.js +25 -7
  82. package/dist/suggest.js.map +1 -1
  83. package/dist/testing.d.ts +1 -1
  84. package/dist/testing.js +32 -0
  85. package/dist/testing.js.map +1 -1
  86. package/dist/types.d.ts +12 -0
  87. package/dist/types.js +11 -0
  88. package/dist/types.js.map +1 -1
  89. package/package.json +10 -10
  90. package/schema/evalkeeper.prisma +3 -0
  91. package/src/drafts.ts +6 -1
  92. package/src/failures.ts +50 -0
  93. package/src/glossary.ts +6 -2
  94. package/src/health.ts +55 -7
  95. package/src/index.ts +2 -0
  96. package/src/legs.ts +8 -2
  97. package/src/next/actions.ts +96 -17
  98. package/src/next/route.ts +2 -1
  99. package/src/next/weekly.ts +15 -4
  100. package/src/next/wiring.ts +6 -0
  101. package/src/order.ts +64 -0
  102. package/src/prisma/index.ts +5 -0
  103. package/src/prune.ts +15 -1
  104. package/src/react/AddCase.tsx +98 -11
  105. package/src/react/AnswerKey.tsx +74 -14
  106. package/src/react/CaseMenu.tsx +24 -0
  107. package/src/react/CompareView.tsx +19 -4
  108. package/src/react/FeedbackView.tsx +13 -3
  109. package/src/react/HubSections.tsx +18 -11
  110. package/src/react/ModelMenu.tsx +24 -7
  111. package/src/react/PriorityPicker.tsx +143 -0
  112. package/src/react/RateView.tsx +1 -0
  113. package/src/react/RunView.tsx +41 -6
  114. package/src/react/SettingsHistory.tsx +3 -3
  115. package/src/react/SuiteSections.tsx +418 -251
  116. package/src/react/WeeklyCheck.tsx +12 -6
  117. package/src/react/app.ts +4 -0
  118. package/src/react/format.ts +4 -2
  119. package/src/react/pieces.tsx +96 -2
  120. package/src/runner.ts +11 -4
  121. package/src/settings.ts +37 -2
  122. package/src/suggest.ts +26 -7
  123. package/src/testing.ts +35 -1
  124. package/src/types.ts +18 -0
  125. package/templates/lib/evalkeeper/actions.ts +8 -0
@@ -1,12 +1,17 @@
1
1
  import {
2
2
  FAVOR_TEXT,
3
+ allPassed,
3
4
  answerKeyHealth,
4
5
  attacksFrom,
5
6
  barStatus,
6
7
  checkBar,
7
8
  draftAnswers,
8
- draftsToTarget,
9
9
  newStarters,
10
+ orderRows,
11
+ pctBeside,
12
+ priorityGain,
13
+ priorityOf,
14
+ type SuitePriority,
10
15
  isInjectionSuite,
11
16
  meanCalibrationError,
12
17
  money,
@@ -19,6 +24,7 @@ import {
19
24
  } from "../index.js";
20
25
  import { AnswerKey } from "./AnswerKey.js";
21
26
  import { ModelMenu } from "./ModelMenu.js";
27
+ import { PriorityPicker } from "./PriorityPicker.js";
22
28
  import { Tabs } from "./Tabs.js";
23
29
  import {
24
30
  Link,
@@ -32,10 +38,9 @@ import {
32
38
  Select,
33
39
  Spinner,
34
40
  Submit,
35
- TextInput,
36
41
  Tip,
37
42
  } from "./pieces.js";
38
- import { pct, LINK } from "./format.js";
43
+ import { pct, LINK, QUIET_BUTTON } from "./format.js";
39
44
  import { ChevronDown, RotateCw, ShieldAlert, Sparkles } from "lucide-react";
40
45
  import { evalsPath, type EvalAppConfig, attacksResisted } from "./app.js";
41
46
  import { SettingsHistory } from "./SettingsHistory.js";
@@ -74,12 +79,16 @@ export async function loadSuitePage(app: EvalAppConfig, key: string) {
74
79
  const attacks = attacksFrom(attackBoards);
75
80
  // An injection suite's models are chosen on its base suite's page.
76
81
  const choosesHere = !isInjectionSuite(suite);
77
- const s = choosesHere
78
- ? suggest(rows, suite.checks, suite.priority, app.models, { attacks })
79
- : null;
82
+ // The suite's priority, or the one an admin chose in its settings.
83
+ const priority = priorityOf(suite, liveSettings.settings);
80
84
  const testing =
81
85
  rows.some((r) => r.testing) ||
82
86
  attackBoards.some((a) => a.rows.some((r) => r.testing));
87
+ // No suggestion while a test runs: it would weigh half a board.
88
+ const s =
89
+ choosesHere && !testing
90
+ ? suggest(rows, suite.checks, priority, app.models, { attacks })
91
+ : null;
83
92
  // What testing each model would cost now, attack cases included,
84
93
  // counting answers it would reuse.
85
94
  const estimates = new Map(
@@ -100,7 +109,30 @@ export async function loadSuitePage(app: EvalAppConfig, key: string) {
100
109
  const showAttacks = attackBoards.some((a) => a.cases > 0);
101
110
  const live = rows.find((r) => r.live);
102
111
  // What would keep the answer key useful, from the same tests.
103
- const health = answerKeyHealth(cases, b.caseResults);
112
+ const current = rows.filter((r) => r.test && !r.test.stale && !r.baseline);
113
+ const testedAt = current.reduce<Date | null>(
114
+ (m, r) => (r.test && (!m || r.test.at > m) ? r.test.at : m),
115
+ null,
116
+ );
117
+ const health = answerKeyHealth(cases, b.caseResults, new Date(), testedAt);
118
+ // For each split case, which models got it fully right and which didn't,
119
+ // so a person sees the disagreement before deciding.
120
+ const split = new Set(health.split.map((c) => c.id));
121
+ const splitBy: Record<string, { right: string[]; wrong: string[] }> = {};
122
+ if (split.size)
123
+ await Promise.all(
124
+ current
125
+ .filter((r) => !r.variant)
126
+ .map(async (r) => {
127
+ if (!r.test) return;
128
+ for (const o of await app.store.listOutputs(r.test.runId)) {
129
+ if (!split.has(o.caseId) || o.error) continue;
130
+ const side = allPassed(o.scores) ? "right" : "wrong";
131
+ const entry = (splitBy[o.caseId] ??= { right: [], wrong: [] });
132
+ if (!entry[side].includes(r.label)) entry[side].push(r.label);
133
+ }
134
+ }),
135
+ );
104
136
 
105
137
  return {
106
138
  app,
@@ -122,6 +154,8 @@ export async function loadSuitePage(app: EvalAppConfig, key: string) {
122
154
  live,
123
155
  health,
124
156
  cases,
157
+ priority,
158
+ splitBy,
125
159
  };
126
160
  }
127
161
 
@@ -133,6 +167,18 @@ export type SuitePageData = NonNullable<
133
167
  /** A share as a whole percent, or a dash when there's nothing to show. */
134
168
  const asPct = (x: number | null) => (x === null ? "—" : pct(x));
135
169
 
170
+ /**
171
+ * What a priority means for the suggestion, as a sentence: the
172
+ * explanation without its leading name ("cost: this runs…").
173
+ */
174
+ const whyFavor = (favor: SuitePriority["favor"]) => {
175
+ const text = FAVOR_TEXT[favor].replace(/^\w+: /, "");
176
+ return `${text.charAt(0).toUpperCase()}${text.slice(1)}.`;
177
+ };
178
+
179
+ /** The suite's priority, as the page names it. */
180
+ const FAVORS = { cost: "cost", speed: "speed", quality: "accuracy" } as const;
181
+
136
182
  const VS: Record<string, string> = {
137
183
  BETTER: "More accurate",
138
184
  SAME: "About as accurate",
@@ -149,10 +195,6 @@ export function SuiteHeader({ data }: { data: SuitePageData }) {
149
195
  <BackLink href={app.basePath}>Evals</BackLink>
150
196
  <h1 className="text-2xl font-semibold">{suite.label}</h1>
151
197
  <p className="readable text-muted">{suite.description}</p>
152
- <p className="readable text-sm text-muted">
153
- Priority: {FAVOR_TEXT[suite.priority.favor]}.
154
- <InfoTip term="priority" />
155
- </p>
156
198
  </div>
157
199
  </>
158
200
  );
@@ -189,15 +231,31 @@ export function ChosenOnBase({ data }: { data: SuitePageData }) {
189
231
 
190
232
  /** Which models to make live and the fallback, and why; shown when nothing would change too. */
191
233
  export function SuggestionCard({ data }: { data: SuitePageData }) {
192
- const { app, key, s } = data;
234
+ const { app, key, s, choosesHere, testing } = data;
235
+ if (choosesHere && testing)
236
+ return (
237
+ <section className="space-y-3" aria-labelledby="suggestion">
238
+ <h2 id="suggestion" className="text-lg font-semibold">
239
+ Suggested
240
+ <InfoTip term="suggestion" />
241
+ </h2>
242
+ <Card>
243
+ <p className="readable text-sm text-muted">
244
+ Waiting for the tests running now to finish. The suggestion weighs
245
+ every model&apos;s finished test, so it follows then.
246
+ </p>
247
+ </Card>
248
+ </section>
249
+ );
193
250
  return (
194
251
  <>
195
252
  {/* Shown when nothing would change too, so a higher score that
196
- isn't enough to switch for comes with its reason. */}
253
+ isn't enough to switch for comes with its reason. A section like
254
+ Models: the heading outside, Use these beside it. */}
197
255
  {s && (
198
- <Card className="space-y-3">
199
- <div className="flex flex-wrap items-start justify-between gap-3">
200
- <h2 className="font-semibold">
256
+ <section className="space-y-3" aria-labelledby="suggestion">
257
+ <div className="flex items-center justify-between gap-4">
258
+ <h2 id="suggestion" className="text-lg font-semibold">
201
259
  {s.same ? "No change suggested" : "Suggested"}
202
260
  <InfoTip term="suggestion" />
203
261
  </h2>
@@ -210,23 +268,25 @@ export function SuggestionCard({ data }: { data: SuitePageData }) {
210
268
  </form>
211
269
  )}
212
270
  </div>
213
- {!s.same && (
214
- <p>
215
- Live: <strong>{s.live.label}</strong>
216
- {s.fallback && (
217
- <>
218
- {" "}
219
- · Fallback: <strong>{s.fallback.label}</strong>
220
- </>
221
- )}
222
- </p>
223
- )}
224
- <ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
225
- {s.reasons.map((r) => (
226
- <li key={r}>{r}</li>
227
- ))}
228
- </ul>
229
- </Card>
271
+ <Card className="space-y-3">
272
+ {!s.same && (
273
+ <p>
274
+ Live: <strong>{s.live.label}</strong>
275
+ {s.fallback && (
276
+ <>
277
+ {" "}
278
+ · Fallback: <strong>{s.fallback.label}</strong>
279
+ </>
280
+ )}
281
+ </p>
282
+ )}
283
+ <ul className="readable list-disc space-y-1 pl-5 text-sm text-muted">
284
+ {s.reasons.map((r) => (
285
+ <li key={r}>{r}</li>
286
+ ))}
287
+ </ul>
288
+ </Card>
289
+ </section>
230
290
  )}
231
291
  </>
232
292
  );
@@ -273,12 +333,37 @@ export function ModelTable({ data }: { data: SuitePageData }) {
273
333
  estimates,
274
334
  showAttacks,
275
335
  live,
336
+ s,
337
+ priority,
276
338
  } = data;
339
+ const suggestedLive = s && !s.keepLive ? s.live.key : null;
340
+ const suggestedFallback =
341
+ s?.fallback && !s.fallback.fallback ? s.fallback.key : null;
342
+ const ordered = orderRows(rows, suite.checks, priority, {
343
+ live: suggestedLive,
344
+ });
277
345
  return (
278
346
  <>
279
347
  <section className="space-y-3">
280
348
  <div className="flex items-center justify-between gap-4">
281
- <h2 className="text-lg font-semibold">Models</h2>
349
+ <div className="flex flex-wrap items-center gap-2">
350
+ <h2 className="text-lg font-semibold">Models</h2>
351
+ {/* Why this priority, in its words: the page says it once. */}
352
+ {choosesHere && app.actions.setPriority ? (
353
+ <PriorityPicker
354
+ action={app.actions.setPriority}
355
+ suite={key}
356
+ favor={priority.favor}
357
+ own={suite.priority.favor}
358
+ label={`Favors ${FAVORS[priority.favor]}`}
359
+ why={whyFavor(priority.favor)}
360
+ />
361
+ ) : (
362
+ <Tip text={whyFavor(priority.favor)} side="bottom" id="favors">
363
+ <Chip tone="neutral">Favors {FAVORS[priority.favor]}</Chip>
364
+ </Tip>
365
+ )}
366
+ </div>
282
367
  <div className="flex items-center gap-4">
283
368
  <form action={app.actions.testAll}>
284
369
  <input type="hidden" name="suite" value={key} />
@@ -293,7 +378,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
293
378
  <th className="p-3 font-normal">Model</th>
294
379
  <th className="p-3 font-normal">
295
380
  <Tip term="score" side="bottom">
296
- Score
381
+ Accuracy
297
382
  </Tip>
298
383
  </th>
299
384
  <th className="p-3 font-normal">
@@ -310,7 +395,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
310
395
  )}
311
396
  <th className="p-3 font-normal">
312
397
  <Tip term="time" side="bottom" align="end">
313
- Time
398
+ Speed
314
399
  </Tip>
315
400
  </th>
316
401
  {suite.decisions && (
@@ -341,7 +426,7 @@ export function ModelTable({ data }: { data: SuitePageData }) {
341
426
  </tr>
342
427
  </thead>
343
428
  <tbody>
344
- {rows.map((r) => (
429
+ {ordered.map((r) => (
345
430
  <tr key={r.key} className="border-b border-line last:border-0">
346
431
  <td className="p-3">
347
432
  <div className="flex flex-wrap items-center gap-2">
@@ -364,6 +449,20 @@ export function ModelTable({ data }: { data: SuitePageData }) {
364
449
  <Chip tone="fallback">Fallback</Chip>
365
450
  </Tip>
366
451
  )}
452
+ {(r.key === suggestedLive ||
453
+ r.key === suggestedFallback) && (
454
+ <Tip
455
+ term="suggestion"
456
+ side="bottom"
457
+ id={`suggested-${r.key}`}
458
+ >
459
+ <Chip tone="suggested">
460
+ {r.key === suggestedLive
461
+ ? "Suggested"
462
+ : "Suggested fallback"}
463
+ </Chip>
464
+ </Tip>
465
+ )}
367
466
  {retiresLabel(app.models, r.model) && (
368
467
  <Tip
369
468
  term="retiring"
@@ -413,9 +512,21 @@ export function ModelTable({ data }: { data: SuitePageData }) {
413
512
  <Spinner />
414
513
  </span>
415
514
  ) : r.test ? (
416
- <Link href={evalsPath(app, key, "runs", r.test.runId)}>
417
- <Score right={r.test.right} total={r.test.total} />
418
- </Link>
515
+ <div className="flex flex-col gap-0.5">
516
+ <Link href={evalsPath(app, key, "runs", r.test.runId)}>
517
+ <Score right={r.test.right} total={r.test.total} />
518
+ </Link>
519
+ {!r.test.stale && r.test.failedAnswers > 0 && (
520
+ <Link
521
+ href={`${evalsPath(app, key, "runs", r.test.runId)}#failed`}
522
+ className="text-xs text-muted hover:underline"
523
+ >
524
+ {r.test.failedAnswers}{" "}
525
+ {r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
526
+ failed: see why
527
+ </Link>
528
+ )}
529
+ </div>
419
530
  ) : (
420
531
  <span className="text-muted">
421
532
  {r.failed ?? "Not tested"}
@@ -468,6 +579,9 @@ export function ModelTable({ data }: { data: SuitePageData }) {
468
579
  className={LINK}
469
580
  >
470
581
  {VS[r.vsLive]}
582
+ {(r.vsLive === "SAME" || r.vsLive === "BETTER") &&
583
+ priorityGain(r, live, priority) &&
584
+ `, ${priorityGain(r, live, priority)}`}
471
585
  </Link>
472
586
  ) : r.vsLive ? (
473
587
  VS[r.vsLive]
@@ -476,68 +590,28 @@ export function ModelTable({ data }: { data: SuitePageData }) {
476
590
  )}
477
591
  </td>
478
592
  <td className="p-3">
479
- <div className="flex flex-col items-end gap-0.5">
480
- <div className="flex justify-end gap-2">
481
- <form action={app.actions.testModel}>
482
- <input type="hidden" name="suite" value={key} />
483
- <input type="hidden" name="model" value={r.model} />
484
- {/* A row at another setting tests at its own. */}
485
- {r.variant && (
486
- <input
487
- type="hidden"
488
- name="effort"
489
- value={r.effort ?? "default"}
490
- />
491
- )}
492
- <Tip
493
- control
494
- id={`test-${r.key}`}
495
- text={
496
- r.test
497
- ? "Test this model again on every case in use."
498
- : "Test this model on every case in use."
499
- }
500
- side="bottom"
501
- align="end"
502
- >
503
- <IconSubmit
504
- label="Test"
505
- icon={
506
- <RotateCw aria-hidden className="h-4 w-4" />
507
- }
508
- />
509
- </Tip>
510
- </form>
511
- {choosesHere && (
512
- <ModelMenu
513
- suite={key}
514
- model={r.model}
515
- label={r.label}
516
- makeLive={
517
- !r.live && r.canMakeLive
518
- ? app.actions.makeLive
519
- : null
520
- }
521
- makeFallback={
522
- r.canMakeFallback
523
- ? app.actions.makeFallback
524
- : null
525
- }
526
- effort={r.variant ? r.effort : undefined}
527
- />
528
- )}
529
- </div>
530
- <EstimateNote
531
- id={r.key}
532
- estimate={estimates.get(r.key)}
593
+ <div className="flex justify-end">
594
+ <ModelMenu
595
+ suite={key}
596
+ model={r.model}
597
+ label={r.label}
598
+ test={{
599
+ action: app.actions.testModel,
600
+ text: r.test ? "Test again" : "Test",
601
+ note: estimateText(estimates.get(r.key)),
602
+ }}
603
+ makeLive={
604
+ choosesHere && !r.live && r.canMakeLive
605
+ ? app.actions.makeLive
606
+ : null
607
+ }
608
+ makeFallback={
609
+ choosesHere && r.canMakeFallback
610
+ ? app.actions.makeFallback
611
+ : null
612
+ }
613
+ effort={r.variant ? r.effort : undefined}
533
614
  />
534
- {r.test && !r.test.stale && r.test.failedAnswers > 0 && (
535
- <span className="text-right text-xs text-muted">
536
- {r.test.failedAnswers}{" "}
537
- {r.test.failedAnswers === 1 ? "answer" : "answers"}{" "}
538
- failed on its last test
539
- </span>
540
- )}
541
615
  </div>
542
616
  </td>
543
617
  </tr>
@@ -676,7 +750,7 @@ export function CheckBreakdownSection({ data }: { data: SuitePageData }) {
676
750
  <span
677
751
  className={`inline-block rounded px-2 py-0.5 tabular-nums ${BAR_TONE[barStatus(rate, checkBar(c))]}`}
678
752
  >
679
- {pct(rate)}
753
+ {pctBeside(rate, checkBar(c))}
680
754
  </span>
681
755
  )}
682
756
  </td>
@@ -730,7 +804,11 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
730
804
  <InfoTip term="checks" />
731
805
  </h2>
732
806
  <div className="grid gap-3 md:grid-cols-2">
733
- {suite.checks.map((c) => {
807
+ {/* Serious first; each group keeps the suite's own order. */}
808
+ {[
809
+ ...suite.checks.filter((c) => c.severity === "serious"),
810
+ ...suite.checks.filter((c) => c.severity !== "serious"),
811
+ ].map((c) => {
734
812
  const rate = live?.test?.byCheck[c.key];
735
813
  return (
736
814
  <Card key={c.key} className="space-y-1">
@@ -756,7 +834,7 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
756
834
  : "text-warn"
757
835
  }
758
836
  >
759
- {pct(rate.passed / rate.n)}
837
+ {pctBeside(rate.passed / rate.n, checkBar(c))}
760
838
  </span>{" "}
761
839
  ({rate.passed}/{rate.n}) ·{" "}
762
840
  </>
@@ -873,44 +951,6 @@ export function AnswerKeyToolsSection({ data }: { data: SuitePageData }) {
873
951
  </form>
874
952
  </Card>
875
953
  ),
876
- actions.draftMore && suite.draftMore && inUse.length > 0 && (
877
- <details
878
- key="draft"
879
- className="group rounded-lg border border-line bg-card"
880
- >
881
- <summary className="flex cursor-pointer list-none items-center justify-between gap-3 p-4 text-sm font-medium">
882
- <span className="flex items-center gap-1.5">
883
- <Sparkles aria-hidden className="h-4 w-4" />
884
- Draft {draftsToTarget(inUse.length)} more cases
885
- </span>
886
- <ChevronDown
887
- aria-hidden
888
- className="h-4 w-4 transition-transform group-open:rotate-180"
889
- />
890
- </summary>
891
- <form action={actions.draftMore} className="space-y-3 px-4 pb-4">
892
- <input type="hidden" name="suite" value={key} />
893
- <div>
894
- <label htmlFor="draft-focus" className="block text-sm font-medium">
895
- Anything to focus on? (optional)
896
- </label>
897
- <TextInput
898
- id="draft-focus"
899
- name="focus"
900
- maxLength={500}
901
- placeholder="e.g. longer, messier notes; more than one owner"
902
- className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2 text-sm"
903
- />
904
- <p className="readable mt-1 text-xs text-muted">
905
- A model looks at the cases you have and covers what&apos;s
906
- missing. Drafts need your review and count only once you confirm
907
- them.
908
- </p>
909
- </div>
910
- <Submit>Draft cases</Submit>
911
- </form>
912
- </details>
913
- ),
914
954
  ].filter(Boolean);
915
955
  if (!parts.length) return null;
916
956
  return <div className="space-y-3">{parts}</div>;
@@ -934,6 +974,7 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
934
974
  tools={
935
975
  <>
936
976
  {suite.caseKind === "imported" &&
977
+ suite.rateBlind !== false &&
937
978
  (suite.labelFromForm || app.answerEditors[key]) && (
938
979
  <Tip control term="rateBlind" side="bottom" align="end">
939
980
  <Link
@@ -984,6 +1025,26 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
984
1025
  answers change.
985
1026
  </p>
986
1027
  }
1028
+ tools={
1029
+ <>
1030
+ <a
1031
+ href="https://seanhudson.github.io/evalkeeper/guides/suites/#more-attacks"
1032
+ className={LINK}
1033
+ >
1034
+ Add an attack
1035
+ </a>
1036
+ {app.actions.makeAttackCases && (
1037
+ <form action={app.actions.makeAttackCases}>
1038
+ <input
1039
+ type="hidden"
1040
+ name="suite"
1041
+ value={a.suite.key}
1042
+ />
1043
+ <Submit variant="quiet">Update attack cases</Submit>
1044
+ </form>
1045
+ )}
1046
+ </>
1047
+ }
987
1048
  />
988
1049
  ),
989
1050
  })),
@@ -994,31 +1055,19 @@ export function AnswerKeySection({ data }: { data: SuitePageData }) {
994
1055
  );
995
1056
  }
996
1057
 
997
- /** "Free: all 16 reused" or "~$0.03, 4 of 16 reused", under a model's buttons. */
998
- function EstimateNote({
999
- id,
1000
- estimate,
1001
- }: {
1002
- id: string;
1058
+ /**
1059
+ * What testing a model costs now, as the menu says it: "free, all 34
1060
+ * reused", "~$0.10, 15 of 34 reused". Null before any cases.
1061
+ */
1062
+ function estimateText(
1003
1063
  estimate:
1004
- { answers: number; reused: number; costUsd: number | null } | undefined;
1005
- }) {
1064
+ { answers: number; reused: number; costUsd: number | null } | undefined,
1065
+ ): string | null {
1006
1066
  if (!estimate || estimate.answers === 0) return null;
1007
1067
  const { answers, reused, costUsd } = estimate;
1008
- const text =
1009
- reused === answers
1010
- ? `Free: all ${answers} reused`
1011
- : `${costUsd === null ? "Cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
1012
- return (
1013
- <Tip
1014
- text="What testing this model costs now. Answers an identical request gave in the last 7 days are reused for free."
1015
- id={`estimate-${id}`}
1016
- side="bottom"
1017
- align="end"
1018
- >
1019
- <span className="whitespace-nowrap text-xs text-muted">{text}</span>
1020
- </Tip>
1021
- );
1068
+ return reused === answers
1069
+ ? `free, all ${answers} reused`
1070
+ : `${costUsd === null ? "cost unknown" : `~${money(costUsd)}`}${reused ? `, ${reused} of ${answers} reused` : ""}`;
1022
1071
  }
1023
1072
 
1024
1073
  /**
@@ -1059,12 +1108,23 @@ function UnderAttack({
1059
1108
  title={attackLabel}
1060
1109
  className="tabular-nums"
1061
1110
  >
1062
- {resisted ? pct(resisted.resisted / resisted.of) : "—"}
1063
- {row.test.stale
1064
- ? " · out of date"
1065
- : row.test.failedAnswers
1066
- ? " · answers failed"
1067
- : ""}
1111
+ {row.test.stale ? (
1112
+ `${resisted ? pct(resisted.resisted / resisted.of) : "—"} · out of date`
1113
+ ) : row.test.failedAnswers && !resisted ? (
1114
+ <Tip
1115
+ term="attackFailures"
1116
+ side="bottom"
1117
+ id={`attack-failed-${row.key}`}
1118
+ >
1119
+ <span className="text-warn">
1120
+ {row.test.failedAnswers} failed: test again
1121
+ </span>
1122
+ </Tip>
1123
+ ) : resisted ? (
1124
+ pct(resisted.resisted / resisted.of)
1125
+ ) : (
1126
+ "—"
1127
+ )}
1068
1128
  </Link>
1069
1129
  );
1070
1130
  // Not tested yet: the model's Test runs the attacks with its cases.
@@ -1078,7 +1138,7 @@ function UnderAttack({
1078
1138
  * an injection suite, whose cases are made from its base suite's.
1079
1139
  */
1080
1140
  export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1081
- const { app, key, suite, health: h, choosesHere } = data;
1141
+ const { app, key, suite, health: h, choosesHere, splitBy } = data;
1082
1142
  const thin = h.tags.filter(([, n]) => n === 1).map(([t]) => t);
1083
1143
  const needs =
1084
1144
  h.easyToRetire.length ||
@@ -1096,105 +1156,212 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1096
1156
  {title(c)}
1097
1157
  </a>
1098
1158
  );
1099
- const { retireEasy, retireStaleDrafts } = app.actions;
1159
+ const { retireEasy, retireStaleDrafts, keepAnswer } = app.actions;
1100
1160
  const cases = (n: number) => `${n} ${n === 1 ? "case" : "cases"}`;
1101
1161
  const drafts = (n: number) => `${n} ${n === 1 ? "draft" : "drafts"}`;
1162
+ const { draftMore } = app.actions;
1163
+ const check = h.split.length > 0 || h.duplicates.length > 0;
1164
+ const retire = h.easyToRetire.length > 0 || h.staleDrafts.length > 0;
1102
1165
  return (
1103
1166
  <section className="space-y-3" aria-labelledby="answer-key-health">
1104
1167
  <h2 id="answer-key-health" className="text-lg font-semibold">
1105
1168
  Answer key health
1106
1169
  <InfoTip term="answerKeyHealth" />
1107
1170
  </h2>
1108
- <Card className="space-y-5 text-sm">
1109
- {h.easyToRetire.length > 0 && (
1110
- <div className="readable space-y-2">
1111
- <p>
1112
- <span className="font-medium">Easy cases</span>
1113
- <InfoTip term="easyCases" />: every current model gets{" "}
1114
- {cases(h.easy.length)} fully right, so they no longer tell models
1115
- apart. Retire {h.easyToRetire.length} and keep{" "}
1116
- {h.easy.length - h.easyToRetire.length} as a floor
1117
- <InfoTip term="easyFloor" />, so a test still catches a model that
1118
- breaks the basics. Recent tests are rescored for free.
1119
- </p>
1120
- {retireEasy && (
1121
- <form action={retireEasy}>
1122
- <input type="hidden" name="suite" value={key} />
1123
- <Submit variant="quiet">
1124
- Retire {h.easyToRetire.length} easy{" "}
1125
- {h.easyToRetire.length === 1 ? "case" : "cases"}
1126
- </Submit>
1127
- </form>
1171
+ {/* What to do, in order: fix doubtful answers, fill thin spots, prune. */}
1172
+ <Card className="space-y-6 text-sm">
1173
+ {check && (
1174
+ <div className="readable space-y-3">
1175
+ <h3 className="font-medium">Check these answers</h3>
1176
+ {h.split.length > 0 && (
1177
+ <div className="space-y-2">
1178
+ <p>
1179
+ Models split about evenly on {cases(h.split.length)}: some
1180
+ give the answer key&apos;s answer, some don&apos;t. For each,
1181
+ decide who&apos;s right. Keep the answer if it&apos;s right,
1182
+ fix it if the models were, or retire the case if there&apos;s
1183
+ no right answer.
1184
+ <InfoTip term="splitCases" />
1185
+ </p>
1186
+ <ul className="space-y-2">
1187
+ {h.split.map((c) => {
1188
+ const by = splitBy[c.id];
1189
+ const names = (xs: string[]) =>
1190
+ new Intl.ListFormat("en-US").format(xs);
1191
+ return (
1192
+ <li
1193
+ key={c.id}
1194
+ className="space-y-2 rounded-md bg-tint p-3"
1195
+ >
1196
+ <div className="font-medium">{caseLink(c)}</div>
1197
+ {by && (
1198
+ <p className="text-xs text-muted">
1199
+ {by.right.length > 0 &&
1200
+ `Gave the answer key's answer: ${names(by.right)}. `}
1201
+ {by.wrong.length > 0 &&
1202
+ `Didn't: ${names(by.wrong)}.`}
1203
+ </p>
1204
+ )}
1205
+ <div className="flex flex-wrap items-center gap-2">
1206
+ {keepAnswer && (
1207
+ <form action={keepAnswer}>
1208
+ <input type="hidden" name="suite" value={key} />
1209
+ <input type="hidden" name="case" value={c.id} />
1210
+ <Submit variant="quiet">
1211
+ The answer is right
1212
+ </Submit>
1213
+ </form>
1214
+ )}
1215
+ <a
1216
+ href={`#case-${c.id}`}
1217
+ className={`inline-flex items-center rounded-md px-3 py-1.5 text-sm ${QUIET_BUTTON}`}
1218
+ >
1219
+ Fix the answer
1220
+ </a>
1221
+ <form action={app.actions.retireCase}>
1222
+ <input type="hidden" name="suite" value={key} />
1223
+ <input type="hidden" name="case" value={c.id} />
1224
+ <Submit variant="quiet">Retire it</Submit>
1225
+ </form>
1226
+ </div>
1227
+ </li>
1228
+ );
1229
+ })}
1230
+ </ul>
1231
+ </div>
1232
+ )}
1233
+ {h.duplicates.length > 0 && (
1234
+ <div className="space-y-1">
1235
+ <p>
1236
+ These pairs share nearly all their words, so each counts
1237
+ twice. Keep the clearer one and retire the other.
1238
+ <InfoTip term="nearDuplicates" />
1239
+ </p>
1240
+ <ul className="list-disc space-y-0.5 pl-5">
1241
+ {h.duplicates.map(([a, b]) => (
1242
+ <li key={`${a.id}-${b.id}`}>
1243
+ {caseLink(a)} and {caseLink(b)}
1244
+ </li>
1245
+ ))}
1246
+ </ul>
1247
+ </div>
1128
1248
  )}
1129
1249
  </div>
1130
1250
  )}
1131
- {h.split.length > 0 && (
1132
- <div className="readable space-y-1">
1133
- <p>
1134
- <span className="font-medium">Split cases</span>
1135
- <InfoTip term="splitCases" />: models divide about evenly on{" "}
1136
- {cases(h.split.length)}. The answer may be unclear, so check it
1137
- first.
1138
- </p>
1139
- <ul className="list-disc space-y-0.5 pl-5">
1140
- {h.split.map((c) => (
1141
- <li key={c.id}>{caseLink(c)}</li>
1142
- ))}
1143
- </ul>
1144
- </div>
1145
- )}
1146
- {h.duplicates.length > 0 && (
1147
- <div className="readable space-y-1">
1148
- <p>
1149
- <span className="font-medium">Near-duplicates</span>
1150
- <InfoTip term="nearDuplicates" />: these pairs share nearly all
1151
- their words. Keep the clearer one.
1152
- </p>
1153
- <ul className="list-disc space-y-0.5 pl-5">
1154
- {h.duplicates.map(([a, b]) => (
1155
- <li key={`${a.id}-${b.id}`}>
1156
- {caseLink(a)} and {caseLink(b)}
1157
- </li>
1158
- ))}
1159
- </ul>
1160
- </div>
1161
- )}
1162
- {h.staleDrafts.length > 0 && (
1163
- <div className="readable space-y-2">
1164
- <p>
1165
- <span className="font-medium">Old drafts</span>
1166
- <InfoTip term="oldDrafts" />: {drafts(h.staleDrafts.length)}{" "}
1167
- nobody reviewed in 30 days. The weekly check retires them on its
1168
- own.
1251
+ {thin.length > 0 && (
1252
+ <div className="space-y-2">
1253
+ <h3 className="font-medium">Add cases here</h3>
1254
+ <p className="readable">
1255
+ {thin.length} {thin.length === 1 ? "topic has" : "topics have"}{" "}
1256
+ only one case, so the score on each rests on a single example: one
1257
+ mistake swings it, and a fix can&apos;t be confirmed. Add a case
1258
+ or two to each.
1259
+ <InfoTip term="tagCoverage" />
1169
1260
  </p>
1170
- {retireStaleDrafts && (
1171
- <form action={retireStaleDrafts}>
1261
+ {draftMore && suite.draftMore ? (
1262
+ <form action={draftMore} className="space-y-2">
1172
1263
  <input type="hidden" name="suite" value={key} />
1264
+ <ul className="flex flex-wrap gap-1.5">
1265
+ {thin.map((t) => (
1266
+ <li key={t}>
1267
+ <label className="inline-flex cursor-pointer items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800 has-[:checked]:bg-amber-300 dark:bg-amber-500/15 dark:text-amber-200 dark:has-[:checked]:bg-amber-500/40">
1268
+ <input
1269
+ type="checkbox"
1270
+ name="topic"
1271
+ value={t}
1272
+ className="h-3 w-3 accent-amber-700"
1273
+ />
1274
+ {t}
1275
+ </label>
1276
+ </li>
1277
+ ))}
1278
+ </ul>
1173
1279
  <Submit variant="quiet">
1174
- Retire {h.staleDrafts.length} old{" "}
1175
- {h.staleDrafts.length === 1 ? "draft" : "drafts"} now
1280
+ Draft cases for the topics you picked
1176
1281
  </Submit>
1282
+ <p className="readable text-xs text-muted">
1283
+ Two drafts a topic, to confirm like any draft. Pick none to
1284
+ cover them all.
1285
+ </p>
1177
1286
  </form>
1287
+ ) : (
1288
+ <>
1289
+ <ul className="flex flex-wrap gap-1.5">
1290
+ {thin.map((t) => (
1291
+ <li key={t}>
1292
+ <a
1293
+ href={`#add-case=${encodeURIComponent(t)}`}
1294
+ className="inline-flex rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800 hover:underline dark:bg-amber-500/15 dark:text-amber-200"
1295
+ >
1296
+ {t}
1297
+ </a>
1298
+ </li>
1299
+ ))}
1300
+ </ul>
1301
+ <p className="readable text-xs text-muted">
1302
+ Pick a topic to add a case with it already tagged.
1303
+ </p>
1304
+ </>
1178
1305
  )}
1306
+ <details className="group">
1307
+ <summary className="cursor-pointer text-muted">
1308
+ Show all topics
1309
+ </summary>
1310
+ <ul className="mt-2 flex flex-wrap gap-1.5">
1311
+ {h.tags.map(([t, n]) => (
1312
+ <li key={t}>
1313
+ <Chip tone={n === 1 ? "warn" : "neutral"}>
1314
+ {t} · {n}
1315
+ </Chip>
1316
+ </li>
1317
+ ))}
1318
+ </ul>
1319
+ </details>
1179
1320
  </div>
1180
1321
  )}
1181
- {thin.length > 0 && (
1182
- <div className="space-y-2">
1183
- <p className="readable">
1184
- <span className="font-medium">Coverage</span>
1185
- <InfoTip term="tagCoverage" />: {thin.length}{" "}
1186
- {thin.length === 1 ? "tag has" : "tags have"} a single case. A new
1187
- case there tells you the most.
1188
- </p>
1189
- <ul className="flex flex-wrap gap-1.5">
1190
- {h.tags.map(([t, n]) => (
1191
- <li key={t}>
1192
- <Chip tone={n === 1 ? "warn" : "neutral"}>
1193
- {t} · {n}
1194
- </Chip>
1195
- </li>
1196
- ))}
1197
- </ul>
1322
+ {retire && (
1323
+ <div className="readable space-y-3">
1324
+ <h3 className="font-medium">Retire these</h3>
1325
+ {h.easyToRetire.length > 0 && (
1326
+ <div className="space-y-2">
1327
+ <p>
1328
+ Every current model gets {cases(h.easy.length)} fully right,
1329
+ so they no longer tell models apart. Retire{" "}
1330
+ {h.easyToRetire.length} and keep{" "}
1331
+ {h.easy.length - h.easyToRetire.length} as a floor, so a test
1332
+ still catches a model that breaks the basics. Recent tests are
1333
+ rescored for free.
1334
+ <InfoTip term="easyCases" />
1335
+ </p>
1336
+ {retireEasy && (
1337
+ <form action={retireEasy}>
1338
+ <input type="hidden" name="suite" value={key} />
1339
+ <Submit variant="quiet">
1340
+ Retire {h.easyToRetire.length} easy{" "}
1341
+ {h.easyToRetire.length === 1 ? "case" : "cases"}
1342
+ </Submit>
1343
+ </form>
1344
+ )}
1345
+ </div>
1346
+ )}
1347
+ {h.staleDrafts.length > 0 && (
1348
+ <div className="space-y-2">
1349
+ <p>
1350
+ {drafts(h.staleDrafts.length)} nobody reviewed in 30 days. The
1351
+ weekly check retires them on its own.
1352
+ <InfoTip term="oldDrafts" />
1353
+ </p>
1354
+ {retireStaleDrafts && (
1355
+ <form action={retireStaleDrafts}>
1356
+ <input type="hidden" name="suite" value={key} />
1357
+ <Submit variant="quiet">
1358
+ Retire {h.staleDrafts.length} old{" "}
1359
+ {h.staleDrafts.length === 1 ? "draft" : "drafts"} now
1360
+ </Submit>
1361
+ </form>
1362
+ )}
1363
+ </div>
1364
+ )}
1198
1365
  </div>
1199
1366
  )}
1200
1367
  </Card>