@crowandraven/evalkeeper 0.18.0 → 0.19.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.
- package/dist/decisions.js +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/drafts.d.ts +2 -0
- package/dist/drafts.js +1 -1
- package/dist/drafts.js.map +1 -1
- package/dist/glossary.d.ts +25 -14
- package/dist/glossary.js +25 -14
- package/dist/glossary.js.map +1 -1
- package/dist/health.js +2 -2
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memoryStore.d.ts +2 -1
- package/dist/memoryStore.js +9 -0
- package/dist/memoryStore.js.map +1 -1
- package/dist/next/actions.js +58 -3
- package/dist/next/actions.js.map +1 -1
- package/dist/prisma/contracts.d.ts +5 -2
- package/dist/prisma/contracts.js +7 -1
- package/dist/prisma/contracts.js.map +1 -1
- package/dist/prisma/index.d.ts +40 -1
- package/dist/prisma/index.js +37 -1
- package/dist/prisma/index.js.map +1 -1
- package/dist/prune.d.ts +5 -2
- package/dist/prune.js +7 -4
- package/dist/prune.js.map +1 -1
- package/dist/react/AddCase.js +11 -5
- package/dist/react/AddCase.js.map +1 -1
- package/dist/react/AnswerKey.js +7 -4
- package/dist/react/AnswerKey.js.map +1 -1
- package/dist/react/CaseMenu.d.ts +2 -2
- package/dist/react/CaseMenu.js +10 -31
- package/dist/react/CaseMenu.js.map +1 -1
- package/dist/react/CompareView.js +3 -3
- package/dist/react/CompareView.js.map +1 -1
- package/dist/react/ConfirmAnswer.js +1 -1
- package/dist/react/ConfirmAnswer.js.map +1 -1
- package/dist/react/Drawer.d.ts +32 -0
- package/dist/react/Drawer.js +60 -0
- package/dist/react/Drawer.js.map +1 -0
- package/dist/react/HubSections.d.ts +31 -18
- package/dist/react/HubSections.js +104 -103
- package/dist/react/HubSections.js.map +1 -1
- package/dist/react/Menu.d.ts +37 -0
- package/dist/react/Menu.js +51 -0
- package/dist/react/Menu.js.map +1 -0
- package/dist/react/ModelMenu.d.ts +1 -1
- package/dist/react/ModelMenu.js +8 -32
- package/dist/react/ModelMenu.js.map +1 -1
- package/dist/react/RunView.js +24 -4
- package/dist/react/RunView.js.map +1 -1
- package/dist/react/Spending.d.ts +25 -0
- package/dist/react/Spending.js +51 -0
- package/dist/react/Spending.js.map +1 -0
- package/dist/react/SuiteSections.d.ts +25 -6
- package/dist/react/SuiteSections.js +233 -75
- package/dist/react/SuiteSections.js.map +1 -1
- package/dist/react/app.d.ts +18 -0
- package/dist/react/app.js.map +1 -1
- package/dist/react/format.d.ts +13 -0
- package/dist/react/format.js +13 -0
- package/dist/react/format.js.map +1 -1
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +3 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/pieces.d.ts +21 -8
- package/dist/react/pieces.js +44 -14
- package/dist/react/pieces.js.map +1 -1
- package/dist/runner.d.ts +15 -1
- package/dist/runner.js +89 -13
- package/dist/runner.js.map +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +18 -0
- package/dist/settings.js.map +1 -1
- package/dist/spending.d.ts +100 -0
- package/dist/spending.js +133 -0
- package/dist/spending.js.map +1 -0
- package/dist/stats.d.ts +3 -1
- package/dist/stats.js +6 -2
- package/dist/stats.js.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/suggest.js +17 -12
- package/dist/suggest.js.map +1 -1
- package/dist/suiteSettings.d.ts +78 -0
- package/dist/suiteSettings.js +142 -0
- package/dist/suiteSettings.js.map +1 -0
- package/dist/suites/crisisRisk.js +3 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/hopelessness.js +6 -6
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/injection.js +2 -2
- package/dist/suites/injection.js.map +1 -1
- package/dist/summary.d.ts +41 -4
- package/dist/summary.js +46 -8
- package/dist/summary.js.map +1 -1
- package/dist/testing.d.ts +19 -0
- package/dist/testing.js +61 -0
- package/dist/testing.js.map +1 -1
- package/dist/todo.d.ts +146 -0
- package/dist/todo.js +198 -0
- package/dist/todo.js.map +1 -0
- package/dist/types.d.ts +40 -7
- package/dist/types.js +28 -4
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/schema/evalkeeper.prisma +13 -0
- package/src/decisions.ts +1 -1
- package/src/drafts.ts +3 -1
- package/src/glossary.ts +35 -14
- package/src/health.ts +3 -2
- package/src/index.ts +3 -0
- package/src/memoryStore.ts +15 -1
- package/src/next/actions.ts +67 -2
- package/src/prisma/contracts.ts +16 -1
- package/src/prisma/index.ts +68 -1
- package/src/prune.ts +7 -2
- package/src/react/AddCase.tsx +13 -11
- package/src/react/AnswerKey.tsx +17 -5
- package/src/react/CaseMenu.tsx +23 -77
- package/src/react/CompareView.tsx +4 -10
- package/src/react/ConfirmAnswer.tsx +1 -1
- package/src/react/Drawer.tsx +130 -0
- package/src/react/HubSections.tsx +180 -414
- package/src/react/Menu.tsx +155 -0
- package/src/react/ModelMenu.tsx +23 -74
- package/src/react/RunView.tsx +46 -3
- package/src/react/Spending.tsx +200 -0
- package/src/react/SuiteSections.tsx +579 -175
- package/src/react/app.ts +18 -0
- package/src/react/format.ts +15 -0
- package/src/react/index.ts +3 -0
- package/src/react/pieces.tsx +57 -18
- package/src/runner.ts +122 -12
- package/src/settings.ts +20 -0
- package/src/spending.ts +209 -0
- package/src/stats.ts +8 -2
- package/src/store.ts +5 -0
- package/src/suggest.ts +21 -14
- package/src/suiteSettings.ts +201 -0
- package/src/suites/crisisRisk.ts +3 -3
- package/src/suites/hopelessness.ts +6 -6
- package/src/suites/injection.ts +2 -2
- package/src/summary.ts +59 -8
- package/src/testing.ts +77 -0
- package/src/todo.ts +318 -0
- package/src/types.ts +57 -9
- package/starter/index.ts +7 -0
- package/templates/lib/evalkeeper/actions.ts +20 -0
package/src/todo.ts
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { BoardRow } from "./board.js";
|
|
2
|
+
import type { ModelCatalog } from "./models.js";
|
|
3
|
+
import { stableJson } from "./stableJson.js";
|
|
4
|
+
import { suggest, type AttackResults } from "./suggest.js";
|
|
5
|
+
import { tooFewBelow } from "./summary.js";
|
|
6
|
+
import {
|
|
7
|
+
checkBar,
|
|
8
|
+
pctBeside,
|
|
9
|
+
type CheckDef,
|
|
10
|
+
type SuitePriority,
|
|
11
|
+
} from "./types.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A suite's to-do list: what to do next, in the order to do it, each with
|
|
15
|
+
* why. The suite's page shows it at the top, where each item is done; the
|
|
16
|
+
* hub shows only whether there is one (`suiteStatus`). Pure, from the same
|
|
17
|
+
* board the page reads, so the two always agree.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** One thing to do on a suite, with what the page needs to act on it. */
|
|
21
|
+
export type Todo =
|
|
22
|
+
| {
|
|
23
|
+
kind: "testAll";
|
|
24
|
+
/** Models with a current test now. */
|
|
25
|
+
tested: number;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
kind: "retest";
|
|
29
|
+
/** Why, when it isn't a change since the last test (live's answers failed). */
|
|
30
|
+
why?: string;
|
|
31
|
+
}
|
|
32
|
+
| {
|
|
33
|
+
kind: "makeLive";
|
|
34
|
+
/** The model to make live, or the fallback to set. */
|
|
35
|
+
model: string;
|
|
36
|
+
label: string;
|
|
37
|
+
/** True: the fallback changes, live stays. */
|
|
38
|
+
fallback: boolean;
|
|
39
|
+
/** The suggestion's first reason, as the item's why. */
|
|
40
|
+
why: string;
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
kind: "fixCheck";
|
|
44
|
+
check: string;
|
|
45
|
+
label: string;
|
|
46
|
+
/** The live model's pass rate on it (or the best tested one's). */
|
|
47
|
+
rate: number;
|
|
48
|
+
/** The rate it should reach. */
|
|
49
|
+
aim: number;
|
|
50
|
+
/** Cases every tested model misses it on, when the page counted them. */
|
|
51
|
+
missed: number | null;
|
|
52
|
+
/** The live model's test, for the cases it misses. */
|
|
53
|
+
runId: string | null;
|
|
54
|
+
}
|
|
55
|
+
| { kind: "confirm"; answers: number }
|
|
56
|
+
| { kind: "addCases"; add: number; cases: number; target: number }
|
|
57
|
+
| { kind: "makeAttacks"; suites: { key: string; label: string }[] }
|
|
58
|
+
| { kind: "retireStarters"; cases: number }
|
|
59
|
+
| { kind: "reviewSplit"; cases: number };
|
|
60
|
+
|
|
61
|
+
/** What a suite's to-do list is made from. */
|
|
62
|
+
export type TodoInput = {
|
|
63
|
+
/** The suite's board rows (`runner.board`). */
|
|
64
|
+
rows: readonly BoardRow[];
|
|
65
|
+
checks: readonly CheckDef[];
|
|
66
|
+
priority: SuitePriority;
|
|
67
|
+
models?: ModelCatalog;
|
|
68
|
+
/** The feature's injection suites (`attacksFrom`), for the suggestion. */
|
|
69
|
+
attacks?: AttackResults[];
|
|
70
|
+
/** Cases in use: confirmed or provisional answers, not retired. */
|
|
71
|
+
cases: number;
|
|
72
|
+
/** Of those, answers still provisional. */
|
|
73
|
+
provisional: number;
|
|
74
|
+
/** The suite's target number of cases (`targetCasesOf`). */
|
|
75
|
+
target: number;
|
|
76
|
+
/** Attack suites set up for this feature with no attack cases yet. */
|
|
77
|
+
unmadeAttacks?: { key: string; label: string }[];
|
|
78
|
+
/** Starter cases a starter update replaced (`replacedStarters`). */
|
|
79
|
+
replacedStarters?: number;
|
|
80
|
+
/** Cases models split on (`answerKeyHealth(...).split`). */
|
|
81
|
+
splitCases?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Per must-pass check, cases every tested model misses it on. Only the
|
|
84
|
+
* suite's page counts them (it reads the answers); the hub leaves it out.
|
|
85
|
+
*/
|
|
86
|
+
missedByCheck?: Readonly<Record<string, number>>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Rows with a current, complete-enough test to count as tested. */
|
|
90
|
+
function testedRows(rows: readonly BoardRow[]) {
|
|
91
|
+
return rows.filter((r) => !r.baseline && r.test && !r.test.stale);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* A suite's to-do list, in the order to do it: test every model (or
|
|
96
|
+
* retest), make a better model live, fix must-pass checks every model
|
|
97
|
+
* misses, confirm provisional answers, add cases toward the target, make
|
|
98
|
+
* attack cases, then retire replaced starters and review split cases.
|
|
99
|
+
* Empty when there's nothing to do.
|
|
100
|
+
*
|
|
101
|
+
* @param input - The suite's board, checks, cases, and target.
|
|
102
|
+
*/
|
|
103
|
+
export function suiteTodos(input: TodoInput): Todo[] {
|
|
104
|
+
const { rows, checks, cases, provisional, target } = input;
|
|
105
|
+
const out: Todo[] = [];
|
|
106
|
+
const testing = rows.some((r) => r.testing);
|
|
107
|
+
const models = rows.filter((r) => !r.baseline && !r.variant);
|
|
108
|
+
const tested = testedRows(rows);
|
|
109
|
+
const stale = rows.some((r) => !r.baseline && r.test?.stale);
|
|
110
|
+
|
|
111
|
+
// 1. Tests first: nothing else can be judged without them.
|
|
112
|
+
if (!testing) {
|
|
113
|
+
if (stale) out.push({ kind: "retest" });
|
|
114
|
+
else if (tested.length < Math.min(2, models.length))
|
|
115
|
+
out.push({ kind: "testAll", tested: tested.length });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 2. A better model, by the same rules as the suggestion; not while a
|
|
119
|
+
// test runs, when it would weigh half a board.
|
|
120
|
+
const s =
|
|
121
|
+
!testing && tested.length
|
|
122
|
+
? suggest(
|
|
123
|
+
rows as BoardRow[],
|
|
124
|
+
[...checks],
|
|
125
|
+
input.priority,
|
|
126
|
+
input.models ?? {},
|
|
127
|
+
{ attacks: input.attacks ?? [] },
|
|
128
|
+
)
|
|
129
|
+
: null;
|
|
130
|
+
// Live's test has failed answers: test it again before comparing.
|
|
131
|
+
if (s?.retestLive && !out.some((t) => t.kind === "retest"))
|
|
132
|
+
out.push({ kind: "retest", why: s.reasons[0] ?? "" });
|
|
133
|
+
if (s && !s.same && !s.retestLive) {
|
|
134
|
+
const fallback = s.keepLive;
|
|
135
|
+
const to = fallback ? s.fallback : s.live;
|
|
136
|
+
if (to)
|
|
137
|
+
out.push({
|
|
138
|
+
kind: "makeLive",
|
|
139
|
+
model: to.model,
|
|
140
|
+
label: to.label,
|
|
141
|
+
fallback,
|
|
142
|
+
why: s.reasons[0] ?? "",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// 3. Must-pass checks every tested model misses: the fix is in the
|
|
147
|
+
// instructions or the answers, not the model.
|
|
148
|
+
if (tested.length) {
|
|
149
|
+
const live = tested.find((r) => r.live) ?? null;
|
|
150
|
+
for (const c of checks) {
|
|
151
|
+
if (c.severity !== "serious") continue;
|
|
152
|
+
const aim = checkBar(c);
|
|
153
|
+
const rates = tested.map((r) => r.test?.byCheck[c.key]?.rate ?? null);
|
|
154
|
+
if (!rates.every((x) => x !== null && x < aim)) continue;
|
|
155
|
+
const shown =
|
|
156
|
+
live?.test?.byCheck[c.key]?.rate ??
|
|
157
|
+
Math.max(...rates.filter((x): x is number => x !== null));
|
|
158
|
+
out.push({
|
|
159
|
+
kind: "fixCheck",
|
|
160
|
+
check: c.key,
|
|
161
|
+
label: c.label,
|
|
162
|
+
rate: shown,
|
|
163
|
+
aim,
|
|
164
|
+
missed: input.missedByCheck?.[c.key] ?? null,
|
|
165
|
+
runId: live?.test?.runId ?? null,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 4–7. The answer key.
|
|
171
|
+
if (provisional) out.push({ kind: "confirm", answers: provisional });
|
|
172
|
+
if (cases < target)
|
|
173
|
+
out.push({ kind: "addCases", add: target - cases, cases, target });
|
|
174
|
+
if (input.unmadeAttacks?.length && cases > 0)
|
|
175
|
+
out.push({ kind: "makeAttacks", suites: input.unmadeAttacks });
|
|
176
|
+
if (input.replacedStarters)
|
|
177
|
+
out.push({ kind: "retireStarters", cases: input.replacedStarters });
|
|
178
|
+
if (input.splitCases)
|
|
179
|
+
out.push({ kind: "reviewSplit", cases: input.splitCases });
|
|
180
|
+
return out;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const n = (count: number, word: string, plural = `${word}s`) =>
|
|
184
|
+
`${count} ${count === 1 ? word : plural}`;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A to-do item in words: what to do, and why, as the suite's page shows
|
|
188
|
+
* it ("Add 10 cases", "40 of 50, so scores firm up").
|
|
189
|
+
*
|
|
190
|
+
* @param t - The item.
|
|
191
|
+
*/
|
|
192
|
+
export function todoText(t: Todo): { what: string; why: string } {
|
|
193
|
+
switch (t.kind) {
|
|
194
|
+
case "testAll":
|
|
195
|
+
return {
|
|
196
|
+
what: "Test every model",
|
|
197
|
+
why:
|
|
198
|
+
t.tested === 0
|
|
199
|
+
? "none has been tested yet."
|
|
200
|
+
: "only one has been tested, so there's nothing to compare it with.",
|
|
201
|
+
};
|
|
202
|
+
case "retest":
|
|
203
|
+
return {
|
|
204
|
+
what: "Test again",
|
|
205
|
+
why:
|
|
206
|
+
t.why ||
|
|
207
|
+
"the instructions, answers, or cases changed since the last test.",
|
|
208
|
+
};
|
|
209
|
+
case "makeLive":
|
|
210
|
+
return {
|
|
211
|
+
what: t.fallback
|
|
212
|
+
? `Make ${t.label} the fallback`
|
|
213
|
+
: `Make ${t.label} live`,
|
|
214
|
+
// The suggestion's sentence as it is: it starts with a model's name.
|
|
215
|
+
why: t.why,
|
|
216
|
+
};
|
|
217
|
+
case "fixCheck":
|
|
218
|
+
return {
|
|
219
|
+
what: `Fix "${t.label}"`,
|
|
220
|
+
why: `passes ${pctBeside(t.rate, t.aim)} of the time (aim: ${Math.round(t.aim * 100)}%)${
|
|
221
|
+
t.missed
|
|
222
|
+
? `; every model tested misses it on ${n(t.missed, "case")}`
|
|
223
|
+
: "; every model tested misses it"
|
|
224
|
+
}. The fix is in the instructions or the answers, not the model.`,
|
|
225
|
+
};
|
|
226
|
+
case "confirm":
|
|
227
|
+
return {
|
|
228
|
+
what: `Confirm ${n(t.answers, "answer")}`,
|
|
229
|
+
why: `${t.answers === 1 ? "it's" : "they're"} provisional, so scores rest on answers nobody reviewed.`,
|
|
230
|
+
};
|
|
231
|
+
case "addCases":
|
|
232
|
+
return {
|
|
233
|
+
what: `Add ${n(t.add, "case")}`,
|
|
234
|
+
why: `${t.cases} of ${t.target}, so a score could still be well off.`,
|
|
235
|
+
};
|
|
236
|
+
case "makeAttacks":
|
|
237
|
+
return {
|
|
238
|
+
what: "Make attack cases",
|
|
239
|
+
why: "attacks are set up, but none are made, so nobody knows if a model follows text it can't trust.",
|
|
240
|
+
};
|
|
241
|
+
case "retireStarters":
|
|
242
|
+
return {
|
|
243
|
+
what: `Retire ${n(t.cases, "replaced starter")}`,
|
|
244
|
+
why: `the suite's starter cases changed, and ${t.cases === 1 ? "this one is" : "these are"} no longer among them.`,
|
|
245
|
+
};
|
|
246
|
+
case "reviewSplit":
|
|
247
|
+
return {
|
|
248
|
+
what: `Review ${n(t.cases, "case")} models split on`,
|
|
249
|
+
why: "often the answer is wrong or the case unclear, and either makes every score less trustworthy.",
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Where a suite stands on the hub, in one word. */
|
|
255
|
+
export type SuiteStatus = "attention" | "unknown" | "healthy";
|
|
256
|
+
|
|
257
|
+
/** The order the hub lists suites in: what needs you first. */
|
|
258
|
+
export const SUITE_STATUS_ORDER: readonly SuiteStatus[] = [
|
|
259
|
+
"attention",
|
|
260
|
+
"unknown",
|
|
261
|
+
"healthy",
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
/** What each status is called on the hub and the suite's page. */
|
|
265
|
+
export const SUITE_STATUS_LABEL: Readonly<Record<SuiteStatus, string>> = {
|
|
266
|
+
attention: "Needs attention",
|
|
267
|
+
unknown: "Can't tell yet",
|
|
268
|
+
healthy: "Healthy",
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Where a suite stands: Can't tell yet when no model has a current test or
|
|
273
|
+
* there are too few cases to judge (against the suite's own target),
|
|
274
|
+
* unless a must-pass check is already missed; otherwise Needs attention
|
|
275
|
+
* when its to-do list has anything on it, and Healthy when it doesn't.
|
|
276
|
+
*
|
|
277
|
+
* @param input - What the to-do list is made from.
|
|
278
|
+
* @param todos - The list, when already made (`suiteTodos(input)`).
|
|
279
|
+
*/
|
|
280
|
+
export function suiteStatus(
|
|
281
|
+
input: TodoInput,
|
|
282
|
+
todos: readonly Todo[] = suiteTodos(input),
|
|
283
|
+
): SuiteStatus {
|
|
284
|
+
if (todos.some((t) => t.kind === "fixCheck")) return "attention";
|
|
285
|
+
if (
|
|
286
|
+
testedRows(input.rows).length === 0 ||
|
|
287
|
+
input.cases < tooFewBelow(input.target)
|
|
288
|
+
)
|
|
289
|
+
return "unknown";
|
|
290
|
+
return todos.length ? "attention" : "healthy";
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Starter cases a starter update replaced: added from the suite's
|
|
295
|
+
* `starter` (`sourceRef` "starter:<suite>#<key>") and not retired, whose
|
|
296
|
+
* input no longer matches any current starter. A case with no `sourceRef`
|
|
297
|
+
* is never listed, even when it matches nothing: it may be hand-made.
|
|
298
|
+
*
|
|
299
|
+
* @param suite - The suite: its key and current `starter` cases.
|
|
300
|
+
* @param cases - The suite's cases.
|
|
301
|
+
*/
|
|
302
|
+
export function replacedStarters<
|
|
303
|
+
C extends { status: string; sourceRef: string | null; input: unknown },
|
|
304
|
+
>(
|
|
305
|
+
suite: { key: string; starter?: readonly { input: unknown }[] | undefined },
|
|
306
|
+
cases: readonly C[],
|
|
307
|
+
): C[] {
|
|
308
|
+
const prefix = `starter:${suite.key}#`;
|
|
309
|
+
const current = new Set(
|
|
310
|
+
(suite.starter ?? []).map((s) => stableJson(s.input)),
|
|
311
|
+
);
|
|
312
|
+
return cases.filter(
|
|
313
|
+
(c) =>
|
|
314
|
+
c.status !== "RETIRED" &&
|
|
315
|
+
c.sourceRef?.startsWith(prefix) === true &&
|
|
316
|
+
!current.has(stableJson(c.input)),
|
|
317
|
+
);
|
|
318
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -34,6 +34,13 @@ export type CheckResult = {
|
|
|
34
34
|
* `brier`, `logLoss`, `confidence`, and `correct` (see decisionCheck).
|
|
35
35
|
*/
|
|
36
36
|
measures?: Record<string, number> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Set by Evalkeeper when it grades: the check's level then (the suite's,
|
|
39
|
+
* or a person's from Suite settings). A nice-to-have (`minor`) miss
|
|
40
|
+
* never fails an answer (`allPassed`). Absent on answers graded before
|
|
41
|
+
* levels were kept: those count every check.
|
|
42
|
+
*/
|
|
43
|
+
level?: CheckDef["severity"] | undefined;
|
|
37
44
|
/**
|
|
38
45
|
* Set by Evalkeeper on checks from a suite's `gradeTogether`: they grade
|
|
39
46
|
* this answer against others (a ranking), so the case matters to other
|
|
@@ -54,18 +61,51 @@ export type CheckDef = {
|
|
|
54
61
|
/** "code": needs no label. "label": compares with a confirmed label. */
|
|
55
62
|
kind: "code" | "label";
|
|
56
63
|
/**
|
|
57
|
-
* Serious: changes what the product does (which
|
|
58
|
-
* in, what a summary claims)
|
|
59
|
-
*
|
|
64
|
+
* Its level. Serious (must pass): changes what the product does (which
|
|
65
|
+
* queue a ticket lands in, what a summary claims); models are ranked on
|
|
66
|
+
* these misses first. Moderate (should pass): matters, but less. Minor
|
|
67
|
+
* (nice to have): a fair difference of judgment (a category, how finely
|
|
68
|
+
* to split); tracked against its aim, but never fails an answer. A
|
|
69
|
+
* person can change any check's level in the suite's settings.
|
|
70
|
+
*/
|
|
71
|
+
severity: "serious" | "moderate" | "minor";
|
|
72
|
+
/**
|
|
73
|
+
* The pass rate it aims for, shown as its aim; default by severity
|
|
74
|
+
* (checkBar).
|
|
60
75
|
*/
|
|
61
|
-
severity: "serious" | "minor";
|
|
62
|
-
/** Pass rate it should reach; default by severity (checkBar). */
|
|
63
76
|
bar?: number;
|
|
64
77
|
};
|
|
65
78
|
|
|
66
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Each level's aim when a check sets none: must pass 95%, should pass 85%,
|
|
81
|
+
* nice to have 75%.
|
|
82
|
+
*/
|
|
83
|
+
export const DEFAULT_AIM: Readonly<Record<CheckDef["severity"], number>> = {
|
|
84
|
+
serious: 0.95,
|
|
85
|
+
moderate: 0.85,
|
|
86
|
+
minor: 0.75,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** The levels in order, most important first, for sorting checks. */
|
|
90
|
+
export const SEVERITY_ORDER: readonly CheckDef["severity"][] = [
|
|
91
|
+
"serious",
|
|
92
|
+
"moderate",
|
|
93
|
+
"minor",
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* What the pages call each level: a serious check must pass, a moderate
|
|
98
|
+
* one should pass, a minor one is nice to have.
|
|
99
|
+
*/
|
|
100
|
+
export const SEVERITY_LABEL: Readonly<Record<CheckDef["severity"], string>> = {
|
|
101
|
+
serious: "Must pass",
|
|
102
|
+
moderate: "Should pass",
|
|
103
|
+
minor: "Nice to have",
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** The pass rate a check should reach: its own, else its level's (DEFAULT_AIM). */
|
|
67
107
|
export function checkBar(c: CheckDef): number {
|
|
68
|
-
return c.bar ??
|
|
108
|
+
return c.bar ?? DEFAULT_AIM[c.severity];
|
|
69
109
|
}
|
|
70
110
|
|
|
71
111
|
/**
|
|
@@ -80,7 +120,7 @@ export function pctBeside(rate: number, bar: number): string {
|
|
|
80
120
|
: `${whole}%`;
|
|
81
121
|
}
|
|
82
122
|
|
|
83
|
-
/** Meets the bar, is within 10 points of it, or is further below. */
|
|
123
|
+
/** Meets the aim (bar), is within 10 points of it, or is further below. */
|
|
84
124
|
export function barStatus(
|
|
85
125
|
rate: number,
|
|
86
126
|
bar: number,
|
|
@@ -106,7 +146,7 @@ export const FAVOR_TEXT: Record<SuitePriority["favor"], string> = {
|
|
|
106
146
|
"speed: someone waits on this, so a model that scores as well and answers clearly faster is worth switching to, and so is one about as accurate (within 10 points) in half the time",
|
|
107
147
|
cost: "cost: this runs in the background, often, so a model that scores as well and is clearly cheaper is worth switching to, and so is one about as accurate (within 10 points) at half the cost",
|
|
108
148
|
quality:
|
|
109
|
-
"quality: people read and act on this, so only clearly better accuracy or fewer
|
|
149
|
+
"quality: people read and act on this, so only clearly better accuracy or fewer must-pass misses is worth switching for",
|
|
110
150
|
};
|
|
111
151
|
|
|
112
152
|
/**
|
|
@@ -120,6 +160,14 @@ export type Suite<Input, Output, Label> = {
|
|
|
120
160
|
priority: SuitePriority;
|
|
121
161
|
label: string;
|
|
122
162
|
description: string;
|
|
163
|
+
/**
|
|
164
|
+
* How many cases this suite's answer key should have (default 50). Lower
|
|
165
|
+
* it for a suite whose every case costs real money (a billed web search,
|
|
166
|
+
* say), where about 10 is the sensible size. A person can change it on
|
|
167
|
+
* the suite's page (Suite settings) when the runner has a
|
|
168
|
+
* `suiteSettings` store; theirs wins.
|
|
169
|
+
*/
|
|
170
|
+
targetCases?: number;
|
|
123
171
|
/** Bump when checks change, so runs say which grading they used. */
|
|
124
172
|
graderVersion: string;
|
|
125
173
|
input: z.ZodType<Input>;
|
package/starter/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
prismaFeedbackStore,
|
|
16
16
|
prismaSettingsStore,
|
|
17
17
|
prismaStore,
|
|
18
|
+
prismaSuiteSettingsStore,
|
|
18
19
|
} from "@crowandraven/evalkeeper/prisma";
|
|
19
20
|
// TODO: your app's Prisma client, with Evalkeeper's models added to the
|
|
20
21
|
// schema (node_modules/@crowandraven/evalkeeper/schema/evalkeeper.prisma).
|
|
@@ -88,6 +89,9 @@ export const runner = createRunner({
|
|
|
88
89
|
instructionTexts: (operation) => INSTRUCTION_TEXTS[operation] ?? [],
|
|
89
90
|
route: routeFor,
|
|
90
91
|
candidates: (operation) => ({ models: modelsFor(operation) }),
|
|
92
|
+
// Lets people change a suite's target number of cases on its page
|
|
93
|
+
// (the EvalSuiteSetting table). Leave it out to keep the targets in code.
|
|
94
|
+
suiteSettings: prismaSuiteSettingsStore(prisma),
|
|
91
95
|
});
|
|
92
96
|
|
|
93
97
|
/**
|
|
@@ -116,4 +120,7 @@ export const wiring = {
|
|
|
116
120
|
routeFor,
|
|
117
121
|
answerEditors,
|
|
118
122
|
requireAdmin,
|
|
123
|
+
// TODO, optional: `spending` (an EvalSpending), if your app keeps daily
|
|
124
|
+
// spending limits for eval tests. The pages then show what tests spent
|
|
125
|
+
// and save the limits, with a stop.
|
|
119
126
|
} satisfies Omit<EvalWiring, "basePath">;
|
|
@@ -101,6 +101,26 @@ export async function keepAnswer(form: FormData) {
|
|
|
101
101
|
return actions.keepAnswer(form);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export async function retireReplacedStarters(form: FormData) {
|
|
105
|
+
return actions.retireReplacedStarters(form);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function saveSuiteSettings(form: FormData) {
|
|
109
|
+
return actions.saveSuiteSettings(form);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function saveLimits(form: FormData) {
|
|
113
|
+
return actions.saveLimits(form);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function stopTests(form: FormData) {
|
|
117
|
+
return actions.stopTests(form);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function allowTests(form: FormData) {
|
|
121
|
+
return actions.allowTests(form);
|
|
122
|
+
}
|
|
123
|
+
|
|
104
124
|
export async function runWeeklyNow() {
|
|
105
125
|
return actions.runWeeklyNow();
|
|
106
126
|
}
|