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.local with SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN
  • At least one AI key: OPENAI_API_KEY or ANTHROPIC_API_KEY
  • CRON_SECRET set in .env.local
  • EVERGREEN_ENABLED=true in .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: true with 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

Back to index