Skip to content

Configuration

Runtime configuration is resolved in config/cfg.py from AWS Secrets Manager via fs_config, selected by the ENVIRONMENT variable. The forge is standalone: it owns its own MySQL DB and never imports hq.sql_models.

Environment selection

ENVIRONMENT Secrets prefix AWS / broker / MySQL
prd /prd/... live
stg /stg/... live
local /stg/... offline fallbacks (dev convenience -- points at stage)
test none fully offline; SQLite + memory:// broker; Celery eager

ENVIRONMENT unset defaults to prd (deploy-safe: an instance with no explicit env var behaves like production rather than silently falling through to staging). test and local never touch AWS, RabbitMQ, or a live MySQL.

Real generation vs stubs (critical)

Deployed environments generate for real by default

In stg / prd, providers default to REAL -- a scaffold or article run generates real content, images, logo, and favicon with no env var to set, and real jobs cost money.

The stub gate is PROVIDER_STUBS_ENABLED (FORGE_PROVIDER_STUBS):

  • Stubs OFF (default in stg/prd): real providers. Deterministic behavior is opt-in only.
  • Stubs ON: set FORGE_PROVIDER_STUBS=1 (or true) -- a no-network, no-key deterministic path (placeholder images, context-derived text).
  • Forced ON under ENVIRONMENT=test: the suite/CI never make paid provider calls. This guard must not be removed.

account_id is required for real jobs

Every real (non-stub) job that calls an AI provider must pass an account_id -- the OpenAI account id from the harvester ai_accounts table. On stage the account id is 3468.

  • Precedence: spec.account_id → defaults.account_id → defaults.text.account_id → configured fallback. If none resolves, the OpenAI path raises a clear error (it never guesses a credential).
  • The real key is read from the harvester ai_accounts rows at call time (generation/ai_accounts.py), keyed by account_id, and is never stored in the forge DB or config module.
  • Under stubs the account_id is not resolved (the offline suite stays key-free).

Anthropic (Claude) creds live at CLAUDE_CREDENTIALS_REF = /common/cms-ai-forge/anthropic (env-independent -- identical for prd + stage), resolved inside ClaudeProvider's graceful try/except. Claude is reserved for a later code-gen phase and is not the content default.

Secret / parameter paths

Documented, never hardcoded values (<env> is prd or stg):

Purpose Path
Forge MySQL SM /<env>/cms-ai-forge/mysql
RabbitMQ (broker) SM /<env>/shared/rabbitmq
Redis (Celery result backend, for the image chord) SM /<env>/shared/redis
cms-api service account SM /<env>/cms-ai-forge/service-account
cms-api base URL SSM /<env>/cms-ai-forge/cms-api-url
Harvester MySQL (read-only ai_accounts source) SM /<env>/mysql/skynet-harvester
WordPress DB (read-only, wp_import) SM /common/wordpress-db
Anthropic / Claude key SM /common/cms-ai-forge/anthropic
OpenAI (text + images) via the harvester ai_accounts rows (account_id)

Scheduled content refresh (Phase 4, AISD-154)

Env-driven (not a secret), OFF by default. The Celery-beat entry forge-content-refresh is registered only when enabled, so stg/prd opt in explicitly and CI/test never auto-fire paid content jobs.

Env var Default Meaning
FORGE_CONTENT_REFRESH_ENABLED 0 (off) 1/true registers the beat entry
FORGE_CONTENT_REFRESH_INTERVAL_SECONDS 86400 (daily) cadence in seconds
FORGE_CONTENT_REFRESH_SPECS [] JSON list of {site, spec, defaults} to enqueue each tick

Each tick creates one content_refresh job per configured site-spec; the planner expands it as an article_batch, so the ledger + (site_id, slug) dedup make each tick idempotent. Malformed JSON / a non-integer interval warn and fall back rather than crashing the worker.

Example FORGE_CONTENT_REFRESH_SPECS:

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