Skip to content

feat(engine): first-class local vs live provider modes - #963

Merged
sam-goodwin merged 29 commits into
mainfrom
feat/provider-modes
Jul 29, 2026
Merged

sam-goodwin merged 29 commits into
mainfrom
feat/provider-modes

Conversation

@sam-goodwin

@sam-goodwin sam-goodwin commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Make provider mode (local vs live) a first-class engine concept: the mode that reconciled a resource is persisted in state, switching modes plans a replacement, and every delete resolves the provider variant of the mode that created the row — so alchemy deploy right after alchemy dev cleanly replaces local instances instead of updating over them (and vice versa). On top of that engine, this PR brings the Cloudflare dev experience to parity: KV/R2/D1/Queues are emulated locally, Alchemy.remote() opts individual resources onto real Cloudflare — including queues, in both directions — and the Node-side capability clients reach the same local simulators the workers see.

Mode resolution

  • every state commit stamps providerMode: "live" | "local"; a mismatch with the resolved mode forces a replace (the provider diff is not consulted — diffing props across runtimes is meaningless)
  • the mode comes from the command (alchemy dev → local, alchemy deploy → live); the one user knob is Alchemy.remote() — "run this live even in dev", captured at registration like adopt() (a no-op during deploy):
const queue = yield* Queue("Jobs", {}).pipe(Alchemy.remote());
  • mode-agnostic providers (a single implementation) satisfy any requested mode, so dev runs over constructs that mix emulatable and live-only resources just work — they never stamp and never replace on a switch
  • conflicting decorations on the same FQN die with ConflictingProviderModeError
  • rows without a stamp are assumed to be the current run's mode (re-stamped on next write)

ProviderLayer.dual (replaces select)

export const WorkerProvider = () =>
  ProviderLayer.dual(Worker, {
    live: () => LiveWorkerProvider(),
    local: () =>
      LocalWorkerProvider().pipe(Layer.provide(localRuntimeServices())),
  });

Registers both variants: the run-default eagerly, the other lazily (memoized via Layer.fromBuildMemo against the build's MemoMap), so a live deploy only constructs workerd machinery when a local-mode row actually needs deleting. deleteOldGenerations, GC chain draining, orphan deletes, sync, tail, and logs all resolve by the row's stamped mode.

LocalProvider — standard long-running local providers

LocalProvider.make(Dev, serverEntryUrl, Effect.gen(function* () {
  return {
    // plain-data restart surface; canonically hashed for noop-vs-restart
    resolveConfig: (ctx) => Effect.succeed({ ... }),
    // boot in the provided Scope; return Attributes at readiness
    start: Effect.fn(function* ({ config, invalidate }) { ... }),
    // delete-only cleanup that intentionally outlives restarts
    stop: ({ id }) => Effect.void,
  };
}));

Generates diff/reconcile/delete/list from the instance registry (per-id lock, config-hash comparison, instanceId-guarded delete for replacement safety, invalidate for self-dying processes) and wraps RpcProvider so the registry lives in the dev sidecar across user-code reloads. Command.Dev and LocalWorkerProvider are rewritten on it.

Local emulation for KV, R2, D1 (and inline-script workers)

Namespace, Bucket, and Database are now ProviderLayer.dual: in dev they fabricate dev:-prefixed ids with no cloud calls, and the worker's bindings lower onto the local workerd simulators. The providers carry no promotion logic — mode transitions are engine-orchestrated replacements (a live provider never sees a dev: id). D1 applies migrationsDir and importFiles against the local simulator through the platform proxy (multi-statement SQL over the raw d1 service). Workers defined with inline script: (no main) bypass the bundler and serve/restart on script change; assets-only Workers serve locally through an ASSETS-delegating stub; new dev: { cache, cf } props control the local Cache API and request.cf blob.

Node-side capability clients reach the local simulators

The *Local KV/R2 capability layers (and QueryDatabaseLocal) previously spoke only the cloud REST API. For dev: resources they now drive the local simulators through the runtime's platform proxy (cloudflare-tools#88, getPlatformProxy extracted from cloudflare-tools#74): the *Local layers reuse the same native-binding client builders the *Binding variants use, over per-operation proxied bindings — real ids keep the HTTP clients, dispatched per call from the lazily-resolved id. R2 rich objects (R2ObjectBody bodies, metadata) ride the proxy's r2-object encoding:

const Seed = Action("Seed", Effect.gen(function* () {
  const kv = yield* Cloudflare.KV.ReadWriteNamespace(ns);
  return Effect.fn(function* () {
    yield* kv.put("seeded", "from-action");   // lands in the local simulator
  });
}).pipe(Effect.provide(Cloudflare.KV.ReadWriteNamespaceLocal)));

Shared scaffolding in Cloudflare/LocalGateway.ts (localGatewayRuntime + the per-call mode dispatcher).

Alchemy.remote() queues work from local dev — both directions

Cloudflare's preview/remote-binding sessions reject queue bindings at the platform level (cloudflare/workers-sdk#9929), so:

  • Producing: when a LOCAL worker binds a LIVE queue, the eval registers a real shim worker (+ an Alchemy.Random bearer token) as ordinary engine-managed resources — the same idiom as AccountApiToken. The local binding relays workerd's queue wire protocol to the shim over HTTPS; the shim decodes it back into send()/sendBatch() on its real queue binding. Output-based ordering, stable-name updates, deletion on destroy, and orphan GC on promotion all come from the engine. v8-serialized messages are rejected with guidance to pass an explicit contentType.
  • Consuming: the Consumer's local provider attaches an http_pull consumer to the real queue, and the runtime's pull loop drains it into the local broker, which delivers to the local queue() handler with the usual local batching/retry/DLQ semantics.
local worker ──▶ shim ──▶ real queue ──▶ pull loop ──▶ local queue() handler

The e2e test round-trips a message: produced through the binding, observed in the REAL queue, received by the local handler.

Also in this PR

  • the opt-out decorator is named Alchemy.remote() (matching wrangler's "remote bindings" vocabulary; the persisted mode enum stays "live" | "local")
  • alchemy-test runner: a timed-out test's hanging teardown no longer stalls the run — the body is interrupted with a bounded 10s grace period and abandoned (with a clear report) if it doesn't settle
  • new .local.test.ts convention for dev-mode suites, plus ModeCycle.test.ts: the full local → hybrid (remote() within dev) → live → local cycle against the real cloud, including the demotion leg (live → local with real cloud deletions)
  • ProviderModePolicy is a tri-state Context.Reference (unset / remote() / remote(false)), simplifying its consumers while keeping conflict detection
  • DurableObjectNamespace live tests run concurrently (~450s → ~80s)

Tests

23 plan/apply mode tests plus LocalProvider.make lifecycle unit tests. The 8 dev-mode suites (KV/R2/D1/Queues/CacheCf/Script/AssetsOnly/ModeCycle, 19 tests incl. Alchemy.remote() and Action-gateway coverage) run green repeatedly with retries disabled; companion cloudflare-runtime suite green (267 tests).

Persist which provider mode (local/live) reconciled each resource, plan
mode switches as replacements, and resolve every delete with the provider
variant of the mode that created the row. Adds local()/live() combinators,
ProviderLayer.dual (lazy memoized variants, replaces select), and a
standard LocalProvider runner for long-running dev processes that
Command.Dev and LocalWorkerProvider are rebuilt on.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sam-goodwin
sam-goodwin force-pushed the feat/provider-modes branch from 7074898 to 400c9a1 Compare July 27, 2026 21:00
@alchemy-version-bot

alchemy-version-bot Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

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

@alchemy.run/better-auth

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

@alchemy.run/pr-package

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

sam-goodwin and others added 22 commits July 27, 2026 14:08
Adds infrastructure-as-code/local-provider.mdx (provider modes,
ProviderLayer.dual, LocalProvider.make, testing) with a sidebar entry and
a cross-link from the Custom Provider guide, and a "Provider Modes & Local
Providers" doctrine section in AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…detail)

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop local(): dev mode IS the local default, so the only user knob is
live() — "run this live even in dev" (a no-op during deploy). Exported
flat as Alchemy.live(); ProviderModePolicy reduces to a boolean. Tests
simulate dev runs via an AlchemyContext.dev override (inDev helper).

Co-authored-by: Cursor <cursoragent@cursor.com>
… only building providers

Co-authored-by: Cursor <cursoragent@cursor.com>
Each test.provider test owns an isolated scratch stack (private in-memory
state, physical names derived from the unique test name), so none can
observe another's cloud resources. Wrapping them in describe.concurrent
overlaps their workers.dev edge-propagation waits, cutting the file from
~450s serial (the whole Workers suite's critical path) to ~80s.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	packages/alchemy/src/Cloudflare/Workers/LocalWorkerProvider.ts
Exercises both self_url forms against local workerd (the suite runs with
dev: true): the env sentinel (PUBLIC_URL on the async worker) and the
Effect-native yield* Worker.URL accessor (new /url route on the effect
worker). Covers the local path ported in the main merge, which had no
suite coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e simulators

Points the cloudflare-tools submodule at the local-bindings branch
(alchemy-run/cloudflare-tools#85) and wires the new simulators into dev mode:

- KV Namespace, R2 Bucket, and D1 Database get registry-free local
  providers registered via ProviderLayer.dual: under `alchemy dev` the
  resource is a `dev:`-identified state row with no cloud API calls.
- toRuntimeBinding discriminates on the identity: a `dev:` id lowers onto
  the local simulator (KvNamespace.local / R2Bucket.local / D1.local),
  a real id keeps the remote proxy — so `Alchemy.live()`-opted resources
  still pass through to the cloud in dev. R2 has no opaque id, so the
  `dev:` marker rides on the bucket name.
- Live providers gain Queue-style promotion guards: a `dev:` id diffs as
  update-not-replace (with the id dropped from stables for that update),
  observation skips the impossible by-id read, and delete is a no-op.
- Cache API (`caches.default`) and `request.cf` need no alchemy wiring
  (always-on plugin / entry middleware); pinned by CacheCfLocal.test.ts.

D1 migrations/imports are not applied locally (no Node-side query path
into the simulator yet) — the local provider warns and skips.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rkerd gateway

The D1 simulator is only reachable from inside workerd, but alchemy's
migration runner is Node code in the deploy process. Bridge the two:

- ApplyMigrations is refactored around a D1SqlExecutor — the same
  executor-agnostic flow (wrangler-compatible d1_migrations table,
  idempotent re-application, sequential ids) now runs against either
  backend. The cloud executor keeps distilled's d1.queryDatabase.
- LocalD1Gateway boots a scoped, ephemeral workerd whose only module
  forwards POST bodies to the raw `d1` service (a plain service binding
  carrying the database id on the designator props), so Node speaks the
  full multi-statement D1 HTTP protocol into the simulator's DO SQLite.
- The D1 local provider applies migrations in reconcile through that
  gateway, records migrationsHashes, and detects file/table drift in
  diff exactly like the live provider. importFiles remain cloud-only.

The cloudflare-dev example's D1 database now uses a real migrationsDir
and its /d1 route relies on the migrated schema (no runtime DDL).

Co-authored-by: Cursor <cursoragent@cursor.com>
…)-in-dev coverage

Establishes the practice: every resource with a local provider gets a
co-located {Resource}.local.test.ts (Test.make({ dev: true })) covering
both the local-simulator roundtrip and the Alchemy.live() opt-out —
documented in the AGENTS.md provider-modes doctrine.

- Renames the new local suites to the convention (KV/Namespace.local,
  R2/Bucket.local, D1/Database.local, Workers/CacheCf.local).
- Adds Alchemy.live()-in-dev tests for KV (mixed local + live namespaces
  on one worker), R2, and D1: real (non-dev:) identities, remote-proxied
  bindings verified out-of-band via distilled, and the stamped-live
  delete on destroy verified gone from the cloud.
- KV fixture selects the binding under test via ?binding=; R2 fixture
  gains a /seed route that writes without deleting.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ist-optional providers

- Provider.succeed/effect accept an optional `list` (safe [] default),
  removing the inference trap where the missing required member
  defaulted every *Req type param to never. Local providers drop their
  boilerplate empty list.
- Inline `script:` workers now serve under the local provider (the
  string IS the module; changes restart via the hashed config) instead
  of silently hanging on a bundler watch that never emits.
- Queue bindings carry an alchemy-only `queueId` (stripped before
  upload) so dev can discriminate: local queues use the broker;
  Alchemy.live() queues fail the deploy loudly — the runtime's remote
  queue producer (queue-remote translator, companion branch) has an
  unfinished capnweb RPC leg upstream, and a clear deploy error beats a
  guaranteed 500 on first send.
- materializeWorkerBindings no longer double-emits resource-backed env
  entries as duplicate json bindings alongside their native binding.
- Queue.local.test.ts pins end-to-end local delivery (producer +
  consumer + broker) and the loud live()-queue failure; readiness
  backoff in local tests is capped (uncapped exponential over 10 recurs
  summed to ~8.5 minutes).

Co-authored-by: Cursor <cursoragent@cursor.com>
…motion test, runner hang fix

Closes out the local-provider gap list:

- QueryDatabaseLocal reaches the LOCAL simulator for `dev:` databases:
  the D1 client is refactored around a query transport, and a per-call
  ephemeral workerd gateway tunnels {sql, params} / batch bodies into
  the simulator's DO SQLite (same storage the worker binding reads).
  KV/R2 *Local capability layers fail `dev:` ids loudly with guidance
  (the D1 gateway is the template for their follow-up).
- D1 importFiles apply locally (multi-statement SQL through the
  gateway, hash-skip semantics matching the cloud import flow) with
  drift detection in diff.
- Worker `dev: { cache, cf }`: Cache API opt-out (workers.dev parity)
  and per-worker request.cf override, wired through the hashed config
  to the runtime (companion: RuntimeWorker.cf + per-worker Globals).
- DevPromotion.test.ts: a dev-mode stack (KV/R2/D1 `dev:` rows) deploys
  live — mode-switch replacements create real cloud resources, verified
  out-of-band, and destroy removes them.
- alchemy-test: a timed-out body is now interrupted fire-and-forget
  with a bounded 10s teardown grace, then abandoned — a hung finalizer
  (e.g. a scratch destroy blocked on wedged dev machinery) can no
  longer swallow the timeout report and stall the run to the wall.
- cloudflare-tools submodule bump: remote-queue scaffolding (marked
  non-functional), RuntimeWorker.cf, WORKERD_DUMP_CONFIG debug dump.

Co-authored-by: Cursor <cursoragent@cursor.com>
The `*Local` KV and R2 capability layers (Action-side clients speaking
the cloud REST API) can now reach `dev:` resources: each op boots an
ephemeral workerd gateway that emulates the REST endpoints the client
builders call over the native binding, and the op's HttpClient is
rebased onto the gateway origin — same clients, same distilled ops,
same typed error matchers (KeyNotFound 10009, NoSuchKey 404), local
data plane. Shared scaffolding lives in Cloudflare/LocalGateway.ts;
the D1 gateway is refactored onto it.

- KV: values GET/PUT(multipart)/DELETE, metadata, keys list, bulk/get
- R2: object GET/PUT/DELETE, bulk delete, list with cursor
- Action-seeding tests prove the worker's native binding reads what
  the Node-side client wrote (KV + R2)

Queue live() producers stay a loud deploy-time error, now citing the
platform limitation: Cloudflare preview sessions do not support queue
bindings at all (an edge preview with one serves 503 for every
request; wrangler has the same gap — cloudflare/workers-sdk#9929).

Also fix the cache-cf test fixture to use a per-run cache key (the
local cache simulator persists across runs), and bump cloudflare-tools
for the per-worker cf blob, the Bun-spawner workerd console output fix,
and the process-wide port allocation fix that resolved rotating 120s
hangs when many local dev stacks start concurrently.

Co-authored-by: Cursor <cursoragent@cursor.com>
…latform limitation

Co-authored-by: Cursor <cursoragent@cursor.com>
…ne-managed shim

Producing to an Alchemy.live() queue from a locally-running worker now
works. Cloudflare preview sessions reject queue bindings at the
platform level (cloudflare/workers-sdk#9929), so the eval conditionally
registers a REAL shim worker instead — an ordinary engine-managed
Worker (+ Alchemy.Random bearer token) instantiated when a LOCAL host
binds a LIVE queue, the same idiom as AccountApiToken and event-source
mappings:

  local worker ── env.QUEUE.send() ──▶ forwarder (local workerd)
       wire protocol + bearer token ──▶ deployed shim (workers.dev)
                                    ──▶ real Cloudflare Queue

The engine provides the whole lifecycle: Output-based ordering (shim
deploys before the local worker serves), stable-name updates, deletion
on destroy, and orphan GC on promotion (a live deploy stops
registering the shim). Both binding spellings are covered — plain
`env: { QUEUE: queue }` (WorkerAsyncBindings) and the WriteQueue
capability layer. v8-serialized messages are rejected with a 422
explaining to pass an explicit contentType; the shim's queueId/shim
metadata is stripped from the wire shape before upload.

The e2e test deploys a live() queue + local worker in dev, sends
single and batch messages through the binding, and pulls them back
out of the REAL queue via an out-of-band http_pull consumer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Consuming an Alchemy.live() queue from a locally-running worker now
works, completing the dev-mode queue story (producers landed via the
deployed shim):

  local worker ──▶ shim ──▶ real queue ──▶ pull loop ──▶ local broker
                                             ──▶ local queue() handler

- The Consumer's local provider, for a live queueId, observes the real
  queue (name + consumers), ensures an http_pull consumer exists for
  the pull loop to lease from, and records queueName/pullConsumerId on
  the attributes; delete removes the pull consumer (idempotent).
- LocalWorkerProvider wires consumers of live queues with
  `pull: { queueId, accountId }` so the runtime's Queue plugin drains
  the real queue into the local broker — local batching/retry/DLQ
  semantics apply from there.
- E2E test: live() queue + local worker + Consumer; a message produced
  through the binding lands in the REAL queue and comes back to the
  local queue() handler; destroy removes the queue, shim, and pull
  consumer.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Conflict: main's assets-only Workers (#969) added its dev-mode support
to LocalWorkerProvider's old runInstance structure, which this branch
replaced with LocalProvider.make. Resolved by porting the feature into
the new structure: an `assetsOnly` flag on the resolved (hashed) config
and a runAssetsOnly branch in the start dispatch serving the
ASSETS-delegating stub. Added AssetsOnly.local.test.ts to pin the
dev-mode path (main only covered the live deploy).

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment on lines +267 to +273
// A `dev:` id means the live database doesn't exist yet — update
// (create) rather than replace, even if name/account changed. The dev
// id is about to be replaced by a real one, so it must not be
// advertised as stable for this update.
if (output?.databaseId && !isLiveId(output.databaseId)) {
return { action: "update", stables: ["accountId"] } as const;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we wanted the engine to see these as distinct entities with a replace in between, orchestrated by the engine, so that way the isLiveId bit is no longer necessary. Did that not work out?

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.

You were right — it did work out; this was vestigial. The engine plans a replacement on any stamped-mode mismatch (without consulting the provider diff) and routes each generation's delete to the provider of the mode that created it, so a live provider can never actually see a dev: id. Removed every isLiveId branch from the KV/R2/D1/Queue live providers in 427b564 and replaced DevPromotion.test.ts with ModeCycle.test.ts — the full local → hybrid (live() within dev) → live → local cycle against the real cloud, including the previously-untested demotion leg. All green with zero promotion logic in the providers.

Comment thread packages/alchemy/src/ProviderMode.ts Outdated
Comment on lines +31 to +34
export class ProviderModePolicy extends Context.Service<
ProviderModePolicy,
boolean
>()("ProviderModePolicy") {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have you considered using Context.Reference instead of Context.Service? This way the default value is returned automatically if not specified in context.

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.

Done in 427b564 — with one nuance: the some/none distinction was load-bearing (an explicit policy that disagrees with a prior registration dies with ConflictingProviderModeError; an absent one inherits). So it's a tri-state Context.Reference<boolean | undefined> defaulting to undefined, which keeps that distinction while collapsing the serviceOption/Option juggling at the consumers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can probably be simplified using the platform proxy - implementation in that PR isn't perfect but can be adapted.

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.

Adopted — and it reached further than D1. I extracted the platform proxy from #74 into alchemy-run/cloudflare-tools#88 (adapted for post-#85 main; the main fix was a layer-lifetime bug where Effect.provide tore down the scoped services as soon as open() resolved), then migrated all three gateways in bccbdad:

  • D1: withLocalD1Query opens a proxy with a raw d1 service binding and POSTs the D1 HTTP protocol through the fetch passthrough — multi-statement migrations keep working, bespoke gateway worker gone.
  • KV/R2: the REST-API emulation gateways are deleted entirely; for dev: ids the *Local layers now reuse the *Binding client builders over proxied native bindings (R2 rich objects needed a new r2-object protocol tag in feat: dev mode for cloudflare workers #88 — body buffering + Node-side rehydration with bodyUsed semantics).

sam-goodwin and others added 2 commits July 28, 2026 13:55
Co-authored-by: Cursor <cursoragent@cursor.com>
…mode switches are engine replacements

Review feedback from #963 (john-royal):

- Remove every isLiveId promotion branch from the KV/R2/D1/Queue live
  providers (diff update-with-narrowed-stables, reconcile/read dev-id
  skips, delete guards). The engine already plans a REPLACEMENT when a
  row's stamped providerMode differs from the resolved mode — without
  consulting the provider diff — and routes each generation's delete to
  the provider of the mode that created it, so a live provider can
  never see a dev: id. Queue's queueId returns to stables.
- Replace DevPromotion.test.ts with ModeCycle.test.ts: the full
  local → hybrid (live() within dev) → live → local cycle against the
  real cloud, asserting replacement identities, no-churn for the
  already-live resource across promotion, and the previously-untested
  demotion leg (live → local with real cloud deletions).
- ProviderModePolicy becomes a tri-state Context.Reference
  (undefined | true | false, default undefined), collapsing the
  serviceOption/Option juggling at its consumers while preserving the
  unset vs explicit distinction that conflict detection relies on.

Co-authored-by: Cursor <cursoragent@cursor.com>
sam-goodwin and others added 4 commits July 28, 2026 15:35
Review feedback from #963 (john-royal): replace the hand-rolled
ephemeral-workerd gateways with the runtime's platform proxy
(cloudflare-tools#88, extracted from #74).

- D1: withLocalD1Query opens a proxy hosting a raw `d1` service binding
  and POSTs the full D1 HTTP protocol through the proxy's fetch
  passthrough — multi-statement migrations/imports keep working, minus
  the bespoke gateway worker.
- KV/R2: the REST-API emulation gateways are gone entirely. For `dev:`
  ids the *Local layers now build the same native-binding clients the
  *Binding variants use (makeReadKVClient / makeRead / …) over
  per-operation proxied bindings; real ids keep the HTTP clients. A
  shared dispatchByMode builds the per-call dispatching client from the
  lazily-resolved id. R2 rich objects (R2ObjectBody bodies, metadata,
  writeHttpMetadata) ride the proxy's new "r2-object" encoding.
- LocalGateway.ts shrinks to the shared runtime layer, gatewayName, and
  dispatchByMode; the REST-emulation scaffolding (withLocalGateway,
  rebaseHttpClient) is deleted.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…r-aggregating destroy

Ports into the LocalProvider.make structure:
- make-before-break serveWith (workerd scopes fork from rootScope, closed on
  cutover / closeWorkerd) from #863
- url/urls/domain Attributes + resolveLocalUrls wildcard-host handling from #977
  (local urls no longer carry a trailing slash; tests updated to `${url}/path`)
- ALCHEMY_WORKER_NAME env (#860), viteMain root-relative resolution (#796),
  toRuntimeBinding dev.remote param for send_email (#865)

distilled bumped to main (0.30.2).

Co-authored-by: Cursor <cursoragent@cursor.com>
"remote" matches the ecosystem vocabulary for dev-time real-cloud bindings
(wrangler's remote bindings, cloudflare-runtime's *.remote constructors,
the send_email dev.remote prop). The persisted ProviderMode enum stays
"live" | "local" — only the user-facing decorator is renamed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sam-goodwin
sam-goodwin merged commit 68fd790 into main Jul 29, 2026
9 checks passed
@sam-goodwin
sam-goodwin deleted the feat/provider-modes branch July 29, 2026 01:46
john-royal added a commit that referenced this pull request Jul 30, 2026
Brings in 94 commits from main (local vs live provider modes #963,
workersDev/domain props #977, Worker.URL self-binding #964, assets-only
Workers #969, Prisma provider #416, version affinity #985, telemetry
#860) while preserving this branch's SourceProvider architecture and
Website framework integrations.

- Worker providers take main's side wholesale; the SourceProvider
  integration is re-grafted as a dispatch: `props.source` routes through
  `resolveSource`/`loadSource` (build, hash slots, and local dev in both
  server and bundle modes via the make-before-break serve path), while
  script/vite/python/prebuilt/assets-only workers keep main's paths.
- Apply.ts: both sides landed the resolved-bindings persistence fix
  (#874 / ef08f4c); merged as the union, keeping `providerMode` and
  `bindings` on replaced-state commits.
- test Utils/Http.ts: keep main's generalized retryResponse machinery
  (expectUrlRedirect/expectUrlHeader) and re-add expectDirectStatus on
  top of it.
- Website tests track main's API: `url`/`subdomain` props fold into
  `workersDev`; dev-mode R2 cleanup skips virtual `dev:` buckets.
- cloudflare-tools submodule bumped to this branch's merge of its own
  upstream main (59c3861); distilled synced to main's pointer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sam-goodwin added a commit that referenced this pull request Jul 30, 2026
…lt emulation (#963)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
wmadden pushed a commit to wmadden/alchemy that referenced this pull request Aug 3, 2026
Responding to review: replace the providers({ dev }) override option with
the ProviderLayer.dual registration introduced in alchemy-run#963, matching the
Cloudflare providers.

Each Prisma resource module now exports its Provider() factory as a dual
layer: live = the Management API implementation, local = the dev stub
(Prisma.Database keeps its @prisma/dev-backed local implementation, Compute
keeps ComputeDevProvider as its local variant). The engine resolves the
variant per run and per resource, so alchemy dev picks local automatically
and Alchemy.remote() opts individual resources back into live.

- remove providers({ dev }), PrismaLocalProviders, and liveProviders();
  embedders replacing implementations construct their own layer from the
  exported per-resource Provider() factories, the Providers collection, and
  managementApi()
- move the dev stub helpers to Prisma/Internal/DevStub.ts and each stub
  into its resource module as the dual's local thunk
- providers() now always carries the (lazy) stack management-api layer; it
  registers auth without resolving credentials, so dev needs no token
- tests: provide AlchemyContext where provider layers are built directly,
  assert dual mode metadata, drop the dev-override test

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
DavidJFelix added a commit to DavidJFelix/alchemy-effect that referenced this pull request Aug 7, 2026
Resolves conflicts between the dashboard work (deployment journal in
apply, --ui deploy flow, delete-node pending reporting) and main's
Plan.destroy + aggregated destroy failures (alchemy-run#973), destroy stack-state
cleanup (alchemy-run#965), and local/live provider modes (alchemy-run#963):

- apply: keep the journal exit-mapping; run state.deleteStack after the
  deployment journal closes on a successful destroy
- collectGarbage: adopt main's outcome-based blocked/failed delete
  aggregation, keep the pending status report for queued deletions
- deploy/destroy/test harness: Plan.destroy + apply command option
- Cloudflare Workers ui: domains attr became singular domain
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.

2 participants