Local AI Deployment Lock
Section titled “Local AI Deployment Lock”NutsNews Worker shards must use the home-server local AI provider first.
This lock exists because a Worker deploy without AI_PROVIDER=local, LOCAL_AI_URL, and the LOCAL_AI_API_KEY secret binding silently behaves like an OpenAI deployment. That creates unexpected OpenAI usage and hides local-server configuration mistakes.
What changed
Section titled “What changed”npm run generate:wranglernow refuses to generate production shard configs unless local AI is complete.npm run deploy:allnow runs the local-AI config verifier before deploying shards.AI_PROVIDER_FALLBACK_TO_OPENAI=trueis required by default.- Article reviews and summary translations no longer fall back to OpenAI when fallback is enabled.
- CI runs a local-AI deployment-lock regression.
- CI runs an immutable-test guard so locked regression tests cannot be edited later without explicit owner approval.
Required deploy environment
Section titled “Required deploy environment”Create worker/.env.deploy.local from worker/.env.deploy.example:
cd workercp .env.deploy.example .env.deploy.localSet these values:
NUTSNEWS_SECRETS_STORE_ID=...NUTSNEWS_KV_NAMESPACE_ID=...AI_PROVIDER=localLOCAL_AI_URL=https://your-local-ai-tunnel.example.comLOCAL_AI_MODEL=qwen2.5:3bAI_PROVIDER_FALLBACK_TO_OPENAI=trueAI_REVIEW_CONCURRENCY=1ENABLE_LOCAL_AI_SECRET_BINDING=trueLOCAL_AI_API_KEY_SECRET_NAME=LOCAL_AI_API_KEYThe LOCAL_AI_API_KEY value itself must live in Cloudflare Secrets Store. The Worker config only binds the secret name.
Safe deploy command
Section titled “Safe deploy command”cd workernpm run check:local-ai-confignpm run deploy:alldeploy:local-ai is kept as an alias for deploy:all.
Emergency OpenAI-only deploy
Section titled “Emergency OpenAI-only deploy”OpenAI-only deploys are blocked by default. Use this only after explicit owner approval:
cd workerNUTSNEWS_ALLOW_OPENAI_ONLY_DEPLOYMENT=true npm run deploy:openai-onlyOpenAI fallback for a local-AI deployment is also blocked by default. Use this only after explicit owner approval:
cd workerNUTSNEWS_ALLOW_OPENAI_FALLBACK_DEPLOYMENT=true AI_PROVIDER_FALLBACK_TO_OPENAI=true npm run deploy:allVerification after deploy
Section titled “Verification after deploy”Call one shard manually:
curl "https://nutsnews-worker-0.nutsnews.workers.dev/?limit=1&imageLookups=1"Look for:
aiProviderislocalaiReviewProviderOrderis["local"]localAiConfiguredistrueopenAiFallbackEnabledisfalselocalAiCallCountis greater than0when a story reaches AI reviewopenAiCallCountis0estimatedOpenAiCostUsdis0
If aiReviewedCount is 0, the shard did not need AI for that run. Try another shard or increase the manual limit.
Regression tests
Section titled “Regression tests”cd workernpm run test:local-ai-locknpm run test:e2e:offlinenpm run test:immutableThe offline E2E test already asserts aiProvider === "local" and openAiCallCount === 0.
