Skip to content

fix(engine): destroy robustness — aggregated GC failures + fatal zombie rows - #899

Merged
sam-goodwin merged 3 commits into
mainfrom
claude/engine-destroy-robustness
Jul 21, 2026
Merged

sam-goodwin merged 3 commits into
mainfrom
claude/engine-destroy-robustness

Conversation

@sam-goodwin

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

Copy link
Copy Markdown
Member

Engine hardening 2/3 — based on claude/engine-binding-diff-stability; merge in order B1→B2→B3. Destroy (and the GC phase of a deploy) previously failed fast; now it deletes everything it can and aggregates every failure.

  • One failing provider delete interrupted every sibling deletion mid-flight, leaving their physical resources and state rows behind. collectGarbage now records per-resource failures, keeps deleting, and raises the combined cause at the end. An upstream whose dependent failed skips its own physical delete (state retained) via an internal DependentDeletionFailed marker, without double-recording the cause.
  • A "zombie" state row — a resourceType with no registered provider (type removed from the program, or renamed without an alias) — is fatal at plan time. The program and state fundamentally disagree, and without the provider the row's physical resource cannot be deleted anyway, so nothing is deployed or destroyed. Previously this died deep inside findProviderByType with a bare string; the plan now dies up front with a typed error naming the row and the remediation:
export class MissingProviderError extends Data.TaggedError("MissingProviderError")<{
  message: string; // includes remediation: re-register / alias / clear the row
  resourceType: string;
  fqn: string;
}> {}
  • The replaced-chain drain loop stops after a failed pass instead of spinning forever on rows that cannot make progress.

New offline suite test/destroy-robustness.test.ts: sibling non-interruption, dependent-failure skip, failing attr-less read recovery, and zombie fatality on both destroy and deploy — including the remediation path (clear the row → destroy proceeds); plan.test.ts pins that a zombie row fails the plan with resourceType/fqn/remediation intact.

🤖 Generated with Claude Code

sam-goodwin and others added 2 commits July 21, 2026 01:32
…+ deterministic sid order

A no-change redeploy could mark every bound resource "update" forever:

- Binding rows were persisted without stripping unresolved leaves. A
  function-typed Effect in binding data (a tagged Worker/Function class in
  env — the standard circular-binding pattern) passes through plan/apply
  resolution untouched, and durable (JSON) state stores persist it via its
  toJSON as an {"_id":"Effect",...} relic. The next plan's diffBindings then
  compares that relic against the live class stripped to undefined — a
  phantom binding "update" on every deploy. Apply now strips binding rows at
  every commit boundary (lifecycle commits, converge, GC), the same
  invariant #835/#874/#890 established for props.

- Binding registration order is not stable across deploys (capability
  layers do real IO concurrently before host.bind), so provider
  diff/reconcile inputs and persisted rows could flip order and churn any
  consumer that hashes or deep-compares the array. dedupeBindings and
  diffBindings now return sid-sorted rows, and Plan normalizes oldBindings
  through dedupeBindings too.

New offline engine suite test/binding-stability.test.ts pins no-change
redeploys to all-noop plans across nine binding-data shapes on both the
in-memory store and a JSON round-tripping store, plus the ordering and
plain-data invariants.

Co-Authored-By: Claude Fable 5 <[email protected]>
… tolerance

Destroy (and the GC phase of a deploy) previously failed fast:

- One failing provider `delete` interrupted every sibling deletion
  mid-flight, leaving their physical resources AND state rows behind.
  collectGarbage now records per-resource failures, keeps deleting
  everything it can, and raises the combined cause at the end. An upstream
  whose dependent failed skips its own physical delete (state retained) via
  an internal DependentDeletionFailed marker, without double-recording.
- A "zombie" state row — resourceType with no registered provider (type
  removed from the program, or renamed without an alias) — killed the ENTIRE
  plan via `findProviderByType`'s die, blocking both deploy and destroy.
  Plan/GC now fall back to a stub provider whose lifecycle fails with a
  typed `MissingProviderError`, so everything else applies/destroys and the
  zombie surfaces in the aggregated failure with a remediation message. The
  row is retained so re-registering the provider (or aliasing) reclaims the
  physical resource.
- The replaced-chain drain loop stops after a failed pass instead of
  spinning forever on rows that cannot make progress.

New offline suite test/destroy-robustness.test.ts covers: sibling
non-interruption, dependent-failure skip, failing attr-less read recovery,
and zombie rows on both destroy and deploy; plan.test.ts pins that zombie
rows still plan.

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/23e8174

@alchemy.run/better-auth

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

@alchemy.run/pr-package

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

Base automatically changed from claude/engine-binding-diff-stability to main July 21, 2026 22:31
Review feedback: a state row whose resource type has no registered
provider means the program and state fundamentally disagree, and
without the provider the physical resource cannot be deleted anyway —
falling back to a stub that fails one row while everything else
proceeds just strands the zombie silently. The plan now dies up front
with MissingProviderError (resourceType + fqn + remediation) and
nothing is deployed or destroyed. missingProviderStub is gone; tests
assert the fatal behavior and the clear-the-row remediation path.

Co-Authored-By: Claude Fable 5 <[email protected]>
@sam-goodwin sam-goodwin changed the title fix(engine): destroy robustness — aggregated GC failures + zombie-row tolerance fix(engine): destroy robustness — aggregated GC failures + fatal zombie rows Jul 21, 2026
@sam-goodwin
sam-goodwin merged commit eb63af6 into main Jul 21, 2026
9 checks passed
@sam-goodwin
sam-goodwin deleted the claude/engine-destroy-robustness branch July 21, 2026 22:52
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