Skip to content

Remaining reminder scheduling: skip, last run, and failure #103

Done

Description

@cardmagic

Problem

Ruby reminders already cover one-shot and recurring schedules, missed: :latest and missed: :all, cancellation, and inspection. Three parts of that surface are still missing. They are the Ruby counterpart of the remaining work on solid-objects-js#37.

On origin/main (80523e7):

  • There is no skip missed-run policy. schedule raises unless missed is all or latest, and the reminders table check allows only 'latest' and 'all'.
  • ReminderStatus has occurrence, status, and next_run_at. It does not have last run. The reminders table has no last-run column.
  • ReminderStatus has no failure information. The reminders table allows status 'paused', but nothing writes it. If the scheduler cannot enqueue because the operation is unknown, it raises UnknownMessage, releases the claim, and leaves the reminder scheduled.

Proposed API

Keep the public names latest and all. Add skip. Do not rename. Document that latest coalesces missed occurrences (the JS PRD's run_once) and all enqueues each missed occurrence (the JS PRD's catch_up). Default when missed is omitted stays latest. schedule accepts missed: :skip or "skip". Adding skip also changes the reminders missed_policy check constraint.

reminder and reminders stay a read. They still include this turn's staged intents. Add two fields to ReminderStatus:

  • last_run_at, or nil if the reminder has never been enqueued. This is the time the runtime last enqueued the reminder as a mailbox message, not when that operation finished. The reminders table does not store it today.
  • error_class, or nil, the error class that paused the reminder. Mailbox retries and dead letters stay on the message. Do not put the mailbox retry count on ReminderStatus.

occurrence stays as it is. It is the number of times this reminder has been enqueued.

Semantics

  • skip. A skip missed-run policy drops missed occurrences and waits for the next scheduled time.
  • On replace. Keep last_run_at and occurrence, and clear error_class. Today a replace already keeps occurrence and sets status to "scheduled".
  • Pause on unknown operation at fire. When the scheduler cannot enqueue because the operation is unknown, pause the reminder and record error_class. Do not leave the reminder scheduled. Mailbox failure of an already enqueued occurrence does not pause the reminder. Retries and dead letters stay on the message. This issue does not add a resume API.
  • Fire authorization. A fired reminder stays an internal mailbox message. Internal deliveries do not call authorize_message, as docs/authorization.md already says. An external enqueue of the same operation still goes through authorize_message.
  • Timing contract. Document what the code does today. Do not invent a time zone or clock-skew guarantee. schedule(at:) stores at as next_run_at. The scheduler treats a reminder as due when next_run_at is on or before the test now if one is passed, otherwise database_now, which reads the database clock and converts that value to UTC. Retry and retention of a fired reminder follow the mailbox message it enqueued. Time zone and clock skew are not a documented guarantee in the Ruby docs today.

Acceptance

Cover create, replace, cancel, recurring execution, the missed-run policies latest, all, and skip, actor-facing last_run_at, occurrence, and error_class (a replace keeps the first two and clears error_class), that an unknown operation at fire pauses the reminder and records error_class, restart recovery, that a fired reminder still runs when authorize_message returns false while an external enqueue of the same operation still goes through authorize_message, and duplicate delivery.

Ruby has one runtime, not the JS SQL and Durable Objects adapters. This is not a second copy of the JS conformance suite.

Not planned

  • A distinct reschedule method. Scheduling an existing name already replaces its next occurrence. Reopen if the ergonomics prove otherwise.
  • A return value from unschedule / unschedule_all that reports whether a schedule was removed. Cancellation stays an intent that returns nil, matching Orleans UnregisterReminder and Durable Objects deleteAlarm. Whether an alarm is present is answered by reminder / reminders, which already include this turn's staged intents. Reopen if a caller cannot get that answer from the read.

Already on main

On origin/main (80523e7):

  • schedule(at:, every:, missed:, key:) returns a durable handle. missed is latest or all.
  • A name identifies at most one active schedule per actor. Scheduling an existing name replaces it. A replace keeps occurrence.
  • One-shot and recurring schedules, cancellable by operation, by key, or by handle. unschedule and unschedule_all return nil.
  • ReminderStatus already has name, operation, key, next_run_at, interval_seconds, missed_policy, occurrence, status, and handle.
  • A fired reminder enqueues an internal mailbox message with idempotency key reminder:<id>:<occurrence>, so it inherits mailbox ordering, retry, dead letters, and deduplication. Internal delivery does not call authorize_message.
  • The scheduler claims due scheduled reminders, including a reminder whose claim owner is gone.
  • docs/reminders.md already says reminder and reminders include the current turn's staged changes. docs/authorization.md already says internal reminder deliveries do not re-enter the public client policy.

JavaScript counterpart

solid-objects-js#37 is the JS remaining-work issue. This issue is the Ruby counterpart of that remaining work, in Ruby names (ReminderStatus, last_run_at, error_class, Time). It is not a line-by-line port.

Activity

  1. cardmagic commented on Dec 2, 2026

    @cardmagic
    OwnerAuthor

    Completed by #110, shipped in v1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions