Skip to content

feat(void): add Cloudflare Workflows through a workflows/ convention - #918

Draft
isakgustavsen wants to merge 2 commits into
voidzero-dev:mainfrom
isakgustavsen:feat/workflows
Draft

isakgustavsen wants to merge 2 commits into
voidzero-dev:mainfrom
isakgustavsen:feat/workflows

Conversation

@isakgustavsen

@isakgustavsen isakgustavsen commented Nov 25, 2026 •

Copy link
Copy Markdown

Closes #779

Adds Cloudflare Workflows to native Void apps, defined like Durable State and discovered like queues.

// workflows/onboarding.ts
import { defineWorkflow } from 'void/workflows';

export const Onboarding = defineWorkflow<{ userId: string }>({
  async run(event, step) {
    await step.do('send welcome email', () => sendWelcome(event.payload.userId));
    await step.sleep('wait a day', '1 day');
    await step.do('send tips', () => sendTips(event.payload.userId));
  },
});
export default Onboarding;

// routes/api/signup.ts
const instance = await Onboarding.create({ params: { userId } });

What it adds

  • void/workflows (server-only): defineWorkflow({ name?, params?, run }) and defineWorkflowEntrypoint({ name?, class }) for native WorkflowEntrypoint classes, mirroring defineDurableState / defineDurableObject. The returned definition has create(), createBatch() and get(), each also accepting an explicit Workflow binding first, like get(namespace, name) on Durable Objects.
  • Params validation: an optional Standard Schema params validates before create() / createBatch(). run receives the parsed type, and invalid params throw WorkflowParamsError with { message, path } issues.
  • Naming: workflows/send-welcome.ts becomes the WORKFLOW_SEND_WELCOME binding (prefix, like QUEUE_*) and the SendWelcomeWorkflow class. Subdirectories join with - (order/notifications.ts → order-notifications), and paths with a _-prefixed segment are ignored, as in queues/. Optional static name pins identity, and void info reports it.
  • Direct Cloudflare deploys name each Workflow <worker>-<resource>, since Workflow names are account-scoped. The deploy passes the Worker name to the build, and the emitted workflows set is pinned before the build and verified before upload. An authored cloudflare.workflows entry with the same binding and class keeps its name. Workflows are on Workers Free.
  • Unsupported targets fail clearly: Void platform deploys, framework adapter mode and Node targets reject workflows/ with an actionable error for now.
  • Binding inference scans workflows/ (including _ helpers and subfolders), so a Workflow that is the only user of void/db, void/kv and similar still gets the binding.
  • Startup guard (also for durable-objects/): the generated Worker entry imports convention modules through their namespace and fails startup with a named error when a file does not default-export a definition.
  • Docs: guide, API reference, resource inference, structure, CLI info, skill index and package AGENTS.md.

Testing

  • Unit: scanner (nested paths, _ ignore, collisions), config merge, runtime API and types, entry compilation, void info.
  • Integration: a generated Worker running a real Workflow under Miniflare (params validation, steps reading the Worker env), the startup guard for both directories, and a real vp build deploy-config merge.
  • vp check passes formatting and lint. Its only errors are tsconfigs that unbuilt playgrounds haven't generated, and none are in changed files.
  • vp run test: 2,766 passed. The 14 failures are platform admin browser tests that need Playwright's Chromium, which isn't installed locally. This PR doesn't touch platform/.

Follow-ups

  • Fail on Workflow names over Cloudflare's length limit instead of truncating, as queues do.
  • Decide whether run should also validate params for instances started outside Void (dashboard, wrangler workflows trigger, raw binding).
  • Void platform support.

🤖 Generated with Claude Code

Isak Gustavsen and others added 2 commits November 25, 2026 01:09
Each default-exported defineWorkflow() or defineWorkflowEntrypoint() module
in workflows/ becomes a Cloudflare Workflow with a WORKFLOW_<NAME> binding
and <Name>Workflow class, started from routes with Definition.create(),
createBatch() and get(). Params can be validated with a Standard Schema.

Discovery follows queues/: subdirectories are joined with '-' and paths
with a '_'-prefixed segment are ignored, so step helpers can live beside
the workflows. Deploys to Cloudflare name each Workflow
<worker>-<resource>, since Workflow names are account-scoped, and verify
the emitted set before upload. Void platform deploys, framework mode and
Node targets reject workflows/ for now.

The generated Worker entry now imports convention modules through their
namespace and fails startup with a named error when a module does not
default-export a definition; this also covers durable-objects/.

Closes voidzero-dev#779

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resource imports used only inside workflows/, including _-prefixed step
helpers and nested folders, now count toward binding inference, as they
already do for durable-objects/. Apps with a sourceDir scan workflows/ too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Workflows as a binding

1 participant