Read a threaded schedule signal receipt without changing dispatch state.
Lease one target-side signal attempt. A retry waits while the lease is live and replays a settled receipt. After an ambiguous crash, lease takeover repeats the same stable dispatch id: delivery is deliberately at-least-once because the agent action and D1 receipt cannot be committed in one transaction.
Atomically claim one due fire and persist its recoverable dispatch row.
Flowsafe facade create: schedule row, owner row, and the deployment count cap share one D1 transaction. The schedules domain and resource registry must therefore use the same binding.
Insert a new schedule row. Throws if a row with the same id already exists. Returns the stored row.
Delete an authorized facade schedule and its owner in one transaction.
Delete a schedule and its trigger history.
Make terminal-run discard authoritative for the exact leased run. A schedule signal may have observed a suspension and settled a wake just before terminal cleanup acquired the target-thread FIFO. That same-run receipt is safe to replace; unrelated or non-execution receipts fail closed.
Read the exact claimed fire a target Durable Object is allowed to execute. Prepared, executing, and settled are one target-side lease lifecycle; the deferred trigger remains the authority until the tick settles its outcome. A schedule id without its atomically claimed trigger and run id is never an execution capability.
Get a single schedule by id. Returns null if not found.
Initialize the storage domain. This should create any necessary tables/collections. Default implementation is a no-op - override in adapters that need initialization.
List schedules whose nextFireAt <= now and whose status === 'active'.
Used by the scheduler tick loop.
Optionallimit: numberList schedules matching the filter (no pagination — schedule counts are expected to stay small).
Optionalfilter: ScheduleFilterList trigger history for a schedule, newest first.
Optionalopts: ScheduleTriggerListOptionsAppend an entry to a schedule's trigger history.
Persist the target decision before the thread DO returns it to the tick.
Merge tick-owned retry diagnostics into a deferred trigger. Target-side dispatch state can change between the tick's read and this write, so a full-row replacement here would erase the current lease or receipt.
Partial update of a schedule row.
Compare-and-swap update of nextFireAt. Used by the scheduler to claim
a fire before publishing — only one tick across many processes will succeed.
Returns true if the row's nextFireAt matched expectedNextFireAt and
was advanced to newNextFireAt. Returns false if another instance
already advanced it (meaning the caller should skip publishing).
The D1 schedules domain: workflow + agent schedule rows and their trigger history. Mirrors core's
SchedulesStoragecontract exactly (the abstract methodsmastra.schedulesdrives + the scheduler tick reads), so a host that composes it intocreateD1Storage({ domains })gets D1-durable schedules with no adapter change.