Repository navigation
prisma dev --environment runs a separate local copy; dev url and dev stop act on what you name - #392
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…and environment devEnvironmentDir(environment) names .prisma-composer/dev/<encoded name>, percent-encoded so a / stays one folder. The devDir every local-target hook receives is that folder, and current() is asked for one app in one environment instead of returning the app run last. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The record (format 3) lives in the environment's folder and keeps every app run there; nothing selects a current app or stops another one. Instances get a composer.environment label. A pre-environment .prisma-composer/dev/ is moved into the environment dev: record, env.json, secrets.json and bucket objects. A bucket recorded over another directory is replaced by one over its folder, and a deployment whose artifact is no longer unpacked in the folder is deployed again, so moved state keeps working. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Preflight writes secrets to the environment's folder, the emulators hook ensures instances there and stops nothing else, --fresh removes only the environment's folder and its Alchemy stage, and current() reads one app in one environment. Preflight and teardown first move a pre-environment dev folder into dev. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
prisma dev, dev url, dev stop and the log operation take an environment (default dev). dev runs Alchemy at that stage with the stack file in the environment's folder, and refuses a local target extension whose container does not carry the environment (DEPS.EXTENSION_INCOMPATIBLE), as deploy does. dev url reads the app from the address without importing the entry; dev stop reads it from the entry or --name. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Piped, it is the last field of each line; in human output it follows the node and directory. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Amends the per-directory record and dev url/dev stop decisions, and updates local-dev, the guides and the core-concepts skill. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Alchemy keeps the stage feature/x inside the folder of the stage feature. Removing the whole folder on --fresh of feature also wiped feature/x, so its next run minted new values against instances its record still held. Teardown now removes only the stage's own files, and its folder once empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
The move ran only inside prisma dev. After the upgrade, prisma dev stop could not see an app started with --detach under the previous version and failed with DEV.NOT_STARTED_HERE while the app kept running. The local target's current lookup now runs the same idempotent move first. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
On a case-insensitive filesystem, such as the default on macOS, Dev and dev share one folder, so prisma dev --environment Dev reused dev's copy and --fresh deleted it. The first prisma dev in an environment now writes the exact name into the folder, --fresh keeps it, and dev, dev url, dev stop and the log operation fail with DEV.ENVIRONMENT_NAME_MISMATCH when it differs, before anything is torn down or read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Each layer was tested on its own, but nothing ran the real prisma dev pipeline twice in one directory. The detach script now starts test beside dev and checks that dev url gives each its own URL, that --fresh on test keeps dev's bucket object, and that stopping test leaves dev answering. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Writing the name before teardown turned an unwritable .prisma-composer into a raw ENOTDIR instead of DEV.STACK_WRITE_FAILED. The name is still checked before teardown, and is now written in the step that already reports a failed write of the environment's folder. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
So a first run after the upgrade with a name differing only in case is refused instead of taking over dev's data. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
✅ Gizmo reviewed 8a1f601 — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughThis PR makes each environment name ( Local dev (lowering + extensions packages). Dev state (instance record, env values, secrets, buckets) moves into per-environment folders keyed by a URL-encoded environment name, each stamped with its exact name to catch case-collisions on case-insensitive filesystems ( The local-target seam. The Upgrade migration. Docs and skills. The design decision records, Tests. Coverage spans the narrow layers: migration of a pre-C3 fixture folder, per-environment isolation (the detach test now runs two environments side by side), name-addressed Known limitations acknowledged in the description: the shared |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
commit: |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
New findings: 🟡 2 minor · trace
Findings outside the diff
- 🟡 Minor · correctness packages/0-framework/2-authoring/node/src/control/build.ts — Build adapters' working folder
.prisma-composer/artifacts/<address>/is shared by every environment, racing concurrentprisma devruns
The PR's headline claim is that two environments of one app run at once in one folder (acceptance criterion 1), but the build adapters' working folder is still shared by every environment:nextjs()andnode()build into<cwd>/.prisma-composer/artifacts/<address>/(packages/0-framework/2-authoring/nextjs/src/control/build.ts:286, packages/0-framework/2-authoring/node/src/control/build.ts:417 — untouched by this PR). Twoprisma dev --environmentprocesses starting at the same moment assemble into the same per-address folder concurrently. The Deployment provider's own artifact unpack was made per-environment and race-safe by hash in this PR, so this is the one remaining shared root. The PR description lists it under "Known, not fixed here"; recording it so it is tracked against the files that own the path.
Recommended fix: Scope the adapters' workDir by environment too (e.g.<cwd>/.prisma-composer/artifacts/<environment>/<address>/, or under the environment's dev folder like the Deployment provider's artifacts), or make the assembler take the environment into the working-directory layout it documents at core/src/control/deploy.ts:251.
devAttach runs the move, so log on a folder written before environments had folders finds the running app instead of reporting nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Brings in ADR-0059 (environment, not stage), the stage-to-environment rename (#390), the node-addressing close-out (#391), v0.35.0 (#389) and prisma dev --environment (#392). The secrets behaviour follows each environment: the dev preflight keeps its fingerprint key in the environment folder, and deletes a leftover secrets.json both there and in the pre-environment folder. Moving pre-environment state into dev no longer moves secrets.json; it deletes it. Tests pass the environment, and our docs say environment where main renamed stage and environment variables where they mean variables. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before this change, a folder held one local copy of each app.
--environmentwas accepted but every name shared that copy. Running another app stopped the previous one.dev urlanddev stopacted on whichever app ran last.Decision: each environment name is a complete, separate local copy
prisma dev --environment <name>runs the whole app as that environment, with its own services, databases, buckets and ports. The default isdev. Two environments of one app run at once in one folder. Elsewhere an environment is a place the app runs with its own data, and the usual reason to name one locally is a clean copy for tests that leaves working data alone.Where each copy lives
Everything that belongs to one copy moves into
.prisma-composer/dev/<environment>/: the record of local instances, the environment variable values, the placeholder secrets, the generated stack file, the artifacts and the bucket objects. The folder name is URL-encoded, because a name may contain/. Alchemy runs with--stage <environment>, so its state is already separate. Each instance gets acomposer.environmentlabel, andemulator listshows the environment at the end of each line.Commands act on what you name
The record loses its
currentapp. Nothing is stopped when another app or environment starts.dev url <address>takes the app from the address (shop.apiis the appshop) and never imports the entry.dev stoptakes the app from the config's entry or--name, asprisma devanddeploy listdo.--environment, defaultdev. An app that never ran in that environment fails withDEV.NOT_STARTED_HERE.--freshdeletes only the named environment's copy of the app. It keeps the Alchemy state of nested stages such asfeature/x.Upgrading keeps your data
The first
prisma dev,dev urlordev stopafter the upgrade moves the folder's existing record, environment variables, secrets and bucket objects intodev/. Databases, ports and objects survive. This overrides the per-directory record decision's rule that local state is never migrated, following the full-address decision, which rewrote the record.Two smaller safeguards
Devanddevwould share a folder. Each folder now records its environment's exact name, and a different name is refused withDEV.ENVIRONMENT_NAME_MISMATCH.prisma devnow runs the extension version check thatdeployruns, refusing an incompatible local target withDEPS.EXTENSION_INCOMPATIBLE.Docs
Amendment notes on the per-directory record decision, the
dev url/dev stopdecision and the control subpath decision.local-dev.md,deploy-cli.md, the glossary, the running-locally and deploying guides, and the core-concepts skill are updated.Verification
pnpm build,typecheck,lintand every package's tests pass. The integration tests pass, and the detach test now runs two environments side by side.Known, not fixed here
0.35.0-devprereleases contain the environment rename but ignore the environment locally, and they pass the extension version check. Prereleases are not a compatibility promise..prisma-composer/artifacts/<address>/, is still shared by every environment, so two environments starting at the same moment write to it together.Alternatives considered
dev stop --environment teststops every app run astestin the folder. Rejected: the command must know which app it acts on.dev urlreads the app from the config's entry. Rejected: the full address already names the app, and reading the entry means importing the module.Agent: achilles-41
🤖 Generated with Claude Code