Skip to content

feat(dev): prisma dev runs a service with its build adapter's dev server (ADR-0056) - #381

Merged
sneub merged 15 commits into
mainfrom
feat/dev-server
Oct 27, 2026
Merged

sneub merged 15 commits into
mainfrom
feat/dev-server

Conversation

@sneub

@sneub sneub commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Implements ADR-0056 (#377).

Summary

Under prisma dev, a Next.js service could only run its assembled standalone build. Every edit needed next build and a reconverge, its logs never reached the terminal, and plain next dev couldn't read service.load() or service.input(). Following ADR-0056, a service now runs the dev server its build adapter declares, on its own instance and port, with the environment a deployment would give it. nextjs() runs next dev; node({ dev: [...] }) runs the command the author wrote. There is no flag: prisma dev module.ts is the whole command.

  • core: build descriptors gain an optional serve step, returning a DevServer. LowerOptions.unassembled lowers a service through a new optional reserve hook in place of package + deploy. LocalTargetAttachment gains serve, logs gains addresses, and LocalNodeLocation gains command.
  • assemble: assembleServices(…, { devServers }). A serve step that throws is DEV.DEV_SERVER_UNAVAILABLE.
  • nextjs / node: serve steps; node() gains dev.
  • dev-emulators: a deployment can be { command: { cwd, argv } }. A put answers { started }, and the instance view reports command.
  • prisma-cloud: stash / stashProviderParams / stashInput become one pure stashRows, which run() applies, so a dev server gets exactly the rows run() writes. The compute descriptor gains reserve, and the local attachment gains serve.
  • cli: dev servers are announced before the first converge, lowered unassembled, and served after resume and after every reconverge (dev-server-restarted when the emulator restarts one). Their output is streamed as [address] line. The entry and authoring modules are watched. ServiceEndpoint.devServer and DevUrl.runs are new. A missing reserve or serve is DEV.DEV_SERVER_UNSUPPORTED before anything converges.
  • docs / skill / example: running-locally gains a "Dev servers" section; getting-started and the core-concepts skill mirror it; local-dev.md registers the two codes. examples/store drops scripts/dev.ts, which ran against in-memory fakes with env names the storefront no longer reads: pnpm dev is now prisma dev module.ts with nothing to build.

Testing performed

  • pnpm typecheck, pnpm lint, pnpm lint:deps, pnpm lint:casts, lint:control-bytes, lint:retired-binary-name, scripts/check-skill-packaging.mjs and the website content tests all pass.
  • New tests:
    • lowering unassembled / reserve
    • assembleServices({ devServers })
    • the Next.js and Node serve steps
    • emulator command deployments against a real daemon: bare-name resolution, no-op vs restart, artifact↔command switching, executable not found, malformed body, resume, readiness hint
    • stashRows
    • attachment serve against a real emulator: secret value, address-free stash, sibling rows hidden, shell env kept
    • dev() operation tests: event order, unassembled in the stack file, serve after resume, output streaming, authoring-module reconverge + restart event, both UNSUPPORTED cases, start failure rollback
    • family rendering; dev url runs
  • Package suites green: core 67, assemble 14, nextjs 17, node 48, dev-emulators 135, cli 316. In the prisma-cloud target suite, 6 unhandled initdb: program "postgres" is needed errors come from postgres-harness.ts because this machine has no system postgres binary. No named test fails.
  • Manual, against a fresh [email protected] Next.js app with packed 0.34.0 tarballs of this branch and [email protected]:
    • prisma dev module.ts, with no next build, runs next dev on the service URL.
    • Page and route edits hot-reload with the same process and no reconverge, and the /_next/hmr websocket opens on that URL.
    • service.load().database is the local Postgres.
    • An envSecret from .env reaches service.input(), once .env is loaded in prisma.config.ts (see notes).
    • Route console.log lines appear as [app] ….
    • Ctrl-C, --detach and dev stop leave no orphaned next/next-server, and dev url --json reports "runs":"dev-server".
  • Manual, examples/store: pnpm dev brings up catalog, orders and promotions under bun --watch and the storefront under next dev with no build; the storefront renders the Postgres-backed catalog over RPC.

Checklist

  • All commits are signed off (git commit -s) per the DCO. The DCO status check will block merge if any commit is missing a Signed-off-by: trailer.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • The PR title is a conventional commit (feat, fix, chore, docs, refactor, test, build) — PR titles drive the auto-generated release notes.
  • Tests are updated (or n/a if the change is doc-only / refactor with no behavioural delta).

Notes for the reviewer

Where the code departs from the ADR's literal text:

  1. Resolving next. The ADR says import.meta.resolve('next/package.json', pathToFileURL(appDir + '/')), but Node (24 and 26) ignores the parent argument without --experimental-import-meta-resolve. It would resolve from this package's install, not the app's. createRequire(appDir).resolve(...) does what the ADR intends.
  2. Log backlog. The session follows dev-server logs with a 200-line backlog, not tail: 0. Otherwise Next's startup banner, which is written while dev waits for readiness, never shows, though the ADR's own example output shows it. The emulator clears the log on each fresh start, so the backlog is only the current process's output.
  3. configKey / ORIGIN_KEY_NAME moved to a leaf config-key.ts, re-exported from serializer.ts. Having stashRows in serializer.ts import RESERVED_PROVIDER_PARAMS otherwise creates a TDZ import cycle, because origin-key.ts and streams-keys.ts use those values at module load.
  4. node({ dev: [] }) is rejected when node() is called. Builds are not validated when the graph is loaded, so there was no load-time check to hook into.

Known gaps:

  • .env and secrets. A secret that is only in a .env loaded by Next reaches the app as local-placeholder-…, because Composer sets the variable first and Next never overrides a set one. The guide documents the fix (process.loadEnvFile('.env') in prisma.config.ts). The create-prisma Next template doesn't do this today, so the template needs a follow-up.
  • Topology edits. The session imports the entry module once, so after a topology edit the Alchemy child converges the new graph but the session keeps the one it loaded. Adding or removing a service, or changing its build adapter, needs a restart. This predates the PR and is now recorded in local-dev.md.
  • Logs docs conflict. The running-locally.md Logs section will conflict trivially with the prisma dev logs PR (feat(cli): add prisma dev logs and point the dev front door at it #378), whichever merges second.

sneub added 9 commits October 23, 2026 21:40
…rves unassembled services

ADR-0056. A build descriptor gains an optional serve step returning a DevServer
(cwd, argv for a port and host, display). LowerOptions gains unassembled: those
services are provisioned and serialized as always, but reserve() runs in place
of package() and deploy(), so dependents get the same URL without an artifact.
The local-target attachment gains serve() and logs() an addresses filter; a
local node location may report the command it runs.

Signed-off-by: Shane Neubauer <[email protected]>
…assembled

ADR-0056. assembleServices takes { devServers }. With it, each service build
descriptor is asked for a dev server first; a returned DevServer is recorded in
AssembledServices.devServers and the service gets no bundle and no assemble
events. A serve step that throws is DEV.DEV_SERVER_UNAVAILABLE with the address.
prisma deploy passes nothing and assembles every service as before.

Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The Next.js descriptor serve step runs `next dev -p <port> -H <host>`
in appDir, with the next binary resolved from the app own dependencies. It
uses createRequire, because Node ignores import.meta.resolve parent argument
without --experimental-import-meta-resolve and would resolve from this
package install instead. node() gains an optional dev argv, run verbatim in
the authoring module directory; an empty one is rejected when declared.

Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The deployment body gains a command form ({ cwd, argv }) beside the
artifact form; a body with both or neither is malformed. argv[0] is used when
absolute, else resolved on the deployment env PATH like bun. Change detection
compares the form, then the hash or cwd/argv, env and listens. A put now
answers 200 { started }, true only for a fresh start. The instance view
reports command. Readiness failures of a command add that a dev server must
listen on its PORT. Readiness, logs, supervision, stop and resume are shared.

Signed-off-by: Shane Neubauer <[email protected]>
ADR-0056. The stash, stashProviderParams and stashInput functions become one
pure stashRows(node, address, env), which run() applies to process.env, so a
dev server is started with exactly the rows run() writes. configKey and
ORIGIN_KEY_NAME move to a leaf module so serializer.ts can import the reserved
provider params without a TDZ import cycle.

The compute descriptor gains reserve: deploy outputs and entity without the
Deployment, the URL taken from the App. The local attachment gains serve,
which materializes the deployment environment, stashes it, lays it over the
shell environment and puts a command deployment on the instance; logs takes
an addresses filter; a located service reports the command it runs.

Signed-off-by: Shane Neubauer <[email protected]>
…r output

ADR-0056. prisma dev asks build descriptors for dev servers; those services
are announced (dev-server event), lowered unassembled, and served on their
instance after the converge and the resume, and again after every successful
reconverge, where a restart is reported (dev-server-restarted). A descriptor
without reserve or an attachment without serve is DEV.DEV_SERVER_UNSUPPORTED
before anything converges, so attachments are now made before the first
converge. The foreground session follows the dev servers logs and emits
each line (dev-server-output), rendered as [address] line. The entry and every
service authoring module are watched, so a topology edit reconverges when
every service runs a dev server. ServiceEndpoint gains devServer (the endpoint
event data) and dev url gains runs.

Signed-off-by: Shane Neubauer <[email protected]>
Running locally gains a Dev servers section: Next.js services run next dev
with no build, node() services run their dev argv, output is streamed with
the address prefix, the environment is the deployment one over the shell,
and the gotcha that a secret only in a framework-loaded .env reaches the app
as the local placeholder (load .env in prisma.config.ts instead). Getting
started and the core-concepts skill mirror it. local-dev.md registers
DEV.DEV_SERVER_UNAVAILABLE and DEV.DEV_SERVER_UNSUPPORTED and records that
the session keeps the topology it started with.

Signed-off-by: Shane Neubauer <[email protected]>
Replaces scripts/dev.ts, which ran next dev against in-memory fakes with
pre-COMPOSER_ env names the storefront no longer reads. catalog, orders and
promotions declare dev: [bun, --watch, server.ts] and the storefront runs
next dev, so pnpm dev is prisma dev module.ts with nothing to build.

Signed-off-by: Shane Neubauer <[email protected]>
@sneub sneub changed the title feat(dev): prisma dev runs a service with its build adapter dev server (ADR-0056) feat(dev): prisma dev runs a service with its build adapter's dev server (ADR-0056) Oct 23, 2026
@prisma-gizmo

prisma-gizmo Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Gizmo reviewed 5e68e8a — posted 0 inline comment(s) this pass.

Open findings: none

Change walkthrough

This incremental delta touches only packages/0-framework/3-tooling/cli/src/dev/tests/watch.test.ts: the authoringModuleTargets() test now derives service module URLs with pathToFileURL(path.resolve(p)).href instead of hard-coding bare file:///repo/... strings, so the test inputs are valid file URLs on Windows (where a drive-less file:///repo/... URL makes fileURLToPath throw).

authoringModuleTargets in watch.ts:59-71 converts each file:-prefixed build.module with fileURLToPath and re-resolves it with path.resolve, so round-tripping the fixture paths through pathToFileURL(path.resolve(...)) reproduces exactly the same resolved path on POSIX and Windows — matching the path.resolve(...) expectations, which resolve identically on both. The dedup behavior under test (the web and admin services share one authoring module and yield a single watch target) is preserved, since both services now build byte-identical URLs, and the non-file virtual:service module is still skipped. The import swap from fileURLToPath to pathToFileURL is complete, with no leftover usage of the removed fileOf helper.

In the context of the larger PR (ADR-0056: prisma dev runs each service's build adapter's dev server), this test guards the watch set that reconverges on edits — the entry module plus each service's authoring module — and the delta makes that guard portable to Windows contributors and CI without changing what it asserts.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 548a2c8c-78c4-4ec4-9aec-4b400335cb29
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 5e68e8a

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New findings: none · trace

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No Gizmo finding is open and the head commit has been reviewed. Approving.

sneub added 4 commits October 27, 2026 15:51
The local-dev store integration proof (criterion 2) touches catalog dist and
expects exactly that service to restart; with a dev command catalog no longer
ran its artifact and the proof timed out. Catalog keeps the rebuild loop,
orders, promotions and the storefront keep their dev servers, so the proof now
also shows a rebuild does not restart dev servers. pnpm dev builds catalog
first.

Signed-off-by: Shane Neubauer <[email protected]>
Brings in ADR-0057 (#384): addresses start with the app name and COMPOSER_
keys normalise - to _. configKey moved to config-key.ts on this branch, so
addressKeySegments moves there with it and serializer.ts re-exports both;
stashRows keeps building keys through configKey and needs no other change.
The dev-server tests use full addresses (shop.auth, hello-dev.app,
fixture-module.web), and the stashRows test uses my-shop.web so it covers
the - to _ rule.

Signed-off-by: Shane Neubauer <[email protected]>
…R-0057)

After the merge of #384 every address starts with the app name, so the
front door, the dev-server lines and dev url read shop.web, not app.

Signed-off-by: Shane Neubauer <[email protected]>

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New findings: none · trace

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No Gizmo finding is open and the head commit has been reviewed. Approving.

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

New findings: none · trace

@prisma-gizmo prisma-gizmo Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No Gizmo finding is open and the head commit has been reviewed. Approving.

@sneub
sneub merged commit f244e9b into main Oct 27, 2026
26 checks passed
@sneub
sneub deleted the feat/dev-server branch October 27, 2026 05:35
wmadden-electric added a commit that referenced this pull request Oct 27, 2026
Brings in dev servers (#381), full node addresses (#384, ADR-0057), the deploy entry in prisma.config.ts (#387) and prisma deploy list (#388). The secrets decision becomes ADR-0058, and every reference to it moves with it.

A dev server gets its environment from materializeEnv, so it receives the same per-service secret values from process.env, an unset optional secret is absent, and a changed value restarts it; the serve test now covers both. The docs that described placeholders for dev servers now describe reading secrets before the dev server starts. Tests and expected error text use full addresses.

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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