Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/evals/__tests__/leaderboard-outcomes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ test("retains visible outcomes when a later configuration has incomplete grading
expect(html).toContain("73 ungraded · zero credit");
expect(html).toContain("38.3%");
expect(html).not.toMatch(/>\s*—\s*</u);
expect(html).toContain("run=astra-max-perps-1");
expect(html).toContain("#/models/astra?run=astra-max-spot-1");
const evidence = renderToStaticMarkup(
createElement(LeaderboardPage, { rows: [row], initialExpandedModel: row.model.id }),
);
expect(evidence).toContain("run=astra-max-perps-1");
});

test("the page supplies all eligible original and recovery settings to the chart", () => {
Expand Down
128 changes: 128 additions & 0 deletions apps/evals/__tests__/leaderboard-state.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { expect, test } from "vitest";
import { configurationLeaderboardRows, type LeaderboardModelRow } from "../src/canonical/selectors";
import {
leaderboardHash,
readLeaderboardState,
visibleLeaderboardRows,
providerOverviewRows,
} from "../src/lib/leaderboard-state";
import { modelRowHref, rowMetricValue } from "../src/components/leaderboard-results";

const rows = configurationLeaderboardRows();

test("a shared link round-trips every desktop/mobile exploration control", () => {
const state = {
...readLeaderboardState(""),
search: "Grok & Astra",
campaign: "all",
grading: "incomplete" as const,
metric: "cost" as const,
direction: "asc" as const,
group: "models" as const,
view: "efficiency" as const,
page: 3,
category: "Predictions" as const,
efficiency: "cost" as const,
overview: true,
};
expect(readLeaderboardState(leaderboardHash(state))).toEqual(state);
});

test("time can be displayed independently while sorting by cost", () => {
const state = readLeaderboardState("#/leaderboard?metric=cost&efficiency=time");
expect(state.direction).toBe("asc");
expect(state.efficiency).toBe("time");
expect(readLeaderboardState(leaderboardHash(state))).toEqual(state);
});

test.each(["overall", "Spot", "Perps", "Predictions", "time", "cost"] as const)(
"links preserve either sort direction and independent columns for %s",
(metric) => {
for (const direction of ["asc", "desc"] as const) {
const state = {
...readLeaderboardState(""),
metric,
direction,
category: "Spot" as const,
efficiency: "time" as const,
};
expect(readLeaderboardState(leaderboardHash(state))).toEqual(state);
}
},
);

test.each(["Perps", "Predictions"] as const)(
"a direct %s sort displays that category on tablet",
(metric) => {
expect(readLeaderboardState(`#/leaderboard?metric=${metric}`).category).toBe(metric);
},
);

test.each(["-1", "NaN", "Infinity", "1.5", "9007199254740992"])(
"invalid overview page %s recovers to the first page",
(page) => {
expect(readLeaderboardState(`#/leaderboard?page=${page}`).page).toBe(0);
},
);

test("incomplete grading filters apply after latest-setting selection", () => {
const shown = visibleLeaderboardRows(
rows,
readLeaderboardState("#/leaderboard?search=Astra&grading=incomplete"),
);
expect(shown).toHaveLength(1);
expect(shown[0]?.runs.Spot?.runId).toBe("recovery-astra-xhigh-spot-1");
});

test.each(["asc", "desc"] as const)(
"missing cost remains after measured zero cost when sorting %s",
(direction) => {
const shown = visibleLeaderboardRows(
rows,
readLeaderboardState(`#/leaderboard?metric=cost&direction=${direction}`),
);
const firstMissing = shown.findIndex((row) => rowMetricValue(row, "cost") === null);
expect(firstMissing).toBeGreaterThan(0);
expect(shown.slice(firstMissing).every((row) => rowMetricValue(row, "cost") === null)).toBe(
true,
);
expect(shown.some((row) => rowMetricValue(row, "cost") === 0)).toBe(true);
},
);

test("model navigation retains the clicked setting's real run, including non-Spot rows", () => {
const row = rows.find((entry) => entry.runs.Spot?.runId === "astra-low-spot-1")!;
expect(modelRowHref(row)).toBe("#/models/astra?run=astra-low-spot-1");
const perpsOnly: LeaderboardModelRow = { ...row, runs: { Perps: row.runs.Perps } };
expect(modelRowHref(perpsOnly)).toBe("#/models/astra?run=astra-low-perps-1");
});

test("the overview includes each provider once without changing ranked settings", () => {
const shown = visibleLeaderboardRows(rows, readLeaderboardState(""));
const originalOrder = shown.map((row) => row.rowId);
const overview = providerOverviewRows(shown);
expect(overview.map((row) => row.model.provider)).toEqual([
"OpenAI",
"xAI",
"Muse",
"Anthropic",
"Google",
"Devin",
]);
for (const row of overview)
expect(row).toBe(shown.find((entry) => entry.model.provider === row.model.provider));
expect(shown.map((row) => row.rowId)).toEqual(originalOrder);
expect(shown).toHaveLength(45);
});

test("provider representatives respect filtering and the active sort", () => {
const shown = visibleLeaderboardRows(
rows,
readLeaderboardState("#/leaderboard?search=Astra&metric=cost"),
);
const overview = providerOverviewRows(shown);
expect(overview).toHaveLength(1);
expect(overview[0]).toBe(shown[0]);
expect(overview[0]?.runs.Spot?.runId).toBe("astra-low-spot-1");
expect(providerOverviewRows([])).toEqual([]);
});
27 changes: 25 additions & 2 deletions apps/evals/__tests__/model-profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ import {
} from "../src/canonical/selectors";
import { ModelSettingResults } from "../src/components/model-setting-results";
import { ModelProfilePage } from "../src/pages/model-profile";
import { selectProfileSetting } from "../src/lib/model-profile-selection";

test("profile selection follows an exact run's whole setting, including historical campaigns", () => {
const high = selectProfileSetting("astra", "astra-high-perps-1")!;
expect(high.runs.Spot?.runId).toBe("astra-high-spot-1");
expect(high.overall).toBeCloseTo(0.866096866);
const historical = selectProfileSetting("astra", "astra-max-predictions-1")!;
expect(
Object.values(historical.runs).every((run) => run.campaignId === historical.campaignId),
).toBe(true);
expect(historical.runs.Spot?.runId).toBe("astra-max-spot-1");
expect(historical.campaignId).not.toBe(selectProfileSetting("astra")?.campaignId);
});

test("unavailable and foreign runs fall back to the same model's latest setting", () => {
const latest = selectProfileSetting("astra")!;
expect(selectProfileSetting("astra", "missing-run")).toEqual(latest);
expect(selectProfileSetting("astra", "grok47-low-spot-1")).toEqual(latest);
expect(selectProfileSetting("astra", undefined, [])).toBeUndefined();
expect(latest.overall).toBeLessThan(selectProfileSetting("astra", "astra-high-spot-1")!.overall!);
});

test("expanded run details appear immediately after their history row", () => {
const runId = "recovery-astra-max-perps-1";
Expand Down Expand Up @@ -134,8 +155,10 @@ test("model profiles retain earlier runs and source downloads below the setting
);
expect(html).toContain("Configuration fingerprints &amp; original downloads");
expect(html).not.toContain("Latest recorded run per family");
expect(html).toContain("Latest recorded max reasoning");
expect(html).toContain("model-profile-metrics");
expect(html).toContain("Latest recorded setting");
expect(html).toContain("mp-stat-strip");
expect(html).toContain("Success by category");
expect(html).not.toContain("model-profile-metrics");
expect(html).toContain("How to read these results");
expect(html.match(/Full campaign notes &amp; sources/gu)).toHaveLength(2);
expect(html).toContain("209/210 graded");
Expand Down
30 changes: 30 additions & 0 deletions apps/evals/__tests__/transaction-evals.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { describe, expect, test } from "vitest";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { parse } from "yaml";
import { configurationLeaderboardRows } from "../src/canonical/selectors";
import { TRANSACTION_TASKS } from "../src/lib/transaction-evals";
import { spotTransactionsHref, TransactionResult } from "../src/components/transaction-results";
import { TaskExplorerPage } from "../src/pages/task-explorer";
import { parseRoute } from "../src/router";
import {
TRANSACTION_RUNS,
transactionRunForRow,
Expand All @@ -24,6 +29,31 @@ interface TaskFile {

const grok47Low = TRANSACTION_RUNS.find((run) => run.runId === "grok-4.7-low-20260925-v4")!;

test.each(TRANSACTION_RUNS)("transaction links retain the exact setting for $runId", (run) => {
const route = parseRoute(spotTransactionsHref(run).slice(1));
expect(route.path).toBe("/tasks");
expect(route.query.get("run")).toBe(run.runId);
expect(route.query.get("model")).toBe(run.canonicalModelId);
const html = renderToStaticMarkup(
createElement(TaskExplorerPage, {
initialFamily: "Spot",
initialCaseId: TRANSACTION_TASKS[0]!.id,
initialModelId: run.canonicalModelId,
initialRunId: run.runId,
initialView: "run",
}),
);
expect(html).toContain(`<code>${run.runId}</code>`);
const owner = configurationLeaderboardRows().find((row) => transactionRunForRow(row) === run);
if (owner) {
const compact = renderToStaticMarkup(
createElement(TransactionResult, { row: owner, compact: true }),
);
expect(compact).toContain("Transactions ↗");
expect(compact).toContain(`run=${run.runId}`);
}
});

describe("Transactions page catalog", () => {
test("lists exactly the task files, with their prompt, tier, user reply and outcome", () => {
const fromFiles = Object.keys(TASK_SOURCES)
Expand Down
54 changes: 54 additions & 0 deletions apps/evals/src/components/leaderboard-evidence.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Fragment, useId, useState } from "react";
import type { LeaderboardModelRow } from "../canonical/selectors";
import { SCORED_FAMILIES } from "../canonical/selectors";
import { rowLabel, CoverageNote, RecordedResult } from "./leaderboard-results";
import { LeaderboardConversations } from "./leaderboard-conversations";
import { RunDetails } from "./results-ui";
import { TransactionDetails } from "./transaction-results";

export function LeaderboardEvidence({ row }: { row: LeaderboardModelRow }) {
const [chatOpen, setChatOpen] = useState(false);
const id = useId();
return (
<section className="lb-evidence" aria-label={`Evidence for ${rowLabel(row)}`}>
<div className="lb-evidence-heading">
<h3>
{row.model.name} <span>{row.configurationLabel}</span>
</h3>
<p>{row.overallReason}</p>
</div>
<div className="lb-evidence-summary">
<RecordedResult
runs={Object.values(row.runs)}
score={row.overall}
overall
reason={row.overallReason}
/>
<div>
<CoverageNote label="Average time" metric={row.averageTime} />
<CoverageNote label="Estimated cost" metric={row.estimatedCost} />
</div>
</div>
<LeaderboardConversations
panelId={`lb-conversations-${id}`}
row={row}
open={chatOpen}
onOpenChange={setChatOpen}
/>
{SCORED_FAMILIES.map((family) =>
row.runs[family] ? (
<Fragment key={family}>
<RunDetails run={row.runs[family]} />
<a
className="results-score-link"
href={`#/tasks?category=${family}&model=${row.model.id}&run=${encodeURIComponent(row.runs[family]!.runId)}`}
>
View {family} tasks and conversations ↗
</a>
</Fragment>
) : null,
)}
<TransactionDetails row={row} />
</section>
);
}
Loading
Loading