Repository navigation
feat(demo): fill the demo brand's Site Audit, AI traffic, catalog and fan-out intents (demo brand, part 3) - #1736
Merged
Conversation
… counts Migration 00380 adds brands.is_demo, demo_version, demo_built_at and demo_hidden_at, one demo brand per organization (partial unique index) and policies that let members read it but never insert, change or delete one. The plan's prompt-location quota, the usage cards' account totals and the web's brand limit leave the demo brand out; the health report's fan-out share leaves out its answers. The brand delete route refuses it: the demo brand is hidden, not deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The daily tracking list, the job claim and recovery (activeBrandFilter / isBrandActive), the signal catch-up, the pulse, the task writer, executor and checks, action validation and Improve outcomes, the Insights sweep, brand facts, Search Console and Analytics syncs, page opportunities, the traffic digest, auto-audits, catalog feeds, Webflow status and volume analysis all leave demo brands out: their data is sample data and nothing may track, write or spend for it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
lib/demo/ builds an organization's demo brand in its own brands: Brewline
Coffee (brewline.example) with fictional `.example` competitors and
publishers, 12 prompts in 3 topics, 6 engines and a run every 3 days over
a month (720 short answers) with citations, product cards, searches and
volumes. Answers are raw engine responses run through tracking's own
parseScraperResponse, parseResponse and the result and shopping card rows
(now pure resultRow and shoppingCardRows in cloro-result-handler.js), and
the rollups are rebuilt by the nightly run's own functions.
ensureDemoBrand creates it, rebuilds it in place (same ids) when
DEMO_VERSION moves on or its data is three days old, and leaves it alone
otherwise; concurrent visits share one build (one-per-org index, a
compare-and-set claim, a lease). Modules are { name, tables, build }, and
a coverage test fails on any brand_id table the demo neither builds nor
lists as skipped or pending.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
POST /api/demo creates or rebuilds the organization's demo brand for any
member and returns { brandId, version, rebuilt }; PATCH /api/demo
{ hidden } hides or shows it for admins and managers ({ brandId, hidden },
404 no_demo without one). Both stay open once a plan has ended.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s and reports Four demo modules over core's answers: signals and a month of actions (tasks, trail, measured outcomes, a task waiting for review, ready-made KPIs, Getting started with its page steps opened), prompt clusters, content opportunities, Editor drafts and Plan marks, prompt, topic and Improve suggestions, and two saved reports. Numbers are counted from the demo's own answers; shapes come from the engine's own functions. detect.js exports single and promptTarget so the demo writes signals in their shape. Co-Authored-By: Claude Opus 5.5 <[email protected]>
DEMO_MODULES runs core, suggestions, actionCenter, content and reports; DEMO_VERSION 2 rebuilds existing demo brands on their next visit. The coverage lists move the workflow tables to built, skip the engine's internal queues and logs and the org-level author default, and leave the draft shopping check to demo-site with the catalog. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ith auditContextOf buildAuditContext fetches the page, robots.txt and llms.txt, then hands them to auditContextOf, which parses the HTML once and extracts its text as before. A page that isn't fetched (the demo brand's) is read exactly as a fetched one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brewline's website (site-world.js) and its traffic: 90 days of Google Analytics as GA4 reports mapped by ga-sync.js (AI sessions by source and page, ChatGPT Shopping's feed visits, pages, channels, items), Search Console's query and page rows mapped by gsc-sync.js, four weeks of snippet visits (a removed guide's 404s for Broken AI links) and journeys made by traffic-events.js's eventRow, a month of AI crawler counts with a Cloudflare Worker connection whose secret hash matches no secret, and the page opportunities detectPageOpportunities finds in them. The brand maps the sample GA4 and Search Console properties and has conversions on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… own verdicts Brewline's pages are rendered as HTML round by round and scored by runSignals and scoreAudit: six key pages audited three times as fixes land, every page in the latest auto-audit. The model-judged signals, Wikidata's brand entity and the recommendations are written in the shapes those steps store. The page inventory goes through selectPages and parseHead, site trust through site-trust.js's checks (4/5: no editorial policy), and the brand facts through factText and keptFacts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Google XML feed of 22 products read by the feed parser and kept as catalogRecords and hashOf keep them, with stable demo ids: a removed seasonal blend, an out-of-stock size, a sale, no images. The products the demo's AI answers show as cards are the same page, title and price. Two categories get their page by hand; the rest match their collection pages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cache The demo writes the intent of each search its answers ran into fanout_query_intents, keyed as the route keys it (normalizeIntentQuery, moved to intent-extraction.js), adding only what the shared cache lacks, so Query Fan-out never needs a model for the demo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s with the demo brand (version 3) The demo-site modules join the core in DEMO_MODULES, and DEMO_VERSION is 3, so every demo brand is rebuilt with them on its next visit. Their tables leave the coverage test's pending list; a CMS connection, sent drafts, product images and Merchant Center item issues are skipped, with why. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… rows stay the same One rebuild for another brand two days later checks both that only the ids and dates change, with room past the default 5 s on a busy machine. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # server/src/lib/demo/coverage.js # server/src/lib/demo/index.js
The first module lays down what the others point at; the rest write their own tables together, each after the module it names in `after`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # server/src/lib/demo/index.js
# Conflicts: # server/src/lib/demo/index.js
A first build no longer clears 70 empty tables, and the core writes each step's independent tables side by side through a shared queue of four statements (write.js: insertChunks, demoWriter). Its rollups move to a refresh step that runs alongside the other modules, Insights, Citations and Mentions together, the month's answer terms in one call (refreshMentionsDaily takes an optional termDays). The core alone went from about 17 s to 7 s on the dev database. A rebuild (new DEMO_VERSION, or data older than three days) no longer deletes the demo first: an `inPlace` module writes over its rows by key (ids are deterministic) and deletes only the rows it didn't write again, then rebuilds the rollups over the old and new days, each refresh call rewriting its days in one statement. Someone opening the demo meanwhile sees last week's data, not empty pages. Modules not marked `inPlace` still have their tables cleared, now just before they are built. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A brand just created isn't empty: its insert trigger starts Getting started, so skipping every clear on a first build made the Action Center's insert hit getting_started_pkey. An in-place module now always writes over by key (the first build only skips reading back and pruning); a module that isn't rebuilt in place clears its own tables just before it is built, on a first build too, alongside the other modules rather than all up front. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irst build Nobody looks at a demo being built for the first time, so every module not rebuilt in place starts clearing what the new brand's triggers made at once, while the core writes, instead of each in turn later, when its deletes queue behind the rollups. A rebuild still clears each module just before it is built, so its old rows stay on show as long as they can. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # server/src/lib/demo/index.js
# Conflicts: # server/src/lib/demo/index.js
A table with an identity id and no other unique columns (ai_bot_events)
can't be written over by key. write(table, rows, { generated: true })
inserts the new rows and, on a rebuild, deletes the brand's rows that were
there before right after: never empty, both there for a moment.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts in place The four workflow modules write through the build's writer (ctx.write): each step's independent tables side by side, and on a rebuild over their old rows by key, deleting only what isn't written again, so their pages never empty while the demo is rebuilt. Keys where a row has no id: getting_started (brand_id, also what a new brand's trigger made), getting_started_steps, action_signals, the cluster members, searches and scopes, and the plan marks; the action and cluster children are found through their parent (scopes). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The three site modules write through the build's writer (ctx.write): their independent tables side by side (traffic's thirteen at once, a visit before its pageviews), and on a rebuild over their old rows by key, deleting only what isn't written again, so their pages never empty while the demo is rebuilt. Google Analytics and Search Console rows are keyed by their day and what they count (their unique columns, as their syncs write them), the audits' signals by audit and signal (found through their audit), the single-row settings by brand. ai_bot_events has an identity id and no other key: its rows are replaced, the old ones deleted right after the new are in. site-common's insertRows goes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
refreshMentionsDaily takes `together`: the rollups (refresh_mentions_daily) and the answer terms (refresh_mention_terms) take their own locks and write their own tables, so the demo runs them side by side instead of one after the other, a second off the longest step of its build. The nightly run keeps them in turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…core # Conflicts: # server/src/lib/action-center/task-checks.js # server/src/lib/action-center/validate.js # server/src/routes/index.js # supabase/schema.sql
…ver main's new tables sweepPromptDemand chose brands by their organization's plan only, so an active workspace's demo brand would have had its sample prompts read and DataForSEO's paid tasks set for them. It now leaves demo brands out, as the other sweeps do. The demo coverage list names the two brand tables main added: prompt_table_views (skipped: the demo starts on the default columns) and prompt_demand (pending a demo follow-up). Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 of 9 tasks
6 tasks done
…core # Conflicts: # server/src/lib/action-center/execution/run.js # server/src/lib/action-center/execution/run.test.js # supabase/schema.sql
…n's new tables sweepCompetitorTimeline (learning C3, on main) chose brands by their organization's plan only, so a demo brand's sample answers would have had their cited pages read every night. It now leaves demo brands out, as the other sweeps do. The demo coverage list names the brand tables main added: cited_page_features, competitor_page_events and competitor_timeline_scans (pending a demo follow-up) and chat_conversations (with Chat). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chat's precedence (ansvisor#1776) left readBrandIsDemo false until the demo chain added brands.is_demo, with a type check that stops compiling once the column exists. It now reads the column, as the server's demo guard does, so a tool that changes or spends on the demo brand is refused with demo_brand; a brand that isn't found isn't one, and a failed read throws. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
|
Merged main forward through #1735's updated branch (no conflicts of its own). Typecheck and the demo tests pass; server lint clean. |
…oduct cap The catalog sync's room (productRoom) counted the live products of every brand in the workspace, so the demo brand's sample catalog took room from the workspace's own sources on a capped plan. It now counts the workspace's real brands only. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good with 086640b1: the demo's sample catalog no longer counts against the plan's product cap. A merge of main with three follow-on changes is on top of it, at d06e94bf.
Reviewed 21f3a02 (part 3), as its own diff on top of #1735's head ebe6378. No migration.
What I changed
- 086640b1 (on 21f3a02):
productRoom(lib/catalog/sources.js) counted the live products of every brand in the workspace againstmaxCatalogProducts. That included the demo brand's 22 live sample products, so on Starter and Growth they took room from the workspace's own feeds. It now counts the workspace's real brands only (.eq('is_demo', false)). The cap tests now include a demo brand with a live product: 4 of them fail without the change. - The merge with main (3b7611c), on top of that:
- Conflicts resolved:
execution/run.js(main'sretry_afterread beside the demo filter), its test, andschema.sql(rebuilt withbuild-schema.sh). - 8e38ca0d. Main's competitor timeline pass (learning C3, #1746) goes over every active brand with competitors. An active workspace's demo brand would have had its sample competitors' pages read each night (spending the night's brand slots on
.examplehosts) and events written to it. It now leaves demo brands out, with a test that fails without the change. - 8e38ca0d, coverage. The demo coverage test failed on main's four newer brand-scoped tables.
cited_page_features,competitor_page_eventsandcompetitor_timeline_scansare now skipped, since nothing is read for a demo brand;chat_conversationsis pending with the demo Chat. - d06e94bf. Main's Chat precedence (#1776) has a compile-time reminder that fails
tsconcebrands.is_demoexists.readBrandIsDemonow reads the column, so Chat refuses a change or a cost on the demo brand. A read that fails throws. Tested both ways.
- Conflicts resolved:
What I checked
- No outside request. The pages are built HTML, parsed by
auditContextOfand scored by the real signals, none of which fetches anything. The feed is parsed from text. GA and Search Console rows go through the sync's mappers without a sync. The bot connection'ssecret_hashcan't match any secret, so no sender can write to it. - Quotas. Site Audit usage counts
site_audit_usageand running audits; the demo writes neither (its audits arecompleted). The bot event caps countai_bot_usage; the demo writesai_bot_events/ai_bot_dailydirectly, so its 30 days of hits don't count against the month. The catalog cap is fixed above. - Shared rows.
fanout_query_intentsgets 25 coffee searches, insert-if-missing (ignoreDuplicates), so a live classification is never overwritten.citation_urlsgets the.exampleaddresses (append-only). No other row outside the demo brand is written. audit/context.jsandnormalizeIntentQuery: behaviour unchanged, covered by the moved tests.- Tests:
- On 21f3a02: demo, catalog, middleware and routes, 375 tests, pass.
- On the merged branch, the full server suite: everything passes except the Framer and content-draft suites (no
framer-apipackage in my local install) and one timing test that passes alone. - On the merged branch, web:
tscclean;src/lib/chat, the embed guard,subscription-guard-coverageandbrand.test.ts(241 tests) pass.
Follow-ups
- The nightly card match (
sweepShoppingCardMatches) goes over every brand whose catalog synced in the last day. The demo's source says it synced at build time, so it is matched again the night after a build. That costs nothing and should change nothing, but it is a nightly write to the demo. Abrands!inner(is_demo)filter there (one foreign key) would keep it off. - Pre-seeding
fanout_query_intentsmakes the demo's hand-written labels the answer for any real brand whose fan-out runs the same 25 searches. They read right today; just keep them sensible if they change.
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
Demo brand, part 3 of 7 (server). The demo brand's Site Audit, AI Referral Traffic, product catalog and fan-out intents. The demo moves to
DEMO_VERSION = 3, so every demo brand is rebuilt on its next visit.lib/demo/site.js,site-html.js,site-world.js): audits, the page inventory, site trust and brand facts.auditContextOfand scored byrunSignalsandscoreAudit, as a fetched page is.audit/context.js: refactor only. A page already fetched can be read into the audit context withauditContextOf; behaviour unchanged.traffic.js), over 90 days: snippet visits and journeys, AI crawler hits, and what Google Analytics and Search Console report.ga-sync.js, Search Console rows throughgsc-sync.js, events througheventRow, sources throughai-sources.js.page-opportunities.js's own findings over them.catalog.js) for Product Visibility, the Content Editor's shopping path and category pages.catalogRecords.fanout-intents.js): the intent of the demo's fan-out searches is written ahead into the shared cache (fanout_query_intents), so Query Fan-out never waits on a model for the demo.ignoreDuplicates), so a live brand's classification is never overwritten.normalizeIntentQuerymoved fromroutes/prompts.jstolib/intent-extraction.jsto be shared; same function.PENDINGto built.brand_cms_connections,content_draft_deliveries,catalog_imagesandcatalog_item_issuesare skipped, each with its reason.content_shopping_checksstays pending, for a demo follow-up.Migration / deploy notes: no migration. Demo brands built at version 2 are rebuilt at the next visit.
Related issue
None (demo brand).
Stacked on #1735 (demo brand, part 2: workflows).
Type of change
feat— New featurerefactor—auditContextOf,normalizeIntentQuery(shared, unchanged)How to test
Checklist
eslint srcpasses. Tests:src/lib/demo,src/lib/catalogandsrc/lib/cms(36 files, 447 tests) pass.yarn typecheckpasses; billing andsubscription-guardtests pass.🤖 Generated with Claude Code