Repository navigation
feat(server): stop every automatic process for a workspace whose plan ended - #1608
Merged
gkhngyk merged 4 commits intoOct 27, 2026
Merged
Conversation
On the cloud, an organization whose trial ended or whose plan was cancelled can still read everything, but every write answers 402 `subscription_inactive` until it buys a plan. - requireActiveSubscription runs on /api after decodeToken. - Left open: reads, /billing, the requests that stop a cost or an access (COST_STOPPING), and the onboarding's three AI calls for an organization that never subscribed. - An active organization is remembered per person for 30 s. - Scheduled work skips these organizations: the GSC and GA syncs, page opportunities, the signal catch-up and the Action Center's task runs (filtered in the query). Their queued jobs are cancelled while still waiting. - site-trust and brand-facts give an ended plan its saved reads only, with no scrape. - The task writer and content-pages keep plan-guard's 402 instead of turning it into a 429. Self-hosted is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… ended A follow-up to the read-only API (ansvisor#1589). On the cloud, nothing runs or is taken in for an organization without an active subscription: - Jobs (tracking, content, retries, the internal trigger) are cancelled when claimed, with failed_reason subscription_inactive (cancelClaimedJob). So nothing they start runs: content opportunities, clusters, site pages. - The signal pass, and the actions it raises, skip these organizations at every entry, not only the catch-up. - The task writer's sweep filters in SQL, so they can't fill its list. - Volume analysis (the internal analyze-volumes) stops. - A Cloro result for one is dropped and its pending row removed: saving it would call the LLM for sentiment. - Ingest: - /bots/ingest answers 200 and reads nothing; - /track (visits, CE-017 events) answers 204 and writes nothing; - the content and content-draft webhooks answer 202 once their secret checks, and write nothing. The sender never sees an error to retry. - isBrandActive, plus a 5-minute cache for these outside events (isOrgActiveCached, isBrandActiveCached): one read per brand at once, failed reads not kept, 10,000 entries at most. A new plan reaches ingest within 5 minutes. Database upkeep (rollups, counters, validation, clean-ups) still runs; none of it raises an action. Self-hosted is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…her its plan ended (read-only automation review)
- "Not active" is remembered for at most 60 s ("active" stays 5 min). A
Cloro result is dropped only on a fresh read that says so.
- On a failed read, the Cloro callback and /track count the workspace as
active and keep the data. The pending Cloro row is removed only once
the result is saved.
- /bots/ingest re-reads on a PlanLimitError. It answers NOT_STORED only
for a workspace that isn't active; otherwise 500, so the sender
retries.
- /track checks the plan after the body, so a bad body gets the same 400
either way.
- A claimed job whose cancel fails is failed, not left active.
- The Cloro callback moved to routes/cloro-callback.js, to be tested as
a route. The plan check runs there, before any brand reads.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
approved these changes
Oct 27, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- Own change. 9980a36 and 2d28ea9, on #1589's head 9040212. #1589's squash on main (6e34ade) has the same content as 9040212 in every file this PR touches. Main's other server changes since then don't touch these 23 files, and the own diff applies cleanly on 15b5b5f. A plain merge of the branch conflicts (add/add in
active-subscriptions.jsand the others #1589 added), because #1589 was squashed: rebase onto main, dropping 9040212, before merging. - Who is never stopped.
- Everything reads
isSubscriptionActive(active,trialing), directly or throughACTIVE_SUBSCRIPTION_STATUSES, which a test keeps equal to it. - A cancel in the app sets
cancel_at_period_end, and Stripe keeps the subscriptionactiveuntil the period ends, so the workspace keeps running until then. Onlycustomer.subscription.deleted(period over) writescanceled. - Trials count as active.
- Self-hosted:
activeOrgFilter/activeBrandFilterreturn "everyone" without a read, and the cached versions returntruebefore touching the map. The task writer keeps its old query off the cloud.
- Everything reads
- Cost of the lookup.
- The job runner reads one brand by id per claimed job, after the claim, so at most one small read per job attempt. The recovery stays one batched read.
- The signal pass reads once per pass. The catch-up already filters in one batch, so each of its brands is read twice; a few small reads a night, not worth changing.
- The task writer filters in its query (
brands!inner(organizations!inner(...))), so ended organizations can't take its 20 places. /track,/bots/ingestand Cloro's callback go through the cache: one read per organization or brand every 5 minutes (60 s for "not active"), a burst waits on one read, failed reads aren't kept, and the map is capped at 10,000 entries. The content callbacks read uncached, but they're rate-limited and rare.
- When the lookup fails.
- Jobs: the read throws inside the job's
try, so the job retries like after any failure and its slot is given back infinally. Right: nothing is spent, and a paying brand's run comes back on the retry. - Signal pass: it throws, and the catch-up runs it again.
- Cloro's callback and
/trackstore as usual. Right: the answer is already paid for, and a beacon can't be sent again. /bots/ingestanswers 500, so the sender retries. Before this, a failed plan read became a 402, so this is safer for a paying sender.- The content callbacks answer 500 through their existing catch.
- Jobs: the read throws inside the job's
- Paying customers' data.
- Cloro drops an answer only when a fresh read says not active, whatever the cache holds. A just-bought plan never loses an answer.
/trackand/bots/ingestcan still drop up to 60 s of data after a purchase, while a "not active" answer is cached. That's the trade the description names, and fine.- In
/bots/ingest, aPlanLimitErrorcan come only from an ended plan or a failed organization read (resolveOrgPlanByOrgId), so a 500 for an active organization is the right answer. /trackchecks the plan after the body is checked, so the answer doesn't tell an outside caller whether a site's plan ended. The content callbacks check it after the secret.
- Jobs. Every job type that starts work has
brandIdindata(allcreateJobcalls). A job that can't be cancelled is failed, never leftactive. - Cloro route move.
app.use('/cloro/callback', router)sits where the oldapp.postwas: after the raw body parser and the request-id middleware, so the signature still sees the raw bytes andreq.logexists. The handler is the old one plus the plan check, moved before the brand reads. - What still runs. Insights rollups, action validation and Improve outcomes. None of them calls a model or another site.
- Tests.
- On main plus this PR's own diff, its 13 test files pass (196 tests).
- With main's source files put back under the same tests, 37 tests fail, and
cloro-callback.test.jsdoesn't load. - The whole server suite on that tree: 3,044 pass. 3 timing tests in
content-people.test.jsandcontent-agent.test.jsfailed under the full run's load and pass when run alone. This PR doesn't touch them.
Before and after the API deploy: server only, so merging changes nothing until the API is deployed. After the deploy, a queued job of an ended workspace is cancelled when it's claimed, and its outside data (bot logs, visits, Cloro answers, workflow callbacks) is answered and not kept.
Follow-ups:
- The web's pollers. A job cancelled with
failed_reason: 'subscription_inactive'keeps the Insights and Content spinners going. Only a workspace whose plan ended while a job was queued sees it, and its next page load sends it to the plan step. In the web part, treatcancelledas an end state and show the plan notice. - Docs.
webhooks.mdxshould name the 202ignoredanswer, as you say, in the docs PR.
On the questions in the description:
past_due: this is a product call, and it's consistent with how daily tracking already works. Note that what isn't kept while Stripe retries the card can't be recovered: visits, bot logs, and the answers of a run that was in flight. If that turns out to hurt customers who pay a few days late, a grace period belongs inisSubscriptionActiveon both the server and the web.- Content-draft "published" callbacks: I'd keep them. The callback records a page the person sent before the plan ended. It costs one write and no outside call. Dropped, the delivery stays "sent" for good, and nothing replays it after they buy again. Either way is safe for cost.
This was referenced Oct 27, 2026
gkhngyk
added a commit
that referenced
this pull request
Oct 28, 2026
… and show it in the Library (00352, shopping path, part 7a) (#1615) * feat(catalog): read a brand's Google Merchant Center products and item issues (00296, #1270 part 1) A Merchant Center account becomes a catalog source, read with the workspace's own Google sign-in through Composio (like Search Console and Analytics), so the token never reaches us. Calls go to the Merchant API v1 through Composio's proxy. - Connector merchant_center: lists the accounts the sign-in opens (plus an advanced account's sub-accounts), checks the picked one, reads every product page (1,000 a page) into the feed parsers' item shape (price from micros, first GTIN, availability and condition enums), keeps an offer listed again under another language or feed label once, and returns each product's item-level issues. syncOrders is a no-op. - 00296 catalog_item_issues: code, severity, attribute, reporting context, description per item; replaced each sync, removed with the source; members read, the server writes. - Plumbing: sign-in connectors (signIn instead of fields/connect), lib/catalog/sign-in.js (proxy request with 429/5xx waits, 'auth' when the sign-in is gone or refused), issue counts on last_counts, plain "Reconnect it in Settings › Integrations" words. - API: GET /api/catalog/accounts, POST /sources with input.account, signIns in GET /connectors, googleMerchantCenter in /integrations/config. - Tests with fixtures: paged list, items with and without issues, expired and refused sign-in, 429 wait, account picker, not set up. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): connect Google Merchant Center and pick each brand's account in Settings › Integrations (#1270 part 2) - Settings › Integrations gets a "Stores and marketplaces" group: a Google Merchant Center card that connects the workspace's Google sign-in like Search Console and Analytics, then lets the active brand pick one of the accounts it opens (GET /api/catalog/accounts) and add it as a catalog source. - Product catalog names the account "Google Merchant Center · Name (id)" and its row reads "N products · M with issues · synced …"; no sign-in button for it (the sign-in is the workspace's). The card reads its sources again when an account is added above. - The Shopping page's My Products tab links to Settings › Integrations to bring in the catalog. - catalog-client: signIns in listStoreConnectors, listSignInAccounts, connectSignInAccount, not_connected; CatalogCounts.issues; IntegrationProvider 'google-merchant-center'. Words in en.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): tell a Merchant Center not set up from a lost sign-in, and keep repeated offers' issues (#1270 review) - sign-in.js: Composio's own 401/403 and Google's 403 are not_set_up, not auth; each refusal is logged by name, status and Google's reason; only the connector's hosts (merchantapi.googleapis.com) are reached. - An offer listed again under another language or feed label is counted on its own (last_counts.repeated), its issues gathered from every listing, and the kept one chosen by a fixed rule (no DISAPPROVED issue, then feed label, then content language). - Account listing and connecting share a 30 s deadline; the sub-account walk stops on a rate limit; a catalog cut at the page limit says so. - entityIdFor moves to composio.js. Tests for paging, deadlines, limits, the proxy helper and the refusal codes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): keep a Merchant Center account to its brand, group the integrations by kind, and say what the catalog is for (#1270 review) - The picked account belongs to the brand it was picked for: switching brands clears it, an add goes to the brand clicked for, one add at once. Accounts already added are marked and can't be picked; a failed list read offers Try again; members get their own line. - Integrations' group headings are h3 headings; Webflow moves to a "Content management systems" group (IntegrationGroup). - Shopping › My Products' catalog note says what the catalog does (the editor's product-page checks), only while the brand has no source. - "1 with an issue"; a fixed platform name before /connectors is read; stores.errors.not_connected. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): say what a Merchant Center not set up means, count repeated offers, and note advanced accounts (#1270 review) - settings.merchantCenter.errors.not_configured says who fixes it (the server's set-up, or the Google account's access), with Try again. - A source's line shows "N listed again, kept once" (last_counts.repeated). - With several accounts, a note says an advanced account holds no products: pick the store's own sub-account. - Every StoreError has a message (checked at typecheck); the Shopping note is _catalog-note.tsx. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(catalog): match each catalog category to its page on the brand's site (00350, shopping path part 1) The shopping path links a buying guide or a comparison to the category's own page, so each catalog category is matched, on every read, to one of the brand's site pages whose address reads as a category page (the editor's page-type rule: /collections/, /category/, /c/, /shop/, WooCommerce's /product-category/; never a product page or a themed collection). Best match: the last path segment is the category's name, then the title or h1 holds it, then most of its words; ties go to the more cited, then visited page. - 00350: catalog_category_pages keeps a person's decision (a page, or none) by category name; catalog_category_counts(brand) gives live products and how many are in stock (service role only). - lib/catalog/category-pages.js: categorySlug, matchCategoryPages, categoryPages(brandId), setCategoryPage (page must be on the brand's domains). - API: GET /api/catalog/categories (members), PUT and DELETE (admins and managers). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): show each catalog category's page in Settings › Integrations and let admins change it (shopping path part 1) - Category pages, under the product catalog in Stores and marketplaces: each category of the active brand with its products and how many are in stock, its page on the site, and how it was found (its address or title names the category, most of its words, set by hand). Shown once the catalog has categories. - Admins and managers change a page (it must be on the brand's site), set none, or put a hand-set one back to the automatic match; members see the table. - catalog-client: listCategoryPages, setCategoryPage, resetCategoryPage; words in settings.catalog.categories. - The API calls a person's decision 'manual' whether it's a page or none. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): pick a draft's shopping path from the brand's catalog (00351, shopping path part 2) On an online shop, a buying guide, a best-of list or a comparison links the right category page and products in stock that Merchant Center accepts. The API picks them for the draft's topic and keeps them on the draft: - Topic: the title's words count 3, the brief's keywords 2, its goal and headings 1. - Categories: with a page on the site (00350) and stock, the best first, a second only when it scores half the first's (2 at most). - Products: the picked categories' first, then the brand's (2,000 scored, the best 40 read in full); offered when they have a link, a variant in stock and Merchant Center doesn't refuse that variant; the cheapest such variant's price, and its non-refusing issues (e.g. missing GTIN). How many by page type: best-of 8, buying guide 5, comparison and alternatives 4, guide 4, blog post 3. The best left out are kept with why (sold out, refused, no link). - The person's choices survive a rebuild: locked and added products stay (counted in the page's number), removed ones never come back. - 00351 content_drafts.shopping_path jsonb (64 KB at most); members edit it like the brief. - POST /api/content-drafts/:draftId/shopping-path { brandId }: { path }, or { path: null, reason } ('not_a_shop', 'page_type', 'no_catalog'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): show and change a draft's shopping path in the editor's Brief tab (shopping path part 3) Brief › Shopping path, above the brief, for a page type that links products (best-of, buying guide, comparison, alternatives, guide, blog post) on an e-commerce brand: - Pick from the catalog the first time (POST /:draftId/shopping-path), Pick again after; why a draft takes none (not a shop, page type, no catalog). - The category page with where it goes (in the intro and at the end). - Each product with its price (sale price first, en-US in its currency), In stock or Low stock, its Merchant Center issues, and its place by page type (Top picks #n, Compared #n, linked in the text). - Lock (kept when picked again or rewritten), Remove (saved at once), Swap (removed, then picked again for the next best), Add product (search the catalog's names, then picked again with it kept). - The best products left out, with why (sold out, Merchant Center refuses it, no page to link). - actions/shopping-path.ts: read and save through RLS like the brief, build through the API, search the catalog. lib/content/shopping-path.ts: the path's schema, which pages take one, places, changes. Words in contentEditor.editor.shopping; shopping_path in types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): write a page with its shopping path, the catalog's facts only (shopping path part 4) The Content Agent now writes with the draft's shopping path: - A new page: the writer is told the category page (name it in the opening, point to it again at the end) and the products in order with the catalog's price and stock only, never another spec (a placeholder instead). It writes text, so the names it wrote are linked afterwards (shopping-links.js linkShoppingPath): each target the first time a paragraph or a list item names it, never in a heading or inside a link; products first, longest names first; a category's last word singular or plural too. - A page it changes (rewrite from brief, suggestions, rule fixes): the path's pages join the pages it may link to, first in the prompt whatever the rules, and in the allow list (anything else is still unwrapped). - The path's names and prices are given to the number and people guards, so the catalog's price isn't turned into a placeholder. - content-links.js: linkTargetsPrompt and linkAllowList read targets.shopping; startDraftWriting and fixDraftRules read shopping_path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): put catalog products in a page as a card or a grid, by hand or with the agent (shopping path part 5) - + Insert › Products (the toolbar and the empty-line menu), on an online shop's draft: search the catalog by name, pick 1 to 4, Insert. One shows as a card, more as a grid: each product's picture, name and price (its cheapest variant in stock, sale price first), linked to its page. An HTML block with inline styles and no words of its own, so every export and CMS shows it as written, in any language. - The agent's new page on a list, a buying guide or a comparison with two products or more gets the same grid from its shopping path, at the end of the section that links the products most (else before the last H2, else at the end). - The markup is written twice, web (lib/content/product-block.ts) and server (lib/shopping-blocks.js); both tests expect the same string. - actions/shopping-path.ts getProductsForBlock reads products, variants and images through RLS; catalog_images added to types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): match category pages safely, quickly and by the editor's own rule (shopping path part 1 review) - A malformed % in a page address no longer breaks the read. - Pages and categories are prepared once, with a word index; site_pages isn't read when nothing can match. - GET uses the general limiter; PUT/DELETE get their own bucket. - The category-page rule is the editor's (page-types.ts), checked on both sides by one fixture list; /blog/category/ and pages marked first (best-of, size guides, -vs-, policies) aren't category pages. - Parent words count; a one-word category matches by address only. - Turkish and German letters fold (lib/letters.js, shared with Webflow). - The table is read again when sources change; editing resets per brand. - catalog_category_counts counts the web's four in-stock values. - PUT refuses a category the catalog doesn't have; messages fit the routes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): check a page's shopping links in Rules and Before you publish (shopping path part 6) On an online shop's page with a shopping path: - Rules › Links and sources gets three Shopping rules: it links its category page; it links the path's products (3 by default, or all of a smaller path; a product card or grid counts); and none it links is sold out, refused by Merchant Center for free listings, or gone from the catalog. The last isn't the agent's to fix (NOT_FOR_AGENT). - Before you publish gets a Shopping links row: the products to swap by name and why, else a missing link to the category page, else how many work. Read fresh when it opens. - readPage reads the links inside HTML blocks too (htmlBlockLinks). - getShoppingCheck reads the path's products against the catalog now (in stock as feed-match.ts reads it; a refusal counts for FREE_LISTINGS or no destination); useShoppingCheck feeds the rules and the dialog. - catalog_item_issues added to types/supabase.ts; words in contentEditor.editor.rules and beforePublish.shopping. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read a shopping path's kept products by id and every catalog row, with one stock rule (shopping path part 2 review) - Locked and added products are read by id from the brand's own catalog, always kept; a removed or unknown one is left out as 'gone'. - Every read is chunked and paged past PostgREST's 1,000-row cap. - The route has its own bucket (shoppingPathLimiter); descriptions are cut to 400 characters once read. - More stop words and years, letters folded as category pages do, and 'no_match' when nothing fits. - A refusal counts only for free listings or an empty context. - One stock list (catalog/stock.js), the same as feed-match.ts and 00350. - The saved path is read through Zod; a bad one is taken as none and logged. Writes are capped to 64 KB and conditional on builtAt/savedAt (409 'changed'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): fit the category pages table in Settings' card at 1024 px The table was 640 px wide in a 417 px card at 1024 px. The Change buttons sat out of sight, and the header's screen-reader label, outside the scroll box, scrolled the whole page sideways. - How a page was found is now a line under it, so four columns fit. - While a category is being changed, its form takes the button's cell as well. - The scroll box contains its label (`relative`). - Addresses wrap only where they must ([overflow-wrap:anywhere]). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep a person's shopping path change and read the API's new path shape (shopping path part 3 review) - The schema takes the API's shape: 'gone' and a missing title for a product left out, 'no_match', savedAt, availability in lowercase with underscores, and the same caps as the server. A reason it doesn't know reads as a general line instead of failing. - A change is saved before the path is picked again, so a failed pick (429, 502) doesn't lose it. - A save writes only locked, removed and added, and only over the path that was read (builtAt and savedAt). Otherwise it answers 'changed' and the tab reads the path again. A build's 409 'changed' and 429 have their own lines. - An unreadable saved path, 'no_match' or an unknown reason offers "Pick from the catalog". - Links must be http(s); others show without a link. - The search has its own error; the Lock button has a fixed name with aria-pressed. - Removed: the unused fromCatalog string. - Rows are keyed by their place and name; the category path wraps with [overflow-wrap:anywhere]. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): write a shopping path's prices, stock and links only as the catalog and the brand's site give them (shopping path part 4 review) - shoppingPathFor reads the path once per run through readShoppingPath. A bad shape counts as no path and is logged; the run goes on. - Prices pass in their usual forms ($189, 189 USD, ₺1.299,00), with the sign matching the currency; any other price becomes a placeholder. - Stock is read fresh from catalog_variants at write time and named through stock.js. Unknown stock says nothing. - Links: https and the brand's own domains only (brandSite, shared with category pages). - Product names match case-sensitively and category names don't. Letters are folded, and singulars come from category pages. - The fix path guards prices and names too. - A name or address is used once. A product name's numbers are free only where the name stands. - The prompt takes as many products as the page type links, 40 at most, locked and added ones kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep sold-out products out of product blocks and send the grid as a list (shopping path part 5 review) - The agent's grid takes only products in stock, counted after the filter, with the price and stock read fresh by shoppingPathFor. - Insert › Products: - A product is offered only when it's in stock and has an https page. Search hits show the price, or "Sold out" or "No page to link", and can't be picked when they're out. - At insert, a product sold out meanwhile is left out with a toast. - Each product's variants and image are read on their own: no shared row cap; an image with no variant first. - The cheapest variant in stock is picked by sale_price ?? price, with one stock reading shared with feed-match.ts (variantStock). - Cancel or Esc while inserting inserts nothing. - The search has its own error; picks survive a new search and can be taken back; Insert shows it's working; the count is aria-live. - The markup has spaces and line breaks, so text exports read each product apart. Webflow gets the grid as a <ul> list. Links are https, without tracking or a hash, the same on both sides (a shared fixture). A price of 0 is none; a sale price counts only under the price, for the agent's price line too. - The grid goes before the last H2 when no section links the products. - Tests for the writer's grid, getProductsForBlock and the toolbar's Products button. Docs: Insert › Products in the Content Editor guide. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(content): give the fix path's shopping test the fresh variant the price is read from Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): check a page's shopping links against every catalog row, its removed products and Brief's changes (shopping path part 6 review) - getShoppingCheck reads products, variants and Merchant Center issues in 100-id chunks, paged past 1,000 rows, with the brand taken from the draft. Stock is read by variantStock, contexts normalised as the server's. - Products removed or left out of the path are checked too, when they can't be sold. They count for shopLinksLive only, and its words say to remove or replace the link on the page. - Brief's Shopping path tells the editor when it changes, so the check reads again. - One link collector (PageRead.links) for Rules and Before you publish, HTML blocks included, so the product grid counts in both. - shopProductLinks counts only products that can be sold. - A failed read shows as failed, and a re-read keeps the last result. - Before you publish: - shows reading and failed rows, and "N of M products linked"; - the bad list is capped with "+N more", as Rules names the products. - shopLinksLive alone gets its own not-for-agent message. - Relative links resolve against the page's address or the brand's domain. Co-Authored-By: Claude Opus 5.5 <[email protected]> * wip(content): shopping link check after each catalog sync and the Library's Shopping path column (shopping path part 7a, before merging part 6's review) * fix(content): check removed and left-out products and relative links after each catalog sync, as the editor's Rules now do Part 6's review widened the editor's link check. The daily check after a catalog sync (lib/shopping-check.js) now reads a page the same way: - a product the person removed from the path, or the path left out, is checked too. It counts, at the catalog's page for it, only when it no longer sells: the page may still link it; - "products" and "products linked" count the path's products that sell; - a draft's relative link ("/products/x") is read against its page, else the brand's primary site; - catalog variants are read by the brand too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read the Library's shopping checks on their own, so the Library lists its drafts before 00352 is applied Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): trust a live page's shopping links only when it is the page, name removed products, and skip ended plans A live page is read only on the brand's site and with words enough to be the page; one that links none of the path while its draft does is read from its draft. A removed product is named by its catalog title, and a brand whose workspace's plan ended isn't checked (#1608). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): bound the work on a long link in the shopping check, and test its live-page deadline and draft cap Skip a link longer than 2,048 characters when a page's links are read. Test the 3-minute live-page deadline, and that no row is dropped when a run stops at its most drafts. --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk
added a commit
that referenced
this pull request
Oct 28, 2026
…ducts no longer for sale, and close it once fixed (shopping path, part 7b) (#1616) * feat(catalog): read a brand's Google Merchant Center products and item issues (00296, #1270 part 1) A Merchant Center account becomes a catalog source, read with the workspace's own Google sign-in through Composio (like Search Console and Analytics), so the token never reaches us. Calls go to the Merchant API v1 through Composio's proxy. - Connector merchant_center: lists the accounts the sign-in opens (plus an advanced account's sub-accounts), checks the picked one, reads every product page (1,000 a page) into the feed parsers' item shape (price from micros, first GTIN, availability and condition enums), keeps an offer listed again under another language or feed label once, and returns each product's item-level issues. syncOrders is a no-op. - 00296 catalog_item_issues: code, severity, attribute, reporting context, description per item; replaced each sync, removed with the source; members read, the server writes. - Plumbing: sign-in connectors (signIn instead of fields/connect), lib/catalog/sign-in.js (proxy request with 429/5xx waits, 'auth' when the sign-in is gone or refused), issue counts on last_counts, plain "Reconnect it in Settings › Integrations" words. - API: GET /api/catalog/accounts, POST /sources with input.account, signIns in GET /connectors, googleMerchantCenter in /integrations/config. - Tests with fixtures: paged list, items with and without issues, expired and refused sign-in, 429 wait, account picker, not set up. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): connect Google Merchant Center and pick each brand's account in Settings › Integrations (#1270 part 2) - Settings › Integrations gets a "Stores and marketplaces" group: a Google Merchant Center card that connects the workspace's Google sign-in like Search Console and Analytics, then lets the active brand pick one of the accounts it opens (GET /api/catalog/accounts) and add it as a catalog source. - Product catalog names the account "Google Merchant Center · Name (id)" and its row reads "N products · M with issues · synced …"; no sign-in button for it (the sign-in is the workspace's). The card reads its sources again when an account is added above. - The Shopping page's My Products tab links to Settings › Integrations to bring in the catalog. - catalog-client: signIns in listStoreConnectors, listSignInAccounts, connectSignInAccount, not_connected; CatalogCounts.issues; IntegrationProvider 'google-merchant-center'. Words in en.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): tell a Merchant Center not set up from a lost sign-in, and keep repeated offers' issues (#1270 review) - sign-in.js: Composio's own 401/403 and Google's 403 are not_set_up, not auth; each refusal is logged by name, status and Google's reason; only the connector's hosts (merchantapi.googleapis.com) are reached. - An offer listed again under another language or feed label is counted on its own (last_counts.repeated), its issues gathered from every listing, and the kept one chosen by a fixed rule (no DISAPPROVED issue, then feed label, then content language). - Account listing and connecting share a 30 s deadline; the sub-account walk stops on a rate limit; a catalog cut at the page limit says so. - entityIdFor moves to composio.js. Tests for paging, deadlines, limits, the proxy helper and the refusal codes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): keep a Merchant Center account to its brand, group the integrations by kind, and say what the catalog is for (#1270 review) - The picked account belongs to the brand it was picked for: switching brands clears it, an add goes to the brand clicked for, one add at once. Accounts already added are marked and can't be picked; a failed list read offers Try again; members get their own line. - Integrations' group headings are h3 headings; Webflow moves to a "Content management systems" group (IntegrationGroup). - Shopping › My Products' catalog note says what the catalog does (the editor's product-page checks), only while the brand has no source. - "1 with an issue"; a fixed platform name before /connectors is read; stores.errors.not_connected. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): say what a Merchant Center not set up means, count repeated offers, and note advanced accounts (#1270 review) - settings.merchantCenter.errors.not_configured says who fixes it (the server's set-up, or the Google account's access), with Try again. - A source's line shows "N listed again, kept once" (last_counts.repeated). - With several accounts, a note says an advanced account holds no products: pick the store's own sub-account. - Every StoreError has a message (checked at typecheck); the Shopping note is _catalog-note.tsx. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(catalog): match each catalog category to its page on the brand's site (00350, shopping path part 1) The shopping path links a buying guide or a comparison to the category's own page, so each catalog category is matched, on every read, to one of the brand's site pages whose address reads as a category page (the editor's page-type rule: /collections/, /category/, /c/, /shop/, WooCommerce's /product-category/; never a product page or a themed collection). Best match: the last path segment is the category's name, then the title or h1 holds it, then most of its words; ties go to the more cited, then visited page. - 00350: catalog_category_pages keeps a person's decision (a page, or none) by category name; catalog_category_counts(brand) gives live products and how many are in stock (service role only). - lib/catalog/category-pages.js: categorySlug, matchCategoryPages, categoryPages(brandId), setCategoryPage (page must be on the brand's domains). - API: GET /api/catalog/categories (members), PUT and DELETE (admins and managers). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): show each catalog category's page in Settings › Integrations and let admins change it (shopping path part 1) - Category pages, under the product catalog in Stores and marketplaces: each category of the active brand with its products and how many are in stock, its page on the site, and how it was found (its address or title names the category, most of its words, set by hand). Shown once the catalog has categories. - Admins and managers change a page (it must be on the brand's site), set none, or put a hand-set one back to the automatic match; members see the table. - catalog-client: listCategoryPages, setCategoryPage, resetCategoryPage; words in settings.catalog.categories. - The API calls a person's decision 'manual' whether it's a page or none. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): pick a draft's shopping path from the brand's catalog (00351, shopping path part 2) On an online shop, a buying guide, a best-of list or a comparison links the right category page and products in stock that Merchant Center accepts. The API picks them for the draft's topic and keeps them on the draft: - Topic: the title's words count 3, the brief's keywords 2, its goal and headings 1. - Categories: with a page on the site (00350) and stock, the best first, a second only when it scores half the first's (2 at most). - Products: the picked categories' first, then the brand's (2,000 scored, the best 40 read in full); offered when they have a link, a variant in stock and Merchant Center doesn't refuse that variant; the cheapest such variant's price, and its non-refusing issues (e.g. missing GTIN). How many by page type: best-of 8, buying guide 5, comparison and alternatives 4, guide 4, blog post 3. The best left out are kept with why (sold out, refused, no link). - The person's choices survive a rebuild: locked and added products stay (counted in the page's number), removed ones never come back. - 00351 content_drafts.shopping_path jsonb (64 KB at most); members edit it like the brief. - POST /api/content-drafts/:draftId/shopping-path { brandId }: { path }, or { path: null, reason } ('not_a_shop', 'page_type', 'no_catalog'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): show and change a draft's shopping path in the editor's Brief tab (shopping path part 3) Brief › Shopping path, above the brief, for a page type that links products (best-of, buying guide, comparison, alternatives, guide, blog post) on an e-commerce brand: - Pick from the catalog the first time (POST /:draftId/shopping-path), Pick again after; why a draft takes none (not a shop, page type, no catalog). - The category page with where it goes (in the intro and at the end). - Each product with its price (sale price first, en-US in its currency), In stock or Low stock, its Merchant Center issues, and its place by page type (Top picks #n, Compared #n, linked in the text). - Lock (kept when picked again or rewritten), Remove (saved at once), Swap (removed, then picked again for the next best), Add product (search the catalog's names, then picked again with it kept). - The best products left out, with why (sold out, Merchant Center refuses it, no page to link). - actions/shopping-path.ts: read and save through RLS like the brief, build through the API, search the catalog. lib/content/shopping-path.ts: the path's schema, which pages take one, places, changes. Words in contentEditor.editor.shopping; shopping_path in types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): write a page with its shopping path, the catalog's facts only (shopping path part 4) The Content Agent now writes with the draft's shopping path: - A new page: the writer is told the category page (name it in the opening, point to it again at the end) and the products in order with the catalog's price and stock only, never another spec (a placeholder instead). It writes text, so the names it wrote are linked afterwards (shopping-links.js linkShoppingPath): each target the first time a paragraph or a list item names it, never in a heading or inside a link; products first, longest names first; a category's last word singular or plural too. - A page it changes (rewrite from brief, suggestions, rule fixes): the path's pages join the pages it may link to, first in the prompt whatever the rules, and in the allow list (anything else is still unwrapped). - The path's names and prices are given to the number and people guards, so the catalog's price isn't turned into a placeholder. - content-links.js: linkTargetsPrompt and linkAllowList read targets.shopping; startDraftWriting and fixDraftRules read shopping_path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): put catalog products in a page as a card or a grid, by hand or with the agent (shopping path part 5) - + Insert › Products (the toolbar and the empty-line menu), on an online shop's draft: search the catalog by name, pick 1 to 4, Insert. One shows as a card, more as a grid: each product's picture, name and price (its cheapest variant in stock, sale price first), linked to its page. An HTML block with inline styles and no words of its own, so every export and CMS shows it as written, in any language. - The agent's new page on a list, a buying guide or a comparison with two products or more gets the same grid from its shopping path, at the end of the section that links the products most (else before the last H2, else at the end). - The markup is written twice, web (lib/content/product-block.ts) and server (lib/shopping-blocks.js); both tests expect the same string. - actions/shopping-path.ts getProductsForBlock reads products, variants and images through RLS; catalog_images added to types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): match category pages safely, quickly and by the editor's own rule (shopping path part 1 review) - A malformed % in a page address no longer breaks the read. - Pages and categories are prepared once, with a word index; site_pages isn't read when nothing can match. - GET uses the general limiter; PUT/DELETE get their own bucket. - The category-page rule is the editor's (page-types.ts), checked on both sides by one fixture list; /blog/category/ and pages marked first (best-of, size guides, -vs-, policies) aren't category pages. - Parent words count; a one-word category matches by address only. - Turkish and German letters fold (lib/letters.js, shared with Webflow). - The table is read again when sources change; editing resets per brand. - catalog_category_counts counts the web's four in-stock values. - PUT refuses a category the catalog doesn't have; messages fit the routes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): check a page's shopping links in Rules and Before you publish (shopping path part 6) On an online shop's page with a shopping path: - Rules › Links and sources gets three Shopping rules: it links its category page; it links the path's products (3 by default, or all of a smaller path; a product card or grid counts); and none it links is sold out, refused by Merchant Center for free listings, or gone from the catalog. The last isn't the agent's to fix (NOT_FOR_AGENT). - Before you publish gets a Shopping links row: the products to swap by name and why, else a missing link to the category page, else how many work. Read fresh when it opens. - readPage reads the links inside HTML blocks too (htmlBlockLinks). - getShoppingCheck reads the path's products against the catalog now (in stock as feed-match.ts reads it; a refusal counts for FREE_LISTINGS or no destination); useShoppingCheck feeds the rules and the dialog. - catalog_item_issues added to types/supabase.ts; words in contentEditor.editor.rules and beforePublish.shopping. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read a shopping path's kept products by id and every catalog row, with one stock rule (shopping path part 2 review) - Locked and added products are read by id from the brand's own catalog, always kept; a removed or unknown one is left out as 'gone'. - Every read is chunked and paged past PostgREST's 1,000-row cap. - The route has its own bucket (shoppingPathLimiter); descriptions are cut to 400 characters once read. - More stop words and years, letters folded as category pages do, and 'no_match' when nothing fits. - A refusal counts only for free listings or an empty context. - One stock list (catalog/stock.js), the same as feed-match.ts and 00350. - The saved path is read through Zod; a bad one is taken as none and logged. Writes are capped to 64 KB and conditional on builtAt/savedAt (409 'changed'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): fit the category pages table in Settings' card at 1024 px The table was 640 px wide in a 417 px card at 1024 px. The Change buttons sat out of sight, and the header's screen-reader label, outside the scroll box, scrolled the whole page sideways. - How a page was found is now a line under it, so four columns fit. - While a category is being changed, its form takes the button's cell as well. - The scroll box contains its label (`relative`). - Addresses wrap only where they must ([overflow-wrap:anywhere]). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep a person's shopping path change and read the API's new path shape (shopping path part 3 review) - The schema takes the API's shape: 'gone' and a missing title for a product left out, 'no_match', savedAt, availability in lowercase with underscores, and the same caps as the server. A reason it doesn't know reads as a general line instead of failing. - A change is saved before the path is picked again, so a failed pick (429, 502) doesn't lose it. - A save writes only locked, removed and added, and only over the path that was read (builtAt and savedAt). Otherwise it answers 'changed' and the tab reads the path again. A build's 409 'changed' and 429 have their own lines. - An unreadable saved path, 'no_match' or an unknown reason offers "Pick from the catalog". - Links must be http(s); others show without a link. - The search has its own error; the Lock button has a fixed name with aria-pressed. - Removed: the unused fromCatalog string. - Rows are keyed by their place and name; the category path wraps with [overflow-wrap:anywhere]. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): write a shopping path's prices, stock and links only as the catalog and the brand's site give them (shopping path part 4 review) - shoppingPathFor reads the path once per run through readShoppingPath. A bad shape counts as no path and is logged; the run goes on. - Prices pass in their usual forms ($189, 189 USD, ₺1.299,00), with the sign matching the currency; any other price becomes a placeholder. - Stock is read fresh from catalog_variants at write time and named through stock.js. Unknown stock says nothing. - Links: https and the brand's own domains only (brandSite, shared with category pages). - Product names match case-sensitively and category names don't. Letters are folded, and singulars come from category pages. - The fix path guards prices and names too. - A name or address is used once. A product name's numbers are free only where the name stands. - The prompt takes as many products as the page type links, 40 at most, locked and added ones kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep sold-out products out of product blocks and send the grid as a list (shopping path part 5 review) - The agent's grid takes only products in stock, counted after the filter, with the price and stock read fresh by shoppingPathFor. - Insert › Products: - A product is offered only when it's in stock and has an https page. Search hits show the price, or "Sold out" or "No page to link", and can't be picked when they're out. - At insert, a product sold out meanwhile is left out with a toast. - Each product's variants and image are read on their own: no shared row cap; an image with no variant first. - The cheapest variant in stock is picked by sale_price ?? price, with one stock reading shared with feed-match.ts (variantStock). - Cancel or Esc while inserting inserts nothing. - The search has its own error; picks survive a new search and can be taken back; Insert shows it's working; the count is aria-live. - The markup has spaces and line breaks, so text exports read each product apart. Webflow gets the grid as a <ul> list. Links are https, without tracking or a hash, the same on both sides (a shared fixture). A price of 0 is none; a sale price counts only under the price, for the agent's price line too. - The grid goes before the last H2 when no section links the products. - Tests for the writer's grid, getProductsForBlock and the toolbar's Products button. Docs: Insert › Products in the Content Editor guide. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(content): give the fix path's shopping test the fresh variant the price is read from Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): check a page's shopping links against every catalog row, its removed products and Brief's changes (shopping path part 6 review) - getShoppingCheck reads products, variants and Merchant Center issues in 100-id chunks, paged past 1,000 rows, with the brand taken from the draft. Stock is read by variantStock, contexts normalised as the server's. - Products removed or left out of the path are checked too, when they can't be sold. They count for shopLinksLive only, and its words say to remove or replace the link on the page. - Brief's Shopping path tells the editor when it changes, so the check reads again. - One link collector (PageRead.links) for Rules and Before you publish, HTML blocks included, so the product grid counts in both. - shopProductLinks counts only products that can be sold. - A failed read shows as failed, and a re-read keeps the last result. - Before you publish: - shows reading and failed rows, and "N of M products linked"; - the bad list is capped with "+N more", as Rules names the products. - shopLinksLive alone gets its own not-for-agent message. - Relative links resolve against the page's address or the brand's domain. Co-Authored-By: Claude Opus 5.5 <[email protected]> * wip(content): shopping link check after each catalog sync and the Library's Shopping path column (shopping path part 7a, before merging part 6's review) * fix(content): check removed and left-out products and relative links after each catalog sync, as the editor's Rules now do Part 6's review widened the editor's link check. The daily check after a catalog sync (lib/shopping-check.js) now reads a page the same way: - a product the person removed from the path, or the path left out, is checked too. It counts, at the catalog's page for it, only when it no longer sells: the page may still link it; - "products" and "products linked" count the path's products that sell; - a draft's relative link ("/products/x") is read against its page, else the brand's primary site; - catalog variants are read by the brand too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(action-center): open a Fix action for a live page that links products no longer for sale, and close it once fixed (shopping path, part 7b) The mockup's "Action Center · a task the daily catalog check made". After each catalog sync the shopping check reads every published page with a shopping path again. A live page that links a product that is sold out, refused by Merchant Center or gone from the catalog gets a Fix action (lib/action-center/from-shopping-check.js, kind 'shopping_links'): - one per page (dedup key shopping_links:<draftId>), named after the page: "Best rain jackets for 2026: 2 products are sold out"; - one task, "Swap the 2 products that no longer sell", with the page, why, the steps, the path's in-stock products to link instead and its Done when: "The page links no product that is sold out, refused or gone. Checked automatically after the next catalog sync." It carries no change text, so AC-010's nightly page sweep leaves it to this check; - impact high from three products, scored as a sure, quick fix. The same check closes it: once the live page links none of them, its task and the action are completed, each with a History line. Work someone added to it stays open, and so does the action. A page whose action was dismissed isn't raised again for the same products; one closed while they still don't sell waits 7 days. At most 5 new actions a check, the rest at the next sync. Only a live page read now counts: a draft isn't what readers see, and a page that couldn't be read says nothing. A failure is logged and the check goes on. The drawer shows the page with "Swap in the editor", the products that no longer sell and why, and the ones to link instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read the Library's shopping checks on their own, so the Library lists its drafts before 00352 is applied Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): trust a live page's shopping links only when it is the page, name removed products, and skip ended plans A live page is read only on the brand's site and with words enough to be the page; one that links none of the path while its draft does is read from its draft. A removed product is named by its catalog title, and a brand whose workspace's plan ended isn't checked (#1608). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(action-center): check a shopping links task with Check now, and close it as checked automatically Check now on the task runs the catalog sync's shopping check on its one draft (checkShoppingDraft) instead of answering not_checkable; a draft with no path left says so. The check completes the task with its last check kept and writes AC-010's task_checked line to the History, as the other automatic checks do. The nightly page sweep leaves these tasks to the catalog sync. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(action-center): list the product catalog's check among where actions come from Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): bound the work on a long link in the shopping check, and test its live-page deadline and draft cap Skip a link longer than 2,048 characters when a page's links are read. Test the 3-minute live-page deadline, and that no row is dropped when a run stops at its most drafts. * fix(action-center): keep a shopping links action open while its page still links the products it names The check now counts an open action's products on its page even when a rebuilt shopping path dropped them, only while they still don't sell, so a sync or Check now closes the action only once the page links none of them. When the open action can't be read, its action isn't synced. --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
gkhngyk
added a commit
that referenced
this pull request
Oct 28, 2026
…an (shopping path, part 7c) (#1617) * feat(catalog): read a brand's Google Merchant Center products and item issues (00296, #1270 part 1) A Merchant Center account becomes a catalog source, read with the workspace's own Google sign-in through Composio (like Search Console and Analytics), so the token never reaches us. Calls go to the Merchant API v1 through Composio's proxy. - Connector merchant_center: lists the accounts the sign-in opens (plus an advanced account's sub-accounts), checks the picked one, reads every product page (1,000 a page) into the feed parsers' item shape (price from micros, first GTIN, availability and condition enums), keeps an offer listed again under another language or feed label once, and returns each product's item-level issues. syncOrders is a no-op. - 00296 catalog_item_issues: code, severity, attribute, reporting context, description per item; replaced each sync, removed with the source; members read, the server writes. - Plumbing: sign-in connectors (signIn instead of fields/connect), lib/catalog/sign-in.js (proxy request with 429/5xx waits, 'auth' when the sign-in is gone or refused), issue counts on last_counts, plain "Reconnect it in Settings › Integrations" words. - API: GET /api/catalog/accounts, POST /sources with input.account, signIns in GET /connectors, googleMerchantCenter in /integrations/config. - Tests with fixtures: paged list, items with and without issues, expired and refused sign-in, 429 wait, account picker, not set up. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): connect Google Merchant Center and pick each brand's account in Settings › Integrations (#1270 part 2) - Settings › Integrations gets a "Stores and marketplaces" group: a Google Merchant Center card that connects the workspace's Google sign-in like Search Console and Analytics, then lets the active brand pick one of the accounts it opens (GET /api/catalog/accounts) and add it as a catalog source. - Product catalog names the account "Google Merchant Center · Name (id)" and its row reads "N products · M with issues · synced …"; no sign-in button for it (the sign-in is the workspace's). The card reads its sources again when an account is added above. - The Shopping page's My Products tab links to Settings › Integrations to bring in the catalog. - catalog-client: signIns in listStoreConnectors, listSignInAccounts, connectSignInAccount, not_connected; CatalogCounts.issues; IntegrationProvider 'google-merchant-center'. Words in en.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): tell a Merchant Center not set up from a lost sign-in, and keep repeated offers' issues (#1270 review) - sign-in.js: Composio's own 401/403 and Google's 403 are not_set_up, not auth; each refusal is logged by name, status and Google's reason; only the connector's hosts (merchantapi.googleapis.com) are reached. - An offer listed again under another language or feed label is counted on its own (last_counts.repeated), its issues gathered from every listing, and the kept one chosen by a fixed rule (no DISAPPROVED issue, then feed label, then content language). - Account listing and connecting share a 30 s deadline; the sub-account walk stops on a rate limit; a catalog cut at the page limit says so. - entityIdFor moves to composio.js. Tests for paging, deadlines, limits, the proxy helper and the refusal codes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): keep a Merchant Center account to its brand, group the integrations by kind, and say what the catalog is for (#1270 review) - The picked account belongs to the brand it was picked for: switching brands clears it, an add goes to the brand clicked for, one add at once. Accounts already added are marked and can't be picked; a failed list read offers Try again; members get their own line. - Integrations' group headings are h3 headings; Webflow moves to a "Content management systems" group (IntegrationGroup). - Shopping › My Products' catalog note says what the catalog does (the editor's product-page checks), only while the brand has no source. - "1 with an issue"; a fixed platform name before /connectors is read; stores.errors.not_connected. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): say what a Merchant Center not set up means, count repeated offers, and note advanced accounts (#1270 review) - settings.merchantCenter.errors.not_configured says who fixes it (the server's set-up, or the Google account's access), with Try again. - A source's line shows "N listed again, kept once" (last_counts.repeated). - With several accounts, a note says an advanced account holds no products: pick the store's own sub-account. - Every StoreError has a message (checked at typecheck); the Shopping note is _catalog-note.tsx. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(catalog): match each catalog category to its page on the brand's site (00350, shopping path part 1) The shopping path links a buying guide or a comparison to the category's own page, so each catalog category is matched, on every read, to one of the brand's site pages whose address reads as a category page (the editor's page-type rule: /collections/, /category/, /c/, /shop/, WooCommerce's /product-category/; never a product page or a themed collection). Best match: the last path segment is the category's name, then the title or h1 holds it, then most of its words; ties go to the more cited, then visited page. - 00350: catalog_category_pages keeps a person's decision (a page, or none) by category name; catalog_category_counts(brand) gives live products and how many are in stock (service role only). - lib/catalog/category-pages.js: categorySlug, matchCategoryPages, categoryPages(brandId), setCategoryPage (page must be on the brand's domains). - API: GET /api/catalog/categories (members), PUT and DELETE (admins and managers). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(settings): show each catalog category's page in Settings › Integrations and let admins change it (shopping path part 1) - Category pages, under the product catalog in Stores and marketplaces: each category of the active brand with its products and how many are in stock, its page on the site, and how it was found (its address or title names the category, most of its words, set by hand). Shown once the catalog has categories. - Admins and managers change a page (it must be on the brand's site), set none, or put a hand-set one back to the automatic match; members see the table. - catalog-client: listCategoryPages, setCategoryPage, resetCategoryPage; words in settings.catalog.categories. - The API calls a person's decision 'manual' whether it's a page or none. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): pick a draft's shopping path from the brand's catalog (00351, shopping path part 2) On an online shop, a buying guide, a best-of list or a comparison links the right category page and products in stock that Merchant Center accepts. The API picks them for the draft's topic and keeps them on the draft: - Topic: the title's words count 3, the brief's keywords 2, its goal and headings 1. - Categories: with a page on the site (00350) and stock, the best first, a second only when it scores half the first's (2 at most). - Products: the picked categories' first, then the brand's (2,000 scored, the best 40 read in full); offered when they have a link, a variant in stock and Merchant Center doesn't refuse that variant; the cheapest such variant's price, and its non-refusing issues (e.g. missing GTIN). How many by page type: best-of 8, buying guide 5, comparison and alternatives 4, guide 4, blog post 3. The best left out are kept with why (sold out, refused, no link). - The person's choices survive a rebuild: locked and added products stay (counted in the page's number), removed ones never come back. - 00351 content_drafts.shopping_path jsonb (64 KB at most); members edit it like the brief. - POST /api/content-drafts/:draftId/shopping-path { brandId }: { path }, or { path: null, reason } ('not_a_shop', 'page_type', 'no_catalog'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): show and change a draft's shopping path in the editor's Brief tab (shopping path part 3) Brief › Shopping path, above the brief, for a page type that links products (best-of, buying guide, comparison, alternatives, guide, blog post) on an e-commerce brand: - Pick from the catalog the first time (POST /:draftId/shopping-path), Pick again after; why a draft takes none (not a shop, page type, no catalog). - The category page with where it goes (in the intro and at the end). - Each product with its price (sale price first, en-US in its currency), In stock or Low stock, its Merchant Center issues, and its place by page type (Top picks #n, Compared #n, linked in the text). - Lock (kept when picked again or rewritten), Remove (saved at once), Swap (removed, then picked again for the next best), Add product (search the catalog's names, then picked again with it kept). - The best products left out, with why (sold out, Merchant Center refuses it, no page to link). - actions/shopping-path.ts: read and save through RLS like the brief, build through the API, search the catalog. lib/content/shopping-path.ts: the path's schema, which pages take one, places, changes. Words in contentEditor.editor.shopping; shopping_path in types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): write a page with its shopping path, the catalog's facts only (shopping path part 4) The Content Agent now writes with the draft's shopping path: - A new page: the writer is told the category page (name it in the opening, point to it again at the end) and the products in order with the catalog's price and stock only, never another spec (a placeholder instead). It writes text, so the names it wrote are linked afterwards (shopping-links.js linkShoppingPath): each target the first time a paragraph or a list item names it, never in a heading or inside a link; products first, longest names first; a category's last word singular or plural too. - A page it changes (rewrite from brief, suggestions, rule fixes): the path's pages join the pages it may link to, first in the prompt whatever the rules, and in the allow list (anything else is still unwrapped). - The path's names and prices are given to the number and people guards, so the catalog's price isn't turned into a placeholder. - content-links.js: linkTargetsPrompt and linkAllowList read targets.shopping; startDraftWriting and fixDraftRules read shopping_path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): put catalog products in a page as a card or a grid, by hand or with the agent (shopping path part 5) - + Insert › Products (the toolbar and the empty-line menu), on an online shop's draft: search the catalog by name, pick 1 to 4, Insert. One shows as a card, more as a grid: each product's picture, name and price (its cheapest variant in stock, sale price first), linked to its page. An HTML block with inline styles and no words of its own, so every export and CMS shows it as written, in any language. - The agent's new page on a list, a buying guide or a comparison with two products or more gets the same grid from its shopping path, at the end of the section that links the products most (else before the last H2, else at the end). - The markup is written twice, web (lib/content/product-block.ts) and server (lib/shopping-blocks.js); both tests expect the same string. - actions/shopping-path.ts getProductsForBlock reads products, variants and images through RLS; catalog_images added to types/supabase.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(catalog): match category pages safely, quickly and by the editor's own rule (shopping path part 1 review) - A malformed % in a page address no longer breaks the read. - Pages and categories are prepared once, with a word index; site_pages isn't read when nothing can match. - GET uses the general limiter; PUT/DELETE get their own bucket. - The category-page rule is the editor's (page-types.ts), checked on both sides by one fixture list; /blog/category/ and pages marked first (best-of, size guides, -vs-, policies) aren't category pages. - Parent words count; a one-word category matches by address only. - Turkish and German letters fold (lib/letters.js, shared with Webflow). - The table is read again when sources change; editing resets per brand. - catalog_category_counts counts the web's four in-stock values. - PUT refuses a category the catalog doesn't have; messages fit the routes. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): check a page's shopping links in Rules and Before you publish (shopping path part 6) On an online shop's page with a shopping path: - Rules › Links and sources gets three Shopping rules: it links its category page; it links the path's products (3 by default, or all of a smaller path; a product card or grid counts); and none it links is sold out, refused by Merchant Center for free listings, or gone from the catalog. The last isn't the agent's to fix (NOT_FOR_AGENT). - Before you publish gets a Shopping links row: the products to swap by name and why, else a missing link to the category page, else how many work. Read fresh when it opens. - readPage reads the links inside HTML blocks too (htmlBlockLinks). - getShoppingCheck reads the path's products against the catalog now (in stock as feed-match.ts reads it; a refusal counts for FREE_LISTINGS or no destination); useShoppingCheck feeds the rules and the dialog. - catalog_item_issues added to types/supabase.ts; words in contentEditor.editor.rules and beforePublish.shopping. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read a shopping path's kept products by id and every catalog row, with one stock rule (shopping path part 2 review) - Locked and added products are read by id from the brand's own catalog, always kept; a removed or unknown one is left out as 'gone'. - Every read is chunked and paged past PostgREST's 1,000-row cap. - The route has its own bucket (shoppingPathLimiter); descriptions are cut to 400 characters once read. - More stop words and years, letters folded as category pages do, and 'no_match' when nothing fits. - A refusal counts only for free listings or an empty context. - One stock list (catalog/stock.js), the same as feed-match.ts and 00350. - The saved path is read through Zod; a bad one is taken as none and logged. Writes are capped to 64 KB and conditional on builtAt/savedAt (409 'changed'). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(settings): fit the category pages table in Settings' card at 1024 px The table was 640 px wide in a 417 px card at 1024 px. The Change buttons sat out of sight, and the header's screen-reader label, outside the scroll box, scrolled the whole page sideways. - How a page was found is now a line under it, so four columns fit. - While a category is being changed, its form takes the button's cell as well. - The scroll box contains its label (`relative`). - Addresses wrap only where they must ([overflow-wrap:anywhere]). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep a person's shopping path change and read the API's new path shape (shopping path part 3 review) - The schema takes the API's shape: 'gone' and a missing title for a product left out, 'no_match', savedAt, availability in lowercase with underscores, and the same caps as the server. A reason it doesn't know reads as a general line instead of failing. - A change is saved before the path is picked again, so a failed pick (429, 502) doesn't lose it. - A save writes only locked, removed and added, and only over the path that was read (builtAt and savedAt). Otherwise it answers 'changed' and the tab reads the path again. A build's 409 'changed' and 429 have their own lines. - An unreadable saved path, 'no_match' or an unknown reason offers "Pick from the catalog". - Links must be http(s); others show without a link. - The search has its own error; the Lock button has a fixed name with aria-pressed. - Removed: the unused fromCatalog string. - Rows are keyed by their place and name; the category path wraps with [overflow-wrap:anywhere]. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): write a shopping path's prices, stock and links only as the catalog and the brand's site give them (shopping path part 4 review) - shoppingPathFor reads the path once per run through readShoppingPath. A bad shape counts as no path and is logged; the run goes on. - Prices pass in their usual forms ($189, 189 USD, ₺1.299,00), with the sign matching the currency; any other price becomes a placeholder. - Stock is read fresh from catalog_variants at write time and named through stock.js. Unknown stock says nothing. - Links: https and the brand's own domains only (brandSite, shared with category pages). - Product names match case-sensitively and category names don't. Letters are folded, and singulars come from category pages. - The fix path guards prices and names too. - A name or address is used once. A product name's numbers are free only where the name stands. - The prompt takes as many products as the page type links, 40 at most, locked and added ones kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep sold-out products out of product blocks and send the grid as a list (shopping path part 5 review) - The agent's grid takes only products in stock, counted after the filter, with the price and stock read fresh by shoppingPathFor. - Insert › Products: - A product is offered only when it's in stock and has an https page. Search hits show the price, or "Sold out" or "No page to link", and can't be picked when they're out. - At insert, a product sold out meanwhile is left out with a toast. - Each product's variants and image are read on their own: no shared row cap; an image with no variant first. - The cheapest variant in stock is picked by sale_price ?? price, with one stock reading shared with feed-match.ts (variantStock). - Cancel or Esc while inserting inserts nothing. - The search has its own error; picks survive a new search and can be taken back; Insert shows it's working; the count is aria-live. - The markup has spaces and line breaks, so text exports read each product apart. Webflow gets the grid as a <ul> list. Links are https, without tracking or a hash, the same on both sides (a shared fixture). A price of 0 is none; a sale price counts only under the price, for the agent's price line too. - The grid goes before the last H2 when no section links the products. - Tests for the writer's grid, getProductsForBlock and the toolbar's Products button. Docs: Insert › Products in the Content Editor guide. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(content): give the fix path's shopping test the fresh variant the price is read from Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): check a page's shopping links against every catalog row, its removed products and Brief's changes (shopping path part 6 review) - getShoppingCheck reads products, variants and Merchant Center issues in 100-id chunks, paged past 1,000 rows, with the brand taken from the draft. Stock is read by variantStock, contexts normalised as the server's. - Products removed or left out of the path are checked too, when they can't be sold. They count for shopLinksLive only, and its words say to remove or replace the link on the page. - Brief's Shopping path tells the editor when it changes, so the check reads again. - One link collector (PageRead.links) for Rules and Before you publish, HTML blocks included, so the product grid counts in both. - shopProductLinks counts only products that can be sold. - A failed read shows as failed, and a re-read keeps the last result. - Before you publish: - shows reading and failed rows, and "N of M products linked"; - the bad list is capped with "+N more", as Rules names the products. - shopLinksLive alone gets its own not-for-agent message. - Relative links resolve against the page's address or the brand's domain. Co-Authored-By: Claude Opus 5.5 <[email protected]> * wip(content): shopping link check after each catalog sync and the Library's Shopping path column (shopping path part 7a, before merging part 6's review) * fix(content): check removed and left-out products and relative links after each catalog sync, as the editor's Rules now do Part 6's review widened the editor's link check. The daily check after a catalog sync (lib/shopping-check.js) now reads a page the same way: - a product the person removed from the path, or the path left out, is checked too. It counts, at the catalog's page for it, only when it no longer sells: the page may still link it; - "products" and "products linked" count the path's products that sell; - a draft's relative link ("/products/x") is read against its page, else the brand's primary site; - catalog variants are read by the brand too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(action-center): open a Fix action for a live page that links products no longer for sale, and close it once fixed (shopping path, part 7b) The mockup's "Action Center · a task the daily catalog check made". After each catalog sync the shopping check reads every published page with a shopping path again. A live page that links a product that is sold out, refused by Merchant Center or gone from the catalog gets a Fix action (lib/action-center/from-shopping-check.js, kind 'shopping_links'): - one per page (dedup key shopping_links:<draftId>), named after the page: "Best rain jackets for 2026: 2 products are sold out"; - one task, "Swap the 2 products that no longer sell", with the page, why, the steps, the path's in-stock products to link instead and its Done when: "The page links no product that is sold out, refused or gone. Checked automatically after the next catalog sync." It carries no change text, so AC-010's nightly page sweep leaves it to this check; - impact high from three products, scored as a sure, quick fix. The same check closes it: once the live page links none of them, its task and the action are completed, each with a History line. Work someone added to it stays open, and so does the action. A page whose action was dismissed isn't raised again for the same products; one closed while they still don't sell waits 7 days. At most 5 new actions a check, the rest at the next sync. Only a live page read now counts: a draft isn't what readers see, and a page that couldn't be read says nothing. A failure is logged and the check goes on. The drawer shows the page with "Swap in the editor", the products that no longer sell and why, and the ones to link instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(content): show a shop's Shopping opportunities in the Content Plan: buying guides its categories miss and posts whose shopping links need fixing (shopping path, part 7c) The mockup's "Content Plan · Shopping opportunities". For a brand whose site type is e-commerce and whose catalog has categories, a section above the priority list (plan/_shopping-opportunities.tsx), with the catalog's products and categories beside its title: - Buying guide · New: a category with 3 or more products in stock that no page of the brand's guides shoppers to yet (no draft's shopping path holds it, no draft's title names it). Why says how many tracked prompts ask about it, and when it has no category page to link. Create starts a "How to choose hiking boots" buying guide from the first of those prompts and opens it in the editor; a draft still being written for the category shows Open draft instead. At most 10, the best first. - Existing post · Fix: a published post whose last check after a catalog sync (00352) found it links a product that no longer sells, or not each of its path's category pages ("No link to the Rain Jackets page. 2 products it links are sold out."). Optimize opens it. Ranked on the Plan's Priority Score scale (SCORE_WEIGHTS, the Plan's levels): a guide as a new page, its opportunity the prompts asking and the products in stock; a post by how many products it links that no longer sell. lib/content/shopping-plan.ts makes the rows; getShoppingPlan (lib/actions/shopping-plan.ts) reads the drafts with their path's categories and last check, the active prompts and the catalog's products; the categories come from the API (listCategoryPages). Read on its own: when it can't be, or there are no categories, the section stays hidden. The guide documents the section, the Library's Shopping path column and the Action Center's sold-out action. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): read the Library's shopping checks on their own, so the Library lists its drafts before 00352 is applied Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): trust a live page's shopping links only when it is the page, name removed products, and skip ended plans A live page is read only on the brand's site and with words enough to be the page; one that links none of the path while its draft does is read from its draft. A removed product is named by its catalog title, and a brand whose workspace's plan ended isn't checked (#1608). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(action-center): check a shopping links task with Check now, and close it as checked automatically Check now on the task runs the catalog sync's shopping check on its one draft (checkShoppingDraft) instead of answering not_checkable; a draft with no path left says so. The check completes the task with its last check kept and writes AC-010's task_checked line to the History, as the other automatic checks do. The nightly page sweep leaves these tasks to the catalog sync. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(action-center): list the product catalog's check among where actions come from Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(content): keep the Plan's Shopping opportunities through another period's read instead of reading them again Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(content): say which live pages the shopping check reads from their draft, and that Check now closes the task Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
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
Read-only, part A2: nothing automatic runs or is taken in for a workspace whose plan ended. #1589 stops their writes and some scheduled jobs. Ansvisor's rule is that every automatic process stops for them too, with no cost to us until they buy: action and signal generation, data intake, suggestions and every kind of tracking. Self-hosted is unchanged.
A paying workspace is never affected. A cancel runs to the end of the paid period, so only an ended trial, an ended cancellation or a refused card counts as not active.
Stacked on #1589. This PR's own change is its commits after #1589's: 9980a36 and 2d28ea9 (the pre-push review's fixes). Server only.
What stops for a workspace that isn't active (on the cloud):
job-runner.js): tracking and content jobs, their retries and the internal trigger are cancelled when claimed (cancelClaimedJob,failed_reason: 'subscription_inactive'). So nothing they'd start runs either: content opportunities, clusters, site pages. If that cancel fails, the job is failed rather than leftactive. A failed plan read retries the job as any error does.actions!inner(… organizations!inner(subscription_status))), so they can't fill its 20.analyze-volumes) stops.routes/cloro-callback.js, moved out ofserver.jsto be tested), before any brand reads.Ingest from outside answers success and keeps nothing, so the sender never retries:
/bots/ingestanswers 200NOT_STOREDand reads nothing;/track(visits, CE-017 events) answers 204;ignored, after their secret checks.Never dropping a paying workspace's data (from the review):
lib/active-subscriptions.js:isOrgActiveCached,isBrandActiveCached):/trackcount the workspace as active. The pending Cloro row goes only once the result is saved./bots/ingestre-reads on aPlanLimitError(plan-guard raises one on a passing read error too). It answersNOT_STOREDonly for a workspace that isn't active; otherwise 500, so the sender retries./trackchecks the plan after the body, so a bad body gets the same 400 either way, and the public snippet can't tell whether a site's plan ended.Still runs: database upkeep (rollups, counters, action validation, Improve outcomes, clean-ups, citation recounts), the health report and Socket.io. None of it raises an action or costs anything outside.
Related issue
None. Product decision (Ansvisor, 2026-10-27): "action generation, signal generation, data intake, suggestions, every kind of tracking must stop" for a workspace whose plan ended. Follows #1589.
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
cd server && npx vitest run src/lib/active-subscriptions.test.js src/lib/job-runner.test.js src/lib/job-manager.test.js src/lib/signals/pass.test.js src/lib/action-center/task-writer src/lib/volume-analysis.test.js src/routes/cloro-callback.test.js src/routes/bot-ingest.test.js src/routes/traffic-track.test.js src/routes/webhook-content-callback.test.js src/routes/webhook-content-draft-callback.test.jssubscription_status = canceled:/trackevent and a bot log are answered but not stored;active, and within a minute they're stored again.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — no web changeyarn typecheckpasses (run fromweb/) — no web changeyarn format:checkpasses (run fromweb/) — no web changeAlso run in
server/:npm run format,npm run lintandnpm test(3,022 tests). The fixers broke 21 behaviours one at a time to check that the tests catch them.For you, @gkhngyk:
past_dueis not active, per Ansvisor's decision. A refused card stops tracking and intake at once, and data sent meanwhile isn't kept. "Update payment method" unlocks it (feat(web): let a workspace whose plan ended browse read-only, with one "Choose a plan" dialog #1599).cancelledwithsubscription_inactive; they keep spinning. Active workspaces never get there.webhooks.mdx) should name the 202ignoredanswer. That goes in the read-only docs PR.!innerfilter was tried against PostgREST for feat(server): keep a workspace read-only once its plan has ended #1589's task runs. The task writer uses the same shape.🤖 Generated with Claude Code