Skip to content

ADR 0005: Cloudflare primitives for files, jobs and schedules ​

  • Status: Accepted
  • Date: 2026-11-18
  • Spec version: 1.0.0

Context ​

Footage and edits are large. Research and video processing exceed Worker CPU limits. The agency needs reminders, timeouts and generated events at specific times.

Decision ​

  • R2 for all large files. Browser uploads go straight to R2 with presigned multipart URLs; downloads use short-lived signed links. D1 never stores file bodies.
  • Queues for jobs (jobs, with a jobs-dlq dead-letter queue and 3 retries). Messages are versioned envelopes with idempotency keys.
  • Cron Trigger every 15 minutes for sweeps that find due work from data.
  • All of it provisioned in packages/infra/alchemy.run.ts; the server Worker exports fetch, scheduled and queue.
  • Cloudflare Workflows are an option for a multi-step job that needs durable state; not adopted yet.

Consequences ​

  • Jobs and sweeps must be idempotent; a retry or a re-run changes nothing.
  • Deadline-driven actions (lock scripts, auto-approve) can lag by up to one cron interval. Acceptable; raise the frequency if not.
  • Presigning requires R2 S3 credentials as secrets and a bucket CORS rule (milestone 7).
  • Heavy processing calls an external service from a job.

Revisit when ​

A sweep needs sub-minute precision (use Durable Object alarms or Workflows), or Queues pricing/limits stop fitting the volume.

Internal documentation. Not for clients.