@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,116 @@
1
+ import type { EvalStore } from "./store.js";
2
+ import type { AnySuite } from "./types.js";
3
+ /**
4
+ * A read-only check that a store reads what's already in your tables:
5
+ * every case, answer, test, and output of each suite, with anything that
6
+ * doesn't parse (an unknown status, a cost that isn't a number, a missing
7
+ * column) listed by row, with counts. It never writes, so it's safe on a
8
+ * copy of real data; it's the first thing to run after mapping a store
9
+ * onto an app's own tables.
10
+ */
11
+ /** What a row is: a case, an answer, a test (a run), or an output. */
12
+ export type ReadKind = "case" | "answer" | "test" | "output";
13
+ /** One value that doesn't read as Evalkeeper expects. */
14
+ export type ReadProblem = {
15
+ suite: string;
16
+ kind: ReadKind;
17
+ /** The row's id, or empty when the rows couldn't be read at all. */
18
+ id: string;
19
+ /** Evalkeeper's name for the field, or empty for the whole row. */
20
+ field: string;
21
+ /** What's wrong, in plain words. */
22
+ problem: string;
23
+ };
24
+ /** How many of each were read. */
25
+ export type ReadCounts = {
26
+ cases: number;
27
+ answers: number;
28
+ tests: number;
29
+ outputs: number;
30
+ };
31
+ /** What a read check found for one suite. */
32
+ export type SuiteReadReport = {
33
+ suite: string;
34
+ counts: ReadCounts;
35
+ problems: ReadProblem[];
36
+ };
37
+ /** What a read check found, suite by suite. */
38
+ export type ReadCheckReport = {
39
+ suites: SuiteReadReport[];
40
+ };
41
+ /** A row as read, keyed by Evalkeeper's field names. */
42
+ export type ReadRow = Readonly<Record<string, unknown>>;
43
+ /**
44
+ * Where a read check reads rows from: a store's records
45
+ * (`checkStoreReads`), or an adapter's raw rows before it fills in
46
+ * defaults (`prismaReadCheck` in `@crowandraven/evalkeeper-prisma`), so a
47
+ * value the store would quietly replace still shows. Cases come with
48
+ * their answers in `labels`.
49
+ */
50
+ export type ReadSource = {
51
+ /** A suite's cases, retired ones too, each with its answers. */
52
+ cases(suite: string): Promise<readonly ReadRow[]>;
53
+ /** A suite's tests, newest first, at most `limit` when given. */
54
+ tests(suite: string, limit: number | undefined): Promise<readonly ReadRow[]>;
55
+ /** These tests' outputs. */
56
+ outputs(testIds: readonly string[]): Promise<readonly ReadRow[]>;
57
+ };
58
+ /** What to check: suites by key, or the suites themselves. */
59
+ export type ReadCheckOptions = {
60
+ /**
61
+ * The suites to read. Pass the suite itself (not just its key) to also
62
+ * check each case's input and answer against the suite's own schemas,
63
+ * the way your code reads them.
64
+ */
65
+ suites: readonly (string | AnySuite)[];
66
+ /** Read at most this many tests per suite, newest first. All by default. */
67
+ tests?: number;
68
+ };
69
+ /**
70
+ * What doesn't read as Evalkeeper expects in one row: each field that's
71
+ * missing or holds a value the store can't use as it is.
72
+ *
73
+ * @param kind - What the row is.
74
+ * @param row - The row, keyed by Evalkeeper's field names.
75
+ */
76
+ export declare function rowProblems(kind: ReadKind, row: ReadRow): {
77
+ field: string;
78
+ problem: string;
79
+ }[];
80
+ /**
81
+ * Reads each suite's rows from a source and lists what doesn't parse, with
82
+ * counts. Read-only. Use `checkStoreReads` for any store, or an adapter's
83
+ * own check (`prismaReadCheck`) to see values before the store fills in
84
+ * defaults.
85
+ *
86
+ * @param source - Where to read the rows.
87
+ * @param opts - Which suites, and how many tests of each.
88
+ */
89
+ export declare function checkReads(source: ReadSource, opts: ReadCheckOptions): Promise<ReadCheckReport>;
90
+ /**
91
+ * Reads each suite's cases, answers, tests, and outputs through a store
92
+ * and lists anything that doesn't parse, with counts. Read-only, so it's
93
+ * safe on a copy of real data. A store may fill in defaults as it reads
94
+ * (the Prisma store reads an unknown status as a known one); for a Prisma
95
+ * store, `prismaReadCheck` sees the values before that.
96
+ *
97
+ * @param store - The store to read through.
98
+ * @param opts - Which suites, and how many tests of each.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { checkStoreReads, readCheckSummary } from "@crowandraven/evalkeeper";
103
+ *
104
+ * const report = await checkStoreReads(store, { suites: SUITES });
105
+ * console.log(readCheckSummary(report).join("\n"));
106
+ * ```
107
+ */
108
+ export declare function checkStoreReads(store: EvalStore, opts: ReadCheckOptions): Promise<ReadCheckReport>;
109
+ /**
110
+ * A read check in words: a line per suite with its counts, then each kind
111
+ * of problem once with how many rows have it and an example id.
112
+ *
113
+ * @param report - What `checkReads`, `checkStoreReads`, or
114
+ * `prismaReadCheck` found.
115
+ */
116
+ export declare function readCheckSummary(report: ReadCheckReport): string[];
@@ -0,0 +1,321 @@
1
+ import { EVAL_SETS } from "./store.js";
2
+ const CASE_STATUSES = ["DRAFT", "ACTIVE", "RETIRED"];
3
+ const SPLITS = ["DEV", "TEST"];
4
+ const LABEL_STATUSES = [
5
+ "PENDING",
6
+ "CONFIRMED",
7
+ "PROVISIONAL",
8
+ "REJECTED",
9
+ "SKIPPED",
10
+ ];
11
+ const RUN_STATUSES = ["RUNNING", "SUCCEEDED", "FAILED"];
12
+ const missing = "is missing (no column for it, or not mapped)";
13
+ // JSON.stringify gives undefined for these, or throws for a bigint.
14
+ const show = (v) => v === undefined || typeof v === "bigint" || typeof v === "function"
15
+ ? String(v)
16
+ : JSON.stringify(v);
17
+ const text = (v) => v === undefined
18
+ ? missing
19
+ : typeof v === "string"
20
+ ? null
21
+ : `isn't text: ${show(v)}`;
22
+ const textOrNull = (v) => (v === null ? null : text(v));
23
+ const present = (v) => (v === undefined ? missing : null);
24
+ const oneOf = (allowed, orNull = false) => (v) => v === undefined
25
+ ? missing
26
+ : (orNull && v === null) || (typeof v === "string" && allowed.includes(v))
27
+ ? null
28
+ : `${show(v)} isn't one of ${allowed.join(", ")}`;
29
+ const when = (v) => v === undefined
30
+ ? missing
31
+ : v instanceof Date && !Number.isNaN(v.getTime())
32
+ ? null
33
+ : `isn't a date: ${show(v)}`;
34
+ const whenOrNull = (v) => (v === null ? null : when(v));
35
+ const amount = (orNull) => (v) => v === undefined
36
+ ? missing
37
+ : orNull && v === null
38
+ ? null
39
+ : typeof v === "number" && Number.isFinite(v) && v >= 0
40
+ ? null
41
+ : `isn't a number of zero or more: ${show(v)}`;
42
+ /** A run setting: a column the app may not have, so unset is fine. */
43
+ const setting = (v) => v === undefined || v === null || (typeof v === "number" && Number.isFinite(v))
44
+ ? null
45
+ : `isn't a number: ${show(v)}`;
46
+ const count = (v) => v === undefined
47
+ ? missing
48
+ : typeof v === "number" && Number.isInteger(v) && v >= 1
49
+ ? null
50
+ : `isn't a whole number of 1 or more: ${show(v)}`;
51
+ const yesNo = (v) => v === undefined
52
+ ? missing
53
+ : typeof v === "boolean"
54
+ ? null
55
+ : `isn't true or false: ${show(v)}`;
56
+ const words = (v) => v === undefined
57
+ ? missing
58
+ : Array.isArray(v) && v.every((x) => typeof x === "string")
59
+ ? null
60
+ : `isn't a list of words: ${show(v)}`;
61
+ const objectOrNull = (v) => v === undefined || v === null || (typeof v === "object" && !Array.isArray(v))
62
+ ? null
63
+ : `isn't what the runner writes: ${show(v)}`;
64
+ const scores = (v) => v === undefined ||
65
+ v === null ||
66
+ (Array.isArray(v) &&
67
+ v.every((s) => typeof s === "object" &&
68
+ s !== null &&
69
+ typeof Reflect.get(s, "key") === "string"))
70
+ ? null
71
+ : `isn't a list of check results: ${show(v)}`;
72
+ /**
73
+ * The fields of each kind of row and what each must be. Nulls the stores
74
+ * read on purpose (a legacy test with no set reads as ALL, no grader
75
+ * version as empty) aren't problems.
76
+ */
77
+ const RULES = {
78
+ case: {
79
+ id: text,
80
+ suite: text,
81
+ input: present,
82
+ tags: words,
83
+ split: oneOf(SPLITS),
84
+ status: oneOf(CASE_STATUSES),
85
+ source: text,
86
+ sourceRef: textOrNull,
87
+ note: textOrNull,
88
+ createdAt: when,
89
+ updatedAt: when,
90
+ },
91
+ answer: {
92
+ id: text,
93
+ kind: oneOf(["EXPECTED"]),
94
+ status: oneOf(LABEL_STATUSES),
95
+ value: present,
96
+ raterRole: text,
97
+ raterId: textOrNull,
98
+ note: textOrNull,
99
+ createdAt: when,
100
+ updatedAt: when,
101
+ },
102
+ test: {
103
+ id: text,
104
+ suite: text,
105
+ model: text,
106
+ promptVersion: text,
107
+ reasoningEffort: textOrNull,
108
+ temperature: setting,
109
+ maxOutputTokens: setting,
110
+ set: oneOf(EVAL_SETS, true),
111
+ repeats: count,
112
+ datasetVersion: textOrNull,
113
+ graderVersion: textOrNull,
114
+ status: oneOf(RUN_STATUSES),
115
+ metrics: objectOrNull,
116
+ error: textOrNull,
117
+ estimatedCostUsd: amount(true),
118
+ startedBy: textOrNull,
119
+ startedAt: when,
120
+ finishedAt: whenOrNull,
121
+ },
122
+ output: {
123
+ id: text,
124
+ runId: text,
125
+ caseId: text,
126
+ repeat: count,
127
+ requestHash: text,
128
+ output: present,
129
+ error: textOrNull,
130
+ scores,
131
+ costUsd: amount(false),
132
+ ms: amount(false),
133
+ reused: yesNo,
134
+ createdAt: when,
135
+ },
136
+ };
137
+ /**
138
+ * What doesn't read as Evalkeeper expects in one row: each field that's
139
+ * missing or holds a value the store can't use as it is.
140
+ *
141
+ * @param kind - What the row is.
142
+ * @param row - The row, keyed by Evalkeeper's field names.
143
+ */
144
+ export function rowProblems(kind, row) {
145
+ const out = [];
146
+ for (const [field, rule] of Object.entries(RULES[kind])) {
147
+ const problem = rule(row[field]);
148
+ if (problem)
149
+ out.push({ field, problem });
150
+ }
151
+ return out;
152
+ }
153
+ const idOf = (row) => (typeof row.id === "string" ? row.id : "");
154
+ const message = (e) => (e instanceof Error ? e.message : String(e));
155
+ /** The first thing a schema says is wrong, in a line. */
156
+ function schemaProblem(schema, value) {
157
+ const parsed = schema.safeParse(value);
158
+ if (parsed.success)
159
+ return null;
160
+ const [first] = parsed.error.issues;
161
+ const where = first?.path.length ? `${first.path.join(".")}: ` : "";
162
+ return `doesn't fit the suite's schema (${where}${first?.message ?? "invalid"})`;
163
+ }
164
+ async function checkSuite(source, key, suite, opts) {
165
+ const counts = { cases: 0, answers: 0, tests: 0, outputs: 0 };
166
+ const problems = [];
167
+ const add = (kind, row) => {
168
+ for (const p of rowProblems(kind, row))
169
+ problems.push({ suite: key, kind, id: idOf(row), ...p });
170
+ };
171
+ const unreadable = (kind, e) => problems.push({
172
+ suite: key,
173
+ kind,
174
+ id: "",
175
+ field: "",
176
+ problem: `couldn't be read: ${message(e)}`,
177
+ });
178
+ try {
179
+ for (const c of await source.cases(key)) {
180
+ counts.cases++;
181
+ add("case", c);
182
+ if (suite && c.input !== undefined) {
183
+ const p = schemaProblem(suite.input, c.input);
184
+ if (p)
185
+ problems.push({
186
+ suite: key,
187
+ kind: "case",
188
+ id: idOf(c),
189
+ field: "input",
190
+ problem: p,
191
+ });
192
+ }
193
+ if (!Array.isArray(c.labels)) {
194
+ problems.push({
195
+ suite: key,
196
+ kind: "case",
197
+ id: idOf(c),
198
+ field: "labels",
199
+ problem: "has no list of answers (check the mapping's labels relation)",
200
+ });
201
+ continue;
202
+ }
203
+ for (const l of c.labels) {
204
+ counts.answers++;
205
+ const row = typeof l === "object" && l !== null
206
+ ? // Trust boundary: a row object from the source, read by key.
207
+ l
208
+ : {};
209
+ add("answer", row);
210
+ // A skip (blind rating) has no answer to fit the schema.
211
+ if (suite && row.value !== undefined && row.status !== "SKIPPED") {
212
+ const p = schemaProblem(suite.labelValue, row.value);
213
+ if (p)
214
+ problems.push({
215
+ suite: key,
216
+ kind: "answer",
217
+ id: idOf(row),
218
+ field: "value",
219
+ problem: p,
220
+ });
221
+ }
222
+ }
223
+ }
224
+ }
225
+ catch (e) {
226
+ unreadable("case", e);
227
+ }
228
+ let testIds = [];
229
+ try {
230
+ const tests = await source.tests(key, opts.tests);
231
+ counts.tests = tests.length;
232
+ for (const t of tests)
233
+ add("test", t);
234
+ testIds = tests.map(idOf).filter((id) => id !== "");
235
+ }
236
+ catch (e) {
237
+ unreadable("test", e);
238
+ }
239
+ if (testIds.length) {
240
+ try {
241
+ const outputs = await source.outputs(testIds);
242
+ counts.outputs = outputs.length;
243
+ for (const o of outputs)
244
+ add("output", o);
245
+ }
246
+ catch (e) {
247
+ unreadable("output", e);
248
+ }
249
+ }
250
+ return { suite: key, counts, problems };
251
+ }
252
+ /**
253
+ * Reads each suite's rows from a source and lists what doesn't parse, with
254
+ * counts. Read-only. Use `checkStoreReads` for any store, or an adapter's
255
+ * own check (`prismaReadCheck`) to see values before the store fills in
256
+ * defaults.
257
+ *
258
+ * @param source - Where to read the rows.
259
+ * @param opts - Which suites, and how many tests of each.
260
+ */
261
+ export async function checkReads(source, opts) {
262
+ const suites = [];
263
+ for (const s of opts.suites)
264
+ suites.push(await checkSuite(source, typeof s === "string" ? s : s.key, typeof s === "string" ? null : s, opts));
265
+ return { suites };
266
+ }
267
+ /**
268
+ * Reads each suite's cases, answers, tests, and outputs through a store
269
+ * and lists anything that doesn't parse, with counts. Read-only, so it's
270
+ * safe on a copy of real data. A store may fill in defaults as it reads
271
+ * (the Prisma store reads an unknown status as a known one); for a Prisma
272
+ * store, `prismaReadCheck` sees the values before that.
273
+ *
274
+ * @param store - The store to read through.
275
+ * @param opts - Which suites, and how many tests of each.
276
+ *
277
+ * @example
278
+ * ```ts
279
+ * import { checkStoreReads, readCheckSummary } from "@crowandraven/evalkeeper";
280
+ *
281
+ * const report = await checkStoreReads(store, { suites: SUITES });
282
+ * console.log(readCheckSummary(report).join("\n"));
283
+ * ```
284
+ */
285
+ export function checkStoreReads(store, opts) {
286
+ return checkReads({
287
+ cases: (suite) => store.listCases(suite, { includeRetired: true }),
288
+ tests: (suite, limit) => store.listRuns(suite, limit === undefined ? {} : { limit }),
289
+ outputs: async (ids) => store.listOutputsFor
290
+ ? store.listOutputsFor([...ids])
291
+ : (await Promise.all(ids.map((id) => store.listOutputs(id)))).flat(),
292
+ }, opts);
293
+ }
294
+ const plural = (n, one, many) => `${n.toLocaleString("en-US")} ${n === 1 ? one : many}`;
295
+ /**
296
+ * A read check in words: a line per suite with its counts, then each kind
297
+ * of problem once with how many rows have it and an example id.
298
+ *
299
+ * @param report - What `checkReads`, `checkStoreReads`, or
300
+ * `prismaReadCheck` found.
301
+ */
302
+ export function readCheckSummary(report) {
303
+ const lines = [];
304
+ for (const s of report.suites) {
305
+ const c = s.counts;
306
+ lines.push(`${s.suite}: ${plural(c.cases, "case", "cases")}, ${plural(c.answers, "answer", "answers")}, ${plural(c.tests, "test", "tests")}, and ${plural(c.outputs, "output", "outputs")}; ${s.problems.length ? plural(s.problems.length, "problem", "problems") : "no problems"}.`);
307
+ const groups = new Map();
308
+ for (const p of s.problems) {
309
+ const what = `${p.kind}${p.field ? ` ${p.field}` : ""} ${p.problem}`;
310
+ const g = groups.get(what);
311
+ if (g)
312
+ g.n++;
313
+ else
314
+ groups.set(what, { n: 1, id: p.id });
315
+ }
316
+ for (const [what, g] of groups)
317
+ lines.push(` ${what}: ${plural(g.n, "row", "rows")}${g.id ? ` (e.g. ${g.id})` : ""}.`);
318
+ }
319
+ return lines;
320
+ }
321
+ //# sourceMappingURL=readCheck.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readCheck.js","sourceRoot":"","sources":["../src/readCheck.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA4EvC,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACrD,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/B,MAAM,cAAc,GAAG;IACrB,SAAS;IACT,WAAW;IACX,aAAa;IACb,UAAU;IACV,SAAS;CACV,CAAC;AACF,MAAM,YAAY,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;AAIxD,MAAM,OAAO,GAAG,8CAA8C,CAAC;AAC/D,oEAAoE;AACpE,MAAM,IAAI,GAAG,CAAC,CAAU,EAAU,EAAE,CAClC,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,UAAU;IACjE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACX,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAExB,MAAM,IAAI,GAAS,CAAC,CAAC,EAAE,EAAE,CACvB,CAAC,KAAK,SAAS;IACb,CAAC,CAAC,OAAO;IACT,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACjC,MAAM,UAAU,GAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAA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B,KAAK,CAAC,IAAI,CACR,KAAK,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAC5E,CAAC;IACN,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/runner.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { type ModelCatalog, type ReasoningEffort } from "./models.js";
2
2
  import type { BoardRow } from "./board.js";
3
3
  import type { CaseRecord, EvalSet, EvalStore, RunRecord } from "./store.js";
4
+ import { type CaseInInstructions } from "./inInstructions.js";
5
+ import { type ActivityDraftResult } from "./activity.js";
4
6
  import { confirmedLabel, isProvisional } from "./labels.js";
5
7
  export { confirmedLabel, isProvisional };
6
8
  import type { AnySuite, CheckResult } from "./types.js";
@@ -34,6 +36,13 @@ export type RunnerOptions = {
34
36
  * marks older tests out of date.
35
37
  */
36
38
  promptVersion: (operation: string) => string | Promise<string>;
39
+ /**
40
+ * Everything the operation's model is told, as text: system text, prompt
41
+ * templates, schema and tool descriptions (`instructionParts` in
42
+ * `@crowandraven/evalkeeper-ai-sdk`, from the parts you hash). Lets
43
+ * `casesInInstructions` warn when a case was copied into them.
44
+ */
45
+ instructionTexts?: (operation: string) => string[] | Promise<string[]>;
37
46
  /**
38
47
  * The live reasoning setting for an operation; null: the model's own.
39
48
  * Defaults to the route's, when `route` is given.
@@ -142,6 +151,11 @@ export declare function mapLimit<T, R>(items: T[], limit: number, fn: (item: T)
142
151
  export declare function createRunner(opts: RunnerOptions): {
143
152
  startDriftCheck: (suiteKey: string) => Promise<string | null>;
144
153
  runDriftCheck: (suiteKey: string) => Promise<string | null>;
154
+ draftFromActivity: (suiteKey: string, o?: {
155
+ limit?: number;
156
+ since?: Date;
157
+ today?: Date;
158
+ }) => Promise<ActivityDraftResult>;
145
159
  board: (suiteKey: string) => Promise<{
146
160
  suite: AnySuite;
147
161
  route: Route;
@@ -210,8 +224,10 @@ export declare function createRunner(opts: RunnerOptions): {
210
224
  a: RunRecord;
211
225
  b: RunRecord;
212
226
  comparison: import("./compare.js").Comparison;
227
+ disagreements: import("./compare.js").Disagreement[];
213
228
  caveats: string[];
214
229
  } | null>;
230
+ casesInInstructions: (suiteKey: string) => Promise<CaseInInstructions[]>;
215
231
  };
216
232
  /** What createRunner returns. */
217
233
  export type Runner = ReturnType<typeof createRunner>;
package/dist/runner.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @module evalkeeper/runner
6
6
  */
7
7
  import { createHash } from "node:crypto";
8
- import { compareRuns } from "./compare.js";
8
+ import { compareRuns, disagreements } from "./compare.js";
9
9
  import { isStuck, shouldContinue } from "./legs.js";
10
10
  import { effortFor, isBaseline, } from "./models.js";
11
11
  import { allPassed } from "./stats.js";
@@ -13,6 +13,8 @@ import { pickQuickSet } from "./quickSet.js";
13
13
  import { stableJson } from "./stableJson.js";
14
14
  import { suiteMetrics } from "./stats.js";
15
15
  import { withTimeout } from "./timeout.js";
16
+ import { casesInInstructions, } from "./inInstructions.js";
17
+ import { draftFromActivity as draftCases, } from "./activity.js";
16
18
  import { SCHEDULED } from "./weekly.js";
17
19
  import { confirmedLabel, isProvisional } from "./labels.js";
18
20
  export { confirmedLabel, isProvisional };
@@ -503,6 +505,16 @@ export function createRunner(opts) {
503
505
  await runEval(id, { fresh: true });
504
506
  return id;
505
507
  }
508
+ /**
509
+ * One suite's weekly drafts from your app's activity: asks the suite's
510
+ * `draftFromActivity` for up to `limit` cases a week (default
511
+ * ACTIVITY_DRAFTS_PER_WEEK) and adds new ones as drafts with PENDING
512
+ * answers, skipping anything drafted before. Call it for each suite from
513
+ * the weekly job; suites without the method draft nothing.
514
+ */
515
+ async function draftFromActivity(suiteKey, o = {}) {
516
+ return draftCases({ store, suite: suiteOrThrow(suiteKey), ...o });
517
+ }
506
518
  /**
507
519
  * Several tests' outputs by test id: one call where the store can, so a
508
520
  * remote database isn't asked once per test.
@@ -536,6 +548,8 @@ export function createRunner(opts) {
536
548
  /**
537
549
  * Two finished tests of a suite compared case by case: `a` the one in
538
550
  * place, `b` the challenger. Null if either isn't a finished test.
551
+ * `disagreements` lists the cases they graded differently, for reading
552
+ * the two answers side by side.
539
553
  */
540
554
  async function compare(suiteKey, a, b) {
541
555
  const suite = suiteOrThrow(suiteKey);
@@ -555,7 +569,8 @@ export function createRunner(opts) {
555
569
  ms: x.ms,
556
570
  reused: x.reused,
557
571
  }));
558
- const comparison = compareRuns(await asOutputs(ra), await asOutputs(rb), suite.checks.map((c) => c.key));
572
+ const [oa, ob] = await Promise.all([asOutputs(ra), asOutputs(rb)]);
573
+ const comparison = compareRuns(oa, ob, suite.checks.map((c) => c.key));
559
574
  // Comparable only when measured the same way.
560
575
  const caveats = [
561
576
  ra.set !== rb.set && `different sets (${ra.set} and ${rb.set})`,
@@ -566,7 +581,38 @@ export function createRunner(opts) {
566
581
  ra.promptVersion !== rb.promptVersion &&
567
582
  `different instructions (${ra.promptVersion} and ${rb.promptVersion})`,
568
583
  ].filter((x) => Boolean(x));
569
- return { suite, a: ra, b: rb, comparison, caveats };
584
+ return {
585
+ suite,
586
+ a: ra,
587
+ b: rb,
588
+ comparison,
589
+ disagreements: disagreements(oa, ob),
590
+ caveats,
591
+ };
592
+ }
593
+ /**
594
+ * The suite's cases in use or in draft whose text appears in its
595
+ * operation's instructions (see `casesInInstructions`), for a warning on
596
+ * the suite page. Empty without `instructionTexts`.
597
+ */
598
+ async function casesInInstructionsFor(suiteKey) {
599
+ const suite = suiteOrThrow(suiteKey);
600
+ if (!opts.instructionTexts)
601
+ return [];
602
+ const [texts, cases] = await Promise.all([
603
+ opts.instructionTexts(suite.operation),
604
+ store.listCases(suite.key),
605
+ ]);
606
+ return casesInInstructions(cases
607
+ .filter((c) => c.status !== "RETIRED")
608
+ .map((c) => {
609
+ const parsed = suite.input.safeParse(c.input);
610
+ return {
611
+ id: c.id,
612
+ title: parsed.success ? suite.title(parsed.data) : "A case",
613
+ input: c.input,
614
+ };
615
+ }), texts);
570
616
  }
571
617
  /**
572
618
  * The model board for one suite: every model the operation can use, with
@@ -766,6 +812,7 @@ export function createRunner(opts) {
766
812
  return {
767
813
  startDriftCheck,
768
814
  runDriftCheck,
815
+ draftFromActivity,
769
816
  board,
770
817
  suiteOrThrow,
771
818
  casesFor,
@@ -777,6 +824,7 @@ export function createRunner(opts) {
777
824
  rescoreRecent,
778
825
  stopStuckRuns,
779
826
  compare,
827
+ casesInInstructions: casesInInstructionsFor,
780
828
  };
781
829
  }
782
830
  //# sourceMappingURL=runner.js.map