Skip to content

Roadmap: portable durable scheduling #37

Open

Description

@cardmagic

PRD: portable durable scheduling — remaining work

Status: Partially implemented
Owner: Solid Objects maintainers

Reminders now cover most of the original scope in both JS adapters. This description has been rewritten to the parts that are not done, so nobody re-implements what shipped. The shipped portion is recorded at the bottom.

Remaining requirements

  • SCHED-005 (partial): A skip missed-run policy shall exist, dropping missed occurrences and waiting for the next scheduled time. latest (run once for a missed window) and all (catch up on every missed occurrence) already exist. Decided (Lucas, 29 Nov 2026): keep the public names latest and all, and add skip. Do not rename. Document that latest is the original PRD's run_once and all is catch_up. Adding skip also changes the SQL missed_policy check constraint and the Durable Objects stored missed value.

  • SCHED-007 (partial): Inspection shall return status, next run, last run, attempt, and failure information without mutating actor state. Status and next run already exist on the actor-facing ScheduledReminder. Decided (Lucas, 29 Nov 2026): add the three remaining fields to ScheduledReminder on both JS adapters. reminder() and reminders() stay a read.

    • lastRunAtMilliseconds, or null 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. Neither adapter stores it today. SQL needs a column. The Durable Objects Reminder record needs a field.
    • occurrence, the number of times this reminder has been enqueued. Document it as the original PRD's "attempt". Do not expose Durable Objects generation on the actor API; it is a UUID that changes on schedule and on resume, not a count. Do not put the mailbox retry count on ScheduledReminder; retries stay on the message. SQL already stores occurrence, and operator-facing ReminderRecord already exposes it. Durable Objects stores no count today and needs one. JS docs/api.md currently says ScheduledReminder omits an occurrence count because SQL tracks one and Durable Objects does not. That sentence changes once both adapters store and return it.
    • errorName, or null, the error that paused the reminder, matching operator-facing ReminderRecord. SQL writes error when firing fails because the operation is unknown. Durable Objects pauses the reminder when the mailbox message is exhausted or too large, and stores no error. Both adapters must write errorName when they pause a reminder. Mailbox retries and dead letters stay on the message.
    • On replace: keep lastRunAtMilliseconds and occurrence, and clear errorName. SQL already keeps occurrence and clears error on replace. Durable Objects currently overwrites the whole record, so it must keep those two.

Remaining acceptance criteria

  • One conformance suite across adapters covering create, replace, cancel, recurring execution, the missed-run policies latest, all, and skip, actor-facing lastRunAtMilliseconds, occurrence, and errorName (a replace keeps the first two and clears errorName), restart recovery, that a fired reminder still runs when authorizeMessage returns false while an external enqueue of the same operation still goes through authorizeMessage, and duplicate delivery. Today SQL and Durable Objects scheduling are tested separately. test/support/portable-runtime-contract.ts exercises no scheduling at all.
    • Both latest and all exist in code on both adapters. The Durable Objects recovery test covers latest only. No Durable Objects test found covers all catching up every missed occurrence.
    • SQL tests recover a reminder claimed by a stale process, and reject an unknown reminder operation before persistence. No test found covers that a fired reminder still runs when authorizeMessage returns false, that an external enqueue of the same operation still goes through authorizeMessage, or that a fired reminder is not delivered twice. Both adapters enqueue the fired reminder with an idempotency key, which is what would suppress a duplicate.
    • This is the highest-value item left on this issue.
  • Document the timing contract. Decided (Lucas, 29 Nov 2026): document what the code does today. Do not invent a time zone or clock-skew guarantee. JS schedule({ at }) stores at.getTime() as epoch milliseconds and compares that with the runtime's now. 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 JS or Ruby docs. This issue does not add a Ruby docs change.

Not planned

  • reschedule(handle, { runAt }) as a distinct method. SCHED-002 is satisfied: scheduling an existing name replaces its next occurrence atomically, and the repository reports the replacement with its previous run time. A second spelling of that would add surface without adding capability. Reopen if the ergonomics prove otherwise.
  • A return value from unschedule / unscheduleAll that reports whether a schedule was removed (SCHED-003). Cancellation stays an intent that returns nothing, 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 implemented, for reference

  • SCHED-001 schedule({ at:, every:, missed:, key: }) returns a durable handle in both JS adapters.
  • SCHED-002 A name identifies at most one active schedule per actor, and rescheduling replaces the next occurrence atomically.
  • SCHED-004 One-shot and recurring schedules, cancellable by operation, by key, or by handle.
  • SCHED-006 A fired reminder enqueues an internal mailbox message, so it inherits mailbox ordering, retry, dead letters, and deduplication. Decided (Lucas, 29 Nov 2026): the fire does not call authorizeMessage. Internal delivery skips it, as JS docs/api.md already says. An external enqueue of the same operation still goes through authorizeMessage. The 5 Sep PRD said schedule execution shall use normal mailbox authorization; that check at fire time is not what shipped. The idempotency key is reminder:<id>:<occurrence> on SQL and reminder:<generation>:<at> on Durable Objects. Callers should not assume those keys have the same shape.
  • SCHED-008 Restart recovery on both JS adapters. The SQL scheduler claims due reminders from the reminders table, including a reminder whose claim owner is gone. Durable Objects does not re-arm an alarm in the host constructor. alarm() runs a pump, and the storage layer sets or deletes the alarm from due work after a pass. If that pump fails, the host sets an alarm at most 30 seconds out.
  • Docs. JS docs/api.md, merged in PR #97, says unschedule() returns nothing because it stages an intent rather than applying one, and that reminder / reminders answer whether an alarm is present, including this turn's staged cancels and schedules. Cancellation still returns nothing (see Not planned). Ruby docs/reminders.md already said both reads include the current turn's staged changes and does not repeat the old rationale.
  • The same actor scheduling API runs over SQL polling, PostgreSQL and Redis wake-up, and Durable Object alarms. No caller names the mechanism.

Activity

  1. added
    enhancement
    on Sep 5, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions