@crowandraven/evalkeeper 0.8.0 → 0.10.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/cli/addPages.js +1 -1
- package/dist/cli/addPages.js.map +1 -1
- package/dist/feedback.d.ts +3 -1
- package/dist/feedback.js +3 -1
- package/dist/feedback.js.map +1 -1
- package/dist/glossary.d.ts +5 -0
- package/dist/glossary.js +5 -0
- package/dist/glossary.js.map +1 -1
- package/dist/health.d.ts +4 -1
- package/dist/health.js +4 -2
- package/dist/health.js.map +1 -1
- package/dist/importCases.d.ts +15 -4
- package/dist/importCases.js +20 -18
- package/dist/importCases.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/reviews.d.ts +172 -0
- package/dist/reviews.js +294 -0
- package/dist/reviews.js.map +1 -0
- package/dist/runner.d.ts +14 -1
- package/dist/runner.js +10 -0
- package/dist/runner.js.map +1 -1
- package/dist/suggest.d.ts +52 -2
- package/dist/suggest.js +101 -8
- package/dist/suggest.js.map +1 -1
- package/dist/suiteContract.d.ts +3 -2
- package/dist/suiteContract.js +5 -2
- package/dist/suiteContract.js.map +1 -1
- package/dist/suites/attackImport.d.ts +99 -0
- package/dist/suites/attackImport.js +283 -0
- package/dist/suites/attackImport.js.map +1 -0
- package/dist/suites/crisisRisk.d.ts +9 -2
- package/dist/suites/crisisRisk.js +8 -3
- package/dist/suites/crisisRisk.js.map +1 -1
- package/dist/suites/crisisRiskCases.d.ts +4 -3
- package/dist/suites/crisisRiskCases.js +4 -3
- package/dist/suites/crisisRiskCases.js.map +1 -1
- package/dist/suites/crisisRiskReviews.d.ts +15 -0
- package/dist/suites/crisisRiskReviews.js +926 -0
- package/dist/suites/crisisRiskReviews.js.map +1 -0
- package/dist/suites/hopelessness.d.ts +9 -2
- package/dist/suites/hopelessness.js +8 -5
- package/dist/suites/hopelessness.js.map +1 -1
- package/dist/suites/hopelessnessCases.d.ts +3 -2
- package/dist/suites/hopelessnessCases.js +3 -2
- package/dist/suites/hopelessnessCases.js.map +1 -1
- package/dist/suites/hopelessnessReviews.d.ts +15 -0
- package/dist/suites/hopelessnessReviews.js +1080 -0
- package/dist/suites/hopelessnessReviews.js.map +1 -0
- package/dist/suites/index.d.ts +5 -0
- package/dist/suites/index.js +5 -0
- package/dist/suites/index.js.map +1 -1
- package/dist/suites/injection.d.ts +162 -0
- package/dist/suites/injection.js +331 -0
- package/dist/suites/injection.js.map +1 -0
- package/dist/suites/injectionAttacks.d.ts +3 -0
- package/dist/suites/injectionAttacks.js +34 -0
- package/dist/suites/injectionAttacks.js.map +1 -0
- package/dist/types.d.ts +100 -2
- package/dist/types.js +106 -11
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/addPages.ts +1 -1
- package/src/feedback.ts +3 -1
- package/src/glossary.ts +10 -0
- package/src/health.ts +4 -2
- package/src/importCases.ts +21 -20
- package/src/index.ts +1 -0
- package/src/reviews.ts +428 -0
- package/src/runner.ts +15 -1
- package/src/suggest.ts +145 -13
- package/src/suiteContract.ts +5 -2
- package/src/suites/attackImport.ts +327 -0
- package/src/suites/crisisRisk.ts +15 -3
- package/src/suites/crisisRiskCases.ts +4 -3
- package/src/suites/crisisRiskReviews.ts +927 -0
- package/src/suites/hopelessness.ts +15 -5
- package/src/suites/hopelessnessCases.ts +3 -2
- package/src/suites/hopelessnessReviews.ts +1081 -0
- package/src/suites/index.ts +5 -0
- package/src/suites/injection.ts +463 -0
- package/src/suites/injectionAttacks.ts +136 -0
- package/src/types.ts +169 -17
- package/starter/index.ts +11 -0
- package/templates/app/evals/[suite]/page.tsx +185 -32
- package/templates/app/evals/[suite]/rate/page.tsx +14 -4
- package/templates/app/evals/feedback/page.tsx +3 -1
- package/templates/app/evals/page.tsx +44 -5
- package/templates/components/evalkeeper/AnswerKey.tsx +35 -6
- package/templates/components/evalkeeper/Fields.tsx +49 -5
- package/templates/lib/evalkeeper/actions.ts +39 -15
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Metadata } from "next";
|
|
2
2
|
import Link from "next/link";
|
|
3
3
|
import {
|
|
4
|
+
attackMistakes,
|
|
5
|
+
attacksFrom,
|
|
4
6
|
attention,
|
|
7
|
+
isInjectionSuite,
|
|
5
8
|
perAnswer,
|
|
6
9
|
seconds,
|
|
7
10
|
suiteHealth,
|
|
@@ -51,8 +54,14 @@ export default async function EvalsHub() {
|
|
|
51
54
|
const down = thumbs.reduce((t, s) => t + s.down, 0);
|
|
52
55
|
const waiting = thumbs.reduce((t, s) => t + s.open, 0);
|
|
53
56
|
const flagged = thumbs.filter((s) => s.alert).length;
|
|
57
|
+
// An injection suite shows on its base suite's card, not its own.
|
|
58
|
+
const attacksOn = (key: string) =>
|
|
59
|
+
boards.filter((x) => isInjectionSuite(x.suite) && x.suite.base.key === key);
|
|
60
|
+
const cards = boards
|
|
61
|
+
.map((b, i) => ({ b, i }))
|
|
62
|
+
.filter(({ b }) => !isInjectionSuite(b.suite));
|
|
54
63
|
const needs = attention(
|
|
55
|
-
|
|
64
|
+
cards.map(({ b }) => ({
|
|
56
65
|
key: b.suite.key,
|
|
57
66
|
label: b.suite.label,
|
|
58
67
|
rows: b.rows,
|
|
@@ -123,9 +132,10 @@ export default async function EvalsHub() {
|
|
|
123
132
|
Suites
|
|
124
133
|
<InfoTip term="suites" />
|
|
125
134
|
</h2>
|
|
126
|
-
{
|
|
135
|
+
{cards.length === 0 && <NoSuites />}
|
|
127
136
|
<div className="space-y-4">
|
|
128
|
-
{
|
|
137
|
+
{cards.map(({ b, i }) => {
|
|
138
|
+
const attacked = attacksOn(b.suite.key);
|
|
129
139
|
const h = suiteHealth(
|
|
130
140
|
b.rows,
|
|
131
141
|
b.suite.checks,
|
|
@@ -133,12 +143,14 @@ export default async function EvalsHub() {
|
|
|
133
143
|
b.cases,
|
|
134
144
|
b.provisional,
|
|
135
145
|
MODELS,
|
|
146
|
+
{ attacks: attacksFrom(attacked) },
|
|
136
147
|
);
|
|
137
148
|
const [history, current] = histories[i] ?? [[], null];
|
|
138
149
|
return (
|
|
139
150
|
<SuiteCard
|
|
140
151
|
key={b.suite.key}
|
|
141
152
|
board={b}
|
|
153
|
+
attacked={attacked}
|
|
142
154
|
health={h}
|
|
143
155
|
history={history}
|
|
144
156
|
current={current}
|
|
@@ -223,16 +235,19 @@ const scoreTone = (rate: number) =>
|
|
|
223
235
|
|
|
224
236
|
/**
|
|
225
237
|
* One feature on the hub: its live version and models, what the live
|
|
226
|
-
* model costs and how fast it is, its latest test,
|
|
227
|
-
* its settings history.
|
|
238
|
+
* model costs and how fast it is, its latest test, how it does under
|
|
239
|
+
* attack, what needs a look, and its settings history.
|
|
228
240
|
*/
|
|
229
241
|
function SuiteCard({
|
|
230
242
|
board: b,
|
|
243
|
+
attacked,
|
|
231
244
|
health: h,
|
|
232
245
|
history,
|
|
233
246
|
current,
|
|
234
247
|
}: {
|
|
235
248
|
board: Board;
|
|
249
|
+
/** The injection suites that attack this feature. */
|
|
250
|
+
attacked: Board[];
|
|
236
251
|
health: ReturnType<typeof suiteHealth>;
|
|
237
252
|
history: HistoryEntry[];
|
|
238
253
|
current: { settings: Settings; version: SettingsVersion | null } | null;
|
|
@@ -327,6 +342,30 @@ function SuiteCard({
|
|
|
327
342
|
</ul>
|
|
328
343
|
)}
|
|
329
344
|
|
|
345
|
+
{attacked.map((a) => {
|
|
346
|
+
const n = live ? attackMistakes(live.key, attacksFrom([a])) : null;
|
|
347
|
+
return (
|
|
348
|
+
<p key={a.suite.key} className="relative text-sm">
|
|
349
|
+
Under attack
|
|
350
|
+
<InfoTip term="underAttack" />:{" "}
|
|
351
|
+
{n === null ? (
|
|
352
|
+
<span className="text-muted">live model not tested</span>
|
|
353
|
+
) : (
|
|
354
|
+
<span className={n ? "font-semibold text-bad" : "text-good"}>
|
|
355
|
+
{n} serious {n === 1 ? "mistake" : "mistakes"}
|
|
356
|
+
</span>
|
|
357
|
+
)}{" "}
|
|
358
|
+
· {a.cases} attack cases ·{" "}
|
|
359
|
+
<Link
|
|
360
|
+
href={evalsPath(a.suite.key)}
|
|
361
|
+
className="text-accent hover:underline"
|
|
362
|
+
>
|
|
363
|
+
{a.suite.label}
|
|
364
|
+
</Link>
|
|
365
|
+
</p>
|
|
366
|
+
);
|
|
367
|
+
})}
|
|
368
|
+
|
|
330
369
|
{s && (
|
|
331
370
|
<details className="group/history relative rounded-md bg-tint">
|
|
332
371
|
<summary className="flex list-none items-center justify-between gap-2 p-3 text-sm font-medium">
|
|
@@ -6,11 +6,14 @@ import {
|
|
|
6
6
|
type AnySuite,
|
|
7
7
|
type BoardRow,
|
|
8
8
|
type CheckResult,
|
|
9
|
+
EXPERT_REVIEWED,
|
|
10
|
+
FROM_BASE_CASE,
|
|
11
|
+
isShippedReview,
|
|
9
12
|
} from "@crowandraven/evalkeeper";
|
|
10
13
|
import { addCase, editAnswer, retireCase } from "@/lib/evalkeeper/actions";
|
|
11
14
|
import { Check, ChevronRight, CircleAlert, X } from "lucide-react";
|
|
12
|
-
import { store } from "@/lib/evalkeeper";
|
|
13
|
-
import { FieldValues, Fields } from "./Fields";
|
|
15
|
+
import { answerEditors, store } from "@/lib/evalkeeper";
|
|
16
|
+
import { AnswerInput, FieldValues, Fields } from "./Fields";
|
|
14
17
|
import { AddCaseHeader } from "./AddCase";
|
|
15
18
|
import { CaseMenu } from "./CaseMenu";
|
|
16
19
|
import { ConfirmAnswer } from "./ConfirmAnswer";
|
|
@@ -82,14 +85,18 @@ export async function AnswerKey({
|
|
|
82
85
|
tools={tools}
|
|
83
86
|
form={
|
|
84
87
|
fields &&
|
|
85
|
-
suite.labelFromForm && (
|
|
88
|
+
(suite.labelFromForm || answerEditors[suite.key]) && (
|
|
86
89
|
<form action={addCase} className="space-y-4">
|
|
87
90
|
<input type="hidden" name="suite" value={suite.key} />
|
|
88
91
|
<Fields fields={fields.input} prefix="new-" />
|
|
89
92
|
<p className="readable text-sm text-muted">
|
|
90
93
|
What a good answer is. You're writing it, so it's confirmed.
|
|
91
94
|
</p>
|
|
92
|
-
<
|
|
95
|
+
<AnswerInput
|
|
96
|
+
fields={fields.label}
|
|
97
|
+
editor={answerEditors[suite.key]}
|
|
98
|
+
prefix="new-"
|
|
99
|
+
/>
|
|
93
100
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
94
101
|
<div className="space-y-1">
|
|
95
102
|
<label
|
|
@@ -173,6 +180,18 @@ function CaseItem({
|
|
|
173
180
|
c.labels.find((l) => l.status === "CONFIRMED") ??
|
|
174
181
|
c.labels.find((l) => l.status === "PROVISIONAL") ??
|
|
175
182
|
c.labels.find((l) => l.status === "PENDING");
|
|
183
|
+
// A confirmation from outside the app: shipped with the suite, or
|
|
184
|
+
// carried from the case an attack case was made from.
|
|
185
|
+
const shipped =
|
|
186
|
+
answer?.status !== "CONFIRMED"
|
|
187
|
+
? null
|
|
188
|
+
: answer.raterRole === FROM_BASE_CASE
|
|
189
|
+
? { text: "From base case", term: "fromBaseCase" as const }
|
|
190
|
+
: !isShippedReview(answer)
|
|
191
|
+
? null
|
|
192
|
+
: answer.raterRole === EXPERT_REVIEWED
|
|
193
|
+
? { text: "Expert reviewed", term: "expertReviewed" as const }
|
|
194
|
+
: { text: "Author reviewed", term: "authorReviewed" as const };
|
|
176
195
|
const status = (answer && STATUS[answer.status]) ?? {
|
|
177
196
|
text: "No answer",
|
|
178
197
|
tone: "warn" as const,
|
|
@@ -206,6 +225,11 @@ function CaseItem({
|
|
|
206
225
|
<Tip term={status.term} id={`status-${c.id}`}>
|
|
207
226
|
<Chip tone={status.tone}>{status.text}</Chip>
|
|
208
227
|
</Tip>
|
|
228
|
+
{shipped && (
|
|
229
|
+
<Tip term={shipped.term} id={`reviewed-${c.id}`}>
|
|
230
|
+
<Chip tone="neutral">{shipped.text}</Chip>
|
|
231
|
+
</Tip>
|
|
232
|
+
)}
|
|
209
233
|
<Tip term={c.split === "TEST" ? "test" : "dev"} id={`split-${c.id}`}>
|
|
210
234
|
<Chip tone="neutral">{c.split === "TEST" ? "Test" : "Dev"}</Chip>
|
|
211
235
|
</Tip>
|
|
@@ -259,6 +283,9 @@ function CaseItem({
|
|
|
259
283
|
{JSON.stringify(answer?.value ?? null, null, 2)}
|
|
260
284
|
</pre>
|
|
261
285
|
)}
|
|
286
|
+
{shipped && answer?.note && (
|
|
287
|
+
<p className="readable text-xs text-muted">{answer.note}</p>
|
|
288
|
+
)}
|
|
262
289
|
{(tags.length > 0 || c.note) && (
|
|
263
290
|
<p className="readable text-xs text-muted">
|
|
264
291
|
{tags.length > 0 && `Tags: ${tags.join(", ")}. `}
|
|
@@ -325,7 +352,7 @@ function CaseItem({
|
|
|
325
352
|
retire={retireCase}
|
|
326
353
|
startEditing={!answer}
|
|
327
354
|
editLabel={
|
|
328
|
-
suite.fields && suite.labelFromForm
|
|
355
|
+
suite.fields && (suite.labelFromForm || answerEditors[suite.key])
|
|
329
356
|
? answer
|
|
330
357
|
? "Edit answer"
|
|
331
358
|
: "Write the answer"
|
|
@@ -340,8 +367,10 @@ function CaseItem({
|
|
|
340
367
|
>
|
|
341
368
|
<input type="hidden" name="suite" value={suite.key} />
|
|
342
369
|
<input type="hidden" name="case" value={c.id} />
|
|
343
|
-
<
|
|
370
|
+
<AnswerInput
|
|
344
371
|
fields={suite.fields.label}
|
|
372
|
+
editor={answerEditors[suite.key]}
|
|
373
|
+
input={c.input}
|
|
345
374
|
values={answer?.value}
|
|
346
375
|
prefix={`${c.id}-`}
|
|
347
376
|
/>
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ANSWER_JSON_FIELD,
|
|
3
|
+
asText,
|
|
4
|
+
fieldValue,
|
|
5
|
+
type AnswerEditorProps,
|
|
6
|
+
type FormField,
|
|
7
|
+
} from "@crowandraven/evalkeeper";
|
|
2
8
|
import { InfoTip } from "./Tip";
|
|
3
9
|
|
|
4
10
|
/**
|
|
@@ -54,8 +60,9 @@ export function Fields({
|
|
|
54
60
|
name={f.name}
|
|
55
61
|
defaultValue={value}
|
|
56
62
|
required={f.required}
|
|
57
|
-
rows={f.kind === "lines" ? 4 : 5}
|
|
58
|
-
|
|
63
|
+
rows={f.kind === "lines" ? 4 : f.kind === "json" ? 8 : 5}
|
|
64
|
+
spellCheck={f.kind !== "json"}
|
|
65
|
+
className={`${box} ${f.kind === "json" ? "font-mono text-xs" : ""}`}
|
|
59
66
|
/>
|
|
60
67
|
)}
|
|
61
68
|
<p className="readable text-xs text-muted">{f.help}</p>
|
|
@@ -87,8 +94,12 @@ export function FieldValues({
|
|
|
87
94
|
{f.label}
|
|
88
95
|
<InfoTip text={f.help} id={`${prefix}${f.name}-read`} />
|
|
89
96
|
</dt>
|
|
90
|
-
<dd className="readable whitespace-pre-wrap">
|
|
91
|
-
{
|
|
97
|
+
<dd className="readable break-words whitespace-pre-wrap">
|
|
98
|
+
{f.kind === "json" && v !== undefined && v !== null ? (
|
|
99
|
+
<pre className="text-xs whitespace-pre-wrap">
|
|
100
|
+
{JSON.stringify(v, null, 2)}
|
|
101
|
+
</pre>
|
|
102
|
+
) : Array.isArray(v) ? (
|
|
92
103
|
v.length ? (
|
|
93
104
|
<ul className="list-disc pl-5">
|
|
94
105
|
{v.map((x, i) => (
|
|
@@ -108,3 +119,36 @@ export function FieldValues({
|
|
|
108
119
|
</dl>
|
|
109
120
|
);
|
|
110
121
|
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A suite's answer, for writing or editing it: the app's own answer editor
|
|
125
|
+
* when it registered one for this suite (`answerEditors` in the wiring
|
|
126
|
+
* module), otherwise the suite's answer fields.
|
|
127
|
+
*/
|
|
128
|
+
export function AnswerInput({
|
|
129
|
+
fields,
|
|
130
|
+
editor: Editor,
|
|
131
|
+
input = null,
|
|
132
|
+
values,
|
|
133
|
+
prefix = "",
|
|
134
|
+
}: {
|
|
135
|
+
fields: FormField[];
|
|
136
|
+
/** The app's editor for this suite, if any. */
|
|
137
|
+
editor?: React.ComponentType<AnswerEditorProps> | undefined;
|
|
138
|
+
/** The case's input; null on "Add a case". */
|
|
139
|
+
input?: unknown;
|
|
140
|
+
values?: unknown;
|
|
141
|
+
prefix?: string;
|
|
142
|
+
}) {
|
|
143
|
+
if (Editor)
|
|
144
|
+
return (
|
|
145
|
+
<Editor
|
|
146
|
+
name={ANSWER_JSON_FIELD}
|
|
147
|
+
idPrefix={prefix}
|
|
148
|
+
input={input}
|
|
149
|
+
value={values ?? null}
|
|
150
|
+
fields={fields}
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
return <Fields fields={fields} values={values} prefix={prefix} />;
|
|
154
|
+
}
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
import { after } from "next/server";
|
|
4
4
|
import { revalidatePath } from "next/cache";
|
|
5
5
|
import {
|
|
6
|
+
answerFromForm,
|
|
7
|
+
attackMistakes,
|
|
8
|
+
attacksFrom,
|
|
6
9
|
blindRating,
|
|
7
10
|
caseFromFeedback,
|
|
8
11
|
formText,
|
|
12
|
+
isInjectionSuite,
|
|
9
13
|
leakNote,
|
|
10
14
|
raterStatus,
|
|
11
15
|
skipMark,
|
|
@@ -33,6 +37,21 @@ import { runWeeklyCheck, startWeeklyCheck } from "./weekly";
|
|
|
33
37
|
const suiteFrom = (form: FormData) =>
|
|
34
38
|
runner.suiteOrThrow(formText(form, "suite"));
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The suite whose page chooses models: never an injection suite, whose
|
|
42
|
+
* results show on its base suite's page and count in its suggestion.
|
|
43
|
+
*/
|
|
44
|
+
function choosingSuite(form: FormData) {
|
|
45
|
+
const suite = suiteFrom(form);
|
|
46
|
+
if (isInjectionSuite(suite))
|
|
47
|
+
throw new Error(`Choose models on ${suite.base.label}`);
|
|
48
|
+
return suite;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A suite's injection suites, as its suggestion reads them. */
|
|
52
|
+
const attacksOn = async (suiteKey: string) =>
|
|
53
|
+
attacksFrom(await runner.attackBoards(suiteKey));
|
|
54
|
+
|
|
36
55
|
export async function testModel(form: FormData) {
|
|
37
56
|
await requireAdmin();
|
|
38
57
|
const suite = suiteFrom(form);
|
|
@@ -102,15 +121,16 @@ const VS: Record<string, string> = {
|
|
|
102
121
|
|
|
103
122
|
export async function makeLive(form: FormData) {
|
|
104
123
|
const admin = await requireAdmin();
|
|
105
|
-
const suite =
|
|
124
|
+
const suite = choosingSuite(form);
|
|
106
125
|
const model = formText(form, "model");
|
|
107
126
|
const { row, evidence } = await evidenceFor(suite.key, model);
|
|
127
|
+
const attacked = attackMistakes(row.key, await attacksOn(suite.key));
|
|
108
128
|
await settings.update(
|
|
109
129
|
suite.operation,
|
|
110
130
|
{ model },
|
|
111
131
|
{
|
|
112
132
|
by: admin.name,
|
|
113
|
-
reason: `Made ${row.label} live: ${evidence.score.right}/${evidence.score.total}, ${VS[row.vsLive ?? ""] ?? "no comparison"}`,
|
|
133
|
+
reason: `Made ${row.label} live: ${evidence.score.right}/${evidence.score.total}, ${VS[row.vsLive ?? ""] ?? "no comparison"}${attacked === null ? "" : `; ${attacked} serious ${attacked === 1 ? "mistake" : "mistakes"} under attack`}`,
|
|
114
134
|
evidence,
|
|
115
135
|
},
|
|
116
136
|
);
|
|
@@ -119,7 +139,7 @@ export async function makeLive(form: FormData) {
|
|
|
119
139
|
|
|
120
140
|
export async function makeFallback(form: FormData) {
|
|
121
141
|
const admin = await requireAdmin();
|
|
122
|
-
const suite =
|
|
142
|
+
const suite = choosingSuite(form);
|
|
123
143
|
const model = formText(form, "model");
|
|
124
144
|
const { reason, evidence } = await fallbackEvidence(suite.key, model);
|
|
125
145
|
await settings.update(
|
|
@@ -133,9 +153,14 @@ export async function makeFallback(form: FormData) {
|
|
|
133
153
|
/** Applies the suggestion: its live and fallback models, in one change. */
|
|
134
154
|
export async function useSuggestion(form: FormData) {
|
|
135
155
|
const admin = await requireAdmin();
|
|
136
|
-
const suite =
|
|
137
|
-
const board = await
|
|
138
|
-
|
|
156
|
+
const suite = choosingSuite(form);
|
|
157
|
+
const [board, attacks] = await Promise.all([
|
|
158
|
+
runner.board(suite.key),
|
|
159
|
+
attacksOn(suite.key),
|
|
160
|
+
]);
|
|
161
|
+
const s = suggest(board.rows, suite.checks, suite.priority, MODELS, {
|
|
162
|
+
attacks,
|
|
163
|
+
});
|
|
139
164
|
if (!s || s.same) return;
|
|
140
165
|
await settings.update(
|
|
141
166
|
suite.operation,
|
|
@@ -159,7 +184,7 @@ export async function useSuggestion(form: FormData) {
|
|
|
159
184
|
/** Makes an earlier version live again; a reason is required. */
|
|
160
185
|
export async function rollBackSettings(form: FormData) {
|
|
161
186
|
const admin = await requireAdmin();
|
|
162
|
-
const suite =
|
|
187
|
+
const suite = choosingSuite(form);
|
|
163
188
|
const reason = formText(form, "reason");
|
|
164
189
|
if (!reason) throw new Error("Say why you're rolling back");
|
|
165
190
|
await settings.rollBack(suite.operation, formText(form, "version"), {
|
|
@@ -192,7 +217,6 @@ export async function rescore(form: FormData) {
|
|
|
192
217
|
export async function addCase(form: FormData) {
|
|
193
218
|
await requireAdmin();
|
|
194
219
|
const suite = suiteFrom(form);
|
|
195
|
-
if (!suite.labelFromForm) throw new Error("This suite has no answer form");
|
|
196
220
|
const { input, removed } = withoutLeaks(
|
|
197
221
|
suite,
|
|
198
222
|
suite.inputFromForm(form),
|
|
@@ -214,7 +238,7 @@ export async function addCase(form: FormData) {
|
|
|
214
238
|
{
|
|
215
239
|
kind: "EXPECTED",
|
|
216
240
|
status: "CONFIRMED",
|
|
217
|
-
value: suite
|
|
241
|
+
value: answerFromForm(suite, form),
|
|
218
242
|
raterRole: "OWNER",
|
|
219
243
|
raterId: null,
|
|
220
244
|
note: null,
|
|
@@ -231,14 +255,13 @@ export async function addCase(form: FormData) {
|
|
|
231
255
|
export async function editAnswer(form: FormData) {
|
|
232
256
|
await requireAdmin();
|
|
233
257
|
const suite = suiteFrom(form);
|
|
234
|
-
if (!suite.labelFromForm) throw new Error("This suite has no answer form");
|
|
235
258
|
const caseId = formText(form, "case");
|
|
236
259
|
const known = (await store.listCases(suite.key)).some((c) => c.id === caseId);
|
|
237
260
|
if (!known) throw new Error("Unknown case");
|
|
238
261
|
await store.addLabel(caseId, {
|
|
239
262
|
kind: "EXPECTED",
|
|
240
263
|
status: "CONFIRMED",
|
|
241
|
-
value: suite
|
|
264
|
+
value: answerFromForm(suite, form),
|
|
242
265
|
raterRole: "OWNER",
|
|
243
266
|
raterId: null,
|
|
244
267
|
note: null,
|
|
@@ -256,7 +279,7 @@ export async function editAnswer(form: FormData) {
|
|
|
256
279
|
*/
|
|
257
280
|
async function caseToRate(form: FormData, raterId: string) {
|
|
258
281
|
const suite = suiteFrom(form);
|
|
259
|
-
if (suite.caseKind !== "imported"
|
|
282
|
+
if (suite.caseKind !== "imported")
|
|
260
283
|
throw new Error("This suite isn't rated blind");
|
|
261
284
|
const caseId = formText(form, "case");
|
|
262
285
|
const c = (await store.listCases(suite.key)).find((x) => x.id === caseId);
|
|
@@ -273,12 +296,11 @@ async function caseToRate(form: FormData, raterId: string) {
|
|
|
273
296
|
export async function rateBlind(form: FormData) {
|
|
274
297
|
const admin = await requireAdmin();
|
|
275
298
|
const { suite, c } = await caseToRate(form, admin.id);
|
|
276
|
-
if (!suite.labelFromForm) throw new Error("This suite has no answer form");
|
|
277
299
|
await store.addLabel(
|
|
278
300
|
c.id,
|
|
279
301
|
blindRating({
|
|
280
302
|
raterId: admin.id,
|
|
281
|
-
value: suite
|
|
303
|
+
value: answerFromForm(suite, form),
|
|
282
304
|
reason: formText(form, "reason"),
|
|
283
305
|
}),
|
|
284
306
|
);
|
|
@@ -317,7 +339,9 @@ async function find(id: string) {
|
|
|
317
339
|
export async function makeCase(form: FormData) {
|
|
318
340
|
await requireAdmin();
|
|
319
341
|
const f = await find(formText(form, "feedback"));
|
|
320
|
-
const suite = SUITES.find(
|
|
342
|
+
const suite = SUITES.find(
|
|
343
|
+
(s) => s.operation === f.operation && !isInjectionSuite(s),
|
|
344
|
+
);
|
|
321
345
|
const draft = suite ? caseFromFeedback(f, suite) : null;
|
|
322
346
|
if (!draft || !suite) throw new Error("This rating can't become a case");
|
|
323
347
|
const c = await store.createCase(draft);
|