ContextWorkers are arbitrary code that executes inside the request path, not in a queue behind it. Mutate, enrich, block, audit. Every decision inline, at sub-millisecond overhead.
Each worker moves through four states during a request: spawn, execute, yield, close. Spawning a pre-allocated WASM instance costs around 90 microseconds on commodity hardware. Node and Python workers pay a higher spawn tax; RelayGate pools them eagerly when the config loads.
During execute, the worker receives a structured envelope: the parsed request, a per-tenant context bundle, a receipt builder, and access to secrets and the ledger. The worker mutates or blocks. On yield, the mutation set is committed to the request; on close, the receipt is signed and forwarded.
A worker reads and writes through the ctx surface. Reads are lazy; the gateway only materializes the request body if the worker calls for it. Writes are batched and applied in declaration order after the worker yields. Every mutation is recorded in the receipt.
A worker returns one of five dispositions. Pass forwards the request untouched. Mutate commits a write set. Enrich adds headers or metadata without changing the body. Block short-circuits with a 4xx the client sees. Branch rewrites the backend target and starts over.
Other gateways queue your logic before or after the request and call it "middleware." That forces every mutation through a round-trip. RelayGate runs your code in the gateway process, against the parsed envelope, with zero copies. The only "middleware" that actually sits in the middle.
Everything the homepage demos exercise maps onto one of these eight archetypes. Each is shipped as a builtin; each is also installable from the gallery as a template to fork.