Skip to content

Job intents

Every job carries an intent and an intent-specific spec. The planner (workers/planner.py) expands intent + spec into the child GenerationTask rows that the entity workers then drive. This page documents every intent.

The request envelope is entity-generic:

POST /jobs
{
  "site": "FRDEV",                 // resolved to a numeric cms-api site_id
  "intent": "article_batch",       // one of the intents below
  "defaults": {                    // provider/publish defaults, applied per task
    "publish_status": "draft",     // draft | published (default: stays draft)
    "author_id": 1                 // required by cms-api ContentCreate
  },
  "spec": { /* intent-specific, see below */ },
  "idempotency_key": "optional-dedupes-resubmits",
  "submitted_by": "optional"
}

account_id is required for real generation

Any intent that calls a real (non-stub) AI provider must carry spec.account_id -- the OpenAI account id from the harvester ai_accounts table (3468 on stage). See Configuration. It can also be supplied via defaults.account_id / defaults.text.account_id.

Intent summary

Intent Expands to Real AI calls
site_scaffold 6 chained entity tasks (settings→logo→taxonomy→style→template→page_type) logo image + text (settings/taxonomy)
article_batch categories × articles_per_category article tasks (capped 50) text + images per article
single_article one article task text + images
wp_import one article task per WP post reference (capped 50, overflow logged) image fetch only
wp_site_import discovers the WP post set itself, one article task per post, chaining continuation jobs image fetch only
cms_copy one article task per source content id (capped 50) image fetch only
seo_enrich one task per existing published row missing SEO (capped 50) text per row
settings_tune one settings-tune task none (deterministic nav)
content_refresh a recurring article_batch (scheduled) text + images
generate_<entity> one targeted entity task depends on entity

The per-job article cap (_MAX_ARTICLES_PER_JOB = 50) bounds article_batch, wp_import, cms_copy, and seo_enrich fan-out.


site_scaffold

Purpose. Generate a site's bespoke, renderable shell in dependency order so an empty site can render and list before it hosts content.

Produces. The six-step ordered chain, each task linked to the previous via parent_task_id so it publishes in order:

settings → logo → taxonomy → style → template → page_type

style and template assign an existing style/template (never generate one): style points the site's style_slug SiteSetting at an existing style; template binds the site to an existing populated template via Site.template_id.

Spec fields.

Field Meaning
site_id, domain, site_title, niche Site identity; domain drives cdn_base_url (same-origin media)
categories Category names for the nav shell + taxonomy
style_slug Existing style to assign (default: the seeded default style)
template_id Existing template to assign (default: the -1 populated preset)
account_id OpenAI account for the real logo/text generation

Example.

{
  "site": "FRDEV",
  "intent": "site_scaffold",
  "spec": {
    "site_id": 207,
    "domain": "frdev.wantskicks.com",
    "site_title": "Front Story Dev",
    "niche": "sneaker culture",
    "categories": ["Releases", "Guides", "Trends", "Reviews"],
    "style_slug": "default",
    "account_id": 3468
  }
}

article_batch

Purpose. Fill a scaffolded shell with content that lists on the homepage/category pages and renders via the article page type.

Produces. One article task per (category, article index), source ai_generate. Each article fans out image children (featured + inline) via a Celery chord before it publishes.

Spec fields. categories (list), articles_per_category (int), topic_seed, images_per_article ({featured, inline}), plus site identity + account_id. defaults.publish_status controls whether articles land as draft (default) or published; defaults.author_id sets the required cms-api author.

Example.

{
  "site": "FRDEV",
  "intent": "article_batch",
  "defaults": { "publish_status": "draft", "author_id": 1 },
  "spec": {
    "site_id": 207,
    "site_title": "Front Story Dev",
    "niche": "sneaker culture",
    "account_id": 3468,
    "categories": ["Releases", "Guides"],
    "articles_per_category": 2,
    "topic_seed": "2026 spring sneaker trends",
    "images_per_article": { "featured": 1, "inline": 3 }
  }
}

single_article

Purpose. Generate exactly one article (e.g. a targeted/on-demand piece).

Produces. One article task; source defaults to ai_generate.

Spec fields. category, site identity + account_id, optional source.

Example.

{
  "site": "FRDEV",
  "intent": "single_article",
  "defaults": { "publish_status": "draft", "author_id": 1 },
  "spec": {
    "site_id": 207,
    "site_title": "Front Story Dev",
    "niche": "sneaker culture",
    "account_id": 3468,
    "category": "Releases"
  }
}

wp_import

Purpose. Import existing WordPress posts into the CMS (WordPress → CMS).

Produces. One article task per entry in spec.posts, source wp_import. The strategy reads the WP MySQL DB primary with a REST-API fallback and converts the post HTML into content_blocks. Images carry source_url and are fetched rather than generated, so no text-provider account_id is needed.

Spec fields. posts (list of post ids/slugs or {post: ...} dicts), site identity, optional top-level category (CMS site category name — must match the /{category}/{slug} route segment, e.g. "Trending Now" on fashionradar). When omitted, the first WordPress category term from the REST _embed payload is used so the article still gets a resolvable URL.

Example.

{
  "site": "FRDEV",
  "intent": "wp_import",
  "defaults": { "publish_status": "draft", "author_id": 1 },
  "spec": {
    "site_id": 207,
    "category": "Trending Now",
    "posts": [1234, 1235, "some-post-slug"]
  }
}

Publish-time integrity gate (AISD-284 / AISD-314)

An imported article that would publish broken is dropped before the publish claim rather than published and repaired afterwards: the wantskicks import published 4 rows whose images never copied, and the rows existed, served, and looked fine in every count. forge.workers.publish._broken_reason refuses a task when the payload is missing title or content_blocks, or when the article had image briefs and none of the images copied. A partial image failure is not broken -- an article that lost one inline picture still reads.

The gate is scoped to source: wp_import articles on purpose. An AI-generated article that comes back without images is a generation failure with its own retry semantics, and dropping it here would hide that behind a rule written for imported content.

A refused task is dead-lettered, not retried: failed → dead with the reason recorded, plus an article_broken warning event on the job. "This article has no title" is a settled verdict, and every retry would re-derive it identically until the attempt budget ran out. The task stays visible in the job tree for audit.

A duplicate is exempt from every check (AISD-314). A duplicate is a ledger short-circuit: _spawn_article_image_children spawns no image children for one, so "none of the images copied" is unsatisfiable by construction, and _publish_article records the ledger entry and skips the create, so there is no reader-visible row to judge. Applying the checks anyway dead-lettered all 58 articles of a fashionradar re-import and reported a correct no-op as total failure.


cms_copy

Purpose. Copy content between CMS sites (CMS → CMS).

Produces. One article task per entry in spec.sources, source cms_copy. Reads each source row via GET /admin/v1/content/{id}; images fetched by source_url.

Spec fields. sources (list of content ids or {source_content_id: ...} dicts), destination site identity.

Example.

{
  "site": "FRDEV",
  "intent": "cms_copy",
  "defaults": { "publish_status": "draft", "author_id": 1 },
  "spec": {
    "site_id": 207,
    "sources": [98, 99, 100]
  }
}

seo_enrich (Phase 4, AISD-154)

Purpose. Populate SEO/OpenGraph/canonical/schema metadata on existing published content that is missing it.

Produces. At plan time, a single cms-api list_content(site_id, status="published") read enumerates the site's published rows; one seo_enrich task is emitted per row that is not already SEO-populated (a row with both seo_title and seo_description is skipped), carrying that row's id/title/slug/description/categories in params so the generator needs no per-row read. Fan-out is capped at 50; re-runs make progress because populated rows are then skipped.

Publish PATCHes the SEO subset onto the existing row via PATCH /admin/v1/content/{id} (ContentUpdate): seo_title, seo_description, og_title, og_description, og_image, canonical_url, schema_type, noindex. canonical_url is re-derived from the existing title by reusing the article generator's slug/canonical helpers -- never a provider-supplied canonical and never a divergent slugifier -- so it matches cms-api's title-derived breadcrumb exactly.

Spec fields. site_id, account_id (the generator uses the OpenAI text path). No per-row input -- the planner discovers the rows.

Example.

{
  "site": "FRDEV",
  "intent": "seo_enrich",
  "spec": {
    "site_id": 207,
    "account_id": 3468
  }
}

settings_tune (Phase 4, AISD-154)

Purpose. Fix the hardcoded-default-navigation bug and polish site settings. This is the explicit Phase-4 nav fix.

Produces. A single settings_tune task. It reads the site's real cms-api categories at context-build time and derives navigation from that actual taxonomy (ordered by the categories' sort_order) instead of the hardcoded default nav the scaffold SettingsGenerator falls back to. It also applies ads_txt / robots_txt / default_og_image only when supplied in the spec (verbatim passthrough -- ads.txt publisher lines are never AI-invented). Applied via PATCH /admin/v1/sites/{id}/settings, idempotent.

The generator is deterministic: it ignores any provider-returned navigation so the taxonomy-derived nav (and operator-supplied ads/robots) always win. An empty derived nav omits the key so a PATCH never clobbers existing navigation with [].

Spec fields. site_id, site_title, and optionally ads_txt, robots_txt, default_og_image.

Example.

{
  "site": "FRDEV",
  "intent": "settings_tune",
  "spec": {
    "site_id": 207,
    "site_title": "Front Story Dev",
    "ads_txt": "google.com, pub-0000000000000000, DIRECT, f08c47fec0942fa0",
    "robots_txt": "User-agent: *\nAllow: /\nSitemap: https://frdev.wantskicks.com/sitemap.xml"
  }
}

content_refresh (Phase 4, AISD-154)

Purpose. Keep a site fresh over time with recurring content batches.

Produces. Expands exactly like article_batch (so the ai_content_ledger + (site_id, slug) dedup make each cadence tick idempotent -- no duplicate content). It is normally not posted by hand: a Celery-beat task (workers/content_refresh.enqueue_content_refresh) creates one content_refresh job per configured site-spec on a cadence.

Scheduled and OFF by default

The beat entry is registered only when FORGE_CONTENT_REFRESH_ENABLED is true. The site/category/count payloads come from FORGE_CONTENT_REFRESH_SPECS (a JSON list of {site, spec, defaults}) and the cadence from FORGE_CONTENT_REFRESH_INTERVAL_SECONDS (default 86400 = daily). CI/test and un-opted-in environments never auto-fire paid content jobs. See Configuration. Posting content_refresh directly to POST /jobs works and is useful for a one-off manual refresh.

Example (manual one-off).

{
  "site": "FRDEV",
  "intent": "content_refresh",
  "defaults": { "publish_status": "draft", "author_id": 1 },
  "spec": {
    "site_id": 207,
    "site_title": "Front Story Dev",
    "niche": "sneaker culture",
    "account_id": 3468,
    "categories": ["Releases"],
    "articles_per_category": 1
  }
}

generate_<entity> granulars

For targeted re-runs of a single scaffold entity without running the whole chain. Each expands to exactly one entity task of the mapped type:

Intent Entity Publishes via
generate_settings settings PATCH /admin/v1/sites/{id}/settings
generate_logo logo logo/favicon media paths through upsert_settings
generate_taxonomy taxonomy POST /admin/v1/sites/{id}/categories
generate_style style assign existing style (PATCH .../style)
generate_template template assign existing template (PATCH /admin/v1/sites/{id})
generate_page_types page_type POST /admin/v1/sites/{id}/page-types
template_variant template_variant assign pairing (PATCH .../template-style)
page_type_variant page_type_variant upsert/replace extra page types

Example.

{
  "site": "FRDEV",
  "intent": "generate_logo",
  "spec": {
    "site_id": 207,
    "site_title": "Front Story Dev",
    "niche": "sneaker culture",
    "account_id": 3468
  }
}

template_variant (AISD-153)

Assign an existing curated template_styles pairing to the site. No CSS/HTML generation and no block-override writes.

{
  "site": "FRDEV",
  "intent": "template_variant",
  "spec": {
    "site_id": 207,
    "template_style_id": 12
  }
}

page_type_variant (AISD-153)

Add (or replace) thin page_types rows. Named variants: gallery, long_form, landing. Optional explicit page_types descriptor list. replace=true keeps scaffold home/category/article plus requested variants and deletes orphans.

{
  "site": "FRDEV",
  "intent": "page_type_variant",
  "spec": {
    "site_id": 207,
    "variants": ["gallery", "landing"]
  }
}

Any unrecognized intent falls back to a single task named after the intent ({entity_type: intent, params: spec}).

wp_site_import

Imports a whole WordPress site rather than a hand-listed set of posts. This is what POST /migrate_from_wp submits (AISD-250).

Produces. One article task per discovered post, source wp_import -- the same per-post path as wp_import, so nothing about publishing changes.

Discovery. forge.generation.sources.wp_discovery pages the WordPress REST API. type selects the post set:

type posts
editorial every category except the trending bucket (default)
trending the trending bucket only
all unfiltered

Windowing. The trending bucket alone is ~3,082 posts against a 50-task cap, so a job plans one window and queues a continuation job carrying the remaining posts in spec.pending_posts. Discovery therefore runs once per import, not once per hop -- re-paging every hop would be ~1,900 REST list requests. Chaining rather than raising the cap keeps each job's task tree small enough to inspect and retry, and lets a failed window be re-driven without re-planning the site.

Three job events make the chain observable on GET /jobs/{id}:

event meaning
wp_import_continued a hop completed and queued the next one
wp_import_continuation_failed the next job could NOT be queued -- the chain stopped, and the remaining posts are not imported
wp_import_incomplete discovery hit its page ceiling, so the post set is knowably partial

Because a queueing failure never fails the parent job (that would throw away the window it already planned), check the chain, not just the first job's state, to confirm an import finished.

Each hop also records its predecessor in ai_generation_jobs.parent_job_id (AISD-318), so the chain is queryable as data rather than only recoverable from the derived idempotency key (<parent>:wp-continue:<offset>) and the text of the wp_import_continued event.

Cancelling an import cancels the whole chain. A hop queues its successor during its own planning, so by the time an operator cancels, the next job may already exist and be planning -- cancelling one row would stop nothing they can perceive. POST /jobs/{id}/cancel therefore walks parent_job_id forward and cancels every descendant, and plan_job refuses to expand a job that is already cancelled (recording a job_cancelled_before_planning event so a hop that was queued and then stopped explains itself rather than looking like a redelivered message).

Trending is not a content type. In WordPress it is a second URL rewrite prefix serving a noindex variant of any post -- not a post type and not a routing taxonomy. So trending posts import as content_type: listicle (the shape they actually carry), with is_trending: true and visible_in_ui: false so ~3k rows stay out of the CMS admin list without being unpublished.

Translations are skipped. lang-* / locale-slugged posts are counted and reported, not imported: uq_content_site_slug is per-site, not per-(site, language), so a translation collides with its original.

curl -X POST "$FORGE/migrate_from_wp" -H 'Content-Type: application/json' \
  -d '{"website": "wantskicks", "type": "trending"}'
# -> {"job_id": "...", "state": "received"}

Optional body fields: wp_base_url (defaults to https://<website>.com), max_posts (trial run), force_refetch, idempotency_key, submitted_by.

Re-running is safe (AISD-256). Uploads are content-addressed -- the publisher sends a sha256 of the bytes and cms-api derives the object key from it -- so identical images overwrite the same object instead of piling up new ones, and the stored media_path is stable across runs. An image this site has already copied is reused without re-downloading it, and an already-imported post short-circuits before the create.

The reuse is keyed on (site, source_url), so it cannot see an image edited upstream. Pass force_refetch: true to re-download a site's media; a changed image then lands on a new key and the previous object is logged as unreferenced.

Site assets are imported on the first hop (AISD-258). Before any article is planned, the importer brings across the things a site needs to be reviewable:

asset source written via
logo the site_logo attachment on /wp-json (absent = no logo imported) MediaPublisher.upload(kind="logo")
favicon /favicon.ico MediaPublisher.upload(kind="favicon")
categories /wp/v2/categories, minus trending / uncategorized / lang-* upsert_categories
authors /wp/v2/users, created global, then linked upsert_author + link_site_author
settings site name / description / language upsert_settings
ads.txt / robots.txt /ads.txt, /robots.txt upsert_settings (ads_txt, robots_txt)

Two things about this are load-bearing:

kind is what makes branding work at all. The worker resolves branding by fixed path — /cmp-media/<scope>/logo.webp and /favicon.ico (AISD-198) — so an upload to a generated key is silently never served. kind is the field that makes cms-api return the convention key instead, and it requires cms-api at AISD-258 or later: an older deployment drops the field (pydantic extra="ignore") and the upload lands somewhere nothing reads.

It runs once per import, not once per hop. A continuation job carries the same spec, so the step is discriminated on spec.pending_posts being absent — the same rule the wipe uses. Pass skip_site_assets: true to opt out entirely (re-importing content onto a site whose branding you have already tuned by hand).

A failure here is recorded, not raised: a wp_import_site_assets event carries the per-asset counts and any per-step errors, and the article import continues. Missing branding degrades a site's appearance; abandoning the import loses its content.

Wiping first (AISD-257). wipe_first: true calls cms-api's site-wipe before planning — content, taxonomy, site-author links and every object under the site's media prefix — so a rebuild is one call. It too runs only on the first hop; on a continuation it would delete everything the previous hop just imported. Unlike the asset import, a wipe failure aborts the import, because importing on top of content that was supposed to be gone produces exactly the mixed state the wipe exists to prevent.

A migration names the CMS it targets (AISD-259). target_env is required on POST /migrate_from_wp — there is no default:

target_env cms-api credentials writes prod data
dev /stg/cms-ai-forge/* no
preprod /prd/cms-ai-forge/* yes
prod /prd/cms-ai-forge/* yes
curl -X POST "$FORGE/migrate_from_wp" -H 'Content-Type: application/json' \
  -d '{"website": "fashionradar", "type": "trending", "target_env": "dev"}'

Three things about this are deliberate.

preprod writes production data. It resolves to the same /prd/cms-api/mysql as prod — there is no separate preprod dataset. It exists to validate new code against real data. So both preprod and prod require confirm_writes_prod_data: true, and the refusal message for preprod says so explicitly, because the name alone does not read as dangerous.

Prod is not reachable today, and that is the guard. /prd/cms-ai-forge/* does not exist, so a prod request returns 502 target_not_configured naming the missing parameter. Making prod reachable means provisioning those credentials — a deliberate, reviewable act rather than a request field. Refusals happen at submit time, before a job row exists: an import that dies on its first publish has already told the caller it succeeded.

The target travels on the job, not the process. cfg.CMS_API_BASE_URL is resolved once at import, so a single forge would otherwise write to exactly one cms-api forever. The target is recorded on job.spec.target_env, prefixed onto every job event as [target=<env>], and re-resolved at each of the nine publisher construction sites — the planner, the publish worker, the entity workers and both media generators. A target honoured only in the planner would be worse than none, because the job would report one destination and write to another.

Jobs submitted through POST /jobs without a target keep using the forge's own environment, unchanged.

Requires the forge service account. cms-api's PROVENANCE_ROLES is {forge, super_admin} (AISD-249): authenticated as a plain admin, the importer's creator_source / published_at are silently derived instead of honoured, and imported rows look self-authored.