Repository navigation
feat(content): plan each section's answer, format and facts in the brief behind CONTENT_BRIEF_RULES, with the cited pages numbered and the rules in effect (brief rules PR 4) - #1540
Conversation
…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]>
…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
|
Merged #1539 is now on the branch too, so the contract test that reads Checks after the merge: server format and lint clean; 223 test files, 2,788 passed, 3 skipped. PR 5, stacked on this one, is coming next. |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
-
With
CONTENT_BRIEF_RULESoff.- The system prompt and schema are version 1's. The prompt template gives the same text: the two new lines are empty strings, and the blank line before "Prompts the page must answer" stays. The pinned hashes hold this.
rulesis parsed by the route but goes no further (planTois[]). The guard doesn't know the rules' numbers, as the version 1 test shows.v2is read from the answer's shape. Version 1's schema drops keys it doesn't know, so a version 1 answer never getsversion: 2, andfitBriefreturns it as it is.stripSourceIdskeeps its default, so the writer and Fix strip as before.- The only change: an H2's fan-out also matches when the model copies it in quotes. A fan-out written exactly as listed still matches first.
-
The route.
rulesis optional, at most 60, and cut to 60/200/500 characters. That's the writer's limits, and the web'sMAX_AGENT_RULES(#1541) is 60, so the list the editor sends always parses. An API from before this PR drops the key. -
The stored brief and the editor. Each new field is written as
draftBriefSchemaon main reads it, so nothing is dropped on read:answeris at most 600 characters, or null;formatis a listed key, or null;factshas at most 4 items, each with:- a non-empty
claimof at most 300 characters; - a listed
sourceType; source: null, or{ kind: 'cited_page', ref ≤ 2048, label ≤ 300 }, kept only with a label;
- a non-empty
versionis 2.
Other readers:
- The writer's
briefTextreads only version 1's fields, so a version 2 brief writes the same page. - Edit brief keeps the new fields (#1539).
- A brief stored before reads as it did.
-
The model's answer.
- An off-list format or kind is read by key or dropped.
- A fact without a claim or with an unknown kind is dropped.
- A number that isn't a listed page reads as no source.
- A missing key or a wrong type fails the call, as in version 1: it's charged, nothing is saved, and the brief stays as it was. A stop saves nothing either.
-
The prompt.
- The pages and the read come from the same numbered list (
briefNumbered), so a number can't point at another page. - The route bounds the rules.
- The page addresses are the request's, as before.
- The pages and the read come from the same numbered list (
-
The AI budget.
- Still one call, held with
reserveAiBudgetand charged by its usage, withreleaseinfinally. - With the flag on, the extra tokens are charged by what the call used. With it off, the tokens are the same.
- Still one call, held with
-
The work.
fanoutKeyandstripSourceIdsrun on short strings, and the guard runs once per field, so no input makes them slow. -
The fit. Sources go first, then facts, measured against 60,000 bytes, which leaves room for jsonb's spaces.
- The last step isn't measured again, and version 1's fields aren't cut to fit. So a brief at every limit in a three-byte script could still go past 64 KB.
- A real brief is a few KB, so I'd leave it.
-
Tests.
- The plan, fit, enum and route tests fail without the change.
- The enum test reads the JSON schema zod really writes, not a mock.
- The contract test reads the web's own
brief.ts.
-
Merge.
- d887cb9 merges main. Six files conflict on a re-merge, each resolved to this PR's side. Main's copies of those files are byte for byte #1538's head (f267683), so nothing of main is lost. The rest is main's.
- The head contains main (4efa150), so it merges cleanly. Server only, no migration.
- Nothing changes on Vercel at merge. At the API deploy, with the flag off, the only change is the quoted fan-out match.
Follow-ups (before the version 2 record, PR 10):
- The judge can't quote the new Format lines (
server/src/lib/content-brief-eval.js:113,:243,:252).readJudgedcompares a quote with each field's text without its label, and asks for three words at least. A Format line's text is one word ("table").- So "Format: table", the quote the
formatcriterion invites, can never pass. The criterion falls to 0, markedunquoted, exactly where version 2 adds the plan. - This is #1538's open item (a quote with its line's label) made worse. The record keeps only the scores as read, so a version 2 run would have to be paid for again.
- Fix:
- Compare quotes with each line as the judge sees it (
norm(f.label + f.text)), which still contains the text alone. - Let a quote that is a whole line pass under three words.
- Add a test: a "Format: table" quote keeps its score.
- Compare quotes with each line as the judge sees it (
- The judge's rubric isn't versioned (
content-brief-eval.js:68,:275).- This PR changes the
formatcriterion.promptVersionhashes the brief's prompt only, so a baseline judged under #1538's wording isn't marked stale next to version 2 judged under this one. - Fix: record a hash of
JUDGE_SYSTEM_PROMPTandBRIEF_CRITERIAbesidepromptVersion, and skip a record made under another. Or record the version 1 baseline only after this lands.
- This PR changes the
- A fact's source address isn't checked (
server/src/lib/content-brief.js:482).- The ref is a cited page's address as the request sent it (
rebuildSources.pages[].urlis cut, not checked as an address). Nothing shows it yet. - Fix: keep a page as a fact's source only when its ref is http(s), as
brief.tsdoes for links. At the latest, check it in PR 9 before the ref is ever used as a link.
- The ref is a cited page's address as the request sent it (
Summary
Brief rules 2026, PR 4 of 10: the brief plans each section's answer, format and facts.
CONTENT_BRIEF_RULES, which is off by default.With
CONTENT_BRIEF_RULES=true: Rebuild outline writes the brief's version 2 for each section, in the shape #1539's editor reads (the contract inweb/src/lib/content/brief.ts).With it off, the system prompt, the schema, the prompt and the saved brief are the same as before. Two tests check this:
245d727b9091at phase 0,bfa5ca4994bfat phase 2).One small change also applies with the flag off: an H2's fan-out now also matches when the model copies it with the quotes the prompt lists it in. A fan-out written exactly as listed still matches first.
What the model is asked
outlineSchemaV2adds three fields to each section:answer: what the section's first sentences must answer directly. It is a note to the writer, with no word count.format: one ofparagraphs,list,steps,tableorfaq.facts: about one fact per section. Each fact has:statistic,study,quote,exampleorofficial;formatandsourceTypeare enums in the JSON schema the model is given (.meta({ enum })), so a model that supports constrained output picks keys and doesn't write free words. A Turkish or German brief would otherwise translate them ("tablo"), which the web can't read.Zod's own validation still accepts any string, so a model that writes "Table" doesn't fail the whole call, which would still be charged.
sectionPlanthen reads the key: trimmed and in lower case, or none.SYSTEM_PROMPT_V2It is version 1's rules plus these:
sourceonly.The prompt, with the flag on
S1: <url> (kind)):numberSources, the same as the writer's.PAGE_TYPE_SECTION_FORMATS), e.g. a table for a comparison or numbered steps for a guide.{ brandId, sources, rules? }withbriefRules(at most 60). This mirrors the writer's{ sources, rules }, and PR 7 (feat(content): send the rules in effect with Rebuild outline, so the brief plans to them with the brief rules (2026) on (brief rules PR 7) #1541) sends them.rebuildSourcesis unchanged. The writer and Fix share it.The answer as kept (
sectionPlan)stripSourceIds(text, count); the writer's calls are unchanged).{ kind: 'cited_page', ref, label }, never by its number in this run. The number would point at another page once the Sources tab changes.fitBriefA version 2 brief over 60,000 bytes first drops the facts' sources, then the facts. The column holds 64 KB, and the margin leaves room for jsonb's spacing. So a brief that was charged for always saves.
The eval (#1538)
promptVersiontakes the flag into account.Answer:,Format:andFact (kind, check against <page>):lines.formatcriterion asks for H2 lengths only. The brief plans no H1: the page's title is the draft's.briefRules. To record version 2's briefs (PR 10), run it withCONTENT_BRIEF_RULES=true..env.exampleAdds
CONTENT_BRIEF_RULES, off until the eval passes it.Cost with the flag on
Related issue
Roadmap CE-EVAL-001 / brief rules 2026 (no GitHub issue).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
CONTENT_BRIEF_RULES=true, click Rebuild outline on a draft that has a cited page in Sources. Check the savedcontent_drafts.brief:version: 2;answer,formatandfacts;sourceisnullor one of the cited pages, by kind and ref.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/): no web changesyarn typecheckpasses (run fromweb/): no web changesyarn format:checkpasses (run fromweb/): no web changesServer checks, run locally on this branch:
npm run format: no changes beyond this PR's files.npm run lint: clean.npm test: 223 files, 2,778 passed, 4 skipped.Tests
" Table "read astable;s1;briefRulesand the route: rules passed through, cut to fit; more than 60 refused.web/src/lib/content/brief.ts, its sample andsources.ts, and compares the limits, the kinds and the source kinds;Pre-push review
Two review passes ran before pushing.
First pass, on the first commit. Fixed:
formatandsourceType, which a Turkish brief would translate;rebuildSources;Object.hasOwnfor the page type's formats;Second pass, on the fixes. It confirmed the flag-off hashes against #1538's head. Fixed:
mapOutlinetest, a route test that actually cuts.Left for later:
factsstays a required array in the schema, askeyPointsis.🤖 Generated with Claude Code