@crowandraven/evalkeeper 0.14.0 → 0.15.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.
@@ -25,6 +25,9 @@ import {
25
25
  import { AnswerKey } from "./AnswerKey.js";
26
26
  import { ModelMenu } from "./ModelMenu.js";
27
27
  import { PriorityPicker } from "./PriorityPicker.js";
28
+ import { InfoPopover } from "./InfoPopover.js";
29
+ import { GLOSSARY } from "../glossary.js";
30
+ import type { AnswerGuide } from "../types.js";
28
31
  import { Tabs } from "./Tabs.js";
29
32
  import {
30
33
  Link,
@@ -41,7 +44,7 @@ import {
41
44
  Tip,
42
45
  } from "./pieces.js";
43
46
  import { pct, LINK, QUIET_BUTTON } from "./format.js";
44
- import { ChevronDown, RotateCw, ShieldAlert, Sparkles } from "lucide-react";
47
+ import { Plus, RotateCw, ShieldAlert, Sparkles } from "lucide-react";
45
48
  import { evalsPath, type EvalAppConfig, attacksResisted } from "./app.js";
46
49
  import { SettingsHistory } from "./SettingsHistory.js";
47
50
 
@@ -342,6 +345,8 @@ export function ModelTable({ data }: { data: SuitePageData }) {
342
345
  const ordered = orderRows(rows, suite.checks, priority, {
343
346
  live: suggestedLive,
344
347
  });
348
+ const tunable = tunableModels(data);
349
+ const columns = 7 + (showAttacks ? 1 : 0) + (suite.decisions ? 2 : 0);
345
350
  return (
346
351
  <>
347
352
  <section className="space-y-3">
@@ -617,6 +622,15 @@ export function ModelTable({ data }: { data: SuitePageData }) {
617
622
  </tr>
618
623
  ))}
619
624
  </tbody>
625
+ {tunable.length > 0 && (
626
+ <tfoot>
627
+ <tr>
628
+ <td colSpan={columns} className="p-2">
629
+ <TestSettingForm data={data} tunable={tunable} />
630
+ </td>
631
+ </tr>
632
+ </tfoot>
633
+ )}
620
634
  </table>
621
635
  </Card>
622
636
  </section>
@@ -625,52 +639,71 @@ export function ModelTable({ data }: { data: SuitePageData }) {
625
639
  }
626
640
 
627
641
  /**
628
- * Testing a model at a reasoning setting other than the feature's: less
629
- * reasoning is faster and cheaper, more can be more accurate. Each setting
630
- * gets its own row in the model table. Shows only when a model the feature
631
- * may use lists its settings in your catalog.
642
+ * The models a feature may use that list reasoning settings in your
643
+ * catalog, each with its settings; empty when there's nothing to test.
632
644
  */
633
- export function TestSettingSection({ data }: { data: SuitePageData }) {
634
- const { app, key, operation, choosesHere } = data;
635
- const tunable = app.runner.modelsFor(operation).flatMap((m) => {
645
+ function tunableModels(data: SuitePageData) {
646
+ const { app, operation, choosesHere } = data;
647
+ if (!choosesHere) return [];
648
+ return app.runner.modelsFor(operation).flatMap((m) => {
636
649
  const efforts = app.models[m]?.efforts;
637
650
  return efforts?.length
638
651
  ? [{ model: m, label: app.models[m]?.label ?? m, efforts }]
639
652
  : [];
640
653
  });
641
- if (!choosesHere || !tunable.length) return null;
654
+ }
655
+
656
+ /**
657
+ * Testing a model at a reasoning setting other than the feature's: less
658
+ * reasoning is faster and cheaper, more can be more accurate. Each setting
659
+ * gets its own row in the model table. The table's last row, inset.
660
+ */
661
+ function TestSettingForm({
662
+ data,
663
+ tunable,
664
+ }: {
665
+ data: SuitePageData;
666
+ tunable: ReturnType<typeof tunableModels>;
667
+ }) {
668
+ const { app, key } = data;
642
669
  return (
643
670
  <form
644
671
  action={app.actions.testModel}
645
- className="flex flex-wrap items-end gap-2"
672
+ className="flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md bg-tint px-3 py-2.5"
646
673
  >
647
674
  <input type="hidden" name="suite" value={key} />
648
- <div>
649
- <label htmlFor="test-setting" className="block text-sm font-medium">
650
- Test a reasoning setting
651
- <InfoTip term="reasoningSetting" id="test-setting" />
652
- </label>
653
- <Select
654
- id="test-setting"
655
- name="setting"
656
- className="mt-1 rounded-md border border-line bg-card px-3 py-2 text-sm"
657
- >
658
- {tunable.map((t) => (
659
- <optgroup key={t.model} label={t.label}>
660
- {t.efforts.map((e) => (
661
- <option key={e} value={JSON.stringify([t.model, e])}>
662
- {t.label} · {e} reasoning
663
- </option>
664
- ))}
665
- </optgroup>
666
- ))}
667
- </Select>
668
- </div>
675
+ <label htmlFor="test-setting" className="text-sm font-medium">
676
+ Test a reasoning setting
677
+ <InfoTip term="reasoningSetting" id="test-setting" />
678
+ </label>
679
+ <Select
680
+ id="test-setting"
681
+ name="setting"
682
+ className="rounded-md border border-line bg-card px-3 py-1.5 text-sm"
683
+ >
684
+ {tunable.map((t) => (
685
+ <optgroup key={t.model} label={t.label}>
686
+ {t.efforts.map((e) => (
687
+ <option key={e} value={JSON.stringify([t.model, e])}>
688
+ {t.label} · {e} reasoning
689
+ </option>
690
+ ))}
691
+ </optgroup>
692
+ ))}
693
+ </Select>
669
694
  <Submit variant="quiet">Test this setting</Submit>
670
695
  </form>
671
696
  );
672
697
  }
673
698
 
699
+ /**
700
+ * @deprecated The model table's last row holds this now; it renders
701
+ * nothing. Remove it from your page.
702
+ */
703
+ export function TestSettingSection(_props: { data: SuitePageData }) {
704
+ return null;
705
+ }
706
+
674
707
  const BAR_TONE = {
675
708
  meets:
676
709
  "bg-emerald-100 text-emerald-900 dark:bg-emerald-500/15 dark:text-emerald-200",
@@ -853,8 +886,8 @@ export function ChecksSection({ data }: { data: SuitePageData }) {
853
886
  }
854
887
 
855
888
  /**
856
- * Ways to fill the answer key, beside adding a case by hand: how to judge
857
- * an answer, testing with draft answers before review, an injection
889
+ * Ways to fill the answer key, beside adding a case by hand: testing with
890
+ * draft answers before review, an injection
858
891
  * suite's attack cases, starter cases not added yet, and more drafts from
859
892
  * the suite's `draftMore`. Each shows only when it applies and your app
860
893
  * passes its action.
@@ -865,42 +898,8 @@ export function AnswerKeyToolsSection({ data }: { data: SuitePageData }) {
865
898
  const inUse = cases.filter((c) => c.status !== "RETIRED");
866
899
  const drafts = draftAnswers(cases);
867
900
  const fresh = newStarters(suite.starter, cases);
868
- const guide =
869
- suite.answerGuide ??
870
- (suite.labelHelp ? { points: [{ text: suite.labelHelp }] } : null);
871
901
  const injection = isInjectionSuite(suite) ? suite : null;
872
902
  const parts = [
873
- guide && (
874
- <details
875
- key="guide"
876
- className="group rounded-lg border border-line bg-card"
877
- >
878
- <summary className="flex cursor-pointer list-none items-center justify-between gap-3 p-4 text-sm font-medium">
879
- How to judge an answer
880
- <ChevronDown
881
- aria-hidden
882
- className="h-4 w-4 transition-transform group-open:rotate-180"
883
- />
884
- </summary>
885
- <div className="readable space-y-2 px-4 pb-4 text-sm">
886
- {guide.lead && <p className="font-medium">{guide.lead}</p>}
887
- {(() => {
888
- const items = guide.points.map((p, n) => (
889
- <li key={n}>
890
- {p.term && <strong>{p.term} </strong>}
891
- {p.text}
892
- </li>
893
- ));
894
- return guide.ordered ? (
895
- <ol className="list-decimal space-y-1 pl-5">{items}</ol>
896
- ) : (
897
- <ul className="list-disc space-y-1 pl-5">{items}</ul>
898
- );
899
- })()}
900
- {guide.note && <p className="text-muted">{guide.note}</p>}
901
- </div>
902
- </details>
903
- ),
904
903
  actions.useDraftsProvisionally && drafts.length > 0 && (
905
904
  <Card key="provisional" className="space-y-3">
906
905
  <p className="readable text-sm">
@@ -955,21 +954,59 @@ export function AnswerKeyToolsSection({ data }: { data: SuitePageData }) {
955
954
  if (!parts.length) return null;
956
955
  return <div className="space-y-3">{parts}</div>;
957
956
  }
957
+ /** A suite's answer guide: its lead-in, points (numbered when in order), and note. */
958
+ function AnswerGuideText({ guide }: { guide: AnswerGuide }) {
959
+ const items = guide.points.map((p, n) => (
960
+ <li key={n}>
961
+ {p.term && <strong>{p.term} </strong>}
962
+ {p.text}
963
+ </li>
964
+ ));
965
+ return (
966
+ <div className="space-y-2">
967
+ {guide.lead && <p>{guide.lead}</p>}
968
+ {guide.ordered ? (
969
+ <ol className="list-decimal space-y-1 pl-5">{items}</ol>
970
+ ) : (
971
+ <ul className="list-disc space-y-1 pl-5">{items}</ul>
972
+ )}
973
+ {guide.note && <p className="text-muted">{guide.note}</p>}
974
+ </div>
975
+ );
976
+ }
977
+
958
978
  /** The answer key: the cases in use and their answers, with ways to add and rate them. */
959
979
  export function AnswerKeySection({ data }: { data: SuitePageData }) {
960
980
  const { app, key, b, suite, rows, attackBoards } = data;
961
981
  // A feature's attack cases are a tab of its answer key.
962
982
  const attacked = attackBoards.filter((a) => a.cases > 0);
983
+ const guide =
984
+ suite.answerGuide ??
985
+ (suite.labelHelp ? { points: [{ text: suite.labelHelp }] } : null);
963
986
  const cases = (
964
987
  <AnswerKey
965
988
  app={app}
966
989
  suite={suite}
967
990
  rows={rows}
968
991
  heading={
969
- <h2 className="text-lg font-semibold">
970
- Answer key ({b.cases} cases in use)
971
- <InfoTip term="answerKey" />
972
- </h2>
992
+ guide ? (
993
+ // The guide's list can't sit inside the heading; its button sits beside it.
994
+ <div className="flex items-center">
995
+ <h2 className="text-lg font-semibold">
996
+ Answer key ({b.cases} cases in use)
997
+ </h2>
998
+ <InfoPopover label="About the answer key">
999
+ <p className="text-muted">{GLOSSARY.answerKey}</p>
1000
+ <p className="font-medium">How to judge an answer</p>
1001
+ <AnswerGuideText guide={guide} />
1002
+ </InfoPopover>
1003
+ </div>
1004
+ ) : (
1005
+ <h2 className="text-lg font-semibold">
1006
+ Answer key ({b.cases} cases in use)
1007
+ <InfoTip term="answerKey" />
1008
+ </h2>
1009
+ )
973
1010
  }
974
1011
  tools={
975
1012
  <>
@@ -1171,16 +1208,17 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1171
1208
  {/* What to do, in order: fix doubtful answers, fill thin spots, prune. */}
1172
1209
  <Card className="space-y-6 text-sm">
1173
1210
  {check && (
1174
- <div className="readable space-y-3">
1175
- <h3 className="font-medium">Check these answers</h3>
1211
+ <div className="space-y-3">
1212
+ <h3 className="font-medium">Answers worth a second look</h3>
1176
1213
  {h.split.length > 0 && (
1177
1214
  <div className="space-y-2">
1178
- <p>
1215
+ <p className="readable">
1179
1216
  Models split about evenly on {cases(h.split.length)}: some
1180
- give the answer key&apos;s answer, some don&apos;t. For each,
1181
- decide who&apos;s right. Keep the answer if it&apos;s right,
1182
- fix it if the models were, or retire the case if there&apos;s
1183
- no right answer.
1217
+ give the answer key&apos;s answer, some don&apos;t. That often
1218
+ means the answer is wrong or the case is unclear, and either
1219
+ one makes every score less trustworthy. For each, decide
1220
+ who&apos;s right: keep the answer, fix it, or retire the case
1221
+ if there&apos;s no right answer.
1184
1222
  <InfoTip term="splitCases" />
1185
1223
  </p>
1186
1224
  <ul className="space-y-2">
@@ -1195,7 +1233,7 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1195
1233
  >
1196
1234
  <div className="font-medium">{caseLink(c)}</div>
1197
1235
  {by && (
1198
- <p className="text-xs text-muted">
1236
+ <p className="readable text-xs text-muted">
1199
1237
  {by.right.length > 0 &&
1200
1238
  `Gave the answer key's answer: ${names(by.right)}. `}
1201
1239
  {by.wrong.length > 0 &&
@@ -1231,7 +1269,7 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1231
1269
  </div>
1232
1270
  )}
1233
1271
  {h.duplicates.length > 0 && (
1234
- <div className="space-y-1">
1272
+ <div className="readable space-y-1">
1235
1273
  <p>
1236
1274
  These pairs share nearly all their words, so each counts
1237
1275
  twice. Keep the clearer one and retire the other.
@@ -1285,23 +1323,36 @@ export function AnswerKeyHealthSection({ data }: { data: SuitePageData }) {
1285
1323
  </p>
1286
1324
  </form>
1287
1325
  ) : (
1288
- <>
1289
- <ul className="flex flex-wrap gap-1.5">
1290
- {thin.map((t) => (
1291
- <li key={t}>
1292
- <a
1293
- href={`#add-case=${encodeURIComponent(t)}`}
1294
- className="inline-flex rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800 hover:underline dark:bg-amber-500/15 dark:text-amber-200"
1295
- >
1296
- {t}
1297
- </a>
1298
- </li>
1299
- ))}
1300
- </ul>
1326
+ <div className="space-y-2">
1327
+ <p className="readable text-muted">
1328
+ Pick a topic to open Add a case with it already tagged.
1329
+ </p>
1330
+ <div className="flex flex-wrap items-center gap-3">
1331
+ <ul className="flex flex-wrap gap-1.5">
1332
+ {thin.map((t) => (
1333
+ <li key={t}>
1334
+ <a
1335
+ href={`#add-case=${encodeURIComponent(t)}`}
1336
+ className="inline-flex rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800 hover:underline dark:bg-amber-500/15 dark:text-amber-200"
1337
+ >
1338
+ {t}
1339
+ </a>
1340
+ </li>
1341
+ ))}
1342
+ </ul>
1343
+ <a
1344
+ href="#add-case="
1345
+ className={`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm ${QUIET_BUTTON}`}
1346
+ >
1347
+ <Plus aria-hidden className="h-4 w-4" />
1348
+ Add a case
1349
+ </a>
1350
+ </div>
1301
1351
  <p className="readable text-xs text-muted">
1302
- Pick a topic to add a case with it already tagged.
1352
+ A suite with <code>draftMore</code> drafts whole cases for the
1353
+ topics you pick instead.
1303
1354
  </p>
1304
- </>
1355
+ </div>
1305
1356
  )}
1306
1357
  <details className="group">
1307
1358
  <summary className="cursor-pointer text-muted">
@@ -1391,7 +1442,6 @@ export async function SuitePage({
1391
1442
  <SuggestionCard data={data} />
1392
1443
  <CasesInInstructions data={data} />
1393
1444
  <ModelTable data={data} />
1394
- <TestSettingSection data={data} />
1395
1445
  <CheckBreakdownSection data={data} />
1396
1446
  <Versions data={data} />
1397
1447
  <ChecksSection data={data} />
@@ -5,6 +5,7 @@ import {
5
5
  InfoTip,
6
6
  Link,
7
7
  RefreshWhile,
8
+ Spinner,
8
9
  Submit,
9
10
  Tip,
10
11
  LocalDate,
@@ -32,9 +33,19 @@ export function WeeklyCheck({
32
33
  Weekly check
33
34
  <InfoTip term="weeklyCheck" />
34
35
  </h2>
35
- <form action={app.actions.runWeeklyNow}>
36
- <Submit variant="quiet">Run it now</Submit>
37
- </form>
36
+ {weekly.running > 0 ? (
37
+ <span
38
+ role="status"
39
+ className="inline-flex items-center gap-2 rounded-md px-3 py-1.5 text-sm text-muted"
40
+ >
41
+ <Spinner />
42
+ Running
43
+ </span>
44
+ ) : (
45
+ <form action={app.actions.runWeeklyNow}>
46
+ <Submit variant="quiet">Run it now</Submit>
47
+ </form>
48
+ )}
38
49
  </div>
39
50
  <Card className="space-y-4">
40
51
  <p className="readable text-sm text-muted">
package/src/runner.ts CHANGED
@@ -813,13 +813,19 @@ export function createRunner(opts: RunnerOptions) {
813
813
  * set on its live model, at its live reasoning setting, marked as
814
814
  * started by the schedule. Record every suite's first, so a page can show
815
815
  * them running, then run each with `runEval(id, { fresh: true })`.
816
- * Returns the test's id, or null when the suite has no cases in use.
816
+ * Returns the test's id, or null when the suite has no cases in use or
817
+ * its weekly check is already running.
817
818
  * Needs `route`.
818
819
  */
819
820
  async function startDriftCheck(suiteKey: string): Promise<string | null> {
820
821
  if (!opts.route) throw new Error("The drift check needs the route option");
821
822
  const suite = suiteOrThrow(suiteKey);
822
823
  if (!(await casesFor(suite.key, "SMOKE")).length) return null;
824
+ // One check at a time: pressing Run it now twice doesn't start two.
825
+ await stopStuckRuns(suite.key);
826
+ const running = await store.listRuns(suite.key, { status: "RUNNING" });
827
+ if (running.some((r) => r.startedBy === SCHEDULED && r.set === "SMOKE"))
828
+ return null;
823
829
  const route = await opts.route(suite.operation);
824
830
  const { run } = await createRun({
825
831
  suite: suite.key,
package/src/types.ts CHANGED
@@ -280,7 +280,8 @@ export type Suite<Input, Output, Label> = {
280
280
  rateBlind?: boolean;
281
281
  /**
282
282
  * How a person should judge an answer, where it takes more than each
283
- * field's help: shown above the answer key as "How to judge an answer".
283
+ * field's help: opened from the info button beside the answer key's
284
+ * heading, as "How to judge an answer".
284
285
  * Without it, `labelHelp` shows there. For people only: it never reaches
285
286
  * the model, so it doesn't change the instructions hash.
286
287
  */
package/src/weekly.ts CHANGED
@@ -101,9 +101,14 @@ export function weeklySummary(args: {
101
101
  .filter((r) => r.startedBy === SCHEDULED && r.set === "SMOKE")
102
102
  .sort((a, b) => +b.startedAt - +a.startedAt);
103
103
  const lastAt = scheduled[0]?.startedAt ?? null;
104
- // The last weekly batch: everything started within a day of the newest.
104
+ // The last weekly batch: each suite's newest check started within a day
105
+ // of the newest, so a suite checked again (Run it now) shows its latest.
105
106
  const batch = lastAt
106
- ? scheduled.filter((r) => +lastAt - +r.startedAt < DAY)
107
+ ? scheduled.filter(
108
+ (r, i) =>
109
+ +lastAt - +r.startedAt < DAY &&
110
+ scheduled.findIndex((x) => x.suite === r.suite) === i,
111
+ )
107
112
  : [];
108
113
 
109
114
  const drift: WeeklySummary["drift"] = [];