Skip to content

fix(cloudflare/workers): converge plans with Effect-valued env bindings - #890

Merged
sam-goodwin merged 5 commits into
mainfrom
claude/worker-spurious-update-1460d5
Jul 21, 2026
Merged

sam-goodwin merged 5 commits into
mainfrom
claude/worker-spurious-update-1460d5

Conversation

@sam-goodwin

Copy link
Copy Markdown
Member

Binding a tagged Worker identity in another Worker's env (the circular-bindings pattern) deployed correctly but re-planned as update on every subsequent plan, forever.

class Target extends Cloudflare.Worker<Target, {}>()("Target") {}

Caller.make({ main, env: { TARGET: Target } }, Effect.succeed({}))
// deploy → plan → "update", deploy → plan → "update", ...

The tag is an Effect: stripUnresolved drops it from stored props at commit, while the desired props still carry it — and its toJSON serializes to {"_id":"Effect",...}, so the engine's raw-props fallback saw a permanent diff.

Three changes, each covered by the new regression test:

  • havePropsChanged compares both sides through stripUnresolved, symmetric with the commit boundary, so an Effect in desired props no longer reports a phantom change.
  • WorkerProvider.diff (and the local dev provider) strip Effect-valued entries before the isResolved gate instead of bailing to the raw-props fallback — bundle/metadata hash change detection still runs, so a code-only edit to main still plans an update (verified: reverting just this piece makes the code-change assertion fail with a silent noop).
  • Terminal apply commits persist the resolved bindingOutputs the provider reconciled with instead of raw node.bindings (which hold unresolved Outputs that JSON state stores silently drop), so the next plan's diffBindings compares like against like. This is the second non-convergence path reported in the issue comments (the PR fix(core): persist resolved bindings on terminal commits #266 case).

The regression test deploys a target + a caller bound via the Effect tag in env, asserts the live service binding, asserts an identical program plans noop for both workers, then edits the caller's entry file and asserts the plan flips to update.

Closes #874

🤖 Generated with Claude Code

An Effect-valued Worker tag in `env` (the circular-bindings pattern)
re-planned as `update` on every deploy, forever (#874):

- `havePropsChanged` now compares both sides through `stripUnresolved`,
  matching the commit boundary — a tag's `toJSON` form no longer reports
  a phantom change against the stripped stored props.
- The Worker providers' `diff` strips Effect-valued entries before the
  `isResolved` gate so bundle/metadata hash change detection still runs
  (a code-only edit must still plan an update).
- Terminal apply commits persist the RESOLVED binding payload the
  provider reconciled with instead of raw `node.bindings`, so the next
  plan's `diffBindings` compares like against like.

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

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

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

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

@alchemy.run/better-auth

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

@alchemy.run/pr-package

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

sam-goodwin and others added 4 commits July 20, 2026 23:44
Regression for the second path reported in #874 (the PR #266 case):
plain_text binding whose text is an Output must plan noop after apply.

Co-Authored-By: Claude Fable 5 <[email protected]>
Guards the binding-data change-detection channel that #874's Effect
stripping relies on: v1 -> noop, v2 -> update -> deploys -> noop.

Co-Authored-By: Claude Fable 5 <[email protected]>
Unit regression for the Apply.ts half of #874 across the create,
update, and replace commit sites: persisted binding data must be the
resolved value, not a live Output expression.

Co-Authored-By: Claude Fable 5 <[email protected]>
@sam-goodwin
sam-goodwin merged commit 96bb913 into main Jul 21, 2026
6 of 8 checks passed
@sam-goodwin
sam-goodwin deleted the claude/worker-spurious-update-1460d5 branch July 21, 2026 07:32
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.

Effect-valued Worker env entries never converge: plans re-update forever

1 participant