Add Alchemy deployment for the Cloudflare cluster - #7550
Open
tim-smart wants to merge 3 commits into
Open
Conversation
…grams CloudflareDurableObjectPrograms exposes the entity, workflow, durable queue, and singleton Durable Object behaviors as Effect programs over a minimal native state, so frameworks that create their own classes can run them. AlchemyCloudflareCluster.make runs inside an Effect-native Cloudflare.Worker init program: it registers four library-owned alchemy Durable Object classes backed by the programs, builds CloudflareCluster.layer merged with the user layer into the isolate-lifetime scope, and returns the provide/wake handle with the native namespace escape hatches. alchemy is an optional peer dependency and the package index stays free of it.
The minimal example at packages/platform/cloudflare/examples/alchemy (worker plus alchemy.run.ts, one entity and one singleton) and the tstyche typetests compile in normal PR CI against the pinned alchemy peer. They live in their own tsconfig project (tsconfig.alchemy.json, referenced from the root tsconfig so 'pnpm check' covers it): the alchemy type graph loads bun globals that clash with the shared tests project's node globals. An @types/ssh2>@types/node override keeps a second @types/node major out of the install for the same reason.
The workflow_dispatch-only canary reinstalls the latest alchemy@beta and reruns the integration typechecks and typetests. The README gains the Alchemy walkthrough, a pointer to examples/alchemy, and the manual live smoke checklist; the Wrangler section is unchanged.
🦋 Changeset detectedLatest commit: f414380 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the Alchemy v2 ("Infrastructure as Effects") deployment story for the Cloudflare cluster, stacked on #7322. Closes EFF-988.
AlchemyCloudflareCluster.makeruns inside an Effect-nativeCloudflare.Workerinit program. It registers four library-owned alchemy Durable Object classes (Alchemy owns bindings, class exports, and SQLite migrations), buildsCloudflareCluster.layermerged with the user's handler layer into the isolate-lifetime scope, and returns a handle. The user never declares or re-exports DO classes:CloudflareDurableObjectPrograms(revived from Simplify Cloudflare Durable Object framework integration #7385, rebuilt on the current internals) exposes the four Durable Object behaviors as class-independent Effect programs; the alchemy DO classes call them, and the Wrangler classes are untouched.provide(attaches the built Context),wake(name)(a cron handler for the singleton, noSingleton/prefix), the four native namespace bindings as escape hatches, andcontext.alchemyis an optional peer (>=2.0.0-beta <3, dev-pinned to2.0.0-beta.76); the package index stays alchemy-free, the module is reachable only via@effect/platform-cloudflare/AlchemyCloudflareCluster.packages/platform/cloudflare/examples/alchemy(one entity, one singleton, one Cron Trigger) plus tstyche typetests, both typechecked in normal PR CI. They compile in a dedicatedtsconfig.alchemy.jsonproject because the alchemy type graph loads bun globals that clash with the shared tests project's node globals (same reason for the@types/ssh2>@types/nodeoverride).workflow_dispatchcanary (Alchemy Canary) reinstalls the latestalchemy@betaand reruns the typechecks/typetests.Two deviations from the handoff snippet, both forced by the actual alchemy@beta.76 surface:
Cloudflare.Workers.crontakes a handler function, socluster.wake(name)returns() => Effect<void>(passed directly tocron) rather than a bare Effect.cronrequiresCronEventSourceLiveprovided on the init program (alchemy's documented pattern); the cluster layer itself is still never provided that way.Runtime unit tests cover the programs and the handle building (
internal/alchemyCluster). The alchemy-importing glue is typecheck-only in this repo: alchemy's runtime targets the publishedeffectrelease, which has diverged from workspace HEAD (e.g.Config.string→Config.String), so executing alchemy code against the workspace source fails by construction — that skew is exactly what the canary watches. The livealchemy deploysmoke from the README checklist still needs one run by someone with Cloudflare credentials.Supersedes #7548.