Repository navigation
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
Merged
Conversation
…ld outline runs, so the brief plans to them with the brief rules (2026) on (brief rules PR 7) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the brief's own keywords, and describe the rules only when a rebuild asks for them (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
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:
- What the API does with
rules.- Main, and the older API on prod:
rebuildBody(server/src/routes/content-drafts.js:169) is a plainz.object(zod 4), unchanged since #1293. It drops a key it doesn't know, so the request passes as before and the brief is built as today. - #1540 (and #1543, which contains it) reads the field as
rules: briefRules.optional(). Each rule is cut to 60 / 200 / 500 characters, and a request with more than 60 is refused.rebuildDraftBriefuses the rules only withCONTENT_BRIEF_RULES=true(planTo). With the flag off they're parsed and set aside, and the prompt and the guard stay as before. - So the server part this PR needs is #1540's route and prompt. Nothing it depends on is missing. PR 6 isn't open, and this PR doesn't need it.
- Main, and the older API on prod:
- What is sent.
- The list is
rules.rules, the one the Rules tab shows and Start, Rewrite from brief and Rewrite the page send. That's the draft's own choices, or My rules for its type on an untouched draft, over the page type's set with the brand's language. - It's filtered as
agentWriteRequestfilters: on, not the feed's, not one H1. Each rule is described by the sameuseRuleDescriber. - A fan-out rule names the fan-outs the page as written now doesn't use. Fix reads them the same way. Start reads a new page's against an empty page, but the rebuild also sends the page's headings as they are now, so reading the page as written fits it.
- The Keywords rule is sent only when the person changed it.
changedcompares the rule's value with the brief's keywords, so a value the person typed is sent and the brief's own isn't. The tests cover both. - The person's own text rules aren't sent (item 1).
- The list is
- Size.
- At most 60 rules:
sliceruns beforemap. - A name is a label. A detail is the rule's value (at most 500 characters by the rules schema) plus at most 300 characters of fan-outs.
- In practice that's a few KB, far inside the server action's 1 MB and the API's limits.
- #1540 cuts a long detail rather than refusing it, so nothing the editor describes can fail the rebuild there.
- At most 60 rules:
- With the flag off.
- There's no web flag. The web sends the rules whenever any are on, and the API decides what to do with them.
- With
CONTENT_BRIEF_RULESoff, the person sees no change. - The rules are described only when a rebuild asks, so typing costs nothing.
- Tests. Each fails without its change:
- the hook test, because the fourth argument would be undefined;
- the action test, because the body would have no
rules, orrules: []with a plain truthiness check; - the page test, because
expect.any(Array)would get no fourth argument; rulesForBrief, because the brief's own keywords would passrulesForAgent.
- Merge.
- Web only, two commits on 4085418, no migration.
- It merges cleanly on main (4efa150) and on #1543's head.
- Since the base, main changed only
content-drafts.ts,content-drafts-brief.test.tsandpage.test.tsxamong this PR's files. They merge without conflict, and the tests still read right: the action is mocked in the page test, and no test mocksagent-writewhere the side panel renders. - CI passes (format, lint, typecheck).
- Before the API is deployed:
- Rebuild outline, Rebuild with selection, Use lost prompts and Build brief work and read as today. The request carries the rules, and the API drops them.
- Nothing that works today stops working.
Follow-ups:
- The person's own rules aren't sent (
_side-panel.tsx:313-316,agent-write.ts:104).- Start, Rewrite from brief, Rewrite the page and Fix send the text rules that are on (
textRules), and the writer lists them (content-writer.js:273). - The rebuild sends only the rule list. So with the flag on, the brief plans without a rule like "End each comparison with the trial offer", and the writer then follows a rule the plan left out.
- Fix:
- Send
textRulesbesiderules, asstartAgentbuilds them:rules.textRules.filter(({ rule }) => rule.on).map(({ rule }) => rule.text). - Have #1540's
rebuildBodyread them aswriteDraftInputdoes (up to 50, 300 characters each), and list them under "Rules the page is written to". - Or say in the PR why the brief leaves them out.
- Send
- The API on prod drops the field, so the two PRs can still merge in either order.
- Start, Rewrite from brief, Rewrite the page and Fix send the text rules that are on (
- One filter in two places (
agent-write.ts:86-97and:158-191).agentWriteRequestrepeatsrulesForAgent's filter, its 60-rule cap and its description.- Fix: build the
{ rule, status }pairs there and callrulesForAgent. Then what the brief plans to and what the writer follows can't drift apart.
7 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 7 of 10: Rebuild outline sends the rules in effect. Web only, cut from
main, no migration.The brief rules (2026) plan a page to fit its rules, for example:
PR 4 (#1540) has the API read the rules from the rebuild request when
CONTENT_BRIEF_RULESis on. They come in the request body as{ brandId, sources, rules? }, the same shape as the writer's{ sources, rules }. This PR sends them:rulesForAgent(agent-write.ts) builds the list the Content Agent reads from the rules the editor checks. It keeps a rule only when it is:It keeps 60 rules at most, describes each as Fix does, and lists a fan-out rule's remaining fan-outs.
rulesForBriefis that list without the Keywords rule while it holds the current brief's own keywords. A rebuild writes the keywords anew from the sources, so planning to the old ones would hold it back. A Keywords rule the person set is sent.The side panel keeps the rules as checked and describes them only when Rebuild outline asks (
pageNow()→PageNow.rules), not on every keystroke.useBriefRebuildpasses them to therebuildDraftBriefaction as their own argument, beside the sources.The action puts them in the request body only when there are any.
RebuildSourcesstays as it is.Order: before PR 4, the API reads the request body with a plain
z.object, which dropsrules. So this PR changes nothing until PR 4's server is deployed with the flag on, and the two can merge in either order.Cost: about +200 input tokens per rebuild with the flag on, and nothing with it off.
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
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Web checks, run locally on this branch:
yarn format: no changes beyond this PR's files.yarn lint: 0 errors. The 6 warnings are in files this PR doesn't touch.yarn typecheck: clean.yarn test: 423 files, 3,959 passed.yarn build: OK, with CI's placeholder env.Tests:
rulesForAgentkeeps the rules that are on and the agent's, and describes a fan-out rule with its status.rulesForBriefleaves out the Keywords rule filled from the brief, and keeps one the person set.oneH1,feedMatchor the brief's own keywords.Pre-push review
A review agent read the change before the push. Fixed from it:
rulesForBriefleaves it out unless the person set it.t()calls per keystroke. Now they're described only when a rebuild asks.Left as is: after "Use lost prompts", a fan-out rule's "fan-outs to use" can be one read behind, because the rule statuses come from the editor's last render. The sources sent are current, and the next rebuild has them.
🤖 Generated with Claude Code