4. Generate Evergreen Facts
Purpose: Trigger the evergreen pipeline to generate timeless AI-created facts distributed across active topic categories. Runs daily via cron or manually for testing.
Prerequisites:
.env.localwithSUPABASE_URL,SUPABASE_SERVICE_ROLE_KEY,UPSTASH_REDIS_REST_URL,UPSTASH_REDIS_REST_TOKEN- At least one AI key:
OPENAI_API_KEYorANTHROPIC_API_KEY CRON_SECRETset in.env.localEVERGREEN_ENABLED=truein.env.local- Active topic categories with schemas in the database
Cost / Duration: ~$1 AI cost | ~2 min
Prompt
Generate evergreen facts via the daily pipeline.
Step 1 — Set environment variables:
```bash
# In .env.local ensure these are set:
# EVERGREEN_ENABLED=true
# EVERGREEN_DAILY_QUOTA=20
```
Step 2 — Start the worker-facts consumer:
```bash
bun run dev --filter=@eko/worker-facts
```
Step 3 — Start the worker-validate consumer:
```bash
bun run dev --filter=@eko/worker-validate
```
Step 4 — Trigger the cron endpoint:
```bash
curl -X POST http://localhost:3000/api/cron/generate-evergreen \
-H "Authorization: Bearer $CRON_SECRET"
```
This enqueues GENERATE_EVERGREEN messages for each active topic category,
distributing the daily quota proportionally. In production, this runs
automatically at 3am UTC daily.
Verify: Check the response and worker logs.
```bash
curl -s http://localhost:3000/api/cron/generate-evergreen \
-X POST \
-H "Authorization: Bearer $CRON_SECRET" | jq .
```
Expected: `{ "success": true, "topics": <N>, "dailyQuota": 20, "enqueued": <N> }`
Check worker logs for:
- `Processing GENERATE_EVERGREEN` (worker-facts)
- `Fact record validated` or `Fact record rejected` (worker-validate)
- `GENERATE_CHALLENGE_CONTENT complete` (worker-facts, post-validation)
Verification
- Cron endpoint returns
success: truewith correct topic count - Worker-facts processes GENERATE_EVERGREEN messages
- Worker-validate validates generated facts
- Challenge content is generated for validated facts
- No AI generation errors in worker logs
Related Prompts
- Backfill Summaries — Backfill summaries for events
- Content Cleanup Pass — Clean up generated content