Joel Stevick

Eval harness · The golden set · cases.jsonl and the corpora · stage 1 of 1

Reading the cases

At the start of an eval run, run.mjs reads evals/cases.jsonl, one JSON case per line, and keeps the cases that --only names, or all of them. Each case names a corpus (resume, book or both). Every corpus that a selected case names gets a demo account of its own (a row in the demos table, as a visitor gets at sign-up), holding exactly that corpus's PDFs. During scoring, fileOf() supplies the file name missing from the passages in the reranker's candidate pool (those retrieval handed it to choose from).

Runs in: Your machine, the developer's machine: npm test (vitest, demo/tests/), npm run eval (Node and wrangler dev, evals/) and npm run search (Node, examples/). New to Cloudflare? How these fit together
evals/run.mjs10 / 10 lines on this page explainedlines 31-32,45-46,62-63,231-234 of 349; the rest are on other stage pages
In the browser
runs in the visitor's browser, on the demo page
Ingestion
runs when a PDF's text is uploaded
Query time
runs when the Worker answers a question or a search_documents call from the MCP server, and in the request handling every route shares, in the Worker and in the site's functions, which uploads and removals pass through too
MCP request
runs on a request to the MCP server or its OAuth endpoints
Site request
runs on a site request that is not a question, an upload, an MCP call or the cron: a page load, a session read, the demo page's /api/grants calls, an admin read, a file's removal
Scheduled
runs in the Worker's daily cron job
Eval run
runs when the eval harness runs on a developer's machine
MCP host
runs in an MCP host outside the Worker: the search loop example, on a developer's machine (npm run search) or in its test
Module load
runs once, when the module is loaded
Type only
erased by the TypeScript compiler; never runs
Never runs
a comment, a licence or markup with no behaviour of its own

Pinned to joelstevick-demo-rag-pipeline at 6a9c6c7.

evals/run.mjs The eval harness's runner, a Node script.

CORPUS

constant · lines 31–32View on GitHub

The three corpora a case can name, each a list of PDFs in evals/corpus/.

// Each case names one of these corpora; its demo is given exactly these PDFs from evals/corpus/.const CORPUS = { resume: ['resume.pdf'], book: ['book.pdf'], both: ['resume.pdf', 'book.pdf'] }

Three corpora, a demo account each Eval run

WhatMaps each value a case may give in its corpus field to the PDFs that corpus's demo account receives.

WhyThe both corpus tests retrieval under distraction: resume-02 asks a résumé question with the book uploaded too. The journal's smoke run, made with a dummy key at no cost, already showed only 4 of 7 employers reaching the answer's context in that setting. Each corpus gets a separate demo account, so a case never searches PDFs that its corpus does not name.

resume: resume.pdfbook: book.pdfboth: resume.pdf, book.pdfcases.jsonl at the pin: 3 resume, 26 book, 1 bothevals/JOURNAL.md, The harness: smoke run, 4 of 7 employers in context with the book uploaded too

only

constant · lines 45–46View on GitHub

The case ids that --only names, or null for every case.

// --only narrows the run to the listed case ids, for re-running a few cases cheaply.const only = args.only ? new Set(args.only.split(',')) : null

--only, as a Set Eval run

WhatSplits the --only value on commas into a Set of ids. Without the flag, only is null and no case is filtered out.

WhyA full run of 30 cases costs about half a dollar against a $7.50 cap on all runs together, so --only re-checks one or two cases after a change. An id that matches no case is ignored without an error, because the filter keeps only the cases whose id is in the Set.

evals/runs/2026-10-30T13-49-56-stream-final: $0.5142 for 30 cases

cases

constant · lines 62–63View on GitHub

The golden set, parsed from JSONL and narrowed to --only.

// One case per non-empty line of the JSONL, narrowed to --only when given.const cases = readFileSync('evals/cases.jsonl', 'utf8').split('\n').filter(Boolean).map((line) => JSON.parse(line)).filter((c) => !only || only.has(c.id))

Parse the JSONL Eval run

WhatParses each non-empty line as one case and keeps the cases whose id is in only, or every case when --only is absent. Each case holds id, corpus, category, origin, question, expected_behavior (answer, fallback or correct_or_fallback), required_facts (each a fact with short match terms), forbidden_claims, sources (file, page and an evidence quote copied verbatim from the page's extracted text), severity and notes.

WhyWith one case per line, a reviewed commit that adds or changes a case is a one-line diff. The README allows a case to change only by a reviewed commit, never to make a run pass. A malformed line makes JSON.parse throw, which stops the run before the Worker starts or any model is called.

30 cases at the pin: resume-01–04, book-01–21, boundary-01–05answer 23, fallback 3, correct_or_fallback 4evals/JOURNAL.md, The harness: the first golden set had 25 cases

The same idea, shown in the course's code: A golden-set case in JSON lines: facts, forbidden claims, sources From Prove it works, Ep 1: The golden set
Explained in Ep 1: A golden-set case: question, required facts, sources with quotes From RAG deep dive, Ep 1: RAG Debugging: Retrieval, Reranking or Generation?

fileOf()

function · lines 231–234View on GitHub

The file a case's expected sources are in.

Called by score() Scoring a case

/** The pool's passages carry no file name; a case's sources are all in one file. */

Why scoring needs a file for pool passages Never runs

WhatThe doc comment states the reason: the reranker's pool, read back from the rerank prompt, holds passage texts without file names.

WhyScoring matches a passage to an expected source by file and by text, so each pool passage needs a file before the comparison can run.

function fileOf(c) {  return c.sources[0]?.file}

The first source's file Eval run

WhatReturns the file of the case's first expected source, or undefined when the case has no sources (the absent-topic cases and resume-04).

WhyfileOf() assumes all of a case's sources are in one file, which holds for all 30 cases at the pin. For resume-02 (corpus both), book passages in the pool are tagged resume.pdf too. A false match from that is very unlikely, because a match also needs the résumé evidence, or a half of it at least 30 characters long, in the passage text.

cases with sources in two files at the pin: 0