Standing Order Agent / Module 06
Module 06

Cron starts the work. A durable workflow finishes it.

User schedules live as dynamic application data. A small static dispatcher finds due occurrences, deduplicates them in PostgreSQL, and enqueues resumable order-cycle jobs.

1 mindispatcher interval
1unique occurrence key
weekly cadence supported
0lost jobs after restart
Dispatch

How a recurring order becomes a job

Scheduling and jobs module
Scheduling and jobs module
A static dispatcher locks due schedules, creates a unique occurrence, advances timezone-aware recurrence, and writes the job outbox in one transaction.
Transaction

Seven steps prevent duplicates

  1. 01

    Trigger

    Graphile Worker runs dispatch_due_schedules every minute.

  2. 02

    Lock

    Select due schedule rows with FOR UPDATE SKIP LOCKED.

  3. 03

    Calculate

    Resolve the occurrence in the schedule’s IANA timezone, including daylight-saving behavior.

  4. 04

    Create

    Insert the order cycle with a unique constraint on schedule ID and occurrence time.

  5. 05

    Publish

    Write the job outbox in the same transaction as the new order cycle.

  6. 06

    Advance

    Calculate and store the next occurrence, respecting skip, pause, and exceptions.

  7. 07

    Execute

    Enqueue the order-cycle ID as the durable idempotency key.

Job catalog

Small jobs with explicit retry semantics

TaskPurposeRetry
dispatch_due_schedulesCreate unique due occurrencesSafe; transaction and unique key deduplicate
prepare_order_cycleResume the order workflowStep-aware; reconcile live cart before writes
send_notificationDeliver one domain-event messageSafe with event ID idempotency
expire_reviewExpire stale snapshot and release resourcesSafe if current state still awaits review
retailer_smoke_checkDetect selector or schema driftRead-only and rate-limited
!
Checkout is never a normal retry

A transient error before checkout may retry after reconciliation. An ambiguous response after a final action becomes checkout_unknown and requires manual verification.