@crowandraven/evalkeeper 0.5.0 → 0.8.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/README.md +16 -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 +6 -1
  12. package/dist/cli/addPages.js +19 -4
  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/decisions.js +8 -0
  21. package/dist/decisions.js.map +1 -1
  22. package/dist/feedback.d.ts +17 -2
  23. package/dist/feedback.js +13 -2
  24. package/dist/feedback.js.map +1 -1
  25. package/dist/glossary.d.ts +22 -0
  26. package/dist/glossary.js +22 -0
  27. package/dist/glossary.js.map +1 -1
  28. package/dist/health.js +5 -3
  29. package/dist/health.js.map +1 -1
  30. package/dist/importCases.d.ts +76 -5
  31. package/dist/importCases.js +114 -14
  32. package/dist/importCases.js.map +1 -1
  33. package/dist/inInstructions.d.ts +47 -0
  34. package/dist/inInstructions.js +95 -0
  35. package/dist/inInstructions.js.map +1 -0
  36. package/dist/index.d.ts +5 -0
  37. package/dist/index.js +5 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/memoryStore.js +3 -1
  40. package/dist/memoryStore.js.map +1 -1
  41. package/dist/readCheck.d.ts +116 -0
  42. package/dist/readCheck.js +321 -0
  43. package/dist/readCheck.js.map +1 -0
  44. package/dist/runner.d.ts +16 -0
  45. package/dist/runner.js +51 -3
  46. package/dist/runner.js.map +1 -1
  47. package/dist/settings.d.ts +81 -3
  48. package/dist/settings.js +160 -23
  49. package/dist/settings.js.map +1 -1
  50. package/dist/store.d.ts +10 -3
  51. package/dist/suggest.d.ts +10 -1
  52. package/dist/suggest.js +22 -4
  53. package/dist/suggest.js.map +1 -1
  54. package/dist/suiteContract.d.ts +23 -0
  55. package/dist/suiteContract.js +106 -0
  56. package/dist/suiteContract.js.map +1 -0
  57. package/dist/suites/crisisRisk.d.ts +83 -0
  58. package/dist/suites/crisisRisk.js +176 -0
  59. package/dist/suites/crisisRisk.js.map +1 -0
  60. package/dist/suites/crisisRiskCases.d.ts +40 -0
  61. package/dist/suites/crisisRiskCases.js +179 -0
  62. package/dist/suites/crisisRiskCases.js.map +1 -0
  63. package/dist/suites/hopelessness.d.ts +116 -0
  64. package/dist/suites/hopelessness.js +293 -0
  65. package/dist/suites/hopelessness.js.map +1 -0
  66. package/dist/suites/hopelessnessCases.d.ts +61 -0
  67. package/dist/suites/hopelessnessCases.js +242 -0
  68. package/dist/suites/hopelessnessCases.js.map +1 -0
  69. package/dist/suites/index.d.ts +11 -0
  70. package/dist/suites/index.js +12 -0
  71. package/dist/suites/index.js.map +1 -0
  72. package/dist/testing.d.ts +162 -12
  73. package/dist/testing.js +479 -115
  74. package/dist/testing.js.map +1 -1
  75. package/dist/types.d.ts +98 -0
  76. package/dist/types.js +68 -0
  77. package/dist/types.js.map +1 -1
  78. package/dist/weekly.d.ts +21 -3
  79. package/dist/weekly.js +18 -1
  80. package/dist/weekly.js.map +1 -1
  81. package/package.json +5 -1
  82. package/src/activity.ts +154 -0
  83. package/src/assertExpect.ts +168 -0
  84. package/src/blind.ts +138 -0
  85. package/src/cli/addPages.ts +20 -4
  86. package/src/cli/main.ts +4 -3
  87. package/src/compare.ts +85 -0
  88. package/src/decisions.ts +10 -0
  89. package/src/feedback.ts +20 -2
  90. package/src/glossary.ts +40 -0
  91. package/src/health.ts +5 -3
  92. package/src/importCases.ts +172 -33
  93. package/src/inInstructions.ts +105 -0
  94. package/src/index.ts +5 -0
  95. package/src/memoryStore.ts +2 -1
  96. package/src/readCheck.ts +458 -0
  97. package/src/runner.ts +74 -4
  98. package/src/settings.ts +192 -26
  99. package/src/store.ts +11 -3
  100. package/src/suggest.ts +33 -4
  101. package/src/suiteContract.ts +147 -0
  102. package/src/suites/crisisRisk.ts +250 -0
  103. package/src/suites/crisisRiskCases.ts +205 -0
  104. package/src/suites/hopelessness.ts +410 -0
  105. package/src/suites/hopelessnessCases.ts +286 -0
  106. package/src/suites/index.ts +11 -0
  107. package/src/testing.ts +646 -121
  108. package/src/types.ts +147 -0
  109. package/src/weekly.ts +39 -3
  110. package/starter/index.ts +8 -0
  111. package/templates/app/evals/[suite]/compare/page.tsx +385 -0
  112. package/templates/app/evals/[suite]/page.tsx +104 -31
  113. package/templates/app/evals/[suite]/rate/page.tsx +143 -0
  114. package/templates/app/evals/[suite]/runs/[runId]/page.tsx +84 -3
  115. package/templates/app/evals/[suite]/side-by-side/page.tsx +320 -0
  116. package/templates/app/evals/feedback/page.tsx +3 -0
  117. package/templates/app/evals/page.tsx +3 -0
  118. package/templates/components/evalkeeper/AnswerKey.tsx +2 -1
  119. package/templates/components/evalkeeper/DisagreementChip.tsx +35 -0
  120. package/templates/components/evalkeeper/ReadableOutput.tsx +97 -0
  121. package/templates/components/evalkeeper/RollBack.tsx +21 -1
  122. package/templates/components/evalkeeper/SettingsHistory.tsx +29 -5
  123. package/templates/components/evalkeeper/WeeklyCheck.tsx +34 -2
  124. package/templates/lib/evalkeeper/actions.ts +68 -4
  125. package/templates/lib/evalkeeper/weekly.ts +27 -4
@@ -0,0 +1,320 @@
1
+ import type { Metadata } from "next";
2
+ import Link from "next/link";
3
+ import { notFound } from "next/navigation";
4
+ import { ArrowLeft, ArrowRight, Check, Minus, X } from "lucide-react";
5
+ import {
6
+ aroundCase,
7
+ type AnySuite,
8
+ type CheckResult,
9
+ type OutputRecord,
10
+ type RunRecord,
11
+ } from "@crowandraven/evalkeeper";
12
+ import { DisagreementChip } from "@/components/evalkeeper/DisagreementChip";
13
+ import { FieldValues } from "@/components/evalkeeper/Fields";
14
+ import { ReadableOutput } from "@/components/evalkeeper/ReadableOutput";
15
+ import { InfoTip, Tip } from "@/components/evalkeeper/Tip";
16
+ import { BackLink, Card, pct } from "@/components/evalkeeper/ui";
17
+ import {
18
+ MODELS,
19
+ requireAdmin,
20
+ runner,
21
+ store,
22
+ SUITE_BY_KEY,
23
+ } from "@/lib/evalkeeper";
24
+ import { evalsPath } from "@/lib/evalkeeper/paths";
25
+
26
+ export const dynamic = "force-dynamic";
27
+
28
+ export async function generateMetadata({
29
+ params,
30
+ }: {
31
+ params: Promise<{ suite: string }>;
32
+ }): Promise<Metadata> {
33
+ const { suite } = await params;
34
+ return { title: `Side by side: ${SUITE_BY_KEY[suite]?.label ?? "Evals"}` };
35
+ }
36
+
37
+ /** A search parameter as one string, or null when it's missing or repeated. */
38
+ const one = (v: string | string[] | undefined) =>
39
+ typeof v === "string" && v ? v : null;
40
+
41
+ /**
42
+ * Two tests' answers to one case, side by side with the expected answer
43
+ * and what each check found, and previous and next through the cases the
44
+ * two graded differently. `a` is the test in place, `b` the challenger,
45
+ * and `case` the case (the first disagreement when left out).
46
+ */
47
+ export default async function SideBySidePage({
48
+ params,
49
+ searchParams,
50
+ }: {
51
+ params: Promise<{ suite: string }>;
52
+ searchParams: Promise<Record<string, string | string[] | undefined>>;
53
+ }) {
54
+ await requireAdmin();
55
+ const { suite: key } = await params;
56
+ const sp = await searchParams;
57
+ const a = one(sp.a);
58
+ const b = one(sp.b);
59
+ if (!a || !b) notFound();
60
+ const result = await runner.compare(key, a, b);
61
+ if (!result) notFound();
62
+ const { suite, disagreements } = result;
63
+ const caseId = one(sp.case) ?? disagreements[0]?.caseId ?? null;
64
+ const compareHref = `${evalsPath(key, "compare")}?${new URLSearchParams({ a, b })}`;
65
+ const back = <BackLink href={compareHref}>Compare</BackLink>;
66
+ if (!caseId)
67
+ return (
68
+ <div className="space-y-4">
69
+ {back}
70
+ <h1 className="text-2xl font-semibold">Side by side</h1>
71
+ <p className="readable text-muted">
72
+ The two tests graded every shared case alike: there&apos;s nothing to
73
+ read side by side.
74
+ </p>
75
+ </div>
76
+ );
77
+
78
+ const [cases, outA, outB] = await Promise.all([
79
+ store.listCases(key, { includeRetired: true }),
80
+ store.listOutputs(a),
81
+ store.listOutputs(b),
82
+ ]);
83
+ const c = cases.find((x) => x.id === caseId);
84
+ if (!c) notFound();
85
+ const input = suite.input.parse(c.input);
86
+ const expected =
87
+ c.labels.find((l) => l.status === "CONFIRMED") ??
88
+ c.labels.find((l) => l.status === "PROVISIONAL");
89
+ const here = aroundCase(disagreements, caseId);
90
+ const d = disagreements[here.index];
91
+ const to = (id: string) =>
92
+ `${evalsPath(key, "side-by-side")}?${new URLSearchParams({ a, b, case: id })}`;
93
+ const byRepeat = (os: OutputRecord[]) =>
94
+ os.filter((o) => o.caseId === caseId).sort((x, y) => x.repeat - y.repeat);
95
+
96
+ return (
97
+ <div className="space-y-6">
98
+ {back}
99
+ <div className="space-y-2">
100
+ <p className="text-sm text-muted">
101
+ Side by side
102
+ <InfoTip term="sideBySide" />
103
+ {" · "}
104
+ {suite.label}
105
+ </p>
106
+ <h1 className="text-2xl font-semibold">{suite.title(input)}</h1>
107
+ <div className="flex flex-wrap items-center justify-between gap-3">
108
+ <span className="flex items-center gap-2 text-sm text-muted">
109
+ {d ? (
110
+ <>
111
+ <DisagreementChip kind={d.kind} id="kind" />
112
+ <Tip term="disagreements" id="position">
113
+ <span>
114
+ {here.index + 1} of {disagreements.length} where they differ
115
+ </span>
116
+ </Tip>
117
+ </>
118
+ ) : (
119
+ <span>Both tests graded this case alike.</span>
120
+ )}
121
+ </span>
122
+ <nav aria-label="Cases where they differ" className="flex gap-2">
123
+ {here.previous ? (
124
+ <StepLink href={to(here.previous)} dir="previous" />
125
+ ) : (
126
+ <StepLink dir="previous" />
127
+ )}
128
+ {here.next ? (
129
+ <StepLink href={to(here.next)} dir="next" />
130
+ ) : (
131
+ <StepLink dir="next" />
132
+ )}
133
+ </nav>
134
+ </div>
135
+ </div>
136
+
137
+ <Card className="grid gap-5 text-sm md:grid-cols-2">
138
+ <section className="min-w-0 space-y-2">
139
+ <h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
140
+ Input
141
+ </h2>
142
+ {/* A suite's own readable input (describe) reads best. */}
143
+ {suite.describe ? (
144
+ <pre className="readable text-xs whitespace-pre-wrap">
145
+ {suite.describe(input)}
146
+ </pre>
147
+ ) : suite.fields ? (
148
+ <FieldValues
149
+ fields={suite.fields.input}
150
+ values={c.input}
151
+ prefix="in-"
152
+ />
153
+ ) : (
154
+ <pre className="readable text-xs whitespace-pre-wrap">
155
+ {JSON.stringify(c.input, null, 2)}
156
+ </pre>
157
+ )}
158
+ </section>
159
+ <section className="min-w-0 space-y-2">
160
+ <h2 className="text-xs font-semibold uppercase tracking-wide text-muted">
161
+ Expected answer
162
+ <InfoTip term="expectedAnswer" />
163
+ </h2>
164
+ {!expected ? (
165
+ <p className="readable text-muted">No answer in use.</p>
166
+ ) : suite.fields ? (
167
+ <FieldValues
168
+ fields={suite.fields.label}
169
+ values={expected.value}
170
+ prefix="expected-"
171
+ />
172
+ ) : (
173
+ <pre className="readable whitespace-pre-wrap text-xs">
174
+ {JSON.stringify(expected.value, null, 2)}
175
+ </pre>
176
+ )}
177
+ </section>
178
+ </Card>
179
+
180
+ <div className="grid gap-4 md:grid-cols-2">
181
+ <Side
182
+ side="inPlace"
183
+ run={result.a}
184
+ outputs={byRepeat(outA)}
185
+ suite={suite}
186
+ score={d?.champion ?? null}
187
+ runHref={evalsPath(key, "runs", a)}
188
+ />
189
+ <Side
190
+ side="challenger"
191
+ run={result.b}
192
+ outputs={byRepeat(outB)}
193
+ suite={suite}
194
+ score={d?.challenger ?? null}
195
+ runHref={evalsPath(key, "runs", b)}
196
+ />
197
+ </div>
198
+ </div>
199
+ );
200
+ }
201
+
202
+ /** A link to the previous or next disagreement, or a dimmed one at either end. */
203
+ function StepLink({ href, dir }: { href?: string; dir: "previous" | "next" }) {
204
+ const label = dir === "previous" ? "Previous" : "Next";
205
+ const body =
206
+ dir === "previous" ? (
207
+ <>
208
+ <ArrowLeft aria-hidden className="h-4 w-4" />
209
+ {label}
210
+ </>
211
+ ) : (
212
+ <>
213
+ {label}
214
+ <ArrowRight aria-hidden className="h-4 w-4" />
215
+ </>
216
+ );
217
+ const cls =
218
+ "inline-flex items-center gap-1 rounded-md border border-line px-3 py-1.5 text-sm";
219
+ return href ? (
220
+ <Link href={href} className={`${cls} hover:bg-tint`}>
221
+ {body}
222
+ </Link>
223
+ ) : (
224
+ <span aria-disabled="true" className={`${cls} text-muted opacity-60`}>
225
+ {body}
226
+ </span>
227
+ );
228
+ }
229
+
230
+ /** One test's answers to the case, with what each check found. */
231
+ function Side({
232
+ side,
233
+ run,
234
+ outputs,
235
+ suite,
236
+ score,
237
+ runHref,
238
+ }: {
239
+ side: "inPlace" | "challenger";
240
+ run: RunRecord;
241
+ outputs: OutputRecord[];
242
+ suite: AnySuite;
243
+ score: number | null;
244
+ runHref: string;
245
+ }) {
246
+ const label = (k: string) =>
247
+ suite.checks.find((x) => x.key === k)?.label ?? k;
248
+ return (
249
+ <Card className="space-y-4 text-sm">
250
+ <div className="space-y-1">
251
+ <p className="text-xs font-semibold uppercase tracking-wide text-muted">
252
+ {side === "inPlace" ? "In place" : "Challenger"}
253
+ <InfoTip term={side} id={`${side}-side`} />
254
+ </p>
255
+ <h2 className="text-lg font-semibold">
256
+ <Link href={runHref} className="hover:underline">
257
+ {MODELS[run.model]?.label ?? run.model}
258
+ </Link>
259
+ </h2>
260
+ {score !== null && (
261
+ <Tip term="caseScore" id={`${side}-score`}>
262
+ <span className="text-muted">Scored {pct(score)} on this case</span>
263
+ </Tip>
264
+ )}
265
+ </div>
266
+ {outputs.length === 0 && (
267
+ <p className="readable text-muted">This test has no answer here.</p>
268
+ )}
269
+ {outputs.map((o) => {
270
+ const checks: CheckResult[] = o.scores ?? [];
271
+ return (
272
+ <section key={o.id} className="space-y-3 rounded-md bg-tint p-3">
273
+ {outputs.length > 1 && (
274
+ <p className="text-xs text-muted">Repeat {o.repeat + 1}</p>
275
+ )}
276
+ {o.error ? (
277
+ <p className="readable text-bad">No answer: {o.error}</p>
278
+ ) : suite.fields && suite.labelFromOutput ? (
279
+ <FieldValues
280
+ fields={suite.fields.label}
281
+ values={suite.labelFromOutput(o.output)}
282
+ prefix={`${side}-${o.repeat}-`}
283
+ />
284
+ ) : (
285
+ <ReadableOutput value={o.output} />
286
+ )}
287
+ {checks.length > 0 && (
288
+ <ul className="space-y-1">
289
+ {checks.map((x) => (
290
+ <li key={x.key} className="flex items-start gap-1.5">
291
+ {x.pass === null ? (
292
+ <Minus
293
+ aria-label="Doesn't apply"
294
+ className="mt-0.5 h-4 w-4 shrink-0 text-muted"
295
+ />
296
+ ) : x.pass ? (
297
+ <Check
298
+ aria-label="Passed"
299
+ className="mt-0.5 h-4 w-4 shrink-0 text-good"
300
+ />
301
+ ) : (
302
+ <X
303
+ aria-label="Failed"
304
+ className="mt-0.5 h-4 w-4 shrink-0 text-warn"
305
+ />
306
+ )}
307
+ <span className="readable">
308
+ {label(x.key)}
309
+ {x.note && <span className="text-muted">: {x.note}</span>}
310
+ </span>
311
+ </li>
312
+ ))}
313
+ </ul>
314
+ )}
315
+ </section>
316
+ );
317
+ })}
318
+ </Card>
319
+ );
320
+ }
@@ -1,3 +1,4 @@
1
+ import type { Metadata } from "next";
1
2
  import {
2
3
  asText,
3
4
  thumbsSummary,
@@ -17,6 +18,8 @@ import { EVALS_BASE } from "@/lib/evalkeeper/paths";
17
18
 
18
19
  export const dynamic = "force-dynamic";
19
20
 
21
+ export const metadata: Metadata = { title: "Feedback: Evals" };
22
+
20
23
  /**
21
24
  * What people thought of the AI's answers: thumbs per feature this week,
22
25
  * and each rating waiting for a look, to make into a case or dismiss.
@@ -1,3 +1,4 @@
1
+ import type { Metadata } from "next";
1
2
  import Link from "next/link";
2
3
  import {
3
4
  attention,
@@ -29,6 +30,8 @@ import { ChevronDown } from "lucide-react";
29
30
 
30
31
  export const dynamic = "force-dynamic";
31
32
 
33
+ export const metadata: Metadata = { title: "Evals" };
34
+
32
35
  /** The evals hub: where each suite stands, and what needs attention. */
33
36
  export default async function EvalsHub() {
34
37
  await requireAdmin();
@@ -189,7 +189,8 @@ function CaseItem({
189
189
 
190
190
  return (
191
191
  <details
192
- className="group rounded-md border border-line bg-card"
192
+ id={`case-${c.id}`}
193
+ className="group scroll-mt-4 rounded-md border border-line bg-card"
193
194
  // Where ConfirmAnswer moves on to after confirming the case above.
194
195
  data-pending={answer?.status === "PENDING" ? "true" : undefined}
195
196
  >
@@ -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
+ }
@@ -0,0 +1,97 @@
1
+ import { asText } from "@crowandraven/evalkeeper";
2
+
3
+ /**
4
+ * Any answer, readable, for suites without their own way to show it (no
5
+ * `labelFromOutput`): text as paragraphs, lists as bullets, small objects
6
+ * as one line each, and fields with their names, never raw JSON.
7
+ */
8
+
9
+ const label = (key: string) =>
10
+ key
11
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
12
+ .replace(/_/g, " ")
13
+ .replace(/^./, (c) => c.toUpperCase());
14
+
15
+ function isPlain(v: unknown): v is string | number | boolean | null {
16
+ return v === null || ["string", "number", "boolean"].includes(typeof v);
17
+ }
18
+
19
+ function Inline({ value }: { value: unknown }) {
20
+ if (value === null || value === undefined || value === "")
21
+ return <span className="text-muted">–</span>;
22
+ if (typeof value === "boolean") return <>{value ? "Yes" : "No"}</>;
23
+ return <>{asText(value)}</>;
24
+ }
25
+
26
+ /** One line for a small object: its longest text first, then the rest. */
27
+ function Row({ value }: { value: Record<string, unknown> }) {
28
+ const entries = Object.entries(value);
29
+ const main = entries.find(([, v]) => typeof v === "string" && v.length > 20);
30
+ const rest = entries.filter(([k, v]) => k !== main?.[0] && isPlain(v));
31
+ return (
32
+ <>
33
+ {main ? asText(main[1]) : null}
34
+ {rest.length > 0 && (
35
+ <span className="text-xs text-muted">
36
+ {main ? " · " : ""}
37
+ {rest
38
+ .map(([k, v]) => `${label(k)}: ${v === null ? "–" : asText(v)}`)
39
+ .join(" · ")}
40
+ </span>
41
+ )}
42
+ </>
43
+ );
44
+ }
45
+
46
+ export function ReadableOutput({ value }: { value: unknown }) {
47
+ if (isPlain(value))
48
+ return typeof value === "string" && value.length > 80 ? (
49
+ <p className="readable break-words whitespace-pre-wrap">{value}</p>
50
+ ) : (
51
+ <span className="break-words">
52
+ <Inline value={value} />
53
+ </span>
54
+ );
55
+ if (Array.isArray(value)) {
56
+ if (!value.length) return <span className="text-muted">None</span>;
57
+ return (
58
+ <ul className="readable list-disc space-y-1 pl-5 break-words">
59
+ {value.map((v: unknown, i) => (
60
+ <li key={i}>
61
+ {isPlain(v) ? (
62
+ <Inline value={v} />
63
+ ) : v &&
64
+ typeof v === "object" &&
65
+ !Array.isArray(v) &&
66
+ Object.values(v).every(isPlain) ? (
67
+ <Row value={v as Record<string, unknown>} />
68
+ ) : (
69
+ <ReadableOutput value={v} />
70
+ )}
71
+ </li>
72
+ ))}
73
+ </ul>
74
+ );
75
+ }
76
+ if (value && typeof value === "object") {
77
+ // Long text (a letter, a summary) reads best first and in full.
78
+ const entries = Object.entries(value as Record<string, unknown>).sort(
79
+ (a, b) =>
80
+ Number(typeof b[1] === "string" && b[1].length > 80) -
81
+ Number(typeof a[1] === "string" && a[1].length > 80),
82
+ );
83
+ return (
84
+ <dl className="space-y-2">
85
+ {entries.map(([k, v]) => (
86
+ <div key={k}>
87
+ <dt className="text-xs text-muted">{label(k)}</dt>
88
+ <dd>
89
+ <ReadableOutput value={v} />
90
+ </dd>
91
+ </div>
92
+ ))}
93
+ </dl>
94
+ );
95
+ }
96
+ return <span className="text-muted">–</span>;
97
+ }
@@ -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
+ };
@@ -1,5 +1,6 @@
1
1
  import Link from "next/link";
2
2
  import {
3
+ GLOSSARY,
3
4
  describeChange,
4
5
  type ChangeKind,
5
6
  type HistoryEntry,
@@ -30,9 +31,19 @@ const KIND: Record<
30
31
  help: "An earlier version made live again.",
31
32
  },
32
33
  DEPLOY: {
33
- text: "Deployed",
34
+ text: "New instructions",
34
35
  tone: "fallback",
35
- help: "The instructions changed in code under the live settings.",
36
+ help: GLOSSARY.newInstructions,
37
+ },
38
+ OUTSIDE: {
39
+ text: "Changed outside",
40
+ tone: "warn",
41
+ help: GLOSSARY.changedOutside,
42
+ },
43
+ INSTRUCTIONS: {
44
+ text: "Instructions edited",
45
+ tone: "fallback",
46
+ help: GLOSSARY.instructionsEdited,
36
47
  },
37
48
  };
38
49
 
@@ -123,6 +134,9 @@ export function HistoryEntries({
123
134
  const ev = (e.evidence ?? {}) as Evidence;
124
135
  const testId = ev.runId ?? ev.live ?? null;
125
136
  const isLive = e.to.id === liveId;
137
+ // Said outright: "same models" read as the app switching models.
138
+ const unchanged = (v: typeof e.to) =>
139
+ `Models unchanged: ${label(v.model)} live${v.fallbackModel ? `, ${label(v.fallbackModel)} fallback` : ""}`;
126
140
  return (
127
141
  <article
128
142
  key={e.id}
@@ -138,15 +152,24 @@ export function HistoryEntries({
138
152
  {isLive && <Chip tone="live">Live now</Chip>}
139
153
  </span>
140
154
  <span className="text-xs text-muted">
141
- {e.by ?? "System"} · {e.createdAt.toLocaleString()}
155
+ {e.by ??
156
+ (e.kind === "OUTSIDE"
157
+ ? "Found by the system"
158
+ : "System")}{" "}
159
+ · {e.createdAt.toLocaleString()}
142
160
  </span>
143
161
  </div>
144
162
  <ul className="readable list-disc pl-5">
145
163
  {(e.kind === "ROLLBACK"
146
164
  ? [`Back to v${e.to.number}: ${label(e.to.model)} live`]
147
165
  : e.kind === "DEPLOY"
148
- ? ["Same models, new instructions"]
149
- : describeChange(e.from, e.to, label)
166
+ ? [unchanged(e.to), "The instructions in code changed"]
167
+ : e.kind === "INSTRUCTIONS"
168
+ ? [
169
+ unchanged(e.to),
170
+ "The instructions were edited at runtime",
171
+ ]
172
+ : describeChange(e.from, e.to, label)
150
173
  ).map((line) => (
151
174
  <li key={line}>{line}</li>
152
175
  ))}
@@ -166,6 +189,7 @@ export function HistoryEntries({
166
189
  suite={suite}
167
190
  versionId={e.to.id}
168
191
  number={e.to.number}
192
+ kind={e.kind}
169
193
  />
170
194
  )}
171
195
  </div>
@@ -3,7 +3,7 @@ import { money, type WeeklySummary } from "@crowandraven/evalkeeper";
3
3
  import { runWeeklyNow } from "@/lib/evalkeeper/actions";
4
4
  import { RefreshWhile } from "./RefreshWhile";
5
5
  import { Submit } from "./Submit";
6
- import { InfoTip } from "./Tip";
6
+ import { InfoTip, Tip } from "./Tip";
7
7
  import { Card, Chip, pct } from "./ui";
8
8
  import { evalsPath } from "@/lib/evalkeeper/paths";
9
9
 
@@ -33,7 +33,8 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
33
33
  : "Not run yet. "}
34
34
  Every Monday, each live model answers its suite&apos;s quick set
35
35
  again, so a quiet change by its provider shows up here. It also flags
36
- models retiring soon and features people rate poorly.
36
+ models retiring soon and features people rate poorly. Suites that can
37
+ draft cases from the week&apos;s activity add a few for you to review.
37
38
  </p>
38
39
 
39
40
  {weekly.clear && (
@@ -118,6 +119,37 @@ export function WeeklyCheck({ weekly }: { weekly: WeeklySummary }) {
118
119
  ))}
119
120
  </ul>
120
121
  )}
122
+
123
+ {weekly.drafted.length > 0 && (
124
+ <ul className="readable space-y-2 text-sm">
125
+ {weekly.drafted.map((d) => (
126
+ <li
127
+ key={`drafted-${d.suite}`}
128
+ className="flex flex-wrap items-baseline gap-2"
129
+ >
130
+ <Tip term="activityDraft" id={`drafted-${d.suite}`}>
131
+ <Chip tone="neutral">Drafted</Chip>
132
+ </Tip>
133
+ <span>
134
+ {d.label}: {d.count} case{d.count === 1 ? "" : "s"} drafted
135
+ from this week&apos;s activity,{" "}
136
+ {d.waiting === 0
137
+ ? "all reviewed."
138
+ : `${d.waiting} waiting for review. `}
139
+ {d.waiting > 0 && (
140
+ <Link
141
+ href={`${evalsPath(d.suite)}#answer-key`}
142
+ className="underline"
143
+ >
144
+ Review them
145
+ </Link>
146
+ )}
147
+ {d.waiting > 0 && "."}
148
+ </span>
149
+ </li>
150
+ ))}
151
+ </ul>
152
+ )}
121
153
  </Card>
122
154
  </section>
123
155
  );