Skip to content

chore: rename alchemy-effect → alchemy@2.0.0-beta.20#16

Merged
cooper (czxtm) merged 3 commits intomainfrom
claude/alchemy-effect-rename
Apr 29, 2026
Merged

chore: rename alchemy-effect → alchemy@2.0.0-beta.20#16
cooper (czxtm) merged 3 commits intomainfrom
claude/alchemy-effect-rename

Conversation

@czxtm
Copy link
Copy Markdown
Contributor

Summary

Upstream renamed alchemy-effect to alchemy (v2.x). Migrates the workspace to the new package + v2 API. Unblocks the bun install failure tracked in stackpanel-r7g.

Imports

  • alchemy-effect/Xalchemy/X across 10 source files
  • v2 no longer top-level re-exports Cloudflare, Output, Stage → switch to namespace imports (import * as Cloudflare from \"alchemy/Cloudflare\") and Alchemy.Stage from import * as Alchemy from \"alchemy\"

Stack API

v2 uses a 3-arg constructor with required state layer. All 5 deploy scripts (apps/{web,docs,api}, packages/db, packages/infra/src/docs.stack.ts) updated:

```ts
// v0.12.x (alchemy-effect)
export default Stack.make(name, providers)(program);

// v2 (alchemy)
export default Alchemy.Stack(
name,
{ providers, state: Cloudflare.state() },
program,
);
```

Package.json

  • 4 simple workspaces: \"alchemy-effect\": \"catalog:\"\"alchemy\": \"catalog:\"
  • packages/infra: drops dead \"alchemy\": \"^0.81.2\" (classic API not used in src/), switches catalog ref to v2

Cleanup

  • Deletes packages/infra/gen/ — stale duplicate of packages/gen/* workspaces (1 commit / 90d vs 44, zero external references)
  • Deletes vendored OpenNext asset overlay (vendor/alchemy-effect-opennext-overlay/, scripts/apply-alchemy-effect-opennext-assets.ts, scripts/ALCHEMY_EFFECT_OPENNEXT_UPSTREAM.md, root postinstall hook). The overlay was tied to alchemy-effect@0.12.x's file structure and is incompatible with v2

Behavior changes to flag

  1. State backend: All 5 stacks now use Cloudflare.state() instead of filesystem LocalState. First deploy from each environment will prompt to deploy the alchemy-state-store worker; CI runs require the store to exist or they die with AuthError. The actions/cache@v4 of apps/{web,docs}/.alchemy/ in the workflows is now a no-op and can be removed in a follow-up

  2. OpenNext cache overlay: apps/docs/alchemy.run.ts assets.sources field commented out with a TODO. Until alchemy@2 ships native AssetsProps.sources, OpenNext incremental cache misses for cdn-cgi/_next_cache paths fall back to ISR revalidation (cache hit-rate regression, not a hard breakage)

Verification

  • bun install succeeds; lockfile regenerated cleanly
  • tsc --noEmit clean for all 5 affected workspaces — no alchemy errors remain
  • Pre-existing unrelated errors untouched (third-party plugin type errors in @distilled.cloud/cloudflare-rolldown-plugin, root tsconfig.json empty files, unused dotenv import in packages/db/drizzle.config.ts)

Test plan

  • CI runs green
  • Manually verify apps/web deploy against a preview branch (Cloudflare state-store first-time bootstrap)
  • Manually verify apps/docs deploy
  • Confirm apps/docs cache hit-rate before vs after (acceptable regression)
  • Decide whether to keep the now-unused actions/cache@v4 of .alchemy/ in workflows

Closes the install-side of stackpanel-r7g.

Follow-ups filed:

  • Restore .open-next/cache asset overlay once alchemy@2 supports AssetsProps.sources (or vendor a v2-compatible patch)
  • Remove now-obsolete actions/cache@v4 of apps/{web,docs}/.alchemy/ from deploy workflows

Upstream renamed `alchemy-effect` to `alchemy` (v2.x). Migrates the
workspace to the new package and v2 API.

Imports
- `alchemy-effect/X` → `alchemy/X` across 10 source files
- Top-level `{ Cloudflare, Output, Stage }` no longer re-exported in v2 →
  switch to namespace imports (`import * as Cloudflare from "alchemy/Cloudflare"`)
  and `Alchemy.Stage` from `import * as Alchemy from "alchemy"`

Stack API
- v2 `Stack` is a 3-arg constructor `Alchemy.Stack(name, opts, effect)`
  with required `state` layer. All 5 deploy scripts (apps/{web,docs,api},
  packages/db, packages/infra/src/docs.stack.ts) now use
  `Cloudflare.state()` (Cloudflare-hosted state store)

Package.json
- 4 simple workspaces: `"alchemy-effect": "catalog:"` →
  `"alchemy": "catalog:"`
- `packages/infra`: drops dead `"alchemy": "^0.81.2"` (classic API not
  used in src/), switches catalog ref to v2

Cleanup
- Deletes `packages/infra/gen/` — stale duplicate of `packages/gen/*`
  workspaces (1 commit / 90d vs 44, no external references)
- Deletes vendored OpenNext asset overlay
  (`vendor/alchemy-effect-opennext-overlay/`,
   `scripts/apply-alchemy-effect-opennext-assets.ts`,
   `scripts/ALCHEMY_EFFECT_OPENNEXT_UPSTREAM.md`,
   root `postinstall` hook). The overlay was tied to the
  `alchemy-effect@0.12.x` file structure and is incompatible with v2.
  `apps/docs/alchemy.run.ts` `assets.sources` field commented out with
  a TODO referencing the follow-up — until alchemy@2 ships native
  `AssetsProps.sources`, OpenNext incremental cache misses for
  `cdn-cgi/_next_cache` paths fall back to ISR revalidation (cache
  hit-rate regression, not a hard breakage)

Behavior change to flag
- All 5 stacks now use `Cloudflare.state()` instead of the previous
  filesystem-only LocalState. First deploy from each environment will
  prompt to deploy the `alchemy-state-store` worker; CI runs require
  the store to exist or they die with `AuthError`. The existing
  `actions/cache@v4` of `apps/{web,docs}/.alchemy/` in the workflows
  is now a no-op and can be removed in a follow-up

Verification
- `bun install` succeeds (lockfile regenerated, the original
  stackpanel-r7g blocker is gone)
- `tsc --noEmit` clean for all 5 affected workspaces — no alchemy
  errors remain. Pre-existing unrelated errors (third-party plugin
  type errors, root tsconfig empty `files`, unused `dotenv` import)
  are untouched
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Cursor Bugbot is generating a summary for commit b35d8c7. Configure here.

cooper (czxtm) added a commit that referenced this pull request Apr 29, 2026
… follow-ups

stackpanel-r7g closed by PR #16 (alchemy-effect → alchemy@2 rename).

Follow-ups discovered while shipping the migration:
- stackpanel-49t — restore .open-next/cache asset overlay once alchemy@2
  ships AssetsProps.sources (vendored overlay was deleted as incompatible
  with v2's restructured Worker.ts/Assets.ts)
- stackpanel-zhq — remove now-obsolete actions/cache@v4 of
  apps/{web,docs}/.alchemy from deploy workflows (Cloudflare.state()
  replaces filesystem LocalState)
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b35d8c7013

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread packages/db/alchemy.run.ts Outdated
)(
{
providers: allProviders,
state: Cloudflare.state(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep DB stack on local state by default

Switching this stack to Cloudflare.state() makes bun run db:up depend on deploy-scope Cloudflare state credentials, but this entrypoint still only calls loadAppEnv("web", "dev"), which does not load the deploy scope where ALCHEMY_STATE_TOKEN/Cloudflare deploy vars are defined (packages/gen/env/src/embedded-data.ts). That regresses the previous local behavior (filesystem state) and can fail local Docker/Neon provisioning unless users manually inject deploy secrets. Use local state here or load deploy env before selecting the Cloudflare state backend.

Useful? React with 👍 / 👎.

apps/docs/alchemy.run.ts imports from `effect/Effect` directly but the
package wasn't declared as a dep, so bun's per-workspace resolution
inside `apps/docs/` (where the deploy step runs) couldn't find it.

Surfaced as `ResolveMessage: Cannot find module 'effect/Effect' from
apps/docs/alchemy.run.ts` in the Deploy Docs CI job for PR #16.
…e for staging/prod

Addresses PR #16 review: switching every stack to Cloudflare.state()
broke local entrypoints that don't load deploy-scope creds (notably
`bun run db:up`, which only loads `loadAppEnv("web", "dev")` — see
packages/gen/env/src/embedded-data.ts) and required CI deploys to first
bootstrap the Cloudflare state-store Worker, which alchemy v2 explicitly
won't do under CI=true.

Add `selectStateBackend(appEnv)` helper in @stackpanel/infra/lib/deploy:
  - dev      → localState() (filesystem; cached across CI runs via
               actions/cache; no Cloudflare creds required for PR
               previews or `bun run db:up`)
  - staging  → Cloudflare.state() (durable, team-shared)
  - prod     → Cloudflare.state() (durable, team-shared)

Wire it through apps/{web,docs,api}/alchemy.run.ts. Use localState()
directly in packages/db/alchemy.run.ts since it's local-only and has no
stage variable — this is the regression the reviewer flagged.

Unblocks the PR-16 preview deploys (which were failing with "Unauthorized:
Authentication error" from Cloudflare.state()'s first getScriptSetting
call) without requiring a token-scope change. Staging/prod still need
the state-store Worker bootstrapped interactively before their first
deploy, but that's a one-time, account-wide setup.
@czxtm cooper (czxtm) merged commit 66b3e57 into main Apr 29, 2026
4 of 7 checks passed
@github-actions
Copy link
Copy Markdown

Docs preview pr-16 has been destroyed.

@github-actions
Copy link
Copy Markdown

Preview pr-16 has been destroyed.

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