Builds the execution half of the Geek Room "Build a Benchmarking Platform
for AI Agents, Not Just Models" theme: every submission now carries a real
execution trace (steps, outbound/tool-call count, latency p50/p95, tokens +
cost when the endpoint reports them, error/timeout counts) and an opt-in,
deterministically seeded fault-injection stress test (injected timeouts,
5xx responses, malformed answers at configurable rates) that reports
robustness: accuracy under faults vs. the clean run.
- benchmark-scoring.ts: instrumentRunner wraps any Runner with tracing;
endpointRunner gains an optional onOutcome hook + parses real
usage/cost_usd from the submitter's response body; mulberry32-seeded
fault injection with disjoint timeout/server_error/malformed buckets.
- benchmark-submissions.server.ts: wires tracing into both runner kinds,
runs a second faulted pass when requested, persists {clean trace,
robustness} + the fault-injection config on two new additive, nullable
columns (migrations/0012_benchmark_execution_trace.sql).
- API route + leaderboard feed: pass faultInjection through, return
trace/robustness/faultInjection on every submission.
- UI: /submit-model gets a "Stress-test with fault injection" checkbox and
Execution trace / Robustness under faults cards; /leaderboard's gold-suite
tab gets p50 ms / Outbound calls / Errors / Robustness columns for
community submissions.
Verified end to end: a real HTTP submission against a running dev server
(fault injection on, real trace + robustness persisted and read back from
the public leaderboard feed) and endpointRunner against a real local HTTP
agent (93 real round trips; real measured latency/tokens/cost; a 60%-fault
pass provably short-circuiting before the real network call) — see
hackathons/geekroom-2026/verify-execution-trace.mjs and
HACKATHON-SUBMISSION.md's "Real execution-trace + fault-injection run".
Re-recorded demo.mp4/poster.png (real Playwright capture, real ffmpeg
conversion) to show the new flow. npm test (138/1 skip/0 fail), npm run
gold (61/0), npm run typecheck (clean) all unchanged.
168 lines
8.1 KiB
JavaScript
168 lines
8.1 KiB
JavaScript
/**
|
|
* Record a REAL screen capture of the live Benchmark Submissions flow:
|
|
* /keys (create an API key) -> /submit-model (submit THREE genuinely
|
|
* different real answer sources, the third with fault injection enabled)
|
|
* -> /leaderboard (all three appear live as "Community submitted" rows
|
|
* with real computed scores, trace, and robustness columns).
|
|
*
|
|
* This drives an ACTUAL running dev server (no mocking, no staged
|
|
* screenshots) with Playwright's Chromium and its built-in video recorder.
|
|
* The three submissions:
|
|
* 1. "system-one-replay" — OpenJev's own model replayed through the
|
|
* external path (hackathons/geekroom-2026/system-one-replay-answers.json,
|
|
* built by generate-system-one-replay.ts). Expected ~85.6% accuracy,
|
|
* ECE ~0.096 — matches evalGold("system-one") byte-for-byte.
|
|
* 2. "uniform-baseline-v1" — a genuinely different, content-blind
|
|
* uninformed-guess baseline (hackathons/geekroom-2026/
|
|
* uniform-baseline-v1-answers.json, built by
|
|
* generate-baseline-submission.ts). Expected much lower accuracy
|
|
* (~35%), proving the platform scores more than one self-referential
|
|
* submission.
|
|
* 3. "trace-fault-demo" (2026-11-10) — the system-one-replay answers again,
|
|
* this time with "Stress-test with fault injection" checked, to show
|
|
* the real execution-trace + robustness-under-faults cards and the
|
|
* matching new leaderboard columns (p50 ms, outbound calls, errors,
|
|
* robustness) — the "Not Just Models" half of the hackathon theme.
|
|
*
|
|
* Usage (dev server must already be running, e.g. `npm run dev -- --port 8099`):
|
|
* BASE_URL=http://localhost:8099 node hackathons/geekroom-2026/record-demo.mjs
|
|
*
|
|
* Requires the `playwright` package resolvable on NODE_PATH (this repo does
|
|
* not depend on Playwright itself; point NODE_PATH at a cached install whose
|
|
* `playwright-core` chromium revision matches a REALLY cached browser binary
|
|
* on this machine — check with
|
|
* `node -e "console.log(require('playwright').chromium.executablePath())"`
|
|
* under candidate NODE_PATHs, then `ls ~/Library/Caches/ms-playwright`; a
|
|
* mismatch doesn't fail loudly, it silently records zero video):
|
|
* NODE_PATH=/path/to/node_modules node hackathons/geekroom-2026/record-demo.mjs
|
|
*
|
|
* Writes hackathons/geekroom-2026/demo-raw.webm (Playwright's native output,
|
|
* kept as the source-of-truth capture) — convert to the final demo.mp4 with
|
|
* ffmpeg (see README note alongside this file).
|
|
*/
|
|
import { readFileSync, mkdirSync, renameSync, readdirSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { createRequire } from "node:module";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const BASE_URL = process.env.BASE_URL ?? "http://localhost:8099";
|
|
const OUT_DIR = join(__dirname, "_video_tmp");
|
|
const FINAL_WEBM = join(__dirname, "demo-raw.webm");
|
|
|
|
async function main() {
|
|
// Dynamic `import()` ignores NODE_PATH; CJS `require()` honors it, so load
|
|
// the cached `playwright` package via a `require` shim instead.
|
|
const require = createRequire(import.meta.url);
|
|
const { chromium } = require("playwright");
|
|
|
|
mkdirSync(OUT_DIR, { recursive: true });
|
|
|
|
const browser = await chromium.launch();
|
|
const context = await browser.newContext({
|
|
viewport: { width: 1280, height: 800 },
|
|
recordVideo: { dir: OUT_DIR, size: { width: 1280, height: 800 } },
|
|
});
|
|
const page = await context.newPage();
|
|
|
|
const systemOneAnswers = readFileSync(
|
|
join(__dirname, "system-one-replay-answers.json"),
|
|
"utf8",
|
|
);
|
|
const baselineAnswers = readFileSync(
|
|
join(__dirname, "uniform-baseline-v1-answers.json"),
|
|
"utf8",
|
|
);
|
|
|
|
// ── 1. Create a real API key (no login required: dev mode, auth disabled) ─
|
|
await page.goto(`${BASE_URL}/keys`, { waitUntil: "networkidle" });
|
|
await page.getByRole("button", { name: "New key" }).click();
|
|
await page.getByPlaceholder("e.g. production, ci-bot, staging").fill("hackathon-demo");
|
|
await page.getByRole("button", { name: "Create key" }).click();
|
|
await page.getByText(/Key ready: hackathon-demo/).waitFor({ timeout: 15_000 });
|
|
await page.waitForTimeout(1200);
|
|
|
|
async function submitAnswers(label, answersJson) {
|
|
await page.goto(`${BASE_URL}/submit-model`, { waitUntil: "networkidle" });
|
|
await page.getByPlaceholder("acme-typed-v1").fill(label);
|
|
await page.getByText("Precomputed answers (JSON)").click();
|
|
await page.getByPlaceholder(/gold case id/).fill(answersJson);
|
|
await page.waitForTimeout(500);
|
|
await page.getByRole("button", { name: "Submit and score" }).click();
|
|
await page
|
|
.getByRole("heading", { name: `Scored: ${label}` })
|
|
.waitFor({ timeout: 30_000 });
|
|
// Let the viewer read the real computed numbers.
|
|
await page.waitForTimeout(2500);
|
|
}
|
|
|
|
// ── 2. Submission #1: OpenJev's own model, replayed through the external
|
|
// submission path (proves the pipeline reproduces evalGold() exactly). ──
|
|
await submitAnswers("system-one-replay", systemOneAnswers);
|
|
|
|
// ── 3. Submission #2: a genuinely different, content-blind baseline model
|
|
// (never reads case content, never imports the scoring engine — proof
|
|
// a real third-party submission source works, not just a self-replay). ─
|
|
await submitAnswers("uniform-baseline-v1", baselineAnswers);
|
|
|
|
// ── 4. Submission #3 (2026-11-10): the same replay answers, this time
|
|
// with fault injection on — shows the real "Execution trace" +
|
|
// "Robustness under faults" cards (the theme's execution half). ───────
|
|
await page.goto(`${BASE_URL}/submit-model`, { waitUntil: "networkidle" });
|
|
await page.getByPlaceholder("acme-typed-v1").fill("trace-fault-demo");
|
|
await page.getByText("Precomputed answers (JSON)").click();
|
|
await page.getByPlaceholder(/gold case id/).fill(systemOneAnswers);
|
|
await page.getByText("Stress-test with fault injection").click();
|
|
await page.waitForTimeout(500);
|
|
await page.getByRole("button", { name: /Running 93 gold cases|Submit and score/ }).click();
|
|
await page
|
|
.getByRole("heading", { name: "Scored: trace-fault-demo" })
|
|
.waitFor({ timeout: 30_000 });
|
|
await page.waitForTimeout(800);
|
|
await page.getByText("Execution trace").first().scrollIntoViewIfNeeded();
|
|
await page.waitForTimeout(2500);
|
|
await page.getByText("Robustness under faults").scrollIntoViewIfNeeded();
|
|
await page.waitForTimeout(3500);
|
|
|
|
// ── 5. Leaderboard: all three real "Community submitted" rows, live,
|
|
// including the new trace + robustness columns. ───────────────────────
|
|
await page.getByRole("link", { name: "View on leaderboard" }).click();
|
|
await page.getByRole("tab", { name: "Gold suite (in-repo)" }).click();
|
|
const baselineRow = page.getByText("uniform-baseline-v1").first();
|
|
const systemOneRow = page.getByText("system-one-replay").first();
|
|
const traceRow = page.getByText("trace-fault-demo").first();
|
|
await systemOneRow.waitFor({ timeout: 15_000 });
|
|
await baselineRow.waitFor({ timeout: 15_000 });
|
|
await traceRow.waitFor({ timeout: 15_000 });
|
|
// Scroll the real community rows into view so the proof is on camera, not
|
|
// just present-but-off-screen in the DOM.
|
|
await traceRow.scrollIntoViewIfNeeded();
|
|
await page.waitForTimeout(1000);
|
|
await page.mouse.wheel(0, -80);
|
|
await page.waitForTimeout(1500);
|
|
// Scroll the table horizontally so the new trailing columns (p50 ms,
|
|
// Outbound calls, Errors, Robustness) are actually on camera.
|
|
const table = page.locator("table").last();
|
|
await table.evaluate((el) => {
|
|
const scroller = el.closest(".overflow-x-auto");
|
|
if (scroller) scroller.scrollLeft = scroller.scrollWidth;
|
|
});
|
|
await page.waitForTimeout(4500);
|
|
|
|
await context.close();
|
|
await browser.close();
|
|
|
|
// Playwright names the file after an internal id; find and rename it.
|
|
const produced = readdirSync(OUT_DIR).find((f) => f.endsWith(".webm"));
|
|
if (!produced) {
|
|
throw new Error(`No .webm produced in ${OUT_DIR} — recording failed.`);
|
|
}
|
|
renameSync(join(OUT_DIR, produced), FINAL_WEBM);
|
|
console.log(`Wrote real screen-recorded demo: ${FINAL_WEBM}`);
|
|
}
|
|
|
|
main().catch((err) => {
|
|
console.error(err);
|
|
process.exit(1);
|
|
});
|