Repository navigation
fix(content): read no product sentence as a claim, know the brand's own name, keep the possessive out of the placeholder, and read more Turkish and German forms (review follow-ups of #1537) - #1544
Conversation
…adings' answers and what the last rewrite came to, and offer a Length it can reach Co-Authored-By: Claude Opus 5.5 <[email protected]>
… for, keep its numbers on the row (00285), and read the floor's sections closer (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and count the last rewrite only within its Length's band and the same kept text (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one more pass Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er to rewrite the cited passages too when they hold the Length out of reach Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e back, release an unused hold, keep a cited-too miss as evidence, and offer it only when cited passages hold the Length (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he agent and Next step move on, and count open rules as the Rules tab does Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es read the page, keep the Length's own words, and wait for the passages before dropping skips (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ion, not the next step, and say how many placeholders it leaves to fill Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aphs, and read a rewrite's once, not on every key (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y why a run left nothing, and show a failed last run on the card Co-Authored-By: Claude Opus 5.5 <[email protected]>
… id and kind, not by clocks, and clear a failed last run once another starts (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e rules before they're accepted, and say which rule met now one would break Co-Authored-By: Claude Opus 5.5 <[email protected]>
…age as it is now, and count a rewrite's Length as its own line reads it (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wasn't given or drops a name a passage has Co-Authored-By: Claude Opus 5.5 <[email protected]>
…give claims only to sources the page or its input names, and put a rewrite's as a placeholder (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…editor shows them, and hold the rules chip until its count stands Co-Authored-By: Claude Opus 5.5 <[email protected]>
…aracters as the toolbar counts them, and the run's rule count Co-Authored-By: Claude Opus 5.5 <[email protected]>
…for the brief and catalog before the rules' count, hold the panel's counts with it, and read the shown rewrite's Length by the editor's count (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s open suggestions for the page before, and drop a batch's card once the page no longer has it Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e left open never holds the next run out of sight Co-Authored-By: Claude Opus 5.5 <[email protected]>
…estions when they can't be set aside, and hold History while the agent works or a decision saves (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a sweep on the step under way, a line on what it does, and the page drawn in Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, true without an outline, and silent on rules or sources read none of; even step spacing; steadier tests (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hich runs as a Fix, with its steps and Stop Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a Start's write doesn't stand in for it; the rewrite prop says what it reads (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t once it's decided too, not only while it's shown Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ents say when it's read and who counts it (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ace between them, cap a source's name at eight words, read "en" after "göre" as the source's claim, never skip a name's last word, and read "per" and "states" as the page's language and grammar have them (review of ansvisor#1520) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…age's language from its rules or My rules as the CMS send does, keep a name's last word only for an -ly word or a capitalised role, and read "states"/"claims" as nouns after a count but a year before a source (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m X" only after "according to", "in" or "per"; a tool's report "shows" only before "that" or a figure), know the brand's own name, keep the possessive out of the placeholder, and read more Turkish and German forms (review follow-ups of ansvisor#1537) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nce or for a name-shaped one, skip German nouns before "zufolge", keep acronyms and the people guard as they were, cut only a lowercase possessive, and hold the comma form to a sentence's "In" (pre-push review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…als reads in linear time (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rules by the brand's kind of site (Fix, Start and the CMS send), and read "states"/"claims" after a count at a sentence's start as nouns but small words before a source as a claim (review follow-ups of ansvisor#1537) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Merged #1537's dotted-name fix in, and added #1537's round-2 low follow-ups here (8c6253d):
Checks: server format and lint clean; 224 test files, 2,815 passed, 3 skipped. |
gkhngyk
left a comment
There was a problem hiding this comment.
Needs changes: one fix before merge, for two new patterns' speed on a long run of spaces. Each earlier item is done; the rest are small follow-ups.
What I checked:
- Stack and merge.
- 9616cc7 only brings #1537's 38dc169 in: re-merging its parents gives the same tree.
- #1537 is squashed on main now (64f6d9c), and main's copies of the eight files are #1537's head. Through a temp base (main's tree, with #1537's head and main as parents) this PR merges clean, and the result is exactly its own change (
origin/pr/1537..origin/pr/1544). - Server only, no migration. Nothing changes on Vercel at merge.
- #1537's round-31 follow-ups:
- Product sentences. Done.
- The comma form is read only after "according to", "per" or a sentence's "In". "Send a survey from Typeform, Jotform or Google Forms" and "Download the 2025 report from Gartner, then…" aren't read.
- "report from X shows" needs "that" or a figure: "The Performance report from Google Search Console shows clicks and impressions" isn't read.
- The brand's own name is known in Fix, Start and the hand-off (
[brand.name]): "A weekly report from Acme shows that…" and "Acme's data shows that…" stay on Acme's page. - A name made only of a sentence's words isn't counted ("Who says B2B content…"), and an acronym still is ("According to AMA").
- One gap this opens is item 2; what's still read is item 3.
- The possessive. Done. "According to [source]'s latest survey", "[source]'s research shows", with curly apostrophes too; "O'Day" stays whole. One side effect is in item 4.
- Turkish and German. Done.
- Each case I listed is now read: a year or a word before the noun, the form without the ending, "zufolge" and "nach Angaben von".
- "Google Analytics'e göre" becomes "[source]'e göre", and the sentence words are read past only by the attributions.
- "laut Hersteller", "Herstellerangaben" and "Datenblatt" aren't read. What's still read is in item 3.
- Product sentences. Done.
- #1537's round-32 follow-ups:
2. A<br>inside a bold or a link. Done.inlineTextreturns a break thatwalkends the line on, and a block inside an inline tag ends it too. The three cases read as separate lines, in the guards and in the page read.
3. My rules by the brand's kind of site. Done.draftLanguage(draft, brand)filters bybrandSiteType(brand), which issiteTypeOfonsite_type,industryandshopping_mode_enabled, as the editor'sgetMyRuleSetsdoes. Fix and Start (and the hand-off, through Fix) select those columns.- 00227's key is
(organization_id, site_type, page_type), so.maybeSingle()sees one row at most. - The CMS send's
myRuleSetsfilters the same way. With no set for the brand's kind, both fall back to the brand's language, as before.
- "states" and "claims". Done. "Most US states that…" isn't read, and "In some cases Gartner states that…" is. One side effect is in item 4.
- Speed. I timed every reader on 100 KB inputs: runs of capitals, acronyms, initials, dotted words, spaces, non-breaking spaces and newlines, punctuation, possessives, the new Turkish and German words, "In … report from" runs, and nested inline tags with
<br>. Two patterns grow with the square of a run of spaces (item 1). Everything else is linear.
Before merge:
- Bound the work on a long run of spaces (
server/src/lib/content-agent.js:424,:446).- Both patterns start with a lookbehind that ends in
\s+. V8 checks it at every position, and inside a run of spaces each check walks back over the whole run. - The time grows with the square of the run, so a long run of spaces, non-breaking spaces or newlines in a paragraph is slow to read. #1537's readers read the same text in milliseconds.
- This reaches the page read at Fix, Start and the hand-off (
attributableSources), a rewrite's placeholders and the check on each change. - Fix: look for the word first, so the lookbehind runs only where it can match:
// :424 String.raw`(?=(?:[Rr]eport|[Ss]tudy|[Ss]urvey|[Pp]aper|[Pp]oll)\s)(?<=(?:\b[Aa]ccording\s+to|… // :446 new RegExp(String.raw`(?=\p{Lu})(?<=[^\s.!?:]\s+)${TR_NAME}\s+${TR_REPORT}`, 'gu'),
- With both, the test file's sentences and 60 more of mine read the same, and the runs of spaces read in milliseconds.
- Add a speed test with a long run of spaces through
attributableSources, beside the ones for capitals and initials.
- Both patterns start with a lookbehind that ends in
Low, follow-up:
2. A claim with an aside after "a report by X" is no longer read (:414).
- "A 2025 report by Gartner, published in May, found that 40%…" and "A recent study from Stanford, which surveyed 500 teams, shows that…" were read through the comma before. Now neither form takes them.
- Fix: allow one short aside before the verb, bounded so it stays linear:
(?=(?:\s*,[^,.!?;]{1,80},)?\s+(?:…verbs…)). Both sentences are then read, and the product sentences still aren't. It can go in with item 1.
- Product and tool sentences still read:
- English.
- "In the report from Google Search Console, you can see…" and "In a report from Google Analytics, filter by channel" (
:424): the small words take "the" and "a". Skipping the comma form when the reader is spoken to after it ("you", "your") covers these and your Typeform case. - "The Search Console report shows clicks and impressions" and "GA4's Acquisition report shows where…" (
:386, from #1520). Hold "shows" / "showed" there to "that" or a figure, as:414now does.
- "In the report from Google Search Console, you can see…" and "In a report from Google Analytics, filter by channel" (
- Turkish.
- An acronym for a kind of report at a sentence's start is read as a source: "SEO raporuna göre", "PDF raporuna göre" (
TR_SHAPED,:447). A short list to skip (SEO, PDF, KPI, CRM, ERP) would do. - A list's number makes a first noun read mid-sentence: "1) Ürün açıklamasına göre" (
:446). Leave)out of the lookbehind's class.
- An acronym for a kind of report at a sentence's start is read as a source: "SEO raporuna göre", "PDF raporuna göre" (
- German.
- "Laut Angaben des Herstellers", the commonest maker's form, still reads "Angaben" (
:393). So do compounds of the skipped nouns and other product-page nouns: "Laut Produktdatenblatt", "Laut Packungsbeilage", "Laut Kundenbewertungen". Skip "Angaben", and match the skipped nouns inside a compound. - "Einer neuen Studie zufolge" and "Einer repräsentativen Umfrage zufolge" are newly read as "Studie" and "Umfrage" (
:403). A rewrite then writes "Einer neuen [source] zufolge". Skip a noun after an adjective ending (-en, -em, -er, -es), as after an article.
- "Laut Angaben des Herstellers", the commonest maker's form, still reads "Angaben" (
- English.
- Two small side effects.
- A name that is itself possessive: "According to McDonald's, sales rose" becomes "According to [source]'s, sales rose" (
:592). Keep the ending out only when a word follows it. - "In most of the US states that allow it…" now reads "US", which #1537 didn't (
:382). Allow "of the" after the count words.
- A name that is itself possessive: "According to McDonald's, sales rose" becomes "According to [source]'s, sales rose" (
- Tests and the send's brand read.
- The CMS send's test brand is B2B, which the default also gives. A brand with Shopping mode on, expecting the e-commerce set's language, would show the filter works.
myRuleSetsreads the brand a second time (content-delivery.js:447-451).brandForcould select the three columns instead. Today a failed read there picks the B2B set, not none.
…lowups # Conflicts: # server/src/lib/content-agent.js # server/src/lib/content-agent.test.js # server/src/lib/content-delivery.js # server/src/lib/content-language.js # server/src/lib/content-language.test.js # server/src/lib/content-people.js # server/src/lib/content-writer.js # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx # web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
|
Merged main forward (d1acdb2), as #1537 is squash-merged now.
🤖 Generated with Claude Code |
…ith a short aside after "a report by X" (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… knows no performance global Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks. Item 1 and item 2 are done (f2ccadb, 70ae579). 1. Long runs of spaces. Both of your fixes are in:
Timing every pattern in
With all four, the readers take about 40 ms on 40k spaces, NBSP or newlines. The same search over
The tests (
I reverted each fix on its own, and the tests fail for six of the seven. The "In … report from X," noun lookahead is the exception: its old form read a long run in 20–40 ms, so it guards in theory only. Behaviour is unchanged: on about 4k strings from the content tests, the old and new patterns match the same, apart from item 2's two new sentences. 2. An aside before the verb. Done as you wrote it:
Still not read: "The Performance report from Google Search Console shows clicks", and an aside past its bound. 3–5 go in the next follow-up PR, as you marked them:
Server checks: format and lint clean; 225 test files, 2,892 passed, 3 skipped. 🤖 Generated with Claude Code |
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good, with follow-ups. Both round-33 items are done, and the patterns you changed read the same text as before, in linear time. Three kinds of long input still slow down older code in content-people.js and the number guard. That code has been on main since #1421 and CE-033, and this PR doesn't make it slower, so the fixes can go in the follow-up PR.
What I checked:
-
The new commits.
-
Merge. It merges clean on main (307670b). The merged tree differs from main by exactly this PR's own change: 9 server files, no migration.
-
What users see. Nothing changes on Vercel at merge. The server changes go out with the next API deploy.
-
Behaviour. I read about 5,300 strings with the round-33 head and with this one, through the attribution readers and the people guards (text and HTML):
- every string and line in the 20
content-*test files; - round 33's sentences;
- about 90 of mine on the quote cues, "Sarah, our head of growth", "states/claims", "zufolge", the Turkish form and the aside, with extra spaces, line breaks and marks.
Only the aside's sentences read differently (item 2). The quote cues' new spacing and the lookaheads that look for a capital or a noun first match the same text as before.
- every string and line in the 20
-
Speed. I timed each public reader on 100 KB inputs, as Latin-1 text and with a character past Latin-1:
- the readers:
attributedNames,addsAttribution,placeholderAttributions(InHtml),attributableSources,dropsName; keepSuggestions, with an insert, a replace and a longafter;guardPeopleandguardPeopleInHtml.
The inputs:
- runs of spaces, non-breaking spaces, newlines, tabs and mixed whitespace, alone and before each pattern's trigger words;
- capitals, initials, dotted words, possessives, apostrophes, commas, list separators and brackets;
- quote marks followed by spaces;
- people cues;
- the Turkish and German words;
- the aside, repeated.
I also timed each of the 80 regexes in the two files alone, and the slowest cases on Node 20 too, which the server runs. Node 20 and Node 22 time them alike.
- The eight patterns you changed, the aside among them, read every input in linear time.
- Item 6 is what still grows faster than the text. Item 7 is linear but adds up.
- the readers:
Round 33:
- A long run of spaces. Done.
- The "In … report from X," pattern looks for the noun first. The Turkish pattern, "states/claims" and "zufolge" look for a capital first.
- In
content-people.js, the "Sarah, our head of growth" cue looks for a capital first, and the two quote cues read the spaces one way only. - The new speed tests use a character past Latin-1, so the timed input can't hide a slow path.
- An aside before the verb. Done.
- Both sentences are read. "The Performance report from Google Search Console shows clicks" still isn't, and nor is an aside past 80 characters.
- One side effect: the aside can be the rest of a list, so "A survey from Typeform, Jotform or Google Forms, found that…" now reads Typeform. That's rare, and the sentence is a claim anyway.
- Product and tool sentences. Not done: next PR, as agreed.
- The two side effects. Not done: next PR.
- The tests and the send's brand read. Not done: next PR.
Follow-ups:
- Bound the work on three more kinds of long input. These run on the model's text: a Fix's or a Start's changes (
keepSuggestions), a page rewrite and the brief.- Letters joined by apostrophes ("Ab’Ab’Ab’…", "A’A’A’…", "a’Aa’A…", "''A''A…";
content-people.js:62,:65).NAMEmay start right after an apostrophe, since it only checks for a letter before it.WORD's lookahead[\p{L}'’]*\p{Ll}then scans to the end of the run from each capital in it.- The time grows with the square of the run, in the four cues that start with
NAME(:317,:323,:353,:383). - Fix:
- Don't start a name inside a word:
(?<!\p{L}|\p{L}['’]). - Let the lookahead read only what the word can hold:
(?=(?:\p{L}|['’](?=\p{Lu}))*?\p{Ll}).
- Don't start a name inside a word:
- With both, each apostrophe run I tried reads in linear time. The 5,300 strings read the same, and a name after an opening quote mark ("'Jane Doe said…") is still read.
- An opening bracket with no closing one ("[a [a [a …";
content-people.js:483, andcontent-sources.js:145in the number guard)./\[[^\]]*\]/gscans to the end of the text from each[.- Fix:
/\[[^[\]]*\]/g. It reads a placeholder the same way; only nested brackets read differently.
- A line with thousands of names, sources or numbers to replace.
- Each new edit is checked against every edit kept so far:
content-people.js:504,content-agent.js:600. editLinesrebuilds a node's whole text once per edit (content-people.js:652-660), andplaceholderNumbersrebuilds and re-slices the text per number (content-sources.js:335-345).- So the time grows with the number of edits times the line's length.
- Fix:
- Keep the edits in order of start, and check only the neighbours with a binary search.
- Rebuild each text node, or the text, once from its pieces between the edits.
- I tried this for the two guards: the placeholders come out the same on the 5,300 strings, and the time is linear.
- Each new edit is checked against every edit kept so far:
- Add each to the speed tests, with a character past Latin-1.
- Letters joined by apostrophes ("Ab’Ab’Ab’…", "A’A’A’…", "a’Aa’A…", "''A''A…";
- Low: the attribution readers on a long line of capitalised words.
- It's linear, but each pattern that starts with a name tries one at every capital. This PR adds several of those ("zufolge", the Turkish forms), so such a line takes about half again as long as on main.
- Fix: run a pattern only when its trigger word is in the line ("zufolge", "laut", "states", "claims", "says", the Turkish forms' word after a source…). A line without one then skips it.
|
Thanks for the merge. The follow-ups (round 33's items 3–5 and items 6–7 from your approval) are in #1563. |
… as a source, read the brand once for a send, and read long input in linear time (#1544 review follow-ups) (#1563) Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
#1537's low follow-ups from your 10:56 review.
1. No product sentence read as a claim
data fromdoes. "The Performance report from Google Search Console shows clicks and impressions" isn't read. "finds", "reveals" and the others still are.attributableSources(…, own), and Fix and the writer pass[brand.name]. So "A weekly report from Acme shows that…" and "Acme's data shows that…" stay on Acme's page. The possessive pattern itself is unchanged.attributionsIndrops a name that is only those words. "Who says B2B content has to be boring?" isn't counted as a claim, as the placeholder already didn't take it. An acronym is still a name ("According to AMA, …"), even when its letters spell a sentence's word.2. The possessive stays out of the placeholder
attributionEditsends the edit before a lowercase apostrophe ending, asknownNamecuts it, so a name's own apostrophe stays inside it ("O'Day"):3. Turkish and German
Now read:
Now read whole:
TR_SENTENCE_WORDS), so "Ancak Google Analytics'e göre" keeps "Ancak". The people guard'sNOT_NAMESis unchanged ("Son Heung-min said…" still gets its placeholder).Not read:
Related issue
Follow-ups of #1537's review (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
Also run the
fixDraftRulestest "gives a claim to the brand's own data".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; 224 test files, 2,811 passed, 3 skipped.
Pre-push review
A review agent read the change before the push. It found nothing high, checked that each new test fails without its change, and timed the regexes (about 260 ms worst on 200,000 characters).
Fixed from it:
Each of those now has a negative test. A shaped-name regex in the first version was slow on a 20,000-character word (640 ms); it's rewritten to one pass (53 ms).
Left as is:
isKnown).🤖 Generated with Claude Code