Skip to content

feat(content): plan the page in the brief behind CONTENT_BRIEF_RULES: essentials, angle, proof to gather, fan-outs left out and freshness, with Brief › Your input as sources (brief rules PR 5) - #1543

Merged
gkhngyk merged 12 commits into
ansvisor:mainfrom
cihan-gyk:feature/brief-page-plan
Oct 26, 2026

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Brief rules 2026, PR 5 of 10: the brief plans the page itself. It adds the essentials at the top, the angle, the brand's own proof to gather, the fan-outs left for another page, and freshness. It also reads Brief › Your input as sources.

What the model is asked

outlineSchemaV2 gains page-level fields:

  • tldr: what the page's essentials at its top must state, as a note to the writer.
  • angle: what this page can show that commodity pages can't.
  • proof: up to 4 pieces of the brand's own proof to gather. Each is one of experience, data, case, test or quote, plus what to gather. The kind is an enum in the JSON schema only, as PR 4's keys are, so an off-list kind never fails a charged call.
  • leftOut: fan-outs from the list that belong on another page, so the page keeps to one topic.
  • datedPoint: what the page should date (a price, a figure with its month), or null.

SYSTEM_PROMPT_V2 gains a line for each of them. It also says:

  • the person's input is used as given, never with an invented customer, test, quote or figure;
  • a fact's source can be one of the person's input items;
  • a proof's kind is a key, like format and sourceType.

Brief › Your input

  • With the flag on, the rebuild reads the draft's input (readDraftInputs, Quality's second phase) and lists it after the cited pages, numbered the same way: S2 "Returns by model": Their own data, a table: ….
  • The notes that only place an input (a quote's address, the day Ansvisor data was read) aren't listed: a fact cites the input by its number, and an echoed date or address would only come back with placeholders in it.
  • A fact can name an input item as its source. It is kept as { kind: 'input', ref: 'data:1', label }, as feat(content): read and keep the brief's version 2 through Edit brief (brief rules PR 3) #1539's sample has it.
  • The input's words are given, so the guard keeps their figures and names: "4.2% returns" from the person's table isn't turned into a placeholder.
  • With the flag off, the input isn't read at all.

The answer, as kept (pagePlan)

  • tldr, angle, each proof's what and datedPoint:
  • Proof: an unknown kind or an empty what is dropped, and 6 at most are kept.
  • Left out: only fan-outs the person kept and no H2 answers, written as listed (quotes taken off), each once, 20 at most.
  • Freshness comes partly from the page type (PAGE_TYPE_FRESHNESS in content-page-types.js):
    • an "Updated" line for best-of, buying guide, alternatives, comparison, pricing and policy pages;
    • the year in the title for the first four.
    • datedPoint is the model's. With neither, freshness is null.
  • fitBrief now drops the fan-outs left out first, then the facts' sources, then the facts.

The eval

  • The judge sees the TL;DR, the angle, the proof, the fan-outs left out and the freshness, and the gate reads them for invented figures, names and addresses.
  • fanoutCoverage counts only the fan-outs the brief keeps. A fan-out left for another page on purpose isn't scored as missed. leftOut reports how many were left out.

Cost with the flag on

  • About +250 output tokens, plus the input's own length when there is input (a table is cut to 3,000 characters, as for the writer).
  • About +$0.001 per brief at Gemini 3 Flash's list price.

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. Run the tests:
    cd server && npx vitest run src/lib/content-brief.test.js src/lib/content-brief-eval.test.js src/lib/content-page-types.test.js
  2. Set CONTENT_BRIEF_RULES=true and CONTENT_QUALITY_PHASE=2, and use an AI key.
  3. On a buying guide draft, add something in Brief › Your input and click Rebuild outline.
  4. Check the saved content_drafts.brief. It has:
    • tldr, angle and proof;
    • leftOut, listing only kept fan-outs;
    • freshness with updatedLine and yearInTitle set to true;
    • possibly a fact whose source is { kind: 'input', … }.

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 checks, run locally on this branch after #1540's merge with main:

  • npm run format: no changes.
  • npm run lint: clean.
  • npm test: 223 files, 2,796 passed, 3 skipped (the eval's recorded-baseline tests).

Tests:

  • The page plan: guarded and cut; S-numbers taken out; proof kinds read by key and unknown ones dropped; fan-outs left out validated (quoted, answered, unknown, repeated); freshness by page type, and none for a page that doesn't date.
  • Your input: numbered after the cited pages; its figures kept; a fact's source kept as an input; not read with the flag off.
  • fitBrief: the fan-outs left out go first when that is enough.
  • Page types: the type maps name only the editor's page types.
  • Eval: the judge sees the page plan, and the gate reads it. Coverage leaves out the fan-outs left for another page.
  • Contract test: it now runs, since feat(content): read and keep the brief's version 2 through Edit brief (brief rules PR 3) #1539 came in with main. It compares every limit and kind with brief.ts, including PROOF_KINDS, and checks the input source kind against the web's SUGGESTION_SOURCE_KINDS.

Pre-push review

A review agent read the change before the push. It confirmed:

  • nothing changes with the flag off: the input isn't read, and the prompt hashes are pinned;
  • every limit and kind matches the web's brief.ts;
  • the output's nullability fits the web;
  • unusual leftOut values are handled: non-strings, case, quotes, duplicates, and fan-outs an H2 answers;
  • the input widens the guard the same way the writer's does, unit-aware;
  • the person's own text is put in the prompt as the writer puts it.

Fixed from it:

  • the input notes are no longer listed;
  • coverage now leaves out the fan-outs left for another page;
  • the contract test now checks the input kind;
  • a helper was renamed.

Left for later: none of the eval's cases has Brief › Your input yet, so planning from the person's input isn't scored. PR 10 can add one.

🤖 Generated with Claude Code

cihan-gyk and others added 11 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]>
…ief behind CONTENT_BRIEF_RULES, with the data numbered, the page type's formats and the rules in effect; keep the facts' sources by kind and ref, cut to the web's version 2 limits and fit under 64 KB (brief rules PR 4)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…umber only the cited pages as sources, take the rules beside the sources, and read version 2's answers and facts in the brief eval (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…N schema only, so an off-list value never fails a charged call; take out only the page numbers given; match a fan-out as listed before its unquoted form; ask the judge for H2 lengths only (pre-push review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… its essentials, angle, the brand's own proof to gather, the fan-outs left for another page and freshness by page type, with Brief › Your input numbered as sources (brief rules PR 5)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nt the eval's fan-out coverage over the fan-outs the brief keeps, and compare the input kind with the web's (pre-push review)

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

# Conflicts:
#	server/.env.example
#	server/src/lib/content-brief-eval.js
#	server/src/lib/content-brief-eval.test.js
#	server/src/lib/content-brief.js
#	server/src/lib/content-brief.test.js
#	server/src/scripts/eval-brief.js

@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 follow-ups.

What I checked:

  • With CONTENT_BRIEF_RULES off.

    • The input isn't read: readDraftInputs isn't called, and inputSources(null) is [].
    • The prompt is as before: the new line is an empty string, and the blank line after the cited pages stays. The pinned hashes hold this.
    • Version 1's schema drops the page fields, so no version is written.
  • Brief › Your input.

    • It's read by the draft, which the rebuild has already matched to the brand, after the route's access check. It's read only at Quality phase 2 or later (readDraftInputs returns null below that).
    • A failed read fails the rebuild before anything is held or charged.
  • The input in the prompt. It's listed as the writer lists it (inputSources):

    • one line per item, with double quotes made single;
    • cut: experience to 4,000 characters, at most 5 tables of 3,000, 10 Ansvisor rows and 10 quotes;
    • the notes left out.

    It's numbered after the pages, from the same briefNumbered list the read uses. The guard knows its words through sourceWords, as the writer's does, the note aside.

  • The stored brief and the editor. Each field is written as draftBriefSchema on main reads it, so nothing is dropped on read:

    • tldr and angle are at most 500 characters, or null;
    • proof has at most 6 items, each a listed kind and a what of at most 300 characters;
    • leftOut has at most 20 fan-outs the person kept, as listed, none an H2 answers;
    • freshness is the object, or null;
    • an input source is { kind: 'input', ref, label ≤ 300 }, a kind in SUGGESTION_SOURCE_KINDS.

    The contract test now compares every limit and kind. Edit brief keeps these fields, and a brief stored before reads as it did.

  • The model's answer.

    • An off-list proof kind or an empty what is dropped.
    • A left-out item that isn't a kept fan-out is dropped.
    • A missing key fails the call as in #1540: it's charged, nothing is saved, and the brief stays as it was.
  • The AI budget. Still one call. The input's tokens are charged by what it used, through the same hold and release.

  • The work. fanoutMatcher runs once per left-out item, and the model's answer bounds the list. The guard reads the input's words once (knownPeople), so no input makes it slow.

  • The fit. The fan-outs left out go first, then the facts' sources, then the facts. The test fails without the new first step.

  • Tests. The page plan, input and flag-off tests fail without the change. The input test reads through the real inputSources.

  • Merge.

    • 1851425 merges #1540's new head. A re-merge of its parents gives the same tree.
    • The head contains #1540 and main. Server only, no migration.
    • Nothing changes on Vercel at merge, or at the API deploy while the flag is off.

Follow-ups (before PR 10 compares version 2 with the baseline):

  1. Coverage rises as the brief leaves more out (server/src/lib/content-brief-eval.js:180-190, :335, :346).
    • fanoutCoverage now counts only the fan-outs the brief keeps. A brief that leaves 3 of 4 out and answers the last one scores 1.0. One that leaves them all out is null, and drops out of the mean.
    • summarize doesn't add up leftOut. So the headline coverage of version 2 can beat the baseline's without the sums showing why.
    • Fix: in summarize, add the fan-outs left out and keep coverage over all fan-outs next to the kept-only figure. Test a case that leaves every fan-out out.
  2. The new page lines have #1540's quote problem (content-brief-eval.js:112-140).
    • The judge sees "TL;DR: ", "Angle: ", "Proof to gather (kind): " and "Freshness: ", and the quote check reads the text without them. A quote that starts with its label, like Freshness: an "Updated" line, scores 0.
    • Fix: the same as #1540 item 1: read quotes against the line with its label.
  3. The schema still asks for a cited page only (server/src/lib/content-brief.js:241).
    • The system prompt now says a fact's source can be one of the person's input items. The source field's description, which the model reads in the JSON schema, still says "the cited page to check it against".
    • Fix: word it as the system prompt does: "The number (S1…) of the person's input that gives it, or of the cited page to check it against, or null."
  4. Nothing reads leftOut yet (content-brief.js:545; server/src/lib/content-writer.js:228).
    • The writer's briefText reads only version 1's fields and still gets every kept fan-out. The editor's fan-out rules still count a left-out fan-out as missing.
    • Before the flag goes on, a later PR in the series should have the writer and Rules read it. Otherwise the brief leaves out what the page and the checks still ask for.

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