# Weekly Sermon Capture — Cron Configuration
# Location: ~/.openclaw/cron/sermon-schedule.yaml
#
# This cron fires a task message to Dorian (main agent).
# Dorian classifies it as Path C → Systems Architect → Worker.
# No custom agent. No manual routing flags needed.
# Completion notification flows via ops-maintainer → Telegram.

name: "weekly-sermon-capture"
schedule: "0 7 * * 0"          # Sunday 7:00 AM
timezone: "America/Los_Angeles" # Adjust if needed

# The message delivered to Dorian at trigger time.
# Written to match Dorian's classification rules:
# "Automation design, Notion workflows, integrations → Systems Architect"
task_message: |
  CRON TASK — weekly-sermon-capture
  execution_date must be injected into the Lobster run via --args-json.
  Do not derive it inside workflow YAML or shell env.

  Run the weekly sermon capture workflow:
  1. Fetch https://richfieldcc.churchcenter.com/home
  2. Extract sermon notes, life group questions, and worship folder URLs
  3. Fetch content from all three resource URLs
  4. Call the LLM once (combined) to extract scripture, outline notes,
     and generate questions ordered by increasing depth
  5. Create a new page in Notion Notes DB, Area = Bible,
     Title = "Sermon @Now - [execution_date]"
  6. Relay completion status to Braden via Telegram

  Worker contract: ~/.openclaw/workspace/contracts/sermon-worker-contract.yaml
  Lobster workflow: ~/.openclaw/workflows/sermon-automation.lobster
  Invocation shape:
    lobster run --file ~/.openclaw/workflows/sermon-automation.lobster \
      --args-json '{"execution_date":"YYYY-MM-DD"}'

# Runtime environment
env:
  NOTION_BIBLE_DB_ID: "${NOTION_BIBLE_DB_ID}"   # Set in ~/.openclaw/.env

# Cron delivers output directly to Telegram channel (ops-maintainer relay).
# Does NOT feed back into the main session conversation history.
output_channel: "telegram"

# Retry policy
retry:
  max_attempts: 2
  backoff_seconds: 300   # 5 min between attempts

# Failure handling
on_failure:
  notify: true
  channel: "telegram"
  message: |
    ❌ weekly-sermon-capture FAILED
    Execution date: check the Lobster args-json payload for this run
    Error: ${ERROR_MESSAGE}
    Step: ${FAILED_STEP}
    Manual action required.
