Skip to content

feat(content): add the brief eval: 30 cases, the 2026 brief rules as a rubric, a gate on what the brief wasn't given, and a judge's quoted scores (CE-EVAL-001, brief rules PR 2) - #1538

Merged
gkhngyk merged 5 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-eval
Oct 26, 2026

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Brief rules 2026, PR 2 of 10: the brief eval (CE-EVAL-001). Stacked on #1535 (the brief's number and name guard). This PR's own changes are its commits after #1535's branch. Server only.

Before the brief gains the 2026 rules (answer-first lines, facts with their kind of source, a TL;DR, an angle and proof to gather, entities, freshness, format hints, guardrails, links), this PR adds a way to measure briefs, so the change can be measured against today's (v1) briefs. It covers our own briefs only; there are no competitor briefs.

  • content-brief-eval.js:
    • BRIEF_CRITERIA: nine criteria, one per rule, each scored 0 (missing), 1 (partly) or 2 (fully).
    • briefChecks: checks anyone can repeat:
    • judgeSchema, JUDGE_SYSTEM_PROMPT, buildJudgePrompt: a judge model scores each criterion with the brief's own words. The judge sees the brief as plain lines: Goal, Audience, each H2 and key point, Keywords.
    • readJudged keeps one whole score from 0 to 2 per criterion. A score above 0 whose quote isn't in the brief becomes 0, marked unquoted, so the judge can't vouch for what the brief doesn't say. A quote must be at least 3 words and within one line. It's compared in one Unicode form, with straight quotes and apostrophes, without the marks around it, and split where it was shortened ("…").
    • summarize: the mean per criterion, the gate, the checks, the tokens.
    • promptVersion: a short hash of the brief's rules, its schema and every case's prompt, under Quality's phase (from phase 2 the prompt names the site type). A record made under another prompt or phase is stale.
  • __fixtures__/brief-eval/cases.js:
    • 30 pages to plan: ten per site type (B2B, B2C, e-commerce), in English, Turkish and German;
    • the page types each site type offers (SITE_PAGE_TYPES, tested), new pages and live ones;
    • each is what Rebuild outline is given;
    • made-up brands only.
  • samples.js: a good brief and a bad one, plus a judge answer, for the tests.
  • scripts/eval-brief.js: for each case, it writes the brief with the brief's own model, prompt and shaping, checks it, has the judge score it, and prints the sums.
    • It records the model's own answer, the usage and the judge's scores. The test shapes and checks each answer again, so a change to the guard or the checks is read against the record.
    • A failed case is recorded with its error, never left out. Only a whole run, every case answered, writes recorded.json; any other goes to recorded.partial.json (gitignored).
    • Each call has a 120 s timeout.
    • The judge model is BRIEF_EVAL_JUDGE_MODEL, else anthropic/claude-haiku-4-5 (another model family), at the model's own temperature: newer models take no other.
    • The record keeps the Quality phase it ran under. Run it with the CONTENT_QUALITY_PHASE the API runs with.
    • It charges no workspace's AI usage and touches no database.
    • A full run is about a dollar.
    • It is run as node src/scripts/eval-brief.js, as eval-no-fabrication.js is. I didn't add an npm script.
  • content-brief.js:
    • the brief's shaping moves into shapeBrief, and its known numbers and names into briefKnown, so Rebuild outline and the eval read the model's answer the same way;
    • SYSTEM_PROMPT and outlineSchema are exported;
    • no behaviour changes.
  • .env.example: BRIEF_EVAL_JUDGE_MODEL, with a note.

CI (as agreed with the user: the recorded results in CI, live runs by the maintainer only):

  • content-brief-eval.test.js checks the cases, the rubric, the checks and the judge's reading on every run, for free and without a key.
  • Once recorded.json exists, it also reads the models' briefs:
    • every brief passes the gate;
    • 90% plan 3–10 sections;
    • each has all nine scores.
  • A record made under another prompt is skipped and said, not failed.

For @gkhngyk:

  1. With the brief's provider key and an Anthropic key (or another judge via BRIEF_EVAL_JUDGE_MODEL), and the CONTENT_QUALITY_PHASE the API runs with, run node src/scripts/eval-brief.js from server/. That records today's (v1) baseline before PR 4 changes the brief.
  2. Commit recorded.json to this branch, or post the printed sums and I'll add it.

PR 10 records the v2 briefs and sets the thresholds per criterion. The new brief fields stay behind CONTENT_BRIEF_RULES until then.

Related issue

Roadmap CE-EVAL-001 / brief rules 2026 (no GitHub issue).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/lib/content-brief-eval.test.js src/lib/content-brief.test.js.
  2. With keys: node src/scripts/eval-brief.js 3 records three cases and prints their sums. npx vitest run src/lib/content-brief-eval.test.js then reads them.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no web changes
  • yarn typecheck passes (run from web/): no web changes
  • yarn format:check passes (run from web/): no web changes
  • Changes are focused — one concern per PR

Server: npm run format, npm run lint (clean) and npm test (2,765 passed, 3 skipped: the two record tests without recorded.json, and the one skipped on main).

Tests:

  • the cases' coverage;
  • the rubric's nine keys;
  • the judge's prompt;
  • the checks on a good brief (gate passes, every fan-out answered) and a bad one (an address no one gave, a thin outline, the guard's placeholders, and what a guard would have let through);
  • a judge score kept only with the brief's own words, read as a whole number 0 to 2;
  • the sums;
  • the prompt's hash;
  • quotes read in any marks, shortened, three words at least, within one line;
  • addresses by host and path;
  • headings and questions in quotes read as the guard reads them;
  • the recorded briefs, when recorded and current: every case answered, shaped and checked again.

Seen by the eval's own tests, for #1535: the guard reads a heading in heading mode, as page headings are read. So a role before a name in a heading ("What CFO Anna Weber Needs From A Forecast") isn't read, and the name stays. That's the writer's own trade-off for title case ("Questions A CTO Asks Before Switching"); the record will show whether it matters for briefs.

A pre-push review ran; its findings are fixed in the second commit (the gate as the guard reads it, the raw answers checked again, quote reading, the prompt's version, partial runs, addresses).

🤖 Generated with Claude Code

cihan-gyk and others added 4 commits October 26, 2026 04:31
…ave as a placeholder, so the writer can't take it as given

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aceholder in half, and test the audience, names in headings and Turkish percentages (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s as a rubric, checks anyone can repeat with a gate on anything the brief wasn't given, a judge model's quoted scores, and a script that records them (CE-EVAL-001, brief rules PR 2)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e by line; record the model's own answers and check them again in the test; read quotes in any marks, shortened, three words at least, in one line the judge saw; version the prompt under Quality's phase and the schema; keep a partial run apart; compare addresses by host and path (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with one fix before the baseline is recorded, and follow-ups.

What I checked:

  • Only by hand, and nothing touched.
    • The script isn't an npm script, and no test imports it. Vitest includes only src/**/*.test.js.
    • The test calls no model. It reads recorded.json only when the file is there, so CI needs no key and spends nothing.
    • The script makes two calls a case, the brief's model and then the judge, each with a 120 s timeout. count runs fewer cases.
    • A missing provider key fails at start, before any call.
    • No reserveAiBudget, so no workspace's AI usage is charged.
    • No read or write: it loads the Supabase client from .env only because the modules import it, as eval-no-fabrication.js does.
  • The refactor. shapeBrief and briefKnown move #1535's code as it was, so Rebuild outline saves the same brief. SYSTEM_PROMPT and outlineSchema are only exported.
  • The record.
    • The model's own answers are kept and shaped again in the test, so a later change to the guard is read against them.
    • A failed case is recorded, not left out, and a partial run goes to the ignored file.
    • promptVersion covers the rules, the schema and each case's prompt under the recorded phase, and leaves the environment as it was. A stale record is skipped, not failed.
  • Cases.
    • 30 cases: ten per site type, in three languages, new and live pages, with page types the editor offers.
    • The brands are made up. The cited pages are generic sites.
  • The judge.
    • Another model family.
    • Scores are whole numbers from 0 to 2.
    • A score above 0 needs three words or more from one line of the brief.
  • Merge.
    • Server only, and it contains #1535 and nothing else. It merges cleanly on main.
    • No runtime path changes, so nothing changes at merge or at the API deploy.

Before the baseline run:

  1. A quote with its line's label earns 0 (server/src/lib/content-brief-eval.js:179, :216-239).
    • The judge sees lines that start "Goal: ", "Audience: ", "H2: " and "Keywords: ", and is told to copy "exactly from one of its lines".
    • A quote that starts with its label, e.g. "H2: What a rolling 13-week cash forecast is", isn't in the field, which has no label. So a fair score becomes 0, marked unquoted. EDGES takes off a key point's "- ", but not the other labels.
    • The record keeps only the scores as read (server/src/scripts/eval-brief.js:88-93). An unquoted score keeps its quote but loses its number. A later fix can't re-read the baseline; it has to be paid for again.
    • Fix:
      • Take a leading goal: / audience: / h2: / keywords: off each part before the lookup.
      • Keep the judge's own answer (graded.object) in the record, and read it with readJudged in the test and the sums, as the brief's answer is read.
      • Add a test: a quote that starts with "H2: " keeps its score.

Follow-ups:
2. The gate reads as the guard does, so it can't fail on figures or people (content-brief-eval.js:131-132, content-brief.js:340-348).

  • found uses the guard's own numbers, cues and question rule, on a brief the guard has just shaped. It finds nothing there, except a figure the cut happens to make. So in the baseline and in v2 alike, the gate's figures and people are 0 by design. It still tests that every field goes through the guard: the test on the unshaped answer shows that.

  • It can't show what the guard lets through:

    • a role and a name in a heading (the description says the record will show whether that matters; it can't);
    • a name inside a quoted question;
    • a name without a cue.
  • Nor can it show what the guard takes out by mistake: a count, or a reworded search in quotes (#1535's follow-ups).

  • Fix: for each case, list and print two things, and keep both out of the gate:

    • What the guard took out of the model's answer: guard.found on the raw answer's fields. The test can work it out from the record for free.
    • What a person should look over, read without the guard's cues, as toReview does for the no-fabrication set (src/lib/__fixtures__/no-fabrication/guarded.js). That means names as NAME reads them and quotes of four words or more, a line at a time, that the case didn't give.

    Then name the gate for what it checks: every field guarded, and no address the case didn't give.

  1. A recorded address can turn CI red (content-brief-eval.test.js:262).
    • The record test fails when any recorded brief has an address the case didn't give.
    • The brief has no address guard, so a made-up address is something to measure, not a regression. A baseline with one can't be committed without failing CI.
    • Until #1535 leaves addresses alone, a given address fails too: case b2b-de-solution_page cites ".../thread/123", which the guard turns into ".../thread/[figure, source]" if the brief names it.
    • Fix: fail the record test on figures and people only, and count addresses in the sums.

@gkhngyk
gkhngyk merged commit d15419b into ansvisor:main Oct 26, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants