Before building a custom World, check the Worlds Ecosystem page — there may already be a community implementation for your infrastructure.
Reference Implementation: The Postgres World source code is a production-ready example of how to implement the World interface with a database backend and graphile-worker for queuing.
What is a World?
A World connects workflows to the infrastructure that powers them. The World interface abstracts three core responsibilities:- Storage — Persisting workflow runs, steps, hooks, and the event log
- Queue — Enqueuing and processing workflow and step invocations
- Streamer — Managing real-time data streams between workflows and clients
start() method initializes any background tasks needed by your World (e.g., queue polling).
The Event Log Model
Workflow storage is built on an append-only event log. All state changes happen through events — you never modify runs, steps, or hooks directly. Instead, you create events that update the materialized state. Events fall into three categories: run lifecycle events, step lifecycle events, and hook lifecycle events. See the Event Sourcing documentation for a complete list of event types and their semantics.Storage Interface
The Storage interface provides read access to materialized entities and write access through events:Key Implementation Details
Event Creation: Whenevents.create() is called, your implementation must:
- Persist the event to the event log
- Atomically update the affected entity (run, step, or hook)
- Return both the created event and the updated entity
run_created events, the runId parameter is null. Your World generates and returns a new runId.
Hook Tokens: Hook tokens must be unique. If a hook_created event conflicts with an existing token, return a hook_conflict event instead.
Automatic Hook Disposal: When a workflow reaches a terminal state (completed, failed, or cancelled), automatically dispose of all associated hooks to release tokens for reuse.
Queue Interface
The Queue interface handles asynchronous execution of workflows and steps:Queue Names
Queue names follow a specific pattern:__wkf_workflow_<name>— For workflow invocations__wkf_step_<name>— For step invocations
Message Payloads
Two types of messages flow through queues: Workflow Invocations:Implementation Considerations
- Messages must be delivered at-least-once
- Support configurable retry policies
- Track attempt counts for observability
- Implement idempotency using the
idempotencyKeyoption when provided
Streamer Interface
The Streamer interface enables real-time data streaming:runId and name. Each workflow run can have multiple named streams.
Reference Implementations
Study these implementations for guidance:- Local World — Filesystem-based, great for understanding the basics
- Postgres World — Database-backed with graphile-worker for queuing
Testing Your World
Workflow DevKit includes an E2E test suite that validates World implementations. Once your World is published to npm:- Add your world to
worlds-manifest.json - Open a PR to the Workflow repository
- CI will automatically run the E2E test suite against your implementation
Publishing Your World
- Package your World — Export a default World instance from your package
- Publish to npm — Publish your package to npm
- Add to the manifest — Submit a PR adding your world to
worlds-manifest.json - Document configuration — Clearly document any required environment variables