@crowandraven/evalkeeper 0.5.0 → 0.7.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 (101) hide show
  1. package/README.md +7 -0
  2. package/dist/activity.d.ts +58 -0
  3. package/dist/activity.js +125 -0
  4. package/dist/activity.js.map +1 -0
  5. package/dist/assertExpect.d.ts +52 -0
  6. package/dist/assertExpect.js +104 -0
  7. package/dist/assertExpect.js.map +1 -0
  8. package/dist/blind.d.ts +79 -0
  9. package/dist/blind.js +113 -0
  10. package/dist/blind.js.map +1 -0
  11. package/dist/cli/addPages.d.ts +1 -1
  12. package/dist/cli/addPages.js +4 -1
  13. package/dist/cli/addPages.js.map +1 -1
  14. package/dist/cli/main.d.ts +1 -1
  15. package/dist/cli/main.js +4 -3
  16. package/dist/cli/main.js.map +1 -1
  17. package/dist/compare.d.ts +38 -0
  18. package/dist/compare.js +62 -0
  19. package/dist/compare.js.map +1 -1
  20. package/dist/glossary.d.ts +20 -0
  21. package/dist/glossary.js +20 -0
  22. package/dist/glossary.js.map +1 -1
  23. package/dist/health.js +5 -3
  24. package/dist/health.js.map +1 -1
  25. package/dist/importCases.d.ts +76 -5
  26. package/dist/importCases.js +114 -14
  27. package/dist/importCases.js.map +1 -1
  28. package/dist/index.d.ts +4 -0
  29. package/dist/index.js +4 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/memoryStore.js +3 -1
  32. package/dist/memoryStore.js.map +1 -1
  33. package/dist/readCheck.d.ts +116 -0
  34. package/dist/readCheck.js +321 -0
  35. package/dist/readCheck.js.map +1 -0
  36. package/dist/runner.d.ts +7 -0
  37. package/dist/runner.js +25 -3
  38. package/dist/runner.js.map +1 -1
  39. package/dist/settings.d.ts +81 -3
  40. package/dist/settings.js +160 -23
  41. package/dist/settings.js.map +1 -1
  42. package/dist/store.d.ts +10 -3
  43. package/dist/suggest.d.ts +10 -1
  44. package/dist/suggest.js +22 -4
  45. package/dist/suggest.js.map +1 -1
  46. package/dist/suiteContract.d.ts +17 -0
  47. package/dist/suiteContract.js +69 -0
  48. package/dist/suiteContract.js.map +1 -0
  49. package/dist/suites/crisisRisk.d.ts +83 -0
  50. package/dist/suites/crisisRisk.js +176 -0
  51. package/dist/suites/crisisRisk.js.map +1 -0
  52. package/dist/suites/crisisRiskCases.d.ts +40 -0
  53. package/dist/suites/crisisRiskCases.js +179 -0
  54. package/dist/suites/crisisRiskCases.js.map +1 -0
  55. package/dist/suites/index.d.ts +9 -0
  56. package/dist/suites/index.js +10 -0
  57. package/dist/suites/index.js.map +1 -0
  58. package/dist/testing.d.ts +127 -11
  59. package/dist/testing.js +378 -104
  60. package/dist/testing.js.map +1 -1
  61. package/dist/types.d.ts +92 -0
  62. package/dist/types.js +68 -0
  63. package/dist/types.js.map +1 -1
  64. package/dist/weekly.d.ts +21 -3
  65. package/dist/weekly.js +18 -1
  66. package/dist/weekly.js.map +1 -1
  67. package/package.json +5 -1
  68. package/src/activity.ts +154 -0
  69. package/src/assertExpect.ts +168 -0
  70. package/src/blind.ts +138 -0
  71. package/src/cli/addPages.ts +4 -1
  72. package/src/cli/main.ts +4 -3
  73. package/src/compare.ts +85 -0
  74. package/src/glossary.ts +36 -0
  75. package/src/health.ts +5 -3
  76. package/src/importCases.ts +172 -33
  77. package/src/index.ts +4 -0
  78. package/src/memoryStore.ts +2 -1
  79. package/src/readCheck.ts +458 -0
  80. package/src/runner.ts +33 -4
  81. package/src/settings.ts +192 -26
  82. package/src/store.ts +11 -3
  83. package/src/suggest.ts +33 -4
  84. package/src/suiteContract.ts +101 -0
  85. package/src/suites/crisisRisk.ts +250 -0
  86. package/src/suites/crisisRiskCases.ts +205 -0
  87. package/src/suites/index.ts +9 -0
  88. package/src/testing.ts +508 -109
  89. package/src/types.ts +141 -0
  90. package/src/weekly.ts +39 -3
  91. package/templates/app/evals/[suite]/compare/page.tsx +375 -0
  92. package/templates/app/evals/[suite]/page.tsx +55 -19
  93. package/templates/app/evals/[suite]/rate/page.tsx +133 -0
  94. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +12 -0
  95. package/templates/app/evals/[suite]/side-by-side/page.tsx +300 -0
  96. package/templates/components/evalkeeper/DisagreementChip.tsx +35 -0
  97. package/templates/components/evalkeeper/RollBack.tsx +21 -1
  98. package/templates/components/evalkeeper/SettingsHistory.tsx +20 -2
  99. package/templates/components/evalkeeper/WeeklyCheck.tsx +34 -2
  100. package/templates/lib/evalkeeper/actions.ts +68 -4
  101. package/templates/lib/evalkeeper/weekly.ts +27 -4
@@ -108,10 +108,13 @@ export default async function SuitePage({
108
108
  Suggested
109
109
  <InfoTip term="suggestion" />
110
110
  </h2>
111
- <form action={useSuggestion}>
112
- <input type="hidden" name="suite" value={key} />
113
- <Submit>Use these</Submit>
114
- </form>
111
+ {/* Retesting live changes nothing until the fallback would. */}
112
+ {!(s.retestLive && (!s.fallback || s.fallback.fallback)) && (
113
+ <form action={useSuggestion}>
114
+ <input type="hidden" name="suite" value={key} />
115
+ <Submit>Use these</Submit>
116
+ </form>
117
+ )}
115
118
  </div>
116
119
  <p>
117
120
  Live: <strong>{s.live.label}</strong>
@@ -133,10 +136,18 @@ export default async function SuitePage({
133
136
  <section className="space-y-3">
134
137
  <div className="flex items-center justify-between gap-4">
135
138
  <h2 className="text-lg font-semibold">Models</h2>
136
- <form action={testAll}>
137
- <input type="hidden" name="suite" value={key} />
138
- <Submit variant="quiet">Test every model</Submit>
139
- </form>
139
+ <div className="flex items-center gap-4">
140
+ <Link
141
+ href={evalsPath(key, "compare")}
142
+ className="text-sm text-muted hover:text-ink"
143
+ >
144
+ Compare two tests
145
+ </Link>
146
+ <form action={testAll}>
147
+ <input type="hidden" name="suite" value={key} />
148
+ <Submit variant="quiet">Test every model</Submit>
149
+ </form>
150
+ </div>
140
151
  </div>
141
152
  <Card className="overflow-x-auto p-0 lg:overflow-visible">
142
153
  <table className="w-full text-sm">
@@ -290,7 +301,19 @@ export default async function SuitePage({
290
301
  <td className="p-3 tabular-nums">
291
302
  {r.test ? perAnswer(r.test.costPerAnswer) : "—"}
292
303
  </td>
293
- <td className="p-3">{r.vsLive ? VS[r.vsLive] : "—"}</td>
304
+ <td className="p-3">
305
+ {r.vsLive && live?.test && r.test && !r.live ? (
306
+ <Link
307
+ href={`${evalsPath(key, "compare")}?${new URLSearchParams({ a: live.test.runId, b: r.test.runId })}`}
308
+ >
309
+ {VS[r.vsLive]}
310
+ </Link>
311
+ ) : r.vsLive ? (
312
+ VS[r.vsLive]
313
+ ) : (
314
+ "—"
315
+ )}
316
+ </td>
294
317
  <td className="p-3">
295
318
  <div className="flex flex-col items-end gap-0.5">
296
319
  <div className="flex justify-end gap-2">
@@ -406,7 +429,8 @@ export default async function SuitePage({
406
429
  </div>
407
430
  </section>
408
431
 
409
- <section className="space-y-3">
432
+ {/* The weekly check links here to review drafts. */}
433
+ <section id="answer-key" className="scroll-mt-4 space-y-3">
410
434
  <AnswerKey
411
435
  suite={suite}
412
436
  rows={rows}
@@ -417,15 +441,27 @@ export default async function SuitePage({
417
441
  </h2>
418
442
  }
419
443
  tools={
420
- <form action={rescore}>
421
- <input type="hidden" name="suite" value={key} />
422
- <Tip control term="rescore" side="bottom" align="end">
423
- <IconSubmit
424
- label="Rescore tests"
425
- icon={<RotateCw aria-hidden className="h-4 w-4" />}
426
- />
427
- </Tip>
428
- </form>
444
+ <>
445
+ {suite.caseKind === "imported" && suite.labelFromForm && (
446
+ <Tip control term="rateBlind" side="bottom" align="end">
447
+ <Link
448
+ href={evalsPath(key, "rate")}
449
+ className="inline-flex items-center rounded-md border border-accent/40 bg-card px-3 py-1.5 text-sm text-accent hover:bg-accent/10"
450
+ >
451
+ Rate blind
452
+ </Link>
453
+ </Tip>
454
+ )}
455
+ <form action={rescore}>
456
+ <input type="hidden" name="suite" value={key} />
457
+ <Tip control term="rescore" side="bottom" align="end">
458
+ <IconSubmit
459
+ label="Rescore tests"
460
+ icon={<RotateCw aria-hidden className="h-4 w-4" />}
461
+ />
462
+ </Tip>
463
+ </form>
464
+ </>
429
465
  }
430
466
  />
431
467
  </section>
@@ -0,0 +1,133 @@
1
+ import Link from "next/link";
2
+ import { notFound } from "next/navigation";
3
+ import { rateQueue } from "@crowandraven/evalkeeper";
4
+ import { FieldValues, Fields } from "@/components/evalkeeper/Fields";
5
+ import { Submit } from "@/components/evalkeeper/Submit";
6
+ import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
7
+ import { BackLink, Card } from "@/components/evalkeeper/ui";
8
+ import { requireAdmin, SUITE_BY_KEY, store } from "@/lib/evalkeeper";
9
+ import { rateBlind, skipCase } from "@/lib/evalkeeper/actions";
10
+ import { evalsPath } from "@/lib/evalkeeper/paths";
11
+
12
+ export const dynamic = "force-dynamic";
13
+
14
+ /**
15
+ * Rating an imported suite's cases blind: one case at a time, the oldest
16
+ * this person hasn't rated or skipped, shown by its input alone. The app's
17
+ * output, what anyone did with the item, other answers, tags, and notes
18
+ * stay hidden, because any of them anchors the rating.
19
+ */
20
+ export default async function RateBlindPage({
21
+ params,
22
+ }: {
23
+ params: Promise<{ suite: string }>;
24
+ }) {
25
+ const admin = await requireAdmin();
26
+ const { suite: key } = await params;
27
+ const suite = SUITE_BY_KEY[key];
28
+ const fields = suite?.fields;
29
+ if (
30
+ !suite ||
31
+ suite.caseKind !== "imported" ||
32
+ !fields ||
33
+ !suite.labelFromForm
34
+ )
35
+ notFound();
36
+ const queue = rateQueue(await store.listCases(key), admin.id);
37
+ const next = queue.next;
38
+ const input = next ? suite.input.parse(next.input) : null;
39
+
40
+ return (
41
+ <div className="space-y-8">
42
+ <div className="space-y-2">
43
+ <BackLink href={evalsPath(key)}>{suite.label}</BackLink>
44
+ <h1 className="text-2xl font-semibold">
45
+ Rate blind
46
+ <InfoTip term="rateBlind" />
47
+ </h1>
48
+ <p className="readable text-muted">
49
+ One case at a time, from its input alone. You won&apos;t see what the
50
+ app decided or what anyone did with it, so nothing anchors your
51
+ answer. Give the answer and why, or skip it.
52
+ </p>
53
+ <p className="text-sm text-muted">
54
+ <Tip term="rateQueue" id="rate-queue">
55
+ <span>
56
+ {queue.rated} rated · {queue.skipped} skipped · {queue.left} left
57
+ </span>
58
+ </Tip>
59
+ </p>
60
+ </div>
61
+
62
+ {next && input !== null ? (
63
+ <Card className="space-y-6">
64
+ <section className="space-y-3">
65
+ <h2 className="font-semibold">{suite.title(input)}</h2>
66
+ {fields.input.length ? (
67
+ <FieldValues
68
+ fields={fields.input}
69
+ values={next.input}
70
+ prefix="rate-in-"
71
+ />
72
+ ) : (
73
+ <pre className="readable whitespace-pre-wrap text-sm">
74
+ {suite.describe?.(input) ?? JSON.stringify(next.input, null, 2)}
75
+ </pre>
76
+ )}
77
+ </section>
78
+
79
+ {/* Keyed by case, so the next case starts with an empty form. */}
80
+ <form key={next.id} action={rateBlind} className="space-y-4">
81
+ <input type="hidden" name="suite" value={key} />
82
+ <input type="hidden" name="case" value={next.id} />
83
+ <Fields fields={fields.label} prefix="rate-" />
84
+ <div className="space-y-1">
85
+ <label
86
+ htmlFor="rate-reason"
87
+ className="block text-sm font-medium"
88
+ >
89
+ Why
90
+ </label>
91
+ <textarea
92
+ id="rate-reason"
93
+ name="reason"
94
+ required
95
+ rows={3}
96
+ className="w-full rounded-md border border-line bg-card px-3 py-2 text-sm focus:border-accent focus:outline-none"
97
+ />
98
+ <p className="readable text-xs text-muted">
99
+ What in the input decided it, in a sentence. Kept with your
100
+ answer, so anyone checking it later sees your reasoning.
101
+ </p>
102
+ </div>
103
+ <p className="readable text-xs text-muted">
104
+ Saves your own confirmed answer beside anyone else&apos;s, and
105
+ rescores tests for free.
106
+ </p>
107
+ <Submit>Save rating</Submit>
108
+ </form>
109
+
110
+ <form action={skipCase}>
111
+ <input type="hidden" name="suite" value={key} />
112
+ <input type="hidden" name="case" value={next.id} />
113
+ <Tip control term="skip" id="rate-skip">
114
+ <Submit variant="quiet">Skip</Submit>
115
+ </Tip>
116
+ </form>
117
+ </Card>
118
+ ) : (
119
+ <Card className="space-y-2">
120
+ <h2 className="font-semibold">Nothing left for you to rate</h2>
121
+ <p className="readable text-sm text-muted">
122
+ You&apos;ve rated or skipped every case in this suite.
123
+ {queue.skipped > 0 &&
124
+ " Cases you skipped are still in the answer key, where you can write their answers."}
125
+ </p>
126
+ <Link href={evalsPath(key)} className="text-sm text-accent">
127
+ Back to the answer key
128
+ </Link>
129
+ </Card>
130
+ )}
131
+ </div>
132
+ );
133
+ }
@@ -1,3 +1,4 @@
1
+ import Link from "next/link";
1
2
  import { notFound } from "next/navigation";
2
3
  import { allPassed, money, summarize } from "@crowandraven/evalkeeper";
3
4
  import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
@@ -41,6 +42,17 @@ export default async function RunPage({
41
42
  <p className="text-sm text-muted">
42
43
  {run.startedAt.toLocaleString()} · {run.status.toLowerCase()}
43
44
  {metrics && ` · spent ${money(metrics.costUsd)}`}
45
+ {run.status === "SUCCEEDED" && (
46
+ <>
47
+ {" · "}
48
+ <Link
49
+ href={`${evalsPath(key, "compare")}?${new URLSearchParams({ b: runId })}`}
50
+ className="hover:text-ink"
51
+ >
52
+ Compare with another test
53
+ </Link>
54
+ </>
55
+ )}
44
56
  </p>
45
57
  {run.error && <p className="readable text-bad">{run.error}</p>}
46
58
  </div>
@@ -0,0 +1,300 @@
1
+ import Link from "next/link";
2
+ import { notFound } from "next/navigation";
3
+ import { ArrowLeft, ArrowRight, Check, Minus, X } from "lucide-react";
4
+ import {
5
+ aroundCase,
6
+ type AnySuite,
7
+ type CheckResult,
8
+ type OutputRecord,
9
+ type RunRecord,
10
+ } from "@crowandraven/evalkeeper";
11
+ import { DisagreementChip } from "@/components/evalkeeper/DisagreementChip";
12
+ import { FieldValues } from "@/components/evalkeeper/Fields";
13
+ import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
14
+ import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
15
+ import { MODELS, requireAdmin, runner, store } from "@/lib/evalkeeper";
16
+ import { evalsPath } from "@/lib/evalkeeper/paths";
17
+
18
+ export const dynamic = "force-dynamic";
19
+
20
+ /** A search parameter as one string, or null when it's missing or repeated. */
21
+ const one = (v: string | string[] | undefined) =>
22
+ typeof v === "string" && v ? v : null;
23
+
24
+ /**
25
+ * Two tests' answers to one case, side by side with the expected answer
26
+ * and what each check found, and previous and next through the cases the
27
+ * two graded differently. `a` is the test in place, `b` the challenger,
28
+ * and `case` the case (the first disagreement when left out).
29
+ */
30
+ export default async function SideBySidePage({
31
+ params,
32
+ searchParams,
33
+ }: {
34
+ params: Promise<{ suite: string }>;
35
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
36
+ }) {
37
+ await requireAdmin();
38
+ const { suite: key } = await params;
39
+ const sp = await searchParams;
40
+ const a = one(sp.a);
41
+ const b = one(sp.b);
42
+ if (!a || !b) notFound();
43
+ const result = await runner.compare(key, a, b);
44
+ if (!result) notFound();
45
+ const { suite, disagreements } = result;
46
+ const caseId = one(sp.case) ?? disagreements[0]?.caseId ?? null;
47
+ const compareHref = `${evalsPath(key, "compare")}?${new URLSearchParams({ a, b })}`;
48
+ const back = <BackLink href={compareHref}>Compare</BackLink>;
49
+ if (!caseId)
50
+ return (
51
+ <div className="space-y-4">
52
+ {back}
53
+ <h1 className="text-2xl font-semibold">Side by side</h1>
54
+ <p className="readable text-muted">
55
+ The two tests graded every shared case alike: there&apos;s nothing to
56
+ read side by side.
57
+ </p>
58
+ </div>
59
+ );
60
+
61
+ const [cases, outA, outB] = await Promise.all([
62
+ store.listCases(key, { includeRetired: true }),
63
+ store.listOutputs(a),
64
+ store.listOutputs(b),
65
+ ]);
66
+ const c = cases.find((x) => x.id === caseId);
67
+ if (!c) notFound();
68
+ const input = suite.input.parse(c.input);
69
+ const expected =
70
+ c.labels.find((l) => l.status === "CONFIRMED") ??
71
+ c.labels.find((l) => l.status === "PROVISIONAL");
72
+ const here = aroundCase(disagreements, caseId);
73
+ const d = disagreements[here.index];
74
+ const to = (id: string) =>
75
+ `${evalsPath(key, "side-by-side")}?${new URLSearchParams({ a, b, case: id })}`;
76
+ const byRepeat = (os: OutputRecord[]) =>
77
+ os.filter((o) => o.caseId === caseId).sort((x, y) => x.repeat - y.repeat);
78
+
79
+ return (
80
+ <div className="space-y-6">
81
+ {back}
82
+ <div className="space-y-2">
83
+ <p className="text-sm text-muted">
84
+ Side by side
85
+ <InfoTip term="sideBySide" />
86
+ {" · "}
87
+ {suite.label}
88
+ </p>
89
+ <h1 className="text-2xl font-semibold">{suite.title(input)}</h1>
90
+ <div className="flex flex-wrap items-center justify-between gap-3">
91
+ <span className="flex items-center gap-2 text-sm text-muted">
92
+ {d ? (
93
+ <>
94
+ <DisagreementChip kind={d.kind} id="kind" />
95
+ <Tip term="disagreements" id="position">
96
+ <span>
97
+ {here.index + 1} of {disagreements.length} where they differ
98
+ </span>
99
+ </Tip>
100
+ </>
101
+ ) : (
102
+ <span>Both tests graded this case alike.</span>
103
+ )}
104
+ </span>
105
+ <nav aria-label="Cases where they differ" className="flex gap-2">
106
+ {here.previous ? (
107
+ <StepLink href={to(here.previous)} dir="previous" />
108
+ ) : (
109
+ <StepLink dir="previous" />
110
+ )}
111
+ {here.next ? (
112
+ <StepLink href={to(here.next)} dir="next" />
113
+ ) : (
114
+ <StepLink dir="next" />
115
+ )}
116
+ </nav>
117
+ </div>
118
+ </div>
119
+
120
+ <Card className="grid gap-5 text-sm md:grid-cols-2">
121
+ <section className="space-y-2">
122
+ <h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
123
+ Input
124
+ </h2>
125
+ {suite.fields ? (
126
+ <FieldValues
127
+ fields={suite.fields.input}
128
+ values={c.input}
129
+ prefix="in-"
130
+ />
131
+ ) : (
132
+ <pre className="readable whitespace-pre-wrap text-xs">
133
+ {suite.describe?.(input) ?? JSON.stringify(c.input, null, 2)}
134
+ </pre>
135
+ )}
136
+ </section>
137
+ <section className="space-y-2">
138
+ <h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
139
+ Expected answer
140
+ <InfoTip term="expectedAnswer" />
141
+ </h2>
142
+ {!expected ? (
143
+ <p className="readable text-muted">No answer in use.</p>
144
+ ) : suite.fields ? (
145
+ <FieldValues
146
+ fields={suite.fields.label}
147
+ values={expected.value}
148
+ prefix="expected-"
149
+ />
150
+ ) : (
151
+ <pre className="readable whitespace-pre-wrap text-xs">
152
+ {JSON.stringify(expected.value, null, 2)}
153
+ </pre>
154
+ )}
155
+ </section>
156
+ </Card>
157
+
158
+ <div className="grid gap-4 md:grid-cols-2">
159
+ <Side
160
+ role="inPlace"
161
+ run={result.a}
162
+ outputs={byRepeat(outA)}
163
+ suite={suite}
164
+ score={d?.champion ?? null}
165
+ runHref={evalsPath(key, "runs", a)}
166
+ />
167
+ <Side
168
+ role="challenger"
169
+ run={result.b}
170
+ outputs={byRepeat(outB)}
171
+ suite={suite}
172
+ score={d?.challenger ?? null}
173
+ runHref={evalsPath(key, "runs", b)}
174
+ />
175
+ </div>
176
+ </div>
177
+ );
178
+ }
179
+
180
+ /** A link to the previous or next disagreement, or a dimmed one at either end. */
181
+ function StepLink({ href, dir }: { href?: string; dir: "previous" | "next" }) {
182
+ const label = dir === "previous" ? "Previous" : "Next";
183
+ const body =
184
+ dir === "previous" ? (
185
+ <>
186
+ <ArrowLeft aria-hidden className="h-4 w-4" />
187
+ {label}
188
+ </>
189
+ ) : (
190
+ <>
191
+ {label}
192
+ <ArrowRight aria-hidden className="h-4 w-4" />
193
+ </>
194
+ );
195
+ const cls =
196
+ "inline-flex items-center gap-1 rounded-md border border-line px-3 py-1.5 text-sm";
197
+ return href ? (
198
+ <Link href={href} className={`${cls} hover:bg-tint`}>
199
+ {body}
200
+ </Link>
201
+ ) : (
202
+ <span aria-disabled="true" className={`${cls} text-muted opacity-60`}>
203
+ {body}
204
+ </span>
205
+ );
206
+ }
207
+
208
+ /** One test's answers to the case, with what each check found. */
209
+ function Side({
210
+ role,
211
+ run,
212
+ outputs,
213
+ suite,
214
+ score,
215
+ runHref,
216
+ }: {
217
+ role: "inPlace" | "challenger";
218
+ run: RunRecord;
219
+ outputs: OutputRecord[];
220
+ suite: AnySuite;
221
+ score: number | null;
222
+ runHref: string;
223
+ }) {
224
+ const label = (k: string) =>
225
+ suite.checks.find((x) => x.key === k)?.label ?? k;
226
+ return (
227
+ <Card className="space-y-4 text-sm">
228
+ <div className="space-y-1">
229
+ <p className="text-xs font-semibold uppercase tracking-wide text-muted">
230
+ {role === "inPlace" ? "In place" : "Challenger"}
231
+ <InfoTip term={role} id={`${role}-side`} />
232
+ </p>
233
+ <h2 className="text-lg font-semibold">
234
+ <Link href={runHref} className="hover:underline">
235
+ {MODELS[run.model]?.label ?? run.model}
236
+ </Link>
237
+ </h2>
238
+ {score !== null && (
239
+ <Tip term="caseScore" id={`${role}-score`}>
240
+ <span className="text-muted">Scored {pct(score)} on this case</span>
241
+ </Tip>
242
+ )}
243
+ </div>
244
+ {outputs.length === 0 && (
245
+ <p className="readable text-muted">This test has no answer here.</p>
246
+ )}
247
+ {outputs.map((o) => {
248
+ const checks: CheckResult[] = o.scores ?? [];
249
+ return (
250
+ <section key={o.id} className="space-y-3 rounded-md bg-tint p-3">
251
+ {outputs.length > 1 && (
252
+ <p className="text-xs text-muted">Repeat {o.repeat + 1}</p>
253
+ )}
254
+ {o.error ? (
255
+ <p className="readable text-bad">No answer: {o.error}</p>
256
+ ) : suite.fields && suite.labelFromOutput ? (
257
+ <FieldValues
258
+ fields={suite.fields.label}
259
+ values={suite.labelFromOutput(o.output)}
260
+ prefix={`${role}-${o.repeat}-`}
261
+ />
262
+ ) : (
263
+ <pre className="readable whitespace-pre-wrap text-xs">
264
+ {JSON.stringify(o.output, null, 2)}
265
+ </pre>
266
+ )}
267
+ {checks.length > 0 && (
268
+ <ul className="space-y-1">
269
+ {checks.map((x) => (
270
+ <li key={x.key} className="flex items-start gap-1.5">
271
+ {x.pass === null ? (
272
+ <Minus
273
+ aria-label="Doesn't apply"
274
+ className="mt-0.5 h-4 w-4 shrink-0 text-muted"
275
+ />
276
+ ) : x.pass ? (
277
+ <Check
278
+ aria-label="Passed"
279
+ className="mt-0.5 h-4 w-4 shrink-0 text-good"
280
+ />
281
+ ) : (
282
+ <X
283
+ aria-label="Failed"
284
+ className="mt-0.5 h-4 w-4 shrink-0 text-warn"
285
+ />
286
+ )}
287
+ <span className="readable">
288
+ {label(x.key)}
289
+ {x.note && <span className="text-muted">: {x.note}</span>}
290
+ </span>
291
+ </li>
292
+ ))}
293
+ </ul>
294
+ )}
295
+ </section>
296
+ );
297
+ })}
298
+ </Card>
299
+ );
300
+ }
@@ -0,0 +1,35 @@
1
+ import type { DisagreementKind } from "@crowandraven/evalkeeper";
2
+ import { Tip } from "./Tip";
3
+ import { Chip } from "./ui";
4
+
5
+ /** How each kind of disagreement shows: its chip and its glossary entry. */
6
+ const KIND = {
7
+ broke: { text: "Broke", tone: "serious", term: "broke" },
8
+ fixed: { text: "Fixed", tone: "live", term: "fixed" },
9
+ differ: {
10
+ text: "Missed differently",
11
+ tone: "warn",
12
+ term: "missedDifferently",
13
+ },
14
+ } as const satisfies Record<DisagreementKind, unknown>;
15
+
16
+ /**
17
+ * How two tests disagree on a case (broke, fixed, or missed differently),
18
+ * as a chip with its tooltip. `id` keeps tooltip ids unique on a list.
19
+ */
20
+ export function DisagreementChip({
21
+ kind,
22
+ id,
23
+ align,
24
+ }: {
25
+ kind: DisagreementKind;
26
+ id: string;
27
+ align?: "center" | "end";
28
+ }) {
29
+ const k = KIND[kind];
30
+ return (
31
+ <Tip term={k.term} id={id} {...(align ? { align } : {})}>
32
+ <Chip tone={k.tone}>{k.text}</Chip>
33
+ </Tip>
34
+ );
35
+ }
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useState } from "react";
4
+ import type { ChangeKind } from "@crowandraven/evalkeeper";
4
5
  import { rollBackSettings } from "@/lib/evalkeeper/actions";
5
6
  import { Submit } from "./Submit";
6
7
  import { Tip } from "./Tip";
@@ -8,19 +9,24 @@ import { Tip } from "./Tip";
8
9
  /**
9
10
  * Rolls a feature back to an earlier version. The button stays off until
10
11
  * there's a note saying why: the note is kept with the version, for
11
- * whoever reads the history next.
12
+ * whoever reads the history next. Only settings go back, so a version made
13
+ * by an instructions change says the instructions stay as they are now.
12
14
  */
13
15
  export function RollBack({
14
16
  suite,
15
17
  versionId,
16
18
  number,
19
+ kind,
17
20
  }: {
18
21
  suite: string;
19
22
  versionId: string;
20
23
  number: number;
24
+ /** How the version was made, for what rolling back to it does. */
25
+ kind?: ChangeKind;
21
26
  }) {
22
27
  const [reason, setReason] = useState("");
23
28
  const missing = reason.trim() === "";
29
+ const note = WHAT_GOES_BACK[kind ?? "CHANGE"]?.(number);
24
30
  const button = (
25
31
  <Submit variant="quiet" disabled={missing}>
26
32
  Roll back to v{number}
@@ -54,9 +60,23 @@ export function RollBack({
54
60
  >
55
61
  {button}
56
62
  </Tip>
63
+ ) : note ? (
64
+ <Tip text={note} id={`rollback-${versionId}`}>
65
+ {button}
66
+ </Tip>
57
67
  ) : (
58
68
  button
59
69
  )}
60
70
  </form>
61
71
  );
62
72
  }
73
+
74
+ /** What rolling back to a version does, when it's more than its settings. */
75
+ const WHAT_GOES_BACK: Partial<Record<ChangeKind, (n: number) => string>> = {
76
+ DEPLOY: (n) =>
77
+ `Makes v${n}'s settings live again. The instructions stay as they are now: a deploy changed them, and only a deploy changes them back.`,
78
+ INSTRUCTIONS: (n) =>
79
+ `Makes v${n}'s settings live again. The instructions stay as they are now: they were edited at runtime, so undo that edit where it was made.`,
80
+ OUTSIDE: (n) =>
81
+ `Makes v${n}'s settings, found changed outside these settings, live again.`,
82
+ };