Skip to main content

Deployment

AI SpendOps deploys three Cloudflare Workers across two environments, with CI/CD via GitHub Actions.

Workers

WorkerDev NameProd Name
Proxyaispendops-proxy-devaispendops-proxy-prod
Usage Consumeraispendops-usage-consumer-devaispendops-usage-consumer-prod
Denial Consumeraispendops-denial-consumer-devaispendops-denial-consumer-prod

All workers are deployed from the LumatechUK/AI SpendOps-proxy monorepo.

CI/CD

GitHub Actions

TriggerTargetBehaviour
Push to mainDevAuto-deploy all changed workers (path-filtered)
Manual dispatchProdRequires manual approval via GitHub Actions workflow dispatch

Path filtering ensures that a change to apps/proxy-worker/ only redeploys the proxy worker, not the consumers (and vice versa).

Deployment Steps

  1. Install dependencies (npm ci)
  2. Run type checking and linting
  3. Run unit tests
  4. Deploy via wrangler deploy with environment-specific config
  5. Post-deploy smoke test (health check endpoint)

KV Namespaces

EnvironmentNamespace IDContents
Deve9ceb...API key policies, pricing blob, pricing version, tenant overrides, missing model flags
Prodb3580...Same structure as Dev

Each environment has its own isolated KV namespace. Data is never shared between environments.

Key Patterns

PatternExamplePurpose
key:{hash}key:a1b2c3d4...API key policy (HMAC hash lookup)
pricing:blobFull pricing data blob
pricing:versionCurrent pricing version number
pricing:tenant:{tid}pricing:tenant:t_abc123Tenant pricing overrides
missing:{provider}:{model}missing:openai:gpt-5-turboFlagged missing model (written once)

Queues

QueueEnvironmentProducerConsumer
usage-events-devDevProxy (dev)Usage Consumer (dev)
usage-events-prodProdProxy (prod)Usage Consumer (prod)
denial-events-devDevProxy (dev)Denial Consumer (dev)
denial-events-prodProdProxy (prod)Denial Consumer (prod)

Queue settings (max batch size, max retries, visibility timeout) are configured in each worker's wrangler.toml.

Shared Resources

Some resources are shared across environments:

ResourceDetails
ClickHouseSingle database. Events are tagged with env field (dev or prod).
Azure SQLSingle database. Tenant/key/pricing data shared (management plane does not differentiate by environment).
Azure FunctionsCloudflarePricingSync, BudgetAlertEvaluator, ExchangeRateSync — each targets the appropriate KV namespace based on configuration.