Skip to content

fix(content): put a number, name or quote the brief's sources don't have as a placeholder (brief rules 2026, PR 1) - #1535

Merged
gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/brief-number-guard
Oct 26, 2026
Merged

gkhngyk merged 2 commits into
ansvisor:mainfrom
cihan-gyk:fix/brief-number-guard

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Brief rules 2026, PR 1 of 10: guard the brief's numbers, names and quotes. This PR is cut from main and touches the server only.

The Content Editor's writer reads the brief as part of what it was given. The numbers in the brief, and the people and quotes it names, are in the writer's "known" lists (content-writer.js: knownNumbers(…, brief, …) and knownPeople(…, brief, …)). Rebuild outline asks the model to "use only the facts given", but nothing checked what it wrote. A made-up "73%" or "Dr. Jane Doe" in a key point would pass the writer's own guards (CE-033, CE-044) and could end up on the page.

Now the brief goes through the same guards as a written page before it is cut and saved:

  • briefGuard in content-brief.js knows only what the brief was built from:
    • the brand's name, industry and description;
    • the page's title;
    • the prompts, fan-outs, Search Console queries and current headings kept;
    • the length asked for;
    • today's year.
  • Goal, audience and key points: a number the inputs don't have becomes [figure, source], an unknown person's name [name of a real person], and an unknown quote [quote from a real person, with its source]. These are placeholderNumbers and guardPeople, as the writer uses them.
  • Headings use guardPeople's heading mode, as page headings do.
  • Keywords: a keyword that would add one is dropped. A placeholder can't be searched for.
  • A question in quotes stays: Answer "Which espresso machine should I buy?" is a question to answer, not a person's words. A quote that isn't a question still goes.
  • The cut never splits a placeholder: a goal, audience, heading or key point cut to its limit drops a placeholder the cut would reach, rather than leaving [figure, so.
  • Unchanged:
    • A lone digit used as a count ("Compare 3 grinders") and numbers from the inputs ("under $500" from a prompt) stay.
    • The prompt and the model call are the same, so there is no cost change.

What changes for the person:

  • A structural number the inputs don't have now reads as a placeholder, as it does on a page the writer writes: "Top 10", "Day 10", "of 2027" (only this year counts as known) or "about 800 words". Before, the writer took such a number from the brief as given. Edit brief can put it back: a brief the person edits isn't guarded.
  • A heading keeps a role and a name ("Why CEO Grace Hopper chose Acme"), as page headings do; only an honorific ("Dr. Jane Doe") marks a name there.

Not in this PR: Opportunities › Generate Brief (routes/content.js, generateBriefForOpportunity) has the same gap. The writer falls back to that brief when the draft has none. It is a separate feature with its own quota, so it gets its own PR.

This is the first step of the plan for the 2026 brief rules and CE-EVAL. Next comes the brief eval (CE-EVAL-001), which will record a baseline of today's briefs before the brief gains new fields.

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.test.js.
  2. With an AI provider key, open a draft in the Content Editor, keep a few prompts and fan-outs in Sources, and click Rebuild outline. Any figure, person or quote in the outline that isn't in the kept sources reads as a placeholder in square brackets.

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 (only this PR's two files), npm run lint (clean) and npm test (2,743 passed and 1 skipped as on main; 7 files that timed out under memory pressure passed when rerun alone: 145 tests).

Tests:

  • a rebuild puts an invented percentage, a number in a heading, a person's name and a quote as placeholders;
  • the prompt's and fan-out's numbers, a count and this year stay;
  • a keyword that adds a number is dropped;
  • the guard knows each input (brand, title, headings, length, prompts);
  • the audience, a name in a heading, a keyword that names someone, a question in quotes, and Turkish percentages ("%25", "yüzde 40");
  • the cut drops a placeholder it would split;
  • the limits test now cuts letters, since digits the sources don't have become placeholders.

A pre-push review ran.

🤖 Generated with Claude Code

cihan-gyk and others added 2 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]>

@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:

  • What the guard knows. It knows what the brief's prompt gives as words: the brand's name, industry and description, the page's title, the prompts, fan-outs, Search Console queries and live headings kept, the length, and this year.
    • The rest of the prompt has no facts to lose. The page-type and site-type lines have no numbers or names.
    • The cited pages' and the live page's addresses aren't words, as sourceWords treats them for the writer.
    • So a figure or name the model was given stays. The tests cover each input, numbers from a prompt and a fan-out, a count, this year and Turkish percentages.
  • Where it runs.
    • Goal, audience and key points are read as text. Headings are read as page headings are.
    • A keyword is dropped when the guard would change it.
    • It runs before the cut, and the cut never leaves half a placeholder.
    • keyPoints wraps guard.text, so map's index isn't passed as heading.
  • What it catches.
    • A number with a unit, or of two digits or more. Numbers are read first, so a number inside a quoted question goes too.
    • Names by the writer's cues.
    • Quotes of four words or more.
  • The writer. It reads the brief as given (briefText is in both known and people). A rebuilt brief now adds nothing beyond its inputs, apart from the gaps below.
  • Cost. Same prompt, same single call. The guard runs after the charge.
  • Merge.
    • Server only. Two commits on the old main; it merges cleanly on main (4085418). No migration.
    • Nothing changes on Vercel at merge. Rebuild outline changes with the next API deploy. Edit brief stays unguarded, as described.

Follow-ups:

  1. A given address loses its numbers (server/src/lib/content-brief.js:326).
    • placeholderNumbers reads the whole text, addresses too. The prompt gives the cited pages and the live page by address (:376, :389).
    • A key point that names one with a number in its path gets cut: "…/thread/123" becomes "…/thread/[figure, source]", and "/2024/05/…" loses both numbers. That drops a fact the brief was given, and the address no longer works.
    • It's rare today, since the brief plans no links. The 2026 rules add links. #1538's gate then reads the cut address as one nobody gave: its case b2b-de-solution_page cites ".../thread/123".
    • Fix: run both guards on the text between addresses ((?:https?:\/\/|www\.)\S+) and leave the addresses as written. Add a test with a cited ".../thread/123".
  2. A search in quotes, reworded, becomes a person's quote (:329).
    • The prompt lists the fan-outs in quotes (:383), so the model quotes searches in key points.
    • One of four words or more that isn't word for word in the inputs reads as a quote. On the city-bike case, Compare "derailleur vs internal gear hub" for city riding becomes Compare [quote from a real person, with its source] for city riding. The writer is then asked for a quote from a real person.
    • Fix: read a quote whose every word is in what the brief was given (isKnown on each word against people) as a phrase to target, not a person's words. One next to speech stays a quote. Add a test with a reordered fan-out.
  3. A quoted question makes its words known for the whole text (:327-328).
    • askedIn adds the question's words to the names and quotes the text may have:
      • Answer "Is Dr. Jane Doe right about burr grinders?" keeps Dr. Jane Doe. So does any "Dr. Jane Doe" elsewhere in the same key point. The writer then takes the name as given for the whole page.
      • A question someone is said to ask passes too: "Why did nobody tell me sooner?" says one customer. Without the exception, that's a quote, and it would get the placeholder.
    • Fix: leave a quoted question out of the quote check only. Don't add its words to the known set.
      • Blank its two marks in a copy, read peopleEdits on the copy with people, and apply the edits to the text (the places don't move).
      • Keep a question next to speech (the guard's SPOKEN_AFTER / SPOKEN_BEFORE) as a quote.
      • Test a name inside a quoted question, and a question followed by "says".
  4. A role and a name in a heading pass, and then reach the page's body (:333).
    • Heading mode skips role cues, as page headings do, so "What CFO Anna Weber needs from a forecast" keeps the name. #1538 notes this.
    • On a page, the miss costs one heading. Here it goes further: the writer's people includes the brief, so "CFO Anna Weber explained…" in the body passes too.
    • Fix:
      • Read role cues in a brief heading unless it's in title case (most words after the first capitalised). Title case is the case the trade-off is for ("Questions A CTO Asks Before Switching").
      • For title case, the writer could leave the brief's headings out of people.

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