VIP-61: Experimental.Trigger and Experimental.WorkQueue: cron triggers and durable queues
Status: accepted by Will, 2026-11-23 — standard library only (no compiler or language changes). Will: "58 I accept. I accept every other language proposal but ones that don't require a change to the language and are purely library functions that don't require compiler changes at all should be marked as such". Implemented in the runtime as Experimental.Trigger and Experimental.WorkQueue.
Will's words
Ok so give me a list of [the reference engine's] features. We need to figure out what the VIP should look like. Some of the features outside of durable execution likely should simply be in the standard library I'm guessing but we should enumerate all of them
Summary
One sentence. Experimental.Trigger starts a workflow on a schedule or from a verified webhook, and Experimental.WorkQueue hands work from a workflow to a pool of workers and parks until one answers.
One paragraph. A workflow needs something to start it and somewhere to send slow work. The reference engine (an existing Effect durable-execution framework these built-ins are modelled on) has both: its triggers package keeps cron triggers as durable rows and decides what an occurrence means when the last run is still going or the host was down, and DurableQueue in its flow package persists a request and its result. This VIP ports both. A trigger is typed by the workflow it starts, so its input is the workflow's parameter tuple. A cron expression runs nothing until a host registers the trigger and drives the scheduler. Effect's own Cron module, in scope today, parses the expressions.
"0 3 * * *" ──► Trigger ──► claim the occurrence ──► start Report("#ops") one run per occurrence, across hosts
│ last run still going? overlap: skip | buffer-one | supersede
│ host was down? catchUp: none | one | all
workflow ──► WorkQueue.process(Renders, job) ── park ──► worker pool ──► result recorded ──► workflow resumesDecision
// proposed
workflow Report {
effect call(channel: string) { return try Post(channel, try Summarize()) }
}
export const nightly = Experimental.Trigger.cron(Report, {
id: "nightly-report",
cron: "0 3 * * *",
timezone: "UTC",
input: ["#ops"],
overlap: "skip",
catchUp: "one"
})
export effect function main() {
provide Experimental.Trigger.layer([nightly]) {
try never
}
}Experimental.Trigger
In scope with no import, as VIP-33 rules. Its code is vibelang-runtime/experimental/Trigger. It ports the reference engine's triggers package.
| Call | Meaning | Reference engine |
|---|---|---|
Trigger.cron(W, options) | Declare a schedule for workflow W. An Effect that fails with TriggerError on a bad expression | Trigger.make |
Trigger.layer(triggers) | Register the triggers and run the scheduler for the life of the scope | SqlTriggerStore, Scheduler |
Trigger.webhook(W, { path, verify, input }) | A verified HTTP door that starts W or sends a signal | Channel, Webhook |
Trigger.fires(id) | The fire ledger for one trigger | DispatchReader |
Options of Trigger.cron:
| Option | Values | Default |
|---|---|---|
id | A stable name | Required |
cron | A five-field expression. One the calendar never satisfies is refused | Required |
timezone | An IANA zone | "UTC" |
input | W's parameter tuple | Required |
overlap | "skip", "buffer-one", "supersede" | "skip" |
catchUp | "none", "one", "all", bounded by maxCatchUp | "none", with maxCatchUp 0 |
enabled | boolean | true |
Rules:
- A trigger is a durable row. Two hosts over one database claim occurrences through a lease.
- One occurrence starts one run. Dispatch is at-least-once: a lease recovery can launch the same occurrence again. The scheduler passes one idempotency key per occurrence, and the engine deduplicates on it, so a retried dispatch joins the run it already started (
agent/triggers/README.md). - Two occurrences are two runs, even with equal input. A plain
try Report("#ops")twice joins one run (durable-tasks-workflows). A trigger's key holds the trigger id and the scheduled instant, so tonight's run is not last night's. - A trigger grants nothing. A scheduled run has the authority a person starting it would have. A webhook's verified payload names a workflow; it cannot widen what that workflow may do.
verifyreceives the raw request bytes before anything is parsed.- Catch-up is bounded. A host that was down for a month launches at most
maxCatchUpmissed occurrences.
Experimental.WorkQueue
It ports DurableQueue from the reference engine's flow package. Effect's Queue and DurableQueue keep their names and meanings.
// proposed
schema RenderJob { page: string }
export const Renders = Experimental.WorkQueue.make("Renders", { payload: RenderJob, success: Schema.String, key: (job) => job.page })
export const RendersWorker = Experimental.WorkQueue.worker(Renders, effect (job) => `<html>${job.page}</html>`, { concurrency: 4 })
export effect function render() {
return try Experimental.WorkQueue.process(Renders, { page: "home" })
}| Call | Meaning | Reference engine |
|---|---|---|
WorkQueue.make(name, { payload, success?, error?, key }) | Declare a queue | DurableQueue.make |
WorkQueue.process(queue, payload) | Offer the payload, park, resume with the worker's result | DurableQueue.process |
WorkQueue.worker(queue, handler, { concurrency }) | A layer that runs the handler for each item | DurableQueue.worker |
keyis required. It scopes an occurrence counter; a replay of the same offer derives the same item.- The queue never drops an item. A delivery that could not start is redelivered.
- Until the handler's exit is recorded, a crash runs the handler again. A handler makes its side effects idempotent.
- The waiting run shows the reason
event, as a signal does. - It is a request and its answer, not a broker. It promises no order across hosts and no batch acknowledgement.
What must be built
The reference engine's scheduler launches through a Runner port, and its Webhook and DispatchReader reach the reference engine's control package, a product. The port keeps the Runner port and supplies one adapter over std-durable's engine. That adapter is new code.
Host needs
A SQL store, which std-durable already provides, a clock, and for webhooks an HTTP server. A scheduler needs a process that stays up or a host that wakes it; a browser tab is neither. Which host qualifies is VIP-54's question.
Maintainers' decisions
This record comes from the 2026-11-09 built-in set review. The Status line above records Will’s subsequent ruling.
- In scope with no import, as VIP-33 rules. Design · Review.
- Its code is
vibelang-runtime/experimental/Trigger. Design · Review. - It ports the reference engine's triggers package. Design · Review.
- Call
Trigger.cron(W, options): Meaning: Declare a schedule for workflowW. An Effect that fails withTriggerErroron a bad expression; Reference engine:Trigger.make. Design · Review. - An Effect that fails with
TriggerErroron a bad expression |Trigger.make| Design · Review. - Call
Trigger.layer(triggers): Meaning: Register the triggers and run the scheduler for the life of the scope; Reference engine:SqlTriggerStore,Scheduler. Design · Review. - Call
Trigger.webhook(W, { path, verify, input }): Meaning: A verified HTTP door that startsWor sends a signal; Reference engine:Channel,Webhook. Design · Review. - Call
Trigger.fires(id): Meaning: The fire ledger for one trigger; Reference engine:DispatchReader. Design · Review. - Options of
Trigger.cron: Design · Review. - Option
id: Values: A stable name; Default: Required. Design · Review. - Option
cron: Values: A five-field expression. One the calendar never satisfies is refused; Default: Required. Design · Review. - One the calendar never satisfies is refused | Required | Design · Review.
- Option
timezone: Values: An IANA zone; Default:"UTC". Design · Review. - Option
input: Values:W's parameter tuple; Default: Required. Design · Review. - Option
overlap: Values:"skip","buffer-one","supersede"; Default:"skip". Design · Review. - Option
catchUp: Values:"none","one","all", bounded bymaxCatchUp; Default:"none", withmaxCatchUp0. Design · Review. - Option
enabled: Values: boolean; Default:true. Design · Review. - Rules: Design · Review.
- A trigger is a durable row. Two hosts over one database claim occurrences through a lease. Design · Review.
- One occurrence starts one run. Dispatch is at-least-once: a lease recovery can launch the same occurrence again. Design · Review.
- The scheduler passes one idempotency key per occurrence, and the engine deduplicates on it, so a retried dispatch joins the run it already started (
agent/triggers/README.md). Design · Review. - Two occurrences are two runs, even with equal input. A plain
try Report("#ops")twice joins one run (durable-tasks-workflows). Design · Review. - A trigger's key holds the trigger id and the scheduled instant, so tonight's run is not last night's. Design · Review.
- A trigger grants nothing. A scheduled run has the authority a person starting it would have. Design · Review.
- A webhook's verified payload names a workflow; it cannot widen what that workflow may do. Design · Review.
verifyreceives the raw request bytes before anything is parsed. Design · Review.- Catch-up is bounded. A host that was down for a month launches at most
maxCatchUpmissed occurrences. Design · Review. - It ports
DurableQueuefrom the reference engine's flow package. Design · Review. - Effect's
QueueandDurableQueuekeep their names and meanings. Design · Review. - Call
WorkQueue.make(name, { payload, success?, error?, key }): Meaning: Declare a queue; Reference engine:DurableQueue.make. Design · Review. - Call
WorkQueue.process(queue, payload): Meaning: Offer the payload, park, resume with the worker's result; Reference engine:DurableQueue.process. Design · Review. - Call
WorkQueue.worker(queue, handler, { concurrency }): Meaning: A layer that runs the handler for each item; Reference engine:DurableQueue.worker. Design · Review. keyis required. Design · Review.- It scopes an occurrence counter; a replay of the same offer derives the same item. Design · Review.
- The queue never drops an item. Design · Review.
- A delivery that could not start is redelivered. Design · Review.
- Until the handler's exit is recorded, a crash runs the handler again. Design · Review.
- A handler makes its side effects idempotent. Design · Review.
- The waiting run shows the reason
event, as a signal does. Design · Review. - It is a request and its answer, not a broker. Design · Review.
- It promises no order across hosts and no batch acknowledgement. Design · Review.
- The reference engine's scheduler launches through a
Runnerport, and itsWebhookandDispatchReaderreach the reference engine's control package, a product. Design · Review. - The port keeps the
Runnerport and supplies one adapter over std-durable's engine. Design · Review. - That adapter is new code. Design · Review.
- A SQL store, which std-durable already provides, a clock, and for webhooks an HTTP server. Design · Review.
- A scheduler needs a process that stays up or a host that wakes it; a browser tab is neither. Design · Review.
- Which host qualifies is VIP-54's question. Design · Review.
Adopted review answers
- Keep
Experimental.Xnames under VIP-33. Promotion to a bare module name requires a later decision. Review question 1. - Each trigger occurrence creates its own run even when inputs are equal; ordinary equal-input workflow calls join the first run, and
W.startexplicitly starts another. Review decision.
Compared
The trigger in the reference engine 1.x. It type-checks against the reference engine's triggers package 1.0.0-rc.16.
import * as Trigger from "@smthrs/triggers/Trigger"
export const nightly = Trigger.make({
id: "nightly-report",
flowId: "reports/nightly",
input: { channel: "#ops" },
cron: "0 3 * * *",
timezone: "UTC",
overlap: "skip",
catchUp: "one",
maxCatchUp: 1,
enabled: true
})| Program | Vibe, proposed | Reference engine 1.x |
|---|---|---|
| The trigger, with a one-line target on the Vibe side | 76 tokens, 12 lines | 92 tokens, 13 lines |
The queue, its worker and one process call | 98 tokens, 9 lines | 119 tokens, 13 lines |
Tokens are o200k_base. The counts are close because a trigger is already a small record. The gain is typing: the reference engine names the flow by a string, flowId, and takes input as untyped JSON. Trigger.cron(Report, …) takes the workflow, and a wrong input is a type error.
Checked. Trigger.cron compiles under vibelang 0.0.13 against a declaration of the proposed module, with an effect function standing in for the workflow, and the compiler infers input as the target's parameter tuple. The queue example compiles the same way. workflow is new. Both reference engine programs type-check. The overlap and catchUp values and their defaults are read from agent/triggers/src/Schedule.ts.
Principles
- TypeScript-first. Function calls over a record.
- Effect-second. Effect's
Cronparses and steps the expressions; the reference engine'sCronmodule is "typed wrappers around Effect's cron". Effect also hasClusterCron, which fires on a cluster singleton and has no overlap policy, catch-up or fire ledger. - Optimized for agentic programs. A nightly agent run and a webhook-started run are a few lines each.
- Highly forkable. A fork adds a trigger kind by adding a function that starts a workflow.
- Factory-first. The factory's scheduled reviews are triggers in its source.
What this changes
Experimental.TriggerandExperimental.WorkQueueare new.- Nothing in the grammar.
Alternatives
- A
cronmember onworkflow, such asstatic readonly cron = "0 3 * * *". One workflow often has several schedules with different inputs, and a schedule is deployment, not definition. - Effect's
ClusterCron. It needs a cluster and decides nothing about overlap or downtime. - A queue as a
taskwith a concurrency member. It hides that the work runs in another process with its own delivery guarantees. - Leave triggers to the reference engine. Its CLI manages schedules. A program that ships as a library needs to declare its own.
Follow-up questions
- A workflow the file cannot import. A trigger for a workflow deployed elsewhere needs a string. Recommendation: accept
Trigger.cron("reports#Nightly", { input })withinputtypedunknownand checked against the workflow's schema when it is registered. - Webhook verification presets. The reference engine ships the verify-then-map door, not GitHub or Stripe verifiers. Should the standard library? Recommendation: no; those are integrations.
- A changed schedule. When a trigger's expression changes, are its missed occurrences kept or dropped? Recommendation: dropped, and the change is recorded in the fire ledger.
Depends on
- durable-tasks-workflows: what a trigger starts.
- std-durable: the store and the engine.
- durable-waits: a webhook that sends a signal.