Skip to content

refactor(bindings)!: remove Binding.Policy and align all bindings to a single convention - #690

Merged
sam-goodwin merged 34 commits into
mainfrom
claude/nifty-leakey-8c41dc
Jun 27, 2026
Merged

sam-goodwin merged 34 commits into
mainfrom
claude/nifty-leakey-8c41dc

Conversation

@sam-goodwin

@sam-goodwin sam-goodwin commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

A coordinated naming-alignment release: every Cloudflare service is now a proper namespace, every binding across AWS and Cloudflare follows one {Verb}{Resource} convention, and the two-layer Binding.Policy split is gone — folded into a single runtime-guarded Layer. Almost no new behavior; a rename across ~900 symbols and ~1200 files so the API reads the same everywhere.

Breaking changes

  • Every Cloudflare service is namespaced — Cloudflare.KVNamespace → Cloudflare.KV.Namespace, Cloudflare.Worker → Cloudflare.Workers.Worker (common ones re-exported at the root).
  • AiGateway / AiSearch / AiSecurity collapse into AI — Cloudflare.AiGateway → Cloudflare.AI.Gateway.
  • Bindings are directly callable, namespaced, least-privilege — R2Bucket.bind(b) → Cloudflare.R2.ReadBucket(b), DynamoDB.GetItem.bind(t) → AWS.DynamoDB.GetItem(t).
  • Binding.Policy is removed — deploy-time wiring moves behind an if (!globalThis.__ALCHEMY_RUNTIME__) guard in one Layer.
  • Impl layers renamed — *Live → *Binding (Cloudflare native worker binding) or *Http (HTTP-client binding, all AWS + Cloudflare HTTP impls).
  • Event sources are consume<Resource><Event>(resource, handler) — Queues.messages(q).subscribe(fn) → Queues.consumeQueueMessages(q, fn).
  • Worker-only bindings take a string id — Images({ name: "X" }) → Images("X"); native layers drop *Live/*Layer (BrowserBindingLive → BrowserBinding).
  • Artifacts.Store → Artifacts.Namespace (and ReadWriteStore → ReadWriteNamespace).

Every Cloudflare service is a namespace

Cloudflare/index.ts was a flat export *; it now mirrors the AWS barrel — one export * as <Service> per service, with the redundant prefix stripped:

- const kv = yield* Cloudflare.KVNamespace("Sessions");
- const bucket = yield* Cloudflare.R2Bucket("Assets");
- export default Cloudflare.Worker("Worker", { /* ... */ });
+ const kv = yield* Cloudflare.KV.Namespace("Sessions");
+ const bucket = yield* Cloudflare.R2.Bucket("Assets");
+ export default Cloudflare.Workers.Worker("Worker", { /* ... */ });

Common building blocks stay at the root (Cloudflare.Worker, Container, DurableObject, Workflow, RateLimit, cron). The DO base class loses its suffix (DurableObjectNamespace → DurableObject). Folder reshuffles: Container/ → Containers/, Queue → Queues, workflow code → Workflows/, plus a new Cloudflare.WebSocket type for hibernatable handlers.

Ai* becomes one AI namespace

The three AI services collapse into Cloudflare.AI, dropping the Ai prefix:

- const gateway = yield* Cloudflare.AiGateway("Gateway");
+ const gateway = yield* Cloudflare.AI.Gateway("Gateway");

AiGatewayDataset → AI.Dataset, AiSearchInstance → AI.SearchInstance, AiSecuritySettings → AI.SecuritySettings.

One binding convention, everywhere

AWS and Cloudflare bindings now read identically — the capability is the noun, prefixed by the verb (access level), called directly (.bind is gone):

- const get = yield* AWS.DynamoDB.GetItem.bind(table);
- const bucket = yield* Cloudflare.R2Bucket.bind(Bucket);
+ const get = yield* AWS.DynamoDB.GetItem(table);
+ const bucket = yield* Cloudflare.R2.ReadWriteBucket(Bucket);

Where the API distinguishes access levels, the capability splits into Read / Write / ReadWrite for least privilege:

yield* Cloudflare.KV.ReadNamespace(Sessions);      // get / list
yield* Cloudflare.KV.WriteNamespace(Sessions);     // put / delete
yield* Cloudflare.KV.ReadWriteNamespace(Sessions); // both

*Binding vs *Http

Each capability ships two interchangeable impl Layers; the suffix is the transport:

.pipe(Effect.provide(Cloudflare.R2.ReadWriteBucketBinding)) // native Worker binding (env.BUCKET)
.pipe(Effect.provide(Cloudflare.R2.ReadWriteBucketHttp))    // scoped HTTP token — runs anywhere
  • AWS *Http — emits a least-privilege IAM policy statement on the Lambda role, then calls the distilled HTTP API with it. (AWS has no native binding, so every AWS impl was renamed *Live → *Http.)
  • Cloudflare *Http — mints a scoped AccountApiToken with only the needed permission groups, binds its value as a secret, and calls the REST API through distilled.

The client interface is identical regardless of which Layer you provide — a Worker over its native binding and a Container over a token run the same code.

More Cloudflare *Http bindings

R2, KV, and Queues already had *Http impls; DNS joins them this release, all sharing one mechanism and the verb-first naming:

yield* Cloudflare.DNS.ReadDns(Zone);      // list / get records
yield* Cloudflare.DNS.WriteDns(Zone);     // create / update / delete
yield* Cloudflare.DNS.ReadWriteDns(Zone); // both

An *Http Layer provisions its own credential: at deploy time it mints an AccountApiToken scoped to only the permission groups that access level needs (a ReadNamespace mints a read-only KV token, a WriteNamespace a write-only one) and binds its value into the host as a secret, behind the __ALCHEMY_RUNTIME__ guard. At runtime the client reads the token's value/accountId and calls the REST API — no account-wide key, a different scoped token per capability.

Binding.Policy is gone

Bindings were two pieces: a runtime Binding.Service plus a separate deploy-time Binding.Policy (with its own *PolicyLive layer). They collapse into a single Binding.Service whose setup Effect does the deploy-time wiring inline, guarded so it only runs at plan time:

if (!globalThis.__ALCHEMY_RUNTIME__) {
  yield* host.bind`${resource}`(/* register IAM / native binding / env */);
}
// always: return the typed runtime client

At plan time the guard is open and bind records what the function needs; at runtime the branch is skipped, so the runtime bundle stays small. Every binding — including event sources — now follows this. Binding.Policy, Binding.ServiceClass, and the Policy / PolicyLike types are removed from the core.

Worker-only bindings take a string id

The bindings with no backing resource (Images, Browser, VersionMetadata, RateLimit) take a string id first instead of a { name } object, and their native layers drop *Live/*Layer:

- const images = yield* Cloudflare.Images.Images({ name: "PIPELINE" });
- .pipe(Effect.provide(Cloudflare.Workers.BrowserBindingLive))
+ const images = yield* Cloudflare.Images.Images("PIPELINE");
+ .pipe(Effect.provide(Cloudflare.Workers.BrowserBinding))

Artifacts.Store → Artifacts.Namespace (access via ReadNamespace / WriteNamespace / ReadWriteNamespace).

Event sources: consume<Resource><Event>

Event sources are bindings too. The old X(resource, props?).subscribe(handler) shape becomes a single verb-prefixed, resource-and-event-named callable taking the handler last:

- yield* Cloudflare.Queues.messages(inbound).subscribe((records) => …);
+ yield* Cloudflare.Queues.consumeQueueMessages(inbound, (records) => …);
Before After
SQS.messages(q).subscribe SQS.consumeQueueMessages(q, fn)
S3.notifications(b).subscribe S3.consumeBucketEvents(b, fn)
SNS.notifications(t).subscribe SNS.consumeTopicNotifications(t, fn)
Kinesis.records(s).process Kinesis.consumeStreamRecords(s, fn)
DynamoDB.stream(t).process DynamoDB.consumeTableChanges(t, fn)
GitHub.events(r).subscribe GitHub.consumeRepositoryEvents(r, fn)

Dropping .subscribe also drops the handler's runtime requirements at the source boundary, so explicit Body type arguments no longer break inference.

…ervice

Collapse the legacy `Binding.ServiceClass` + `Binding.Policy` pair into a
single combined `Binding.Service` identifier (tag + callable + type), matching
the `Resource.ts` pattern. The deploy-time IAM/native-binding registration is
inlined into each impl layer under `if (!globalThis.__ALCHEMY_RUNTIME__)`,
resolving the host via `yield* Binding.host`.

- Capabilities are now directly callable: `GetItem(table)` (no `.bind`)
- Impl layers renamed `*Live` -> `*Binding`
- Cloudflare resources/capabilities are namespaced and permission-split
  (`Cloudflare.R2.ReadBucket`, `Cloudflare.SecretsStore.Store`)
- `Binding.ServiceClass` retired

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alchemy-version-bot

alchemy-version-bot Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/d26f87a

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/d26f87a

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/d26f87a

sam-goodwin and others added 2 commits June 25, 2026 14:22
Bring Cloudflare/index.ts to the AWS standard: every resource-bearing service
is `export * as <Service>`, mirroring `Cloudflare.R2.Bucket`, `Cloudflare.Dns.ReadDns`,
`Cloudflare.Email.CatchAll`. Cross-cutting utilities stay flat.

- Container/ -> Containers/ (Cloudflare.Containers.*), Container re-exported at root
- Browser + RateLimit folded into Workers (binding-only primitives), re-exported at root
- Email symbols drop the redundant Email prefix (EmailCatchAll -> Cloudflare.Email.CatchAll)
- Dns/Tunnel capabilities renamed verb-first (DnsRead -> ReadDns, TunnelRead -> ReadTunnel)
- new Access/ and Gateway/ barrels
- convenience root re-exports: Worker, Container, Browser, RateLimit, DurableObject*,
  Rpc*, InferEnv, Workflow, WorkerLoader
- all consumers + JSDoc + generated docs updated

Co-Authored-By: Claude Opus 4.8 <[email protected]>
`Binding` is a Cloudflare native-worker concept. AWS runtime impls call the
distilled HTTP API authenticated by the Lambda's IAM role, so the impl layer is
`*Http` (e.g. DynamoDB.PutItemHttp, SQS.SendMessageBatchHttp, S3.GetObjectHttp),
matching the Cloudflare HTTP-impl convention.

- 117 AWS `<Op>Binding.ts` -> `<Op>Http.ts` (file + layer symbol)
- consumers, indexes, Providers registrations updated
- Cloudflare native `*Binding` layers (e.g. Hyperdrive.ConnectBinding) unchanged

Co-Authored-By: Claude Opus 4.8 <[email protected]>
return Effect.fn(function* (queue: Queue) {
const QueueUrl = yield* queue.queueUrl;
if (!globalThis.__ALCHEMY_RUNTIME__) {
const host = yield* Binding.host;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename this to Binding.Host

});
}
}
return Effect.fn(function* (request: DeleteMessageRequest) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think each of the binding functions should add an identifier

Effect.fn(AWS.SQS.DeleteMessage(${host.LogicalId}), ${queue.LogicalId})(function*(...)

Whatever makes sense for the binding?

},
Effect.gen(function* () {
const artifacts = yield* Cloudflare.Artifacts.bind(Repos);
const artifacts = yield* Cloudflare.Artifacts.Artifacts(Repos);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Cloudflare.Artifacts.ReadStore, Cloudflare.Artifacts.WriteStore, ReadWriteStore, etc.

// then receives and persists it via its `queue(batch)` handler — end-to-end
// regression guard for the Queue, QueueWrite, and QueueConsumer resources.
export const Queue = Cloudflare.Queue("Queue");
export const Queue = Cloudflare.Queue.Queue("Queue");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be Cloudflare.Queues.Queue, Cloudflare.Queues.Consumer, Cloudflare.Queues.ReadQueue(queue)

// Register the same worker script as a consumer of Queue. The worker's
// `queue(batch)` handler (see src/worker.ts) receives each message batch.
yield* Cloudflare.QueueConsumer("QueueConsumer", {
yield* Cloudflare.Queue.QueueConsumer("QueueConsumer", {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to Cloudflare.Queue.Consumer

);
} else if (request.method === "POST" || request.method === "PUT") {
// const request = yield* Cloudflare.Request
// const request = yield* Cloudflare.Workers.Request

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoist Request to Cloudflare.Request

import * as Cloudflare from "alchemy/Cloudflare";

export const Bucket = Cloudflare.R2Bucket("Bucket");
export const Bucket = Cloudflare.R2.R2Bucket("Bucket");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename R2Bucket to Bucket so it's Cloudflare.R2.Bucket(..)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for D1Database, rename to Cloudflare.D1.Database

Apply consistent suffixless convention for each of the namespaces. You'll have to audit each of the cloudflare resources for this problem. All files with a redundant suffix in the name or in the class name need to be removed

D1Database.ts -> Database.ts
class D1Database -> class Database

Comment thread examples/cloudflare-worker/src/KV.ts Outdated
import * as Cloudflare from "alchemy/Cloudflare";

export const KV = Cloudflare.KVNamespace("KV");
export const KV = Cloudflare.KV.KVNamespace("KV");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Cloudflare.KV.Namespace

const { roomId, message } = input;

const stored = yield* Cloudflare.task(
const stored = yield* Cloudflare.Workers.task(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Cloudflare.Workflows.task(..). Move workflow stuff to its own Workflows/ folder

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also want each of these namespaces to be importable directly, just liek effect

two options:

import * as Cloudflare from "alchemy/Cloudflare";

Cloudflare.Workflows.task

or

import * as Workflows from "alchemy/Cloudflare/Workflows";

Workflows.task

Consistent for all namespaces in src/Cloudflare and src/AWS

Comment thread examples/cloudflare-worker/src/Room.ts Outdated
const state = yield* Cloudflare.DurableObjectState;
return Effect.gen(function* () {
const sessions = new Map<string, Cloudflare.DurableWebSocket>();
const sessions = new Map<string, Cloudflare.Workers.DurableWebSocket>();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Cloudflare.WebSocket.Socket

sam-goodwin and others added 22 commits June 25, 2026 16:49
Every Cloudflare resource symbol/class/type/file drops the redundant namespace
prefix (PR #690 review, comment 14): R2Bucket -> Cloudflare.R2.Bucket,
KVNamespace -> Cloudflare.KV.Namespace, D1Database -> Cloudflare.D1.Database,
QueueConsumer -> Cloudflare.Queue.Consumer, AccessPolicy -> Cloudflare.Access.Policy,
PagesProject -> Cloudflare.Pages.Project, etc. (~900 symbols across ~77 services).

- internal types (*Props/*Attributes/*Provider) stripped too where unambiguous
- names colliding with JS globals (Object/Error) or the core Binding/Provider
  modules kept prefixed; workers-types globals (R2Bucket, KVNamespace, …) rewritten
  only on alchemy uses, never on `runtime.*`/`cf.*` references
- all consumers, Providers.ts, and generated docs updated

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Per PR #690 review: the alchemy DO binding is now Cloudflare.Workers.DurableObject
(root re-export Cloudflare.DurableObject); RpcDurableObjectNamespace -> RpcDurableObject.
workers-types/distilled DurableObjectNamespace references are left intact.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Cloudflare.Containers.layerContainer -> Cloudflare.Containers.layer (comment 7)
- hoist Workers Request to a root re-export Cloudflare.Request (comment 9)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Cloudflare.Queue.* -> Cloudflare.Queues.* (Cloudflare's product name; comment 4).
Dir Queue/ -> Queues/; resource/symbols unchanged (Queues.Queue, Queues.Consumer, …).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Capitalize the deploy-time host resolver (PR #690 review, comment 1).
Updated across all ~120 AWS + Cloudflare binding impl layers.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Workflow.ts + WorkflowBridge.ts move from Workers/ to a new Workflows/ namespace
(comment 12): Cloudflare.Workflows.task, Cloudflare.Workflows.Workflow, etc.;
Cloudflare.Workflow stays as a root re-export.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Move Workers/WebSocket.ts to a WebSocket/ namespace (comments 6, 13):
DurableWebSocket -> Cloudflare.WebSocket.Socket,
Cloudflare.Workers.upgrade() -> Cloudflare.WebSocket.upgradeConnection().

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ReadWrite

Cloudflare.Artifacts.ReadStore (get/list/raw), WriteStore (create/delete/import),
ReadWriteStore (both) — same native binding typed to each subset, least-privilege
by construction (comment 3). Drops the stray Cloudflare.Artifacts.Artifacts callable.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ibe)

Replace `X(resource, props?).subscribe(handler)` with `X(resource, handler)` /
`X(resource, props, handler)` across every event source (comment 8): Cloudflare
Queues.messages + Workers.cron, GitHub events, AWS SQS/S3/SNS/EventBridge. The
handler's runtime requirements are dropped at the source boundary (satisfied at
dispatch), so explicit Body type args no longer break inference. Consumers,
JSDoc, tutorials, and generated docs updated.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Each binding's runtime Effect.fn now carries a tracing label derived from its
tag-id + bound resource LogicalIds (PR #690 review, comment 2), e.g.
`AWS.SQS.DeleteMessage(${queue.LogicalId})`, `Cloudflare.R2.ReadBucket(${bucket.LogicalId})`.
Account/service-scoped ops use the bare tag; variadic ops list the sorted resources.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The generated Worker entry imports `makeWorkerBridge`, `makeDurableObjectBridge`,
and `makeWorkflowBridge` from "alchemy/Cloudflare" (Workers/WorkerBundle.ts), but
the namespace refactor moved them under Cloudflare.Workers.* / Cloudflare.Workflows.*,
breaking worker bundling at runtime (tsgo couldn't catch it — the virtual entry is
bundled, not type-checked). Re-export them top-level.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
After folding RateLimit into Workers/, the inline `import { type RateLimitClient }`
back-edge in RateLimit.ts (→ RateLimitBinding.ts) wasn't erased in the rolldown
worker bundle, closing a RateLimitBinding → Worker → WorkerAsyncBindings → RateLimit
cycle so `Layer.effect(RateLimit, …)` captured an undefined tag. Use a statement-level
`import type` (guaranteed erased) to break the cycle.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-suite contention

Cloudflare serializes zone client-cert mutations per zone, so under full-suite
load the deleted-cert tombstone lags past the old ~60s poll budget, flaking
`waitForGone` with CertificateNotDeleted (passes in isolation). Widen the poll to
~135s and the test timeouts to 200s. Delete logic is unchanged — the cert does
settle to deleted, just slower under contention.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The async-worker D1 surface test's `retryRows` reused the ~60s `ready` schedule;
under full-suite concurrency the freshly-deployed worker's writes lag past it
(RowsMismatch), though it passes in isolation. Widen to ~90s (within the 120s
test timeout).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The integration suites hit real cloud APIs at high concurrency; a few tests per
run flake on transient network/edge-propagation issues (read ETIMEDOUT, D1
replica lag, cert tombstone lag) that pass on re-run. Add `retry: 2` so flakes
self-heal while deterministic failures still surface (the test body retries;
deploys live in beforeAll and are not re-run).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Reorder binding impl files so the significant definition (the `*Http`/`*Binding`
Layer export) sits at the top, right after imports, and helper utilities/types
move below it — each file's primary focus reads first. Pure reordering: helpers
moved below are only referenced inside the Layer's Effect.gen/Effect.fn closures
(or are hoisted type aliases), so no use-before-declaration. 15 files across
CloudWatch/DynamoDB/Kinesis (AWS) and Dns/Flagship/KV/Queues/R2/Tunnel/Workers (CF).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…, handler)

Rename every event source to a universal verb-prefixed, resource-named
callable. Handler is the last positional arg, props optional in the middle.

- Cloudflare.Queues.messages   -> consumeQueue
- AWS.SQS.messages             -> consumeQueue
- AWS.S3.notifications         -> consumeBucket
- AWS.SNS.notifications        -> consumeTopic
- GitHub.events                -> consumeRepository
- AWS.Kinesis.records(s,p).process(h) -> consumeStream(s, p?, h)  (flattened)
- AWS.DynamoDB.stream(t,p).process(h) -> consumeStream(t, p?, h)  (flattened)
- AWS.EventBridge.events(...,h) -> consumeEventBus  (routing-builder
  events(...).toLambda/.toQueue/.toEcsTask kept as events)

Also re-export Cloudflare.Workers.cron at the root as Cloudflare.cron.
DynamoDB consumeStream drops the redundant `T extends Table` generic so the
row type is the first explicit type arg: consumeStream<Row>(table, ...).

Updates all call sites, JSDoc, generated provider docs, and the
website tutorials/guides (binding concept, kinesis/dynamodb-streams/sqs/
s3-events/queue-consumer tutorials, llms.txt).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Make each consume callable name the event element it yields, not just
the resource:

- consumeQueue      -> consumeQueueMessages        (AWS.SQS, Cloudflare.Queues)
- consumeBucket     -> consumeBucketEvents         (AWS.S3)
- consumeTopic      -> consumeTopicNotifications   (AWS.SNS)
- consumeRepository -> consumeRepositoryEvents     (GitHub)
- consumeStream     -> consumeStreamRecords        (AWS.Kinesis)
- consumeStream     -> consumeTableChanges         (AWS.DynamoDB)
- consumeEventBus   -> consumeBusEvents            (AWS.EventBridge)

Updates all call sites, JSDoc, generated provider docs, website
tutorials/guides, llms.txt, and the AWS bring-up process docs.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…the runtime guard

Every binding now lives in a single `Binding.Service`/`Layer.effect`. The
deploy-time wiring (IAM, native bindings, sub-resource creation like
`EventSourceMapping`) moves behind `if (!globalThis.__ALCHEMY_RUNTIME__)`,
matching the capability bindings. The two-layer `*Policy` + `*PolicyLive`
split and `Binding.Policy` itself are deleted.

Migrated event sources / routing helpers:
- AWS Lambda: Bucket / Table / Stream / Queue / Topic / EventBridge
- AWS EventBridge routing: ToLambda / ToQueue
- Cloudflare: Queues consumer / Cron / GitHub repository
- Server: S3 bucket

Plan-time resource constructors are resolved at the outer layer; the guarded
deploy block is wrapped in `Namespace.push(host.LogicalId)` so each
EventSourceMapping/subscription keeps the exact logical identity the old
Binding.Policy produced (no resource churn on existing stacks). Runtime
`host.listen` / `ctx.listen` stays outside the guard.

Also:
- Delete dead `BindWorkerPolicy` (never consumed; live path is `bindWorker`).
- Excise `Policy` / `PolicyLike` / `PolicyShape` from the core (Binding.ts,
  Provider.ts, Stack.ts, Platform.ts, index.ts) and both `Providers.ts`.
- AWS Providers test now provides `ArtifactStore` (mirrors the Cloudflare test;
  it was previously masked by Layer.mergeAll variadic inference).
- Rewrite the binding/phases concept docs to describe the single-layer guard.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eAndQueue

The deploy effect did `yield* TableAndQueue` but only provided
`DynamoDBStreamFunctionLive`, which consumes `TableAndQueueLive` internally
(via Effect.provide in the function body) and does not re-expose it — so the
test failed in ~40ms with `Service not found: TableAndQueue` before any
deploy. Pre-existing; never caught because creds were expired.

Export `TableAndQueueLive` and provide it in the test's deploy scope. The
deterministic logical ids (StreamSourceTable / StreamSinkQueue) dedupe to one
physical Table/Queue, so the function's binding and the test's reads share the
same resources. Verified live: real Lambda + DynamoDB stream + SQS sink, a
written item flows through as a change record.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@sam-goodwin
sam-goodwin force-pushed the claude/nifty-leakey-8c41dc branch from a0658fa to 2d51473 Compare June 26, 2026 20:05
@sam-goodwin sam-goodwin changed the title refactor(bindings)!: unify AWS + Cloudflare bindings on one Binding.Service refactor(bindings)!: remove Binding.Policy and align all bindings to a single convention Jun 27, 2026
@sam-goodwin
sam-goodwin marked this pull request as ready for review June 27, 2026 10:45
@sam-goodwin
sam-goodwin merged commit 35b0436 into main Jun 27, 2026
8 of 9 checks passed
@sam-goodwin
sam-goodwin deleted the claude/nifty-leakey-8c41dc branch June 27, 2026 10:45
sam-goodwin added a commit that referenced this pull request Jul 1, 2026
… merge

Main renamed DurableObjectNamespace -> DurableObject (#690) and moved the
worker provider into WorkerProvider.ts. Re-apply the adoption fallback
there, and fix the merged test/JSDoc to the current API.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Mkassabov added a commit that referenced this pull request Jul 8, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
AmanVarshney01 added a commit to AmanVarshney01/alchemy-effect that referenced this pull request Jul 8, 2026
…PI surface

- rework ConnectionBinding to the single binding convention (alchemy-run#690): combined
  tag/callable + Binding.Host dispatch inside ConnectionBindingLive, drop
  Binding.Policy machinery and its Providers registrations
- replace the removed Build/Command helper (alchemy-run#673) with a local spawner-based
  runBuildCommand in ComputeBuild
- update shape-typed class forms to the id-only + .make(props, impl) Platform API
- add the /v1/apps, /v1/deployments, and build-logs surface to the client,
  operation helpers, and route-parity tests (96-route coverage)
- add ScmInstallation.connected/connectedAt, the connected list filter, and
  connectScmInstallation for the new SCM connect endpoint; unreleased routes
  are allowlisted until they ship to the production OpenAPI doc
DavidJFelix pushed a commit to DavidJFelix/alchemy-effect that referenced this pull request Aug 7, 2026
Mkassabov added a commit that referenced this pull request Aug 25, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 25, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 26, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 26, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 26, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 26, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
Mkassabov added a commit that referenced this pull request Aug 26, 2026
Port of the original Binding.Policy implementation to the post-#690
event-source convention (Layer resolves the Worker host directly;
sibling Email.Routing + Email.Rule are yielded under Namespace.push
guarded by __ALCHEMY_RUNTIME__, mirroring Queues.EventSourceLive).

- Cloudflare.email({ zone, matchers }).subscribe(handler) wires the
  runtime email listener and auto-creates Email.Routing (retained on
  destroy) + Email.Rule targeting the host Worker
- Effect-native ForwardableEmailMessage wrapper (forward/reply/
  setReject as Effects, raw escape hatch)
- e2e test + fixture gated on CLOUDFLARE_TEST_ZONE /
  CLOUDFLARE_TEST_EMAIL_INBOX / CLOUDFLARE_TEST_EMAIL_FROM
- doc relocated to cloudflare/email/email-worker.mdx (tutorial/ dir
  no longer exists)
- example updated to the Email.Send / Email.SendBinding API

Co-authored-by: Michael (Pear) <[email protected]>
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.

1 participant