How kits join: capability entrypoints, and why Workers are declared in Alchemy's plain form
The kits call each other through named doors called capability entrypoints. A deployer grants a kit a door by binding it, and the door's name is the identity written in the callee's audit log. All five kits declare their Worker in a plain form, rather than Alchemy's richer form, to make that work. This page says how and why.
Capability entrypoints
A Cloudflare Worker can export a named class that other Workers are bound to, called a WorkerEntrypoint. A service binding is how one Worker calls another directly. In edge-response a kit that others call exports one such class for each thing a caller may do, and the shared Contracts package fixes the names:
| Capability | Kit | What it allows |
|---|---|---|
IngestWrite |
Ingest | Hand records over for storage, as the service-binding entry pattern. |
AdmissionRead |
Detect | Read the effective level of one zone or all zones. |
AdmissionOperator |
Detect | Lower, raise, stop and resume, for a console. |
SignalRead |
Detect | List and read signals. |
CaseRead |
Enrichment | List and read cases. |
EnrichmentOperator |
Enrichment | Stop the agent, and resume it in two steps. |
AssetRead |
Asset map | Look up assets and what depends on them. |
RespondPropose |
Respond | Propose an action, see its status, request an undo. |
RespondOperator |
Respond | List, approve, deny, undo, stop, resume and change settings, for a console. |
Four rules hold for all of them.
- The binding is the grant. A caller can use only the class its binding names. The default entrypoint of every kit has no such methods, and a name that is not exported cannot be bound.
- The name is the identity. A callee writes
capability:<Name>to its audit rows. The caller does not state who it is. - A person never travels as an argument. An operator capability takes the raw Access assertion that the console received, and the callee verifies it itself, failing closed. The audit row records the verified email and the capability.
- No method throws. Each answers either a value or one of a closed list of errors, such as
forbiddenorunavailable, with no text from upstream.
Why the Worker is in the plain form
Alchemy is the tool the kits use to declare their Cloudflare resources in code. At the pinned version, 2.0.0-beta.85, it has two ways to declare a Worker. The richer one is its two-phase, Effect form. The plain one names a module file with main. All five kits use the plain one, called the async form, because of two limits in the richer one.
- It cannot export a named entrypoint. Its generated entry file exports one default class plus Durable Object and Workflow classes, and nothing else is accepted. A kit that must export
AdmissionReadcannot be written that way. The caller side works: a two-phase Worker can be bound to someone else's named entrypoint, it just cannot be one. - Binding properties are dropped on a live deploy. Alchemy lets a service binding carry properties that the callee could read as the caller's identity. Its own source says a deployed Worker's binding does not carry them yet. Local development delivers them, so tests would pass and a live deploy would give an empty identity. The entrypoint name does survive an upload, which is why the name is the grant.
Every kit therefore declares Cloudflare.Worker("Name", { main: "./src/worker.ts" }): Ingest, Detect, Enrichment, Respond and the Asset map. Ingest now exports its IngestWrite class as well, so it has one plain Worker and no two-phase root.
The evidence
Both limits were read from the installed Alchemy source, and the next release, beta.88, was checked and has the same source. Each called kit's tests prove the working shape: in a local Cloudflare runtime simulator with real service bindings, the default entrypoint has none of the methods, an unexported name cannot be used, no capability class holds another's methods, and the audit actor equals the capability name. A test under alchemy dev, which runs locally with no account, binds a small caller Worker to one capability and shows it can read and cannot call an operator method. What is not proven is the live half of the second limit, which rests on Alchemy's source and its own statement. Only a live deploy, which no one has run, can prove it.
The way back
The change is held to one file of each kit, src/capabilities.ts, plus the stack file. The application, the adapters and the tests do not know which form hosts them. When Alchemy can export a named entrypoint from the two-phase form, or can carry binding properties live, a kit moves its classes into the richer Worker, deletes that file and binds with Alchemy's own worker binding. Nothing under the application changes.
What this means for you
You add a binding for each join, one at a time, and each is a grant you can see in your own configuration. A kit with no binding to a peer works alone. The concept page lists the joins and the blueprints page has the full table.