Skip to content

Run prisma dev converges in the prisma process - #411

Draft
wmadden-electric wants to merge 3 commits into
claude/alchemy-deploy-in-processfrom
claude/alchemy-dev-in-process
Draft

wmadden-electric wants to merge 3 commits into
claude/alchemy-deploy-in-processfrom
claude/alchemy-dev-in-process

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
$ prisma dev
# … first converge, services start …
# edit modules/catalog/src/module.ts
modules/catalog/src/module.ts changed. dev loaded the app definition files when it started and cannot load them again; restart dev to apply the change. Rebuilds are paused until then.

prisma dev now runs every converge (the first one and each rebuild) inside the prisma process through the app's converge from #405, with Composer's local target providers. It no longer writes .prisma-composer/dev/<env>/alchemy.run.ts or spawns the Alchemy CLI.

Stacked on #405. Draft: do not merge before #404 and #405.

What changes for users

  • Edits to app definition files need a restart. These are the entry module and every app file it imports outside node_modules. The old child imported the app fresh on every rebuild; inside the prisma process, Node and Bun cache those modules and cannot drop them. Dev now records every file the entry import loaded, and when one changes it pauses rebuilds and asks for a restart. Edits to service code (build output) still apply live. This amends ADR-0056. Pending Will's decision between this and a Node-only live reload.
  • Each converge shows as a step (dev.converge, then dev.rebuild.<n>) with its resources inside, in human and --json output. Deploy and dev share one mapper.
  • Ctrl-C during the first converge exits 130 (DEV.INTERRUPTED) and releases the lease. Ctrl-C during a rebuild waits only for a running converge.
  • New codes: DEV.INTERRUPTED, DEV.CONVERGE_RUNNING, DEV.WORKER_THREAD. DEV.STACK_WRITE_FAILED is replaced by DEV.ENVIRONMENT_WRITE_FAILED.
  • Dev still needs no Prisma token.

How app definition files are recorded

  • Node: the existing resolve hook in entry-resolution.ts also records each resolved file: URL outside node_modules while the entry loads. It only observes.
  • Bun: Bun.plugin onResolve does not see static imports, so dev compares require.cache before and after the entry import. Bun keeps ES modules there too.

Removed

dev/generate-dev-stack.ts, family/dev-converge-child.ts, the fake-child fixture, and renderDevStackFile from @prisma/composer-cli/testing. Destroy keeps generate-stack.ts and run-alchemy.ts.

Alternatives considered

  • Live reload on Node with a resolve hook that adds a generation query to app files. Bun has no such hook, and each rebuild keeps another copy of the edited modules. Deferred.
  • A worker or child per reload. The app graph holds functions and Effect layers that cannot cross a process boundary.
  • Scanning import statements. Misses dynamic imports and tsconfig paths.

Agent: maat-73

🤖 Generated with Claude Code

wmadden-electric and others added 2 commits November 2, 2026 11:17
…ocess

prisma dev, and the dev operation, now lower the app against the local
target and run Alchemy's plan and apply in the prisma process, for the
first converge and every rebuild. No .prisma-composer/dev/<env>/alchemy.run.ts
is written and no Alchemy child is spawned. destroy keeps the child.

- The app's @prisma/composer/internal/converge also exports
  localTargetProviders and devState; CONVERGE_CONTRACT is 2.
- Each converge has its own scope, so the state lease is held only while it
  runs. Rebuilds stay one at a time and coalesce.
- Converge progress reaches the user as converge-resource and
  converge-message dev events; prisma dev renders them as steps and
  messages, with console stdout sent to stderr for the session.
- A failed first converge is DEV.CONVERGE_FAILED with the reasons; a failed
  rebuild is a converge-failed event with the cause, keeping the app. No
  stack file path or reproduce command.
- DevInput.signal interrupts a running converge: the first one fails with
  DEV.INTERRUPTED (prisma dev exits 130); stop() interrupts a rebuild's
  converge and waits for it before stopping services.
- The app is imported once per process, so an edit to the entry module or a
  service's authoring module is reported (definition-changed) and rebuilds
  pause until dev restarts.
- Deleted generate-dev-stack.ts, family/dev-converge-child.ts, the orphaned
  fake-child fixture, and renderDevStackFile from the testing entry.
  DEV.STACK_WRITE_FAILED becomes DEV.STATE_WRITE_FAILED.
- ADR-0064 extended to dev; deploy-cli.md, local-dev.md, guides, the skill
  and the amended ADRs updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…steps, dev codes

- dev records every app file (outside node_modules) the entry import
  loaded: under Node through the existing resolve hook (observe only), under
  Bun from the modules require.cache gained, which includes ES modules. A
  Bun.plugin onResolve sees only dynamic imports, so it is not used. These
  app definition files, plus each authoring module, are hashed and watched;
  an edit to any of them is definition-changed.
- One step tracker and one converge-event mapper for deploy and dev. Each
  dev converge is a step (dev.converge, dev.rebuild.<n>) with its resources
  inside it, and every step it opened is closed when it ends.
- A refused dev converge is DEV.CONVERGE_RUNNING or DEV.WORKER_THREAD, on
  the first converge and in a rebuild's converge-failed event.
- DEV.STATE_WRITE_FAILED is DEV.ENVIRONMENT_WRITE_FAILED.
- stop() waits only for a running converge; a rebuild still in its pipeline
  returns before converging.
- CONVERGE_CONTRACT stays 1: contract 1 was never published.
- The store integration test edits a sub-module's module.ts while dev runs
  and checks for the restart notice and that nothing converges.
- Docs use "app definition files" throughout; running-locally.md no longer
  overstates or understates what is detected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@prisma-gizmo

prisma-gizmo Bot commented Nov 2, 2026

Copy link
Copy Markdown

⏸️ Gizmo skipped the automatic review of 721d18a because this pull request is a draft. It will review automatically once the PR is marked ready for review.

  • Check this box to request a one-time review of the current commit.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@prisma/composer@411
npm i https://pkg.pr.new/@prisma/composer-cli@411
npm i https://pkg.pr.new/@prisma/composer-prisma-cloud@411

commit: 49bac8b

…ev-in-process

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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