Repository navigation
Run prisma deploy through alchemy/Alchemist in the prisma process - #405
Draft
wmadden-electric wants to merge 5 commits into
Draft
wmadden-electric wants to merge 5 commits into
wmadden-electric wants to merge 5 commits into
Conversation
prisma deploy and the deploy operation now lower the app and call Alchemist.plan and Alchemist.apply in process. No alchemy.run.ts is written and no Alchemy child is spawned. destroy and prisma dev keep the stack file. - lower() takes containers and preflight payloads as values; extensions read their payload as LowerContext.preflight. The env transports stay for the stack file. - The report hook returns the summary as a value. - Alchemy events become apply-resource steps under deploy.apply; log lines become messages. - Failures are DEPLOY.ENGINE_FAILED with the cause; Ctrl-C is DEPLOY.INTERRUPTED and closes the scope, releasing the lease. - prisma deploy needs PRISMA_SERVICE_TOKEN in the environment (DEPLOY.SERVICE_TOKEN_REQUIRED): cli-engine 0.9.0 has no public way to hand a command the active access token. - convergeInProcess is the function slice 3 (dev) reuses. - scratch-stack test harness rebuilt on alchemy/Alchemist. - ADR-0064 supersedes ADR-0007 for deploy; amends ADR-0038/0043/0044. 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>
…state - Load lower and convergeInProcess from the app's own @prisma/composer (new @prisma/composer/internal/converge entry), resolved from the app directory; DEPS.ENGINE_UNRESOLVABLE when it cannot be loaded. - lower() takes containers and preflight payloads as required values; transportedLowerInputs() reads both transports for the generated stack files. Core invariant 4 pins process.env to that helper. - convergeInProcess refuses a second concurrent run (DEPLOY.CONVERGE_RUNNING) and a worker thread that would need chdir (DEPLOY.WORKER_THREAD); every process state change is inside the try; Alchemy interaction output goes to stderr; it takes the operation and returns typed failure reasons. - The console redirect moved to the prisma deploy command. - Messages, the engine failure and stack-building errors are redacted. - The service-token check moved into the operation, before preflight and ensure. The command passes a token only for an environment credential, with that credential's workspace, and PRISMA_WORKSPACE_ID is removed when it names none. credentials carries the token; convergeEnv is gone. - family/converge.ts is now family/dev-converge-child.ts. - Docs: ADR-0044 registry, ADR-0064, ADR-0043, ADR-0049, ADR-0062, build-reporting.md, deploy-cli.md and the deploying guide. 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>
|
⏸️ Gizmo skipped the automatic review of bfa4539 because this pull request is a draft. It will review automatically once the PR is marked ready for review.
|
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
CodeRabbit Verify
|
commit: |
- Rename the app-loaded pair to AppConverge / loadAppConverge and the code to DEPS.CONVERGE_UNRESOLVABLE; add "converge" to the glossary. - loadAppConverge refuses an app @prisma/composer at a version other than the host's (DEPS.CONVERGE_VERSION_MISMATCH, naming both), and resolves the install from the directory of prisma.config.ts. - A rejected converge promise is DEPLOY.ENGINE_FAILED. - The one-converge-per-process flag lives on globalThis under a Symbol.for key, so every install shares it. - withProcessState restores the environment before the directory, and the running flag is set inside the try that clears it. - An interrupted prisma deploy reports DEPLOY.INTERRUPTED as a message and ends with the engine abort, so it exits 130. 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>
…on a failed chdir - @prisma/composer/internal/converge-contract exports CONVERGE_CONTRACT; loadAppConverge reads it before loading the converge and refuses a different number with DEPS.CONVERGE_CONTRACT_MISMATCH, naming both contracts and both versions and saying which side to upgrade. Package versions may differ. - A failed chdir back to a removed directory no longer replaces the converge outcome. - ADR-0064, ADR-0044, the ADR index, deploy-cli.md, the glossary and the deploying guide follow. 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>
…my-deploy-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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prisma deploynow runs Alchemy inside theprismaprocess throughalchemy/Alchemist(plan, thenapply). It no longer writes.prisma-composer/alchemy.run.tsor spawns the Alchemy CLI.destroyanddevare unchanged;devmoves in the next pull request.Stacked on #404. Draft: do not merge before #404.
What changes for users
PRISMA_SERVICE_TOKENin the environment. Aprisma loginsession alone now fails early withDEPLOY.SERVICE_TOKEN_REQUIRED.@prisma/cli-enginegives a command no way to read the signed-in token; it only ever wrote it into a child's environment. CI and the e2e workflow already set the token. The code is marked temporary until the engine offers an in-process credentials need.DEPLOY.ENGINE_FAILED, not the Alchemy child's exit status. Ctrl-C prints "The deploy was interrupted. Deploy again to finish." and exits 130 with the engine'sCLI.ABORTED; the state-store lease is released, so the next deploy does not wait.--jsonoutput.How it works
lowerandconvergeInProcessfrom the app's@prisma/composerinstall (new entry@prisma/composer/internal/converge), found from the directory of the app'sprisma.config.ts, so the app's extensions and Alchemy share one copy ofalchemy. If the entry cannot be loaded:DEPS.CONVERGE_UNRESOLVABLE. The host first reads the app'sCONVERGE_CONTRACTnumber (@prisma/composer/internal/converge-contract) and refuses a different one withDEPS.CONVERGE_CONTRACT_MISMATCH. Package versions may differ, because theprismaCLI releases on its own schedule; the number changes only when the data passed between host and app changes.lower()takes containers and preflight results as values. Only the stack files that destroy and dev still generate read them from the environment, through one helper.convergeInProcesssets the deploy's environment and working directory for the run, sends Alchemy's own output to stderr, and restores everything on every exit path. A second concurrent converge in the same process is refused (DEPLOY.CONVERGE_RUNNING), even across two installs.ADR-0064 records the decision. It supersedes ADR-0007 for deploy and amends ADR-0038, 0043, 0044, 0049 and 0062.
Alternatives considered
alchemy.run.tsand load it withAlchemist.importStack. Rejected: writing code only to import it back is a detour.SigilRendererfor output. Rejected: it would give deploy a second output format and nothing in--jsonmode.Manual test
Against real Prisma Cloud with
examples/bucket: deploy (27s), Ctrl-C during a second deploy (exit 130), a third deploy straight after (23s, no lease wait),--jsonoutput (every line valid JSON), destroy (still the child path).Known gaps
prisma logindeploys, above.alchemy/Util/LogRecord,alchemy/Interaction). We will ask Alchemy to expose them fromalchemy/Alchemist.Agent: maat-73
🤖 Generated with Claude Code