@crowandraven/evalkeeper 0.13.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.
Files changed (105) hide show
  1. package/dist/drafts.d.ts +2 -0
  2. package/dist/drafts.js +3 -1
  3. package/dist/drafts.js.map +1 -1
  4. package/dist/failures.d.ts +16 -0
  5. package/dist/failures.js +40 -0
  6. package/dist/failures.js.map +1 -0
  7. package/dist/health.js +2 -1
  8. package/dist/health.js.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/legs.d.ts +4 -1
  13. package/dist/legs.js +6 -2
  14. package/dist/legs.js.map +1 -1
  15. package/dist/next/actions.js +53 -9
  16. package/dist/next/actions.js.map +1 -1
  17. package/dist/next/route.js +2 -1
  18. package/dist/next/route.js.map +1 -1
  19. package/dist/next/weekly.d.ts +7 -2
  20. package/dist/next/weekly.js +5 -3
  21. package/dist/next/weekly.js.map +1 -1
  22. package/dist/prune.d.ts +4 -1
  23. package/dist/prune.js +11 -2
  24. package/dist/prune.js.map +1 -1
  25. package/dist/react/AddCase.d.ts +12 -2
  26. package/dist/react/AddCase.js +70 -8
  27. package/dist/react/AddCase.js.map +1 -1
  28. package/dist/react/AnswerKey.js +11 -5
  29. package/dist/react/AnswerKey.js.map +1 -1
  30. package/dist/react/CaseMenu.d.ts +6 -1
  31. package/dist/react/CaseMenu.js +5 -2
  32. package/dist/react/CaseMenu.js.map +1 -1
  33. package/dist/react/CompareView.js +4 -4
  34. package/dist/react/CompareView.js.map +1 -1
  35. package/dist/react/FeedbackView.js +3 -3
  36. package/dist/react/FeedbackView.js.map +1 -1
  37. package/dist/react/HubSections.js +3 -4
  38. package/dist/react/HubSections.js.map +1 -1
  39. package/dist/react/InfoPopover.d.ts +19 -0
  40. package/dist/react/InfoPopover.js +46 -0
  41. package/dist/react/InfoPopover.js.map +1 -0
  42. package/dist/react/PriorityPicker.d.ts +21 -0
  43. package/dist/react/PriorityPicker.js +33 -0
  44. package/dist/react/PriorityPicker.js.map +1 -0
  45. package/dist/react/RunView.js +21 -5
  46. package/dist/react/RunView.js.map +1 -1
  47. package/dist/react/SettingsHistory.d.ts +2 -1
  48. package/dist/react/SettingsHistory.js +34 -26
  49. package/dist/react/SettingsHistory.js.map +1 -1
  50. package/dist/react/ShowEarlier.d.ts +11 -0
  51. package/dist/react/ShowEarlier.js +19 -0
  52. package/dist/react/ShowEarlier.js.map +1 -0
  53. package/dist/react/SuiteSections.d.ts +10 -8
  54. package/dist/react/SuiteSections.js +99 -55
  55. package/dist/react/SuiteSections.js.map +1 -1
  56. package/dist/react/WeeklyCheck.js +4 -8
  57. package/dist/react/WeeklyCheck.js.map +1 -1
  58. package/dist/react/app.d.ts +2 -0
  59. package/dist/react/app.js.map +1 -1
  60. package/dist/react/format.d.ts +2 -2
  61. package/dist/react/format.js +4 -2
  62. package/dist/react/format.js.map +1 -1
  63. package/dist/react/pieces.d.ts +11 -0
  64. package/dist/react/pieces.js +17 -2
  65. package/dist/react/pieces.js.map +1 -1
  66. package/dist/runner.d.ts +7 -2
  67. package/dist/runner.js +12 -3
  68. package/dist/runner.js.map +1 -1
  69. package/dist/suggest.js +25 -7
  70. package/dist/suggest.js.map +1 -1
  71. package/dist/types.d.ts +2 -1
  72. package/dist/types.js.map +1 -1
  73. package/dist/weekly.js +4 -2
  74. package/dist/weekly.js.map +1 -1
  75. package/package.json +10 -10
  76. package/src/drafts.ts +6 -1
  77. package/src/failures.ts +50 -0
  78. package/src/health.ts +2 -1
  79. package/src/index.ts +1 -0
  80. package/src/legs.ts +8 -2
  81. package/src/next/actions.ts +54 -9
  82. package/src/next/route.ts +2 -1
  83. package/src/next/weekly.ts +15 -4
  84. package/src/prune.ts +15 -1
  85. package/src/react/AddCase.tsx +98 -11
  86. package/src/react/AnswerKey.tsx +74 -14
  87. package/src/react/CaseMenu.tsx +24 -0
  88. package/src/react/CompareView.tsx +19 -4
  89. package/src/react/FeedbackView.tsx +13 -3
  90. package/src/react/HubSections.tsx +10 -5
  91. package/src/react/InfoPopover.tsx +100 -0
  92. package/src/react/PriorityPicker.tsx +122 -0
  93. package/src/react/RunView.tsx +41 -6
  94. package/src/react/SettingsHistory.tsx +114 -76
  95. package/src/react/ShowEarlier.tsx +57 -0
  96. package/src/react/SuiteSections.tsx +318 -260
  97. package/src/react/WeeklyCheck.tsx +26 -9
  98. package/src/react/app.ts +2 -0
  99. package/src/react/format.ts +4 -2
  100. package/src/react/pieces.tsx +34 -1
  101. package/src/runner.ts +18 -5
  102. package/src/suggest.ts +26 -7
  103. package/src/types.ts +2 -1
  104. package/src/weekly.ts +7 -2
  105. package/templates/lib/evalkeeper/actions.ts +4 -0
@@ -5,10 +5,12 @@ import {
5
5
  InfoTip,
6
6
  Link,
7
7
  RefreshWhile,
8
+ Spinner,
8
9
  Submit,
9
10
  Tip,
11
+ LocalDate,
10
12
  } from "./pieces.js";
11
- import { pct, dayOf, LINK } from "./format.js";
13
+ import { pct, LINK } from "./format.js";
12
14
  import { evalsPath, type EvalAppConfig } from "./app.js";
13
15
 
14
16
  /**
@@ -31,17 +33,32 @@ export function WeeklyCheck({
31
33
  Weekly check
32
34
  <InfoTip term="weeklyCheck" />
33
35
  </h2>
34
- <form action={app.actions.runWeeklyNow}>
35
- <Submit variant="quiet">Run it now</Submit>
36
- </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
+ )}
37
49
  </div>
38
50
  <Card className="space-y-4">
39
51
  <p className="readable text-sm text-muted">
40
- {weekly.running > 0
41
- ? `Running now: ${weekly.running} quick set${weekly.running === 1 ? "" : "s"} left. `
42
- : weekly.lastAt
43
- ? `Last run ${dayOf(weekly.lastAt)}, ${money(weekly.costUsd)}. `
44
- : "Not run yet. "}
52
+ {weekly.running > 0 ? (
53
+ `Running now: ${weekly.running} quick set${weekly.running === 1 ? "" : "s"} left. `
54
+ ) : weekly.lastAt ? (
55
+ <>
56
+ Last run <LocalDate date={weekly.lastAt} />,{" "}
57
+ {money(weekly.costUsd)}.{" "}
58
+ </>
59
+ ) : (
60
+ "Not run yet. "
61
+ )}
45
62
  Every Monday, each live model answers its suite&apos;s quick set
46
63
  again, so a quiet change by its provider shows up here. It also flags
47
64
  models retiring soon and features people rate poorly. Suites that can
package/src/react/app.ts CHANGED
@@ -43,6 +43,8 @@ export type EvalActions = {
43
43
  useDraftsProvisionally?: FormAction;
44
44
  /** Changing what a feature's suggestion favors, as a settings version. */
45
45
  setPriority?: FormAction;
46
+ /** Keeping a split case's answer as right, after checking it. */
47
+ keepAnswer?: FormAction;
46
48
  runWeeklyNow: () => Promise<void>;
47
49
  /** Blind rating; only for an app with the rate page. */
48
50
  rateBlind?: FormAction;
@@ -20,21 +20,23 @@ export const QUIET_BUTTON =
20
20
  * A day, with the month as a word so no reader mistakes it:
21
21
  * "Oct 28, 2026" (10/28 is the 10th of the 28th month in most of the world).
22
22
  */
23
- export const dayOf = (d: Date): string =>
23
+ export const dayOf = (d: Date, timeZone?: string): string =>
24
24
  d.toLocaleDateString("en-US", {
25
25
  month: "short",
26
26
  day: "numeric",
27
27
  year: "numeric",
28
+ ...(timeZone ? { timeZone } : {}),
28
29
  });
29
30
 
30
31
  /** A day and time, the same way: "Oct 28, 2026, 3:04 PM". */
31
- export const momentOf = (d: Date): string =>
32
+ export const momentOf = (d: Date, timeZone?: string): string =>
32
33
  d.toLocaleString("en-US", {
33
34
  month: "short",
34
35
  day: "numeric",
35
36
  year: "numeric",
36
37
  hour: "numeric",
37
38
  minute: "2-digit",
39
+ ...(timeZone ? { timeZone } : {}),
38
40
  });
39
41
 
40
42
  /**
@@ -4,6 +4,7 @@ import {
4
4
  createContext,
5
5
  createElement,
6
6
  useContext,
7
+ useSyncExternalStore,
7
8
  type ComponentType,
8
9
  type ReactNode,
9
10
  } from "react";
@@ -11,7 +12,7 @@ import { useFormStatus } from "react-dom";
11
12
  import { ArrowLeft, Info, LoaderCircle } from "lucide-react";
12
13
  import { GLOSSARY, type GlossaryTerm } from "../glossary.js";
13
14
  import type { HealthFlag, HealthStatus } from "../health.js";
14
- import { pct, QUIET_BUTTON } from "./format.js";
15
+ import { dayOf, momentOf, pct, QUIET_BUTTON } from "./format.js";
15
16
 
16
17
  /**
17
18
  * The pieces Evalkeeper's screens are built from. Each draws Evalkeeper's
@@ -471,3 +472,35 @@ export function RefreshWhile(props: RefreshWhileProps) {
471
472
  const C = useSwapped("RefreshWhile");
472
473
  return C ? createElement(C, props) : null;
473
474
  }
475
+
476
+ /** A store that never changes, for useSyncExternalStore. */
477
+ const noChange = () => () => {};
478
+
479
+ /**
480
+ * A date in the viewer's own time zone: "Oct 29, 2026", or with the time.
481
+ * A server formats in its own zone (UTC on most hosts), which can show
482
+ * tomorrow's date in someone's evening, so this renders UTC first and the
483
+ * viewer's zone once the page loads, inside a <time> with the instant.
484
+ */
485
+ export function LocalDate({
486
+ date,
487
+ time = false,
488
+ }: {
489
+ date: Date | string;
490
+ /** Include the time of day. */
491
+ time?: boolean;
492
+ }) {
493
+ const d = new Date(date);
494
+ // False on the server and while hydrating, true once in the browser.
495
+ const here = useSyncExternalStore(
496
+ noChange,
497
+ () => true,
498
+ () => false,
499
+ );
500
+ const zone = here ? undefined : "UTC";
501
+ return (
502
+ <time dateTime={d.toISOString()}>
503
+ {time ? momentOf(d, zone) : dayOf(d, zone)}
504
+ </time>
505
+ );
506
+ }
package/src/runner.ts CHANGED
@@ -60,8 +60,8 @@ export const STUCK_MS = 6 * 60_000;
60
60
  export const REUSE_DAYS = 7;
61
61
 
62
62
  /** A provider refusing calls for billing: every later call fails too. */
63
- export const OUT_OF_CREDITS =
64
- /no credits remaining|credit balance is too low|insufficient_quota|exceeded your current quota|billing/i;
63
+ export { OUT_OF_CREDITS } from "./failures.js";
64
+ import { OUT_OF_CREDITS } from "./failures.js";
65
65
 
66
66
  /**
67
67
  * What the runner needs from your app: storage, suites, models, instruction hashes, and,
@@ -108,7 +108,7 @@ export type RunnerOptions = {
108
108
  */
109
109
  continueRun?: (
110
110
  runId: string,
111
- opts: Required<RunEvalOptions>,
111
+ opts: Required<Omit<RunEvalOptions, "requestStartedAt">>,
112
112
  ) => Promise<boolean>;
113
113
  /**
114
114
  * Which model each operation runs on now, its fallback, and its
@@ -157,6 +157,11 @@ export type RunEvalOptions = {
157
157
  leg?: number;
158
158
  /** What earlier legs' judge spent. */
159
159
  judgeCostUsd?: number;
160
+ /**
161
+ * When the request running this leg started, if earlier than this call
162
+ * (tests queued one after another): the time limit counts from then.
163
+ */
164
+ requestStartedAt?: number;
160
165
  };
161
166
 
162
167
  const sha = (text: string, n = 8) =>
@@ -584,8 +589,9 @@ export function createRunner(opts: RunnerOptions) {
584
589
  let outOfCredits = null as string | null;
585
590
  const timeout = suite.answerTimeoutMs ?? ANSWER_TIMEOUT_MS;
586
591
  const deadline = opts.requestLimitMs
587
- ? Date.now() + opts.requestLimitMs - timeout
592
+ ? (o.requestStartedAt ?? Date.now()) + opts.requestLimitMs - timeout
588
593
  : Infinity;
594
+ const late = Date.now() > deadline;
589
595
  let skipped = 0;
590
596
 
591
597
  await mapLimit(todo, suite.concurrency ?? 6, async ({ c, repeat }) => {
@@ -678,6 +684,7 @@ export function createRunner(opts: RunnerOptions) {
678
684
  done: todo.length - skipped,
679
685
  leg,
680
686
  outOfCredits: !!outOfCredits,
687
+ late,
681
688
  }) &&
682
689
  opts.continueRun &&
683
690
  (await opts.continueRun(runId, next).catch(() => false))
@@ -806,13 +813,19 @@ export function createRunner(opts: RunnerOptions) {
806
813
  * set on its live model, at its live reasoning setting, marked as
807
814
  * started by the schedule. Record every suite's first, so a page can show
808
815
  * them running, then run each with `runEval(id, { fresh: true })`.
809
- * 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.
810
818
  * Needs `route`.
811
819
  */
812
820
  async function startDriftCheck(suiteKey: string): Promise<string | null> {
813
821
  if (!opts.route) throw new Error("The drift check needs the route option");
814
822
  const suite = suiteOrThrow(suiteKey);
815
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;
816
829
  const route = await opts.route(suite.operation);
817
830
  const { run } = await createRun({
818
831
  suite: suite.key,
package/src/suggest.ts CHANGED
@@ -3,6 +3,7 @@ import type { Rate } from "./stats.js";
3
3
  import type { CheckDef, SuitePriority } from "./types.js";
4
4
  import type { Verdict } from "./compare.js";
5
5
  import { at } from "./util.js";
6
+ import { failureHints, failureKind } from "./failures.js";
6
7
 
7
8
  /**
8
9
  * Which model to make live and which the fallback, from a suite's current
@@ -154,6 +155,19 @@ export function seriousMistakes(row: SuggestRow, checks: CheckDef[]): number {
154
155
 
155
156
  const mistakes = (n: number) => `${n} serious mistake${n === 1 ? "" : "s"}`;
156
157
  const rate = (r: SuggestRow) => (r.test ? r.test.right / r.test.total : 0);
158
+
159
+ /**
160
+ * Two scores side by side, "92% against 88%", with as many decimals as it
161
+ * takes (up to two) when they differ but would round alike ("98.14%
162
+ * against 98.06%"), so a reason never compares a number with itself.
163
+ */
164
+ function against(a: number, b: number): string {
165
+ const at = (x: number, d: number) => (x * 100).toFixed(d);
166
+ const d = [0, 1, 2].find((n) => at(a, n) !== at(b, n)) ?? 0;
167
+ return d === 0
168
+ ? `${pct(a)} against ${pct(b)}`
169
+ : `${at(a, d)}% against ${at(b, d)}%`;
170
+ }
157
171
  const pct = (x: number) => `${Math.round(x * 100)}%`;
158
172
  const cost = (r: SuggestRow) => r.test?.costPerAnswer ?? Infinity;
159
173
  const ms = (r: SuggestRow) => r.test?.avgMs ?? Infinity;
@@ -234,8 +248,13 @@ export function suggest<R extends SuggestRow>(
234
248
  next = liveFailed;
235
249
  const n = liveFailed.test.failedAnswers ?? 0;
236
250
  const why = liveFailed.test.failureReason;
251
+ const kind = failureKind(why ?? null);
252
+ // Timeouts and answers cut short fail the same way again: say what
253
+ // to change instead of only "test again".
237
254
  reasons.push(
238
- `Test ${liveFailed.label} again: ${n} of its answers failed on its last test${why ? ` (${why})` : ""}, so it can't be compared yet.`,
255
+ kind === "timeout" || kind === "cutShort"
256
+ ? `${n} of ${liveFailed.label}'s answers failed on its last test (${why}), so it can't be compared yet. ${failureHints([why ?? null]).join(" ")}`
257
+ : `Test ${liveFailed.label} again: ${n} of its answers failed on its last test${why ? ` (${why})` : ""}, so it can't be compared yet.`,
239
258
  );
240
259
  } else if (!live) {
241
260
  if (!liveable.length) return null;
@@ -266,21 +285,21 @@ export function suggest<R extends SuggestRow>(
266
285
  const ra = underAttack(r);
267
286
  const la = underAttack(live);
268
287
  return ra !== null && la !== null && ra <= la - 2 && rate(r) >= rate(live)
269
- ? `${r.label} makes fewer serious mistakes on the attacks than ${live.label} (${ra} against ${la}), and scores at least as well (${pct(rate(r))} against ${pct(rate(live))}).`
288
+ ? `${r.label} makes fewer serious mistakes on the attacks than ${live.label} (${ra} against ${la}), and scores at least as well (${against(rate(r), rate(live))}).`
270
289
  : null;
271
290
  };
272
291
  const why = (r: R): string | null => {
273
292
  if (rate(r) < rate(live)) return trade(r);
274
293
  if (r.vsLive === "BETTER")
275
- return `${r.label} is clearly more accurate than ${live.label}: ${pct(rate(r))} against ${pct(rate(live))}.`;
294
+ return `${r.label} is clearly more accurate than ${live.label} on the cases both answered (overall ${against(rate(r), rate(live))}).`;
276
295
  if (serious(r) <= serious(live) - 2)
277
- return `${r.label} makes fewer serious mistakes than ${live.label} (${serious(r)} against ${serious(live)}), and scores at least as well (${pct(rate(r))} against ${pct(rate(live))}).`;
296
+ return `${r.label} makes fewer serious mistakes than ${live.label} (${serious(r)} against ${serious(live)}), and scores at least as well (${against(rate(r), rate(live))}).`;
278
297
  const byAttacks = attackReason(r);
279
298
  if (byAttacks) return byAttacks;
280
299
  if (priority.favor === "cost" && clearlyLess(cost(r), cost(live)))
281
- return `${r.label} scores at least as well as ${live.label} (${pct(rate(r))} against ${pct(rate(live))}) at ${Math.round((1 - cost(r) / cost(live)) * 100)}% less per answer.`;
300
+ return `${r.label} scores at least as well as ${live.label} (${against(rate(r), rate(live))}) at ${Math.round((1 - cost(r) / cost(live)) * 100)}% less per answer.`;
282
301
  if (priority.favor === "speed" && clearlyLess(ms(r), ms(live)))
283
- return `${r.label} scores at least as well as ${live.label} (${pct(rate(r))} against ${pct(rate(live))}) and answers faster (${(ms(r) / 1000).toFixed(1)}s against ${(ms(live) / 1000).toFixed(1)}s).`;
302
+ return `${r.label} scores at least as well as ${live.label} (${against(rate(r), rate(live))}) and answers faster (${(ms(r) / 1000).toFixed(1)}s against ${(ms(live) / 1000).toFixed(1)}s).`;
284
303
  return null;
285
304
  };
286
305
  // Cost and speed suites: a little less accurate, no clear difference,
@@ -293,7 +312,7 @@ export function suggest<R extends SuggestRow>(
293
312
  serious(r) > serious(live)
294
313
  )
295
314
  return null;
296
- const close = `${r.label} is about as accurate as ${live.label} (${pct(rate(r))} against ${pct(rate(live))}: closer than these cases can tell apart), with no more serious mistakes`;
315
+ const close = `${r.label} is about as accurate as ${live.label} (${against(rate(r), rate(live))}: closer than these cases can tell apart), with no more serious mistakes`;
297
316
  if (priority.favor === "cost" && cost(r) <= cost(live) * HALF)
298
317
  return `${close}, at ${Math.round((1 - cost(r) / cost(live)) * 100)}% less per answer. This suite favors cost.`;
299
318
  if (priority.favor === "speed" && ms(r) <= ms(live) * HALF)
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"] = [];
@@ -97,6 +97,10 @@ export async function setPriority(form: FormData) {
97
97
  return actions.setPriority(form);
98
98
  }
99
99
 
100
+ export async function keepAnswer(form: FormData) {
101
+ return actions.keepAnswer(form);
102
+ }
103
+
100
104
  export async function runWeeklyNow() {
101
105
  return actions.runWeeklyNow();
102
106
  }