Repository navigation
fix(content): the third review's open items — bounded reads (00226), My rules per site type (00227) - #1316
Conversation
… 00226 The third review timed four content reads on production. 00204–00221 are applied there, so 00226 redefines them: - content_page_overlap (ansvisor#1287): the window's answers come from idx_prompt_results_brand_created_cover alone; the prompts are picked where the citations meet them. - content_draft_sources (ansvisor#1292): the window from the cover index, each prompt's answers counted there, "named in" from mentions_prompt_daily plus the first partial day, fan-outs from each prompt's latest 30 answers, citations from their cover index hash-joined to the answers. - content_plan_pages (ansvisor#1308, 00221's copy): the overlap pairs take their window from the current answers alone, no prc.created_at bounds. - content_plan_insights (ansvisor#1309): own ids from the domain index, rows picked on url ids before citation_urls is read, own list capped at 5,000, force_custom_plan. Each matches its 00207–00221 version on a rolled-back dev DB fixture; the Sources fan-outs differ only where a prompt has more than 30 answers in the window. Co-Authored-By: Claude Opus 5.5 <[email protected]>
content_rule_sets was keyed by organization and page type, so a "guide" set saved for a B2B brand also applied to the same organization's shops and travel sites. 00227 adds site_type to the key; getMyRuleSets and saveMyRuleSet use the brand's kind of site (chosen, or guessed). A set saved before is copied to each kind, so it keeps applying where it did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Plan (ansvisor#1308): the reason reads "Citation rate −{pct}%"; Start lists the page the plan named first when the overlap check recommends another, so a person can come back to it (pages matched by address). - Collection sign (ansvisor#1310): whole words of the slug, so /collections/kitchen or /collections/limited-edition are categories; the best-of sign leaves best-sellers to it. - ansvisor#1310's low items: a title naming FAQ with a policy word reads as Policy, as its address does; "what is the best/difference/cost/benefits …" and "what is new" aren't definitions, in titles and paths; the numbered-steps rule checks only a how-to H1 ("Not a how-to" otherwise); "Defined first" needs the verb within the first eight words, after a subject that isn't a pronoun; the writer, brief and agent prompts name the page type and its format (content-page-types.js) instead of its key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
left a comment
There was a problem hiding this comment.
Most of this checks out. Two fixes are left, plus items 1–2 from #1314 that you said come next here.
Timed on production, on the same brands, drafts and windows as the earlier rounds. #1315's autovacuum ran on prompt_results and prompt_result_citations at 15:58–15:59 UTC today, so the cover-index scans now make no heap fetches.
| Read | Before | Now (00226) |
|---|---|---|
content_page_overlap, biggest brand, 500 prompts, 30 d |
9.1–10.6 s cold, 0.3 s warm | 0.49 s first run, 0.2 s warm |
content_draft_sources, 92-prompt draft, 30 d |
8.3–21.7 s cold, 0.76 s warm | 10.7 s first run, 0.44–0.75 s warm |
content_plan_pages, largest, 7 / 30 / 90 d |
15–19 s at 7 d | 0.18 / 0.48 / 0.94 s |
content_plan_insights, largest, 90 d |
4.2 s cold | 2.46 s cold, 0.95 s warm |
What checks out
- The overlap, plan-pages and insights rewrites return the same rows as before.
- "Named in" from
mentions_prompt_dailymatches the raw answers exactly on prod (6,918 of 80,721 for the biggest brand's last 29 days), and the first partial day isn't counted twice. - Generic plans:
- for
content_plan_pagesandcontent_plan_insights, they're no longer dangerous; - for
content_page_overlap, the generic plan never finishes, so itsforce_custom_planhas to stay.
- for
- 00227: the key change hits
content_rule_sets_pkey, the copy is a no-op on prod (no rows yet), the policies still match, and the upsert'sonConflictuses the new key. - The page-type fixes (whole-word collections, policy-before-FAQ, the "what is …" exclusions, "Not a how-to"), the "Citation rate" label, and Start keeping the plan's page (with the www / slash / case match) all behave as described. Tests cover them.
Fixes
- Sources is still over 8 s on a cold first call for the biggest brand (
supabase/migrations/00226_content_reads_bounded.sql:293-302).cited_idsneeds all 106k citations of the draft's 13.6k answers in the window. The planner probesprompt_result_citations_pkeyonce per answer, not the cover-index hash join the comment describes.- Forced onto the hash path, it reads all 672k of the brand's window entries instead: 6.3 s cold.
- Count cited pages over the same latest-30 sample as the fan-outs (
… where a.recency <= 30). That's 2,760 answers instead of 13,618, about a fifth of the reads.
- The plan's page can't be changed when the check finds no overlap (
web/src/lib/content/overlap.ts:67-77,web/src/components/content/new-content-dialog.tsx:409,:1025).- Start pre-selects "Optimize /page" for the page the plan named. When the verdict is
none, the box only says "No existing page answers these prompts · Safe to create" and shows no options. - So the person can't see that the draft will optimize that page, or switch to a new one.
- When
givenis set and there are no options, return[optimizeGiven, create]and render the radio group in thenonebranch. Add anonecase tooverlap.test.ts.
- Start pre-selects "Optimize /page" for the page the plan named. When the verdict is
Low, any time
definesAtOncecompares words with their punctuation attached (web/src/lib/content/rules.ts:573-581), so "Cold brew is, simply, …" reads as Missing.- The defined-first check is English-only. Return
infowhen the brand's language isn't English. citation_url_dailyholds about 12% dead tuples. If the 90-day cold read matters later, give it 00224's autovacuum settings.
Tested on top of main: web 2,453 tests, server 2,005, tsc, lint and Prettier pass, and schema.sql rebuilds unchanged. 00226 and 00227 aren't applied on production yet. I'll apply them when this merges. Note that #1317 takes 00228.
… sample cited_ids needed every citation of the draft's window answers (106k for a 92-prompt draft on the biggest brand), read one answer at a time, and the cold first call still took 10.7 s on prod. It now reads the citations of the same sample as the fan-outs, each prompt's latest 30 answers (2,760 answers instead of 13,618). With the cap lifted it matches the previous read on the dev DB fixture. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Start pre-selects the page the Content plan named, but when the overlap check found no page, the box only said "Safe to create" and offered no option: the person couldn't see the draft would optimize that page, or switch to a new one. With a page from the plan and nothing overlapping, Start now offers "Optimize /page" (chosen) and "Create a new page instead". Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a save's answer never came back, the editor sent the hash of its raw HTML as unconfirmedHash, but the server compares it with the stored page, which is sanitizeDraftHtml's output. sanitize-html rewrites most real pages (<br> to <br />, to U+00A0, links without target/rel, tables without style/colgroup), so on those pages the lost save still ended in a conflict. The editor now hashes the sanitized page, loading the sanitizer only on that path, and the server also takes a stored page equal to the one being saved as its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…econd save When the page changed while a decision was saved, redo.tr was built on the new page, but dispatched only after the second save (the suggestions it no longer fits going back to review). If the page changed again during that call, dispatching threw "Applying a mismatched transaction": the person saw the save-failed toast, and the page and the cards stayed as they were. The redo is now dispatched right after it is built. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t follows The type update after a save or a restore wasn't tied to that version. A write landing between them would have its updated_at become the editor's base, and the next autosave would go over it. Both updates now match the version they follow (updated_at); otherwise the type catches up on the next save, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The verb check compared words with their punctuation attached, so
"Cold brew is, simply, …" read as Missing; words are compared bare now.
- The check reads English words ("is", "means", "refers to"), so for a
brand whose language isn't English it shows "English only" and isn't
counted. The rule context carries the brand's language.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@gkhngyk Fixed. One commit each, in your order:
From your #1314 review:
Low items (2811690): Checked on top of main: web 2,458 tests, tsc, lint and Prettier pass, and |
schema.sql is rebuilt with build-schema.sh after 00224, 00228 and ansvisor#1318. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
The fixes check out.
-
Sources now counts cited pages over the latest-30 sample. Timed on production for the biggest brand, the 92-prompt draft and 30 days:
- first call: 7.2 s (it was 10.7 s);
- warm: 0.28 s;
- generic plan: 0.68 s.
Prompts, answers, "named in", fan-outs and queries are unchanged.
-
Start with nothing overlapping: it offers the plan's page and "Create a new page instead".
-
#1314's two items are fixed: the lost-save hash is now taken over the sanitized page, and redo is dispatched before the second save. The
updated_at-matched type writes and the low items are in too.
I merged main in, rebuilding schema.sql after 00224, 00228 and #1318. Tested on top of main with #1318: web 2,482 tests, server 2,006, tsc, lint and Prettier pass. 00226 and 00227 are applied on production.
Summary
The items @gkhngyk's third review left open on the Content stack, as listed on #1256 after the merge run. 00204–00221 are applied on production, so the reads he timed are redefined in a new migration (00226). My rules' site type is 00227, after #1315's 00224 and #1313's 00225. Items 1–4 of his #1314 review are in this PR too.
Reads (00226):
content_page_overlapreads the window's answers fromidx_prompt_results_brand_created_coveralone. The prompts are picked where the citations meet them (and a.prompt_id = any(p_prompt_ids)incited), so the planner no longer combines the prompt_id index with the brand's.content_draft_sources:mentions_prompt_daily(00157) for the window's whole UTC days, plus the first partial day's answer rows;content_plan_pages(00221's 90-day copy) drops theprc.created_atbounds inpage_promptsand takes the window fromcur_answers.content_plan_insights:citation_urls' domain index first;citation_urlsonly for those;force_custom_plan.Each read was compared with its 00207–00221 version on the dev DB, with a rolled-back fixture, at 7/30/90 days. The output is the same, except the Sources fan-outs, which differ only where a prompt has more than 30 answers in the window. The index-only scans lean on #1315's daily vacuum and analyze.
App:
pageKey)./collections/kitchen,closets,sunset-lamps,limited-editionandtoothpicksare category pages.best-sellersreaches the collection sign: the best-of sign leaves it out, as it does best-practices./pages/shipping-faqdoes./what-is-…paths.server/src/lib/content-page-types.js. A test keeps it in step withPAGE_TYPESand en.json.content_rule_setsgetssite_typein its key.getMyRuleSetsandsaveMyRuleSetuse the brand's kind of site, chosen or guessed. A set saved before is copied to each kind.From the #1314 review:
unconfirmedHashis the hash ofsanitizeDraftHtml(bodyHtml), the page as the server stores it. The sanitizer is imported lazily on that path. The server also takes a stored page equal to the one being saved as its own.redo.tris dispatched right after it is built, before the second save.updated_atof the version they follow.ruleSet's doc comment is back aboveruleSet.Related issue
Follow-up to the reviews on #1287, #1292, #1308, #1309, #1310 and #1314, as listed on #1256.
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/)Also run:
web:yarn test(2,458 tests) andyarn build.server:npm run format,npm run lintandnpm test(2,005 tests).bash supabase/build-schema.sh. 00226 and 00227 are applied on the dev DB. 00227 had a rolled-back dry run first, where a set saved before was copied to the three kinds of site.No new dependencies.
🤖 Generated with Claude Code