Repository navigation
feat(content): name the brand, its products and competitors as written, and plan links to the pages listed only, in the brief behind CONTENT_BRIEF_RULES (brief rules PR 6) - #1545
Merged
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]>
… 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
…n, and plan links to the brand's pages and the sources listed only, in the brief behind CONTENT_BRIEF_RULES (brief rules PR 6) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… past a failed competitors read, cap the pages' titles and skip addresses the web can't keep, drop a link whose words got a placeholder, and give the eval cases competitors and pages to link to (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 12 tasks
4 of 12 tasks
gkhngyk
approved these changes
Oct 26, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- With
CONTENT_BRIEF_RULESoff.- Nothing new is read. The competitors and the link targets are
Promise.resolveplaceholders, so the rebuild makes the same queries as before. - The prompt is as before.
linkableis an empty string, placed where nothing was, and the guard's given text is unchanged (competitorsis[]). The pinned hashes are untouched and hold this. - Version 1's schema has no
products,competitorsorlinks, sonamesAndLinksnever runs, andfitBriefreturns a version 1 brief as it is. The output, the stored brief and the cost are the same.
- Nothing new is read. The competitors and the link targets are
- The new reads, with the flag on.
- The competitors are read by
brand_idon its index. The brand is the draft's, checked just before the reads. readLinkTargetsmakes the reads the agent and the writer already make on every run:- the brand's site pages (the top 41);
- the Sources tab's
content_draft_sourcesfor the draft (bounded in 00226); - the draft's source choices.
- All of them run beside the brand read, before the budget hold. A slow read delays the call but charges nothing.
- A failed read leaves its list empty and is logged. supabase-js returns a network failure as an error, so neither read fails the rebuild.
- The competitors are read by
- Links.
- A link is kept only when its address, read by
linkKey, is on the list it was offered: internal links against the brand's pages, outbound links against the sources. It's stored as listed: http(s) only (readLinkTargetskeeps nothing else), and at most 2,048 characters, sincelinkablefilters before the cut. - The sources leave out the brand's and the competitors' sites and the ones the person left out. The brand's pages leave out the draft's live page.
- The link words go through the guard and are cut to 120, and a link whose words have a placeholder is dropped. The section is an outline H2 or null.
- At most 8 internal and 5 outbound links;
linksis null when there are none.
- A link is kept only when its address, read by
- Names.
- The brand's name comes from the database, cut to 120.
- A competitor is kept only when it's on the list, and is stored as listed.
- A product is at most 120 characters. It must be found, as a whole word, in the brand's own words, and it's taken as written there. It's never the brand's or a competitor's name.
- At most 10 of each list.
- This checks the spelling, not that the name is a product: a common word in the brand's text ("pricing") passes. That's fine for a plan.
- The stored brief and the editor.
- Each field is written the way
draftBriefSchemaon main reads it:entities: a brand of at most 120 characters, and at most 10 products and 10 competitors of at most 120 each;links: at most 8 internal and 5 outbound, each with an http(s)urlof at most 2,048, ananchorof at most 120, and asectionof at most 300 or null.
- The contract test compares every new limit with
brief.ts. - Edit brief keeps both fields (
...brief). The Brief tab doesn't show them yet. - A brief stored before has neither field and reads as it did (
.nullish().catch(null)).
- Each field is written the way
- The work.
- The product match escapes the name and runs one regex per name over the brand's own words. That's linear for each name, and the PR's timing (300 names over 540,000 characters in 180 ms) goes well past any real brief.
- The guard reads a link's words as it reads every other field, and the placeholder check runs on at most 120 characters.
- The fit. The links go first. The new test fails without that step.
entitiesisn't cut (2,520 characters at most). That adds a little to #1540's note on a brief at every limit, but it's still far from a real brief.
- The AI budget. Still one call. With the flag on, the extra tokens are charged by what the call used. A missing new key fails the call as in #1540: it's charged and nothing is saved.
- Merge.
- Through a temp base with main's tree and both parents (1851425 and main), the merge is clean.
- The merged tree differs from main by exactly this PR's diff (5 files), and main's copies of those files are 1851425's.
- Server only, no migration. Nothing changes on Vercel at merge, or at the API deploy while the flag is off.
Round 32's open items:
- The judge can't quote a one-word line (#1540 item 1): not fixed, and now worse. See item 2.
- Fan-out coverage counts only the kept fan-outs (#1543 item 1): not touched.
- A fact's source ref isn't checked to be http(s) (#1540 item 3): not touched. The new link addresses are http(s) by construction, so the gap is still in fact sources only.
- The judge's rubric isn't versioned (#1540 item 2): this PR changes the judge's prompt again. No record exists yet, so nothing goes stale now.
Follow-ups (before PR 10 compares version 2 with the baseline):
- The judge and the gate are told a version 1 brief was given what it wasn't (
server/src/lib/content-brief-eval.js:194-201,:266).- In the three cases with competitors and pages,
buildBriefPromptlists them only with the rules on. ButbuildJudgePromptalways says "Competitors it was given", andbriefChecksalways counts those pages as given addresses. - So the version 1 baseline is graded under
entitiesagainst names it never saw, and its gate passes a guessed own-page address. Both skew the comparison PR 10 makes. - The judge also isn't told the sources an outbound link may go to, which the
linkscriterion asks about. - Fix:
- Show and count the competitors and the link targets only for a brief built with them (
brief.version === 2). - List the sources to link to beside the brand's pages.
- Add a test: a version 1 brief's judge prompt for such a case has no "Competitors it was given".
- Show and count the competitors and the link targets only for a brief built with them (
- In the three cases with competitors and pages,
- The judge can't quote the new "Names as written" line (
content-brief-eval.js:148,:309).- 27 of the 30 cases have no competitors. Unless the page names a product, their line is just the brand's name: one or two words.
- The quote check asks for three words, read without the label, so a quote of that line ("Names as written: Ledgerly", or "Ledgerly") scores 0 under
entitiesand is markedunquoted. - This is #1540 item 1 again, now on a second criterion. The link lines have the label half of it.
- Fix: the same as #1540 item 1: read a quote against the line with its label, and let a quote of a whole line pass under three words.
- The brief plans links the rules have turned off (
server/src/lib/content-brief.js:166,:379).readLinkTargetsis always asked for both lists. The writer asks by the rules in effect (content-writer.js:558).- So with Internal links off for the draft, the brief still lists the brand's pages and plans links to them, which the writer can't keep.
- Fix:
- When rules are sent, pass their keys (
new Set(planTo.map((r) => r.key))), as the writer does. With none sent, keep both lists. - Add a test: rules without
internalLinksgive no brand pages in the prompt and nolinks.internal.
- When rules are sent, pass their keys (
- Bound the competitor names in the prompt (
content-brief.js:376-394,:972).competitors.namehas no length limit in the table or the action, and a name is only trimmed. Its full length and any line breaks go into the prompt.- The names are joined with ", ", so "Acme, Inc." reads as two names, and the model's "Acme" is then dropped because it isn't on the list.
- The read has no order, so which 20 of a longer list are given can change from run to run.
- Fix:
- Collapse the whitespace in each name and cut it to 120 (a longer name can't be stored anyway).
- Order the read by
created_at, as the Competitors list shows them. - List the names one per line (
list(competitors)), or each in quotes. - Put the page titles in quotes too, with double quotes made single, as the input items are: a cited page's title is that site's own text.
- The brand's page titles are its words for products, but not for the guard (
content-brief.js:640,:752,:887-900).- Products may come from the brand's page titles, but
briefKnowndoesn't list those titles. - So a link whose words repeat its page's title ("Top 10 espresso grinders") gets "[figure, source]" and is dropped. And when a product is named only in a title, an H2 that names it reads "Grinder [figure, source]", while
entities.productskeeps "Grinder 900". - Fix:
- Add the brand's listed page titles to the guard's given text, as the competitors now are.
- For a source, guard its link's words with its own title known.
- Products may come from the brand's page titles, but
As with #1543's item 4, nothing reads entities or links yet: not the writer's briefText, and not the Brief tab. A later PR in the series should, before the flag goes on.
4 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brief rules 2026, PR 6 of 10: the brief names things as they're written and plans its links.
CONTENT_BRIEF_RULES(off by default). No migration.entitiesandlinks.What the rebuild reads, with the flag on
competitors; 20 at most. A failed read leaves none, as a failed read of the link targets does, and the rebuild goes on.readLinkTargets, as the Content Agent reads them:The prompt lists 12 of the brand's pages and 8 sources at most (
BRIEF_LINK_PAGES). Those are also the only pages a link may go to. Each page's title is cut to 150 characters, and a page whose address is longer than the web keeps (2,048) isn't offered.What the model is asked
products: the brand's products the page names, written exactly as the data writes them.competitors: the competitors listed that the page names, as listed.links.internal/links.outbound: up to 5 of the brand's pages and up to 3 sources. Each has its address copied from the list, the words to link, and the H2 it goes in.What is kept (
namesAndLinks)entities.brandis the brand's name, from the database, never the model's.entities.competitorskeeps only names on the list, written as listed. A name off the list is dropped.entities.productskeeps a product only where the brand's own words write it: its name, industry and description, the page's title and headings, Your input, and its own pages' titles.linkskeep only addresses on the list, compared as links compare them (linkKey), and stored as listed:fitBrief: past 60,000 bytes, the links go first, then the fan-outs left out, the facts' sources, and the facts.The eval
All of this is used with the flag on only, so the pinned version 1 hashes don't move.
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 whose brand has competitors and Site pages. Check the saved brief:entities.competitorsare names on the brand's list;entities.productsare written as in the sources;linksaddress is one of the brand's pages or a kept source.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 after the review fixes: format and lint clean; 223 test files, 2,801 passed, 3 skipped (the eval's recorded-baseline tests).
Tests:
readLinkTargetscall.fitBrief: the links go first when that's enough.brief.ts.Pre-push review
A review agent read the change before the push. It confirmed:
fitBriefdrops links first, and the fit test exercises that step;Fixed from it:
Left as is: Turkish İ/ı don't match across cases in the product check (
iu), so such a product is dropped. That's safe: nothing wrong is kept.🤖 Generated with Claude Code